@agentstep/gateway 0.5.34 → 0.5.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gateway.js +1757 -1343
- package/package.json +1 -1
package/dist/gateway.js
CHANGED
|
@@ -152880,788 +152880,6 @@ var init_chunk_REHIJQUD = __esm({
|
|
|
152880
152880
|
}
|
|
152881
152881
|
});
|
|
152882
152882
|
|
|
152883
|
-
// ../agent-sdk/dist/chunk-7XQLG5P2.js
|
|
152884
|
-
var BUILT_IN_TOOL_NAMES;
|
|
152885
|
-
var init_chunk_7XQLG5P2 = __esm({
|
|
152886
|
-
"../agent-sdk/dist/chunk-7XQLG5P2.js"() {
|
|
152887
|
-
"use strict";
|
|
152888
|
-
BUILT_IN_TOOL_NAMES = [
|
|
152889
|
-
"Bash",
|
|
152890
|
-
"Read",
|
|
152891
|
-
"Write",
|
|
152892
|
-
"Edit",
|
|
152893
|
-
"Glob",
|
|
152894
|
-
"Grep",
|
|
152895
|
-
"WebFetch",
|
|
152896
|
-
"WebSearch",
|
|
152897
|
-
"ToolSearch",
|
|
152898
|
-
"Skill",
|
|
152899
|
-
"Agent",
|
|
152900
|
-
"NotebookEdit",
|
|
152901
|
-
"TodoWrite"
|
|
152902
|
-
];
|
|
152903
|
-
}
|
|
152904
|
-
});
|
|
152905
|
-
|
|
152906
|
-
// ../agent-sdk/dist/chunk-FX2AEKOV.js
|
|
152907
|
-
function resolveToolset(tools) {
|
|
152908
|
-
const customToolNames = /* @__PURE__ */ new Set();
|
|
152909
|
-
let builtInEnabled = new Set(BUILT_IN_TOOL_NAMES);
|
|
152910
|
-
let hadAgentToolset = false;
|
|
152911
|
-
for (const tool of tools) {
|
|
152912
|
-
if (tool.type === "agent_toolset_20260401") {
|
|
152913
|
-
hadAgentToolset = true;
|
|
152914
|
-
const defaultEnabled = tool.default_config?.enabled ?? true;
|
|
152915
|
-
if (!defaultEnabled) {
|
|
152916
|
-
builtInEnabled = /* @__PURE__ */ new Set();
|
|
152917
|
-
}
|
|
152918
|
-
for (const cfg of tool.configs ?? []) {
|
|
152919
|
-
const raw2 = cfg.name;
|
|
152920
|
-
const name = BUILT_IN_TOOL_NAMES.find(
|
|
152921
|
-
(n) => n.toLowerCase() === raw2.toLowerCase()
|
|
152922
|
-
) ?? raw2;
|
|
152923
|
-
if (!BUILT_IN_TOOL_NAMES.includes(name)) continue;
|
|
152924
|
-
if (cfg.enabled === false) {
|
|
152925
|
-
builtInEnabled.delete(name);
|
|
152926
|
-
} else if (cfg.enabled === true) {
|
|
152927
|
-
builtInEnabled.add(name);
|
|
152928
|
-
}
|
|
152929
|
-
}
|
|
152930
|
-
} else if (tool.type === "custom") {
|
|
152931
|
-
customToolNames.add(tool.name);
|
|
152932
|
-
}
|
|
152933
|
-
}
|
|
152934
|
-
if (!hadAgentToolset) {
|
|
152935
|
-
builtInEnabled = /* @__PURE__ */ new Set();
|
|
152936
|
-
}
|
|
152937
|
-
const allowedTools = Array.from(builtInEnabled);
|
|
152938
|
-
const disallowedTools = BUILT_IN_TOOL_NAMES.filter((n) => !builtInEnabled.has(n));
|
|
152939
|
-
return { allowedTools, disallowedTools, customToolNames };
|
|
152940
|
-
}
|
|
152941
|
-
var init_chunk_FX2AEKOV = __esm({
|
|
152942
|
-
"../agent-sdk/dist/chunk-FX2AEKOV.js"() {
|
|
152943
|
-
"use strict";
|
|
152944
|
-
init_chunk_7XQLG5P2();
|
|
152945
|
-
}
|
|
152946
|
-
});
|
|
152947
|
-
|
|
152948
|
-
// ../agent-sdk/dist/chunk-YJCH35J4.js
|
|
152949
|
-
function buildClaudeArgs(input) {
|
|
152950
|
-
const cfg = getConfig();
|
|
152951
|
-
const policy = input.agent.permission_policy;
|
|
152952
|
-
const permissionMode = input.confirmationMode ? "default" : policy ? "default" : "bypassPermissions";
|
|
152953
|
-
const argv = [
|
|
152954
|
-
"-p",
|
|
152955
|
-
"--output-format",
|
|
152956
|
-
"stream-json",
|
|
152957
|
-
"--verbose",
|
|
152958
|
-
"--permission-mode",
|
|
152959
|
-
permissionMode
|
|
152960
|
-
];
|
|
152961
|
-
const maxTurns = input.maxTurns ?? cfg.agentMaxTurns;
|
|
152962
|
-
if (maxTurns > 0) {
|
|
152963
|
-
argv.push("--max-turns", String(maxTurns));
|
|
152964
|
-
}
|
|
152965
|
-
if (input.claudeSessionId) {
|
|
152966
|
-
argv.push("--resume", input.claudeSessionId);
|
|
152967
|
-
}
|
|
152968
|
-
const tools = resolveToolset(input.agent.tools);
|
|
152969
|
-
let systemPrompt = withGatewayPreamble(input.agent.system, input.memoryStores);
|
|
152970
|
-
if (tools.customToolNames.size > 0) {
|
|
152971
|
-
const toolList = Array.from(tools.customToolNames).map((name) => `mcp__tool-bridge__${name}`).join(", ");
|
|
152972
|
-
systemPrompt += `
|
|
152973
|
-
|
|
152974
|
-
Your custom tools are: ${toolList}. Call them by these exact names \u2014 do not use ToolSearch to find them.`;
|
|
152975
|
-
}
|
|
152976
|
-
argv.push("--system-prompt", systemPrompt);
|
|
152977
|
-
if (input.agent.model) {
|
|
152978
|
-
argv.push("--model", input.agent.model.id);
|
|
152979
|
-
}
|
|
152980
|
-
const mcpToolNames = Array.from(tools.customToolNames).map(
|
|
152981
|
-
(name) => `mcp__tool-bridge__${name}`
|
|
152982
|
-
);
|
|
152983
|
-
const policyAllowed = policy?.always_allow ?? [];
|
|
152984
|
-
const allAllowed = [...tools.allowedTools, ...mcpToolNames, ...policyAllowed];
|
|
152985
|
-
if (allAllowed.length) {
|
|
152986
|
-
argv.push("--allowed-tools", allAllowed.join(","));
|
|
152987
|
-
}
|
|
152988
|
-
if (tools.disallowedTools.length) {
|
|
152989
|
-
argv.push("--disallowed-tools", tools.disallowedTools.join(","));
|
|
152990
|
-
}
|
|
152991
|
-
if (input.agent.model_config?.speed === "fast") {
|
|
152992
|
-
argv.push("--fast");
|
|
152993
|
-
}
|
|
152994
|
-
if (input.agent.mcp_servers && input.agent.mcp_servers.length > 0) {
|
|
152995
|
-
const mcpRecord = {};
|
|
152996
|
-
for (const s of input.agent.mcp_servers) {
|
|
152997
|
-
const { name, ...rest } = s;
|
|
152998
|
-
mcpRecord[name] = rest;
|
|
152999
|
-
}
|
|
153000
|
-
argv.push(
|
|
153001
|
-
"--mcp-config",
|
|
153002
|
-
JSON.stringify({ mcpServers: mcpRecord })
|
|
153003
|
-
);
|
|
153004
|
-
}
|
|
153005
|
-
return argv;
|
|
153006
|
-
}
|
|
153007
|
-
function buildClaudeAuthEnv() {
|
|
153008
|
-
const cfg = getConfig();
|
|
153009
|
-
const env3 = {};
|
|
153010
|
-
const token = cfg.claudeToken || cfg.anthropicApiKey;
|
|
153011
|
-
if (token) {
|
|
153012
|
-
if (token.startsWith("sk-ant-oat")) {
|
|
153013
|
-
env3.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
153014
|
-
} else {
|
|
153015
|
-
env3.ANTHROPIC_API_KEY = token;
|
|
153016
|
-
}
|
|
153017
|
-
}
|
|
153018
|
-
return env3;
|
|
153019
|
-
}
|
|
153020
|
-
var init_chunk_YJCH35J4 = __esm({
|
|
153021
|
-
"../agent-sdk/dist/chunk-YJCH35J4.js"() {
|
|
153022
|
-
"use strict";
|
|
153023
|
-
init_chunk_YE2RMJY7();
|
|
153024
|
-
init_chunk_FX2AEKOV();
|
|
153025
|
-
init_chunk_6EIONZ7F();
|
|
153026
|
-
}
|
|
153027
|
-
});
|
|
153028
|
-
|
|
153029
|
-
// ../agent-sdk/dist/chunk-CY6AWCC6.js
|
|
153030
|
-
function generatePermissionHookScript() {
|
|
153031
|
-
return `#!/usr/bin/env node
|
|
153032
|
-
// Auto-generated PermissionRequest hook for tool confirmation bridge.
|
|
153033
|
-
// Reads hook JSON from stdin, writes request.json + pending sentinel,
|
|
153034
|
-
// polls for response.json, then outputs the hook response to stdout.
|
|
153035
|
-
import { readFileSync, writeFileSync, unlinkSync, existsSync, watchFile, unwatchFile } from 'node:fs';
|
|
153036
|
-
|
|
153037
|
-
const REQUEST_PATH = ${JSON.stringify(PERMISSION_BRIDGE_REQUEST_PATH)};
|
|
153038
|
-
const RESPONSE_PATH = ${JSON.stringify(PERMISSION_BRIDGE_RESPONSE_PATH)};
|
|
153039
|
-
const PENDING_PATH = ${JSON.stringify(PERMISSION_BRIDGE_PENDING_PATH)};
|
|
153040
|
-
const TIMEOUT_MS = 120000; // 2 minutes
|
|
153041
|
-
|
|
153042
|
-
// Read hook input from stdin
|
|
153043
|
-
let input = '';
|
|
153044
|
-
process.stdin.setEncoding('utf8');
|
|
153045
|
-
process.stdin.on('data', (chunk) => { input += chunk; });
|
|
153046
|
-
process.stdin.on('end', () => {
|
|
153047
|
-
let hookInput;
|
|
153048
|
-
try {
|
|
153049
|
-
hookInput = JSON.parse(input);
|
|
153050
|
-
} catch (e) {
|
|
153051
|
-
// If we can't parse the input, allow by default to avoid blocking
|
|
153052
|
-
console.error('[permission-hook] failed to parse stdin:', e.message);
|
|
153053
|
-
outputResult({ behavior: 'allow' });
|
|
153054
|
-
return;
|
|
153055
|
-
}
|
|
153056
|
-
|
|
153057
|
-
// Extract tool details from the PermissionRequest hook payload.
|
|
153058
|
-
// Claude Code sends: { tool_name, tool_input, tool_use_id, ... }
|
|
153059
|
-
const toolName = hookInput.tool_name || hookInput.toolName || 'unknown';
|
|
153060
|
-
const toolInput = hookInput.tool_input || hookInput.toolInput || {};
|
|
153061
|
-
const toolUseId = hookInput.tool_use_id || hookInput.toolUseId || '';
|
|
153062
|
-
|
|
153063
|
-
// Write request.json with tool details
|
|
153064
|
-
writeFileSync(REQUEST_PATH, JSON.stringify({
|
|
153065
|
-
tool_name: toolName,
|
|
153066
|
-
tool_input: toolInput,
|
|
153067
|
-
tool_use_id: toolUseId,
|
|
153068
|
-
}));
|
|
153069
|
-
|
|
153070
|
-
// Create pending sentinel
|
|
153071
|
-
writeFileSync(PENDING_PATH, '');
|
|
153072
|
-
|
|
153073
|
-
// Poll for response.json
|
|
153074
|
-
const startTime = Date.now();
|
|
153075
|
-
let resolved = false;
|
|
153076
|
-
|
|
153077
|
-
const checkResponse = () => {
|
|
153078
|
-
if (resolved) return;
|
|
153079
|
-
if (!existsSync(RESPONSE_PATH)) return;
|
|
153080
|
-
resolved = true;
|
|
153081
|
-
try { unwatchFile(RESPONSE_PATH, pollFn); } catch {}
|
|
153082
|
-
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
153083
|
-
|
|
153084
|
-
try {
|
|
153085
|
-
const resp = JSON.parse(readFileSync(RESPONSE_PATH, 'utf8'));
|
|
153086
|
-
try { unlinkSync(RESPONSE_PATH); } catch {}
|
|
153087
|
-
try { unlinkSync(PENDING_PATH); } catch {}
|
|
153088
|
-
|
|
153089
|
-
if (resp.result === 'allow') {
|
|
153090
|
-
outputResult({ behavior: 'allow' });
|
|
153091
|
-
} else {
|
|
153092
|
-
outputResult({ behavior: 'deny', message: resp.deny_message || 'User denied tool use' });
|
|
153093
|
-
}
|
|
153094
|
-
} catch (e) {
|
|
153095
|
-
console.error('[permission-hook] failed to read response:', e.message);
|
|
153096
|
-
// On error, deny to be safe
|
|
153097
|
-
try { unlinkSync(PENDING_PATH); } catch {}
|
|
153098
|
-
outputResult({ behavior: 'deny', message: 'Permission hook error: ' + e.message });
|
|
153099
|
-
}
|
|
153100
|
-
};
|
|
153101
|
-
|
|
153102
|
-
const pollFn = () => checkResponse();
|
|
153103
|
-
|
|
153104
|
-
// Check immediately in case response was pre-written
|
|
153105
|
-
checkResponse();
|
|
153106
|
-
if (resolved) return;
|
|
153107
|
-
|
|
153108
|
-
// Use fs.watchFile for reliable polling
|
|
153109
|
-
watchFile(RESPONSE_PATH, { interval: 200 }, pollFn);
|
|
153110
|
-
|
|
153111
|
-
// Timeout: deny after TIMEOUT_MS
|
|
153112
|
-
const timeoutTimer = setTimeout(() => {
|
|
153113
|
-
if (resolved) return;
|
|
153114
|
-
resolved = true;
|
|
153115
|
-
try { unwatchFile(RESPONSE_PATH, pollFn); } catch {}
|
|
153116
|
-
try { unlinkSync(PENDING_PATH); } catch {}
|
|
153117
|
-
outputResult({ behavior: 'deny', message: 'Permission request timed out after ' + (TIMEOUT_MS / 1000) + 's' });
|
|
153118
|
-
}, TIMEOUT_MS);
|
|
153119
|
-
});
|
|
153120
|
-
|
|
153121
|
-
function outputResult(decision) {
|
|
153122
|
-
const output = JSON.stringify({
|
|
153123
|
-
hookSpecificOutput: {
|
|
153124
|
-
hookEventName: 'PermissionRequest',
|
|
153125
|
-
decision: decision,
|
|
153126
|
-
},
|
|
153127
|
-
});
|
|
153128
|
-
process.stdout.write(output);
|
|
153129
|
-
process.exit(0);
|
|
153130
|
-
}
|
|
153131
|
-
`;
|
|
153132
|
-
}
|
|
153133
|
-
function buildPermissionHooksConfig() {
|
|
153134
|
-
return {
|
|
153135
|
-
hooks: {
|
|
153136
|
-
PermissionRequest: [
|
|
153137
|
-
{
|
|
153138
|
-
type: "command",
|
|
153139
|
-
command: `node ${PERMISSION_HOOK_SCRIPT_PATH}`
|
|
153140
|
-
}
|
|
153141
|
-
]
|
|
153142
|
-
}
|
|
153143
|
-
};
|
|
153144
|
-
}
|
|
153145
|
-
var PERMISSION_BRIDGE_DIR, PERMISSION_HOOK_SCRIPT_PATH, PERMISSION_BRIDGE_REQUEST_PATH, PERMISSION_BRIDGE_RESPONSE_PATH, PERMISSION_BRIDGE_PENDING_PATH;
|
|
153146
|
-
var init_chunk_CY6AWCC6 = __esm({
|
|
153147
|
-
"../agent-sdk/dist/chunk-CY6AWCC6.js"() {
|
|
153148
|
-
"use strict";
|
|
153149
|
-
PERMISSION_BRIDGE_DIR = "/tmp/permission-bridge";
|
|
153150
|
-
PERMISSION_HOOK_SCRIPT_PATH = `${PERMISSION_BRIDGE_DIR}/hook.mjs`;
|
|
153151
|
-
PERMISSION_BRIDGE_REQUEST_PATH = `${PERMISSION_BRIDGE_DIR}/request.json`;
|
|
153152
|
-
PERMISSION_BRIDGE_RESPONSE_PATH = `${PERMISSION_BRIDGE_DIR}/response.json`;
|
|
153153
|
-
PERMISSION_BRIDGE_PENDING_PATH = `${PERMISSION_BRIDGE_DIR}/pending`;
|
|
153154
|
-
}
|
|
153155
|
-
});
|
|
153156
|
-
|
|
153157
|
-
// ../agent-sdk/dist/chunk-VRRGSQI7.js
|
|
153158
|
-
function generateBridgeScript() {
|
|
153159
|
-
return `#!/bin/bash
|
|
153160
|
-
# Auto-generated MCP stdio server for custom tool bridge.
|
|
153161
|
-
# Pure bash \u2014 no Node.js dependency. Instant startup on Firecracker VMs.
|
|
153162
|
-
|
|
153163
|
-
TOOLS_PATH="${TOOL_BRIDGE_TOOLS_PATH}"
|
|
153164
|
-
REQUEST_PATH="${TOOL_BRIDGE_REQUEST_PATH}"
|
|
153165
|
-
RESPONSE_PATH="${TOOL_BRIDGE_RESPONSE_PATH}"
|
|
153166
|
-
PENDING_PATH="${TOOL_BRIDGE_PENDING_PATH}"
|
|
153167
|
-
|
|
153168
|
-
send_response() {
|
|
153169
|
-
printf '%s\\n' "$1"
|
|
153170
|
-
}
|
|
153171
|
-
|
|
153172
|
-
TOOLS_LIST_JSON=""
|
|
153173
|
-
if [ -f "$TOOLS_PATH" ]; then
|
|
153174
|
-
TOOLS_LIST_JSON=$(sed 's/input_schema/inputSchema/g' "$TOOLS_PATH")
|
|
153175
|
-
fi
|
|
153176
|
-
|
|
153177
|
-
handle_request() {
|
|
153178
|
-
local body="$1"
|
|
153179
|
-
local method id
|
|
153180
|
-
method=$(echo "$body" | grep -o '"method":"[^"]*"' | head -1 | cut -d'"' -f4)
|
|
153181
|
-
id=$(echo "$body" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
153182
|
-
|
|
153183
|
-
case "$method" in
|
|
153184
|
-
initialize)
|
|
153185
|
-
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"protocolVersion":"2025-11-25","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"tool-bridge","version":"1.0.0"}}}'
|
|
153186
|
-
;;
|
|
153187
|
-
notifications/*) ;;
|
|
153188
|
-
ping)
|
|
153189
|
-
[ -n "$id" ] && send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{}}'
|
|
153190
|
-
;;
|
|
153191
|
-
tools/list)
|
|
153192
|
-
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"tools":'"$TOOLS_LIST_JSON"'}}'
|
|
153193
|
-
;;
|
|
153194
|
-
tools/call)
|
|
153195
|
-
local tool_name
|
|
153196
|
-
tool_name=$(echo "$body" | grep -o '"name":"[^"]*"' | tail -1 | cut -d'"' -f4)
|
|
153197
|
-
|
|
153198
|
-
# Reject unknown tools immediately (don't wait for gateway response)
|
|
153199
|
-
if [ -n "$TOOLS_LIST_JSON" ]; then
|
|
153200
|
-
if ! echo "$TOOLS_LIST_JSON" | grep -q "\\"$tool_name\\""; then
|
|
153201
|
-
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"content":[{"type":"text","text":"Unknown tool: '"$tool_name"'"}],"isError":true}}'
|
|
153202
|
-
return
|
|
153203
|
-
fi
|
|
153204
|
-
fi
|
|
153205
|
-
|
|
153206
|
-
# Replay case: response.json already exists (--resume re-entry)
|
|
153207
|
-
if [ -f "$RESPONSE_PATH" ]; then
|
|
153208
|
-
local rdata
|
|
153209
|
-
rdata=$(cat "$RESPONSE_PATH" | tr -d '\\n' | sed 's/\\\\/\\\\\\\\/g; s/"/\\\\"/g')
|
|
153210
|
-
rm -f "$RESPONSE_PATH"
|
|
153211
|
-
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"content":[{"type":"text","text":"'"$rdata"'"}],"isError":false}}'
|
|
153212
|
-
return
|
|
153213
|
-
fi
|
|
153214
|
-
|
|
153215
|
-
# Write the full MCP request body to request.json.
|
|
153216
|
-
# The driver parses tool_use_id, name, and input from it.
|
|
153217
|
-
# Previous approach used grep to extract arguments, which broke on
|
|
153218
|
-
# nested JSON objects (truncated at first closing brace).
|
|
153219
|
-
printf '%s' "$body" > "$REQUEST_PATH"
|
|
153220
|
-
touch "$PENDING_PATH"
|
|
153221
|
-
|
|
153222
|
-
# Poll for response.json (200ms interval, 5min timeout)
|
|
153223
|
-
local elapsed=0
|
|
153224
|
-
while [ $elapsed -lt 1500 ]; do
|
|
153225
|
-
if [ -f "$RESPONSE_PATH" ]; then
|
|
153226
|
-
local rdata
|
|
153227
|
-
rdata=$(cat "$RESPONSE_PATH" | tr -d '\\n' | sed 's/\\\\/\\\\\\\\/g; s/"/\\\\"/g')
|
|
153228
|
-
rm -f "$RESPONSE_PATH" "$PENDING_PATH"
|
|
153229
|
-
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"content":[{"type":"text","text":"'"$rdata"'"}],"isError":false}}'
|
|
153230
|
-
return
|
|
153231
|
-
fi
|
|
153232
|
-
sleep 0.2
|
|
153233
|
-
elapsed=$((elapsed + 1))
|
|
153234
|
-
done
|
|
153235
|
-
# Timeout
|
|
153236
|
-
rm -f "$PENDING_PATH"
|
|
153237
|
-
send_response '{"jsonrpc":"2.0","id":'"$id"',"error":{"code":-32603,"message":"Timeout waiting for tool response"}}'
|
|
153238
|
-
;;
|
|
153239
|
-
*)
|
|
153240
|
-
[ -n "$id" ] && send_response '{"jsonrpc":"2.0","id":'"$id"',"error":{"code":-32601,"message":"Method not found"}}'
|
|
153241
|
-
;;
|
|
153242
|
-
esac
|
|
153243
|
-
}
|
|
153244
|
-
|
|
153245
|
-
# Main loop: handle both raw JSON lines and Content-Length framed messages
|
|
153246
|
-
while IFS= read -r line; do
|
|
153247
|
-
line=\${line%$'\\r'}
|
|
153248
|
-
[ -z "$line" ] && continue
|
|
153249
|
-
case "$line" in
|
|
153250
|
-
Content-Length:*)
|
|
153251
|
-
while IFS= read -r hdr; do hdr=\${hdr%$'\\r'}; [ -z "$hdr" ] && break; done
|
|
153252
|
-
body=$(head -c "\${line#Content-Length: }")
|
|
153253
|
-
handle_request "$body" ;;
|
|
153254
|
-
"{"*) handle_request "$line" ;;
|
|
153255
|
-
esac
|
|
153256
|
-
done
|
|
153257
|
-
`;
|
|
153258
|
-
}
|
|
153259
|
-
function buildBridgeMcpConfig(existingServers) {
|
|
153260
|
-
return {
|
|
153261
|
-
...existingServers,
|
|
153262
|
-
"tool-bridge": {
|
|
153263
|
-
command: "bash",
|
|
153264
|
-
args: [TOOL_BRIDGE_SCRIPT_PATH]
|
|
153265
|
-
}
|
|
153266
|
-
};
|
|
153267
|
-
}
|
|
153268
|
-
function toolsToJson(tools) {
|
|
153269
|
-
return JSON.stringify(
|
|
153270
|
-
tools.map((t2) => ({
|
|
153271
|
-
name: t2.name,
|
|
153272
|
-
description: t2.description,
|
|
153273
|
-
input_schema: t2.input_schema
|
|
153274
|
-
}))
|
|
153275
|
-
);
|
|
153276
|
-
}
|
|
153277
|
-
var TOOL_BRIDGE_DIR, TOOL_BRIDGE_SCRIPT_PATH, TOOL_BRIDGE_TOOLS_PATH, TOOL_BRIDGE_REQUEST_PATH, TOOL_BRIDGE_RESPONSE_PATH, TOOL_BRIDGE_PENDING_PATH;
|
|
153278
|
-
var init_chunk_VRRGSQI7 = __esm({
|
|
153279
|
-
"../agent-sdk/dist/chunk-VRRGSQI7.js"() {
|
|
153280
|
-
"use strict";
|
|
153281
|
-
TOOL_BRIDGE_DIR = "/tmp/tool-bridge";
|
|
153282
|
-
TOOL_BRIDGE_SCRIPT_PATH = `${TOOL_BRIDGE_DIR}/bridge.sh`;
|
|
153283
|
-
TOOL_BRIDGE_TOOLS_PATH = `${TOOL_BRIDGE_DIR}/tools.json`;
|
|
153284
|
-
TOOL_BRIDGE_REQUEST_PATH = `${TOOL_BRIDGE_DIR}/request.json`;
|
|
153285
|
-
TOOL_BRIDGE_RESPONSE_PATH = `${TOOL_BRIDGE_DIR}/response.json`;
|
|
153286
|
-
TOOL_BRIDGE_PENDING_PATH = `${TOOL_BRIDGE_DIR}/pending`;
|
|
153287
|
-
}
|
|
153288
|
-
});
|
|
153289
|
-
|
|
153290
|
-
// ../agent-sdk/dist/chunk-D6RQPBRG.js
|
|
153291
|
-
function createClaudeTranslator(opts) {
|
|
153292
|
-
const toolClass = /* @__PURE__ */ new Map();
|
|
153293
|
-
const toolSpan = /* @__PURE__ */ new Map();
|
|
153294
|
-
const toolMeta = /* @__PURE__ */ new Map();
|
|
153295
|
-
let claudeSessionId = null;
|
|
153296
|
-
let sawInit = false;
|
|
153297
|
-
let sawCustom = false;
|
|
153298
|
-
let turnResult = null;
|
|
153299
|
-
function classify(name) {
|
|
153300
|
-
if (BUILT_IN_SET.has(name)) return "builtin";
|
|
153301
|
-
if (name.startsWith("mcp__")) return "mcp";
|
|
153302
|
-
if (opts.customToolNames.has(name)) return "custom";
|
|
153303
|
-
return "builtin";
|
|
153304
|
-
}
|
|
153305
|
-
function translate(raw2) {
|
|
153306
|
-
const out = [];
|
|
153307
|
-
const type = String(raw2.type ?? "");
|
|
153308
|
-
if (type === "system") {
|
|
153309
|
-
const subtype = raw2.subtype;
|
|
153310
|
-
if (subtype === "init") {
|
|
153311
|
-
if (typeof raw2.session_id === "string") {
|
|
153312
|
-
claudeSessionId = raw2.session_id;
|
|
153313
|
-
}
|
|
153314
|
-
if (!sawInit && opts.isFirstTurn) {
|
|
153315
|
-
sawInit = true;
|
|
153316
|
-
}
|
|
153317
|
-
sawInit = true;
|
|
153318
|
-
}
|
|
153319
|
-
return out;
|
|
153320
|
-
}
|
|
153321
|
-
if (type === "assistant") {
|
|
153322
|
-
const msg = raw2.message ?? {};
|
|
153323
|
-
const blocks = msg.content ?? [];
|
|
153324
|
-
for (const block of blocks) {
|
|
153325
|
-
if (block.type === "text" && typeof block.text === "string") {
|
|
153326
|
-
out.push({
|
|
153327
|
-
type: "agent.message",
|
|
153328
|
-
payload: {
|
|
153329
|
-
content: [{ type: "text", text: block.text }]
|
|
153330
|
-
}
|
|
153331
|
-
});
|
|
153332
|
-
} else if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
153333
|
-
out.push({
|
|
153334
|
-
type: "agent.thinking",
|
|
153335
|
-
payload: {
|
|
153336
|
-
content: [{ type: "thinking", thinking: block.thinking }]
|
|
153337
|
-
}
|
|
153338
|
-
});
|
|
153339
|
-
} else if (block.type === "tool_use" && block.id && block.name) {
|
|
153340
|
-
const cls = classify(block.name);
|
|
153341
|
-
toolClass.set(block.id, cls);
|
|
153342
|
-
let toolSpanId;
|
|
153343
|
-
if (opts.turnSpanId) {
|
|
153344
|
-
toolSpanId = newId("span");
|
|
153345
|
-
toolSpan.set(block.id, toolSpanId);
|
|
153346
|
-
toolMeta.set(block.id, { name: block.name, startMs: Date.now() });
|
|
153347
|
-
out.push({
|
|
153348
|
-
type: "span.tool_call_start",
|
|
153349
|
-
payload: {
|
|
153350
|
-
tool_use_id: block.id,
|
|
153351
|
-
name: block.name,
|
|
153352
|
-
tool_class: cls
|
|
153353
|
-
},
|
|
153354
|
-
spanId: toolSpanId,
|
|
153355
|
-
parentSpanId: opts.turnSpanId
|
|
153356
|
-
});
|
|
153357
|
-
}
|
|
153358
|
-
if (cls === "custom") {
|
|
153359
|
-
sawCustom = true;
|
|
153360
|
-
out.push({
|
|
153361
|
-
type: "agent.custom_tool_use",
|
|
153362
|
-
payload: {
|
|
153363
|
-
tool_use_id: block.id,
|
|
153364
|
-
name: block.name,
|
|
153365
|
-
input: block.input ?? {}
|
|
153366
|
-
},
|
|
153367
|
-
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153368
|
-
});
|
|
153369
|
-
} else if (cls === "mcp") {
|
|
153370
|
-
const parts = block.name.split("__");
|
|
153371
|
-
const serverName = parts[1] ?? "unknown";
|
|
153372
|
-
const toolName = parts.slice(2).join("__") || block.name;
|
|
153373
|
-
out.push({
|
|
153374
|
-
type: "agent.mcp_tool_use",
|
|
153375
|
-
payload: {
|
|
153376
|
-
tool_use_id: block.id,
|
|
153377
|
-
server_name: serverName,
|
|
153378
|
-
tool_name: toolName,
|
|
153379
|
-
input: block.input ?? {}
|
|
153380
|
-
},
|
|
153381
|
-
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153382
|
-
});
|
|
153383
|
-
} else {
|
|
153384
|
-
out.push({
|
|
153385
|
-
type: "agent.tool_use",
|
|
153386
|
-
payload: {
|
|
153387
|
-
tool_use_id: block.id,
|
|
153388
|
-
name: block.name,
|
|
153389
|
-
input: block.input ?? {}
|
|
153390
|
-
},
|
|
153391
|
-
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153392
|
-
});
|
|
153393
|
-
}
|
|
153394
|
-
}
|
|
153395
|
-
}
|
|
153396
|
-
return out;
|
|
153397
|
-
}
|
|
153398
|
-
if (type === "user") {
|
|
153399
|
-
const msg = raw2.message ?? {};
|
|
153400
|
-
const blocks = msg.content ?? [];
|
|
153401
|
-
for (const block of blocks) {
|
|
153402
|
-
if (block.type === "tool_result" && block.tool_use_id) {
|
|
153403
|
-
const cls = toolClass.get(block.tool_use_id);
|
|
153404
|
-
if (cls === "custom") continue;
|
|
153405
|
-
const eventType = cls === "mcp" ? "agent.mcp_tool_result" : "agent.tool_result";
|
|
153406
|
-
const toolSpanId = toolSpan.get(block.tool_use_id);
|
|
153407
|
-
const meta = toolMeta.get(block.tool_use_id);
|
|
153408
|
-
out.push({
|
|
153409
|
-
type: eventType,
|
|
153410
|
-
payload: {
|
|
153411
|
-
tool_use_id: block.tool_use_id,
|
|
153412
|
-
content: block.content ?? null,
|
|
153413
|
-
is_error: block.is_error ?? false
|
|
153414
|
-
},
|
|
153415
|
-
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153416
|
-
});
|
|
153417
|
-
if (toolSpanId && opts.turnSpanId) {
|
|
153418
|
-
const durationMs = meta ? Date.now() - meta.startMs : null;
|
|
153419
|
-
out.push({
|
|
153420
|
-
type: "span.tool_call_end",
|
|
153421
|
-
payload: {
|
|
153422
|
-
tool_use_id: block.tool_use_id,
|
|
153423
|
-
name: meta?.name ?? null,
|
|
153424
|
-
tool_class: cls ?? "builtin",
|
|
153425
|
-
status: block.is_error ? "error" : "ok",
|
|
153426
|
-
duration_ms: durationMs
|
|
153427
|
-
},
|
|
153428
|
-
spanId: toolSpanId,
|
|
153429
|
-
parentSpanId: opts.turnSpanId
|
|
153430
|
-
});
|
|
153431
|
-
toolSpan.delete(block.tool_use_id);
|
|
153432
|
-
toolMeta.delete(block.tool_use_id);
|
|
153433
|
-
}
|
|
153434
|
-
}
|
|
153435
|
-
}
|
|
153436
|
-
return out;
|
|
153437
|
-
}
|
|
153438
|
-
if (type === "result") {
|
|
153439
|
-
const subtype = String(raw2.subtype ?? "success");
|
|
153440
|
-
const usageRaw = raw2.usage ?? {};
|
|
153441
|
-
const usage = {
|
|
153442
|
-
input_tokens: usageRaw.input_tokens ?? 0,
|
|
153443
|
-
output_tokens: usageRaw.output_tokens ?? 0,
|
|
153444
|
-
cache_read_input_tokens: usageRaw.cache_read_input_tokens ?? 0,
|
|
153445
|
-
cache_creation_input_tokens: usageRaw.cache_creation_input_tokens ?? 0,
|
|
153446
|
-
cost_usd: raw2.total_cost_usd ?? 0
|
|
153447
|
-
};
|
|
153448
|
-
let stopReason;
|
|
153449
|
-
if (sawCustom) stopReason = "custom_tool_call";
|
|
153450
|
-
else if (subtype === "error_max_turns") stopReason = "max_turns";
|
|
153451
|
-
else if (subtype === "error_during_execution") stopReason = "error";
|
|
153452
|
-
else stopReason = "end_turn";
|
|
153453
|
-
turnResult = {
|
|
153454
|
-
stopReason,
|
|
153455
|
-
usage,
|
|
153456
|
-
num_turns: raw2.num_turns ?? 1
|
|
153457
|
-
};
|
|
153458
|
-
return out;
|
|
153459
|
-
}
|
|
153460
|
-
return out;
|
|
153461
|
-
}
|
|
153462
|
-
return {
|
|
153463
|
-
translate,
|
|
153464
|
-
getBackendSessionId: () => claudeSessionId,
|
|
153465
|
-
getTurnResult: () => turnResult,
|
|
153466
|
-
sawCustomToolUse: () => sawCustom
|
|
153467
|
-
};
|
|
153468
|
-
}
|
|
153469
|
-
var BUILT_IN_SET;
|
|
153470
|
-
var init_chunk_D6RQPBRG = __esm({
|
|
153471
|
-
"../agent-sdk/dist/chunk-D6RQPBRG.js"() {
|
|
153472
|
-
"use strict";
|
|
153473
|
-
init_chunk_F4WUVOLE();
|
|
153474
|
-
init_chunk_7XQLG5P2();
|
|
153475
|
-
init_ids();
|
|
153476
|
-
BUILT_IN_SET = new Set(BUILT_IN_TOOL_NAMES);
|
|
153477
|
-
}
|
|
153478
|
-
});
|
|
153479
|
-
|
|
153480
|
-
// ../agent-sdk/dist/chunk-J6T3W6RY.js
|
|
153481
|
-
async function installClaudeWrapper(sandboxName, provider) {
|
|
153482
|
-
console.log(`[wrapper] writing ${CLAUDE_WRAPPER_PATH} to ${sandboxName} (${SANDBOX_WRAPPER_SCRIPT4.length} bytes)`);
|
|
153483
|
-
const result = await provider.exec(sandboxName, [
|
|
153484
|
-
"sh",
|
|
153485
|
-
"-c",
|
|
153486
|
-
`cat > ${CLAUDE_WRAPPER_PATH} && chmod +x ${CLAUDE_WRAPPER_PATH} && echo OK`
|
|
153487
|
-
], { stdin: SANDBOX_WRAPPER_SCRIPT4 });
|
|
153488
|
-
console.log(`[wrapper] result: exit=${result.exit_code} stdout="${result.stdout.trim()}" stderr="${result.stderr.trim()}"`);
|
|
153489
|
-
}
|
|
153490
|
-
var CLAUDE_WRAPPER_PATH, SANDBOX_WRAPPER_SCRIPT4;
|
|
153491
|
-
var init_chunk_J6T3W6RY = __esm({
|
|
153492
|
-
"../agent-sdk/dist/chunk-J6T3W6RY.js"() {
|
|
153493
|
-
"use strict";
|
|
153494
|
-
CLAUDE_WRAPPER_PATH = "/tmp/.claude-wrapper";
|
|
153495
|
-
SANDBOX_WRAPPER_SCRIPT4 = `#!/bin/sh
|
|
153496
|
-
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
|
|
153497
|
-
# V8 bytecode cache: Node.js caches compiled JS to disk.
|
|
153498
|
-
# First run builds cache (~55s). Subsequent runs skip V8 compilation (~8s startup).
|
|
153499
|
-
export NODE_COMPILE_CACHE=/tmp/v8-cache
|
|
153500
|
-
mkdir -p /tmp/v8-cache
|
|
153501
|
-
# Install claude CLI if not present
|
|
153502
|
-
if ! command -v claude >/dev/null 2>&1; then npm install -g @anthropic-ai/claude-code; fi
|
|
153503
|
-
claude --version >&2 2>/dev/null || true
|
|
153504
|
-
# Sprites keep-alive: prevent VM suspension during long agent turns.
|
|
153505
|
-
# Only activates if the sprites management socket exists (sprites containers only).
|
|
153506
|
-
SPRITE_SOCK="/.sprite/api.sock"
|
|
153507
|
-
HEARTBEAT_PID=""
|
|
153508
|
-
if [ -S "$SPRITE_SOCK" ]; then
|
|
153509
|
-
# Create task with 5-minute expiry
|
|
153510
|
-
curl -sf --unix-socket "$SPRITE_SOCK" -H "Host: sprite" -X POST http://sprite/v1/tasks -H "Content-Type: application/json" -d '{"name":"agent-turn","expire":"5m"}' >/dev/null 2>&1
|
|
153511
|
-
# Background heartbeat: refresh every 60s
|
|
153512
|
-
(while sleep 60; do
|
|
153513
|
-
curl -sf --unix-socket "$SPRITE_SOCK" -H "Host: sprite" -X PUT http://sprite/v1/tasks/agent-turn -H "Content-Type: application/json" -d '{"expire":"5m"}' >/dev/null 2>&1
|
|
153514
|
-
done) &
|
|
153515
|
-
HEARTBEAT_PID=$!
|
|
153516
|
-
# Cleanup on exit
|
|
153517
|
-
trap 'curl -sf --unix-socket "$SPRITE_SOCK" -H "Host: sprite" -X DELETE http://sprite/v1/tasks/agent-turn >/dev/null 2>&1; [ -n "$HEARTBEAT_PID" ] && kill $HEARTBEAT_PID 2>/dev/null' EXIT
|
|
153518
|
-
fi
|
|
153519
|
-
# Read env vars from stdin until blank line, save remaining stdin to temp file
|
|
153520
|
-
PROMPT_FILE=$(mktemp)
|
|
153521
|
-
while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done
|
|
153522
|
-
cat > "$PROMPT_FILE"
|
|
153523
|
-
# Run as non-root if possible (claude requires non-root for bypassPermissions)
|
|
153524
|
-
if [ "$(id -u)" = "0" ]; then
|
|
153525
|
-
if ! id agent >/dev/null 2>&1; then
|
|
153526
|
-
useradd -m -s /bin/sh agent 2>/dev/null || adduser -D -s /bin/sh agent 2>/dev/null
|
|
153527
|
-
fi
|
|
153528
|
-
chown -R agent /tmp/ 2>/dev/null
|
|
153529
|
-
chown -R agent /home/agent 2>/dev/null
|
|
153530
|
-
# Export env vars to a file for the agent user
|
|
153531
|
-
ENV_FILE=$(mktemp)
|
|
153532
|
-
env | grep -E '^(ANTHROPIC_API_KEY|CLAUDE_CODE_OAUTH_TOKEN|NODE_COMPILE_CACHE|PATH)=' > "$ENV_FILE"
|
|
153533
|
-
chown agent "$ENV_FILE" "$PROMPT_FILE"
|
|
153534
|
-
exec su -s /bin/sh agent -c ". $ENV_FILE && HOME=/home/agent claude $* < $PROMPT_FILE; rm -f $ENV_FILE $PROMPT_FILE"
|
|
153535
|
-
fi
|
|
153536
|
-
# Run claude and clean up temp file (no exec \u2014 let cleanup run)
|
|
153537
|
-
claude "$@" < "$PROMPT_FILE"
|
|
153538
|
-
EXIT_CODE=$?
|
|
153539
|
-
rm -f "$PROMPT_FILE"
|
|
153540
|
-
exit $EXIT_CODE
|
|
153541
|
-
`;
|
|
153542
|
-
}
|
|
153543
|
-
});
|
|
153544
|
-
|
|
153545
|
-
// ../agent-sdk/dist/chunk-H53UXMH4.js
|
|
153546
|
-
function buildTurn4(input) {
|
|
153547
|
-
const { agent, backendSessionId, promptText, toolResults } = input;
|
|
153548
|
-
const argsBase = buildClaudeArgs({
|
|
153549
|
-
agent,
|
|
153550
|
-
claudeSessionId: backendSessionId,
|
|
153551
|
-
confirmationMode: agent.confirmation_mode,
|
|
153552
|
-
memoryStores: input.memoryStores
|
|
153553
|
-
});
|
|
153554
|
-
const env3 = buildClaudeAuthEnv();
|
|
153555
|
-
const customTools = agent.tools.filter((t2) => t2.type === "custom");
|
|
153556
|
-
const hasBridgeTools = customTools.length > 0 || agent.threads_enabled;
|
|
153557
|
-
if (hasBridgeTools || agent.mcp_servers && agent.mcp_servers.length > 0) {
|
|
153558
|
-
const mcpIdx = argsBase.indexOf("--mcp-config");
|
|
153559
|
-
let existingServers = {};
|
|
153560
|
-
if (mcpIdx >= 0 && mcpIdx + 1 < argsBase.length) {
|
|
153561
|
-
try {
|
|
153562
|
-
const existing = JSON.parse(argsBase[mcpIdx + 1]);
|
|
153563
|
-
existingServers = existing.mcpServers ?? {};
|
|
153564
|
-
} catch {
|
|
153565
|
-
}
|
|
153566
|
-
argsBase.splice(mcpIdx, 2);
|
|
153567
|
-
}
|
|
153568
|
-
const merged = hasBridgeTools ? buildBridgeMcpConfig(existingServers) : existingServers;
|
|
153569
|
-
argsBase.push("--mcp-config", JSON.stringify({ mcpServers: merged }));
|
|
153570
|
-
}
|
|
153571
|
-
if (toolResults.length > 0) {
|
|
153572
|
-
const args = [...argsBase, "--input-format", "stream-json"];
|
|
153573
|
-
const content = [];
|
|
153574
|
-
if (promptText) {
|
|
153575
|
-
content.push({ type: "text", text: promptText });
|
|
153576
|
-
}
|
|
153577
|
-
for (const r of toolResults) {
|
|
153578
|
-
content.push({
|
|
153579
|
-
type: "tool_result",
|
|
153580
|
-
tool_use_id: r.custom_tool_use_id,
|
|
153581
|
-
content: r.content
|
|
153582
|
-
});
|
|
153583
|
-
}
|
|
153584
|
-
const userFrame = JSON.stringify({
|
|
153585
|
-
type: "user",
|
|
153586
|
-
message: { role: "user", content }
|
|
153587
|
-
});
|
|
153588
|
-
return { argv: args, env: env3, stdin: userFrame };
|
|
153589
|
-
}
|
|
153590
|
-
return { argv: argsBase, env: env3, stdin: promptText };
|
|
153591
|
-
}
|
|
153592
|
-
function validateRuntime() {
|
|
153593
|
-
const cfg = getConfig();
|
|
153594
|
-
if (!cfg.anthropicApiKey && !cfg.claudeToken) {
|
|
153595
|
-
return null;
|
|
153596
|
-
}
|
|
153597
|
-
return null;
|
|
153598
|
-
}
|
|
153599
|
-
async function installToolBridge(sandboxName, customTools, provider) {
|
|
153600
|
-
if (customTools.length === 0) return;
|
|
153601
|
-
await provider.exec(sandboxName, ["mkdir", "-p", TOOL_BRIDGE_DIR]);
|
|
153602
|
-
await provider.exec(
|
|
153603
|
-
sandboxName,
|
|
153604
|
-
["sh", "-c", `cat > "${TOOL_BRIDGE_SCRIPT_PATH}"`],
|
|
153605
|
-
{ stdin: generateBridgeScript() }
|
|
153606
|
-
);
|
|
153607
|
-
await provider.exec(
|
|
153608
|
-
sandboxName,
|
|
153609
|
-
["sh", "-c", `cat > "${TOOL_BRIDGE_TOOLS_PATH}"`],
|
|
153610
|
-
{ stdin: toolsToJson(customTools) }
|
|
153611
|
-
);
|
|
153612
|
-
await provider.exec(sandboxName, ["chmod", "+x", TOOL_BRIDGE_SCRIPT_PATH]);
|
|
153613
|
-
}
|
|
153614
|
-
async function installPermissionHook(sandboxName, provider) {
|
|
153615
|
-
await provider.exec(sandboxName, ["mkdir", "-p", PERMISSION_BRIDGE_DIR]);
|
|
153616
|
-
await provider.exec(
|
|
153617
|
-
sandboxName,
|
|
153618
|
-
["sh", "-c", `cat > ${PERMISSION_HOOK_SCRIPT_PATH}`],
|
|
153619
|
-
{ stdin: generatePermissionHookScript() }
|
|
153620
|
-
);
|
|
153621
|
-
await provider.exec(sandboxName, ["chmod", "+x", PERMISSION_HOOK_SCRIPT_PATH]);
|
|
153622
|
-
const hooksConfig = buildPermissionHooksConfig();
|
|
153623
|
-
const homeResult = await provider.exec(sandboxName, ["sh", "-c", "echo $HOME"]);
|
|
153624
|
-
const homeDir = homeResult.stdout.replace(/[\x00-\x1f]/g, "").trim() || "/home/sprite";
|
|
153625
|
-
const settingsPath = `${homeDir}/.claude/settings.json`;
|
|
153626
|
-
let existingSettings = {};
|
|
153627
|
-
try {
|
|
153628
|
-
const result = await provider.exec(
|
|
153629
|
-
sandboxName,
|
|
153630
|
-
["cat", settingsPath]
|
|
153631
|
-
);
|
|
153632
|
-
if (result.stdout.trim()) {
|
|
153633
|
-
existingSettings = JSON.parse(result.stdout);
|
|
153634
|
-
}
|
|
153635
|
-
} catch {
|
|
153636
|
-
}
|
|
153637
|
-
const merged = { ...existingSettings, ...hooksConfig };
|
|
153638
|
-
await provider.exec(
|
|
153639
|
-
sandboxName,
|
|
153640
|
-
["sh", "-c", `mkdir -p "${homeDir}/.claude" && cat > "${settingsPath}"`],
|
|
153641
|
-
{ stdin: JSON.stringify(merged, null, 2) }
|
|
153642
|
-
);
|
|
153643
|
-
}
|
|
153644
|
-
var claudeBackend;
|
|
153645
|
-
var init_chunk_H53UXMH4 = __esm({
|
|
153646
|
-
"../agent-sdk/dist/chunk-H53UXMH4.js"() {
|
|
153647
|
-
"use strict";
|
|
153648
|
-
init_chunk_YJCH35J4();
|
|
153649
|
-
init_chunk_CY6AWCC6();
|
|
153650
|
-
init_chunk_VRRGSQI7();
|
|
153651
|
-
init_chunk_D6RQPBRG();
|
|
153652
|
-
init_chunk_J6T3W6RY();
|
|
153653
|
-
init_chunk_6EIONZ7F();
|
|
153654
|
-
claudeBackend = {
|
|
153655
|
-
name: "claude",
|
|
153656
|
-
wrapperPath: CLAUDE_WRAPPER_PATH,
|
|
153657
|
-
buildTurn: buildTurn4,
|
|
153658
|
-
createTranslator: (opts) => createClaudeTranslator(opts),
|
|
153659
|
-
prepareOnSandbox: (name, provider) => installClaudeWrapper(name, provider),
|
|
153660
|
-
validateRuntime
|
|
153661
|
-
};
|
|
153662
|
-
}
|
|
153663
|
-
});
|
|
153664
|
-
|
|
153665
152883
|
// ../agent-sdk/dist/chunk-TPMZO6S2.js
|
|
153666
152884
|
function buildFactoryArgs(input) {
|
|
153667
152885
|
const args = [
|
|
@@ -153706,19 +152924,19 @@ var init_chunk_M72ERPMT = __esm({
|
|
|
153706
152924
|
|
|
153707
152925
|
// ../agent-sdk/dist/chunk-KJ2GJLPQ.js
|
|
153708
152926
|
async function installFactoryWrapper(sandboxName, provider) {
|
|
153709
|
-
const escaped =
|
|
152927
|
+
const escaped = SANDBOX_WRAPPER_SCRIPT4.replace(/'/g, "'\\''");
|
|
153710
152928
|
await provider.exec(sandboxName, [
|
|
153711
152929
|
"bash",
|
|
153712
152930
|
"-c",
|
|
153713
152931
|
`printf '%s' '${escaped}' > ${FACTORY_WRAPPER_PATH} && chmod +x ${FACTORY_WRAPPER_PATH}`
|
|
153714
152932
|
]);
|
|
153715
152933
|
}
|
|
153716
|
-
var FACTORY_WRAPPER_PATH,
|
|
152934
|
+
var FACTORY_WRAPPER_PATH, SANDBOX_WRAPPER_SCRIPT4;
|
|
153717
152935
|
var init_chunk_KJ2GJLPQ = __esm({
|
|
153718
152936
|
"../agent-sdk/dist/chunk-KJ2GJLPQ.js"() {
|
|
153719
152937
|
"use strict";
|
|
153720
152938
|
FACTORY_WRAPPER_PATH = "/tmp/.factory-wrapper";
|
|
153721
|
-
|
|
152939
|
+
SANDBOX_WRAPPER_SCRIPT4 = [
|
|
153722
152940
|
"#!/bin/bash",
|
|
153723
152941
|
"set -e",
|
|
153724
152942
|
'while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done',
|
|
@@ -153887,8 +153105,8 @@ var init_chunk_7TSTCMII = __esm({
|
|
|
153887
153105
|
}
|
|
153888
153106
|
});
|
|
153889
153107
|
|
|
153890
|
-
// ../agent-sdk/dist/chunk-
|
|
153891
|
-
function
|
|
153108
|
+
// ../agent-sdk/dist/chunk-65XY7HRS.js
|
|
153109
|
+
function buildTurn4(input) {
|
|
153892
153110
|
const { agent, backendSessionId, promptText, toolResults } = input;
|
|
153893
153111
|
if (toolResults.length > 0) {
|
|
153894
153112
|
throw new ApiError(
|
|
@@ -153903,20 +153121,20 @@ function buildTurn5(input) {
|
|
|
153903
153121
|
return { argv, env: env3, stdin: wrappedPrompt };
|
|
153904
153122
|
}
|
|
153905
153123
|
var factoryBackend;
|
|
153906
|
-
var
|
|
153907
|
-
"../agent-sdk/dist/chunk-
|
|
153124
|
+
var init_chunk_65XY7HRS = __esm({
|
|
153125
|
+
"../agent-sdk/dist/chunk-65XY7HRS.js"() {
|
|
153908
153126
|
"use strict";
|
|
153909
153127
|
init_chunk_TPMZO6S2();
|
|
153910
153128
|
init_chunk_M72ERPMT();
|
|
153911
153129
|
init_chunk_AQHYCRTO();
|
|
153912
|
-
init_chunk_KJ2GJLPQ();
|
|
153913
153130
|
init_chunk_7TSTCMII();
|
|
153131
|
+
init_chunk_KJ2GJLPQ();
|
|
153914
153132
|
init_chunk_YE2RMJY7();
|
|
153915
153133
|
init_chunk_EZYKRG4W();
|
|
153916
153134
|
factoryBackend = {
|
|
153917
153135
|
name: "factory",
|
|
153918
153136
|
wrapperPath: FACTORY_WRAPPER_PATH,
|
|
153919
|
-
buildTurn:
|
|
153137
|
+
buildTurn: buildTurn4,
|
|
153920
153138
|
createTranslator: (opts) => createFactoryTranslator(opts),
|
|
153921
153139
|
prepareOnSandbox: (name, provider) => prepareFactoryOnSandbox(name, provider),
|
|
153922
153140
|
validateRuntime: validateFactoryRuntime
|
|
@@ -153924,21 +153142,95 @@ var init_chunk_5PS6KN3J = __esm({
|
|
|
153924
153142
|
}
|
|
153925
153143
|
});
|
|
153926
153144
|
|
|
153145
|
+
// ../agent-sdk/dist/chunk-PJYCPDV5.js
|
|
153146
|
+
function buildCodexArgs(input) {
|
|
153147
|
+
const args = [
|
|
153148
|
+
"exec",
|
|
153149
|
+
"--json",
|
|
153150
|
+
"--full-auto",
|
|
153151
|
+
"--skip-git-repo-check"
|
|
153152
|
+
];
|
|
153153
|
+
if (input.agent.model) {
|
|
153154
|
+
const modelId = input.agent.model.id;
|
|
153155
|
+
args.push("--model", modelId);
|
|
153156
|
+
const cloudPrefixes = ["claude-", "gpt-", "o1-", "o3-", "o4-", "codex-", "chatgpt-"];
|
|
153157
|
+
const isOllama = !modelId.includes("/") && !cloudPrefixes.some((p2) => modelId.startsWith(p2));
|
|
153158
|
+
if (isOllama) {
|
|
153159
|
+
args.push("--oss", "--local-provider", "ollama");
|
|
153160
|
+
}
|
|
153161
|
+
}
|
|
153162
|
+
if (input.agent.mcp_servers) {
|
|
153163
|
+
for (const server of input.agent.mcp_servers) {
|
|
153164
|
+
const name = server.name;
|
|
153165
|
+
if (server.type) {
|
|
153166
|
+
args.push("-c", `mcp_servers.${name}.type="${server.type}"`);
|
|
153167
|
+
}
|
|
153168
|
+
if (server.url) {
|
|
153169
|
+
args.push("-c", `mcp_servers.${name}.url="${server.url}"`);
|
|
153170
|
+
}
|
|
153171
|
+
const command = server.command;
|
|
153172
|
+
if (typeof command === "string") {
|
|
153173
|
+
args.push("-c", `mcp_servers.${name}.command="${command}"`);
|
|
153174
|
+
}
|
|
153175
|
+
const sArgs = server.args;
|
|
153176
|
+
if (sArgs && sArgs.length > 0) {
|
|
153177
|
+
args.push(
|
|
153178
|
+
"-c",
|
|
153179
|
+
`mcp_servers.${name}.args=${JSON.stringify(sArgs)}`
|
|
153180
|
+
);
|
|
153181
|
+
}
|
|
153182
|
+
const headers3 = server.headers;
|
|
153183
|
+
if (headers3) {
|
|
153184
|
+
for (const [hk, hv] of Object.entries(headers3)) {
|
|
153185
|
+
args.push("-c", `mcp_servers.${name}.http_headers.${hk}="${hv}"`);
|
|
153186
|
+
}
|
|
153187
|
+
}
|
|
153188
|
+
}
|
|
153189
|
+
}
|
|
153190
|
+
args.push("-");
|
|
153191
|
+
return args;
|
|
153192
|
+
}
|
|
153193
|
+
var init_chunk_PJYCPDV5 = __esm({
|
|
153194
|
+
"../agent-sdk/dist/chunk-PJYCPDV5.js"() {
|
|
153195
|
+
"use strict";
|
|
153196
|
+
}
|
|
153197
|
+
});
|
|
153198
|
+
|
|
153199
|
+
// ../agent-sdk/dist/chunk-SIO4LO2M.js
|
|
153200
|
+
function buildCodexAuthEnv() {
|
|
153201
|
+
const cfg = getConfig();
|
|
153202
|
+
const env3 = {};
|
|
153203
|
+
if (cfg.openAiApiKey) {
|
|
153204
|
+
env3.OPENAI_API_KEY = cfg.openAiApiKey;
|
|
153205
|
+
env3.CODEX_API_KEY = cfg.openAiApiKey;
|
|
153206
|
+
}
|
|
153207
|
+
return env3;
|
|
153208
|
+
}
|
|
153209
|
+
function validateCodexRuntime() {
|
|
153210
|
+
return null;
|
|
153211
|
+
}
|
|
153212
|
+
var init_chunk_SIO4LO2M = __esm({
|
|
153213
|
+
"../agent-sdk/dist/chunk-SIO4LO2M.js"() {
|
|
153214
|
+
"use strict";
|
|
153215
|
+
init_chunk_6EIONZ7F();
|
|
153216
|
+
}
|
|
153217
|
+
});
|
|
153218
|
+
|
|
153927
153219
|
// ../agent-sdk/dist/chunk-XJYR5HE3.js
|
|
153928
153220
|
async function installCodexWrapper(sandboxName, provider) {
|
|
153929
|
-
const escaped =
|
|
153221
|
+
const escaped = SANDBOX_WRAPPER_SCRIPT5.replace(/'/g, "'\\''");
|
|
153930
153222
|
await provider.exec(sandboxName, [
|
|
153931
153223
|
"bash",
|
|
153932
153224
|
"-c",
|
|
153933
153225
|
`printf '%s' '${escaped}' > ${CODEX_WRAPPER_PATH} && chmod +x ${CODEX_WRAPPER_PATH}`
|
|
153934
153226
|
]);
|
|
153935
153227
|
}
|
|
153936
|
-
var CODEX_WRAPPER_PATH,
|
|
153228
|
+
var CODEX_WRAPPER_PATH, SANDBOX_WRAPPER_SCRIPT5;
|
|
153937
153229
|
var init_chunk_XJYR5HE3 = __esm({
|
|
153938
153230
|
"../agent-sdk/dist/chunk-XJYR5HE3.js"() {
|
|
153939
153231
|
"use strict";
|
|
153940
153232
|
CODEX_WRAPPER_PATH = "/tmp/.codex-wrapper";
|
|
153941
|
-
|
|
153233
|
+
SANDBOX_WRAPPER_SCRIPT5 = [
|
|
153942
153234
|
"#!/bin/bash",
|
|
153943
153235
|
// Read env vars from stdin until blank line
|
|
153944
153236
|
'while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done',
|
|
@@ -154152,147 +153444,855 @@ function createCodexTranslator(opts) {
|
|
|
154152
153444
|
});
|
|
154153
153445
|
return out;
|
|
154154
153446
|
}
|
|
154155
|
-
return out;
|
|
153447
|
+
return out;
|
|
153448
|
+
}
|
|
153449
|
+
function getTurnResult() {
|
|
153450
|
+
if (turnCount === 0 && !lastText) return null;
|
|
153451
|
+
return {
|
|
153452
|
+
stopReason: sawCustom ? "custom_tool_call" : "end_turn",
|
|
153453
|
+
usage: {
|
|
153454
|
+
input_tokens: totalInputTokens,
|
|
153455
|
+
output_tokens: totalOutputTokens,
|
|
153456
|
+
cache_read_input_tokens: 0,
|
|
153457
|
+
cache_creation_input_tokens: 0,
|
|
153458
|
+
cost_usd: totalCostUsd
|
|
153459
|
+
},
|
|
153460
|
+
num_turns: turnCount || 1
|
|
153461
|
+
};
|
|
153462
|
+
}
|
|
153463
|
+
return {
|
|
153464
|
+
translate,
|
|
153465
|
+
getBackendSessionId: () => sessionId,
|
|
153466
|
+
getTurnResult,
|
|
153467
|
+
sawCustomToolUse: () => sawCustom
|
|
153468
|
+
};
|
|
153469
|
+
}
|
|
153470
|
+
var init_chunk_CULYZ3VA = __esm({
|
|
153471
|
+
"../agent-sdk/dist/chunk-CULYZ3VA.js"() {
|
|
153472
|
+
"use strict";
|
|
153473
|
+
}
|
|
153474
|
+
});
|
|
153475
|
+
|
|
153476
|
+
// ../agent-sdk/dist/chunk-WEUPM3IN.js
|
|
153477
|
+
function buildTurn5(input) {
|
|
153478
|
+
const { agent, promptText, toolResults } = input;
|
|
153479
|
+
if (toolResults.length > 0) {
|
|
153480
|
+
throw new ApiError(
|
|
153481
|
+
400,
|
|
153482
|
+
"invalid_request_error",
|
|
153483
|
+
"codex backend does not support user.custom_tool_result re-entry in v1"
|
|
153484
|
+
);
|
|
153485
|
+
}
|
|
153486
|
+
const argv = buildCodexArgs({ agent });
|
|
153487
|
+
const env3 = buildCodexAuthEnv();
|
|
153488
|
+
const wrappedPrompt = wrapPromptWithSystem(promptText, agent.system, agent.skills);
|
|
153489
|
+
return { argv, env: env3, stdin: wrappedPrompt };
|
|
153490
|
+
}
|
|
153491
|
+
var codexBackend;
|
|
153492
|
+
var init_chunk_WEUPM3IN = __esm({
|
|
153493
|
+
"../agent-sdk/dist/chunk-WEUPM3IN.js"() {
|
|
153494
|
+
"use strict";
|
|
153495
|
+
init_chunk_PJYCPDV5();
|
|
153496
|
+
init_chunk_SIO4LO2M();
|
|
153497
|
+
init_chunk_NMZMRH3E();
|
|
153498
|
+
init_chunk_XJYR5HE3();
|
|
153499
|
+
init_chunk_CULYZ3VA();
|
|
153500
|
+
init_chunk_YE2RMJY7();
|
|
153501
|
+
init_chunk_EZYKRG4W();
|
|
153502
|
+
codexBackend = {
|
|
153503
|
+
name: "codex",
|
|
153504
|
+
wrapperPath: CODEX_WRAPPER_PATH,
|
|
153505
|
+
buildTurn: buildTurn5,
|
|
153506
|
+
createTranslator: (opts) => createCodexTranslator(opts),
|
|
153507
|
+
prepareOnSandbox: (name, provider) => prepareCodexOnSandbox(name, provider),
|
|
153508
|
+
validateRuntime: validateCodexRuntime
|
|
153509
|
+
};
|
|
153510
|
+
}
|
|
153511
|
+
});
|
|
153512
|
+
|
|
153513
|
+
// ../agent-sdk/dist/chunk-VRRGSQI7.js
|
|
153514
|
+
function generateBridgeScript() {
|
|
153515
|
+
return `#!/bin/bash
|
|
153516
|
+
# Auto-generated MCP stdio server for custom tool bridge.
|
|
153517
|
+
# Pure bash \u2014 no Node.js dependency. Instant startup on Firecracker VMs.
|
|
153518
|
+
|
|
153519
|
+
TOOLS_PATH="${TOOL_BRIDGE_TOOLS_PATH}"
|
|
153520
|
+
REQUEST_PATH="${TOOL_BRIDGE_REQUEST_PATH}"
|
|
153521
|
+
RESPONSE_PATH="${TOOL_BRIDGE_RESPONSE_PATH}"
|
|
153522
|
+
PENDING_PATH="${TOOL_BRIDGE_PENDING_PATH}"
|
|
153523
|
+
|
|
153524
|
+
send_response() {
|
|
153525
|
+
printf '%s\\n' "$1"
|
|
153526
|
+
}
|
|
153527
|
+
|
|
153528
|
+
TOOLS_LIST_JSON=""
|
|
153529
|
+
if [ -f "$TOOLS_PATH" ]; then
|
|
153530
|
+
TOOLS_LIST_JSON=$(sed 's/input_schema/inputSchema/g' "$TOOLS_PATH")
|
|
153531
|
+
fi
|
|
153532
|
+
|
|
153533
|
+
handle_request() {
|
|
153534
|
+
local body="$1"
|
|
153535
|
+
local method id
|
|
153536
|
+
method=$(echo "$body" | grep -o '"method":"[^"]*"' | head -1 | cut -d'"' -f4)
|
|
153537
|
+
id=$(echo "$body" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
153538
|
+
|
|
153539
|
+
case "$method" in
|
|
153540
|
+
initialize)
|
|
153541
|
+
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"protocolVersion":"2025-11-25","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"tool-bridge","version":"1.0.0"}}}'
|
|
153542
|
+
;;
|
|
153543
|
+
notifications/*) ;;
|
|
153544
|
+
ping)
|
|
153545
|
+
[ -n "$id" ] && send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{}}'
|
|
153546
|
+
;;
|
|
153547
|
+
tools/list)
|
|
153548
|
+
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"tools":'"$TOOLS_LIST_JSON"'}}'
|
|
153549
|
+
;;
|
|
153550
|
+
tools/call)
|
|
153551
|
+
local tool_name
|
|
153552
|
+
tool_name=$(echo "$body" | grep -o '"name":"[^"]*"' | tail -1 | cut -d'"' -f4)
|
|
153553
|
+
|
|
153554
|
+
# Reject unknown tools immediately (don't wait for gateway response)
|
|
153555
|
+
if [ -n "$TOOLS_LIST_JSON" ]; then
|
|
153556
|
+
if ! echo "$TOOLS_LIST_JSON" | grep -q "\\"$tool_name\\""; then
|
|
153557
|
+
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"content":[{"type":"text","text":"Unknown tool: '"$tool_name"'"}],"isError":true}}'
|
|
153558
|
+
return
|
|
153559
|
+
fi
|
|
153560
|
+
fi
|
|
153561
|
+
|
|
153562
|
+
# Replay case: response.json already exists (--resume re-entry)
|
|
153563
|
+
if [ -f "$RESPONSE_PATH" ]; then
|
|
153564
|
+
local rdata
|
|
153565
|
+
rdata=$(cat "$RESPONSE_PATH" | tr -d '\\n' | sed 's/\\\\/\\\\\\\\/g; s/"/\\\\"/g')
|
|
153566
|
+
rm -f "$RESPONSE_PATH"
|
|
153567
|
+
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"content":[{"type":"text","text":"'"$rdata"'"}],"isError":false}}'
|
|
153568
|
+
return
|
|
153569
|
+
fi
|
|
153570
|
+
|
|
153571
|
+
# Write the full MCP request body to request.json.
|
|
153572
|
+
# The driver parses tool_use_id, name, and input from it.
|
|
153573
|
+
# Previous approach used grep to extract arguments, which broke on
|
|
153574
|
+
# nested JSON objects (truncated at first closing brace).
|
|
153575
|
+
printf '%s' "$body" > "$REQUEST_PATH"
|
|
153576
|
+
touch "$PENDING_PATH"
|
|
153577
|
+
|
|
153578
|
+
# Poll for response.json (200ms interval, 5min timeout)
|
|
153579
|
+
local elapsed=0
|
|
153580
|
+
while [ $elapsed -lt 1500 ]; do
|
|
153581
|
+
if [ -f "$RESPONSE_PATH" ]; then
|
|
153582
|
+
local rdata
|
|
153583
|
+
rdata=$(cat "$RESPONSE_PATH" | tr -d '\\n' | sed 's/\\\\/\\\\\\\\/g; s/"/\\\\"/g')
|
|
153584
|
+
rm -f "$RESPONSE_PATH" "$PENDING_PATH"
|
|
153585
|
+
send_response '{"jsonrpc":"2.0","id":'"$id"',"result":{"content":[{"type":"text","text":"'"$rdata"'"}],"isError":false}}'
|
|
153586
|
+
return
|
|
153587
|
+
fi
|
|
153588
|
+
sleep 0.2
|
|
153589
|
+
elapsed=$((elapsed + 1))
|
|
153590
|
+
done
|
|
153591
|
+
# Timeout
|
|
153592
|
+
rm -f "$PENDING_PATH"
|
|
153593
|
+
send_response '{"jsonrpc":"2.0","id":'"$id"',"error":{"code":-32603,"message":"Timeout waiting for tool response"}}'
|
|
153594
|
+
;;
|
|
153595
|
+
*)
|
|
153596
|
+
[ -n "$id" ] && send_response '{"jsonrpc":"2.0","id":'"$id"',"error":{"code":-32601,"message":"Method not found"}}'
|
|
153597
|
+
;;
|
|
153598
|
+
esac
|
|
153599
|
+
}
|
|
153600
|
+
|
|
153601
|
+
# Main loop: handle both raw JSON lines and Content-Length framed messages
|
|
153602
|
+
while IFS= read -r line; do
|
|
153603
|
+
line=\${line%$'\\r'}
|
|
153604
|
+
[ -z "$line" ] && continue
|
|
153605
|
+
case "$line" in
|
|
153606
|
+
Content-Length:*)
|
|
153607
|
+
while IFS= read -r hdr; do hdr=\${hdr%$'\\r'}; [ -z "$hdr" ] && break; done
|
|
153608
|
+
body=$(head -c "\${line#Content-Length: }")
|
|
153609
|
+
handle_request "$body" ;;
|
|
153610
|
+
"{"*) handle_request "$line" ;;
|
|
153611
|
+
esac
|
|
153612
|
+
done
|
|
153613
|
+
`;
|
|
153614
|
+
}
|
|
153615
|
+
function buildBridgeMcpConfig(existingServers) {
|
|
153616
|
+
return {
|
|
153617
|
+
...existingServers,
|
|
153618
|
+
"tool-bridge": {
|
|
153619
|
+
command: "bash",
|
|
153620
|
+
args: [TOOL_BRIDGE_SCRIPT_PATH]
|
|
153621
|
+
}
|
|
153622
|
+
};
|
|
153623
|
+
}
|
|
153624
|
+
function toolsToJson(tools) {
|
|
153625
|
+
return JSON.stringify(
|
|
153626
|
+
tools.map((t2) => ({
|
|
153627
|
+
name: t2.name,
|
|
153628
|
+
description: t2.description,
|
|
153629
|
+
input_schema: t2.input_schema
|
|
153630
|
+
}))
|
|
153631
|
+
);
|
|
153632
|
+
}
|
|
153633
|
+
var TOOL_BRIDGE_DIR, TOOL_BRIDGE_SCRIPT_PATH, TOOL_BRIDGE_TOOLS_PATH, TOOL_BRIDGE_REQUEST_PATH, TOOL_BRIDGE_RESPONSE_PATH, TOOL_BRIDGE_PENDING_PATH;
|
|
153634
|
+
var init_chunk_VRRGSQI7 = __esm({
|
|
153635
|
+
"../agent-sdk/dist/chunk-VRRGSQI7.js"() {
|
|
153636
|
+
"use strict";
|
|
153637
|
+
TOOL_BRIDGE_DIR = "/tmp/tool-bridge";
|
|
153638
|
+
TOOL_BRIDGE_SCRIPT_PATH = `${TOOL_BRIDGE_DIR}/bridge.sh`;
|
|
153639
|
+
TOOL_BRIDGE_TOOLS_PATH = `${TOOL_BRIDGE_DIR}/tools.json`;
|
|
153640
|
+
TOOL_BRIDGE_REQUEST_PATH = `${TOOL_BRIDGE_DIR}/request.json`;
|
|
153641
|
+
TOOL_BRIDGE_RESPONSE_PATH = `${TOOL_BRIDGE_DIR}/response.json`;
|
|
153642
|
+
TOOL_BRIDGE_PENDING_PATH = `${TOOL_BRIDGE_DIR}/pending`;
|
|
153643
|
+
}
|
|
153644
|
+
});
|
|
153645
|
+
|
|
153646
|
+
// ../agent-sdk/dist/chunk-7XQLG5P2.js
|
|
153647
|
+
var BUILT_IN_TOOL_NAMES;
|
|
153648
|
+
var init_chunk_7XQLG5P2 = __esm({
|
|
153649
|
+
"../agent-sdk/dist/chunk-7XQLG5P2.js"() {
|
|
153650
|
+
"use strict";
|
|
153651
|
+
BUILT_IN_TOOL_NAMES = [
|
|
153652
|
+
"Bash",
|
|
153653
|
+
"Read",
|
|
153654
|
+
"Write",
|
|
153655
|
+
"Edit",
|
|
153656
|
+
"Glob",
|
|
153657
|
+
"Grep",
|
|
153658
|
+
"WebFetch",
|
|
153659
|
+
"WebSearch",
|
|
153660
|
+
"ToolSearch",
|
|
153661
|
+
"Skill",
|
|
153662
|
+
"Agent",
|
|
153663
|
+
"NotebookEdit",
|
|
153664
|
+
"TodoWrite"
|
|
153665
|
+
];
|
|
153666
|
+
}
|
|
153667
|
+
});
|
|
153668
|
+
|
|
153669
|
+
// ../agent-sdk/dist/chunk-D6RQPBRG.js
|
|
153670
|
+
function createClaudeTranslator(opts) {
|
|
153671
|
+
const toolClass = /* @__PURE__ */ new Map();
|
|
153672
|
+
const toolSpan = /* @__PURE__ */ new Map();
|
|
153673
|
+
const toolMeta = /* @__PURE__ */ new Map();
|
|
153674
|
+
let claudeSessionId = null;
|
|
153675
|
+
let sawInit = false;
|
|
153676
|
+
let sawCustom = false;
|
|
153677
|
+
let turnResult = null;
|
|
153678
|
+
function classify(name) {
|
|
153679
|
+
if (BUILT_IN_SET.has(name)) return "builtin";
|
|
153680
|
+
if (name.startsWith("mcp__")) return "mcp";
|
|
153681
|
+
if (opts.customToolNames.has(name)) return "custom";
|
|
153682
|
+
return "builtin";
|
|
153683
|
+
}
|
|
153684
|
+
function translate(raw2) {
|
|
153685
|
+
const out = [];
|
|
153686
|
+
const type = String(raw2.type ?? "");
|
|
153687
|
+
if (type === "system") {
|
|
153688
|
+
const subtype = raw2.subtype;
|
|
153689
|
+
if (subtype === "init") {
|
|
153690
|
+
if (typeof raw2.session_id === "string") {
|
|
153691
|
+
claudeSessionId = raw2.session_id;
|
|
153692
|
+
}
|
|
153693
|
+
if (!sawInit && opts.isFirstTurn) {
|
|
153694
|
+
sawInit = true;
|
|
153695
|
+
}
|
|
153696
|
+
sawInit = true;
|
|
153697
|
+
}
|
|
153698
|
+
return out;
|
|
153699
|
+
}
|
|
153700
|
+
if (type === "assistant") {
|
|
153701
|
+
const msg = raw2.message ?? {};
|
|
153702
|
+
const blocks = msg.content ?? [];
|
|
153703
|
+
for (const block of blocks) {
|
|
153704
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
153705
|
+
out.push({
|
|
153706
|
+
type: "agent.message",
|
|
153707
|
+
payload: {
|
|
153708
|
+
content: [{ type: "text", text: block.text }]
|
|
153709
|
+
}
|
|
153710
|
+
});
|
|
153711
|
+
} else if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
153712
|
+
out.push({
|
|
153713
|
+
type: "agent.thinking",
|
|
153714
|
+
payload: {
|
|
153715
|
+
content: [{ type: "thinking", thinking: block.thinking }]
|
|
153716
|
+
}
|
|
153717
|
+
});
|
|
153718
|
+
} else if (block.type === "tool_use" && block.id && block.name) {
|
|
153719
|
+
const cls = classify(block.name);
|
|
153720
|
+
toolClass.set(block.id, cls);
|
|
153721
|
+
let toolSpanId;
|
|
153722
|
+
if (opts.turnSpanId) {
|
|
153723
|
+
toolSpanId = newId("span");
|
|
153724
|
+
toolSpan.set(block.id, toolSpanId);
|
|
153725
|
+
toolMeta.set(block.id, { name: block.name, startMs: Date.now() });
|
|
153726
|
+
out.push({
|
|
153727
|
+
type: "span.tool_call_start",
|
|
153728
|
+
payload: {
|
|
153729
|
+
tool_use_id: block.id,
|
|
153730
|
+
name: block.name,
|
|
153731
|
+
tool_class: cls
|
|
153732
|
+
},
|
|
153733
|
+
spanId: toolSpanId,
|
|
153734
|
+
parentSpanId: opts.turnSpanId
|
|
153735
|
+
});
|
|
153736
|
+
}
|
|
153737
|
+
if (cls === "custom") {
|
|
153738
|
+
sawCustom = true;
|
|
153739
|
+
out.push({
|
|
153740
|
+
type: "agent.custom_tool_use",
|
|
153741
|
+
payload: {
|
|
153742
|
+
tool_use_id: block.id,
|
|
153743
|
+
name: block.name,
|
|
153744
|
+
input: block.input ?? {}
|
|
153745
|
+
},
|
|
153746
|
+
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153747
|
+
});
|
|
153748
|
+
} else if (cls === "mcp") {
|
|
153749
|
+
const parts = block.name.split("__");
|
|
153750
|
+
const serverName = parts[1] ?? "unknown";
|
|
153751
|
+
const toolName = parts.slice(2).join("__") || block.name;
|
|
153752
|
+
out.push({
|
|
153753
|
+
type: "agent.mcp_tool_use",
|
|
153754
|
+
payload: {
|
|
153755
|
+
tool_use_id: block.id,
|
|
153756
|
+
server_name: serverName,
|
|
153757
|
+
tool_name: toolName,
|
|
153758
|
+
input: block.input ?? {}
|
|
153759
|
+
},
|
|
153760
|
+
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153761
|
+
});
|
|
153762
|
+
} else {
|
|
153763
|
+
out.push({
|
|
153764
|
+
type: "agent.tool_use",
|
|
153765
|
+
payload: {
|
|
153766
|
+
tool_use_id: block.id,
|
|
153767
|
+
name: block.name,
|
|
153768
|
+
input: block.input ?? {}
|
|
153769
|
+
},
|
|
153770
|
+
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153771
|
+
});
|
|
153772
|
+
}
|
|
153773
|
+
}
|
|
153774
|
+
}
|
|
153775
|
+
return out;
|
|
153776
|
+
}
|
|
153777
|
+
if (type === "user") {
|
|
153778
|
+
const msg = raw2.message ?? {};
|
|
153779
|
+
const blocks = msg.content ?? [];
|
|
153780
|
+
for (const block of blocks) {
|
|
153781
|
+
if (block.type === "tool_result" && block.tool_use_id) {
|
|
153782
|
+
const cls = toolClass.get(block.tool_use_id);
|
|
153783
|
+
if (cls === "custom") continue;
|
|
153784
|
+
const eventType = cls === "mcp" ? "agent.mcp_tool_result" : "agent.tool_result";
|
|
153785
|
+
const toolSpanId = toolSpan.get(block.tool_use_id);
|
|
153786
|
+
const meta = toolMeta.get(block.tool_use_id);
|
|
153787
|
+
out.push({
|
|
153788
|
+
type: eventType,
|
|
153789
|
+
payload: {
|
|
153790
|
+
tool_use_id: block.tool_use_id,
|
|
153791
|
+
content: block.content ?? null,
|
|
153792
|
+
is_error: block.is_error ?? false
|
|
153793
|
+
},
|
|
153794
|
+
...toolSpanId ? { spanId: toolSpanId, parentSpanId: opts.turnSpanId } : {}
|
|
153795
|
+
});
|
|
153796
|
+
if (toolSpanId && opts.turnSpanId) {
|
|
153797
|
+
const durationMs = meta ? Date.now() - meta.startMs : null;
|
|
153798
|
+
out.push({
|
|
153799
|
+
type: "span.tool_call_end",
|
|
153800
|
+
payload: {
|
|
153801
|
+
tool_use_id: block.tool_use_id,
|
|
153802
|
+
name: meta?.name ?? null,
|
|
153803
|
+
tool_class: cls ?? "builtin",
|
|
153804
|
+
status: block.is_error ? "error" : "ok",
|
|
153805
|
+
duration_ms: durationMs
|
|
153806
|
+
},
|
|
153807
|
+
spanId: toolSpanId,
|
|
153808
|
+
parentSpanId: opts.turnSpanId
|
|
153809
|
+
});
|
|
153810
|
+
toolSpan.delete(block.tool_use_id);
|
|
153811
|
+
toolMeta.delete(block.tool_use_id);
|
|
153812
|
+
}
|
|
153813
|
+
}
|
|
153814
|
+
}
|
|
153815
|
+
return out;
|
|
153816
|
+
}
|
|
153817
|
+
if (type === "result") {
|
|
153818
|
+
const subtype = String(raw2.subtype ?? "success");
|
|
153819
|
+
const usageRaw = raw2.usage ?? {};
|
|
153820
|
+
const usage = {
|
|
153821
|
+
input_tokens: usageRaw.input_tokens ?? 0,
|
|
153822
|
+
output_tokens: usageRaw.output_tokens ?? 0,
|
|
153823
|
+
cache_read_input_tokens: usageRaw.cache_read_input_tokens ?? 0,
|
|
153824
|
+
cache_creation_input_tokens: usageRaw.cache_creation_input_tokens ?? 0,
|
|
153825
|
+
cost_usd: raw2.total_cost_usd ?? 0
|
|
153826
|
+
};
|
|
153827
|
+
let stopReason;
|
|
153828
|
+
if (sawCustom) stopReason = "custom_tool_call";
|
|
153829
|
+
else if (subtype === "error_max_turns") stopReason = "max_turns";
|
|
153830
|
+
else if (subtype === "error_during_execution") stopReason = "error";
|
|
153831
|
+
else stopReason = "end_turn";
|
|
153832
|
+
turnResult = {
|
|
153833
|
+
stopReason,
|
|
153834
|
+
usage,
|
|
153835
|
+
num_turns: raw2.num_turns ?? 1
|
|
153836
|
+
};
|
|
153837
|
+
return out;
|
|
153838
|
+
}
|
|
153839
|
+
return out;
|
|
153840
|
+
}
|
|
153841
|
+
return {
|
|
153842
|
+
translate,
|
|
153843
|
+
getBackendSessionId: () => claudeSessionId,
|
|
153844
|
+
getTurnResult: () => turnResult,
|
|
153845
|
+
sawCustomToolUse: () => sawCustom
|
|
153846
|
+
};
|
|
153847
|
+
}
|
|
153848
|
+
var BUILT_IN_SET;
|
|
153849
|
+
var init_chunk_D6RQPBRG = __esm({
|
|
153850
|
+
"../agent-sdk/dist/chunk-D6RQPBRG.js"() {
|
|
153851
|
+
"use strict";
|
|
153852
|
+
init_chunk_F4WUVOLE();
|
|
153853
|
+
init_chunk_7XQLG5P2();
|
|
153854
|
+
init_ids();
|
|
153855
|
+
BUILT_IN_SET = new Set(BUILT_IN_TOOL_NAMES);
|
|
153856
|
+
}
|
|
153857
|
+
});
|
|
153858
|
+
|
|
153859
|
+
// ../agent-sdk/dist/chunk-FX2AEKOV.js
|
|
153860
|
+
function resolveToolset(tools) {
|
|
153861
|
+
const customToolNames = /* @__PURE__ */ new Set();
|
|
153862
|
+
let builtInEnabled = new Set(BUILT_IN_TOOL_NAMES);
|
|
153863
|
+
let hadAgentToolset = false;
|
|
153864
|
+
for (const tool of tools) {
|
|
153865
|
+
if (tool.type === "agent_toolset_20260401") {
|
|
153866
|
+
hadAgentToolset = true;
|
|
153867
|
+
const defaultEnabled = tool.default_config?.enabled ?? true;
|
|
153868
|
+
if (!defaultEnabled) {
|
|
153869
|
+
builtInEnabled = /* @__PURE__ */ new Set();
|
|
153870
|
+
}
|
|
153871
|
+
for (const cfg of tool.configs ?? []) {
|
|
153872
|
+
const raw2 = cfg.name;
|
|
153873
|
+
const name = BUILT_IN_TOOL_NAMES.find(
|
|
153874
|
+
(n) => n.toLowerCase() === raw2.toLowerCase()
|
|
153875
|
+
) ?? raw2;
|
|
153876
|
+
if (!BUILT_IN_TOOL_NAMES.includes(name)) continue;
|
|
153877
|
+
if (cfg.enabled === false) {
|
|
153878
|
+
builtInEnabled.delete(name);
|
|
153879
|
+
} else if (cfg.enabled === true) {
|
|
153880
|
+
builtInEnabled.add(name);
|
|
153881
|
+
}
|
|
153882
|
+
}
|
|
153883
|
+
} else if (tool.type === "custom") {
|
|
153884
|
+
customToolNames.add(tool.name);
|
|
153885
|
+
}
|
|
153886
|
+
}
|
|
153887
|
+
if (!hadAgentToolset) {
|
|
153888
|
+
builtInEnabled = /* @__PURE__ */ new Set();
|
|
153889
|
+
}
|
|
153890
|
+
const allowedTools = Array.from(builtInEnabled);
|
|
153891
|
+
const disallowedTools = BUILT_IN_TOOL_NAMES.filter((n) => !builtInEnabled.has(n));
|
|
153892
|
+
return { allowedTools, disallowedTools, customToolNames };
|
|
153893
|
+
}
|
|
153894
|
+
var init_chunk_FX2AEKOV = __esm({
|
|
153895
|
+
"../agent-sdk/dist/chunk-FX2AEKOV.js"() {
|
|
153896
|
+
"use strict";
|
|
153897
|
+
init_chunk_7XQLG5P2();
|
|
153898
|
+
}
|
|
153899
|
+
});
|
|
153900
|
+
|
|
153901
|
+
// ../agent-sdk/dist/chunk-YJCH35J4.js
|
|
153902
|
+
function buildClaudeArgs(input) {
|
|
153903
|
+
const cfg = getConfig();
|
|
153904
|
+
const policy = input.agent.permission_policy;
|
|
153905
|
+
const permissionMode = input.confirmationMode ? "default" : policy ? "default" : "bypassPermissions";
|
|
153906
|
+
const argv = [
|
|
153907
|
+
"-p",
|
|
153908
|
+
"--output-format",
|
|
153909
|
+
"stream-json",
|
|
153910
|
+
"--verbose",
|
|
153911
|
+
"--permission-mode",
|
|
153912
|
+
permissionMode
|
|
153913
|
+
];
|
|
153914
|
+
const maxTurns = input.maxTurns ?? cfg.agentMaxTurns;
|
|
153915
|
+
if (maxTurns > 0) {
|
|
153916
|
+
argv.push("--max-turns", String(maxTurns));
|
|
153917
|
+
}
|
|
153918
|
+
if (input.claudeSessionId) {
|
|
153919
|
+
argv.push("--resume", input.claudeSessionId);
|
|
153920
|
+
}
|
|
153921
|
+
const tools = resolveToolset(input.agent.tools);
|
|
153922
|
+
let systemPrompt = withGatewayPreamble(input.agent.system, input.memoryStores);
|
|
153923
|
+
if (tools.customToolNames.size > 0) {
|
|
153924
|
+
const toolList = Array.from(tools.customToolNames).map((name) => `mcp__tool-bridge__${name}`).join(", ");
|
|
153925
|
+
systemPrompt += `
|
|
153926
|
+
|
|
153927
|
+
Your custom tools are: ${toolList}. Call them by these exact names \u2014 do not use ToolSearch to find them.`;
|
|
153928
|
+
}
|
|
153929
|
+
argv.push("--system-prompt", systemPrompt);
|
|
153930
|
+
if (input.agent.model) {
|
|
153931
|
+
argv.push("--model", input.agent.model.id);
|
|
153932
|
+
}
|
|
153933
|
+
const mcpToolNames = Array.from(tools.customToolNames).map(
|
|
153934
|
+
(name) => `mcp__tool-bridge__${name}`
|
|
153935
|
+
);
|
|
153936
|
+
const policyAllowed = policy?.always_allow ?? [];
|
|
153937
|
+
const allAllowed = [...tools.allowedTools, ...mcpToolNames, ...policyAllowed];
|
|
153938
|
+
if (allAllowed.length) {
|
|
153939
|
+
argv.push("--allowed-tools", allAllowed.join(","));
|
|
153940
|
+
}
|
|
153941
|
+
if (tools.disallowedTools.length) {
|
|
153942
|
+
argv.push("--disallowed-tools", tools.disallowedTools.join(","));
|
|
153943
|
+
}
|
|
153944
|
+
if (input.agent.model_config?.speed === "fast") {
|
|
153945
|
+
argv.push("--fast");
|
|
153946
|
+
}
|
|
153947
|
+
if (input.agent.mcp_servers && input.agent.mcp_servers.length > 0) {
|
|
153948
|
+
const mcpRecord = {};
|
|
153949
|
+
for (const s of input.agent.mcp_servers) {
|
|
153950
|
+
const { name, ...rest } = s;
|
|
153951
|
+
mcpRecord[name] = rest;
|
|
153952
|
+
}
|
|
153953
|
+
argv.push(
|
|
153954
|
+
"--mcp-config",
|
|
153955
|
+
JSON.stringify({ mcpServers: mcpRecord })
|
|
153956
|
+
);
|
|
154156
153957
|
}
|
|
154157
|
-
|
|
154158
|
-
|
|
154159
|
-
|
|
154160
|
-
|
|
154161
|
-
|
|
154162
|
-
|
|
154163
|
-
|
|
154164
|
-
|
|
154165
|
-
|
|
154166
|
-
|
|
154167
|
-
|
|
154168
|
-
|
|
154169
|
-
};
|
|
153958
|
+
return argv;
|
|
153959
|
+
}
|
|
153960
|
+
function buildClaudeAuthEnv() {
|
|
153961
|
+
const cfg = getConfig();
|
|
153962
|
+
const env3 = {};
|
|
153963
|
+
const token = cfg.claudeToken || cfg.anthropicApiKey;
|
|
153964
|
+
if (token) {
|
|
153965
|
+
if (token.startsWith("sk-ant-oat")) {
|
|
153966
|
+
env3.CLAUDE_CODE_OAUTH_TOKEN = token;
|
|
153967
|
+
} else {
|
|
153968
|
+
env3.ANTHROPIC_API_KEY = token;
|
|
153969
|
+
}
|
|
154170
153970
|
}
|
|
154171
|
-
return
|
|
154172
|
-
translate,
|
|
154173
|
-
getBackendSessionId: () => sessionId,
|
|
154174
|
-
getTurnResult,
|
|
154175
|
-
sawCustomToolUse: () => sawCustom
|
|
154176
|
-
};
|
|
153971
|
+
return env3;
|
|
154177
153972
|
}
|
|
154178
|
-
var
|
|
154179
|
-
"../agent-sdk/dist/chunk-
|
|
153973
|
+
var init_chunk_YJCH35J4 = __esm({
|
|
153974
|
+
"../agent-sdk/dist/chunk-YJCH35J4.js"() {
|
|
154180
153975
|
"use strict";
|
|
153976
|
+
init_chunk_YE2RMJY7();
|
|
153977
|
+
init_chunk_FX2AEKOV();
|
|
153978
|
+
init_chunk_6EIONZ7F();
|
|
154181
153979
|
}
|
|
154182
153980
|
});
|
|
154183
153981
|
|
|
154184
|
-
// ../agent-sdk/dist/chunk-
|
|
154185
|
-
function
|
|
154186
|
-
|
|
154187
|
-
|
|
154188
|
-
|
|
154189
|
-
|
|
154190
|
-
|
|
154191
|
-
|
|
154192
|
-
|
|
154193
|
-
|
|
154194
|
-
|
|
154195
|
-
|
|
154196
|
-
|
|
154197
|
-
|
|
154198
|
-
|
|
154199
|
-
|
|
153982
|
+
// ../agent-sdk/dist/chunk-CY6AWCC6.js
|
|
153983
|
+
function generatePermissionHookScript() {
|
|
153984
|
+
return `#!/usr/bin/env node
|
|
153985
|
+
// Auto-generated PermissionRequest hook for tool confirmation bridge.
|
|
153986
|
+
// Reads hook JSON from stdin, writes request.json + pending sentinel,
|
|
153987
|
+
// polls for response.json, then outputs the hook response to stdout.
|
|
153988
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync, watchFile, unwatchFile } from 'node:fs';
|
|
153989
|
+
|
|
153990
|
+
const REQUEST_PATH = ${JSON.stringify(PERMISSION_BRIDGE_REQUEST_PATH)};
|
|
153991
|
+
const RESPONSE_PATH = ${JSON.stringify(PERMISSION_BRIDGE_RESPONSE_PATH)};
|
|
153992
|
+
const PENDING_PATH = ${JSON.stringify(PERMISSION_BRIDGE_PENDING_PATH)};
|
|
153993
|
+
const TIMEOUT_MS = 120000; // 2 minutes
|
|
153994
|
+
|
|
153995
|
+
// Read hook input from stdin
|
|
153996
|
+
let input = '';
|
|
153997
|
+
process.stdin.setEncoding('utf8');
|
|
153998
|
+
process.stdin.on('data', (chunk) => { input += chunk; });
|
|
153999
|
+
process.stdin.on('end', () => {
|
|
154000
|
+
let hookInput;
|
|
154001
|
+
try {
|
|
154002
|
+
hookInput = JSON.parse(input);
|
|
154003
|
+
} catch (e) {
|
|
154004
|
+
// If we can't parse the input, allow by default to avoid blocking
|
|
154005
|
+
console.error('[permission-hook] failed to parse stdin:', e.message);
|
|
154006
|
+
outputResult({ behavior: 'allow' });
|
|
154007
|
+
return;
|
|
154200
154008
|
}
|
|
154201
|
-
|
|
154202
|
-
|
|
154203
|
-
|
|
154204
|
-
|
|
154205
|
-
|
|
154206
|
-
|
|
154207
|
-
|
|
154208
|
-
|
|
154209
|
-
|
|
154210
|
-
|
|
154211
|
-
|
|
154212
|
-
|
|
154213
|
-
|
|
154214
|
-
|
|
154215
|
-
|
|
154216
|
-
|
|
154217
|
-
|
|
154218
|
-
|
|
154219
|
-
|
|
154009
|
+
|
|
154010
|
+
// Extract tool details from the PermissionRequest hook payload.
|
|
154011
|
+
// Claude Code sends: { tool_name, tool_input, tool_use_id, ... }
|
|
154012
|
+
const toolName = hookInput.tool_name || hookInput.toolName || 'unknown';
|
|
154013
|
+
const toolInput = hookInput.tool_input || hookInput.toolInput || {};
|
|
154014
|
+
const toolUseId = hookInput.tool_use_id || hookInput.toolUseId || '';
|
|
154015
|
+
|
|
154016
|
+
// Write request.json with tool details
|
|
154017
|
+
writeFileSync(REQUEST_PATH, JSON.stringify({
|
|
154018
|
+
tool_name: toolName,
|
|
154019
|
+
tool_input: toolInput,
|
|
154020
|
+
tool_use_id: toolUseId,
|
|
154021
|
+
}));
|
|
154022
|
+
|
|
154023
|
+
// Create pending sentinel
|
|
154024
|
+
writeFileSync(PENDING_PATH, '');
|
|
154025
|
+
|
|
154026
|
+
// Poll for response.json
|
|
154027
|
+
const startTime = Date.now();
|
|
154028
|
+
let resolved = false;
|
|
154029
|
+
|
|
154030
|
+
const checkResponse = () => {
|
|
154031
|
+
if (resolved) return;
|
|
154032
|
+
if (!existsSync(RESPONSE_PATH)) return;
|
|
154033
|
+
resolved = true;
|
|
154034
|
+
try { unwatchFile(RESPONSE_PATH, pollFn); } catch {}
|
|
154035
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
154036
|
+
|
|
154037
|
+
try {
|
|
154038
|
+
const resp = JSON.parse(readFileSync(RESPONSE_PATH, 'utf8'));
|
|
154039
|
+
try { unlinkSync(RESPONSE_PATH); } catch {}
|
|
154040
|
+
try { unlinkSync(PENDING_PATH); } catch {}
|
|
154041
|
+
|
|
154042
|
+
if (resp.result === 'allow') {
|
|
154043
|
+
outputResult({ behavior: 'allow' });
|
|
154044
|
+
} else {
|
|
154045
|
+
outputResult({ behavior: 'deny', message: resp.deny_message || 'User denied tool use' });
|
|
154220
154046
|
}
|
|
154221
|
-
|
|
154222
|
-
|
|
154223
|
-
|
|
154224
|
-
|
|
154047
|
+
} catch (e) {
|
|
154048
|
+
console.error('[permission-hook] failed to read response:', e.message);
|
|
154049
|
+
// On error, deny to be safe
|
|
154050
|
+
try { unlinkSync(PENDING_PATH); } catch {}
|
|
154051
|
+
outputResult({ behavior: 'deny', message: 'Permission hook error: ' + e.message });
|
|
154052
|
+
}
|
|
154053
|
+
};
|
|
154054
|
+
|
|
154055
|
+
const pollFn = () => checkResponse();
|
|
154056
|
+
|
|
154057
|
+
// Check immediately in case response was pre-written
|
|
154058
|
+
checkResponse();
|
|
154059
|
+
if (resolved) return;
|
|
154060
|
+
|
|
154061
|
+
// Use fs.watchFile for reliable polling
|
|
154062
|
+
watchFile(RESPONSE_PATH, { interval: 200 }, pollFn);
|
|
154063
|
+
|
|
154064
|
+
// Timeout: deny after TIMEOUT_MS
|
|
154065
|
+
const timeoutTimer = setTimeout(() => {
|
|
154066
|
+
if (resolved) return;
|
|
154067
|
+
resolved = true;
|
|
154068
|
+
try { unwatchFile(RESPONSE_PATH, pollFn); } catch {}
|
|
154069
|
+
try { unlinkSync(PENDING_PATH); } catch {}
|
|
154070
|
+
outputResult({ behavior: 'deny', message: 'Permission request timed out after ' + (TIMEOUT_MS / 1000) + 's' });
|
|
154071
|
+
}, TIMEOUT_MS);
|
|
154072
|
+
});
|
|
154073
|
+
|
|
154074
|
+
function outputResult(decision) {
|
|
154075
|
+
const output = JSON.stringify({
|
|
154076
|
+
hookSpecificOutput: {
|
|
154077
|
+
hookEventName: 'PermissionRequest',
|
|
154078
|
+
decision: decision,
|
|
154079
|
+
},
|
|
154080
|
+
});
|
|
154081
|
+
process.stdout.write(output);
|
|
154082
|
+
process.exit(0);
|
|
154083
|
+
}
|
|
154084
|
+
`;
|
|
154085
|
+
}
|
|
154086
|
+
function buildPermissionHooksConfig() {
|
|
154087
|
+
return {
|
|
154088
|
+
hooks: {
|
|
154089
|
+
PermissionRequest: [
|
|
154090
|
+
{
|
|
154091
|
+
type: "command",
|
|
154092
|
+
command: `node ${PERMISSION_HOOK_SCRIPT_PATH}`
|
|
154225
154093
|
}
|
|
154226
|
-
|
|
154094
|
+
]
|
|
154227
154095
|
}
|
|
154228
|
-
}
|
|
154229
|
-
args.push("-");
|
|
154230
|
-
return args;
|
|
154096
|
+
};
|
|
154231
154097
|
}
|
|
154232
|
-
var
|
|
154233
|
-
|
|
154098
|
+
var PERMISSION_BRIDGE_DIR, PERMISSION_HOOK_SCRIPT_PATH, PERMISSION_BRIDGE_REQUEST_PATH, PERMISSION_BRIDGE_RESPONSE_PATH, PERMISSION_BRIDGE_PENDING_PATH;
|
|
154099
|
+
var init_chunk_CY6AWCC6 = __esm({
|
|
154100
|
+
"../agent-sdk/dist/chunk-CY6AWCC6.js"() {
|
|
154234
154101
|
"use strict";
|
|
154102
|
+
PERMISSION_BRIDGE_DIR = "/tmp/permission-bridge";
|
|
154103
|
+
PERMISSION_HOOK_SCRIPT_PATH = `${PERMISSION_BRIDGE_DIR}/hook.mjs`;
|
|
154104
|
+
PERMISSION_BRIDGE_REQUEST_PATH = `${PERMISSION_BRIDGE_DIR}/request.json`;
|
|
154105
|
+
PERMISSION_BRIDGE_RESPONSE_PATH = `${PERMISSION_BRIDGE_DIR}/response.json`;
|
|
154106
|
+
PERMISSION_BRIDGE_PENDING_PATH = `${PERMISSION_BRIDGE_DIR}/pending`;
|
|
154235
154107
|
}
|
|
154236
154108
|
});
|
|
154237
154109
|
|
|
154238
|
-
// ../agent-sdk/dist/chunk-
|
|
154239
|
-
function
|
|
154240
|
-
|
|
154241
|
-
const
|
|
154242
|
-
|
|
154243
|
-
|
|
154244
|
-
|
|
154245
|
-
}
|
|
154246
|
-
|
|
154247
|
-
}
|
|
154248
|
-
function validateCodexRuntime() {
|
|
154249
|
-
return null;
|
|
154110
|
+
// ../agent-sdk/dist/chunk-J6T3W6RY.js
|
|
154111
|
+
async function installClaudeWrapper(sandboxName, provider) {
|
|
154112
|
+
console.log(`[wrapper] writing ${CLAUDE_WRAPPER_PATH} to ${sandboxName} (${SANDBOX_WRAPPER_SCRIPT6.length} bytes)`);
|
|
154113
|
+
const result = await provider.exec(sandboxName, [
|
|
154114
|
+
"sh",
|
|
154115
|
+
"-c",
|
|
154116
|
+
`cat > ${CLAUDE_WRAPPER_PATH} && chmod +x ${CLAUDE_WRAPPER_PATH} && echo OK`
|
|
154117
|
+
], { stdin: SANDBOX_WRAPPER_SCRIPT6 });
|
|
154118
|
+
console.log(`[wrapper] result: exit=${result.exit_code} stdout="${result.stdout.trim()}" stderr="${result.stderr.trim()}"`);
|
|
154250
154119
|
}
|
|
154251
|
-
var
|
|
154252
|
-
|
|
154120
|
+
var CLAUDE_WRAPPER_PATH, SANDBOX_WRAPPER_SCRIPT6;
|
|
154121
|
+
var init_chunk_J6T3W6RY = __esm({
|
|
154122
|
+
"../agent-sdk/dist/chunk-J6T3W6RY.js"() {
|
|
154253
154123
|
"use strict";
|
|
154254
|
-
|
|
154124
|
+
CLAUDE_WRAPPER_PATH = "/tmp/.claude-wrapper";
|
|
154125
|
+
SANDBOX_WRAPPER_SCRIPT6 = `#!/bin/sh
|
|
154126
|
+
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
|
|
154127
|
+
# V8 bytecode cache: Node.js caches compiled JS to disk.
|
|
154128
|
+
# First run builds cache (~55s). Subsequent runs skip V8 compilation (~8s startup).
|
|
154129
|
+
export NODE_COMPILE_CACHE=/tmp/v8-cache
|
|
154130
|
+
mkdir -p /tmp/v8-cache
|
|
154131
|
+
# Install claude CLI if not present
|
|
154132
|
+
if ! command -v claude >/dev/null 2>&1; then npm install -g @anthropic-ai/claude-code; fi
|
|
154133
|
+
claude --version >&2 2>/dev/null || true
|
|
154134
|
+
# Sprites keep-alive: prevent VM suspension during long agent turns.
|
|
154135
|
+
# Only activates if the sprites management socket exists (sprites containers only).
|
|
154136
|
+
SPRITE_SOCK="/.sprite/api.sock"
|
|
154137
|
+
HEARTBEAT_PID=""
|
|
154138
|
+
if [ -S "$SPRITE_SOCK" ]; then
|
|
154139
|
+
# Create task with 5-minute expiry
|
|
154140
|
+
curl -sf --unix-socket "$SPRITE_SOCK" -H "Host: sprite" -X POST http://sprite/v1/tasks -H "Content-Type: application/json" -d '{"name":"agent-turn","expire":"5m"}' >/dev/null 2>&1
|
|
154141
|
+
# Background heartbeat: refresh every 60s
|
|
154142
|
+
(while sleep 60; do
|
|
154143
|
+
curl -sf --unix-socket "$SPRITE_SOCK" -H "Host: sprite" -X PUT http://sprite/v1/tasks/agent-turn -H "Content-Type: application/json" -d '{"expire":"5m"}' >/dev/null 2>&1
|
|
154144
|
+
done) &
|
|
154145
|
+
HEARTBEAT_PID=$!
|
|
154146
|
+
# Cleanup on exit
|
|
154147
|
+
trap 'curl -sf --unix-socket "$SPRITE_SOCK" -H "Host: sprite" -X DELETE http://sprite/v1/tasks/agent-turn >/dev/null 2>&1; [ -n "$HEARTBEAT_PID" ] && kill $HEARTBEAT_PID 2>/dev/null' EXIT
|
|
154148
|
+
fi
|
|
154149
|
+
# Read env vars from stdin until blank line, save remaining stdin to temp file
|
|
154150
|
+
PROMPT_FILE=$(mktemp)
|
|
154151
|
+
while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done
|
|
154152
|
+
cat > "$PROMPT_FILE"
|
|
154153
|
+
# Run as non-root if possible (claude requires non-root for bypassPermissions)
|
|
154154
|
+
if [ "$(id -u)" = "0" ]; then
|
|
154155
|
+
if ! id agent >/dev/null 2>&1; then
|
|
154156
|
+
useradd -m -s /bin/sh agent 2>/dev/null || adduser -D -s /bin/sh agent 2>/dev/null
|
|
154157
|
+
fi
|
|
154158
|
+
chown -R agent /tmp/ 2>/dev/null
|
|
154159
|
+
chown -R agent /home/agent 2>/dev/null
|
|
154160
|
+
# Export env vars to a file for the agent user
|
|
154161
|
+
ENV_FILE=$(mktemp)
|
|
154162
|
+
env | grep -E '^(ANTHROPIC_API_KEY|CLAUDE_CODE_OAUTH_TOKEN|NODE_COMPILE_CACHE|PATH)=' > "$ENV_FILE"
|
|
154163
|
+
chown agent "$ENV_FILE" "$PROMPT_FILE"
|
|
154164
|
+
exec su -s /bin/sh agent -c ". $ENV_FILE && HOME=/home/agent claude $* < $PROMPT_FILE; rm -f $ENV_FILE $PROMPT_FILE"
|
|
154165
|
+
fi
|
|
154166
|
+
# Run claude and clean up temp file (no exec \u2014 let cleanup run)
|
|
154167
|
+
claude "$@" < "$PROMPT_FILE"
|
|
154168
|
+
EXIT_CODE=$?
|
|
154169
|
+
rm -f "$PROMPT_FILE"
|
|
154170
|
+
exit $EXIT_CODE
|
|
154171
|
+
`;
|
|
154255
154172
|
}
|
|
154256
154173
|
});
|
|
154257
154174
|
|
|
154258
|
-
// ../agent-sdk/dist/chunk-
|
|
154175
|
+
// ../agent-sdk/dist/chunk-JN3DHH7Z.js
|
|
154259
154176
|
function buildTurn6(input) {
|
|
154260
|
-
const { agent, promptText, toolResults } = input;
|
|
154177
|
+
const { agent, backendSessionId, promptText, toolResults } = input;
|
|
154178
|
+
const argsBase = buildClaudeArgs({
|
|
154179
|
+
agent,
|
|
154180
|
+
claudeSessionId: backendSessionId,
|
|
154181
|
+
confirmationMode: agent.confirmation_mode,
|
|
154182
|
+
memoryStores: input.memoryStores
|
|
154183
|
+
});
|
|
154184
|
+
const env3 = buildClaudeAuthEnv();
|
|
154185
|
+
const customTools = agent.tools.filter((t2) => t2.type === "custom");
|
|
154186
|
+
const hasBridgeTools = customTools.length > 0 || agent.threads_enabled;
|
|
154187
|
+
if (hasBridgeTools || agent.mcp_servers && agent.mcp_servers.length > 0) {
|
|
154188
|
+
const mcpIdx = argsBase.indexOf("--mcp-config");
|
|
154189
|
+
let existingServers = {};
|
|
154190
|
+
if (mcpIdx >= 0 && mcpIdx + 1 < argsBase.length) {
|
|
154191
|
+
try {
|
|
154192
|
+
const existing = JSON.parse(argsBase[mcpIdx + 1]);
|
|
154193
|
+
existingServers = existing.mcpServers ?? {};
|
|
154194
|
+
} catch {
|
|
154195
|
+
}
|
|
154196
|
+
argsBase.splice(mcpIdx, 2);
|
|
154197
|
+
}
|
|
154198
|
+
const merged = hasBridgeTools ? buildBridgeMcpConfig(existingServers) : existingServers;
|
|
154199
|
+
argsBase.push("--mcp-config", JSON.stringify({ mcpServers: merged }));
|
|
154200
|
+
}
|
|
154261
154201
|
if (toolResults.length > 0) {
|
|
154262
|
-
|
|
154263
|
-
|
|
154264
|
-
|
|
154265
|
-
|
|
154202
|
+
const args = [...argsBase, "--input-format", "stream-json"];
|
|
154203
|
+
const content = [];
|
|
154204
|
+
if (promptText) {
|
|
154205
|
+
content.push({ type: "text", text: promptText });
|
|
154206
|
+
}
|
|
154207
|
+
for (const r of toolResults) {
|
|
154208
|
+
content.push({
|
|
154209
|
+
type: "tool_result",
|
|
154210
|
+
tool_use_id: r.custom_tool_use_id,
|
|
154211
|
+
content: r.content
|
|
154212
|
+
});
|
|
154213
|
+
}
|
|
154214
|
+
const userFrame = JSON.stringify({
|
|
154215
|
+
type: "user",
|
|
154216
|
+
message: { role: "user", content }
|
|
154217
|
+
});
|
|
154218
|
+
return { argv: args, env: env3, stdin: userFrame };
|
|
154219
|
+
}
|
|
154220
|
+
return { argv: argsBase, env: env3, stdin: promptText };
|
|
154221
|
+
}
|
|
154222
|
+
function validateRuntime() {
|
|
154223
|
+
const cfg = getConfig();
|
|
154224
|
+
if (!cfg.anthropicApiKey && !cfg.claudeToken) {
|
|
154225
|
+
return null;
|
|
154226
|
+
}
|
|
154227
|
+
return null;
|
|
154228
|
+
}
|
|
154229
|
+
async function installToolBridge(sandboxName, customTools, provider) {
|
|
154230
|
+
if (customTools.length === 0) return;
|
|
154231
|
+
await provider.exec(sandboxName, ["mkdir", "-p", TOOL_BRIDGE_DIR]);
|
|
154232
|
+
await provider.exec(
|
|
154233
|
+
sandboxName,
|
|
154234
|
+
["sh", "-c", `cat > "${TOOL_BRIDGE_SCRIPT_PATH}"`],
|
|
154235
|
+
{ stdin: generateBridgeScript() }
|
|
154236
|
+
);
|
|
154237
|
+
await provider.exec(
|
|
154238
|
+
sandboxName,
|
|
154239
|
+
["sh", "-c", `cat > "${TOOL_BRIDGE_TOOLS_PATH}"`],
|
|
154240
|
+
{ stdin: toolsToJson(customTools) }
|
|
154241
|
+
);
|
|
154242
|
+
await provider.exec(sandboxName, ["chmod", "+x", TOOL_BRIDGE_SCRIPT_PATH]);
|
|
154243
|
+
}
|
|
154244
|
+
async function installPermissionHook(sandboxName, provider) {
|
|
154245
|
+
await provider.exec(sandboxName, ["mkdir", "-p", PERMISSION_BRIDGE_DIR]);
|
|
154246
|
+
await provider.exec(
|
|
154247
|
+
sandboxName,
|
|
154248
|
+
["sh", "-c", `cat > ${PERMISSION_HOOK_SCRIPT_PATH}`],
|
|
154249
|
+
{ stdin: generatePermissionHookScript() }
|
|
154250
|
+
);
|
|
154251
|
+
await provider.exec(sandboxName, ["chmod", "+x", PERMISSION_HOOK_SCRIPT_PATH]);
|
|
154252
|
+
const hooksConfig = buildPermissionHooksConfig();
|
|
154253
|
+
const homeResult = await provider.exec(sandboxName, ["sh", "-c", "echo $HOME"]);
|
|
154254
|
+
const homeDir = homeResult.stdout.replace(/[\x00-\x1f]/g, "").trim() || "/home/sprite";
|
|
154255
|
+
const settingsPath = `${homeDir}/.claude/settings.json`;
|
|
154256
|
+
let existingSettings = {};
|
|
154257
|
+
try {
|
|
154258
|
+
const result = await provider.exec(
|
|
154259
|
+
sandboxName,
|
|
154260
|
+
["cat", settingsPath]
|
|
154266
154261
|
);
|
|
154262
|
+
if (result.stdout.trim()) {
|
|
154263
|
+
existingSettings = JSON.parse(result.stdout);
|
|
154264
|
+
}
|
|
154265
|
+
} catch {
|
|
154267
154266
|
}
|
|
154268
|
-
const
|
|
154269
|
-
|
|
154270
|
-
|
|
154271
|
-
|
|
154267
|
+
const merged = { ...existingSettings, ...hooksConfig };
|
|
154268
|
+
await provider.exec(
|
|
154269
|
+
sandboxName,
|
|
154270
|
+
["sh", "-c", `mkdir -p "${homeDir}/.claude" && cat > "${settingsPath}"`],
|
|
154271
|
+
{ stdin: JSON.stringify(merged, null, 2) }
|
|
154272
|
+
);
|
|
154272
154273
|
}
|
|
154273
|
-
var
|
|
154274
|
-
var
|
|
154275
|
-
"../agent-sdk/dist/chunk-
|
|
154274
|
+
var claudeBackend;
|
|
154275
|
+
var init_chunk_JN3DHH7Z = __esm({
|
|
154276
|
+
"../agent-sdk/dist/chunk-JN3DHH7Z.js"() {
|
|
154276
154277
|
"use strict";
|
|
154277
|
-
|
|
154278
|
-
|
|
154279
|
-
|
|
154280
|
-
|
|
154281
|
-
|
|
154282
|
-
|
|
154283
|
-
|
|
154284
|
-
|
|
154285
|
-
|
|
154286
|
-
wrapperPath: CODEX_WRAPPER_PATH,
|
|
154278
|
+
init_chunk_VRRGSQI7();
|
|
154279
|
+
init_chunk_D6RQPBRG();
|
|
154280
|
+
init_chunk_YJCH35J4();
|
|
154281
|
+
init_chunk_CY6AWCC6();
|
|
154282
|
+
init_chunk_J6T3W6RY();
|
|
154283
|
+
init_chunk_6EIONZ7F();
|
|
154284
|
+
claudeBackend = {
|
|
154285
|
+
name: "claude",
|
|
154286
|
+
wrapperPath: CLAUDE_WRAPPER_PATH,
|
|
154287
154287
|
buildTurn: buildTurn6,
|
|
154288
|
-
createTranslator: (opts) =>
|
|
154289
|
-
prepareOnSandbox: (name, provider) =>
|
|
154290
|
-
validateRuntime
|
|
154288
|
+
createTranslator: (opts) => createClaudeTranslator(opts),
|
|
154289
|
+
prepareOnSandbox: (name, provider) => installClaudeWrapper(name, provider),
|
|
154290
|
+
validateRuntime
|
|
154291
154291
|
};
|
|
154292
154292
|
}
|
|
154293
154293
|
});
|
|
154294
154294
|
|
|
154295
|
-
// ../agent-sdk/dist/chunk-
|
|
154295
|
+
// ../agent-sdk/dist/chunk-V5RHOS43.js
|
|
154296
154296
|
function resolveBackend(name) {
|
|
154297
154297
|
const key = name ?? "claude";
|
|
154298
154298
|
const b2 = BACKENDS[key];
|
|
@@ -154300,15 +154300,15 @@ function resolveBackend(name) {
|
|
|
154300
154300
|
return b2;
|
|
154301
154301
|
}
|
|
154302
154302
|
var BACKENDS;
|
|
154303
|
-
var
|
|
154304
|
-
"../agent-sdk/dist/chunk-
|
|
154303
|
+
var init_chunk_V5RHOS43 = __esm({
|
|
154304
|
+
"../agent-sdk/dist/chunk-V5RHOS43.js"() {
|
|
154305
154305
|
"use strict";
|
|
154306
154306
|
init_chunk_J7F2OFWQ();
|
|
154307
154307
|
init_chunk_A3FQHVUG();
|
|
154308
154308
|
init_chunk_REHIJQUD();
|
|
154309
|
-
|
|
154310
|
-
|
|
154311
|
-
|
|
154309
|
+
init_chunk_65XY7HRS();
|
|
154310
|
+
init_chunk_WEUPM3IN();
|
|
154311
|
+
init_chunk_JN3DHH7Z();
|
|
154312
154312
|
BACKENDS = {
|
|
154313
154313
|
claude: claudeBackend,
|
|
154314
154314
|
opencode: opencodeBackend,
|
|
@@ -154336,12 +154336,12 @@ __export(claude_exports, {
|
|
|
154336
154336
|
var init_claude = __esm({
|
|
154337
154337
|
"../agent-sdk/dist/backends/claude/index.js"() {
|
|
154338
154338
|
"use strict";
|
|
154339
|
-
|
|
154340
|
-
init_chunk_YJCH35J4();
|
|
154341
|
-
init_chunk_CY6AWCC6();
|
|
154339
|
+
init_chunk_JN3DHH7Z();
|
|
154342
154340
|
init_chunk_VRRGSQI7();
|
|
154343
154341
|
init_chunk_D6RQPBRG();
|
|
154342
|
+
init_chunk_YJCH35J4();
|
|
154344
154343
|
init_chunk_YE2RMJY7();
|
|
154344
|
+
init_chunk_CY6AWCC6();
|
|
154345
154345
|
init_chunk_FX2AEKOV();
|
|
154346
154346
|
init_chunk_J6T3W6RY();
|
|
154347
154347
|
init_chunk_F4WUVOLE();
|
|
@@ -154382,7 +154382,7 @@ var init_session_resources2 = __esm({
|
|
|
154382
154382
|
}
|
|
154383
154383
|
});
|
|
154384
154384
|
|
|
154385
|
-
// ../agent-sdk/dist/chunk-
|
|
154385
|
+
// ../agent-sdk/dist/chunk-LJ2ZXLLT.js
|
|
154386
154386
|
function hydrate8(row) {
|
|
154387
154387
|
return {
|
|
154388
154388
|
id: row.id,
|
|
@@ -154462,8 +154462,7 @@ function listFiles(opts) {
|
|
|
154462
154462
|
const hasMore2 = rows2.length > limit;
|
|
154463
154463
|
if (hasMore2) rows2.pop();
|
|
154464
154464
|
const records2 = rows2.map(hydrate8);
|
|
154465
|
-
|
|
154466
|
-
return { data: records2, next_page: nextPage2 };
|
|
154465
|
+
return { data: records2, has_more: hasMore2, first_id: records2[0]?.id ?? null, last_id: records2[records2.length - 1]?.id ?? null };
|
|
154467
154466
|
}
|
|
154468
154467
|
let cursorCondition;
|
|
154469
154468
|
if (opts?.after_id) {
|
|
@@ -154476,8 +154475,7 @@ function listFiles(opts) {
|
|
|
154476
154475
|
const hasMore = rows.length > limit;
|
|
154477
154476
|
if (hasMore) rows.pop();
|
|
154478
154477
|
const records = rows.map(hydrate8);
|
|
154479
|
-
|
|
154480
|
-
return { data: records, next_page: nextPage };
|
|
154478
|
+
return { data: records, has_more: hasMore, first_id: records[0]?.id ?? null, last_id: records[records.length - 1]?.id ?? null };
|
|
154481
154479
|
}
|
|
154482
154480
|
function countFilesForScope(scopeId) {
|
|
154483
154481
|
const db = getDrizzle();
|
|
@@ -154497,8 +154495,8 @@ function deleteFileRecord(id) {
|
|
|
154497
154495
|
db.delete(schema_exports.files).where(eq(schema_exports.files.id, id)).run();
|
|
154498
154496
|
return { id, type: "file_deleted" };
|
|
154499
154497
|
}
|
|
154500
|
-
var
|
|
154501
|
-
"../agent-sdk/dist/chunk-
|
|
154498
|
+
var init_chunk_LJ2ZXLLT = __esm({
|
|
154499
|
+
"../agent-sdk/dist/chunk-LJ2ZXLLT.js"() {
|
|
154502
154500
|
"use strict";
|
|
154503
154501
|
init_chunk_F4WUVOLE();
|
|
154504
154502
|
init_chunk_HFDLUBWN();
|
|
@@ -154526,7 +154524,7 @@ __export(files_exports, {
|
|
|
154526
154524
|
var init_files = __esm({
|
|
154527
154525
|
"../agent-sdk/dist/db/files.js"() {
|
|
154528
154526
|
"use strict";
|
|
154529
|
-
|
|
154527
|
+
init_chunk_LJ2ZXLLT();
|
|
154530
154528
|
init_chunk_F4WUVOLE();
|
|
154531
154529
|
init_chunk_HFDLUBWN();
|
|
154532
154530
|
init_chunk_ZDDMPGN4();
|
|
@@ -154917,7 +154915,7 @@ var init_memory = __esm({
|
|
|
154917
154915
|
}
|
|
154918
154916
|
});
|
|
154919
154917
|
|
|
154920
|
-
// ../agent-sdk/dist/chunk-
|
|
154918
|
+
// ../agent-sdk/dist/chunk-IL2CZHNC.js
|
|
154921
154919
|
function wrapProviderWithSecrets(provider, secrets) {
|
|
154922
154920
|
if (!secrets || Object.keys(secrets).length === 0) return provider;
|
|
154923
154921
|
return {
|
|
@@ -155486,8 +155484,8 @@ async function reconcileDockerOrphanSandboxes() {
|
|
|
155486
155484
|
return { deleted, kept };
|
|
155487
155485
|
}
|
|
155488
155486
|
var import_ulid2, lcLog, SANDBOX_NAME_PREFIX;
|
|
155489
|
-
var
|
|
155490
|
-
"../agent-sdk/dist/chunk-
|
|
155487
|
+
var init_chunk_IL2CZHNC = __esm({
|
|
155488
|
+
"../agent-sdk/dist/chunk-IL2CZHNC.js"() {
|
|
155491
155489
|
"use strict";
|
|
155492
155490
|
init_chunk_4XXQAVKE();
|
|
155493
155491
|
init_chunk_JNSJKHYX();
|
|
@@ -155499,7 +155497,7 @@ var init_chunk_3YWYIVEQ = __esm({
|
|
|
155499
155497
|
init_chunk_NSUVDKNC();
|
|
155500
155498
|
init_chunk_G7KUVNDY();
|
|
155501
155499
|
init_chunk_6U6HEVSN();
|
|
155502
|
-
|
|
155500
|
+
init_chunk_V5RHOS43();
|
|
155503
155501
|
init_chunk_6EIONZ7F();
|
|
155504
155502
|
init_chunk_HFDLUBWN();
|
|
155505
155503
|
init_chunk_EZYKRG4W();
|
|
@@ -155967,7 +155965,7 @@ var init_container_file_sync = __esm({
|
|
|
155967
155965
|
"../agent-sdk/dist/sync/container-file-sync.js"() {
|
|
155968
155966
|
"use strict";
|
|
155969
155967
|
init_chunk_STPT3SWU();
|
|
155970
|
-
|
|
155968
|
+
init_chunk_LJ2ZXLLT();
|
|
155971
155969
|
init_chunk_OEFJPZYH();
|
|
155972
155970
|
init_chunk_F4WUVOLE();
|
|
155973
155971
|
init_chunk_HFDLUBWN();
|
|
@@ -156628,7 +156626,7 @@ var init_threads = __esm({
|
|
|
156628
156626
|
"../agent-sdk/dist/sessions/threads.js"() {
|
|
156629
156627
|
"use strict";
|
|
156630
156628
|
init_chunk_Z5IENUYV();
|
|
156631
|
-
|
|
156629
|
+
init_chunk_YAJJ7KHX();
|
|
156632
156630
|
init_chunk_PJZ5TQYW();
|
|
156633
156631
|
init_chunk_AU4NAQGA();
|
|
156634
156632
|
init_chunk_H6TQGV4L();
|
|
@@ -156639,7 +156637,7 @@ var init_threads = __esm({
|
|
|
156639
156637
|
init_chunk_DZKBUOYU();
|
|
156640
156638
|
init_chunk_WK33IBKY();
|
|
156641
156639
|
init_chunk_LAWTTG2E();
|
|
156642
|
-
|
|
156640
|
+
init_chunk_IL2CZHNC();
|
|
156643
156641
|
init_chunk_4XXQAVKE();
|
|
156644
156642
|
init_chunk_JNSJKHYX();
|
|
156645
156643
|
init_chunk_5ZFOKZGR();
|
|
@@ -156657,7 +156655,7 @@ var init_threads = __esm({
|
|
|
156657
156655
|
init_chunk_G7KUVNDY();
|
|
156658
156656
|
init_chunk_6U6HEVSN();
|
|
156659
156657
|
init_chunk_YTBVILAH();
|
|
156660
|
-
|
|
156658
|
+
init_chunk_V5RHOS43();
|
|
156661
156659
|
init_chunk_J7F2OFWQ();
|
|
156662
156660
|
init_chunk_B6E6BVNK();
|
|
156663
156661
|
init_chunk_6SD6MC2B();
|
|
@@ -156676,25 +156674,25 @@ var init_threads = __esm({
|
|
|
156676
156674
|
init_chunk_UY3VT3HQ();
|
|
156677
156675
|
init_chunk_PDWLVL34();
|
|
156678
156676
|
init_chunk_QCGIYXN4();
|
|
156679
|
-
|
|
156680
|
-
init_chunk_YJCH35J4();
|
|
156681
|
-
init_chunk_CY6AWCC6();
|
|
156682
|
-
init_chunk_VRRGSQI7();
|
|
156683
|
-
init_chunk_D6RQPBRG();
|
|
156684
|
-
init_chunk_IBYOMAZ3();
|
|
156685
|
-
init_chunk_5PS6KN3J();
|
|
156677
|
+
init_chunk_65XY7HRS();
|
|
156686
156678
|
init_chunk_TPMZO6S2();
|
|
156687
156679
|
init_chunk_M72ERPMT();
|
|
156688
156680
|
init_chunk_AQHYCRTO();
|
|
156689
|
-
init_chunk_KJ2GJLPQ();
|
|
156690
156681
|
init_chunk_7TSTCMII();
|
|
156691
|
-
|
|
156682
|
+
init_chunk_KJ2GJLPQ();
|
|
156683
|
+
init_chunk_IBYOMAZ3();
|
|
156684
|
+
init_chunk_WEUPM3IN();
|
|
156685
|
+
init_chunk_PJYCPDV5();
|
|
156686
|
+
init_chunk_SIO4LO2M();
|
|
156692
156687
|
init_chunk_NMZMRH3E();
|
|
156693
|
-
init_chunk_CULYZ3VA();
|
|
156694
156688
|
init_chunk_XJYR5HE3();
|
|
156689
|
+
init_chunk_CULYZ3VA();
|
|
156690
|
+
init_chunk_JN3DHH7Z();
|
|
156691
|
+
init_chunk_VRRGSQI7();
|
|
156692
|
+
init_chunk_D6RQPBRG();
|
|
156693
|
+
init_chunk_YJCH35J4();
|
|
156695
156694
|
init_chunk_YE2RMJY7();
|
|
156696
|
-
|
|
156697
|
-
init_chunk_SIO4LO2M();
|
|
156695
|
+
init_chunk_CY6AWCC6();
|
|
156698
156696
|
init_chunk_FX2AEKOV();
|
|
156699
156697
|
init_chunk_J6T3W6RY();
|
|
156700
156698
|
init_chunk_F4WUVOLE();
|
|
@@ -156713,7 +156711,7 @@ var init_threads = __esm({
|
|
|
156713
156711
|
}
|
|
156714
156712
|
});
|
|
156715
156713
|
|
|
156716
|
-
// ../agent-sdk/dist/chunk-
|
|
156714
|
+
// ../agent-sdk/dist/chunk-YAJJ7KHX.js
|
|
156717
156715
|
function formatStopReason(reason, eventIds) {
|
|
156718
156716
|
if (reason === "custom_tool_call") {
|
|
156719
156717
|
return { type: "requires_action", event_ids: eventIds ?? [] };
|
|
@@ -157619,8 +157617,8 @@ async function writeToolBridgeResponse(sessionId, content) {
|
|
|
157619
157617
|
pendingToolBridgeCalls.delete(sessionId);
|
|
157620
157618
|
}
|
|
157621
157619
|
var gd, pendingToolBridgeCalls, customToolCallCounts, MAX_CUSTOM_TOOL_CALLS_PER_TURN;
|
|
157622
|
-
var
|
|
157623
|
-
"../agent-sdk/dist/chunk-
|
|
157620
|
+
var init_chunk_YAJJ7KHX = __esm({
|
|
157621
|
+
"../agent-sdk/dist/chunk-YAJJ7KHX.js"() {
|
|
157624
157622
|
"use strict";
|
|
157625
157623
|
init_chunk_PJZ5TQYW();
|
|
157626
157624
|
init_chunk_AU4NAQGA();
|
|
@@ -157629,7 +157627,7 @@ var init_chunk_PEZ5ZZBR = __esm({
|
|
|
157629
157627
|
init_chunk_72BKGVBE();
|
|
157630
157628
|
init_chunk_VB6GGRIA();
|
|
157631
157629
|
init_chunk_DZKBUOYU();
|
|
157632
|
-
|
|
157630
|
+
init_chunk_IL2CZHNC();
|
|
157633
157631
|
init_chunk_JNSJKHYX();
|
|
157634
157632
|
init_chunk_RES4BCTF();
|
|
157635
157633
|
init_chunk_ZC7OR65K();
|
|
@@ -157638,9 +157636,9 @@ var init_chunk_PEZ5ZZBR = __esm({
|
|
|
157638
157636
|
init_chunk_XLMNSDUJ();
|
|
157639
157637
|
init_chunk_NSUVDKNC();
|
|
157640
157638
|
init_chunk_6U6HEVSN();
|
|
157641
|
-
|
|
157642
|
-
init_chunk_CY6AWCC6();
|
|
157639
|
+
init_chunk_V5RHOS43();
|
|
157643
157640
|
init_chunk_VRRGSQI7();
|
|
157641
|
+
init_chunk_CY6AWCC6();
|
|
157644
157642
|
init_chunk_FX2AEKOV();
|
|
157645
157643
|
init_chunk_6EIONZ7F();
|
|
157646
157644
|
init_chunk_HFDLUBWN();
|
|
@@ -157655,7 +157653,7 @@ var init_chunk_PEZ5ZZBR = __esm({
|
|
|
157655
157653
|
}
|
|
157656
157654
|
});
|
|
157657
157655
|
|
|
157658
|
-
// ../agent-sdk/dist/chunk-
|
|
157656
|
+
// ../agent-sdk/dist/chunk-2Z4T32WO.js
|
|
157659
157657
|
async function startWorker(opts) {
|
|
157660
157658
|
const pollInterval = opts.pollIntervalMs ?? 5e3;
|
|
157661
157659
|
const workerId = opts.workerId ?? `worker-${process.pid}`;
|
|
@@ -157705,11 +157703,11 @@ async function startWorker(opts) {
|
|
|
157705
157703
|
}
|
|
157706
157704
|
console.log("[worker] stopped");
|
|
157707
157705
|
}
|
|
157708
|
-
var
|
|
157709
|
-
"../agent-sdk/dist/chunk-
|
|
157706
|
+
var init_chunk_2Z4T32WO = __esm({
|
|
157707
|
+
"../agent-sdk/dist/chunk-2Z4T32WO.js"() {
|
|
157710
157708
|
"use strict";
|
|
157711
157709
|
init_chunk_JF777FWD();
|
|
157712
|
-
|
|
157710
|
+
init_chunk_YAJJ7KHX();
|
|
157713
157711
|
}
|
|
157714
157712
|
});
|
|
157715
157713
|
|
|
@@ -158935,17 +158933,19 @@ var init_chunk_7346CKTF = __esm({
|
|
|
158935
158933
|
}
|
|
158936
158934
|
});
|
|
158937
158935
|
|
|
158938
|
-
// ../agent-sdk/dist/chunk-
|
|
158936
|
+
// ../agent-sdk/dist/chunk-EOUNXIPM.js
|
|
158939
158937
|
function listEnvelope(name, item) {
|
|
158940
158938
|
const schema2 = external_exports.object({
|
|
158941
158939
|
data: external_exports.array(item),
|
|
158942
|
-
|
|
158940
|
+
has_more: external_exports.boolean(),
|
|
158941
|
+
first_id: external_exports.string().nullable(),
|
|
158942
|
+
last_id: external_exports.string().nullable()
|
|
158943
158943
|
});
|
|
158944
158944
|
return registry2.register(name, schema2);
|
|
158945
158945
|
}
|
|
158946
158946
|
var import_zod_to_openapi2, UlidId, IsoTimestamp, ErrorEnvelopeSchema, AgentToolsetTool, CustomTool, ToolConfigSchema, McpServerConfigSchema, AgentSkillSchema, ModelConfigSchema, AgentSchema, CreateAgentRequestSchema, UpdateAgentRequestSchema, EnvironmentPackages, EnvironmentNetworking, EnvironmentConfigSchema, EnvironmentSchema, CreateEnvironmentRequestSchema, UpdateEnvironmentRequestSchema, SessionStatsSchema, SessionUsageSchema, SessionStatusSchema, SessionSchema, CreateSessionRequestSchema, UpdateSessionRequestSchema, TextBlock, UserMessageEvent, UserInterruptEvent, UserCustomToolResultEvent, UserToolConfirmationEvent, UserDefineOutcomeEvent, UserEventSchema, UserEventBatchRequestSchema, ManagedEventSchema, VaultSchema, VaultEntrySchema, CreateVaultRequestSchema, UpdateVaultRequestSchema, SetVaultEntryRequestSchema, VaultDeletedResponseSchema, VaultEntryDeletedResponseSchema, BatchOperationSchema, BatchRequestSchema, BatchResultSchema, BatchResponseSchema, AgentListResponseSchema, EnvironmentListResponseSchema, SessionListResponseSchema, EventListResponseSchema, VaultListResponseSchema, VaultEntryListResponseSchema, AgentDeletedResponseSchema, SessionDeletedResponseSchema, EnvironmentDeletedResponseSchema, UserEventAppendResponseSchema, FileScopeSchema, FileRecordSchema, FileListResponseSchema, FileDeletedResponseSchema, VaultCredentialSchema, CreateCredentialRequestSchema, UpdateCredentialRequestSchema, CredentialListResponseSchema, CredentialDeletedResponseSchema, MemoryStoreSchema, CreateMemoryStoreRequestSchema, MemoryStoreListResponseSchema, MemoryStoreDeletedResponseSchema, MemorySchema, CreateMemoryRequestSchema, UpdateMemoryRequestSchema, MemoryListResponseSchema, MemoryDeletedResponseSchema, SessionResourceSchema, AddResourceRequestSchema, ResourceListResponseSchema, ResourceDeletedResponseSchema, KeyScopeSchema, KeyPermissionsSchema, ApiKeySchema, ApiKeyCreatedSchema, CreateApiKeyRequestSchema, PatchApiKeyRequestSchema, ApiKeyListResponseSchema, ApiKeyRevokedResponseSchema, ApiKeyActivityResponseSchema, UpstreamKeySchema, AddUpstreamKeyRequestSchema, PatchUpstreamKeyRequestSchema, UpstreamKeyListResponseSchema, UpstreamKeyDeletedResponseSchema, TenantSchema, CreateTenantRequestSchema, PatchTenantRequestSchema, TenantListResponseSchema, TenantArchivedResponseSchema, AuditEntrySchema, AuditListResponseSchema, TraceListItemSchema, TraceListResponseSchema, SpanNodeSchema, TraceDetailSchema, TraceExportResponseSchema, SkillsCatalogResponseSchema, SkillsSearchResponseSchema, SkillsStatsResponseSchema, SkillsSourcesResponseSchema, MetricsTotalsSchema, MetricsResponseSchema, ApiMetricsResponseSchema, PutSettingRequestSchema, SettingResponseSchema, ProviderStatusResponseSchema, ModelEntrySchema, ModelListResponseSchema, WhoamiResponseSchema, LicenseResponseSchema;
|
|
158947
|
-
var
|
|
158948
|
-
"../agent-sdk/dist/chunk-
|
|
158947
|
+
var init_chunk_EOUNXIPM = __esm({
|
|
158948
|
+
"../agent-sdk/dist/chunk-EOUNXIPM.js"() {
|
|
158949
158949
|
"use strict";
|
|
158950
158950
|
init_chunk_7346CKTF();
|
|
158951
158951
|
init_zod();
|
|
@@ -159084,7 +159084,10 @@ var init_chunk_SAI6LBXW = __esm({
|
|
|
159084
159084
|
"CreateAgentRequest",
|
|
159085
159085
|
external_exports.object({
|
|
159086
159086
|
name: external_exports.string().min(1).openapi({ example: "my-agent" }),
|
|
159087
|
-
model: external_exports.
|
|
159087
|
+
model: external_exports.union([
|
|
159088
|
+
external_exports.string().openapi({ example: "claude-sonnet-4-6" }),
|
|
159089
|
+
external_exports.object({ id: external_exports.string().min(1), speed: external_exports.enum(["standard", "fast"]).optional() }).openapi({ example: { id: "claude-sonnet-4-6" } })
|
|
159090
|
+
]).openapi({ description: 'Model identifier \u2014 either a bare string (`"claude-sonnet-4-6"`) or an object (`{id, speed?}`). Do not include provider prefixes.' }),
|
|
159088
159091
|
description: external_exports.string().max(2048).optional().openapi({
|
|
159089
159092
|
description: "Human-readable description of the agent."
|
|
159090
159093
|
}),
|
|
@@ -159579,7 +159582,9 @@ var init_chunk_SAI6LBXW = __esm({
|
|
|
159579
159582
|
"FileListResponse",
|
|
159580
159583
|
external_exports.object({
|
|
159581
159584
|
data: external_exports.array(FileRecordSchema),
|
|
159582
|
-
|
|
159585
|
+
has_more: external_exports.boolean().openapi({ description: "Whether more results exist beyond this page." }),
|
|
159586
|
+
first_id: external_exports.string().nullable().openapi({ description: "ID of the first item in this page." }),
|
|
159587
|
+
last_id: external_exports.string().nullable().openapi({ description: "ID of the last item in this page. Pass as after_id for the next page." })
|
|
159583
159588
|
})
|
|
159584
159589
|
);
|
|
159585
159590
|
FileDeletedResponseSchema = registry2.register(
|
|
@@ -159892,7 +159897,9 @@ var init_chunk_SAI6LBXW = __esm({
|
|
|
159892
159897
|
"AuditListResponse",
|
|
159893
159898
|
external_exports.object({
|
|
159894
159899
|
data: external_exports.array(AuditEntrySchema),
|
|
159895
|
-
|
|
159900
|
+
has_more: external_exports.boolean(),
|
|
159901
|
+
first_id: external_exports.string().nullable(),
|
|
159902
|
+
last_id: external_exports.string().nullable()
|
|
159896
159903
|
})
|
|
159897
159904
|
);
|
|
159898
159905
|
TraceListItemSchema = registry2.register(
|
|
@@ -160094,7 +160101,7 @@ var init_chunk_SAI6LBXW = __esm({
|
|
|
160094
160101
|
}
|
|
160095
160102
|
});
|
|
160096
160103
|
|
|
160097
|
-
// ../agent-sdk/dist/chunk-
|
|
160104
|
+
// ../agent-sdk/dist/chunk-CNMMJFJI.js
|
|
160098
160105
|
function buildOpenApiDocument(opts) {
|
|
160099
160106
|
const generator = new import_zod_to_openapi3.OpenApiGeneratorV31(registry2.definitions);
|
|
160100
160107
|
return generator.generateDocument({
|
|
@@ -160132,10 +160139,10 @@ function buildOpenApiDocument(opts) {
|
|
|
160132
160139
|
});
|
|
160133
160140
|
}
|
|
160134
160141
|
var import_zod_to_openapi3, ErrorResponses;
|
|
160135
|
-
var
|
|
160136
|
-
"../agent-sdk/dist/chunk-
|
|
160142
|
+
var init_chunk_CNMMJFJI = __esm({
|
|
160143
|
+
"../agent-sdk/dist/chunk-CNMMJFJI.js"() {
|
|
160137
160144
|
"use strict";
|
|
160138
|
-
|
|
160145
|
+
init_chunk_EOUNXIPM();
|
|
160139
160146
|
init_chunk_7346CKTF();
|
|
160140
160147
|
init_zod();
|
|
160141
160148
|
import_zod_to_openapi3 = __toESM(require_dist2(), 1);
|
|
@@ -215475,7 +215482,7 @@ var init_chunk_3MQ2FWXS = __esm({
|
|
|
215475
215482
|
}
|
|
215476
215483
|
});
|
|
215477
215484
|
|
|
215478
|
-
// ../agent-sdk/dist/chunk-
|
|
215485
|
+
// ../agent-sdk/dist/chunk-AE7UG76I.js
|
|
215479
215486
|
function markStopping() {
|
|
215480
215487
|
stopping = true;
|
|
215481
215488
|
}
|
|
@@ -215564,11 +215571,11 @@ async function evictIdleSessions() {
|
|
|
215564
215571
|
}
|
|
215565
215572
|
}
|
|
215566
215573
|
var sweeping, stopping;
|
|
215567
|
-
var
|
|
215568
|
-
"../agent-sdk/dist/chunk-
|
|
215574
|
+
var init_chunk_AE7UG76I = __esm({
|
|
215575
|
+
"../agent-sdk/dist/chunk-AE7UG76I.js"() {
|
|
215569
215576
|
"use strict";
|
|
215570
215577
|
init_chunk_LAWTTG2E();
|
|
215571
|
-
|
|
215578
|
+
init_chunk_IL2CZHNC();
|
|
215572
215579
|
init_chunk_RES4BCTF();
|
|
215573
215580
|
init_chunk_ZC7OR65K();
|
|
215574
215581
|
init_chunk_XLMNSDUJ();
|
|
@@ -215583,7 +215590,7 @@ var init_chunk_OBKTX34F = __esm({
|
|
|
215583
215590
|
}
|
|
215584
215591
|
});
|
|
215585
215592
|
|
|
215586
|
-
// ../agent-sdk/dist/chunk-
|
|
215593
|
+
// ../agent-sdk/dist/chunk-HGV3Y4PS.js
|
|
215587
215594
|
function installShutdownHandlers() {
|
|
215588
215595
|
if (g13.__caShutdownInstalled) return;
|
|
215589
215596
|
g13.__caShutdownInstalled = true;
|
|
@@ -215626,10 +215633,10 @@ async function shutdown(signal) {
|
|
|
215626
215633
|
process.exit(0);
|
|
215627
215634
|
}
|
|
215628
215635
|
var g13, shuttingDown;
|
|
215629
|
-
var
|
|
215630
|
-
"../agent-sdk/dist/chunk-
|
|
215636
|
+
var init_chunk_HGV3Y4PS = __esm({
|
|
215637
|
+
"../agent-sdk/dist/chunk-HGV3Y4PS.js"() {
|
|
215631
215638
|
"use strict";
|
|
215632
|
-
|
|
215639
|
+
init_chunk_AE7UG76I();
|
|
215633
215640
|
init_chunk_AGIXZFHQ();
|
|
215634
215641
|
init_chunk_UYTSKFGK();
|
|
215635
215642
|
init_client();
|
|
@@ -215969,7 +215976,7 @@ var init_file_sync = __esm({
|
|
|
215969
215976
|
init_chunk_HWWFRSAX();
|
|
215970
215977
|
init_chunk_ABUNDZCE();
|
|
215971
215978
|
init_chunk_ZBWKJ42J();
|
|
215972
|
-
|
|
215979
|
+
init_chunk_LJ2ZXLLT();
|
|
215973
215980
|
init_chunk_DZKBUOYU();
|
|
215974
215981
|
init_chunk_RES4BCTF();
|
|
215975
215982
|
init_chunk_MUARVVXF();
|
|
@@ -217737,7 +217744,7 @@ var init_rate_limit = __esm({
|
|
|
217737
217744
|
}
|
|
217738
217745
|
});
|
|
217739
217746
|
|
|
217740
|
-
// ../agent-sdk/dist/chunk-
|
|
217747
|
+
// ../agent-sdk/dist/chunk-ZDURV2LI.js
|
|
217741
217748
|
import path10 from "path";
|
|
217742
217749
|
async function ensureInitialized() {
|
|
217743
217750
|
if (g15.__caInitPromise) return g15.__caInitPromise;
|
|
@@ -217961,18 +217968,18 @@ async function rebuildContainerPool() {
|
|
|
217961
217968
|
}
|
|
217962
217969
|
}
|
|
217963
217970
|
var g15;
|
|
217964
|
-
var
|
|
217965
|
-
"../agent-sdk/dist/chunk-
|
|
217971
|
+
var init_chunk_ZDURV2LI = __esm({
|
|
217972
|
+
"../agent-sdk/dist/chunk-ZDURV2LI.js"() {
|
|
217966
217973
|
"use strict";
|
|
217967
|
-
|
|
217974
|
+
init_chunk_YAJJ7KHX();
|
|
217968
217975
|
init_chunk_B3W3E5CS();
|
|
217969
217976
|
init_chunk_J6ESQUW6();
|
|
217970
217977
|
init_chunk_2KF2TIEY();
|
|
217971
217978
|
init_chunk_3NUTTKE5();
|
|
217972
217979
|
init_chunk_3MQ2FWXS();
|
|
217973
|
-
|
|
217974
|
-
|
|
217975
|
-
|
|
217980
|
+
init_chunk_HGV3Y4PS();
|
|
217981
|
+
init_chunk_AE7UG76I();
|
|
217982
|
+
init_chunk_IL2CZHNC();
|
|
217976
217983
|
init_chunk_RES4BCTF();
|
|
217977
217984
|
init_chunk_ZC7OR65K();
|
|
217978
217985
|
init_chunk_YPXI7Q2M();
|
|
@@ -217990,7 +217997,7 @@ var init_chunk_PLPCYY7I = __esm({
|
|
|
217990
217997
|
}
|
|
217991
217998
|
});
|
|
217992
217999
|
|
|
217993
|
-
// ../agent-sdk/dist/chunk-
|
|
218000
|
+
// ../agent-sdk/dist/chunk-RMCBO7K7.js
|
|
217994
218001
|
async function routeWrap(request2, handler) {
|
|
217995
218002
|
const startedAt = Date.now();
|
|
217996
218003
|
let status = 500;
|
|
@@ -218036,24 +218043,26 @@ function jsonOk(body, status = 200) {
|
|
|
218036
218043
|
}
|
|
218037
218044
|
function paginatedOk(data, requestedLimit) {
|
|
218038
218045
|
const hasMore = data.length === requestedLimit;
|
|
218039
|
-
const
|
|
218040
|
-
|
|
218046
|
+
const firstId = data.length > 0 ? data[0].id : null;
|
|
218047
|
+
const lastId = data.length > 0 ? data[data.length - 1].id : null;
|
|
218048
|
+
return jsonOk({ data, has_more: hasMore, first_id: firstId, last_id: lastId });
|
|
218041
218049
|
}
|
|
218042
218050
|
function decodeCursor(page) {
|
|
218043
218051
|
if (!page) return void 0;
|
|
218052
|
+
if (page.includes("_")) return page;
|
|
218044
218053
|
try {
|
|
218045
218054
|
return Buffer.from(page, "base64url").toString("utf8");
|
|
218046
218055
|
} catch {
|
|
218047
218056
|
return void 0;
|
|
218048
218057
|
}
|
|
218049
218058
|
}
|
|
218050
|
-
var
|
|
218051
|
-
"../agent-sdk/dist/chunk-
|
|
218059
|
+
var init_chunk_RMCBO7K7 = __esm({
|
|
218060
|
+
"../agent-sdk/dist/chunk-RMCBO7K7.js"() {
|
|
218052
218061
|
"use strict";
|
|
218053
218062
|
init_chunk_D2XITRN6();
|
|
218054
218063
|
init_chunk_CWB2DQN5();
|
|
218055
218064
|
init_chunk_HVUWXUUI();
|
|
218056
|
-
|
|
218065
|
+
init_chunk_ZDURV2LI();
|
|
218057
218066
|
init_chunk_3MQ2FWXS();
|
|
218058
218067
|
init_chunk_EZYKRG4W();
|
|
218059
218068
|
}
|
|
@@ -218179,9 +218188,9 @@ var init_dist2 = __esm({
|
|
|
218179
218188
|
"../agent-sdk/dist/index.js"() {
|
|
218180
218189
|
"use strict";
|
|
218181
218190
|
init_chunk_VFSOYCGN();
|
|
218182
|
-
|
|
218183
|
-
|
|
218184
|
-
|
|
218191
|
+
init_chunk_2Z4T32WO();
|
|
218192
|
+
init_chunk_CNMMJFJI();
|
|
218193
|
+
init_chunk_EOUNXIPM();
|
|
218185
218194
|
init_chunk_7346CKTF();
|
|
218186
218195
|
init_chunk_DC2UMEQH();
|
|
218187
218196
|
init_chunk_IC2ETYU5();
|
|
@@ -218192,14 +218201,14 @@ var init_dist2 = __esm({
|
|
|
218192
218201
|
init_chunk_2N2KL4KM();
|
|
218193
218202
|
init_chunk_I2RVN7CP();
|
|
218194
218203
|
init_chunk_K5J4IN2S();
|
|
218195
|
-
|
|
218204
|
+
init_chunk_RMCBO7K7();
|
|
218196
218205
|
init_chunk_D2XITRN6();
|
|
218197
218206
|
init_chunk_CWB2DQN5();
|
|
218198
218207
|
init_chunk_JFHYXFAL();
|
|
218199
218208
|
init_chunk_W6WKXFHN();
|
|
218200
218209
|
init_chunk_HVUWXUUI();
|
|
218201
|
-
|
|
218202
|
-
|
|
218210
|
+
init_chunk_ZDURV2LI();
|
|
218211
|
+
init_chunk_YAJJ7KHX();
|
|
218203
218212
|
init_chunk_PJZ5TQYW();
|
|
218204
218213
|
init_chunk_AU4NAQGA();
|
|
218205
218214
|
init_chunk_H6TQGV4L();
|
|
@@ -218214,10 +218223,10 @@ var init_dist2 = __esm({
|
|
|
218214
218223
|
init_chunk_WK33IBKY();
|
|
218215
218224
|
init_chunk_3NUTTKE5();
|
|
218216
218225
|
init_chunk_3MQ2FWXS();
|
|
218217
|
-
|
|
218218
|
-
|
|
218226
|
+
init_chunk_HGV3Y4PS();
|
|
218227
|
+
init_chunk_AE7UG76I();
|
|
218219
218228
|
init_chunk_LAWTTG2E();
|
|
218220
|
-
|
|
218229
|
+
init_chunk_IL2CZHNC();
|
|
218221
218230
|
init_chunk_4XXQAVKE();
|
|
218222
218231
|
init_chunk_JNSJKHYX();
|
|
218223
218232
|
init_chunk_5ZFOKZGR();
|
|
@@ -218235,7 +218244,7 @@ var init_dist2 = __esm({
|
|
|
218235
218244
|
init_chunk_G7KUVNDY();
|
|
218236
218245
|
init_chunk_6U6HEVSN();
|
|
218237
218246
|
init_chunk_YTBVILAH();
|
|
218238
|
-
|
|
218247
|
+
init_chunk_V5RHOS43();
|
|
218239
218248
|
init_chunk_J7F2OFWQ();
|
|
218240
218249
|
init_chunk_B6E6BVNK();
|
|
218241
218250
|
init_chunk_6SD6MC2B();
|
|
@@ -218254,25 +218263,25 @@ var init_dist2 = __esm({
|
|
|
218254
218263
|
init_chunk_UY3VT3HQ();
|
|
218255
218264
|
init_chunk_PDWLVL34();
|
|
218256
218265
|
init_chunk_QCGIYXN4();
|
|
218257
|
-
|
|
218258
|
-
init_chunk_YJCH35J4();
|
|
218259
|
-
init_chunk_CY6AWCC6();
|
|
218260
|
-
init_chunk_VRRGSQI7();
|
|
218261
|
-
init_chunk_D6RQPBRG();
|
|
218262
|
-
init_chunk_IBYOMAZ3();
|
|
218263
|
-
init_chunk_5PS6KN3J();
|
|
218266
|
+
init_chunk_65XY7HRS();
|
|
218264
218267
|
init_chunk_TPMZO6S2();
|
|
218265
218268
|
init_chunk_M72ERPMT();
|
|
218266
218269
|
init_chunk_AQHYCRTO();
|
|
218267
|
-
init_chunk_KJ2GJLPQ();
|
|
218268
218270
|
init_chunk_7TSTCMII();
|
|
218269
|
-
|
|
218271
|
+
init_chunk_KJ2GJLPQ();
|
|
218272
|
+
init_chunk_IBYOMAZ3();
|
|
218273
|
+
init_chunk_WEUPM3IN();
|
|
218274
|
+
init_chunk_PJYCPDV5();
|
|
218275
|
+
init_chunk_SIO4LO2M();
|
|
218270
218276
|
init_chunk_NMZMRH3E();
|
|
218271
|
-
init_chunk_CULYZ3VA();
|
|
218272
218277
|
init_chunk_XJYR5HE3();
|
|
218278
|
+
init_chunk_CULYZ3VA();
|
|
218279
|
+
init_chunk_JN3DHH7Z();
|
|
218280
|
+
init_chunk_VRRGSQI7();
|
|
218281
|
+
init_chunk_D6RQPBRG();
|
|
218282
|
+
init_chunk_YJCH35J4();
|
|
218273
218283
|
init_chunk_YE2RMJY7();
|
|
218274
|
-
|
|
218275
|
-
init_chunk_SIO4LO2M();
|
|
218284
|
+
init_chunk_CY6AWCC6();
|
|
218276
218285
|
init_chunk_FX2AEKOV();
|
|
218277
218286
|
init_chunk_J6T3W6RY();
|
|
218278
218287
|
init_chunk_F4WUVOLE();
|
|
@@ -218554,7 +218563,7 @@ var init_models = __esm({
|
|
|
218554
218563
|
}
|
|
218555
218564
|
});
|
|
218556
218565
|
|
|
218557
|
-
// ../agent-sdk/dist/chunk-
|
|
218566
|
+
// ../agent-sdk/dist/chunk-BVBVWMQS.js
|
|
218558
218567
|
function getAgentTenantId(id) {
|
|
218559
218568
|
const row = getDb().prepare(`SELECT tenant_id FROM agents WHERE id = ?`).get(id);
|
|
218560
218569
|
return row?.tenant_id;
|
|
@@ -218703,7 +218712,7 @@ function handleCreateAgent(request2) {
|
|
|
218703
218712
|
}
|
|
218704
218713
|
const backend = resolveBackend(backendName);
|
|
218705
218714
|
const modelId = parsed.data.model.id;
|
|
218706
|
-
const modelSpeed = parsed.data.model.speed;
|
|
218715
|
+
const modelSpeed = "speed" in parsed.data.model ? parsed.data.model.speed : void 0;
|
|
218707
218716
|
const { isValidModelForEngine: isValidModelForEngine2, FALLBACK_MODELS: FALLBACK_MODELS2 } = await Promise.resolve().then(() => (init_models(), models_exports));
|
|
218708
218717
|
if (!isValidModelForEngine2(backendName, modelId)) {
|
|
218709
218718
|
throw badRequest(
|
|
@@ -218760,7 +218769,7 @@ function handleListAgents(request2) {
|
|
|
218760
218769
|
const limit = url2.searchParams.get("limit");
|
|
218761
218770
|
const order = url2.searchParams.get("order");
|
|
218762
218771
|
const includeArchived = url2.searchParams.get("include_archived") === "true";
|
|
218763
|
-
const cursor = decodeCursor(url2.searchParams.get("page"));
|
|
218772
|
+
const cursor = decodeCursor(url2.searchParams.get("after_id") ?? url2.searchParams.get("page"));
|
|
218764
218773
|
const requestedLimit = limit ? Number(limit) : 20;
|
|
218765
218774
|
const data = listAgents({
|
|
218766
218775
|
limit: requestedLimit,
|
|
@@ -218802,7 +218811,7 @@ function handleUpdateAgent(request2, id) {
|
|
|
218802
218811
|
throw conflict(`Version mismatch: expected ${current.version}, got ${parsed.data.version}`);
|
|
218803
218812
|
}
|
|
218804
218813
|
const modelId = parsed.data.model?.id;
|
|
218805
|
-
const modelSpeed = parsed.data.model
|
|
218814
|
+
const modelSpeed = parsed.data.model && "speed" in parsed.data.model ? parsed.data.model.speed : void 0;
|
|
218806
218815
|
let mcpRecord;
|
|
218807
218816
|
if (parsed.data.mcp_servers !== void 0) {
|
|
218808
218817
|
mcpRecord = {};
|
|
@@ -218869,7 +218878,7 @@ function handleListAgentVersions(request2, id) {
|
|
|
218869
218878
|
loadAgentForCaller(auth, id);
|
|
218870
218879
|
const url2 = new URL(req.url);
|
|
218871
218880
|
const limit = url2.searchParams.get("limit");
|
|
218872
|
-
const cursorRaw = decodeCursor(url2.searchParams.get("page"));
|
|
218881
|
+
const cursorRaw = decodeCursor(url2.searchParams.get("after_id") ?? url2.searchParams.get("page"));
|
|
218873
218882
|
const cursor = cursorRaw ? Number(cursorRaw) : void 0;
|
|
218874
218883
|
const requestedLimit = limit ? Number(limit) : 20;
|
|
218875
218884
|
const data = listAgentVersions(id, {
|
|
@@ -218877,20 +218886,21 @@ function handleListAgentVersions(request2, id) {
|
|
|
218877
218886
|
cursor
|
|
218878
218887
|
});
|
|
218879
218888
|
const hasMore = data.length === requestedLimit;
|
|
218880
|
-
const
|
|
218881
|
-
|
|
218889
|
+
const firstId = data.length > 0 ? String(data[0].version) : null;
|
|
218890
|
+
const lastId = data.length > 0 ? String(data[data.length - 1].version) : null;
|
|
218891
|
+
return jsonOk({ data, has_more: hasMore, first_id: firstId, last_id: lastId });
|
|
218882
218892
|
});
|
|
218883
218893
|
}
|
|
218884
218894
|
var InlineSkillSchema, RefSkillSchema, SkillSchema, ToolSchema, ModelConfigSchema2, TEXT_EXTENSIONS, CreateSchema, UpdateSchema;
|
|
218885
|
-
var
|
|
218886
|
-
"../agent-sdk/dist/chunk-
|
|
218895
|
+
var init_chunk_BVBVWMQS = __esm({
|
|
218896
|
+
"../agent-sdk/dist/chunk-BVBVWMQS.js"() {
|
|
218887
218897
|
"use strict";
|
|
218888
218898
|
init_chunk_23UKWXJH();
|
|
218889
|
-
|
|
218899
|
+
init_chunk_RMCBO7K7();
|
|
218890
218900
|
init_chunk_JFHYXFAL();
|
|
218891
218901
|
init_chunk_DZKBUOYU();
|
|
218892
218902
|
init_chunk_6U6HEVSN();
|
|
218893
|
-
|
|
218903
|
+
init_chunk_V5RHOS43();
|
|
218894
218904
|
init_chunk_AGIXZFHQ();
|
|
218895
218905
|
init_chunk_EZYKRG4W();
|
|
218896
218906
|
init_zod();
|
|
@@ -218954,7 +218964,10 @@ var init_chunk_LQQRSOMA = __esm({
|
|
|
218954
218964
|
]);
|
|
218955
218965
|
CreateSchema = external_exports.object({
|
|
218956
218966
|
name: external_exports.string().min(1),
|
|
218957
|
-
model: external_exports.
|
|
218967
|
+
model: external_exports.union([
|
|
218968
|
+
external_exports.string().min(1).transform((s) => ({ id: s })),
|
|
218969
|
+
external_exports.object({ id: external_exports.string().min(1), speed: external_exports.enum(["standard", "fast"]).optional() })
|
|
218970
|
+
]),
|
|
218958
218971
|
description: external_exports.string().max(2048).optional(),
|
|
218959
218972
|
metadata: external_exports.record(external_exports.string(), external_exports.string().max(512)).optional(),
|
|
218960
218973
|
system: external_exports.string().nullish(),
|
|
@@ -219010,7 +219023,10 @@ var init_chunk_LQQRSOMA = __esm({
|
|
|
219010
219023
|
UpdateSchema = external_exports.object({
|
|
219011
219024
|
version: external_exports.number().int().min(1),
|
|
219012
219025
|
name: external_exports.string().min(1).optional(),
|
|
219013
|
-
model: external_exports.
|
|
219026
|
+
model: external_exports.union([
|
|
219027
|
+
external_exports.string().min(1).transform((s) => ({ id: s })),
|
|
219028
|
+
external_exports.object({ id: external_exports.string().min(1), speed: external_exports.enum(["standard", "fast"]).optional() })
|
|
219029
|
+
]).optional(),
|
|
219014
219030
|
description: external_exports.string().max(2048).optional(),
|
|
219015
219031
|
metadata: external_exports.record(external_exports.string(), external_exports.string().max(512)).optional(),
|
|
219016
219032
|
system: external_exports.string().nullish(),
|
|
@@ -219072,16 +219088,16 @@ __export(agents_exports, {
|
|
|
219072
219088
|
var init_agents = __esm({
|
|
219073
219089
|
"../agent-sdk/dist/handlers/agents.js"() {
|
|
219074
219090
|
"use strict";
|
|
219075
|
-
|
|
219091
|
+
init_chunk_BVBVWMQS();
|
|
219076
219092
|
init_chunk_23UKWXJH();
|
|
219077
|
-
|
|
219093
|
+
init_chunk_RMCBO7K7();
|
|
219078
219094
|
init_chunk_D2XITRN6();
|
|
219079
219095
|
init_chunk_CWB2DQN5();
|
|
219080
219096
|
init_chunk_JFHYXFAL();
|
|
219081
219097
|
init_chunk_W6WKXFHN();
|
|
219082
219098
|
init_chunk_HVUWXUUI();
|
|
219083
|
-
|
|
219084
|
-
|
|
219099
|
+
init_chunk_ZDURV2LI();
|
|
219100
|
+
init_chunk_YAJJ7KHX();
|
|
219085
219101
|
init_chunk_PJZ5TQYW();
|
|
219086
219102
|
init_chunk_AU4NAQGA();
|
|
219087
219103
|
init_chunk_H6TQGV4L();
|
|
@@ -219096,10 +219112,10 @@ var init_agents = __esm({
|
|
|
219096
219112
|
init_chunk_WK33IBKY();
|
|
219097
219113
|
init_chunk_3NUTTKE5();
|
|
219098
219114
|
init_chunk_3MQ2FWXS();
|
|
219099
|
-
|
|
219100
|
-
|
|
219115
|
+
init_chunk_HGV3Y4PS();
|
|
219116
|
+
init_chunk_AE7UG76I();
|
|
219101
219117
|
init_chunk_LAWTTG2E();
|
|
219102
|
-
|
|
219118
|
+
init_chunk_IL2CZHNC();
|
|
219103
219119
|
init_chunk_4XXQAVKE();
|
|
219104
219120
|
init_chunk_JNSJKHYX();
|
|
219105
219121
|
init_chunk_5ZFOKZGR();
|
|
@@ -219117,7 +219133,7 @@ var init_agents = __esm({
|
|
|
219117
219133
|
init_chunk_G7KUVNDY();
|
|
219118
219134
|
init_chunk_6U6HEVSN();
|
|
219119
219135
|
init_chunk_YTBVILAH();
|
|
219120
|
-
|
|
219136
|
+
init_chunk_V5RHOS43();
|
|
219121
219137
|
init_chunk_J7F2OFWQ();
|
|
219122
219138
|
init_chunk_B6E6BVNK();
|
|
219123
219139
|
init_chunk_6SD6MC2B();
|
|
@@ -219136,25 +219152,25 @@ var init_agents = __esm({
|
|
|
219136
219152
|
init_chunk_UY3VT3HQ();
|
|
219137
219153
|
init_chunk_PDWLVL34();
|
|
219138
219154
|
init_chunk_QCGIYXN4();
|
|
219139
|
-
|
|
219140
|
-
init_chunk_YJCH35J4();
|
|
219141
|
-
init_chunk_CY6AWCC6();
|
|
219142
|
-
init_chunk_VRRGSQI7();
|
|
219143
|
-
init_chunk_D6RQPBRG();
|
|
219144
|
-
init_chunk_IBYOMAZ3();
|
|
219145
|
-
init_chunk_5PS6KN3J();
|
|
219155
|
+
init_chunk_65XY7HRS();
|
|
219146
219156
|
init_chunk_TPMZO6S2();
|
|
219147
219157
|
init_chunk_M72ERPMT();
|
|
219148
219158
|
init_chunk_AQHYCRTO();
|
|
219149
|
-
init_chunk_KJ2GJLPQ();
|
|
219150
219159
|
init_chunk_7TSTCMII();
|
|
219151
|
-
|
|
219160
|
+
init_chunk_KJ2GJLPQ();
|
|
219161
|
+
init_chunk_IBYOMAZ3();
|
|
219162
|
+
init_chunk_WEUPM3IN();
|
|
219163
|
+
init_chunk_PJYCPDV5();
|
|
219164
|
+
init_chunk_SIO4LO2M();
|
|
219152
219165
|
init_chunk_NMZMRH3E();
|
|
219153
|
-
init_chunk_CULYZ3VA();
|
|
219154
219166
|
init_chunk_XJYR5HE3();
|
|
219167
|
+
init_chunk_CULYZ3VA();
|
|
219168
|
+
init_chunk_JN3DHH7Z();
|
|
219169
|
+
init_chunk_VRRGSQI7();
|
|
219170
|
+
init_chunk_D6RQPBRG();
|
|
219171
|
+
init_chunk_YJCH35J4();
|
|
219155
219172
|
init_chunk_YE2RMJY7();
|
|
219156
|
-
|
|
219157
|
-
init_chunk_SIO4LO2M();
|
|
219173
|
+
init_chunk_CY6AWCC6();
|
|
219158
219174
|
init_chunk_FX2AEKOV();
|
|
219159
219175
|
init_chunk_J6T3W6RY();
|
|
219160
219176
|
init_chunk_F4WUVOLE();
|
|
@@ -219171,7 +219187,7 @@ var init_agents = __esm({
|
|
|
219171
219187
|
}
|
|
219172
219188
|
});
|
|
219173
219189
|
|
|
219174
|
-
// ../agent-sdk/dist/chunk-
|
|
219190
|
+
// ../agent-sdk/dist/chunk-VCU64NHY.js
|
|
219175
219191
|
import { createHash as createHash5 } from "crypto";
|
|
219176
219192
|
function anthropicHeaders(apiKey) {
|
|
219177
219193
|
return {
|
|
@@ -219325,8 +219341,8 @@ async function syncAndCreateSession(opts) {
|
|
|
219325
219341
|
return { remoteSessionId: remoteSession.id };
|
|
219326
219342
|
}
|
|
219327
219343
|
var ANTHROPIC_BASE2, BETA_HEADER3;
|
|
219328
|
-
var
|
|
219329
|
-
"../agent-sdk/dist/chunk-
|
|
219344
|
+
var init_chunk_VCU64NHY = __esm({
|
|
219345
|
+
"../agent-sdk/dist/chunk-VCU64NHY.js"() {
|
|
219330
219346
|
"use strict";
|
|
219331
219347
|
init_chunk_ZBWKJ42J();
|
|
219332
219348
|
init_chunk_DBFPJSOY();
|
|
@@ -219484,7 +219500,7 @@ var init_vaults = __esm({
|
|
|
219484
219500
|
}
|
|
219485
219501
|
});
|
|
219486
219502
|
|
|
219487
|
-
// ../agent-sdk/dist/chunk-
|
|
219503
|
+
// ../agent-sdk/dist/chunk-R6NWAM37.js
|
|
219488
219504
|
function getAgentTenantId2(id) {
|
|
219489
219505
|
const row = getDb().prepare(`SELECT tenant_id FROM agents WHERE id = ?`).get(id);
|
|
219490
219506
|
return row?.tenant_id;
|
|
@@ -219862,7 +219878,7 @@ function handleListSessions(request2) {
|
|
|
219862
219878
|
const limit = url2.searchParams.get("limit");
|
|
219863
219879
|
const order = url2.searchParams.get("order");
|
|
219864
219880
|
const includeArchived = url2.searchParams.get("include_archived") === "true";
|
|
219865
|
-
const cursor = decodeCursor(url2.searchParams.get("page"));
|
|
219881
|
+
const cursor = decodeCursor(url2.searchParams.get("after_id") ?? url2.searchParams.get("page"));
|
|
219866
219882
|
const agentId = url2.searchParams.get("agent_id") ?? void 0;
|
|
219867
219883
|
const agentVersion = url2.searchParams.get("agent_version");
|
|
219868
219884
|
const environmentId = url2.searchParams.get("environment_id") ?? void 0;
|
|
@@ -219988,21 +220004,21 @@ function parseMs(v2) {
|
|
|
219988
220004
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
219989
220005
|
}
|
|
219990
220006
|
var ALLOWED_STATUSES, AgentRef, ResourceSchema, CreateSchema2, UpdateSchema2;
|
|
219991
|
-
var
|
|
219992
|
-
"../agent-sdk/dist/chunk-
|
|
220007
|
+
var init_chunk_R6NWAM37 = __esm({
|
|
220008
|
+
"../agent-sdk/dist/chunk-R6NWAM37.js"() {
|
|
219993
220009
|
"use strict";
|
|
219994
|
-
|
|
220010
|
+
init_chunk_VCU64NHY();
|
|
219995
220011
|
init_chunk_ZBWKJ42J();
|
|
219996
220012
|
init_chunk_23UKWXJH();
|
|
219997
220013
|
init_chunk_DC2UMEQH();
|
|
219998
220014
|
init_chunk_TVV7AE3G();
|
|
219999
220015
|
init_chunk_K5J4IN2S();
|
|
220000
|
-
|
|
220016
|
+
init_chunk_RMCBO7K7();
|
|
220001
220017
|
init_chunk_JFHYXFAL();
|
|
220002
220018
|
init_chunk_H6TQGV4L();
|
|
220003
220019
|
init_chunk_DZKBUOYU();
|
|
220004
220020
|
init_chunk_LAWTTG2E();
|
|
220005
|
-
|
|
220021
|
+
init_chunk_IL2CZHNC();
|
|
220006
220022
|
init_chunk_RES4BCTF();
|
|
220007
220023
|
init_chunk_ZC7OR65K();
|
|
220008
220024
|
init_chunk_NSUVDKNC();
|
|
@@ -220084,21 +220100,21 @@ __export(sessions_exports, {
|
|
|
220084
220100
|
var init_sessions = __esm({
|
|
220085
220101
|
"../agent-sdk/dist/handlers/sessions.js"() {
|
|
220086
220102
|
"use strict";
|
|
220087
|
-
|
|
220088
|
-
|
|
220103
|
+
init_chunk_R6NWAM37();
|
|
220104
|
+
init_chunk_VCU64NHY();
|
|
220089
220105
|
init_chunk_ZBWKJ42J();
|
|
220090
220106
|
init_chunk_23UKWXJH();
|
|
220091
220107
|
init_chunk_DC2UMEQH();
|
|
220092
220108
|
init_chunk_TVV7AE3G();
|
|
220093
220109
|
init_chunk_K5J4IN2S();
|
|
220094
|
-
|
|
220110
|
+
init_chunk_RMCBO7K7();
|
|
220095
220111
|
init_chunk_D2XITRN6();
|
|
220096
220112
|
init_chunk_CWB2DQN5();
|
|
220097
220113
|
init_chunk_JFHYXFAL();
|
|
220098
220114
|
init_chunk_W6WKXFHN();
|
|
220099
220115
|
init_chunk_HVUWXUUI();
|
|
220100
|
-
|
|
220101
|
-
|
|
220116
|
+
init_chunk_ZDURV2LI();
|
|
220117
|
+
init_chunk_YAJJ7KHX();
|
|
220102
220118
|
init_chunk_PJZ5TQYW();
|
|
220103
220119
|
init_chunk_AU4NAQGA();
|
|
220104
220120
|
init_chunk_H6TQGV4L();
|
|
@@ -220113,10 +220129,10 @@ var init_sessions = __esm({
|
|
|
220113
220129
|
init_chunk_WK33IBKY();
|
|
220114
220130
|
init_chunk_3NUTTKE5();
|
|
220115
220131
|
init_chunk_3MQ2FWXS();
|
|
220116
|
-
|
|
220117
|
-
|
|
220132
|
+
init_chunk_HGV3Y4PS();
|
|
220133
|
+
init_chunk_AE7UG76I();
|
|
220118
220134
|
init_chunk_LAWTTG2E();
|
|
220119
|
-
|
|
220135
|
+
init_chunk_IL2CZHNC();
|
|
220120
220136
|
init_chunk_4XXQAVKE();
|
|
220121
220137
|
init_chunk_JNSJKHYX();
|
|
220122
220138
|
init_chunk_5ZFOKZGR();
|
|
@@ -220134,7 +220150,7 @@ var init_sessions = __esm({
|
|
|
220134
220150
|
init_chunk_G7KUVNDY();
|
|
220135
220151
|
init_chunk_6U6HEVSN();
|
|
220136
220152
|
init_chunk_YTBVILAH();
|
|
220137
|
-
|
|
220153
|
+
init_chunk_V5RHOS43();
|
|
220138
220154
|
init_chunk_J7F2OFWQ();
|
|
220139
220155
|
init_chunk_B6E6BVNK();
|
|
220140
220156
|
init_chunk_6SD6MC2B();
|
|
@@ -220153,25 +220169,25 @@ var init_sessions = __esm({
|
|
|
220153
220169
|
init_chunk_UY3VT3HQ();
|
|
220154
220170
|
init_chunk_PDWLVL34();
|
|
220155
220171
|
init_chunk_QCGIYXN4();
|
|
220156
|
-
|
|
220157
|
-
init_chunk_YJCH35J4();
|
|
220158
|
-
init_chunk_CY6AWCC6();
|
|
220159
|
-
init_chunk_VRRGSQI7();
|
|
220160
|
-
init_chunk_D6RQPBRG();
|
|
220161
|
-
init_chunk_IBYOMAZ3();
|
|
220162
|
-
init_chunk_5PS6KN3J();
|
|
220172
|
+
init_chunk_65XY7HRS();
|
|
220163
220173
|
init_chunk_TPMZO6S2();
|
|
220164
220174
|
init_chunk_M72ERPMT();
|
|
220165
220175
|
init_chunk_AQHYCRTO();
|
|
220166
|
-
init_chunk_KJ2GJLPQ();
|
|
220167
220176
|
init_chunk_7TSTCMII();
|
|
220168
|
-
|
|
220177
|
+
init_chunk_KJ2GJLPQ();
|
|
220178
|
+
init_chunk_IBYOMAZ3();
|
|
220179
|
+
init_chunk_WEUPM3IN();
|
|
220180
|
+
init_chunk_PJYCPDV5();
|
|
220181
|
+
init_chunk_SIO4LO2M();
|
|
220169
220182
|
init_chunk_NMZMRH3E();
|
|
220170
|
-
init_chunk_CULYZ3VA();
|
|
220171
220183
|
init_chunk_XJYR5HE3();
|
|
220184
|
+
init_chunk_CULYZ3VA();
|
|
220185
|
+
init_chunk_JN3DHH7Z();
|
|
220186
|
+
init_chunk_VRRGSQI7();
|
|
220187
|
+
init_chunk_D6RQPBRG();
|
|
220188
|
+
init_chunk_YJCH35J4();
|
|
220172
220189
|
init_chunk_YE2RMJY7();
|
|
220173
|
-
|
|
220174
|
-
init_chunk_SIO4LO2M();
|
|
220190
|
+
init_chunk_CY6AWCC6();
|
|
220175
220191
|
init_chunk_FX2AEKOV();
|
|
220176
220192
|
init_chunk_J6T3W6RY();
|
|
220177
220193
|
init_chunk_F4WUVOLE();
|
|
@@ -220200,7 +220216,7 @@ __export(driver_exports, {
|
|
|
220200
220216
|
var init_driver = __esm({
|
|
220201
220217
|
"../agent-sdk/dist/sessions/driver.js"() {
|
|
220202
220218
|
"use strict";
|
|
220203
|
-
|
|
220219
|
+
init_chunk_YAJJ7KHX();
|
|
220204
220220
|
init_chunk_PJZ5TQYW();
|
|
220205
220221
|
init_chunk_AU4NAQGA();
|
|
220206
220222
|
init_chunk_H6TQGV4L();
|
|
@@ -220210,7 +220226,7 @@ var init_driver = __esm({
|
|
|
220210
220226
|
init_chunk_YOZ6WDP3();
|
|
220211
220227
|
init_chunk_DZKBUOYU();
|
|
220212
220228
|
init_chunk_WK33IBKY();
|
|
220213
|
-
|
|
220229
|
+
init_chunk_IL2CZHNC();
|
|
220214
220230
|
init_chunk_4XXQAVKE();
|
|
220215
220231
|
init_chunk_JNSJKHYX();
|
|
220216
220232
|
init_chunk_5ZFOKZGR();
|
|
@@ -220228,7 +220244,7 @@ var init_driver = __esm({
|
|
|
220228
220244
|
init_chunk_G7KUVNDY();
|
|
220229
220245
|
init_chunk_6U6HEVSN();
|
|
220230
220246
|
init_chunk_YTBVILAH();
|
|
220231
|
-
|
|
220247
|
+
init_chunk_V5RHOS43();
|
|
220232
220248
|
init_chunk_J7F2OFWQ();
|
|
220233
220249
|
init_chunk_B6E6BVNK();
|
|
220234
220250
|
init_chunk_6SD6MC2B();
|
|
@@ -220247,25 +220263,25 @@ var init_driver = __esm({
|
|
|
220247
220263
|
init_chunk_UY3VT3HQ();
|
|
220248
220264
|
init_chunk_PDWLVL34();
|
|
220249
220265
|
init_chunk_QCGIYXN4();
|
|
220250
|
-
|
|
220251
|
-
init_chunk_YJCH35J4();
|
|
220252
|
-
init_chunk_CY6AWCC6();
|
|
220253
|
-
init_chunk_VRRGSQI7();
|
|
220254
|
-
init_chunk_D6RQPBRG();
|
|
220255
|
-
init_chunk_IBYOMAZ3();
|
|
220256
|
-
init_chunk_5PS6KN3J();
|
|
220266
|
+
init_chunk_65XY7HRS();
|
|
220257
220267
|
init_chunk_TPMZO6S2();
|
|
220258
220268
|
init_chunk_M72ERPMT();
|
|
220259
220269
|
init_chunk_AQHYCRTO();
|
|
220260
|
-
init_chunk_KJ2GJLPQ();
|
|
220261
220270
|
init_chunk_7TSTCMII();
|
|
220262
|
-
|
|
220271
|
+
init_chunk_KJ2GJLPQ();
|
|
220272
|
+
init_chunk_IBYOMAZ3();
|
|
220273
|
+
init_chunk_WEUPM3IN();
|
|
220274
|
+
init_chunk_PJYCPDV5();
|
|
220275
|
+
init_chunk_SIO4LO2M();
|
|
220263
220276
|
init_chunk_NMZMRH3E();
|
|
220264
|
-
init_chunk_CULYZ3VA();
|
|
220265
220277
|
init_chunk_XJYR5HE3();
|
|
220278
|
+
init_chunk_CULYZ3VA();
|
|
220279
|
+
init_chunk_JN3DHH7Z();
|
|
220280
|
+
init_chunk_VRRGSQI7();
|
|
220281
|
+
init_chunk_D6RQPBRG();
|
|
220282
|
+
init_chunk_YJCH35J4();
|
|
220266
220283
|
init_chunk_YE2RMJY7();
|
|
220267
|
-
|
|
220268
|
-
init_chunk_SIO4LO2M();
|
|
220284
|
+
init_chunk_CY6AWCC6();
|
|
220269
220285
|
init_chunk_FX2AEKOV();
|
|
220270
220286
|
init_chunk_J6T3W6RY();
|
|
220271
220287
|
init_chunk_F4WUVOLE();
|
|
@@ -220365,7 +220381,7 @@ var init_sessions2 = __esm({
|
|
|
220365
220381
|
}
|
|
220366
220382
|
});
|
|
220367
220383
|
|
|
220368
|
-
// ../agent-sdk/dist/chunk-
|
|
220384
|
+
// ../agent-sdk/dist/chunk-OMGJEZJS.js
|
|
220369
220385
|
function assertSessionTenant(auth, sessionId) {
|
|
220370
220386
|
const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
|
|
220371
220387
|
if (row) {
|
|
@@ -220951,17 +220967,17 @@ function handleListEvents(request2, sessionId) {
|
|
|
220951
220967
|
});
|
|
220952
220968
|
}
|
|
220953
220969
|
var teeLog, activeTees, MAX_TEE_REENTRIES, TextBlock2, UserMessage, UserInterrupt, UserToolConfirmation, UserCustomToolResult, UserDefineOutcome, UserEvent, BatchSchema;
|
|
220954
|
-
var
|
|
220955
|
-
"../agent-sdk/dist/chunk-
|
|
220970
|
+
var init_chunk_OMGJEZJS = __esm({
|
|
220971
|
+
"../agent-sdk/dist/chunk-OMGJEZJS.js"() {
|
|
220956
220972
|
"use strict";
|
|
220957
220973
|
init_chunk_HWWFRSAX();
|
|
220958
220974
|
init_chunk_ZBWKJ42J();
|
|
220959
220975
|
init_chunk_23UKWXJH();
|
|
220960
220976
|
init_chunk_DC2UMEQH();
|
|
220961
220977
|
init_chunk_TVV7AE3G();
|
|
220962
|
-
|
|
220978
|
+
init_chunk_RMCBO7K7();
|
|
220963
220979
|
init_chunk_JFHYXFAL();
|
|
220964
|
-
|
|
220980
|
+
init_chunk_YAJJ7KHX();
|
|
220965
220981
|
init_chunk_B3W3E5CS();
|
|
220966
220982
|
init_chunk_DZKBUOYU();
|
|
220967
220983
|
init_chunk_LAWTTG2E();
|
|
@@ -221034,21 +221050,21 @@ __export(events_exports, {
|
|
|
221034
221050
|
var init_events = __esm({
|
|
221035
221051
|
"../agent-sdk/dist/handlers/events.js"() {
|
|
221036
221052
|
"use strict";
|
|
221037
|
-
|
|
221053
|
+
init_chunk_OMGJEZJS();
|
|
221038
221054
|
init_chunk_HWWFRSAX();
|
|
221039
221055
|
init_chunk_ABUNDZCE();
|
|
221040
221056
|
init_chunk_ZBWKJ42J();
|
|
221041
221057
|
init_chunk_23UKWXJH();
|
|
221042
221058
|
init_chunk_DC2UMEQH();
|
|
221043
221059
|
init_chunk_TVV7AE3G();
|
|
221044
|
-
|
|
221060
|
+
init_chunk_RMCBO7K7();
|
|
221045
221061
|
init_chunk_D2XITRN6();
|
|
221046
221062
|
init_chunk_CWB2DQN5();
|
|
221047
221063
|
init_chunk_JFHYXFAL();
|
|
221048
221064
|
init_chunk_W6WKXFHN();
|
|
221049
221065
|
init_chunk_HVUWXUUI();
|
|
221050
|
-
|
|
221051
|
-
|
|
221066
|
+
init_chunk_ZDURV2LI();
|
|
221067
|
+
init_chunk_YAJJ7KHX();
|
|
221052
221068
|
init_chunk_PJZ5TQYW();
|
|
221053
221069
|
init_chunk_AU4NAQGA();
|
|
221054
221070
|
init_chunk_H6TQGV4L();
|
|
@@ -221063,10 +221079,10 @@ var init_events = __esm({
|
|
|
221063
221079
|
init_chunk_WK33IBKY();
|
|
221064
221080
|
init_chunk_3NUTTKE5();
|
|
221065
221081
|
init_chunk_3MQ2FWXS();
|
|
221066
|
-
|
|
221067
|
-
|
|
221082
|
+
init_chunk_HGV3Y4PS();
|
|
221083
|
+
init_chunk_AE7UG76I();
|
|
221068
221084
|
init_chunk_LAWTTG2E();
|
|
221069
|
-
|
|
221085
|
+
init_chunk_IL2CZHNC();
|
|
221070
221086
|
init_chunk_4XXQAVKE();
|
|
221071
221087
|
init_chunk_JNSJKHYX();
|
|
221072
221088
|
init_chunk_5ZFOKZGR();
|
|
@@ -221084,7 +221100,7 @@ var init_events = __esm({
|
|
|
221084
221100
|
init_chunk_G7KUVNDY();
|
|
221085
221101
|
init_chunk_6U6HEVSN();
|
|
221086
221102
|
init_chunk_YTBVILAH();
|
|
221087
|
-
|
|
221103
|
+
init_chunk_V5RHOS43();
|
|
221088
221104
|
init_chunk_J7F2OFWQ();
|
|
221089
221105
|
init_chunk_B6E6BVNK();
|
|
221090
221106
|
init_chunk_6SD6MC2B();
|
|
@@ -221103,25 +221119,25 @@ var init_events = __esm({
|
|
|
221103
221119
|
init_chunk_UY3VT3HQ();
|
|
221104
221120
|
init_chunk_PDWLVL34();
|
|
221105
221121
|
init_chunk_QCGIYXN4();
|
|
221106
|
-
|
|
221107
|
-
init_chunk_YJCH35J4();
|
|
221108
|
-
init_chunk_CY6AWCC6();
|
|
221109
|
-
init_chunk_VRRGSQI7();
|
|
221110
|
-
init_chunk_D6RQPBRG();
|
|
221111
|
-
init_chunk_IBYOMAZ3();
|
|
221112
|
-
init_chunk_5PS6KN3J();
|
|
221122
|
+
init_chunk_65XY7HRS();
|
|
221113
221123
|
init_chunk_TPMZO6S2();
|
|
221114
221124
|
init_chunk_M72ERPMT();
|
|
221115
221125
|
init_chunk_AQHYCRTO();
|
|
221116
|
-
init_chunk_KJ2GJLPQ();
|
|
221117
221126
|
init_chunk_7TSTCMII();
|
|
221118
|
-
|
|
221127
|
+
init_chunk_KJ2GJLPQ();
|
|
221128
|
+
init_chunk_IBYOMAZ3();
|
|
221129
|
+
init_chunk_WEUPM3IN();
|
|
221130
|
+
init_chunk_PJYCPDV5();
|
|
221131
|
+
init_chunk_SIO4LO2M();
|
|
221119
221132
|
init_chunk_NMZMRH3E();
|
|
221120
|
-
init_chunk_CULYZ3VA();
|
|
221121
221133
|
init_chunk_XJYR5HE3();
|
|
221134
|
+
init_chunk_CULYZ3VA();
|
|
221135
|
+
init_chunk_JN3DHH7Z();
|
|
221136
|
+
init_chunk_VRRGSQI7();
|
|
221137
|
+
init_chunk_D6RQPBRG();
|
|
221138
|
+
init_chunk_YJCH35J4();
|
|
221122
221139
|
init_chunk_YE2RMJY7();
|
|
221123
|
-
|
|
221124
|
-
init_chunk_SIO4LO2M();
|
|
221140
|
+
init_chunk_CY6AWCC6();
|
|
221125
221141
|
init_chunk_FX2AEKOV();
|
|
221126
221142
|
init_chunk_J6T3W6RY();
|
|
221127
221143
|
init_chunk_F4WUVOLE();
|
|
@@ -221138,6 +221154,31 @@ var init_events = __esm({
|
|
|
221138
221154
|
}
|
|
221139
221155
|
});
|
|
221140
221156
|
|
|
221157
|
+
// ../agent-sdk/dist/db/events.js
|
|
221158
|
+
var events_exports2 = {};
|
|
221159
|
+
__export(events_exports2, {
|
|
221160
|
+
appendEvent: () => appendEvent,
|
|
221161
|
+
appendEventsBatch: () => appendEventsBatch,
|
|
221162
|
+
getLastUnprocessedUserMessage: () => getLastUnprocessedUserMessage,
|
|
221163
|
+
listEvents: () => listEvents,
|
|
221164
|
+
listEventsByTrace: () => listEventsByTrace,
|
|
221165
|
+
markUserEventProcessed: () => markUserEventProcessed,
|
|
221166
|
+
rowToManagedEvent: () => rowToManagedEvent
|
|
221167
|
+
});
|
|
221168
|
+
var init_events2 = __esm({
|
|
221169
|
+
"../agent-sdk/dist/db/events.js"() {
|
|
221170
|
+
"use strict";
|
|
221171
|
+
init_chunk_OEFJPZYH();
|
|
221172
|
+
init_chunk_F4WUVOLE();
|
|
221173
|
+
init_chunk_HFDLUBWN();
|
|
221174
|
+
init_chunk_ZDDMPGN4();
|
|
221175
|
+
init_chunk_CXYMVLYK();
|
|
221176
|
+
init_chunk_AGIXZFHQ();
|
|
221177
|
+
init_chunk_S5CMAWEC();
|
|
221178
|
+
init_chunk_2ESYSVXG();
|
|
221179
|
+
}
|
|
221180
|
+
});
|
|
221181
|
+
|
|
221141
221182
|
// ../agent-sdk/dist/db/environments.js
|
|
221142
221183
|
var environments_exports = {};
|
|
221143
221184
|
__export(environments_exports, {
|
|
@@ -221167,7 +221208,7 @@ var init_environments = __esm({
|
|
|
221167
221208
|
}
|
|
221168
221209
|
});
|
|
221169
221210
|
|
|
221170
|
-
// ../agent-sdk/dist/chunk-
|
|
221211
|
+
// ../agent-sdk/dist/chunk-SP26BYYZ.js
|
|
221171
221212
|
function getEnvironmentTenantId2(id) {
|
|
221172
221213
|
const row = getDb().prepare(`SELECT tenant_id FROM environments WHERE id = ?`).get(id);
|
|
221173
221214
|
return row?.tenant_id;
|
|
@@ -221248,7 +221289,7 @@ function handleListEnvironments(request2) {
|
|
|
221248
221289
|
const limit = url2.searchParams.get("limit");
|
|
221249
221290
|
const order = url2.searchParams.get("order");
|
|
221250
221291
|
const includeArchived = url2.searchParams.get("include_archived") === "true";
|
|
221251
|
-
const cursor = decodeCursor(url2.searchParams.get("page"));
|
|
221292
|
+
const cursor = decodeCursor(url2.searchParams.get("after_id") ?? url2.searchParams.get("page"));
|
|
221252
221293
|
const requestedLimit = limit ? Number(limit) : 20;
|
|
221253
221294
|
const data = listEnvironments({
|
|
221254
221295
|
limit: requestedLimit,
|
|
@@ -221325,12 +221366,12 @@ function handleUpdateEnvironment(request2, id) {
|
|
|
221325
221366
|
});
|
|
221326
221367
|
}
|
|
221327
221368
|
var PackagesSchema, NetworkingSchema, ConfigSchema, CreateSchema3, UpdateSchema3;
|
|
221328
|
-
var
|
|
221329
|
-
"../agent-sdk/dist/chunk-
|
|
221369
|
+
var init_chunk_SP26BYYZ = __esm({
|
|
221370
|
+
"../agent-sdk/dist/chunk-SP26BYYZ.js"() {
|
|
221330
221371
|
"use strict";
|
|
221331
221372
|
init_chunk_23UKWXJH();
|
|
221332
221373
|
init_chunk_K5J4IN2S();
|
|
221333
|
-
|
|
221374
|
+
init_chunk_RMCBO7K7();
|
|
221334
221375
|
init_chunk_JFHYXFAL();
|
|
221335
221376
|
init_chunk_DZKBUOYU();
|
|
221336
221377
|
init_chunk_XLMNSDUJ();
|
|
@@ -221394,17 +221435,17 @@ __export(environments_exports2, {
|
|
|
221394
221435
|
var init_environments2 = __esm({
|
|
221395
221436
|
"../agent-sdk/dist/handlers/environments.js"() {
|
|
221396
221437
|
"use strict";
|
|
221397
|
-
|
|
221438
|
+
init_chunk_SP26BYYZ();
|
|
221398
221439
|
init_chunk_23UKWXJH();
|
|
221399
221440
|
init_chunk_K5J4IN2S();
|
|
221400
|
-
|
|
221441
|
+
init_chunk_RMCBO7K7();
|
|
221401
221442
|
init_chunk_D2XITRN6();
|
|
221402
221443
|
init_chunk_CWB2DQN5();
|
|
221403
221444
|
init_chunk_JFHYXFAL();
|
|
221404
221445
|
init_chunk_W6WKXFHN();
|
|
221405
221446
|
init_chunk_HVUWXUUI();
|
|
221406
|
-
|
|
221407
|
-
|
|
221447
|
+
init_chunk_ZDURV2LI();
|
|
221448
|
+
init_chunk_YAJJ7KHX();
|
|
221408
221449
|
init_chunk_PJZ5TQYW();
|
|
221409
221450
|
init_chunk_AU4NAQGA();
|
|
221410
221451
|
init_chunk_H6TQGV4L();
|
|
@@ -221419,10 +221460,10 @@ var init_environments2 = __esm({
|
|
|
221419
221460
|
init_chunk_WK33IBKY();
|
|
221420
221461
|
init_chunk_3NUTTKE5();
|
|
221421
221462
|
init_chunk_3MQ2FWXS();
|
|
221422
|
-
|
|
221423
|
-
|
|
221463
|
+
init_chunk_HGV3Y4PS();
|
|
221464
|
+
init_chunk_AE7UG76I();
|
|
221424
221465
|
init_chunk_LAWTTG2E();
|
|
221425
|
-
|
|
221466
|
+
init_chunk_IL2CZHNC();
|
|
221426
221467
|
init_chunk_4XXQAVKE();
|
|
221427
221468
|
init_chunk_JNSJKHYX();
|
|
221428
221469
|
init_chunk_5ZFOKZGR();
|
|
@@ -221440,7 +221481,7 @@ var init_environments2 = __esm({
|
|
|
221440
221481
|
init_chunk_G7KUVNDY();
|
|
221441
221482
|
init_chunk_6U6HEVSN();
|
|
221442
221483
|
init_chunk_YTBVILAH();
|
|
221443
|
-
|
|
221484
|
+
init_chunk_V5RHOS43();
|
|
221444
221485
|
init_chunk_J7F2OFWQ();
|
|
221445
221486
|
init_chunk_B6E6BVNK();
|
|
221446
221487
|
init_chunk_6SD6MC2B();
|
|
@@ -221459,25 +221500,25 @@ var init_environments2 = __esm({
|
|
|
221459
221500
|
init_chunk_UY3VT3HQ();
|
|
221460
221501
|
init_chunk_PDWLVL34();
|
|
221461
221502
|
init_chunk_QCGIYXN4();
|
|
221462
|
-
|
|
221463
|
-
init_chunk_YJCH35J4();
|
|
221464
|
-
init_chunk_CY6AWCC6();
|
|
221465
|
-
init_chunk_VRRGSQI7();
|
|
221466
|
-
init_chunk_D6RQPBRG();
|
|
221467
|
-
init_chunk_IBYOMAZ3();
|
|
221468
|
-
init_chunk_5PS6KN3J();
|
|
221503
|
+
init_chunk_65XY7HRS();
|
|
221469
221504
|
init_chunk_TPMZO6S2();
|
|
221470
221505
|
init_chunk_M72ERPMT();
|
|
221471
221506
|
init_chunk_AQHYCRTO();
|
|
221472
|
-
init_chunk_KJ2GJLPQ();
|
|
221473
221507
|
init_chunk_7TSTCMII();
|
|
221474
|
-
|
|
221508
|
+
init_chunk_KJ2GJLPQ();
|
|
221509
|
+
init_chunk_IBYOMAZ3();
|
|
221510
|
+
init_chunk_WEUPM3IN();
|
|
221511
|
+
init_chunk_PJYCPDV5();
|
|
221512
|
+
init_chunk_SIO4LO2M();
|
|
221475
221513
|
init_chunk_NMZMRH3E();
|
|
221476
|
-
init_chunk_CULYZ3VA();
|
|
221477
221514
|
init_chunk_XJYR5HE3();
|
|
221515
|
+
init_chunk_CULYZ3VA();
|
|
221516
|
+
init_chunk_JN3DHH7Z();
|
|
221517
|
+
init_chunk_VRRGSQI7();
|
|
221518
|
+
init_chunk_D6RQPBRG();
|
|
221519
|
+
init_chunk_YJCH35J4();
|
|
221478
221520
|
init_chunk_YE2RMJY7();
|
|
221479
|
-
|
|
221480
|
-
init_chunk_SIO4LO2M();
|
|
221521
|
+
init_chunk_CY6AWCC6();
|
|
221481
221522
|
init_chunk_FX2AEKOV();
|
|
221482
221523
|
init_chunk_J6T3W6RY();
|
|
221483
221524
|
init_chunk_F4WUVOLE();
|
|
@@ -221523,32 +221564,7 @@ var init_bus = __esm({
|
|
|
221523
221564
|
}
|
|
221524
221565
|
});
|
|
221525
221566
|
|
|
221526
|
-
// ../agent-sdk/dist/
|
|
221527
|
-
var events_exports2 = {};
|
|
221528
|
-
__export(events_exports2, {
|
|
221529
|
-
appendEvent: () => appendEvent,
|
|
221530
|
-
appendEventsBatch: () => appendEventsBatch,
|
|
221531
|
-
getLastUnprocessedUserMessage: () => getLastUnprocessedUserMessage,
|
|
221532
|
-
listEvents: () => listEvents,
|
|
221533
|
-
listEventsByTrace: () => listEventsByTrace,
|
|
221534
|
-
markUserEventProcessed: () => markUserEventProcessed,
|
|
221535
|
-
rowToManagedEvent: () => rowToManagedEvent
|
|
221536
|
-
});
|
|
221537
|
-
var init_events2 = __esm({
|
|
221538
|
-
"../agent-sdk/dist/db/events.js"() {
|
|
221539
|
-
"use strict";
|
|
221540
|
-
init_chunk_OEFJPZYH();
|
|
221541
|
-
init_chunk_F4WUVOLE();
|
|
221542
|
-
init_chunk_HFDLUBWN();
|
|
221543
|
-
init_chunk_ZDDMPGN4();
|
|
221544
|
-
init_chunk_CXYMVLYK();
|
|
221545
|
-
init_chunk_AGIXZFHQ();
|
|
221546
|
-
init_chunk_S5CMAWEC();
|
|
221547
|
-
init_chunk_2ESYSVXG();
|
|
221548
|
-
}
|
|
221549
|
-
});
|
|
221550
|
-
|
|
221551
|
-
// ../agent-sdk/dist/chunk-U5XWSJPT.js
|
|
221567
|
+
// ../agent-sdk/dist/chunk-RHSVYAI4.js
|
|
221552
221568
|
function ensureTable() {
|
|
221553
221569
|
const db = getDb();
|
|
221554
221570
|
db.exec(`
|
|
@@ -221589,11 +221605,15 @@ function handleCreateInteraction(request2) {
|
|
|
221589
221605
|
agentId = "";
|
|
221590
221606
|
environmentId = prev.environment_id ?? void 0;
|
|
221591
221607
|
const sessionId2 = prev.session_id;
|
|
221608
|
+
const { listEvents: listEventsForSeq } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221609
|
+
const lastEvents = listEventsForSeq(sessionId2, { limit: 1, order: "desc" });
|
|
221610
|
+
const afterSeq = lastEvents.length > 0 ? lastEvents[0].seq : 0;
|
|
221611
|
+
const functionResultEvents = buildFunctionResultEvents(data.input);
|
|
221592
221612
|
const eventsReq2 = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${sessionId2}/events`), {
|
|
221593
221613
|
method: "POST",
|
|
221594
221614
|
headers: request2.headers,
|
|
221595
221615
|
body: JSON.stringify({
|
|
221596
|
-
events: [{ type: "user.message", content: [{ type: "text", text: inputText }] }]
|
|
221616
|
+
events: functionResultEvents.length > 0 ? functionResultEvents : [{ type: "user.message", content: [{ type: "text", text: inputText }] }]
|
|
221597
221617
|
})
|
|
221598
221618
|
});
|
|
221599
221619
|
const eventsRes2 = await handlePostEvents2(eventsReq2, sessionId2);
|
|
@@ -221601,7 +221621,7 @@ function handleCreateInteraction(request2) {
|
|
|
221601
221621
|
const err = await eventsRes2.json().catch(() => ({}));
|
|
221602
221622
|
throw badRequest(err.error?.message || `failed to send message: ${eventsRes2.status}`);
|
|
221603
221623
|
}
|
|
221604
|
-
const result2 = await waitForCompletion(sessionId2);
|
|
221624
|
+
const result2 = await waitForCompletion(sessionId2, afterSeq);
|
|
221605
221625
|
const interactionId2 = `int_${newId("sesn").slice(5)}`;
|
|
221606
221626
|
const prevSeq = db2.prepare(
|
|
221607
221627
|
`SELECT MAX(seq) as maxSeq FROM google_interactions WHERE session_id = ?`
|
|
@@ -221695,9 +221715,135 @@ function handleCreateInteraction(request2) {
|
|
|
221695
221715
|
return jsonOk(buildResponse(interactionId, result, environmentId));
|
|
221696
221716
|
});
|
|
221697
221717
|
}
|
|
221698
|
-
|
|
221718
|
+
function handleGetInteraction(request2, id) {
|
|
221719
|
+
return routeWrap(request2, async () => {
|
|
221720
|
+
ensureTable();
|
|
221721
|
+
const db = getDb();
|
|
221722
|
+
const row = db.prepare(
|
|
221723
|
+
`SELECT id, session_id, seq, status, environment_id, created_at FROM google_interactions WHERE id = ?`
|
|
221724
|
+
).get(id);
|
|
221725
|
+
if (!row) throw notFound(`interaction not found: ${id}`);
|
|
221726
|
+
const { listEvents: listEvents2 } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221727
|
+
const { rowToManagedEvent: rowToManagedEvent2 } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221728
|
+
const eventRows = listEvents2(row.session_id, { limit: 500, order: "asc" });
|
|
221729
|
+
const steps = [];
|
|
221730
|
+
let inputTokens = 0;
|
|
221731
|
+
let outputTokens = 0;
|
|
221732
|
+
for (const eventRow of eventRows) {
|
|
221733
|
+
const event = rowToManagedEvent2(eventRow);
|
|
221734
|
+
if (event.type === "agent.message") {
|
|
221735
|
+
const content = event.content;
|
|
221736
|
+
const text2 = content?.filter((c2) => c2.type === "text").map((c2) => c2.text).join("") ?? "";
|
|
221737
|
+
if (text2) {
|
|
221738
|
+
steps.push({ type: "model_output", content: [{ type: "text", text: text2 }] });
|
|
221739
|
+
}
|
|
221740
|
+
} else if (event.type === "agent.tool_use") {
|
|
221741
|
+
steps.push({
|
|
221742
|
+
type: "function_call",
|
|
221743
|
+
id: event.tool_use_id ?? "",
|
|
221744
|
+
name: event.name ?? "",
|
|
221745
|
+
arguments: event.input ?? {}
|
|
221746
|
+
});
|
|
221747
|
+
} else if (event.type === "agent.tool_result") {
|
|
221748
|
+
steps.push({
|
|
221749
|
+
type: "code_execution_result",
|
|
221750
|
+
call_id: event.tool_use_id ?? "",
|
|
221751
|
+
result: JSON.stringify(event.content ?? "")
|
|
221752
|
+
});
|
|
221753
|
+
} else if (event.type === "agent.custom_tool_use") {
|
|
221754
|
+
steps.push({
|
|
221755
|
+
type: "function_call",
|
|
221756
|
+
id: event.tool_use_id ?? "",
|
|
221757
|
+
name: event.name ?? "",
|
|
221758
|
+
arguments: event.input ?? {}
|
|
221759
|
+
});
|
|
221760
|
+
} else if (event.type === "span.model_request_end") {
|
|
221761
|
+
const mu = event.model_usage;
|
|
221762
|
+
inputTokens += mu?.input_tokens ?? 0;
|
|
221763
|
+
outputTokens += mu?.output_tokens ?? 0;
|
|
221764
|
+
}
|
|
221765
|
+
}
|
|
221766
|
+
const response = {
|
|
221767
|
+
id: row.id,
|
|
221768
|
+
created: row.created_at,
|
|
221769
|
+
updated: row.created_at,
|
|
221770
|
+
status: row.status,
|
|
221771
|
+
steps,
|
|
221772
|
+
usage: { total_input_tokens: inputTokens, total_output_tokens: outputTokens, total_tokens: inputTokens + outputTokens },
|
|
221773
|
+
environment_id: row.environment_id ?? void 0
|
|
221774
|
+
};
|
|
221775
|
+
return jsonOk(response);
|
|
221776
|
+
});
|
|
221777
|
+
}
|
|
221778
|
+
function handleDeleteInteraction(request2, id) {
|
|
221779
|
+
return routeWrap(request2, async () => {
|
|
221780
|
+
ensureTable();
|
|
221781
|
+
const db = getDb();
|
|
221782
|
+
const row = db.prepare(
|
|
221783
|
+
`SELECT id, session_id FROM google_interactions WHERE id = ?`
|
|
221784
|
+
).get(id);
|
|
221785
|
+
if (!row) throw notFound(`interaction not found: ${id}`);
|
|
221786
|
+
db.prepare(`DELETE FROM google_interactions WHERE id = ?`).run(id);
|
|
221787
|
+
const { handleDeleteSession: handleDeleteSession2 } = await Promise.resolve().then(() => (init_sessions(), sessions_exports));
|
|
221788
|
+
const sessReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${row.session_id}`), {
|
|
221789
|
+
method: "DELETE",
|
|
221790
|
+
headers: request2.headers
|
|
221791
|
+
});
|
|
221792
|
+
await handleDeleteSession2(sessReq, row.session_id).catch(() => {
|
|
221793
|
+
});
|
|
221794
|
+
return jsonOk({ id, deleted: true });
|
|
221795
|
+
});
|
|
221796
|
+
}
|
|
221797
|
+
function handleCancelInteraction(request2, id) {
|
|
221798
|
+
return routeWrap(request2, async () => {
|
|
221799
|
+
ensureTable();
|
|
221800
|
+
const db = getDb();
|
|
221801
|
+
const row = db.prepare(
|
|
221802
|
+
`SELECT id, session_id, seq, status, environment_id, created_at FROM google_interactions WHERE id = ?`
|
|
221803
|
+
).get(id);
|
|
221804
|
+
if (!row) throw notFound(`interaction not found: ${id}`);
|
|
221805
|
+
const { handlePostEvents: handlePostEvents2 } = await Promise.resolve().then(() => (init_events(), events_exports));
|
|
221806
|
+
const eventsReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${row.session_id}/events`), {
|
|
221807
|
+
method: "POST",
|
|
221808
|
+
headers: request2.headers,
|
|
221809
|
+
body: JSON.stringify({
|
|
221810
|
+
events: [{ type: "user.interrupt" }]
|
|
221811
|
+
})
|
|
221812
|
+
});
|
|
221813
|
+
await handlePostEvents2(eventsReq, row.session_id).catch(() => {
|
|
221814
|
+
});
|
|
221815
|
+
db.prepare(`UPDATE google_interactions SET status = 'cancelled' WHERE id = ?`).run(id);
|
|
221816
|
+
const response = {
|
|
221817
|
+
id: row.id,
|
|
221818
|
+
created: row.created_at,
|
|
221819
|
+
updated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
221820
|
+
status: "cancelled",
|
|
221821
|
+
steps: [],
|
|
221822
|
+
usage: { total_input_tokens: 0, total_output_tokens: 0, total_tokens: 0 },
|
|
221823
|
+
environment_id: row.environment_id ?? void 0
|
|
221824
|
+
};
|
|
221825
|
+
return jsonOk(response);
|
|
221826
|
+
});
|
|
221827
|
+
}
|
|
221828
|
+
function buildFunctionResultEvents(input) {
|
|
221829
|
+
if (typeof input === "string") return [];
|
|
221830
|
+
if (!Array.isArray(input)) return [];
|
|
221831
|
+
const results = [];
|
|
221832
|
+
for (const item of input) {
|
|
221833
|
+
if (item && typeof item === "object" && item.type === "function_result") {
|
|
221834
|
+
const callId = item.call_id ?? item.id ?? "";
|
|
221835
|
+
const resultText = item.result ?? item.output ?? "";
|
|
221836
|
+
results.push({
|
|
221837
|
+
type: "user.custom_tool_result",
|
|
221838
|
+
custom_tool_use_id: callId,
|
|
221839
|
+
content: [{ type: "text", text: typeof resultText === "string" ? resultText : JSON.stringify(resultText) }]
|
|
221840
|
+
});
|
|
221841
|
+
}
|
|
221842
|
+
}
|
|
221843
|
+
return results;
|
|
221844
|
+
}
|
|
221845
|
+
async function waitForCompletion(sessionId, afterSeq = 0) {
|
|
221699
221846
|
const { subscribe: subscribe6 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
|
|
221700
|
-
const { listEvents: listEvents2 } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221701
221847
|
return new Promise((resolve3) => {
|
|
221702
221848
|
const steps = [];
|
|
221703
221849
|
let outputText = "";
|
|
@@ -221705,10 +221851,11 @@ async function waitForCompletion(sessionId) {
|
|
|
221705
221851
|
let outputTokens = 0;
|
|
221706
221852
|
let status = "completed";
|
|
221707
221853
|
let resolved = false;
|
|
221854
|
+
let subscription = null;
|
|
221708
221855
|
const timeout = setTimeout(() => {
|
|
221709
221856
|
if (resolved) return;
|
|
221710
221857
|
resolved = true;
|
|
221711
|
-
|
|
221858
|
+
subscription?.unsubscribe();
|
|
221712
221859
|
resolve3({
|
|
221713
221860
|
status: "failed",
|
|
221714
221861
|
steps,
|
|
@@ -221720,7 +221867,7 @@ async function waitForCompletion(sessionId) {
|
|
|
221720
221867
|
if (resolved) return;
|
|
221721
221868
|
resolved = true;
|
|
221722
221869
|
clearTimeout(timeout);
|
|
221723
|
-
|
|
221870
|
+
subscription?.unsubscribe();
|
|
221724
221871
|
resolve3({
|
|
221725
221872
|
status,
|
|
221726
221873
|
steps,
|
|
@@ -221771,9 +221918,11 @@ async function waitForCompletion(sessionId) {
|
|
|
221771
221918
|
status = "failed";
|
|
221772
221919
|
}
|
|
221773
221920
|
}
|
|
221774
|
-
const sub = subscribe6(sessionId,
|
|
221921
|
+
const sub = subscribe6(sessionId, afterSeq, handleEvent);
|
|
221922
|
+
subscription = sub;
|
|
221775
221923
|
if (resolved) {
|
|
221776
221924
|
clearTimeout(timeout);
|
|
221925
|
+
sub.unsubscribe();
|
|
221777
221926
|
}
|
|
221778
221927
|
});
|
|
221779
221928
|
}
|
|
@@ -221790,10 +221939,10 @@ function buildResponse(id, result, environmentId) {
|
|
|
221790
221939
|
};
|
|
221791
221940
|
}
|
|
221792
221941
|
var CreateSchema4;
|
|
221793
|
-
var
|
|
221794
|
-
"../agent-sdk/dist/chunk-
|
|
221942
|
+
var init_chunk_RHSVYAI4 = __esm({
|
|
221943
|
+
"../agent-sdk/dist/chunk-RHSVYAI4.js"() {
|
|
221795
221944
|
"use strict";
|
|
221796
|
-
|
|
221945
|
+
init_chunk_RMCBO7K7();
|
|
221797
221946
|
init_chunk_F4WUVOLE();
|
|
221798
221947
|
init_chunk_AGIXZFHQ();
|
|
221799
221948
|
init_chunk_EZYKRG4W();
|
|
@@ -221814,7 +221963,254 @@ var init_chunk_U5XWSJPT = __esm({
|
|
|
221814
221963
|
}
|
|
221815
221964
|
});
|
|
221816
221965
|
|
|
221817
|
-
// ../agent-sdk/dist/chunk-
|
|
221966
|
+
// ../agent-sdk/dist/chunk-2HTAIROL.js
|
|
221967
|
+
function resolveBaseAgent(baseAgent) {
|
|
221968
|
+
if (!baseAgent) return { engine: "gemini", model: "gemini-2.5-flash" };
|
|
221969
|
+
if (baseAgent === "antigravity-preview-05-2026") {
|
|
221970
|
+
return { engine: "gemini", model: "gemini-2.5-flash" };
|
|
221971
|
+
}
|
|
221972
|
+
return { engine: "gemini", model: baseAgent };
|
|
221973
|
+
}
|
|
221974
|
+
function toGoogleFormat(agent) {
|
|
221975
|
+
return {
|
|
221976
|
+
id: agent.name,
|
|
221977
|
+
base_agent: agent.engine === "gemini" ? "antigravity-preview-05-2026" : void 0,
|
|
221978
|
+
system_instruction: agent.system ?? void 0,
|
|
221979
|
+
description: agent.description ?? void 0,
|
|
221980
|
+
created: agent.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
221981
|
+
updated: agent.updated_at ?? agent.created_at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
221982
|
+
};
|
|
221983
|
+
}
|
|
221984
|
+
function handleCreateGoogleAgent(request2) {
|
|
221985
|
+
return routeWrap(request2, async () => {
|
|
221986
|
+
const body = await request2.json().catch(() => null);
|
|
221987
|
+
const parsed = CreateGoogleAgentSchema.safeParse(body);
|
|
221988
|
+
if (!parsed.success) {
|
|
221989
|
+
throw badRequest(`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
|
|
221990
|
+
}
|
|
221991
|
+
const data = parsed.data;
|
|
221992
|
+
const { engine, model } = resolveBaseAgent(data.base_agent);
|
|
221993
|
+
let systemInstruction = data.system_instruction ?? "";
|
|
221994
|
+
const skills2 = [];
|
|
221995
|
+
if (data.base_environment?.sources) {
|
|
221996
|
+
for (const source of data.base_environment.sources) {
|
|
221997
|
+
const target2 = source.target ?? "";
|
|
221998
|
+
const skillMatch = target2.match(/\.agents\/skills\/([^/]+)\/SKILL\.md$/);
|
|
221999
|
+
if (skillMatch && source.content) {
|
|
222000
|
+
skills2.push({
|
|
222001
|
+
name: skillMatch[1],
|
|
222002
|
+
source: "inline",
|
|
222003
|
+
content: source.content
|
|
222004
|
+
});
|
|
222005
|
+
} else if (target2.endsWith(".agents/AGENTS.md") && source.content) {
|
|
222006
|
+
if (systemInstruction) systemInstruction += "\n\n";
|
|
222007
|
+
systemInstruction += source.content;
|
|
222008
|
+
}
|
|
222009
|
+
}
|
|
222010
|
+
}
|
|
222011
|
+
const agentName = data.id || `google-agent-${Date.now()}`;
|
|
222012
|
+
const { handleCreateAgent: handleCreateAgent2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
222013
|
+
const createBody = {
|
|
222014
|
+
name: agentName,
|
|
222015
|
+
model: { id: model },
|
|
222016
|
+
engine
|
|
222017
|
+
};
|
|
222018
|
+
if (systemInstruction) createBody.system = systemInstruction;
|
|
222019
|
+
if (data.description) createBody.description = data.description;
|
|
222020
|
+
if (skills2.length > 0) createBody.skills = skills2;
|
|
222021
|
+
const createReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents`), {
|
|
222022
|
+
method: "POST",
|
|
222023
|
+
headers: request2.headers,
|
|
222024
|
+
body: JSON.stringify(createBody)
|
|
222025
|
+
});
|
|
222026
|
+
const createRes = await handleCreateAgent2(createReq);
|
|
222027
|
+
if (!createRes.ok) {
|
|
222028
|
+
const err = await createRes.json().catch(() => ({}));
|
|
222029
|
+
throw badRequest(err.error?.message || `failed to create agent: ${createRes.status}`);
|
|
222030
|
+
}
|
|
222031
|
+
const created = await createRes.json();
|
|
222032
|
+
const response = {
|
|
222033
|
+
id: created.name ?? agentName,
|
|
222034
|
+
base_agent: data.base_agent,
|
|
222035
|
+
system_instruction: systemInstruction || void 0,
|
|
222036
|
+
description: data.description,
|
|
222037
|
+
created: created.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
222038
|
+
updated: created.updated_at ?? created.created_at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
222039
|
+
};
|
|
222040
|
+
return jsonOk(response, 201);
|
|
222041
|
+
});
|
|
222042
|
+
}
|
|
222043
|
+
function handleListGoogleAgents(request2) {
|
|
222044
|
+
return routeWrap(request2, async () => {
|
|
222045
|
+
const { handleListAgents: handleListAgents2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
222046
|
+
const listReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents?limit=1000`), {
|
|
222047
|
+
headers: request2.headers
|
|
222048
|
+
});
|
|
222049
|
+
const listRes = await handleListAgents2(listReq);
|
|
222050
|
+
if (!listRes.ok) {
|
|
222051
|
+
return listRes;
|
|
222052
|
+
}
|
|
222053
|
+
const listBody = await listRes.json();
|
|
222054
|
+
const agents2 = (listBody.data ?? []).map(toGoogleFormat);
|
|
222055
|
+
return jsonOk({ agents: agents2 });
|
|
222056
|
+
});
|
|
222057
|
+
}
|
|
222058
|
+
function handleGetGoogleAgent(request2, id) {
|
|
222059
|
+
return routeWrap(request2, async () => {
|
|
222060
|
+
const { handleListAgents: handleListAgents2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
222061
|
+
const listReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents?limit=1000`), {
|
|
222062
|
+
headers: request2.headers
|
|
222063
|
+
});
|
|
222064
|
+
const listRes = await handleListAgents2(listReq);
|
|
222065
|
+
if (!listRes.ok) {
|
|
222066
|
+
return listRes;
|
|
222067
|
+
}
|
|
222068
|
+
const listBody = await listRes.json();
|
|
222069
|
+
const agent = listBody.data?.find((a) => a.name === id);
|
|
222070
|
+
if (!agent) throw notFound(`agent not found: ${id}`);
|
|
222071
|
+
return jsonOk(toGoogleFormat(agent));
|
|
222072
|
+
});
|
|
222073
|
+
}
|
|
222074
|
+
function handleDeleteGoogleAgent(request2, id) {
|
|
222075
|
+
return routeWrap(request2, async () => {
|
|
222076
|
+
const { handleListAgents: handleListAgents2, handleDeleteAgent: handleDeleteAgent2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
222077
|
+
const listReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents?limit=1000`), {
|
|
222078
|
+
headers: request2.headers
|
|
222079
|
+
});
|
|
222080
|
+
const listRes = await handleListAgents2(listReq);
|
|
222081
|
+
if (!listRes.ok) {
|
|
222082
|
+
return listRes;
|
|
222083
|
+
}
|
|
222084
|
+
const listBody = await listRes.json();
|
|
222085
|
+
const agent = listBody.data?.find((a) => a.name === id);
|
|
222086
|
+
if (!agent) throw notFound(`agent not found: ${id}`);
|
|
222087
|
+
const delReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents/${agent.id}`), {
|
|
222088
|
+
method: "DELETE",
|
|
222089
|
+
headers: request2.headers
|
|
222090
|
+
});
|
|
222091
|
+
await handleDeleteAgent2(delReq, agent.id);
|
|
222092
|
+
return jsonOk({});
|
|
222093
|
+
});
|
|
222094
|
+
}
|
|
222095
|
+
var SourceSchema, BaseEnvironmentSchema, CreateGoogleAgentSchema;
|
|
222096
|
+
var init_chunk_2HTAIROL = __esm({
|
|
222097
|
+
"../agent-sdk/dist/chunk-2HTAIROL.js"() {
|
|
222098
|
+
"use strict";
|
|
222099
|
+
init_chunk_RMCBO7K7();
|
|
222100
|
+
init_chunk_EZYKRG4W();
|
|
222101
|
+
init_zod();
|
|
222102
|
+
SourceSchema = external_exports.object({
|
|
222103
|
+
type: external_exports.string().optional(),
|
|
222104
|
+
target: external_exports.string().optional(),
|
|
222105
|
+
content: external_exports.string().optional(),
|
|
222106
|
+
url: external_exports.string().optional()
|
|
222107
|
+
}).passthrough();
|
|
222108
|
+
BaseEnvironmentSchema = external_exports.object({
|
|
222109
|
+
type: external_exports.string().optional(),
|
|
222110
|
+
sources: external_exports.array(SourceSchema).optional()
|
|
222111
|
+
}).passthrough();
|
|
222112
|
+
CreateGoogleAgentSchema = external_exports.object({
|
|
222113
|
+
id: external_exports.string().optional(),
|
|
222114
|
+
description: external_exports.string().optional(),
|
|
222115
|
+
base_agent: external_exports.string().optional(),
|
|
222116
|
+
system_instruction: external_exports.string().optional(),
|
|
222117
|
+
tools: external_exports.array(external_exports.unknown()).optional(),
|
|
222118
|
+
base_environment: BaseEnvironmentSchema.optional()
|
|
222119
|
+
});
|
|
222120
|
+
}
|
|
222121
|
+
});
|
|
222122
|
+
|
|
222123
|
+
// ../agent-sdk/dist/chunk-PULMO5OO.js
|
|
222124
|
+
function buildTarArchive(files2) {
|
|
222125
|
+
const blocks = [];
|
|
222126
|
+
for (const file of files2) {
|
|
222127
|
+
const header = Buffer.alloc(512, 0);
|
|
222128
|
+
const name = file.name.slice(0, 100);
|
|
222129
|
+
header.write(name, 0, Math.min(name.length, 100), "utf8");
|
|
222130
|
+
header.write("0000644\0", 100, 8, "utf8");
|
|
222131
|
+
header.write("0000000\0", 108, 8, "utf8");
|
|
222132
|
+
header.write("0000000\0", 116, 8, "utf8");
|
|
222133
|
+
header.write(file.data.length.toString(8).padStart(11, "0") + "\0", 124, 12, "utf8");
|
|
222134
|
+
const mtime = Math.floor(Date.now() / 1e3);
|
|
222135
|
+
header.write(mtime.toString(8).padStart(11, "0") + "\0", 136, 12, "utf8");
|
|
222136
|
+
header.write(" ", 148, 8, "utf8");
|
|
222137
|
+
header.write("0", 156, 1, "utf8");
|
|
222138
|
+
header.write("ustar\0", 257, 6, "utf8");
|
|
222139
|
+
header.write("00", 263, 2, "utf8");
|
|
222140
|
+
let checksum = 0;
|
|
222141
|
+
for (let i = 0; i < 512; i++) {
|
|
222142
|
+
checksum += header[i];
|
|
222143
|
+
}
|
|
222144
|
+
header.write(checksum.toString(8).padStart(6, "0") + "\0 ", 148, 8, "utf8");
|
|
222145
|
+
blocks.push(header);
|
|
222146
|
+
blocks.push(file.data);
|
|
222147
|
+
const remainder = file.data.length % 512;
|
|
222148
|
+
if (remainder > 0) {
|
|
222149
|
+
blocks.push(Buffer.alloc(512 - remainder, 0));
|
|
222150
|
+
}
|
|
222151
|
+
}
|
|
222152
|
+
blocks.push(Buffer.alloc(1024, 0));
|
|
222153
|
+
return Buffer.concat(blocks);
|
|
222154
|
+
}
|
|
222155
|
+
function handleGetEnvironmentFiles(request2, fileRef) {
|
|
222156
|
+
return routeWrap(request2, async () => {
|
|
222157
|
+
const match2 = fileRef.match(/^environment-(.+):download$/);
|
|
222158
|
+
if (!match2) {
|
|
222159
|
+
throw badRequest("Invalid file reference format. Expected: environment-<envId>:download");
|
|
222160
|
+
}
|
|
222161
|
+
const envId = match2[1];
|
|
222162
|
+
const db = getDb();
|
|
222163
|
+
const env3 = db.prepare(`SELECT id FROM environments WHERE id = ?`).get(envId);
|
|
222164
|
+
if (!env3) {
|
|
222165
|
+
throw notFound(`environment not found: ${envId}`);
|
|
222166
|
+
}
|
|
222167
|
+
const sessions2 = db.prepare(
|
|
222168
|
+
`SELECT id FROM sessions WHERE environment_id = ?`
|
|
222169
|
+
).all(envId);
|
|
222170
|
+
if (sessions2.length === 0) {
|
|
222171
|
+
const emptyTar = Buffer.alloc(1024, 0);
|
|
222172
|
+
return new Response(emptyTar, {
|
|
222173
|
+
headers: {
|
|
222174
|
+
"Content-Type": "application/x-tar",
|
|
222175
|
+
"Content-Length": String(emptyTar.length)
|
|
222176
|
+
}
|
|
222177
|
+
});
|
|
222178
|
+
}
|
|
222179
|
+
const sessionIds = sessions2.map((s) => s.id);
|
|
222180
|
+
const placeholders = sessionIds.map(() => "?").join(",");
|
|
222181
|
+
const fileRows = db.prepare(
|
|
222182
|
+
`SELECT * FROM files WHERE scope_type = 'session' AND scope_id IN (${placeholders})`
|
|
222183
|
+
).all(...sessionIds);
|
|
222184
|
+
const tarFiles = [];
|
|
222185
|
+
for (const row of fileRows) {
|
|
222186
|
+
if (row.storage_path.startsWith("remote:")) continue;
|
|
222187
|
+
try {
|
|
222188
|
+
const data = readFile2(row.storage_path);
|
|
222189
|
+
tarFiles.push({ name: row.filename, data });
|
|
222190
|
+
} catch {
|
|
222191
|
+
}
|
|
222192
|
+
}
|
|
222193
|
+
const tar = buildTarArchive(tarFiles);
|
|
222194
|
+
return new Response(tar, {
|
|
222195
|
+
headers: {
|
|
222196
|
+
"Content-Type": "application/x-tar",
|
|
222197
|
+
"Content-Length": String(tar.length)
|
|
222198
|
+
}
|
|
222199
|
+
});
|
|
222200
|
+
});
|
|
222201
|
+
}
|
|
222202
|
+
var init_chunk_PULMO5OO = __esm({
|
|
222203
|
+
"../agent-sdk/dist/chunk-PULMO5OO.js"() {
|
|
222204
|
+
"use strict";
|
|
222205
|
+
init_chunk_STPT3SWU();
|
|
222206
|
+
init_chunk_RMCBO7K7();
|
|
222207
|
+
init_chunk_AGIXZFHQ();
|
|
222208
|
+
init_chunk_EZYKRG4W();
|
|
222209
|
+
init_client();
|
|
222210
|
+
}
|
|
222211
|
+
});
|
|
222212
|
+
|
|
222213
|
+
// ../agent-sdk/dist/chunk-3CDJ2VQN.js
|
|
221818
222214
|
function handleWhoami(request2) {
|
|
221819
222215
|
return routeWrap(request2, async ({ auth }) => {
|
|
221820
222216
|
return jsonOk({
|
|
@@ -221825,14 +222221,14 @@ function handleWhoami(request2) {
|
|
|
221825
222221
|
});
|
|
221826
222222
|
});
|
|
221827
222223
|
}
|
|
221828
|
-
var
|
|
221829
|
-
"../agent-sdk/dist/chunk-
|
|
222224
|
+
var init_chunk_3CDJ2VQN = __esm({
|
|
222225
|
+
"../agent-sdk/dist/chunk-3CDJ2VQN.js"() {
|
|
221830
222226
|
"use strict";
|
|
221831
|
-
|
|
222227
|
+
init_chunk_RMCBO7K7();
|
|
221832
222228
|
}
|
|
221833
222229
|
});
|
|
221834
222230
|
|
|
221835
|
-
// ../agent-sdk/dist/chunk-
|
|
222231
|
+
// ../agent-sdk/dist/chunk-PUAK45BO.js
|
|
221836
222232
|
function assertSelfHostedEnv(envId) {
|
|
221837
222233
|
const env3 = getEnvironment(envId);
|
|
221838
222234
|
if (!env3) throw notFound(`environment not found: ${envId}`);
|
|
@@ -221845,7 +222241,7 @@ function handleListWork(request2, envId) {
|
|
|
221845
222241
|
assertSelfHostedEnv(envId);
|
|
221846
222242
|
const url2 = new URL(req.url);
|
|
221847
222243
|
const requestedLimit = Number(url2.searchParams.get("limit") || "20");
|
|
221848
|
-
const cursor = decodeCursor(url2.searchParams.get("page"));
|
|
222244
|
+
const cursor = decodeCursor(url2.searchParams.get("after_id") ?? url2.searchParams.get("page"));
|
|
221849
222245
|
const state4 = url2.searchParams.get("state") ?? void 0;
|
|
221850
222246
|
const items = listWorkItems(envId, { limit: requestedLimit, cursor, state: state4 });
|
|
221851
222247
|
return paginatedOk(items, requestedLimit);
|
|
@@ -221934,11 +222330,11 @@ function handleStopWork(request2, envId, workId) {
|
|
|
221934
222330
|
});
|
|
221935
222331
|
}
|
|
221936
222332
|
var UpdateWorkSchema, AckWorkSchema, StopWorkSchema;
|
|
221937
|
-
var
|
|
221938
|
-
"../agent-sdk/dist/chunk-
|
|
222333
|
+
var init_chunk_PUAK45BO = __esm({
|
|
222334
|
+
"../agent-sdk/dist/chunk-PUAK45BO.js"() {
|
|
221939
222335
|
"use strict";
|
|
221940
222336
|
init_chunk_JF777FWD();
|
|
221941
|
-
|
|
222337
|
+
init_chunk_RMCBO7K7();
|
|
221942
222338
|
init_chunk_NSUVDKNC();
|
|
221943
222339
|
init_chunk_EZYKRG4W();
|
|
221944
222340
|
init_zod();
|
|
@@ -222210,7 +222606,7 @@ var init_chunk_DF34ESOO = __esm({
|
|
|
222210
222606
|
}
|
|
222211
222607
|
});
|
|
222212
222608
|
|
|
222213
|
-
// ../agent-sdk/dist/chunk-
|
|
222609
|
+
// ../agent-sdk/dist/chunk-XLVZ5236.js
|
|
222214
222610
|
async function handleGetSkillsCatalog(request2) {
|
|
222215
222611
|
return routeWrap(request2, async ({ request: req }) => {
|
|
222216
222612
|
const url2 = new URL(req.url);
|
|
@@ -222266,15 +222662,15 @@ async function handleGetSkillsFeed(request2) {
|
|
|
222266
222662
|
return jsonOk(feed);
|
|
222267
222663
|
});
|
|
222268
222664
|
}
|
|
222269
|
-
var
|
|
222270
|
-
"../agent-sdk/dist/chunk-
|
|
222665
|
+
var init_chunk_XLVZ5236 = __esm({
|
|
222666
|
+
"../agent-sdk/dist/chunk-XLVZ5236.js"() {
|
|
222271
222667
|
"use strict";
|
|
222272
222668
|
init_chunk_DF34ESOO();
|
|
222273
|
-
|
|
222669
|
+
init_chunk_RMCBO7K7();
|
|
222274
222670
|
}
|
|
222275
222671
|
});
|
|
222276
222672
|
|
|
222277
|
-
// ../agent-sdk/dist/chunk-
|
|
222673
|
+
// ../agent-sdk/dist/chunk-5BIX3H2D.js
|
|
222278
222674
|
async function prepareSessionStream(request2, sessionId) {
|
|
222279
222675
|
try {
|
|
222280
222676
|
await ensureInitialized();
|
|
@@ -222367,14 +222763,14 @@ data: ${JSON.stringify(evt)}
|
|
|
222367
222763
|
}
|
|
222368
222764
|
});
|
|
222369
222765
|
}
|
|
222370
|
-
var
|
|
222371
|
-
"../agent-sdk/dist/chunk-
|
|
222766
|
+
var init_chunk_5BIX3H2D = __esm({
|
|
222767
|
+
"../agent-sdk/dist/chunk-5BIX3H2D.js"() {
|
|
222372
222768
|
"use strict";
|
|
222373
222769
|
init_chunk_ZBWKJ42J();
|
|
222374
222770
|
init_chunk_23UKWXJH();
|
|
222375
222771
|
init_chunk_CWB2DQN5();
|
|
222376
222772
|
init_chunk_JFHYXFAL();
|
|
222377
|
-
|
|
222773
|
+
init_chunk_ZDURV2LI();
|
|
222378
222774
|
init_chunk_DZKBUOYU();
|
|
222379
222775
|
init_chunk_RES4BCTF();
|
|
222380
222776
|
init_chunk_ZC7OR65K();
|
|
@@ -222384,7 +222780,7 @@ var init_chunk_RLBVOOCI = __esm({
|
|
|
222384
222780
|
}
|
|
222385
222781
|
});
|
|
222386
222782
|
|
|
222387
|
-
// ../agent-sdk/dist/chunk-
|
|
222783
|
+
// ../agent-sdk/dist/chunk-3IO3EGWP.js
|
|
222388
222784
|
function handleCreateTenant(request2) {
|
|
222389
222785
|
return routeWrap(request2, async ({ auth, request: req }) => {
|
|
222390
222786
|
requireFeature("tenancy", "multi-tenancy");
|
|
@@ -222483,13 +222879,13 @@ function handleArchiveTenant(request2, id) {
|
|
|
222483
222879
|
});
|
|
222484
222880
|
}
|
|
222485
222881
|
var CreateBody, PatchBody;
|
|
222486
|
-
var
|
|
222487
|
-
"../agent-sdk/dist/chunk-
|
|
222882
|
+
var init_chunk_3IO3EGWP = __esm({
|
|
222883
|
+
"../agent-sdk/dist/chunk-3IO3EGWP.js"() {
|
|
222488
222884
|
"use strict";
|
|
222489
222885
|
init_chunk_23UKWXJH();
|
|
222490
222886
|
init_chunk_FDLQ3IUB();
|
|
222491
222887
|
init_chunk_2N2KL4KM();
|
|
222492
|
-
|
|
222888
|
+
init_chunk_RMCBO7K7();
|
|
222493
222889
|
init_chunk_YTBVILAH();
|
|
222494
222890
|
init_chunk_EZYKRG4W();
|
|
222495
222891
|
init_zod();
|
|
@@ -222503,7 +222899,7 @@ var init_chunk_YREG7LWO = __esm({
|
|
|
222503
222899
|
}
|
|
222504
222900
|
});
|
|
222505
222901
|
|
|
222506
|
-
// ../agent-sdk/dist/chunk-
|
|
222902
|
+
// ../agent-sdk/dist/chunk-4XB2CJPE.js
|
|
222507
222903
|
function loadSession(auth, sessionId) {
|
|
222508
222904
|
const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
|
|
222509
222905
|
if (!row) throw notFound(`session ${sessionId} not found`);
|
|
@@ -222628,12 +223024,12 @@ data: ${JSON.stringify(evt)}
|
|
|
222628
223024
|
});
|
|
222629
223025
|
});
|
|
222630
223026
|
}
|
|
222631
|
-
var
|
|
222632
|
-
"../agent-sdk/dist/chunk-
|
|
223027
|
+
var init_chunk_4XB2CJPE = __esm({
|
|
223028
|
+
"../agent-sdk/dist/chunk-4XB2CJPE.js"() {
|
|
222633
223029
|
"use strict";
|
|
222634
223030
|
init_chunk_Z5IENUYV();
|
|
222635
223031
|
init_chunk_23UKWXJH();
|
|
222636
|
-
|
|
223032
|
+
init_chunk_RMCBO7K7();
|
|
222637
223033
|
init_chunk_RES4BCTF();
|
|
222638
223034
|
init_chunk_ZC7OR65K();
|
|
222639
223035
|
init_chunk_OEFJPZYH();
|
|
@@ -222685,7 +223081,7 @@ var init_chunk_UMXXZ6OX = __esm({
|
|
|
222685
223081
|
}
|
|
222686
223082
|
});
|
|
222687
223083
|
|
|
222688
|
-
// ../agent-sdk/dist/chunk-
|
|
223084
|
+
// ../agent-sdk/dist/chunk-VWCIN45Y.js
|
|
222689
223085
|
function buildSpanTree(events2) {
|
|
222690
223086
|
const nodes = /* @__PURE__ */ new Map();
|
|
222691
223087
|
const openStarts = /* @__PURE__ */ new Map();
|
|
@@ -222869,11 +223265,11 @@ function handleExportTrace(request2, traceId) {
|
|
|
222869
223265
|
return jsonOk(result, result.ok ? 200 : 502);
|
|
222870
223266
|
});
|
|
222871
223267
|
}
|
|
222872
|
-
var
|
|
222873
|
-
"../agent-sdk/dist/chunk-
|
|
223268
|
+
var init_chunk_VWCIN45Y = __esm({
|
|
223269
|
+
"../agent-sdk/dist/chunk-VWCIN45Y.js"() {
|
|
222874
223270
|
"use strict";
|
|
222875
223271
|
init_chunk_UMXXZ6OX();
|
|
222876
|
-
|
|
223272
|
+
init_chunk_RMCBO7K7();
|
|
222877
223273
|
init_chunk_2KF2TIEY();
|
|
222878
223274
|
init_chunk_OEFJPZYH();
|
|
222879
223275
|
init_chunk_EZYKRG4W();
|
|
@@ -223460,7 +223856,7 @@ agentstep skills install \${n}
|
|
|
223460
223856
|
}
|
|
223461
223857
|
});
|
|
223462
223858
|
|
|
223463
|
-
// ../agent-sdk/dist/chunk-
|
|
223859
|
+
// ../agent-sdk/dist/chunk-FH2IOAQM.js
|
|
223464
223860
|
function handleAddUpstreamKey(request2) {
|
|
223465
223861
|
return routeWrap(request2, async ({ auth, request: req }) => {
|
|
223466
223862
|
requireFeature("upstream_pool", "upstream key pool");
|
|
@@ -223552,15 +223948,15 @@ function handleDeleteUpstreamKey(request2, id) {
|
|
|
223552
223948
|
});
|
|
223553
223949
|
}
|
|
223554
223950
|
var AddBody, PatchBody2;
|
|
223555
|
-
var
|
|
223556
|
-
"../agent-sdk/dist/chunk-
|
|
223951
|
+
var init_chunk_FH2IOAQM = __esm({
|
|
223952
|
+
"../agent-sdk/dist/chunk-FH2IOAQM.js"() {
|
|
223557
223953
|
"use strict";
|
|
223558
223954
|
init_chunk_HWWFRSAX();
|
|
223559
223955
|
init_chunk_ABUNDZCE();
|
|
223560
223956
|
init_chunk_23UKWXJH();
|
|
223561
223957
|
init_chunk_FDLQ3IUB();
|
|
223562
223958
|
init_chunk_2N2KL4KM();
|
|
223563
|
-
|
|
223959
|
+
init_chunk_RMCBO7K7();
|
|
223564
223960
|
init_chunk_EZYKRG4W();
|
|
223565
223961
|
init_zod();
|
|
223566
223962
|
AddBody = external_exports.object({
|
|
@@ -223574,7 +223970,7 @@ var init_chunk_GHPBBVDF = __esm({
|
|
|
223574
223970
|
}
|
|
223575
223971
|
});
|
|
223576
223972
|
|
|
223577
|
-
// ../agent-sdk/dist/chunk-
|
|
223973
|
+
// ../agent-sdk/dist/chunk-2YZUXJAN.js
|
|
223578
223974
|
function handleCreateUserProfile(request2) {
|
|
223579
223975
|
return routeWrap(request2, async ({ auth }) => {
|
|
223580
223976
|
const body = await request2.json().catch(() => null);
|
|
@@ -223640,11 +224036,11 @@ function handleUpdateUserProfile(request2, id) {
|
|
|
223640
224036
|
});
|
|
223641
224037
|
}
|
|
223642
224038
|
var TrustGrantSchema, CreateSchema5, UpdateSchema4;
|
|
223643
|
-
var
|
|
223644
|
-
"../agent-sdk/dist/chunk-
|
|
224039
|
+
var init_chunk_2YZUXJAN = __esm({
|
|
224040
|
+
"../agent-sdk/dist/chunk-2YZUXJAN.js"() {
|
|
223645
224041
|
"use strict";
|
|
223646
224042
|
init_chunk_23UKWXJH();
|
|
223647
|
-
|
|
224043
|
+
init_chunk_RMCBO7K7();
|
|
223648
224044
|
init_chunk_YOZ6WDP3();
|
|
223649
224045
|
init_chunk_EZYKRG4W();
|
|
223650
224046
|
init_zod();
|
|
@@ -223666,7 +224062,7 @@ var init_chunk_TIX26S4Y = __esm({
|
|
|
223666
224062
|
}
|
|
223667
224063
|
});
|
|
223668
224064
|
|
|
223669
|
-
// ../agent-sdk/dist/chunk-
|
|
224065
|
+
// ../agent-sdk/dist/chunk-W3DA3OFL.js
|
|
223670
224066
|
function zeroTotals() {
|
|
223671
224067
|
return {
|
|
223672
224068
|
session_count: 0,
|
|
@@ -224026,12 +224422,12 @@ function handleGetApiMetrics(request2) {
|
|
|
224026
224422
|
});
|
|
224027
224423
|
}
|
|
224028
224424
|
var BUCKET_MS, TOP_N, MAX_POINTS_PER_SERIES, MAX_TOTAL_CELLS;
|
|
224029
|
-
var
|
|
224030
|
-
"../agent-sdk/dist/chunk-
|
|
224425
|
+
var init_chunk_W3DA3OFL = __esm({
|
|
224426
|
+
"../agent-sdk/dist/chunk-W3DA3OFL.js"() {
|
|
224031
224427
|
"use strict";
|
|
224032
224428
|
init_chunk_23UKWXJH();
|
|
224033
224429
|
init_chunk_2N2KL4KM();
|
|
224034
|
-
|
|
224430
|
+
init_chunk_RMCBO7K7();
|
|
224035
224431
|
init_chunk_D2XITRN6();
|
|
224036
224432
|
init_chunk_AGIXZFHQ();
|
|
224037
224433
|
init_chunk_EZYKRG4W();
|
|
@@ -224047,7 +224443,7 @@ var init_chunk_ROJCTM3K = __esm({
|
|
|
224047
224443
|
}
|
|
224048
224444
|
});
|
|
224049
224445
|
|
|
224050
|
-
// ../agent-sdk/dist/chunk-
|
|
224446
|
+
// ../agent-sdk/dist/chunk-VIWYYVGR.js
|
|
224051
224447
|
function handleListModels(request2) {
|
|
224052
224448
|
return routeWrap(request2, async ({ request: req }) => {
|
|
224053
224449
|
const url2 = new URL(req.url);
|
|
@@ -224058,15 +224454,15 @@ function handleListModels(request2) {
|
|
|
224058
224454
|
return jsonOk({ data: models });
|
|
224059
224455
|
});
|
|
224060
224456
|
}
|
|
224061
|
-
var
|
|
224062
|
-
"../agent-sdk/dist/chunk-
|
|
224457
|
+
var init_chunk_VIWYYVGR = __esm({
|
|
224458
|
+
"../agent-sdk/dist/chunk-VIWYYVGR.js"() {
|
|
224063
224459
|
"use strict";
|
|
224064
224460
|
init_chunk_UTGP4X74();
|
|
224065
|
-
|
|
224461
|
+
init_chunk_RMCBO7K7();
|
|
224066
224462
|
}
|
|
224067
224463
|
});
|
|
224068
224464
|
|
|
224069
|
-
// ../agent-sdk/dist/chunk-
|
|
224465
|
+
// ../agent-sdk/dist/chunk-NG6NUC3W.js
|
|
224070
224466
|
function originFromRequest(request2) {
|
|
224071
224467
|
const headers3 = request2.headers;
|
|
224072
224468
|
const proto3 = headers3.get("x-forwarded-proto") ?? new URL(request2.url).protocol.replace(":", "");
|
|
@@ -224078,14 +224474,14 @@ async function handleGetOpenApiSpec(request2) {
|
|
|
224078
224474
|
const doc = buildOpenApiDocument({ serverUrl });
|
|
224079
224475
|
return Response.json(doc);
|
|
224080
224476
|
}
|
|
224081
|
-
var
|
|
224082
|
-
"../agent-sdk/dist/chunk-
|
|
224477
|
+
var init_chunk_NG6NUC3W = __esm({
|
|
224478
|
+
"../agent-sdk/dist/chunk-NG6NUC3W.js"() {
|
|
224083
224479
|
"use strict";
|
|
224084
|
-
|
|
224480
|
+
init_chunk_CNMMJFJI();
|
|
224085
224481
|
}
|
|
224086
224482
|
});
|
|
224087
224483
|
|
|
224088
|
-
// ../agent-sdk/dist/chunk-
|
|
224484
|
+
// ../agent-sdk/dist/chunk-R7MZNZNC.js
|
|
224089
224485
|
async function checkLocalProvider(name) {
|
|
224090
224486
|
try {
|
|
224091
224487
|
const provider = await resolveContainerProvider(name);
|
|
@@ -224124,10 +224520,10 @@ async function handleGetProviderStatus(request2) {
|
|
|
224124
224520
|
});
|
|
224125
224521
|
}
|
|
224126
224522
|
var LOCAL_PROVIDERS, CLOUD_PROVIDERS, CLOUD_KEY_MAP;
|
|
224127
|
-
var
|
|
224128
|
-
"../agent-sdk/dist/chunk-
|
|
224523
|
+
var init_chunk_R7MZNZNC = __esm({
|
|
224524
|
+
"../agent-sdk/dist/chunk-R7MZNZNC.js"() {
|
|
224129
224525
|
"use strict";
|
|
224130
|
-
|
|
224526
|
+
init_chunk_RMCBO7K7();
|
|
224131
224527
|
init_chunk_XLMNSDUJ();
|
|
224132
224528
|
init_chunk_6EIONZ7F();
|
|
224133
224529
|
LOCAL_PROVIDERS = ["docker", "apple-container", "podman"];
|
|
@@ -224143,7 +224539,7 @@ var init_chunk_W7MPHRTW = __esm({
|
|
|
224143
224539
|
}
|
|
224144
224540
|
});
|
|
224145
224541
|
|
|
224146
|
-
// ../agent-sdk/dist/chunk-
|
|
224542
|
+
// ../agent-sdk/dist/chunk-DQIQBMC2.js
|
|
224147
224543
|
function assertSessionTenant2(auth, sessionId) {
|
|
224148
224544
|
const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
|
|
224149
224545
|
if (row) {
|
|
@@ -224231,11 +224627,11 @@ function handleDeleteResource(request2, sessionId, resourceId) {
|
|
|
224231
224627
|
});
|
|
224232
224628
|
}
|
|
224233
224629
|
var MAX_RESOURCES_PER_SESSION, AddResourceSchema, UpdateResourceSchema;
|
|
224234
|
-
var
|
|
224235
|
-
"../agent-sdk/dist/chunk-
|
|
224630
|
+
var init_chunk_DQIQBMC2 = __esm({
|
|
224631
|
+
"../agent-sdk/dist/chunk-DQIQBMC2.js"() {
|
|
224236
224632
|
"use strict";
|
|
224237
224633
|
init_chunk_23UKWXJH();
|
|
224238
|
-
|
|
224634
|
+
init_chunk_RMCBO7K7();
|
|
224239
224635
|
init_chunk_DZKBUOYU();
|
|
224240
224636
|
init_chunk_ZC7OR65K();
|
|
224241
224637
|
init_chunk_GCT7A5KR();
|
|
@@ -224266,7 +224662,7 @@ var init_chunk_7XWAEIPU = __esm({
|
|
|
224266
224662
|
}
|
|
224267
224663
|
});
|
|
224268
224664
|
|
|
224269
|
-
// ../agent-sdk/dist/chunk-
|
|
224665
|
+
// ../agent-sdk/dist/chunk-52K3LOFD.js
|
|
224270
224666
|
function maskSecret(value) {
|
|
224271
224667
|
if (!value) return "";
|
|
224272
224668
|
if (value.length <= 12) return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
@@ -224301,10 +224697,10 @@ function handleGetSetting(request2, key) {
|
|
|
224301
224697
|
});
|
|
224302
224698
|
}
|
|
224303
224699
|
var NON_SECRET_KEYS, ALLOWED_KEYS, SECRET_KEYS;
|
|
224304
|
-
var
|
|
224305
|
-
"../agent-sdk/dist/chunk-
|
|
224700
|
+
var init_chunk_52K3LOFD = __esm({
|
|
224701
|
+
"../agent-sdk/dist/chunk-52K3LOFD.js"() {
|
|
224306
224702
|
"use strict";
|
|
224307
|
-
|
|
224703
|
+
init_chunk_RMCBO7K7();
|
|
224308
224704
|
init_chunk_6EIONZ7F();
|
|
224309
224705
|
init_chunk_EZYKRG4W();
|
|
224310
224706
|
NON_SECRET_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -224346,7 +224742,7 @@ var init_chunk_K2YPC2GW = __esm({
|
|
|
224346
224742
|
}
|
|
224347
224743
|
});
|
|
224348
224744
|
|
|
224349
|
-
// ../agent-sdk/dist/chunk-
|
|
224745
|
+
// ../agent-sdk/dist/chunk-2E43SH4Y.js
|
|
224350
224746
|
import { inflateRawSync } from "zlib";
|
|
224351
224747
|
function extractFromZipRaw(buffer) {
|
|
224352
224748
|
const files2 = /* @__PURE__ */ new Map();
|
|
@@ -224525,12 +224921,12 @@ function handleDeleteSkillVersion(request2, skillId, version3) {
|
|
|
224525
224921
|
});
|
|
224526
224922
|
}
|
|
224527
224923
|
var TEXT_EXTENSIONS2, CreateSkillSchema, CreateVersionSchema;
|
|
224528
|
-
var
|
|
224529
|
-
"../agent-sdk/dist/chunk-
|
|
224924
|
+
var init_chunk_2E43SH4Y = __esm({
|
|
224925
|
+
"../agent-sdk/dist/chunk-2E43SH4Y.js"() {
|
|
224530
224926
|
"use strict";
|
|
224531
224927
|
init_chunk_TTDMQ54U();
|
|
224532
224928
|
init_chunk_23UKWXJH();
|
|
224533
|
-
|
|
224929
|
+
init_chunk_RMCBO7K7();
|
|
224534
224930
|
init_chunk_EZYKRG4W();
|
|
224535
224931
|
init_zod();
|
|
224536
224932
|
TEXT_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
@@ -224690,8 +225086,8 @@ __export(init_exports4, {
|
|
|
224690
225086
|
var init_init = __esm({
|
|
224691
225087
|
"../agent-sdk/dist/init.js"() {
|
|
224692
225088
|
"use strict";
|
|
224693
|
-
|
|
224694
|
-
|
|
225089
|
+
init_chunk_ZDURV2LI();
|
|
225090
|
+
init_chunk_YAJJ7KHX();
|
|
224695
225091
|
init_chunk_PJZ5TQYW();
|
|
224696
225092
|
init_chunk_AU4NAQGA();
|
|
224697
225093
|
init_chunk_H6TQGV4L();
|
|
@@ -224706,10 +225102,10 @@ var init_init = __esm({
|
|
|
224706
225102
|
init_chunk_WK33IBKY();
|
|
224707
225103
|
init_chunk_3NUTTKE5();
|
|
224708
225104
|
init_chunk_3MQ2FWXS();
|
|
224709
|
-
|
|
224710
|
-
|
|
225105
|
+
init_chunk_HGV3Y4PS();
|
|
225106
|
+
init_chunk_AE7UG76I();
|
|
224711
225107
|
init_chunk_LAWTTG2E();
|
|
224712
|
-
|
|
225108
|
+
init_chunk_IL2CZHNC();
|
|
224713
225109
|
init_chunk_4XXQAVKE();
|
|
224714
225110
|
init_chunk_JNSJKHYX();
|
|
224715
225111
|
init_chunk_5ZFOKZGR();
|
|
@@ -224727,7 +225123,7 @@ var init_init = __esm({
|
|
|
224727
225123
|
init_chunk_G7KUVNDY();
|
|
224728
225124
|
init_chunk_6U6HEVSN();
|
|
224729
225125
|
init_chunk_YTBVILAH();
|
|
224730
|
-
|
|
225126
|
+
init_chunk_V5RHOS43();
|
|
224731
225127
|
init_chunk_J7F2OFWQ();
|
|
224732
225128
|
init_chunk_B6E6BVNK();
|
|
224733
225129
|
init_chunk_6SD6MC2B();
|
|
@@ -224746,25 +225142,25 @@ var init_init = __esm({
|
|
|
224746
225142
|
init_chunk_UY3VT3HQ();
|
|
224747
225143
|
init_chunk_PDWLVL34();
|
|
224748
225144
|
init_chunk_QCGIYXN4();
|
|
224749
|
-
|
|
224750
|
-
init_chunk_YJCH35J4();
|
|
224751
|
-
init_chunk_CY6AWCC6();
|
|
224752
|
-
init_chunk_VRRGSQI7();
|
|
224753
|
-
init_chunk_D6RQPBRG();
|
|
224754
|
-
init_chunk_IBYOMAZ3();
|
|
224755
|
-
init_chunk_5PS6KN3J();
|
|
225145
|
+
init_chunk_65XY7HRS();
|
|
224756
225146
|
init_chunk_TPMZO6S2();
|
|
224757
225147
|
init_chunk_M72ERPMT();
|
|
224758
225148
|
init_chunk_AQHYCRTO();
|
|
224759
|
-
init_chunk_KJ2GJLPQ();
|
|
224760
225149
|
init_chunk_7TSTCMII();
|
|
224761
|
-
|
|
225150
|
+
init_chunk_KJ2GJLPQ();
|
|
225151
|
+
init_chunk_IBYOMAZ3();
|
|
225152
|
+
init_chunk_WEUPM3IN();
|
|
225153
|
+
init_chunk_PJYCPDV5();
|
|
225154
|
+
init_chunk_SIO4LO2M();
|
|
224762
225155
|
init_chunk_NMZMRH3E();
|
|
224763
|
-
init_chunk_CULYZ3VA();
|
|
224764
225156
|
init_chunk_XJYR5HE3();
|
|
225157
|
+
init_chunk_CULYZ3VA();
|
|
225158
|
+
init_chunk_JN3DHH7Z();
|
|
225159
|
+
init_chunk_VRRGSQI7();
|
|
225160
|
+
init_chunk_D6RQPBRG();
|
|
225161
|
+
init_chunk_YJCH35J4();
|
|
224765
225162
|
init_chunk_YE2RMJY7();
|
|
224766
|
-
|
|
224767
|
-
init_chunk_SIO4LO2M();
|
|
225163
|
+
init_chunk_CY6AWCC6();
|
|
224768
225164
|
init_chunk_FX2AEKOV();
|
|
224769
225165
|
init_chunk_J6T3W6RY();
|
|
224770
225166
|
init_chunk_F4WUVOLE();
|
|
@@ -224781,7 +225177,7 @@ var init_init = __esm({
|
|
|
224781
225177
|
}
|
|
224782
225178
|
});
|
|
224783
225179
|
|
|
224784
|
-
// ../agent-sdk/dist/chunk-
|
|
225180
|
+
// ../agent-sdk/dist/chunk-TBLHBMA5.js
|
|
224785
225181
|
import { randomBytes } from "crypto";
|
|
224786
225182
|
function handleEnrollmentUrl(request2, profileId) {
|
|
224787
225183
|
return routeWrap(request2, async ({ auth }) => {
|
|
@@ -224945,11 +225341,11 @@ async function handleOAuthCallback(request2) {
|
|
|
224945
225341
|
}
|
|
224946
225342
|
}
|
|
224947
225343
|
var pendingEnrollments, EnrollmentSchema;
|
|
224948
|
-
var
|
|
224949
|
-
"../agent-sdk/dist/chunk-
|
|
225344
|
+
var init_chunk_TBLHBMA5 = __esm({
|
|
225345
|
+
"../agent-sdk/dist/chunk-TBLHBMA5.js"() {
|
|
224950
225346
|
"use strict";
|
|
224951
225347
|
init_chunk_23UKWXJH();
|
|
224952
|
-
|
|
225348
|
+
init_chunk_RMCBO7K7();
|
|
224953
225349
|
init_chunk_YOZ6WDP3();
|
|
224954
225350
|
init_chunk_WK33IBKY();
|
|
224955
225351
|
init_chunk_EZYKRG4W();
|
|
@@ -224977,7 +225373,7 @@ var init_chunk_I6WSRROX = __esm({
|
|
|
224977
225373
|
}
|
|
224978
225374
|
});
|
|
224979
225375
|
|
|
224980
|
-
// ../agent-sdk/dist/chunk-
|
|
225376
|
+
// ../agent-sdk/dist/chunk-JFIJEF4N.js
|
|
224981
225377
|
function assertFileTenantByScope(auth, scopeType, scopeId) {
|
|
224982
225378
|
if (!scopeId || scopeType !== "session") {
|
|
224983
225379
|
if (!auth.isGlobalAdmin) throw notFound("file not found");
|
|
@@ -225112,34 +225508,34 @@ function handleDeleteFile(request2, fileId) {
|
|
|
225112
225508
|
return jsonOk(result);
|
|
225113
225509
|
});
|
|
225114
225510
|
}
|
|
225115
|
-
var
|
|
225116
|
-
"../agent-sdk/dist/chunk-
|
|
225511
|
+
var init_chunk_JFIJEF4N = __esm({
|
|
225512
|
+
"../agent-sdk/dist/chunk-JFIJEF4N.js"() {
|
|
225117
225513
|
"use strict";
|
|
225118
225514
|
init_chunk_STPT3SWU();
|
|
225119
|
-
|
|
225515
|
+
init_chunk_LJ2ZXLLT();
|
|
225120
225516
|
init_chunk_23UKWXJH();
|
|
225121
|
-
|
|
225517
|
+
init_chunk_RMCBO7K7();
|
|
225122
225518
|
init_chunk_AGIXZFHQ();
|
|
225123
225519
|
init_chunk_EZYKRG4W();
|
|
225124
225520
|
init_client();
|
|
225125
225521
|
}
|
|
225126
225522
|
});
|
|
225127
225523
|
|
|
225128
|
-
// ../agent-sdk/dist/chunk-
|
|
225524
|
+
// ../agent-sdk/dist/chunk-L2ZB7TCF.js
|
|
225129
225525
|
function handleGetLicense(request2) {
|
|
225130
225526
|
return routeWrap(request2, async () => {
|
|
225131
225527
|
return jsonOk(getLicenseInfo());
|
|
225132
225528
|
});
|
|
225133
225529
|
}
|
|
225134
|
-
var
|
|
225135
|
-
"../agent-sdk/dist/chunk-
|
|
225530
|
+
var init_chunk_L2ZB7TCF = __esm({
|
|
225531
|
+
"../agent-sdk/dist/chunk-L2ZB7TCF.js"() {
|
|
225136
225532
|
"use strict";
|
|
225137
225533
|
init_chunk_2N2KL4KM();
|
|
225138
|
-
|
|
225534
|
+
init_chunk_RMCBO7K7();
|
|
225139
225535
|
}
|
|
225140
225536
|
});
|
|
225141
225537
|
|
|
225142
|
-
// ../agent-sdk/dist/chunk-
|
|
225538
|
+
// ../agent-sdk/dist/chunk-ZPTYXWUO.js
|
|
225143
225539
|
function assertStoreTenant(auth, storeAgentId) {
|
|
225144
225540
|
if (storeAgentId == null) {
|
|
225145
225541
|
if (!auth.isGlobalAdmin) throw notFound("memory store not found");
|
|
@@ -225339,13 +225735,13 @@ function handleDreamMemoryStore(request2, storeId) {
|
|
|
225339
225735
|
});
|
|
225340
225736
|
}
|
|
225341
225737
|
var CreateStoreSchema, UpdateStoreSchema, CreateMemorySchema, UpdateMemorySchema, DreamRequestSchema, dreamCooldowns, DREAM_COOLDOWN_MS;
|
|
225342
|
-
var
|
|
225343
|
-
"../agent-sdk/dist/chunk-
|
|
225738
|
+
var init_chunk_ZPTYXWUO = __esm({
|
|
225739
|
+
"../agent-sdk/dist/chunk-ZPTYXWUO.js"() {
|
|
225344
225740
|
"use strict";
|
|
225345
225741
|
init_chunk_23UKWXJH();
|
|
225346
225742
|
init_chunk_IC2ETYU5();
|
|
225347
225743
|
init_chunk_TVV7AE3G();
|
|
225348
|
-
|
|
225744
|
+
init_chunk_RMCBO7K7();
|
|
225349
225745
|
init_chunk_6EIONZ7F();
|
|
225350
225746
|
init_chunk_AGIXZFHQ();
|
|
225351
225747
|
init_chunk_EZYKRG4W();
|
|
@@ -225380,7 +225776,7 @@ var init_chunk_5U2DDWTW = __esm({
|
|
|
225380
225776
|
}
|
|
225381
225777
|
});
|
|
225382
225778
|
|
|
225383
|
-
// ../agent-sdk/dist/chunk-
|
|
225779
|
+
// ../agent-sdk/dist/chunk-3WPVSQGI.js
|
|
225384
225780
|
function toView3(row) {
|
|
225385
225781
|
return row;
|
|
225386
225782
|
}
|
|
@@ -225551,13 +225947,13 @@ function handleGetApiKeyActivity(request2, id) {
|
|
|
225551
225947
|
});
|
|
225552
225948
|
}
|
|
225553
225949
|
var ScopeSchema, PermissionsSchema, CreateBody2, PatchBody3;
|
|
225554
|
-
var
|
|
225555
|
-
"../agent-sdk/dist/chunk-
|
|
225950
|
+
var init_chunk_3WPVSQGI = __esm({
|
|
225951
|
+
"../agent-sdk/dist/chunk-3WPVSQGI.js"() {
|
|
225556
225952
|
"use strict";
|
|
225557
225953
|
init_chunk_23UKWXJH();
|
|
225558
225954
|
init_chunk_FDLQ3IUB();
|
|
225559
225955
|
init_chunk_2N2KL4KM();
|
|
225560
|
-
|
|
225956
|
+
init_chunk_RMCBO7K7();
|
|
225561
225957
|
init_chunk_3NUTTKE5();
|
|
225562
225958
|
init_chunk_ZC7OR65K();
|
|
225563
225959
|
init_chunk_AGIXZFHQ();
|
|
@@ -225584,7 +225980,7 @@ var init_chunk_LW3AP2XF = __esm({
|
|
|
225584
225980
|
}
|
|
225585
225981
|
});
|
|
225586
225982
|
|
|
225587
|
-
// ../agent-sdk/dist/chunk-
|
|
225983
|
+
// ../agent-sdk/dist/chunk-MG2DS6QE.js
|
|
225588
225984
|
function parseMs2(v2) {
|
|
225589
225985
|
if (!v2) return void 0;
|
|
225590
225986
|
const n = Number(v2);
|
|
@@ -225631,18 +226027,18 @@ function handleListAudit(request2) {
|
|
|
225631
226027
|
});
|
|
225632
226028
|
}
|
|
225633
226029
|
var VALID_OUTCOMES;
|
|
225634
|
-
var
|
|
225635
|
-
"../agent-sdk/dist/chunk-
|
|
226030
|
+
var init_chunk_MG2DS6QE = __esm({
|
|
226031
|
+
"../agent-sdk/dist/chunk-MG2DS6QE.js"() {
|
|
225636
226032
|
"use strict";
|
|
225637
226033
|
init_chunk_23UKWXJH();
|
|
225638
226034
|
init_chunk_FDLQ3IUB();
|
|
225639
|
-
|
|
226035
|
+
init_chunk_RMCBO7K7();
|
|
225640
226036
|
init_chunk_EZYKRG4W();
|
|
225641
226037
|
VALID_OUTCOMES = /* @__PURE__ */ new Set(["success", "denied", "failure"]);
|
|
225642
226038
|
}
|
|
225643
226039
|
});
|
|
225644
226040
|
|
|
225645
|
-
// ../agent-sdk/dist/chunk-
|
|
226041
|
+
// ../agent-sdk/dist/chunk-3RK6EX7J.js
|
|
225646
226042
|
function handleBatch(request2) {
|
|
225647
226043
|
return routeWrap(request2, async () => {
|
|
225648
226044
|
const body = await request2.json();
|
|
@@ -225669,11 +226065,11 @@ function handleBatch(request2) {
|
|
|
225669
226065
|
});
|
|
225670
226066
|
}
|
|
225671
226067
|
var OperationSchema, BatchSchema2;
|
|
225672
|
-
var
|
|
225673
|
-
"../agent-sdk/dist/chunk-
|
|
226068
|
+
var init_chunk_3RK6EX7J = __esm({
|
|
226069
|
+
"../agent-sdk/dist/chunk-3RK6EX7J.js"() {
|
|
225674
226070
|
"use strict";
|
|
225675
226071
|
init_chunk_I2RVN7CP();
|
|
225676
|
-
|
|
226072
|
+
init_chunk_RMCBO7K7();
|
|
225677
226073
|
init_chunk_EZYKRG4W();
|
|
225678
226074
|
init_zod();
|
|
225679
226075
|
OperationSchema = external_exports.object({
|
|
@@ -225687,7 +226083,7 @@ var init_chunk_IJGOOH73 = __esm({
|
|
|
225687
226083
|
}
|
|
225688
226084
|
});
|
|
225689
226085
|
|
|
225690
|
-
// ../agent-sdk/dist/chunk-
|
|
226086
|
+
// ../agent-sdk/dist/chunk-NO77URFL.js
|
|
225691
226087
|
function getVaultTenantId(id) {
|
|
225692
226088
|
const row = getDb().prepare(`SELECT tenant_id FROM vaults WHERE id = ?`).get(id);
|
|
225693
226089
|
return row?.tenant_id;
|
|
@@ -225826,11 +226222,11 @@ function handleDeleteEntry(request2, vaultId, key) {
|
|
|
225826
226222
|
});
|
|
225827
226223
|
}
|
|
225828
226224
|
var CreateVaultSchema, PutEntrySchema, UpdateVaultSchema;
|
|
225829
|
-
var
|
|
225830
|
-
"../agent-sdk/dist/chunk-
|
|
226225
|
+
var init_chunk_NO77URFL = __esm({
|
|
226226
|
+
"../agent-sdk/dist/chunk-NO77URFL.js"() {
|
|
225831
226227
|
"use strict";
|
|
225832
226228
|
init_chunk_23UKWXJH();
|
|
225833
|
-
|
|
226229
|
+
init_chunk_RMCBO7K7();
|
|
225834
226230
|
init_chunk_MUARVVXF();
|
|
225835
226231
|
init_chunk_6U6HEVSN();
|
|
225836
226232
|
init_chunk_AGIXZFHQ();
|
|
@@ -225862,7 +226258,7 @@ var init_chunk_MKPG7QMU = __esm({
|
|
|
225862
226258
|
}
|
|
225863
226259
|
});
|
|
225864
226260
|
|
|
225865
|
-
// ../agent-sdk/dist/chunk-
|
|
226261
|
+
// ../agent-sdk/dist/chunk-L7X2UMNJ.js
|
|
225866
226262
|
function handleCreateCredential(request2, vaultId) {
|
|
225867
226263
|
return routeWrap(request2, async ({ auth }) => {
|
|
225868
226264
|
loadVaultForCaller(auth, vaultId);
|
|
@@ -226053,11 +226449,11 @@ function handleMcpOauthValidate(request2, vaultId, credentialId) {
|
|
|
226053
226449
|
});
|
|
226054
226450
|
}
|
|
226055
226451
|
var TokenEndpointAuthSchema, OAuthRefreshSchema, StaticBearerAuthSchema, McpOauthAuthSchema, CreateCredentialSchema, UpdateStaticBearerAuthSchema, UpdateMcpOauthAuthSchema, UpdateAuthSchema, UpdateCredentialSchema;
|
|
226056
|
-
var
|
|
226057
|
-
"../agent-sdk/dist/chunk-
|
|
226452
|
+
var init_chunk_L7X2UMNJ = __esm({
|
|
226453
|
+
"../agent-sdk/dist/chunk-L7X2UMNJ.js"() {
|
|
226058
226454
|
"use strict";
|
|
226059
|
-
|
|
226060
|
-
|
|
226455
|
+
init_chunk_NO77URFL();
|
|
226456
|
+
init_chunk_RMCBO7K7();
|
|
226061
226457
|
init_chunk_WK33IBKY();
|
|
226062
226458
|
init_chunk_EZYKRG4W();
|
|
226063
226459
|
init_zod();
|
|
@@ -226130,10 +226526,12 @@ __export(handlers_exports, {
|
|
|
226130
226526
|
handleArchiveThread: () => handleArchiveThread,
|
|
226131
226527
|
handleArchiveVault: () => handleArchiveVault,
|
|
226132
226528
|
handleBatch: () => handleBatch,
|
|
226529
|
+
handleCancelInteraction: () => handleCancelInteraction,
|
|
226133
226530
|
handleCreateAgent: () => handleCreateAgent,
|
|
226134
226531
|
handleCreateApiKey: () => handleCreateApiKey,
|
|
226135
226532
|
handleCreateCredential: () => handleCreateCredential,
|
|
226136
226533
|
handleCreateEnvironment: () => handleCreateEnvironment,
|
|
226534
|
+
handleCreateGoogleAgent: () => handleCreateGoogleAgent,
|
|
226137
226535
|
handleCreateInteraction: () => handleCreateInteraction,
|
|
226138
226536
|
handleCreateMemory: () => handleCreateMemory,
|
|
226139
226537
|
handleCreateMemoryStore: () => handleCreateMemoryStore,
|
|
@@ -226148,6 +226546,8 @@ __export(handlers_exports, {
|
|
|
226148
226546
|
handleDeleteEntry: () => handleDeleteEntry,
|
|
226149
226547
|
handleDeleteEnvironment: () => handleDeleteEnvironment,
|
|
226150
226548
|
handleDeleteFile: () => handleDeleteFile,
|
|
226549
|
+
handleDeleteGoogleAgent: () => handleDeleteGoogleAgent,
|
|
226550
|
+
handleDeleteInteraction: () => handleDeleteInteraction,
|
|
226151
226551
|
handleDeleteMemory: () => handleDeleteMemory,
|
|
226152
226552
|
handleDeleteMemoryStore: () => handleDeleteMemoryStore,
|
|
226153
226553
|
handleDeleteResource: () => handleDeleteResource,
|
|
@@ -226167,8 +226567,11 @@ __export(handlers_exports, {
|
|
|
226167
226567
|
handleGetDocs: () => handleGetDocs,
|
|
226168
226568
|
handleGetEntry: () => handleGetEntry,
|
|
226169
226569
|
handleGetEnvironment: () => handleGetEnvironment,
|
|
226570
|
+
handleGetEnvironmentFiles: () => handleGetEnvironmentFiles,
|
|
226170
226571
|
handleGetFile: () => handleGetFile,
|
|
226171
226572
|
handleGetFileContent: () => handleGetFileContent,
|
|
226573
|
+
handleGetGoogleAgent: () => handleGetGoogleAgent,
|
|
226574
|
+
handleGetInteraction: () => handleGetInteraction,
|
|
226172
226575
|
handleGetLicense: () => handleGetLicense,
|
|
226173
226576
|
handleGetMemory: () => handleGetMemory,
|
|
226174
226577
|
handleGetMemoryStore: () => handleGetMemoryStore,
|
|
@@ -226205,6 +226608,7 @@ __export(handlers_exports, {
|
|
|
226205
226608
|
handleListEnvironments: () => handleListEnvironments,
|
|
226206
226609
|
handleListEvents: () => handleListEvents,
|
|
226207
226610
|
handleListFiles: () => handleListFiles,
|
|
226611
|
+
handleListGoogleAgents: () => handleListGoogleAgents,
|
|
226208
226612
|
handleListMemories: () => handleListMemories,
|
|
226209
226613
|
handleListMemoryStores: () => handleListMemoryStores,
|
|
226210
226614
|
handleListMemoryVersions: () => handleListMemoryVersions,
|
|
@@ -226253,53 +226657,55 @@ __export(handlers_exports, {
|
|
|
226253
226657
|
var init_handlers3 = __esm({
|
|
226254
226658
|
"../agent-sdk/dist/handlers/index.js"() {
|
|
226255
226659
|
"use strict";
|
|
226256
|
-
|
|
226257
|
-
|
|
226258
|
-
|
|
226259
|
-
|
|
226660
|
+
init_chunk_RHSVYAI4();
|
|
226661
|
+
init_chunk_2HTAIROL();
|
|
226662
|
+
init_chunk_PULMO5OO();
|
|
226663
|
+
init_chunk_3CDJ2VQN();
|
|
226664
|
+
init_chunk_PUAK45BO();
|
|
226665
|
+
init_chunk_XLVZ5236();
|
|
226260
226666
|
init_chunk_DF34ESOO();
|
|
226261
|
-
|
|
226262
|
-
|
|
226263
|
-
|
|
226264
|
-
|
|
226667
|
+
init_chunk_5BIX3H2D();
|
|
226668
|
+
init_chunk_3IO3EGWP();
|
|
226669
|
+
init_chunk_4XB2CJPE();
|
|
226670
|
+
init_chunk_VWCIN45Y();
|
|
226265
226671
|
init_chunk_3XGUMXGR();
|
|
226266
|
-
|
|
226267
|
-
|
|
226268
|
-
|
|
226269
|
-
|
|
226672
|
+
init_chunk_FH2IOAQM();
|
|
226673
|
+
init_chunk_2YZUXJAN();
|
|
226674
|
+
init_chunk_W3DA3OFL();
|
|
226675
|
+
init_chunk_VIWYYVGR();
|
|
226270
226676
|
init_chunk_UTGP4X74();
|
|
226271
|
-
|
|
226272
|
-
|
|
226273
|
-
|
|
226274
|
-
|
|
226275
|
-
|
|
226276
|
-
|
|
226277
|
-
|
|
226677
|
+
init_chunk_NG6NUC3W();
|
|
226678
|
+
init_chunk_R7MZNZNC();
|
|
226679
|
+
init_chunk_DQIQBMC2();
|
|
226680
|
+
init_chunk_R6NWAM37();
|
|
226681
|
+
init_chunk_VCU64NHY();
|
|
226682
|
+
init_chunk_52K3LOFD();
|
|
226683
|
+
init_chunk_2E43SH4Y();
|
|
226278
226684
|
init_chunk_F27XQZ2O();
|
|
226279
|
-
|
|
226280
|
-
|
|
226281
|
-
|
|
226685
|
+
init_chunk_TBLHBMA5();
|
|
226686
|
+
init_chunk_SP26BYYZ();
|
|
226687
|
+
init_chunk_OMGJEZJS();
|
|
226282
226688
|
init_chunk_HWWFRSAX();
|
|
226283
|
-
|
|
226284
|
-
|
|
226285
|
-
|
|
226689
|
+
init_chunk_JFIJEF4N();
|
|
226690
|
+
init_chunk_L2ZB7TCF();
|
|
226691
|
+
init_chunk_ZPTYXWUO();
|
|
226286
226692
|
init_chunk_STPT3SWU();
|
|
226287
|
-
|
|
226288
|
-
|
|
226289
|
-
|
|
226290
|
-
|
|
226291
|
-
|
|
226292
|
-
|
|
226693
|
+
init_chunk_BVBVWMQS();
|
|
226694
|
+
init_chunk_3WPVSQGI();
|
|
226695
|
+
init_chunk_MG2DS6QE();
|
|
226696
|
+
init_chunk_3RK6EX7J();
|
|
226697
|
+
init_chunk_L7X2UMNJ();
|
|
226698
|
+
init_chunk_NO77URFL();
|
|
226293
226699
|
init_chunk_Z5IENUYV();
|
|
226294
226700
|
init_chunk_UMXXZ6OX();
|
|
226295
226701
|
init_chunk_ABUNDZCE();
|
|
226296
226702
|
init_chunk_TTDMQ54U();
|
|
226297
226703
|
init_chunk_ZBWKJ42J();
|
|
226298
|
-
|
|
226704
|
+
init_chunk_LJ2ZXLLT();
|
|
226299
226705
|
init_chunk_23UKWXJH();
|
|
226300
226706
|
init_chunk_ZBFU37UL();
|
|
226301
|
-
|
|
226302
|
-
|
|
226707
|
+
init_chunk_CNMMJFJI();
|
|
226708
|
+
init_chunk_EOUNXIPM();
|
|
226303
226709
|
init_chunk_7346CKTF();
|
|
226304
226710
|
init_chunk_DC2UMEQH();
|
|
226305
226711
|
init_chunk_IC2ETYU5();
|
|
@@ -226310,14 +226716,14 @@ var init_handlers3 = __esm({
|
|
|
226310
226716
|
init_chunk_2N2KL4KM();
|
|
226311
226717
|
init_chunk_I2RVN7CP();
|
|
226312
226718
|
init_chunk_K5J4IN2S();
|
|
226313
|
-
|
|
226719
|
+
init_chunk_RMCBO7K7();
|
|
226314
226720
|
init_chunk_D2XITRN6();
|
|
226315
226721
|
init_chunk_CWB2DQN5();
|
|
226316
226722
|
init_chunk_JFHYXFAL();
|
|
226317
226723
|
init_chunk_W6WKXFHN();
|
|
226318
226724
|
init_chunk_HVUWXUUI();
|
|
226319
|
-
|
|
226320
|
-
|
|
226725
|
+
init_chunk_ZDURV2LI();
|
|
226726
|
+
init_chunk_YAJJ7KHX();
|
|
226321
226727
|
init_chunk_PJZ5TQYW();
|
|
226322
226728
|
init_chunk_AU4NAQGA();
|
|
226323
226729
|
init_chunk_H6TQGV4L();
|
|
@@ -226332,10 +226738,10 @@ var init_handlers3 = __esm({
|
|
|
226332
226738
|
init_chunk_WK33IBKY();
|
|
226333
226739
|
init_chunk_3NUTTKE5();
|
|
226334
226740
|
init_chunk_3MQ2FWXS();
|
|
226335
|
-
|
|
226336
|
-
|
|
226741
|
+
init_chunk_HGV3Y4PS();
|
|
226742
|
+
init_chunk_AE7UG76I();
|
|
226337
226743
|
init_chunk_LAWTTG2E();
|
|
226338
|
-
|
|
226744
|
+
init_chunk_IL2CZHNC();
|
|
226339
226745
|
init_chunk_4XXQAVKE();
|
|
226340
226746
|
init_chunk_JNSJKHYX();
|
|
226341
226747
|
init_chunk_5ZFOKZGR();
|
|
@@ -226353,7 +226759,7 @@ var init_handlers3 = __esm({
|
|
|
226353
226759
|
init_chunk_G7KUVNDY();
|
|
226354
226760
|
init_chunk_6U6HEVSN();
|
|
226355
226761
|
init_chunk_YTBVILAH();
|
|
226356
|
-
|
|
226762
|
+
init_chunk_V5RHOS43();
|
|
226357
226763
|
init_chunk_J7F2OFWQ();
|
|
226358
226764
|
init_chunk_B6E6BVNK();
|
|
226359
226765
|
init_chunk_6SD6MC2B();
|
|
@@ -226372,25 +226778,25 @@ var init_handlers3 = __esm({
|
|
|
226372
226778
|
init_chunk_UY3VT3HQ();
|
|
226373
226779
|
init_chunk_PDWLVL34();
|
|
226374
226780
|
init_chunk_QCGIYXN4();
|
|
226375
|
-
|
|
226376
|
-
init_chunk_YJCH35J4();
|
|
226377
|
-
init_chunk_CY6AWCC6();
|
|
226378
|
-
init_chunk_VRRGSQI7();
|
|
226379
|
-
init_chunk_D6RQPBRG();
|
|
226380
|
-
init_chunk_IBYOMAZ3();
|
|
226381
|
-
init_chunk_5PS6KN3J();
|
|
226781
|
+
init_chunk_65XY7HRS();
|
|
226382
226782
|
init_chunk_TPMZO6S2();
|
|
226383
226783
|
init_chunk_M72ERPMT();
|
|
226384
226784
|
init_chunk_AQHYCRTO();
|
|
226385
|
-
init_chunk_KJ2GJLPQ();
|
|
226386
226785
|
init_chunk_7TSTCMII();
|
|
226387
|
-
|
|
226786
|
+
init_chunk_KJ2GJLPQ();
|
|
226787
|
+
init_chunk_IBYOMAZ3();
|
|
226788
|
+
init_chunk_WEUPM3IN();
|
|
226789
|
+
init_chunk_PJYCPDV5();
|
|
226790
|
+
init_chunk_SIO4LO2M();
|
|
226388
226791
|
init_chunk_NMZMRH3E();
|
|
226389
|
-
init_chunk_CULYZ3VA();
|
|
226390
226792
|
init_chunk_XJYR5HE3();
|
|
226793
|
+
init_chunk_CULYZ3VA();
|
|
226794
|
+
init_chunk_JN3DHH7Z();
|
|
226795
|
+
init_chunk_VRRGSQI7();
|
|
226796
|
+
init_chunk_D6RQPBRG();
|
|
226797
|
+
init_chunk_YJCH35J4();
|
|
226391
226798
|
init_chunk_YE2RMJY7();
|
|
226392
|
-
|
|
226393
|
-
init_chunk_SIO4LO2M();
|
|
226799
|
+
init_chunk_CY6AWCC6();
|
|
226394
226800
|
init_chunk_FX2AEKOV();
|
|
226395
226801
|
init_chunk_J6T3W6RY();
|
|
226396
226802
|
init_chunk_F4WUVOLE();
|
|
@@ -241006,6 +241412,14 @@ var init_src = __esm({
|
|
|
241006
241412
|
await next();
|
|
241007
241413
|
});
|
|
241008
241414
|
app.post("/google/v1beta/interactions", (c2) => handleCreateInteraction(c2.req.raw));
|
|
241415
|
+
app.get("/google/v1beta/interactions/:id", (c2) => handleGetInteraction(c2.req.raw, c2.req.param("id")));
|
|
241416
|
+
app.delete("/google/v1beta/interactions/:id", (c2) => handleDeleteInteraction(c2.req.raw, c2.req.param("id")));
|
|
241417
|
+
app.post("/google/v1beta/interactions/:id/cancel", (c2) => handleCancelInteraction(c2.req.raw, c2.req.param("id")));
|
|
241418
|
+
app.post("/google/v1beta/agents", (c2) => handleCreateGoogleAgent(c2.req.raw));
|
|
241419
|
+
app.get("/google/v1beta/agents", (c2) => handleListGoogleAgents(c2.req.raw));
|
|
241420
|
+
app.get("/google/v1beta/agents/:id", (c2) => handleGetGoogleAgent(c2.req.raw, c2.req.param("id")));
|
|
241421
|
+
app.delete("/google/v1beta/agents/:id", (c2) => handleDeleteGoogleAgent(c2.req.raw, c2.req.param("id")));
|
|
241422
|
+
app.get("/google/v1beta/files/:fileRef", (c2) => handleGetEnvironmentFiles(c2.req.raw, c2.req.param("fileRef")));
|
|
241009
241423
|
app.get("*", (c2) => {
|
|
241010
241424
|
const path13 = c2.req.path;
|
|
241011
241425
|
if (path13 === "/v1" || path13.startsWith("/v1/") || path13 === "/api" || path13.startsWith("/api/")) {
|