Merge branch 'worktree-agent-a6c7d57da30a90b4f'

This commit is contained in:
2026-10-25 15:24:28 +01:00
35 changed files with 4698 additions and 3 deletions
+64
View File
@@ -0,0 +1,64 @@
// Enterprise APIs page: thin client over /google/enterprise/*. Every Google
// call is a POST; the status route says whether a credential is configured.
(function () {
"use strict";
var $ = function (id) { return document.getElementById(id); };
var out = $("e-out"), err = $("e-error");
function show(text, isError) {
(isError ? err : out).textContent = text;
if (isError) out.textContent = ""; else err.textContent = "";
}
function request(method, path, body) {
var opts = { method: method };
if (body !== undefined) {
opts.headers = { "Content-Type": "application/json" };
opts.body = JSON.stringify(body);
}
return fetch(path, opts).then(function (res) {
return res.text().then(function (text) {
if (!res.ok) {
var msg = "HTTP " + res.status;
try { var j = JSON.parse(text); msg = (j.error || "") + ": " + (j.message || msg); } catch (e) {}
throw new Error(msg);
}
return JSON.parse(text);
});
});
}
function json(id) {
var v = $(id).value.trim();
return v ? JSON.parse(v) : undefined;
}
function run(promise) {
promise.then(function (j) { show(JSON.stringify(j, null, 2), false); })
.catch(function (e) { show(e.message, true); });
}
$("e-find").addEventListener("click", function () {
var path = "/google/enterprise/calls?api=" + encodeURIComponent($("e-api").value) +
"&q=" + encodeURIComponent($("e-q").value);
run(request("GET", path));
});
$("e-run").addEventListener("click", function () {
var body;
try {
body = {
api: $("e-api").value,
rpc: $("e-rpc").value.trim(),
path: json("e-path") || {},
query: json("e-query") || {},
confirm: $("e-confirm").checked
};
var b = json("e-body");
if (b !== undefined) body.body = b;
} catch (e) { show("Invalid JSON: " + e.message, true); return; }
run(request("POST", "/google/enterprise/call", body));
});
request("GET", "/google/enterprise/status").then(function (s) {
$("e-config").textContent = s.configured && s.project_set
? "Google credential and project are set. " + s.calls + " calls available."
: "Not configured: set a Google credential and GOOGLE_CLOUD_PROJECT to call Google.";
}).catch(function () { $("e-config").textContent = "Status unavailable."; });
})();