@agentstep/gateway 0.5.34 → 0.5.35
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 +1690 -1292
- 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();
|
|
@@ -154917,7 +154917,7 @@ var init_memory = __esm({
|
|
|
154917
154917
|
}
|
|
154918
154918
|
});
|
|
154919
154919
|
|
|
154920
|
-
// ../agent-sdk/dist/chunk-
|
|
154920
|
+
// ../agent-sdk/dist/chunk-ZCCHLDLC.js
|
|
154921
154921
|
function wrapProviderWithSecrets(provider, secrets) {
|
|
154922
154922
|
if (!secrets || Object.keys(secrets).length === 0) return provider;
|
|
154923
154923
|
return {
|
|
@@ -155486,8 +155486,8 @@ async function reconcileDockerOrphanSandboxes() {
|
|
|
155486
155486
|
return { deleted, kept };
|
|
155487
155487
|
}
|
|
155488
155488
|
var import_ulid2, lcLog, SANDBOX_NAME_PREFIX;
|
|
155489
|
-
var
|
|
155490
|
-
"../agent-sdk/dist/chunk-
|
|
155489
|
+
var init_chunk_ZCCHLDLC = __esm({
|
|
155490
|
+
"../agent-sdk/dist/chunk-ZCCHLDLC.js"() {
|
|
155491
155491
|
"use strict";
|
|
155492
155492
|
init_chunk_4XXQAVKE();
|
|
155493
155493
|
init_chunk_JNSJKHYX();
|
|
@@ -155499,7 +155499,7 @@ var init_chunk_3YWYIVEQ = __esm({
|
|
|
155499
155499
|
init_chunk_NSUVDKNC();
|
|
155500
155500
|
init_chunk_G7KUVNDY();
|
|
155501
155501
|
init_chunk_6U6HEVSN();
|
|
155502
|
-
|
|
155502
|
+
init_chunk_V5RHOS43();
|
|
155503
155503
|
init_chunk_6EIONZ7F();
|
|
155504
155504
|
init_chunk_HFDLUBWN();
|
|
155505
155505
|
init_chunk_EZYKRG4W();
|
|
@@ -156628,7 +156628,7 @@ var init_threads = __esm({
|
|
|
156628
156628
|
"../agent-sdk/dist/sessions/threads.js"() {
|
|
156629
156629
|
"use strict";
|
|
156630
156630
|
init_chunk_Z5IENUYV();
|
|
156631
|
-
|
|
156631
|
+
init_chunk_KYKVHH7I();
|
|
156632
156632
|
init_chunk_PJZ5TQYW();
|
|
156633
156633
|
init_chunk_AU4NAQGA();
|
|
156634
156634
|
init_chunk_H6TQGV4L();
|
|
@@ -156639,7 +156639,7 @@ var init_threads = __esm({
|
|
|
156639
156639
|
init_chunk_DZKBUOYU();
|
|
156640
156640
|
init_chunk_WK33IBKY();
|
|
156641
156641
|
init_chunk_LAWTTG2E();
|
|
156642
|
-
|
|
156642
|
+
init_chunk_ZCCHLDLC();
|
|
156643
156643
|
init_chunk_4XXQAVKE();
|
|
156644
156644
|
init_chunk_JNSJKHYX();
|
|
156645
156645
|
init_chunk_5ZFOKZGR();
|
|
@@ -156657,7 +156657,7 @@ var init_threads = __esm({
|
|
|
156657
156657
|
init_chunk_G7KUVNDY();
|
|
156658
156658
|
init_chunk_6U6HEVSN();
|
|
156659
156659
|
init_chunk_YTBVILAH();
|
|
156660
|
-
|
|
156660
|
+
init_chunk_V5RHOS43();
|
|
156661
156661
|
init_chunk_J7F2OFWQ();
|
|
156662
156662
|
init_chunk_B6E6BVNK();
|
|
156663
156663
|
init_chunk_6SD6MC2B();
|
|
@@ -156676,25 +156676,25 @@ var init_threads = __esm({
|
|
|
156676
156676
|
init_chunk_UY3VT3HQ();
|
|
156677
156677
|
init_chunk_PDWLVL34();
|
|
156678
156678
|
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();
|
|
156679
|
+
init_chunk_65XY7HRS();
|
|
156686
156680
|
init_chunk_TPMZO6S2();
|
|
156687
156681
|
init_chunk_M72ERPMT();
|
|
156688
156682
|
init_chunk_AQHYCRTO();
|
|
156689
|
-
init_chunk_KJ2GJLPQ();
|
|
156690
156683
|
init_chunk_7TSTCMII();
|
|
156691
|
-
|
|
156684
|
+
init_chunk_KJ2GJLPQ();
|
|
156685
|
+
init_chunk_IBYOMAZ3();
|
|
156686
|
+
init_chunk_WEUPM3IN();
|
|
156687
|
+
init_chunk_PJYCPDV5();
|
|
156688
|
+
init_chunk_SIO4LO2M();
|
|
156692
156689
|
init_chunk_NMZMRH3E();
|
|
156693
|
-
init_chunk_CULYZ3VA();
|
|
156694
156690
|
init_chunk_XJYR5HE3();
|
|
156691
|
+
init_chunk_CULYZ3VA();
|
|
156692
|
+
init_chunk_JN3DHH7Z();
|
|
156693
|
+
init_chunk_VRRGSQI7();
|
|
156694
|
+
init_chunk_D6RQPBRG();
|
|
156695
|
+
init_chunk_YJCH35J4();
|
|
156695
156696
|
init_chunk_YE2RMJY7();
|
|
156696
|
-
|
|
156697
|
-
init_chunk_SIO4LO2M();
|
|
156697
|
+
init_chunk_CY6AWCC6();
|
|
156698
156698
|
init_chunk_FX2AEKOV();
|
|
156699
156699
|
init_chunk_J6T3W6RY();
|
|
156700
156700
|
init_chunk_F4WUVOLE();
|
|
@@ -156713,7 +156713,7 @@ var init_threads = __esm({
|
|
|
156713
156713
|
}
|
|
156714
156714
|
});
|
|
156715
156715
|
|
|
156716
|
-
// ../agent-sdk/dist/chunk-
|
|
156716
|
+
// ../agent-sdk/dist/chunk-KYKVHH7I.js
|
|
156717
156717
|
function formatStopReason(reason, eventIds) {
|
|
156718
156718
|
if (reason === "custom_tool_call") {
|
|
156719
156719
|
return { type: "requires_action", event_ids: eventIds ?? [] };
|
|
@@ -157619,8 +157619,8 @@ async function writeToolBridgeResponse(sessionId, content) {
|
|
|
157619
157619
|
pendingToolBridgeCalls.delete(sessionId);
|
|
157620
157620
|
}
|
|
157621
157621
|
var gd, pendingToolBridgeCalls, customToolCallCounts, MAX_CUSTOM_TOOL_CALLS_PER_TURN;
|
|
157622
|
-
var
|
|
157623
|
-
"../agent-sdk/dist/chunk-
|
|
157622
|
+
var init_chunk_KYKVHH7I = __esm({
|
|
157623
|
+
"../agent-sdk/dist/chunk-KYKVHH7I.js"() {
|
|
157624
157624
|
"use strict";
|
|
157625
157625
|
init_chunk_PJZ5TQYW();
|
|
157626
157626
|
init_chunk_AU4NAQGA();
|
|
@@ -157629,7 +157629,7 @@ var init_chunk_PEZ5ZZBR = __esm({
|
|
|
157629
157629
|
init_chunk_72BKGVBE();
|
|
157630
157630
|
init_chunk_VB6GGRIA();
|
|
157631
157631
|
init_chunk_DZKBUOYU();
|
|
157632
|
-
|
|
157632
|
+
init_chunk_ZCCHLDLC();
|
|
157633
157633
|
init_chunk_JNSJKHYX();
|
|
157634
157634
|
init_chunk_RES4BCTF();
|
|
157635
157635
|
init_chunk_ZC7OR65K();
|
|
@@ -157638,9 +157638,9 @@ var init_chunk_PEZ5ZZBR = __esm({
|
|
|
157638
157638
|
init_chunk_XLMNSDUJ();
|
|
157639
157639
|
init_chunk_NSUVDKNC();
|
|
157640
157640
|
init_chunk_6U6HEVSN();
|
|
157641
|
-
|
|
157642
|
-
init_chunk_CY6AWCC6();
|
|
157641
|
+
init_chunk_V5RHOS43();
|
|
157643
157642
|
init_chunk_VRRGSQI7();
|
|
157643
|
+
init_chunk_CY6AWCC6();
|
|
157644
157644
|
init_chunk_FX2AEKOV();
|
|
157645
157645
|
init_chunk_6EIONZ7F();
|
|
157646
157646
|
init_chunk_HFDLUBWN();
|
|
@@ -157655,7 +157655,7 @@ var init_chunk_PEZ5ZZBR = __esm({
|
|
|
157655
157655
|
}
|
|
157656
157656
|
});
|
|
157657
157657
|
|
|
157658
|
-
// ../agent-sdk/dist/chunk-
|
|
157658
|
+
// ../agent-sdk/dist/chunk-GABMXDZZ.js
|
|
157659
157659
|
async function startWorker(opts) {
|
|
157660
157660
|
const pollInterval = opts.pollIntervalMs ?? 5e3;
|
|
157661
157661
|
const workerId = opts.workerId ?? `worker-${process.pid}`;
|
|
@@ -157705,11 +157705,11 @@ async function startWorker(opts) {
|
|
|
157705
157705
|
}
|
|
157706
157706
|
console.log("[worker] stopped");
|
|
157707
157707
|
}
|
|
157708
|
-
var
|
|
157709
|
-
"../agent-sdk/dist/chunk-
|
|
157708
|
+
var init_chunk_GABMXDZZ = __esm({
|
|
157709
|
+
"../agent-sdk/dist/chunk-GABMXDZZ.js"() {
|
|
157710
157710
|
"use strict";
|
|
157711
157711
|
init_chunk_JF777FWD();
|
|
157712
|
-
|
|
157712
|
+
init_chunk_KYKVHH7I();
|
|
157713
157713
|
}
|
|
157714
157714
|
});
|
|
157715
157715
|
|
|
@@ -215475,7 +215475,7 @@ var init_chunk_3MQ2FWXS = __esm({
|
|
|
215475
215475
|
}
|
|
215476
215476
|
});
|
|
215477
215477
|
|
|
215478
|
-
// ../agent-sdk/dist/chunk-
|
|
215478
|
+
// ../agent-sdk/dist/chunk-K3LM6O44.js
|
|
215479
215479
|
function markStopping() {
|
|
215480
215480
|
stopping = true;
|
|
215481
215481
|
}
|
|
@@ -215564,11 +215564,11 @@ async function evictIdleSessions() {
|
|
|
215564
215564
|
}
|
|
215565
215565
|
}
|
|
215566
215566
|
var sweeping, stopping;
|
|
215567
|
-
var
|
|
215568
|
-
"../agent-sdk/dist/chunk-
|
|
215567
|
+
var init_chunk_K3LM6O44 = __esm({
|
|
215568
|
+
"../agent-sdk/dist/chunk-K3LM6O44.js"() {
|
|
215569
215569
|
"use strict";
|
|
215570
215570
|
init_chunk_LAWTTG2E();
|
|
215571
|
-
|
|
215571
|
+
init_chunk_ZCCHLDLC();
|
|
215572
215572
|
init_chunk_RES4BCTF();
|
|
215573
215573
|
init_chunk_ZC7OR65K();
|
|
215574
215574
|
init_chunk_XLMNSDUJ();
|
|
@@ -215583,7 +215583,7 @@ var init_chunk_OBKTX34F = __esm({
|
|
|
215583
215583
|
}
|
|
215584
215584
|
});
|
|
215585
215585
|
|
|
215586
|
-
// ../agent-sdk/dist/chunk-
|
|
215586
|
+
// ../agent-sdk/dist/chunk-ZACPJA3G.js
|
|
215587
215587
|
function installShutdownHandlers() {
|
|
215588
215588
|
if (g13.__caShutdownInstalled) return;
|
|
215589
215589
|
g13.__caShutdownInstalled = true;
|
|
@@ -215626,10 +215626,10 @@ async function shutdown(signal) {
|
|
|
215626
215626
|
process.exit(0);
|
|
215627
215627
|
}
|
|
215628
215628
|
var g13, shuttingDown;
|
|
215629
|
-
var
|
|
215630
|
-
"../agent-sdk/dist/chunk-
|
|
215629
|
+
var init_chunk_ZACPJA3G = __esm({
|
|
215630
|
+
"../agent-sdk/dist/chunk-ZACPJA3G.js"() {
|
|
215631
215631
|
"use strict";
|
|
215632
|
-
|
|
215632
|
+
init_chunk_K3LM6O44();
|
|
215633
215633
|
init_chunk_AGIXZFHQ();
|
|
215634
215634
|
init_chunk_UYTSKFGK();
|
|
215635
215635
|
init_client();
|
|
@@ -217737,7 +217737,7 @@ var init_rate_limit = __esm({
|
|
|
217737
217737
|
}
|
|
217738
217738
|
});
|
|
217739
217739
|
|
|
217740
|
-
// ../agent-sdk/dist/chunk-
|
|
217740
|
+
// ../agent-sdk/dist/chunk-P7V3S2T3.js
|
|
217741
217741
|
import path10 from "path";
|
|
217742
217742
|
async function ensureInitialized() {
|
|
217743
217743
|
if (g15.__caInitPromise) return g15.__caInitPromise;
|
|
@@ -217961,18 +217961,18 @@ async function rebuildContainerPool() {
|
|
|
217961
217961
|
}
|
|
217962
217962
|
}
|
|
217963
217963
|
var g15;
|
|
217964
|
-
var
|
|
217965
|
-
"../agent-sdk/dist/chunk-
|
|
217964
|
+
var init_chunk_P7V3S2T3 = __esm({
|
|
217965
|
+
"../agent-sdk/dist/chunk-P7V3S2T3.js"() {
|
|
217966
217966
|
"use strict";
|
|
217967
|
-
|
|
217967
|
+
init_chunk_KYKVHH7I();
|
|
217968
217968
|
init_chunk_B3W3E5CS();
|
|
217969
217969
|
init_chunk_J6ESQUW6();
|
|
217970
217970
|
init_chunk_2KF2TIEY();
|
|
217971
217971
|
init_chunk_3NUTTKE5();
|
|
217972
217972
|
init_chunk_3MQ2FWXS();
|
|
217973
|
-
|
|
217974
|
-
|
|
217975
|
-
|
|
217973
|
+
init_chunk_ZACPJA3G();
|
|
217974
|
+
init_chunk_K3LM6O44();
|
|
217975
|
+
init_chunk_ZCCHLDLC();
|
|
217976
217976
|
init_chunk_RES4BCTF();
|
|
217977
217977
|
init_chunk_ZC7OR65K();
|
|
217978
217978
|
init_chunk_YPXI7Q2M();
|
|
@@ -217990,7 +217990,7 @@ var init_chunk_PLPCYY7I = __esm({
|
|
|
217990
217990
|
}
|
|
217991
217991
|
});
|
|
217992
217992
|
|
|
217993
|
-
// ../agent-sdk/dist/chunk-
|
|
217993
|
+
// ../agent-sdk/dist/chunk-4EKHW6VS.js
|
|
217994
217994
|
async function routeWrap(request2, handler) {
|
|
217995
217995
|
const startedAt = Date.now();
|
|
217996
217996
|
let status = 500;
|
|
@@ -218047,13 +218047,13 @@ function decodeCursor(page) {
|
|
|
218047
218047
|
return void 0;
|
|
218048
218048
|
}
|
|
218049
218049
|
}
|
|
218050
|
-
var
|
|
218051
|
-
"../agent-sdk/dist/chunk-
|
|
218050
|
+
var init_chunk_4EKHW6VS = __esm({
|
|
218051
|
+
"../agent-sdk/dist/chunk-4EKHW6VS.js"() {
|
|
218052
218052
|
"use strict";
|
|
218053
218053
|
init_chunk_D2XITRN6();
|
|
218054
218054
|
init_chunk_CWB2DQN5();
|
|
218055
218055
|
init_chunk_HVUWXUUI();
|
|
218056
|
-
|
|
218056
|
+
init_chunk_P7V3S2T3();
|
|
218057
218057
|
init_chunk_3MQ2FWXS();
|
|
218058
218058
|
init_chunk_EZYKRG4W();
|
|
218059
218059
|
}
|
|
@@ -218179,7 +218179,7 @@ var init_dist2 = __esm({
|
|
|
218179
218179
|
"../agent-sdk/dist/index.js"() {
|
|
218180
218180
|
"use strict";
|
|
218181
218181
|
init_chunk_VFSOYCGN();
|
|
218182
|
-
|
|
218182
|
+
init_chunk_GABMXDZZ();
|
|
218183
218183
|
init_chunk_PWLWDWRL();
|
|
218184
218184
|
init_chunk_SAI6LBXW();
|
|
218185
218185
|
init_chunk_7346CKTF();
|
|
@@ -218192,14 +218192,14 @@ var init_dist2 = __esm({
|
|
|
218192
218192
|
init_chunk_2N2KL4KM();
|
|
218193
218193
|
init_chunk_I2RVN7CP();
|
|
218194
218194
|
init_chunk_K5J4IN2S();
|
|
218195
|
-
|
|
218195
|
+
init_chunk_4EKHW6VS();
|
|
218196
218196
|
init_chunk_D2XITRN6();
|
|
218197
218197
|
init_chunk_CWB2DQN5();
|
|
218198
218198
|
init_chunk_JFHYXFAL();
|
|
218199
218199
|
init_chunk_W6WKXFHN();
|
|
218200
218200
|
init_chunk_HVUWXUUI();
|
|
218201
|
-
|
|
218202
|
-
|
|
218201
|
+
init_chunk_P7V3S2T3();
|
|
218202
|
+
init_chunk_KYKVHH7I();
|
|
218203
218203
|
init_chunk_PJZ5TQYW();
|
|
218204
218204
|
init_chunk_AU4NAQGA();
|
|
218205
218205
|
init_chunk_H6TQGV4L();
|
|
@@ -218214,10 +218214,10 @@ var init_dist2 = __esm({
|
|
|
218214
218214
|
init_chunk_WK33IBKY();
|
|
218215
218215
|
init_chunk_3NUTTKE5();
|
|
218216
218216
|
init_chunk_3MQ2FWXS();
|
|
218217
|
-
|
|
218218
|
-
|
|
218217
|
+
init_chunk_ZACPJA3G();
|
|
218218
|
+
init_chunk_K3LM6O44();
|
|
218219
218219
|
init_chunk_LAWTTG2E();
|
|
218220
|
-
|
|
218220
|
+
init_chunk_ZCCHLDLC();
|
|
218221
218221
|
init_chunk_4XXQAVKE();
|
|
218222
218222
|
init_chunk_JNSJKHYX();
|
|
218223
218223
|
init_chunk_5ZFOKZGR();
|
|
@@ -218235,7 +218235,7 @@ var init_dist2 = __esm({
|
|
|
218235
218235
|
init_chunk_G7KUVNDY();
|
|
218236
218236
|
init_chunk_6U6HEVSN();
|
|
218237
218237
|
init_chunk_YTBVILAH();
|
|
218238
|
-
|
|
218238
|
+
init_chunk_V5RHOS43();
|
|
218239
218239
|
init_chunk_J7F2OFWQ();
|
|
218240
218240
|
init_chunk_B6E6BVNK();
|
|
218241
218241
|
init_chunk_6SD6MC2B();
|
|
@@ -218254,25 +218254,25 @@ var init_dist2 = __esm({
|
|
|
218254
218254
|
init_chunk_UY3VT3HQ();
|
|
218255
218255
|
init_chunk_PDWLVL34();
|
|
218256
218256
|
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();
|
|
218257
|
+
init_chunk_65XY7HRS();
|
|
218264
218258
|
init_chunk_TPMZO6S2();
|
|
218265
218259
|
init_chunk_M72ERPMT();
|
|
218266
218260
|
init_chunk_AQHYCRTO();
|
|
218267
|
-
init_chunk_KJ2GJLPQ();
|
|
218268
218261
|
init_chunk_7TSTCMII();
|
|
218269
|
-
|
|
218262
|
+
init_chunk_KJ2GJLPQ();
|
|
218263
|
+
init_chunk_IBYOMAZ3();
|
|
218264
|
+
init_chunk_WEUPM3IN();
|
|
218265
|
+
init_chunk_PJYCPDV5();
|
|
218266
|
+
init_chunk_SIO4LO2M();
|
|
218270
218267
|
init_chunk_NMZMRH3E();
|
|
218271
|
-
init_chunk_CULYZ3VA();
|
|
218272
218268
|
init_chunk_XJYR5HE3();
|
|
218269
|
+
init_chunk_CULYZ3VA();
|
|
218270
|
+
init_chunk_JN3DHH7Z();
|
|
218271
|
+
init_chunk_VRRGSQI7();
|
|
218272
|
+
init_chunk_D6RQPBRG();
|
|
218273
|
+
init_chunk_YJCH35J4();
|
|
218273
218274
|
init_chunk_YE2RMJY7();
|
|
218274
|
-
|
|
218275
|
-
init_chunk_SIO4LO2M();
|
|
218275
|
+
init_chunk_CY6AWCC6();
|
|
218276
218276
|
init_chunk_FX2AEKOV();
|
|
218277
218277
|
init_chunk_J6T3W6RY();
|
|
218278
218278
|
init_chunk_F4WUVOLE();
|
|
@@ -218554,7 +218554,7 @@ var init_models = __esm({
|
|
|
218554
218554
|
}
|
|
218555
218555
|
});
|
|
218556
218556
|
|
|
218557
|
-
// ../agent-sdk/dist/chunk-
|
|
218557
|
+
// ../agent-sdk/dist/chunk-NQ6BN7WH.js
|
|
218558
218558
|
function getAgentTenantId(id) {
|
|
218559
218559
|
const row = getDb().prepare(`SELECT tenant_id FROM agents WHERE id = ?`).get(id);
|
|
218560
218560
|
return row?.tenant_id;
|
|
@@ -218882,15 +218882,15 @@ function handleListAgentVersions(request2, id) {
|
|
|
218882
218882
|
});
|
|
218883
218883
|
}
|
|
218884
218884
|
var InlineSkillSchema, RefSkillSchema, SkillSchema, ToolSchema, ModelConfigSchema2, TEXT_EXTENSIONS, CreateSchema, UpdateSchema;
|
|
218885
|
-
var
|
|
218886
|
-
"../agent-sdk/dist/chunk-
|
|
218885
|
+
var init_chunk_NQ6BN7WH = __esm({
|
|
218886
|
+
"../agent-sdk/dist/chunk-NQ6BN7WH.js"() {
|
|
218887
218887
|
"use strict";
|
|
218888
218888
|
init_chunk_23UKWXJH();
|
|
218889
|
-
|
|
218889
|
+
init_chunk_4EKHW6VS();
|
|
218890
218890
|
init_chunk_JFHYXFAL();
|
|
218891
218891
|
init_chunk_DZKBUOYU();
|
|
218892
218892
|
init_chunk_6U6HEVSN();
|
|
218893
|
-
|
|
218893
|
+
init_chunk_V5RHOS43();
|
|
218894
218894
|
init_chunk_AGIXZFHQ();
|
|
218895
218895
|
init_chunk_EZYKRG4W();
|
|
218896
218896
|
init_zod();
|
|
@@ -219072,16 +219072,16 @@ __export(agents_exports, {
|
|
|
219072
219072
|
var init_agents = __esm({
|
|
219073
219073
|
"../agent-sdk/dist/handlers/agents.js"() {
|
|
219074
219074
|
"use strict";
|
|
219075
|
-
|
|
219075
|
+
init_chunk_NQ6BN7WH();
|
|
219076
219076
|
init_chunk_23UKWXJH();
|
|
219077
|
-
|
|
219077
|
+
init_chunk_4EKHW6VS();
|
|
219078
219078
|
init_chunk_D2XITRN6();
|
|
219079
219079
|
init_chunk_CWB2DQN5();
|
|
219080
219080
|
init_chunk_JFHYXFAL();
|
|
219081
219081
|
init_chunk_W6WKXFHN();
|
|
219082
219082
|
init_chunk_HVUWXUUI();
|
|
219083
|
-
|
|
219084
|
-
|
|
219083
|
+
init_chunk_P7V3S2T3();
|
|
219084
|
+
init_chunk_KYKVHH7I();
|
|
219085
219085
|
init_chunk_PJZ5TQYW();
|
|
219086
219086
|
init_chunk_AU4NAQGA();
|
|
219087
219087
|
init_chunk_H6TQGV4L();
|
|
@@ -219096,10 +219096,10 @@ var init_agents = __esm({
|
|
|
219096
219096
|
init_chunk_WK33IBKY();
|
|
219097
219097
|
init_chunk_3NUTTKE5();
|
|
219098
219098
|
init_chunk_3MQ2FWXS();
|
|
219099
|
-
|
|
219100
|
-
|
|
219099
|
+
init_chunk_ZACPJA3G();
|
|
219100
|
+
init_chunk_K3LM6O44();
|
|
219101
219101
|
init_chunk_LAWTTG2E();
|
|
219102
|
-
|
|
219102
|
+
init_chunk_ZCCHLDLC();
|
|
219103
219103
|
init_chunk_4XXQAVKE();
|
|
219104
219104
|
init_chunk_JNSJKHYX();
|
|
219105
219105
|
init_chunk_5ZFOKZGR();
|
|
@@ -219117,7 +219117,7 @@ var init_agents = __esm({
|
|
|
219117
219117
|
init_chunk_G7KUVNDY();
|
|
219118
219118
|
init_chunk_6U6HEVSN();
|
|
219119
219119
|
init_chunk_YTBVILAH();
|
|
219120
|
-
|
|
219120
|
+
init_chunk_V5RHOS43();
|
|
219121
219121
|
init_chunk_J7F2OFWQ();
|
|
219122
219122
|
init_chunk_B6E6BVNK();
|
|
219123
219123
|
init_chunk_6SD6MC2B();
|
|
@@ -219136,25 +219136,25 @@ var init_agents = __esm({
|
|
|
219136
219136
|
init_chunk_UY3VT3HQ();
|
|
219137
219137
|
init_chunk_PDWLVL34();
|
|
219138
219138
|
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();
|
|
219139
|
+
init_chunk_65XY7HRS();
|
|
219146
219140
|
init_chunk_TPMZO6S2();
|
|
219147
219141
|
init_chunk_M72ERPMT();
|
|
219148
219142
|
init_chunk_AQHYCRTO();
|
|
219149
|
-
init_chunk_KJ2GJLPQ();
|
|
219150
219143
|
init_chunk_7TSTCMII();
|
|
219151
|
-
|
|
219144
|
+
init_chunk_KJ2GJLPQ();
|
|
219145
|
+
init_chunk_IBYOMAZ3();
|
|
219146
|
+
init_chunk_WEUPM3IN();
|
|
219147
|
+
init_chunk_PJYCPDV5();
|
|
219148
|
+
init_chunk_SIO4LO2M();
|
|
219152
219149
|
init_chunk_NMZMRH3E();
|
|
219153
|
-
init_chunk_CULYZ3VA();
|
|
219154
219150
|
init_chunk_XJYR5HE3();
|
|
219151
|
+
init_chunk_CULYZ3VA();
|
|
219152
|
+
init_chunk_JN3DHH7Z();
|
|
219153
|
+
init_chunk_VRRGSQI7();
|
|
219154
|
+
init_chunk_D6RQPBRG();
|
|
219155
|
+
init_chunk_YJCH35J4();
|
|
219155
219156
|
init_chunk_YE2RMJY7();
|
|
219156
|
-
|
|
219157
|
-
init_chunk_SIO4LO2M();
|
|
219157
|
+
init_chunk_CY6AWCC6();
|
|
219158
219158
|
init_chunk_FX2AEKOV();
|
|
219159
219159
|
init_chunk_J6T3W6RY();
|
|
219160
219160
|
init_chunk_F4WUVOLE();
|
|
@@ -219484,7 +219484,7 @@ var init_vaults = __esm({
|
|
|
219484
219484
|
}
|
|
219485
219485
|
});
|
|
219486
219486
|
|
|
219487
|
-
// ../agent-sdk/dist/chunk-
|
|
219487
|
+
// ../agent-sdk/dist/chunk-BSAF4YJB.js
|
|
219488
219488
|
function getAgentTenantId2(id) {
|
|
219489
219489
|
const row = getDb().prepare(`SELECT tenant_id FROM agents WHERE id = ?`).get(id);
|
|
219490
219490
|
return row?.tenant_id;
|
|
@@ -219988,8 +219988,8 @@ function parseMs(v2) {
|
|
|
219988
219988
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
219989
219989
|
}
|
|
219990
219990
|
var ALLOWED_STATUSES, AgentRef, ResourceSchema, CreateSchema2, UpdateSchema2;
|
|
219991
|
-
var
|
|
219992
|
-
"../agent-sdk/dist/chunk-
|
|
219991
|
+
var init_chunk_BSAF4YJB = __esm({
|
|
219992
|
+
"../agent-sdk/dist/chunk-BSAF4YJB.js"() {
|
|
219993
219993
|
"use strict";
|
|
219994
219994
|
init_chunk_AUEKXYNE();
|
|
219995
219995
|
init_chunk_ZBWKJ42J();
|
|
@@ -219997,12 +219997,12 @@ var init_chunk_43Z4MHFG = __esm({
|
|
|
219997
219997
|
init_chunk_DC2UMEQH();
|
|
219998
219998
|
init_chunk_TVV7AE3G();
|
|
219999
219999
|
init_chunk_K5J4IN2S();
|
|
220000
|
-
|
|
220000
|
+
init_chunk_4EKHW6VS();
|
|
220001
220001
|
init_chunk_JFHYXFAL();
|
|
220002
220002
|
init_chunk_H6TQGV4L();
|
|
220003
220003
|
init_chunk_DZKBUOYU();
|
|
220004
220004
|
init_chunk_LAWTTG2E();
|
|
220005
|
-
|
|
220005
|
+
init_chunk_ZCCHLDLC();
|
|
220006
220006
|
init_chunk_RES4BCTF();
|
|
220007
220007
|
init_chunk_ZC7OR65K();
|
|
220008
220008
|
init_chunk_NSUVDKNC();
|
|
@@ -220084,21 +220084,21 @@ __export(sessions_exports, {
|
|
|
220084
220084
|
var init_sessions = __esm({
|
|
220085
220085
|
"../agent-sdk/dist/handlers/sessions.js"() {
|
|
220086
220086
|
"use strict";
|
|
220087
|
-
|
|
220087
|
+
init_chunk_BSAF4YJB();
|
|
220088
220088
|
init_chunk_AUEKXYNE();
|
|
220089
220089
|
init_chunk_ZBWKJ42J();
|
|
220090
220090
|
init_chunk_23UKWXJH();
|
|
220091
220091
|
init_chunk_DC2UMEQH();
|
|
220092
220092
|
init_chunk_TVV7AE3G();
|
|
220093
220093
|
init_chunk_K5J4IN2S();
|
|
220094
|
-
|
|
220094
|
+
init_chunk_4EKHW6VS();
|
|
220095
220095
|
init_chunk_D2XITRN6();
|
|
220096
220096
|
init_chunk_CWB2DQN5();
|
|
220097
220097
|
init_chunk_JFHYXFAL();
|
|
220098
220098
|
init_chunk_W6WKXFHN();
|
|
220099
220099
|
init_chunk_HVUWXUUI();
|
|
220100
|
-
|
|
220101
|
-
|
|
220100
|
+
init_chunk_P7V3S2T3();
|
|
220101
|
+
init_chunk_KYKVHH7I();
|
|
220102
220102
|
init_chunk_PJZ5TQYW();
|
|
220103
220103
|
init_chunk_AU4NAQGA();
|
|
220104
220104
|
init_chunk_H6TQGV4L();
|
|
@@ -220113,10 +220113,10 @@ var init_sessions = __esm({
|
|
|
220113
220113
|
init_chunk_WK33IBKY();
|
|
220114
220114
|
init_chunk_3NUTTKE5();
|
|
220115
220115
|
init_chunk_3MQ2FWXS();
|
|
220116
|
-
|
|
220117
|
-
|
|
220116
|
+
init_chunk_ZACPJA3G();
|
|
220117
|
+
init_chunk_K3LM6O44();
|
|
220118
220118
|
init_chunk_LAWTTG2E();
|
|
220119
|
-
|
|
220119
|
+
init_chunk_ZCCHLDLC();
|
|
220120
220120
|
init_chunk_4XXQAVKE();
|
|
220121
220121
|
init_chunk_JNSJKHYX();
|
|
220122
220122
|
init_chunk_5ZFOKZGR();
|
|
@@ -220134,7 +220134,7 @@ var init_sessions = __esm({
|
|
|
220134
220134
|
init_chunk_G7KUVNDY();
|
|
220135
220135
|
init_chunk_6U6HEVSN();
|
|
220136
220136
|
init_chunk_YTBVILAH();
|
|
220137
|
-
|
|
220137
|
+
init_chunk_V5RHOS43();
|
|
220138
220138
|
init_chunk_J7F2OFWQ();
|
|
220139
220139
|
init_chunk_B6E6BVNK();
|
|
220140
220140
|
init_chunk_6SD6MC2B();
|
|
@@ -220153,25 +220153,25 @@ var init_sessions = __esm({
|
|
|
220153
220153
|
init_chunk_UY3VT3HQ();
|
|
220154
220154
|
init_chunk_PDWLVL34();
|
|
220155
220155
|
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();
|
|
220156
|
+
init_chunk_65XY7HRS();
|
|
220163
220157
|
init_chunk_TPMZO6S2();
|
|
220164
220158
|
init_chunk_M72ERPMT();
|
|
220165
220159
|
init_chunk_AQHYCRTO();
|
|
220166
|
-
init_chunk_KJ2GJLPQ();
|
|
220167
220160
|
init_chunk_7TSTCMII();
|
|
220168
|
-
|
|
220161
|
+
init_chunk_KJ2GJLPQ();
|
|
220162
|
+
init_chunk_IBYOMAZ3();
|
|
220163
|
+
init_chunk_WEUPM3IN();
|
|
220164
|
+
init_chunk_PJYCPDV5();
|
|
220165
|
+
init_chunk_SIO4LO2M();
|
|
220169
220166
|
init_chunk_NMZMRH3E();
|
|
220170
|
-
init_chunk_CULYZ3VA();
|
|
220171
220167
|
init_chunk_XJYR5HE3();
|
|
220168
|
+
init_chunk_CULYZ3VA();
|
|
220169
|
+
init_chunk_JN3DHH7Z();
|
|
220170
|
+
init_chunk_VRRGSQI7();
|
|
220171
|
+
init_chunk_D6RQPBRG();
|
|
220172
|
+
init_chunk_YJCH35J4();
|
|
220172
220173
|
init_chunk_YE2RMJY7();
|
|
220173
|
-
|
|
220174
|
-
init_chunk_SIO4LO2M();
|
|
220174
|
+
init_chunk_CY6AWCC6();
|
|
220175
220175
|
init_chunk_FX2AEKOV();
|
|
220176
220176
|
init_chunk_J6T3W6RY();
|
|
220177
220177
|
init_chunk_F4WUVOLE();
|
|
@@ -220200,7 +220200,7 @@ __export(driver_exports, {
|
|
|
220200
220200
|
var init_driver = __esm({
|
|
220201
220201
|
"../agent-sdk/dist/sessions/driver.js"() {
|
|
220202
220202
|
"use strict";
|
|
220203
|
-
|
|
220203
|
+
init_chunk_KYKVHH7I();
|
|
220204
220204
|
init_chunk_PJZ5TQYW();
|
|
220205
220205
|
init_chunk_AU4NAQGA();
|
|
220206
220206
|
init_chunk_H6TQGV4L();
|
|
@@ -220210,7 +220210,7 @@ var init_driver = __esm({
|
|
|
220210
220210
|
init_chunk_YOZ6WDP3();
|
|
220211
220211
|
init_chunk_DZKBUOYU();
|
|
220212
220212
|
init_chunk_WK33IBKY();
|
|
220213
|
-
|
|
220213
|
+
init_chunk_ZCCHLDLC();
|
|
220214
220214
|
init_chunk_4XXQAVKE();
|
|
220215
220215
|
init_chunk_JNSJKHYX();
|
|
220216
220216
|
init_chunk_5ZFOKZGR();
|
|
@@ -220228,7 +220228,7 @@ var init_driver = __esm({
|
|
|
220228
220228
|
init_chunk_G7KUVNDY();
|
|
220229
220229
|
init_chunk_6U6HEVSN();
|
|
220230
220230
|
init_chunk_YTBVILAH();
|
|
220231
|
-
|
|
220231
|
+
init_chunk_V5RHOS43();
|
|
220232
220232
|
init_chunk_J7F2OFWQ();
|
|
220233
220233
|
init_chunk_B6E6BVNK();
|
|
220234
220234
|
init_chunk_6SD6MC2B();
|
|
@@ -220247,25 +220247,25 @@ var init_driver = __esm({
|
|
|
220247
220247
|
init_chunk_UY3VT3HQ();
|
|
220248
220248
|
init_chunk_PDWLVL34();
|
|
220249
220249
|
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();
|
|
220250
|
+
init_chunk_65XY7HRS();
|
|
220257
220251
|
init_chunk_TPMZO6S2();
|
|
220258
220252
|
init_chunk_M72ERPMT();
|
|
220259
220253
|
init_chunk_AQHYCRTO();
|
|
220260
|
-
init_chunk_KJ2GJLPQ();
|
|
220261
220254
|
init_chunk_7TSTCMII();
|
|
220262
|
-
|
|
220255
|
+
init_chunk_KJ2GJLPQ();
|
|
220256
|
+
init_chunk_IBYOMAZ3();
|
|
220257
|
+
init_chunk_WEUPM3IN();
|
|
220258
|
+
init_chunk_PJYCPDV5();
|
|
220259
|
+
init_chunk_SIO4LO2M();
|
|
220263
220260
|
init_chunk_NMZMRH3E();
|
|
220264
|
-
init_chunk_CULYZ3VA();
|
|
220265
220261
|
init_chunk_XJYR5HE3();
|
|
220262
|
+
init_chunk_CULYZ3VA();
|
|
220263
|
+
init_chunk_JN3DHH7Z();
|
|
220264
|
+
init_chunk_VRRGSQI7();
|
|
220265
|
+
init_chunk_D6RQPBRG();
|
|
220266
|
+
init_chunk_YJCH35J4();
|
|
220266
220267
|
init_chunk_YE2RMJY7();
|
|
220267
|
-
|
|
220268
|
-
init_chunk_SIO4LO2M();
|
|
220268
|
+
init_chunk_CY6AWCC6();
|
|
220269
220269
|
init_chunk_FX2AEKOV();
|
|
220270
220270
|
init_chunk_J6T3W6RY();
|
|
220271
220271
|
init_chunk_F4WUVOLE();
|
|
@@ -220365,7 +220365,7 @@ var init_sessions2 = __esm({
|
|
|
220365
220365
|
}
|
|
220366
220366
|
});
|
|
220367
220367
|
|
|
220368
|
-
// ../agent-sdk/dist/chunk-
|
|
220368
|
+
// ../agent-sdk/dist/chunk-OEYLPPID.js
|
|
220369
220369
|
function assertSessionTenant(auth, sessionId) {
|
|
220370
220370
|
const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
|
|
220371
220371
|
if (row) {
|
|
@@ -220951,17 +220951,17 @@ function handleListEvents(request2, sessionId) {
|
|
|
220951
220951
|
});
|
|
220952
220952
|
}
|
|
220953
220953
|
var teeLog, activeTees, MAX_TEE_REENTRIES, TextBlock2, UserMessage, UserInterrupt, UserToolConfirmation, UserCustomToolResult, UserDefineOutcome, UserEvent, BatchSchema;
|
|
220954
|
-
var
|
|
220955
|
-
"../agent-sdk/dist/chunk-
|
|
220954
|
+
var init_chunk_OEYLPPID = __esm({
|
|
220955
|
+
"../agent-sdk/dist/chunk-OEYLPPID.js"() {
|
|
220956
220956
|
"use strict";
|
|
220957
220957
|
init_chunk_HWWFRSAX();
|
|
220958
220958
|
init_chunk_ZBWKJ42J();
|
|
220959
220959
|
init_chunk_23UKWXJH();
|
|
220960
220960
|
init_chunk_DC2UMEQH();
|
|
220961
220961
|
init_chunk_TVV7AE3G();
|
|
220962
|
-
|
|
220962
|
+
init_chunk_4EKHW6VS();
|
|
220963
220963
|
init_chunk_JFHYXFAL();
|
|
220964
|
-
|
|
220964
|
+
init_chunk_KYKVHH7I();
|
|
220965
220965
|
init_chunk_B3W3E5CS();
|
|
220966
220966
|
init_chunk_DZKBUOYU();
|
|
220967
220967
|
init_chunk_LAWTTG2E();
|
|
@@ -221034,21 +221034,21 @@ __export(events_exports, {
|
|
|
221034
221034
|
var init_events = __esm({
|
|
221035
221035
|
"../agent-sdk/dist/handlers/events.js"() {
|
|
221036
221036
|
"use strict";
|
|
221037
|
-
|
|
221037
|
+
init_chunk_OEYLPPID();
|
|
221038
221038
|
init_chunk_HWWFRSAX();
|
|
221039
221039
|
init_chunk_ABUNDZCE();
|
|
221040
221040
|
init_chunk_ZBWKJ42J();
|
|
221041
221041
|
init_chunk_23UKWXJH();
|
|
221042
221042
|
init_chunk_DC2UMEQH();
|
|
221043
221043
|
init_chunk_TVV7AE3G();
|
|
221044
|
-
|
|
221044
|
+
init_chunk_4EKHW6VS();
|
|
221045
221045
|
init_chunk_D2XITRN6();
|
|
221046
221046
|
init_chunk_CWB2DQN5();
|
|
221047
221047
|
init_chunk_JFHYXFAL();
|
|
221048
221048
|
init_chunk_W6WKXFHN();
|
|
221049
221049
|
init_chunk_HVUWXUUI();
|
|
221050
|
-
|
|
221051
|
-
|
|
221050
|
+
init_chunk_P7V3S2T3();
|
|
221051
|
+
init_chunk_KYKVHH7I();
|
|
221052
221052
|
init_chunk_PJZ5TQYW();
|
|
221053
221053
|
init_chunk_AU4NAQGA();
|
|
221054
221054
|
init_chunk_H6TQGV4L();
|
|
@@ -221063,10 +221063,10 @@ var init_events = __esm({
|
|
|
221063
221063
|
init_chunk_WK33IBKY();
|
|
221064
221064
|
init_chunk_3NUTTKE5();
|
|
221065
221065
|
init_chunk_3MQ2FWXS();
|
|
221066
|
-
|
|
221067
|
-
|
|
221066
|
+
init_chunk_ZACPJA3G();
|
|
221067
|
+
init_chunk_K3LM6O44();
|
|
221068
221068
|
init_chunk_LAWTTG2E();
|
|
221069
|
-
|
|
221069
|
+
init_chunk_ZCCHLDLC();
|
|
221070
221070
|
init_chunk_4XXQAVKE();
|
|
221071
221071
|
init_chunk_JNSJKHYX();
|
|
221072
221072
|
init_chunk_5ZFOKZGR();
|
|
@@ -221084,7 +221084,7 @@ var init_events = __esm({
|
|
|
221084
221084
|
init_chunk_G7KUVNDY();
|
|
221085
221085
|
init_chunk_6U6HEVSN();
|
|
221086
221086
|
init_chunk_YTBVILAH();
|
|
221087
|
-
|
|
221087
|
+
init_chunk_V5RHOS43();
|
|
221088
221088
|
init_chunk_J7F2OFWQ();
|
|
221089
221089
|
init_chunk_B6E6BVNK();
|
|
221090
221090
|
init_chunk_6SD6MC2B();
|
|
@@ -221103,25 +221103,25 @@ var init_events = __esm({
|
|
|
221103
221103
|
init_chunk_UY3VT3HQ();
|
|
221104
221104
|
init_chunk_PDWLVL34();
|
|
221105
221105
|
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();
|
|
221106
|
+
init_chunk_65XY7HRS();
|
|
221113
221107
|
init_chunk_TPMZO6S2();
|
|
221114
221108
|
init_chunk_M72ERPMT();
|
|
221115
221109
|
init_chunk_AQHYCRTO();
|
|
221116
|
-
init_chunk_KJ2GJLPQ();
|
|
221117
221110
|
init_chunk_7TSTCMII();
|
|
221118
|
-
|
|
221111
|
+
init_chunk_KJ2GJLPQ();
|
|
221112
|
+
init_chunk_IBYOMAZ3();
|
|
221113
|
+
init_chunk_WEUPM3IN();
|
|
221114
|
+
init_chunk_PJYCPDV5();
|
|
221115
|
+
init_chunk_SIO4LO2M();
|
|
221119
221116
|
init_chunk_NMZMRH3E();
|
|
221120
|
-
init_chunk_CULYZ3VA();
|
|
221121
221117
|
init_chunk_XJYR5HE3();
|
|
221118
|
+
init_chunk_CULYZ3VA();
|
|
221119
|
+
init_chunk_JN3DHH7Z();
|
|
221120
|
+
init_chunk_VRRGSQI7();
|
|
221121
|
+
init_chunk_D6RQPBRG();
|
|
221122
|
+
init_chunk_YJCH35J4();
|
|
221122
221123
|
init_chunk_YE2RMJY7();
|
|
221123
|
-
|
|
221124
|
-
init_chunk_SIO4LO2M();
|
|
221124
|
+
init_chunk_CY6AWCC6();
|
|
221125
221125
|
init_chunk_FX2AEKOV();
|
|
221126
221126
|
init_chunk_J6T3W6RY();
|
|
221127
221127
|
init_chunk_F4WUVOLE();
|
|
@@ -221138,6 +221138,31 @@ var init_events = __esm({
|
|
|
221138
221138
|
}
|
|
221139
221139
|
});
|
|
221140
221140
|
|
|
221141
|
+
// ../agent-sdk/dist/db/events.js
|
|
221142
|
+
var events_exports2 = {};
|
|
221143
|
+
__export(events_exports2, {
|
|
221144
|
+
appendEvent: () => appendEvent,
|
|
221145
|
+
appendEventsBatch: () => appendEventsBatch,
|
|
221146
|
+
getLastUnprocessedUserMessage: () => getLastUnprocessedUserMessage,
|
|
221147
|
+
listEvents: () => listEvents,
|
|
221148
|
+
listEventsByTrace: () => listEventsByTrace,
|
|
221149
|
+
markUserEventProcessed: () => markUserEventProcessed,
|
|
221150
|
+
rowToManagedEvent: () => rowToManagedEvent
|
|
221151
|
+
});
|
|
221152
|
+
var init_events2 = __esm({
|
|
221153
|
+
"../agent-sdk/dist/db/events.js"() {
|
|
221154
|
+
"use strict";
|
|
221155
|
+
init_chunk_OEFJPZYH();
|
|
221156
|
+
init_chunk_F4WUVOLE();
|
|
221157
|
+
init_chunk_HFDLUBWN();
|
|
221158
|
+
init_chunk_ZDDMPGN4();
|
|
221159
|
+
init_chunk_CXYMVLYK();
|
|
221160
|
+
init_chunk_AGIXZFHQ();
|
|
221161
|
+
init_chunk_S5CMAWEC();
|
|
221162
|
+
init_chunk_2ESYSVXG();
|
|
221163
|
+
}
|
|
221164
|
+
});
|
|
221165
|
+
|
|
221141
221166
|
// ../agent-sdk/dist/db/environments.js
|
|
221142
221167
|
var environments_exports = {};
|
|
221143
221168
|
__export(environments_exports, {
|
|
@@ -221167,7 +221192,7 @@ var init_environments = __esm({
|
|
|
221167
221192
|
}
|
|
221168
221193
|
});
|
|
221169
221194
|
|
|
221170
|
-
// ../agent-sdk/dist/chunk-
|
|
221195
|
+
// ../agent-sdk/dist/chunk-LKHJLSYG.js
|
|
221171
221196
|
function getEnvironmentTenantId2(id) {
|
|
221172
221197
|
const row = getDb().prepare(`SELECT tenant_id FROM environments WHERE id = ?`).get(id);
|
|
221173
221198
|
return row?.tenant_id;
|
|
@@ -221325,12 +221350,12 @@ function handleUpdateEnvironment(request2, id) {
|
|
|
221325
221350
|
});
|
|
221326
221351
|
}
|
|
221327
221352
|
var PackagesSchema, NetworkingSchema, ConfigSchema, CreateSchema3, UpdateSchema3;
|
|
221328
|
-
var
|
|
221329
|
-
"../agent-sdk/dist/chunk-
|
|
221353
|
+
var init_chunk_LKHJLSYG = __esm({
|
|
221354
|
+
"../agent-sdk/dist/chunk-LKHJLSYG.js"() {
|
|
221330
221355
|
"use strict";
|
|
221331
221356
|
init_chunk_23UKWXJH();
|
|
221332
221357
|
init_chunk_K5J4IN2S();
|
|
221333
|
-
|
|
221358
|
+
init_chunk_4EKHW6VS();
|
|
221334
221359
|
init_chunk_JFHYXFAL();
|
|
221335
221360
|
init_chunk_DZKBUOYU();
|
|
221336
221361
|
init_chunk_XLMNSDUJ();
|
|
@@ -221394,17 +221419,17 @@ __export(environments_exports2, {
|
|
|
221394
221419
|
var init_environments2 = __esm({
|
|
221395
221420
|
"../agent-sdk/dist/handlers/environments.js"() {
|
|
221396
221421
|
"use strict";
|
|
221397
|
-
|
|
221422
|
+
init_chunk_LKHJLSYG();
|
|
221398
221423
|
init_chunk_23UKWXJH();
|
|
221399
221424
|
init_chunk_K5J4IN2S();
|
|
221400
|
-
|
|
221425
|
+
init_chunk_4EKHW6VS();
|
|
221401
221426
|
init_chunk_D2XITRN6();
|
|
221402
221427
|
init_chunk_CWB2DQN5();
|
|
221403
221428
|
init_chunk_JFHYXFAL();
|
|
221404
221429
|
init_chunk_W6WKXFHN();
|
|
221405
221430
|
init_chunk_HVUWXUUI();
|
|
221406
|
-
|
|
221407
|
-
|
|
221431
|
+
init_chunk_P7V3S2T3();
|
|
221432
|
+
init_chunk_KYKVHH7I();
|
|
221408
221433
|
init_chunk_PJZ5TQYW();
|
|
221409
221434
|
init_chunk_AU4NAQGA();
|
|
221410
221435
|
init_chunk_H6TQGV4L();
|
|
@@ -221419,10 +221444,10 @@ var init_environments2 = __esm({
|
|
|
221419
221444
|
init_chunk_WK33IBKY();
|
|
221420
221445
|
init_chunk_3NUTTKE5();
|
|
221421
221446
|
init_chunk_3MQ2FWXS();
|
|
221422
|
-
|
|
221423
|
-
|
|
221447
|
+
init_chunk_ZACPJA3G();
|
|
221448
|
+
init_chunk_K3LM6O44();
|
|
221424
221449
|
init_chunk_LAWTTG2E();
|
|
221425
|
-
|
|
221450
|
+
init_chunk_ZCCHLDLC();
|
|
221426
221451
|
init_chunk_4XXQAVKE();
|
|
221427
221452
|
init_chunk_JNSJKHYX();
|
|
221428
221453
|
init_chunk_5ZFOKZGR();
|
|
@@ -221440,7 +221465,7 @@ var init_environments2 = __esm({
|
|
|
221440
221465
|
init_chunk_G7KUVNDY();
|
|
221441
221466
|
init_chunk_6U6HEVSN();
|
|
221442
221467
|
init_chunk_YTBVILAH();
|
|
221443
|
-
|
|
221468
|
+
init_chunk_V5RHOS43();
|
|
221444
221469
|
init_chunk_J7F2OFWQ();
|
|
221445
221470
|
init_chunk_B6E6BVNK();
|
|
221446
221471
|
init_chunk_6SD6MC2B();
|
|
@@ -221459,25 +221484,25 @@ var init_environments2 = __esm({
|
|
|
221459
221484
|
init_chunk_UY3VT3HQ();
|
|
221460
221485
|
init_chunk_PDWLVL34();
|
|
221461
221486
|
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();
|
|
221487
|
+
init_chunk_65XY7HRS();
|
|
221469
221488
|
init_chunk_TPMZO6S2();
|
|
221470
221489
|
init_chunk_M72ERPMT();
|
|
221471
221490
|
init_chunk_AQHYCRTO();
|
|
221472
|
-
init_chunk_KJ2GJLPQ();
|
|
221473
221491
|
init_chunk_7TSTCMII();
|
|
221474
|
-
|
|
221492
|
+
init_chunk_KJ2GJLPQ();
|
|
221493
|
+
init_chunk_IBYOMAZ3();
|
|
221494
|
+
init_chunk_WEUPM3IN();
|
|
221495
|
+
init_chunk_PJYCPDV5();
|
|
221496
|
+
init_chunk_SIO4LO2M();
|
|
221475
221497
|
init_chunk_NMZMRH3E();
|
|
221476
|
-
init_chunk_CULYZ3VA();
|
|
221477
221498
|
init_chunk_XJYR5HE3();
|
|
221499
|
+
init_chunk_CULYZ3VA();
|
|
221500
|
+
init_chunk_JN3DHH7Z();
|
|
221501
|
+
init_chunk_VRRGSQI7();
|
|
221502
|
+
init_chunk_D6RQPBRG();
|
|
221503
|
+
init_chunk_YJCH35J4();
|
|
221478
221504
|
init_chunk_YE2RMJY7();
|
|
221479
|
-
|
|
221480
|
-
init_chunk_SIO4LO2M();
|
|
221505
|
+
init_chunk_CY6AWCC6();
|
|
221481
221506
|
init_chunk_FX2AEKOV();
|
|
221482
221507
|
init_chunk_J6T3W6RY();
|
|
221483
221508
|
init_chunk_F4WUVOLE();
|
|
@@ -221523,32 +221548,7 @@ var init_bus = __esm({
|
|
|
221523
221548
|
}
|
|
221524
221549
|
});
|
|
221525
221550
|
|
|
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
|
|
221551
|
+
// ../agent-sdk/dist/chunk-IYE5USSW.js
|
|
221552
221552
|
function ensureTable() {
|
|
221553
221553
|
const db = getDb();
|
|
221554
221554
|
db.exec(`
|
|
@@ -221589,11 +221589,15 @@ function handleCreateInteraction(request2) {
|
|
|
221589
221589
|
agentId = "";
|
|
221590
221590
|
environmentId = prev.environment_id ?? void 0;
|
|
221591
221591
|
const sessionId2 = prev.session_id;
|
|
221592
|
+
const { listEvents: listEventsForSeq } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221593
|
+
const lastEvents = listEventsForSeq(sessionId2, { limit: 1, order: "desc" });
|
|
221594
|
+
const afterSeq = lastEvents.length > 0 ? lastEvents[0].seq : 0;
|
|
221595
|
+
const functionResultEvents = buildFunctionResultEvents(data.input);
|
|
221592
221596
|
const eventsReq2 = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${sessionId2}/events`), {
|
|
221593
221597
|
method: "POST",
|
|
221594
221598
|
headers: request2.headers,
|
|
221595
221599
|
body: JSON.stringify({
|
|
221596
|
-
events: [{ type: "user.message", content: [{ type: "text", text: inputText }] }]
|
|
221600
|
+
events: functionResultEvents.length > 0 ? functionResultEvents : [{ type: "user.message", content: [{ type: "text", text: inputText }] }]
|
|
221597
221601
|
})
|
|
221598
221602
|
});
|
|
221599
221603
|
const eventsRes2 = await handlePostEvents2(eventsReq2, sessionId2);
|
|
@@ -221601,7 +221605,7 @@ function handleCreateInteraction(request2) {
|
|
|
221601
221605
|
const err = await eventsRes2.json().catch(() => ({}));
|
|
221602
221606
|
throw badRequest(err.error?.message || `failed to send message: ${eventsRes2.status}`);
|
|
221603
221607
|
}
|
|
221604
|
-
const result2 = await waitForCompletion(sessionId2);
|
|
221608
|
+
const result2 = await waitForCompletion(sessionId2, afterSeq);
|
|
221605
221609
|
const interactionId2 = `int_${newId("sesn").slice(5)}`;
|
|
221606
221610
|
const prevSeq = db2.prepare(
|
|
221607
221611
|
`SELECT MAX(seq) as maxSeq FROM google_interactions WHERE session_id = ?`
|
|
@@ -221695,9 +221699,135 @@ function handleCreateInteraction(request2) {
|
|
|
221695
221699
|
return jsonOk(buildResponse(interactionId, result, environmentId));
|
|
221696
221700
|
});
|
|
221697
221701
|
}
|
|
221698
|
-
|
|
221702
|
+
function handleGetInteraction(request2, id) {
|
|
221703
|
+
return routeWrap(request2, async () => {
|
|
221704
|
+
ensureTable();
|
|
221705
|
+
const db = getDb();
|
|
221706
|
+
const row = db.prepare(
|
|
221707
|
+
`SELECT id, session_id, seq, status, environment_id, created_at FROM google_interactions WHERE id = ?`
|
|
221708
|
+
).get(id);
|
|
221709
|
+
if (!row) throw notFound(`interaction not found: ${id}`);
|
|
221710
|
+
const { listEvents: listEvents2 } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221711
|
+
const { rowToManagedEvent: rowToManagedEvent2 } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221712
|
+
const eventRows = listEvents2(row.session_id, { limit: 500, order: "asc" });
|
|
221713
|
+
const steps = [];
|
|
221714
|
+
let inputTokens = 0;
|
|
221715
|
+
let outputTokens = 0;
|
|
221716
|
+
for (const eventRow of eventRows) {
|
|
221717
|
+
const event = rowToManagedEvent2(eventRow);
|
|
221718
|
+
if (event.type === "agent.message") {
|
|
221719
|
+
const content = event.content;
|
|
221720
|
+
const text2 = content?.filter((c2) => c2.type === "text").map((c2) => c2.text).join("") ?? "";
|
|
221721
|
+
if (text2) {
|
|
221722
|
+
steps.push({ type: "model_output", content: [{ type: "text", text: text2 }] });
|
|
221723
|
+
}
|
|
221724
|
+
} else if (event.type === "agent.tool_use") {
|
|
221725
|
+
steps.push({
|
|
221726
|
+
type: "function_call",
|
|
221727
|
+
id: event.tool_use_id ?? "",
|
|
221728
|
+
name: event.name ?? "",
|
|
221729
|
+
arguments: event.input ?? {}
|
|
221730
|
+
});
|
|
221731
|
+
} else if (event.type === "agent.tool_result") {
|
|
221732
|
+
steps.push({
|
|
221733
|
+
type: "code_execution_result",
|
|
221734
|
+
call_id: event.tool_use_id ?? "",
|
|
221735
|
+
result: JSON.stringify(event.content ?? "")
|
|
221736
|
+
});
|
|
221737
|
+
} else if (event.type === "agent.custom_tool_use") {
|
|
221738
|
+
steps.push({
|
|
221739
|
+
type: "function_call",
|
|
221740
|
+
id: event.tool_use_id ?? "",
|
|
221741
|
+
name: event.name ?? "",
|
|
221742
|
+
arguments: event.input ?? {}
|
|
221743
|
+
});
|
|
221744
|
+
} else if (event.type === "span.model_request_end") {
|
|
221745
|
+
const mu = event.model_usage;
|
|
221746
|
+
inputTokens += mu?.input_tokens ?? 0;
|
|
221747
|
+
outputTokens += mu?.output_tokens ?? 0;
|
|
221748
|
+
}
|
|
221749
|
+
}
|
|
221750
|
+
const response = {
|
|
221751
|
+
id: row.id,
|
|
221752
|
+
created: row.created_at,
|
|
221753
|
+
updated: row.created_at,
|
|
221754
|
+
status: row.status,
|
|
221755
|
+
steps,
|
|
221756
|
+
usage: { total_input_tokens: inputTokens, total_output_tokens: outputTokens, total_tokens: inputTokens + outputTokens },
|
|
221757
|
+
environment_id: row.environment_id ?? void 0
|
|
221758
|
+
};
|
|
221759
|
+
return jsonOk(response);
|
|
221760
|
+
});
|
|
221761
|
+
}
|
|
221762
|
+
function handleDeleteInteraction(request2, id) {
|
|
221763
|
+
return routeWrap(request2, async () => {
|
|
221764
|
+
ensureTable();
|
|
221765
|
+
const db = getDb();
|
|
221766
|
+
const row = db.prepare(
|
|
221767
|
+
`SELECT id, session_id FROM google_interactions WHERE id = ?`
|
|
221768
|
+
).get(id);
|
|
221769
|
+
if (!row) throw notFound(`interaction not found: ${id}`);
|
|
221770
|
+
db.prepare(`DELETE FROM google_interactions WHERE id = ?`).run(id);
|
|
221771
|
+
const { handleDeleteSession: handleDeleteSession2 } = await Promise.resolve().then(() => (init_sessions(), sessions_exports));
|
|
221772
|
+
const sessReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${row.session_id}`), {
|
|
221773
|
+
method: "DELETE",
|
|
221774
|
+
headers: request2.headers
|
|
221775
|
+
});
|
|
221776
|
+
await handleDeleteSession2(sessReq, row.session_id).catch(() => {
|
|
221777
|
+
});
|
|
221778
|
+
return jsonOk({ id, deleted: true });
|
|
221779
|
+
});
|
|
221780
|
+
}
|
|
221781
|
+
function handleCancelInteraction(request2, id) {
|
|
221782
|
+
return routeWrap(request2, async () => {
|
|
221783
|
+
ensureTable();
|
|
221784
|
+
const db = getDb();
|
|
221785
|
+
const row = db.prepare(
|
|
221786
|
+
`SELECT id, session_id, seq, status, environment_id, created_at FROM google_interactions WHERE id = ?`
|
|
221787
|
+
).get(id);
|
|
221788
|
+
if (!row) throw notFound(`interaction not found: ${id}`);
|
|
221789
|
+
const { handlePostEvents: handlePostEvents2 } = await Promise.resolve().then(() => (init_events(), events_exports));
|
|
221790
|
+
const eventsReq = new Request(request2.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${row.session_id}/events`), {
|
|
221791
|
+
method: "POST",
|
|
221792
|
+
headers: request2.headers,
|
|
221793
|
+
body: JSON.stringify({
|
|
221794
|
+
events: [{ type: "user.interrupt" }]
|
|
221795
|
+
})
|
|
221796
|
+
});
|
|
221797
|
+
await handlePostEvents2(eventsReq, row.session_id).catch(() => {
|
|
221798
|
+
});
|
|
221799
|
+
db.prepare(`UPDATE google_interactions SET status = 'cancelled' WHERE id = ?`).run(id);
|
|
221800
|
+
const response = {
|
|
221801
|
+
id: row.id,
|
|
221802
|
+
created: row.created_at,
|
|
221803
|
+
updated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
221804
|
+
status: "cancelled",
|
|
221805
|
+
steps: [],
|
|
221806
|
+
usage: { total_input_tokens: 0, total_output_tokens: 0, total_tokens: 0 },
|
|
221807
|
+
environment_id: row.environment_id ?? void 0
|
|
221808
|
+
};
|
|
221809
|
+
return jsonOk(response);
|
|
221810
|
+
});
|
|
221811
|
+
}
|
|
221812
|
+
function buildFunctionResultEvents(input) {
|
|
221813
|
+
if (typeof input === "string") return [];
|
|
221814
|
+
if (!Array.isArray(input)) return [];
|
|
221815
|
+
const results = [];
|
|
221816
|
+
for (const item of input) {
|
|
221817
|
+
if (item && typeof item === "object" && item.type === "function_result") {
|
|
221818
|
+
const callId = item.call_id ?? item.id ?? "";
|
|
221819
|
+
const resultText = item.result ?? item.output ?? "";
|
|
221820
|
+
results.push({
|
|
221821
|
+
type: "user.custom_tool_result",
|
|
221822
|
+
custom_tool_use_id: callId,
|
|
221823
|
+
content: [{ type: "text", text: typeof resultText === "string" ? resultText : JSON.stringify(resultText) }]
|
|
221824
|
+
});
|
|
221825
|
+
}
|
|
221826
|
+
}
|
|
221827
|
+
return results;
|
|
221828
|
+
}
|
|
221829
|
+
async function waitForCompletion(sessionId, afterSeq = 0) {
|
|
221699
221830
|
const { subscribe: subscribe6 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
|
|
221700
|
-
const { listEvents: listEvents2 } = await Promise.resolve().then(() => (init_events2(), events_exports2));
|
|
221701
221831
|
return new Promise((resolve3) => {
|
|
221702
221832
|
const steps = [];
|
|
221703
221833
|
let outputText = "";
|
|
@@ -221705,10 +221835,11 @@ async function waitForCompletion(sessionId) {
|
|
|
221705
221835
|
let outputTokens = 0;
|
|
221706
221836
|
let status = "completed";
|
|
221707
221837
|
let resolved = false;
|
|
221838
|
+
let subscription = null;
|
|
221708
221839
|
const timeout = setTimeout(() => {
|
|
221709
221840
|
if (resolved) return;
|
|
221710
221841
|
resolved = true;
|
|
221711
|
-
|
|
221842
|
+
subscription?.unsubscribe();
|
|
221712
221843
|
resolve3({
|
|
221713
221844
|
status: "failed",
|
|
221714
221845
|
steps,
|
|
@@ -221720,7 +221851,7 @@ async function waitForCompletion(sessionId) {
|
|
|
221720
221851
|
if (resolved) return;
|
|
221721
221852
|
resolved = true;
|
|
221722
221853
|
clearTimeout(timeout);
|
|
221723
|
-
|
|
221854
|
+
subscription?.unsubscribe();
|
|
221724
221855
|
resolve3({
|
|
221725
221856
|
status,
|
|
221726
221857
|
steps,
|
|
@@ -221771,9 +221902,11 @@ async function waitForCompletion(sessionId) {
|
|
|
221771
221902
|
status = "failed";
|
|
221772
221903
|
}
|
|
221773
221904
|
}
|
|
221774
|
-
const sub = subscribe6(sessionId,
|
|
221905
|
+
const sub = subscribe6(sessionId, afterSeq, handleEvent);
|
|
221906
|
+
subscription = sub;
|
|
221775
221907
|
if (resolved) {
|
|
221776
221908
|
clearTimeout(timeout);
|
|
221909
|
+
sub.unsubscribe();
|
|
221777
221910
|
}
|
|
221778
221911
|
});
|
|
221779
221912
|
}
|
|
@@ -221790,10 +221923,10 @@ function buildResponse(id, result, environmentId) {
|
|
|
221790
221923
|
};
|
|
221791
221924
|
}
|
|
221792
221925
|
var CreateSchema4;
|
|
221793
|
-
var
|
|
221794
|
-
"../agent-sdk/dist/chunk-
|
|
221926
|
+
var init_chunk_IYE5USSW = __esm({
|
|
221927
|
+
"../agent-sdk/dist/chunk-IYE5USSW.js"() {
|
|
221795
221928
|
"use strict";
|
|
221796
|
-
|
|
221929
|
+
init_chunk_4EKHW6VS();
|
|
221797
221930
|
init_chunk_F4WUVOLE();
|
|
221798
221931
|
init_chunk_AGIXZFHQ();
|
|
221799
221932
|
init_chunk_EZYKRG4W();
|
|
@@ -221814,7 +221947,254 @@ var init_chunk_U5XWSJPT = __esm({
|
|
|
221814
221947
|
}
|
|
221815
221948
|
});
|
|
221816
221949
|
|
|
221817
|
-
// ../agent-sdk/dist/chunk-
|
|
221950
|
+
// ../agent-sdk/dist/chunk-QZE37OGX.js
|
|
221951
|
+
function resolveBaseAgent(baseAgent) {
|
|
221952
|
+
if (!baseAgent) return { engine: "gemini", model: "gemini-2.5-flash" };
|
|
221953
|
+
if (baseAgent === "antigravity-preview-05-2026") {
|
|
221954
|
+
return { engine: "gemini", model: "gemini-2.5-flash" };
|
|
221955
|
+
}
|
|
221956
|
+
return { engine: "gemini", model: baseAgent };
|
|
221957
|
+
}
|
|
221958
|
+
function toGoogleFormat(agent) {
|
|
221959
|
+
return {
|
|
221960
|
+
id: agent.name,
|
|
221961
|
+
base_agent: agent.engine === "gemini" ? "antigravity-preview-05-2026" : void 0,
|
|
221962
|
+
system_instruction: agent.system ?? void 0,
|
|
221963
|
+
description: agent.description ?? void 0,
|
|
221964
|
+
created: agent.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
221965
|
+
updated: agent.updated_at ?? agent.created_at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
221966
|
+
};
|
|
221967
|
+
}
|
|
221968
|
+
function handleCreateGoogleAgent(request2) {
|
|
221969
|
+
return routeWrap(request2, async () => {
|
|
221970
|
+
const body = await request2.json().catch(() => null);
|
|
221971
|
+
const parsed = CreateGoogleAgentSchema.safeParse(body);
|
|
221972
|
+
if (!parsed.success) {
|
|
221973
|
+
throw badRequest(`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
|
|
221974
|
+
}
|
|
221975
|
+
const data = parsed.data;
|
|
221976
|
+
const { engine, model } = resolveBaseAgent(data.base_agent);
|
|
221977
|
+
let systemInstruction = data.system_instruction ?? "";
|
|
221978
|
+
const skills2 = [];
|
|
221979
|
+
if (data.base_environment?.sources) {
|
|
221980
|
+
for (const source of data.base_environment.sources) {
|
|
221981
|
+
const target2 = source.target ?? "";
|
|
221982
|
+
const skillMatch = target2.match(/\.agents\/skills\/([^/]+)\/SKILL\.md$/);
|
|
221983
|
+
if (skillMatch && source.content) {
|
|
221984
|
+
skills2.push({
|
|
221985
|
+
name: skillMatch[1],
|
|
221986
|
+
source: "inline",
|
|
221987
|
+
content: source.content
|
|
221988
|
+
});
|
|
221989
|
+
} else if (target2.endsWith(".agents/AGENTS.md") && source.content) {
|
|
221990
|
+
if (systemInstruction) systemInstruction += "\n\n";
|
|
221991
|
+
systemInstruction += source.content;
|
|
221992
|
+
}
|
|
221993
|
+
}
|
|
221994
|
+
}
|
|
221995
|
+
const agentName = data.id || `google-agent-${Date.now()}`;
|
|
221996
|
+
const { handleCreateAgent: handleCreateAgent2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
221997
|
+
const createBody = {
|
|
221998
|
+
name: agentName,
|
|
221999
|
+
model: { id: model },
|
|
222000
|
+
engine
|
|
222001
|
+
};
|
|
222002
|
+
if (systemInstruction) createBody.system = systemInstruction;
|
|
222003
|
+
if (data.description) createBody.description = data.description;
|
|
222004
|
+
if (skills2.length > 0) createBody.skills = skills2;
|
|
222005
|
+
const createReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents`), {
|
|
222006
|
+
method: "POST",
|
|
222007
|
+
headers: request2.headers,
|
|
222008
|
+
body: JSON.stringify(createBody)
|
|
222009
|
+
});
|
|
222010
|
+
const createRes = await handleCreateAgent2(createReq);
|
|
222011
|
+
if (!createRes.ok) {
|
|
222012
|
+
const err = await createRes.json().catch(() => ({}));
|
|
222013
|
+
throw badRequest(err.error?.message || `failed to create agent: ${createRes.status}`);
|
|
222014
|
+
}
|
|
222015
|
+
const created = await createRes.json();
|
|
222016
|
+
const response = {
|
|
222017
|
+
id: created.name ?? agentName,
|
|
222018
|
+
base_agent: data.base_agent,
|
|
222019
|
+
system_instruction: systemInstruction || void 0,
|
|
222020
|
+
description: data.description,
|
|
222021
|
+
created: created.created_at ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
222022
|
+
updated: created.updated_at ?? created.created_at ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
222023
|
+
};
|
|
222024
|
+
return jsonOk(response, 201);
|
|
222025
|
+
});
|
|
222026
|
+
}
|
|
222027
|
+
function handleListGoogleAgents(request2) {
|
|
222028
|
+
return routeWrap(request2, async () => {
|
|
222029
|
+
const { handleListAgents: handleListAgents2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
222030
|
+
const listReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents?limit=1000`), {
|
|
222031
|
+
headers: request2.headers
|
|
222032
|
+
});
|
|
222033
|
+
const listRes = await handleListAgents2(listReq);
|
|
222034
|
+
if (!listRes.ok) {
|
|
222035
|
+
return listRes;
|
|
222036
|
+
}
|
|
222037
|
+
const listBody = await listRes.json();
|
|
222038
|
+
const agents2 = (listBody.data ?? []).map(toGoogleFormat);
|
|
222039
|
+
return jsonOk({ agents: agents2 });
|
|
222040
|
+
});
|
|
222041
|
+
}
|
|
222042
|
+
function handleGetGoogleAgent(request2, id) {
|
|
222043
|
+
return routeWrap(request2, async () => {
|
|
222044
|
+
const { handleListAgents: handleListAgents2 } = await Promise.resolve().then(() => (init_agents(), agents_exports));
|
|
222045
|
+
const listReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents?limit=1000`), {
|
|
222046
|
+
headers: request2.headers
|
|
222047
|
+
});
|
|
222048
|
+
const listRes = await handleListAgents2(listReq);
|
|
222049
|
+
if (!listRes.ok) {
|
|
222050
|
+
return listRes;
|
|
222051
|
+
}
|
|
222052
|
+
const listBody = await listRes.json();
|
|
222053
|
+
const agent = listBody.data?.find((a) => a.name === id);
|
|
222054
|
+
if (!agent) throw notFound(`agent not found: ${id}`);
|
|
222055
|
+
return jsonOk(toGoogleFormat(agent));
|
|
222056
|
+
});
|
|
222057
|
+
}
|
|
222058
|
+
function handleDeleteGoogleAgent(request2, id) {
|
|
222059
|
+
return routeWrap(request2, async () => {
|
|
222060
|
+
const { handleListAgents: handleListAgents2, handleDeleteAgent: handleDeleteAgent2 } = 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
|
+
const delReq = new Request(request2.url.replace(/\/google\/v1beta\/agents.*/, `/v1/agents/${agent.id}`), {
|
|
222072
|
+
method: "DELETE",
|
|
222073
|
+
headers: request2.headers
|
|
222074
|
+
});
|
|
222075
|
+
await handleDeleteAgent2(delReq, agent.id);
|
|
222076
|
+
return jsonOk({});
|
|
222077
|
+
});
|
|
222078
|
+
}
|
|
222079
|
+
var SourceSchema, BaseEnvironmentSchema, CreateGoogleAgentSchema;
|
|
222080
|
+
var init_chunk_QZE37OGX = __esm({
|
|
222081
|
+
"../agent-sdk/dist/chunk-QZE37OGX.js"() {
|
|
222082
|
+
"use strict";
|
|
222083
|
+
init_chunk_4EKHW6VS();
|
|
222084
|
+
init_chunk_EZYKRG4W();
|
|
222085
|
+
init_zod();
|
|
222086
|
+
SourceSchema = external_exports.object({
|
|
222087
|
+
type: external_exports.string().optional(),
|
|
222088
|
+
target: external_exports.string().optional(),
|
|
222089
|
+
content: external_exports.string().optional(),
|
|
222090
|
+
url: external_exports.string().optional()
|
|
222091
|
+
}).passthrough();
|
|
222092
|
+
BaseEnvironmentSchema = external_exports.object({
|
|
222093
|
+
type: external_exports.string().optional(),
|
|
222094
|
+
sources: external_exports.array(SourceSchema).optional()
|
|
222095
|
+
}).passthrough();
|
|
222096
|
+
CreateGoogleAgentSchema = external_exports.object({
|
|
222097
|
+
id: external_exports.string().optional(),
|
|
222098
|
+
description: external_exports.string().optional(),
|
|
222099
|
+
base_agent: external_exports.string().optional(),
|
|
222100
|
+
system_instruction: external_exports.string().optional(),
|
|
222101
|
+
tools: external_exports.array(external_exports.unknown()).optional(),
|
|
222102
|
+
base_environment: BaseEnvironmentSchema.optional()
|
|
222103
|
+
});
|
|
222104
|
+
}
|
|
222105
|
+
});
|
|
222106
|
+
|
|
222107
|
+
// ../agent-sdk/dist/chunk-X7UWCDYG.js
|
|
222108
|
+
function buildTarArchive(files2) {
|
|
222109
|
+
const blocks = [];
|
|
222110
|
+
for (const file of files2) {
|
|
222111
|
+
const header = Buffer.alloc(512, 0);
|
|
222112
|
+
const name = file.name.slice(0, 100);
|
|
222113
|
+
header.write(name, 0, Math.min(name.length, 100), "utf8");
|
|
222114
|
+
header.write("0000644\0", 100, 8, "utf8");
|
|
222115
|
+
header.write("0000000\0", 108, 8, "utf8");
|
|
222116
|
+
header.write("0000000\0", 116, 8, "utf8");
|
|
222117
|
+
header.write(file.data.length.toString(8).padStart(11, "0") + "\0", 124, 12, "utf8");
|
|
222118
|
+
const mtime = Math.floor(Date.now() / 1e3);
|
|
222119
|
+
header.write(mtime.toString(8).padStart(11, "0") + "\0", 136, 12, "utf8");
|
|
222120
|
+
header.write(" ", 148, 8, "utf8");
|
|
222121
|
+
header.write("0", 156, 1, "utf8");
|
|
222122
|
+
header.write("ustar\0", 257, 6, "utf8");
|
|
222123
|
+
header.write("00", 263, 2, "utf8");
|
|
222124
|
+
let checksum = 0;
|
|
222125
|
+
for (let i = 0; i < 512; i++) {
|
|
222126
|
+
checksum += header[i];
|
|
222127
|
+
}
|
|
222128
|
+
header.write(checksum.toString(8).padStart(6, "0") + "\0 ", 148, 8, "utf8");
|
|
222129
|
+
blocks.push(header);
|
|
222130
|
+
blocks.push(file.data);
|
|
222131
|
+
const remainder = file.data.length % 512;
|
|
222132
|
+
if (remainder > 0) {
|
|
222133
|
+
blocks.push(Buffer.alloc(512 - remainder, 0));
|
|
222134
|
+
}
|
|
222135
|
+
}
|
|
222136
|
+
blocks.push(Buffer.alloc(1024, 0));
|
|
222137
|
+
return Buffer.concat(blocks);
|
|
222138
|
+
}
|
|
222139
|
+
function handleGetEnvironmentFiles(request2, fileRef) {
|
|
222140
|
+
return routeWrap(request2, async () => {
|
|
222141
|
+
const match2 = fileRef.match(/^environment-(.+):download$/);
|
|
222142
|
+
if (!match2) {
|
|
222143
|
+
throw badRequest("Invalid file reference format. Expected: environment-<envId>:download");
|
|
222144
|
+
}
|
|
222145
|
+
const envId = match2[1];
|
|
222146
|
+
const db = getDb();
|
|
222147
|
+
const env3 = db.prepare(`SELECT id FROM environments WHERE id = ?`).get(envId);
|
|
222148
|
+
if (!env3) {
|
|
222149
|
+
throw notFound(`environment not found: ${envId}`);
|
|
222150
|
+
}
|
|
222151
|
+
const sessions2 = db.prepare(
|
|
222152
|
+
`SELECT id FROM sessions WHERE environment_id = ?`
|
|
222153
|
+
).all(envId);
|
|
222154
|
+
if (sessions2.length === 0) {
|
|
222155
|
+
const emptyTar = Buffer.alloc(1024, 0);
|
|
222156
|
+
return new Response(emptyTar, {
|
|
222157
|
+
headers: {
|
|
222158
|
+
"Content-Type": "application/x-tar",
|
|
222159
|
+
"Content-Length": String(emptyTar.length)
|
|
222160
|
+
}
|
|
222161
|
+
});
|
|
222162
|
+
}
|
|
222163
|
+
const sessionIds = sessions2.map((s) => s.id);
|
|
222164
|
+
const placeholders = sessionIds.map(() => "?").join(",");
|
|
222165
|
+
const fileRows = db.prepare(
|
|
222166
|
+
`SELECT * FROM files WHERE scope_type = 'session' AND scope_id IN (${placeholders})`
|
|
222167
|
+
).all(...sessionIds);
|
|
222168
|
+
const tarFiles = [];
|
|
222169
|
+
for (const row of fileRows) {
|
|
222170
|
+
if (row.storage_path.startsWith("remote:")) continue;
|
|
222171
|
+
try {
|
|
222172
|
+
const data = readFile2(row.storage_path);
|
|
222173
|
+
tarFiles.push({ name: row.filename, data });
|
|
222174
|
+
} catch {
|
|
222175
|
+
}
|
|
222176
|
+
}
|
|
222177
|
+
const tar = buildTarArchive(tarFiles);
|
|
222178
|
+
return new Response(tar, {
|
|
222179
|
+
headers: {
|
|
222180
|
+
"Content-Type": "application/x-tar",
|
|
222181
|
+
"Content-Length": String(tar.length)
|
|
222182
|
+
}
|
|
222183
|
+
});
|
|
222184
|
+
});
|
|
222185
|
+
}
|
|
222186
|
+
var init_chunk_X7UWCDYG = __esm({
|
|
222187
|
+
"../agent-sdk/dist/chunk-X7UWCDYG.js"() {
|
|
222188
|
+
"use strict";
|
|
222189
|
+
init_chunk_STPT3SWU();
|
|
222190
|
+
init_chunk_4EKHW6VS();
|
|
222191
|
+
init_chunk_AGIXZFHQ();
|
|
222192
|
+
init_chunk_EZYKRG4W();
|
|
222193
|
+
init_client();
|
|
222194
|
+
}
|
|
222195
|
+
});
|
|
222196
|
+
|
|
222197
|
+
// ../agent-sdk/dist/chunk-SUEPFZN2.js
|
|
221818
222198
|
function handleWhoami(request2) {
|
|
221819
222199
|
return routeWrap(request2, async ({ auth }) => {
|
|
221820
222200
|
return jsonOk({
|
|
@@ -221825,14 +222205,14 @@ function handleWhoami(request2) {
|
|
|
221825
222205
|
});
|
|
221826
222206
|
});
|
|
221827
222207
|
}
|
|
221828
|
-
var
|
|
221829
|
-
"../agent-sdk/dist/chunk-
|
|
222208
|
+
var init_chunk_SUEPFZN2 = __esm({
|
|
222209
|
+
"../agent-sdk/dist/chunk-SUEPFZN2.js"() {
|
|
221830
222210
|
"use strict";
|
|
221831
|
-
|
|
222211
|
+
init_chunk_4EKHW6VS();
|
|
221832
222212
|
}
|
|
221833
222213
|
});
|
|
221834
222214
|
|
|
221835
|
-
// ../agent-sdk/dist/chunk-
|
|
222215
|
+
// ../agent-sdk/dist/chunk-6CODFATQ.js
|
|
221836
222216
|
function assertSelfHostedEnv(envId) {
|
|
221837
222217
|
const env3 = getEnvironment(envId);
|
|
221838
222218
|
if (!env3) throw notFound(`environment not found: ${envId}`);
|
|
@@ -221934,11 +222314,11 @@ function handleStopWork(request2, envId, workId) {
|
|
|
221934
222314
|
});
|
|
221935
222315
|
}
|
|
221936
222316
|
var UpdateWorkSchema, AckWorkSchema, StopWorkSchema;
|
|
221937
|
-
var
|
|
221938
|
-
"../agent-sdk/dist/chunk-
|
|
222317
|
+
var init_chunk_6CODFATQ = __esm({
|
|
222318
|
+
"../agent-sdk/dist/chunk-6CODFATQ.js"() {
|
|
221939
222319
|
"use strict";
|
|
221940
222320
|
init_chunk_JF777FWD();
|
|
221941
|
-
|
|
222321
|
+
init_chunk_4EKHW6VS();
|
|
221942
222322
|
init_chunk_NSUVDKNC();
|
|
221943
222323
|
init_chunk_EZYKRG4W();
|
|
221944
222324
|
init_zod();
|
|
@@ -222210,7 +222590,7 @@ var init_chunk_DF34ESOO = __esm({
|
|
|
222210
222590
|
}
|
|
222211
222591
|
});
|
|
222212
222592
|
|
|
222213
|
-
// ../agent-sdk/dist/chunk-
|
|
222593
|
+
// ../agent-sdk/dist/chunk-FHOJOLXU.js
|
|
222214
222594
|
async function handleGetSkillsCatalog(request2) {
|
|
222215
222595
|
return routeWrap(request2, async ({ request: req }) => {
|
|
222216
222596
|
const url2 = new URL(req.url);
|
|
@@ -222266,15 +222646,15 @@ async function handleGetSkillsFeed(request2) {
|
|
|
222266
222646
|
return jsonOk(feed);
|
|
222267
222647
|
});
|
|
222268
222648
|
}
|
|
222269
|
-
var
|
|
222270
|
-
"../agent-sdk/dist/chunk-
|
|
222649
|
+
var init_chunk_FHOJOLXU = __esm({
|
|
222650
|
+
"../agent-sdk/dist/chunk-FHOJOLXU.js"() {
|
|
222271
222651
|
"use strict";
|
|
222272
222652
|
init_chunk_DF34ESOO();
|
|
222273
|
-
|
|
222653
|
+
init_chunk_4EKHW6VS();
|
|
222274
222654
|
}
|
|
222275
222655
|
});
|
|
222276
222656
|
|
|
222277
|
-
// ../agent-sdk/dist/chunk-
|
|
222657
|
+
// ../agent-sdk/dist/chunk-AD2WPGDN.js
|
|
222278
222658
|
async function prepareSessionStream(request2, sessionId) {
|
|
222279
222659
|
try {
|
|
222280
222660
|
await ensureInitialized();
|
|
@@ -222367,14 +222747,14 @@ data: ${JSON.stringify(evt)}
|
|
|
222367
222747
|
}
|
|
222368
222748
|
});
|
|
222369
222749
|
}
|
|
222370
|
-
var
|
|
222371
|
-
"../agent-sdk/dist/chunk-
|
|
222750
|
+
var init_chunk_AD2WPGDN = __esm({
|
|
222751
|
+
"../agent-sdk/dist/chunk-AD2WPGDN.js"() {
|
|
222372
222752
|
"use strict";
|
|
222373
222753
|
init_chunk_ZBWKJ42J();
|
|
222374
222754
|
init_chunk_23UKWXJH();
|
|
222375
222755
|
init_chunk_CWB2DQN5();
|
|
222376
222756
|
init_chunk_JFHYXFAL();
|
|
222377
|
-
|
|
222757
|
+
init_chunk_P7V3S2T3();
|
|
222378
222758
|
init_chunk_DZKBUOYU();
|
|
222379
222759
|
init_chunk_RES4BCTF();
|
|
222380
222760
|
init_chunk_ZC7OR65K();
|
|
@@ -222384,7 +222764,7 @@ var init_chunk_RLBVOOCI = __esm({
|
|
|
222384
222764
|
}
|
|
222385
222765
|
});
|
|
222386
222766
|
|
|
222387
|
-
// ../agent-sdk/dist/chunk-
|
|
222767
|
+
// ../agent-sdk/dist/chunk-XXAO5YYL.js
|
|
222388
222768
|
function handleCreateTenant(request2) {
|
|
222389
222769
|
return routeWrap(request2, async ({ auth, request: req }) => {
|
|
222390
222770
|
requireFeature("tenancy", "multi-tenancy");
|
|
@@ -222483,13 +222863,13 @@ function handleArchiveTenant(request2, id) {
|
|
|
222483
222863
|
});
|
|
222484
222864
|
}
|
|
222485
222865
|
var CreateBody, PatchBody;
|
|
222486
|
-
var
|
|
222487
|
-
"../agent-sdk/dist/chunk-
|
|
222866
|
+
var init_chunk_XXAO5YYL = __esm({
|
|
222867
|
+
"../agent-sdk/dist/chunk-XXAO5YYL.js"() {
|
|
222488
222868
|
"use strict";
|
|
222489
222869
|
init_chunk_23UKWXJH();
|
|
222490
222870
|
init_chunk_FDLQ3IUB();
|
|
222491
222871
|
init_chunk_2N2KL4KM();
|
|
222492
|
-
|
|
222872
|
+
init_chunk_4EKHW6VS();
|
|
222493
222873
|
init_chunk_YTBVILAH();
|
|
222494
222874
|
init_chunk_EZYKRG4W();
|
|
222495
222875
|
init_zod();
|
|
@@ -222503,7 +222883,7 @@ var init_chunk_YREG7LWO = __esm({
|
|
|
222503
222883
|
}
|
|
222504
222884
|
});
|
|
222505
222885
|
|
|
222506
|
-
// ../agent-sdk/dist/chunk-
|
|
222886
|
+
// ../agent-sdk/dist/chunk-ZAUWB5DQ.js
|
|
222507
222887
|
function loadSession(auth, sessionId) {
|
|
222508
222888
|
const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
|
|
222509
222889
|
if (!row) throw notFound(`session ${sessionId} not found`);
|
|
@@ -222628,12 +223008,12 @@ data: ${JSON.stringify(evt)}
|
|
|
222628
223008
|
});
|
|
222629
223009
|
});
|
|
222630
223010
|
}
|
|
222631
|
-
var
|
|
222632
|
-
"../agent-sdk/dist/chunk-
|
|
223011
|
+
var init_chunk_ZAUWB5DQ = __esm({
|
|
223012
|
+
"../agent-sdk/dist/chunk-ZAUWB5DQ.js"() {
|
|
222633
223013
|
"use strict";
|
|
222634
223014
|
init_chunk_Z5IENUYV();
|
|
222635
223015
|
init_chunk_23UKWXJH();
|
|
222636
|
-
|
|
223016
|
+
init_chunk_4EKHW6VS();
|
|
222637
223017
|
init_chunk_RES4BCTF();
|
|
222638
223018
|
init_chunk_ZC7OR65K();
|
|
222639
223019
|
init_chunk_OEFJPZYH();
|
|
@@ -222685,7 +223065,7 @@ var init_chunk_UMXXZ6OX = __esm({
|
|
|
222685
223065
|
}
|
|
222686
223066
|
});
|
|
222687
223067
|
|
|
222688
|
-
// ../agent-sdk/dist/chunk-
|
|
223068
|
+
// ../agent-sdk/dist/chunk-3EWEKBVC.js
|
|
222689
223069
|
function buildSpanTree(events2) {
|
|
222690
223070
|
const nodes = /* @__PURE__ */ new Map();
|
|
222691
223071
|
const openStarts = /* @__PURE__ */ new Map();
|
|
@@ -222869,11 +223249,11 @@ function handleExportTrace(request2, traceId) {
|
|
|
222869
223249
|
return jsonOk(result, result.ok ? 200 : 502);
|
|
222870
223250
|
});
|
|
222871
223251
|
}
|
|
222872
|
-
var
|
|
222873
|
-
"../agent-sdk/dist/chunk-
|
|
223252
|
+
var init_chunk_3EWEKBVC = __esm({
|
|
223253
|
+
"../agent-sdk/dist/chunk-3EWEKBVC.js"() {
|
|
222874
223254
|
"use strict";
|
|
222875
223255
|
init_chunk_UMXXZ6OX();
|
|
222876
|
-
|
|
223256
|
+
init_chunk_4EKHW6VS();
|
|
222877
223257
|
init_chunk_2KF2TIEY();
|
|
222878
223258
|
init_chunk_OEFJPZYH();
|
|
222879
223259
|
init_chunk_EZYKRG4W();
|
|
@@ -223460,7 +223840,7 @@ agentstep skills install \${n}
|
|
|
223460
223840
|
}
|
|
223461
223841
|
});
|
|
223462
223842
|
|
|
223463
|
-
// ../agent-sdk/dist/chunk-
|
|
223843
|
+
// ../agent-sdk/dist/chunk-JIXRTWYL.js
|
|
223464
223844
|
function handleAddUpstreamKey(request2) {
|
|
223465
223845
|
return routeWrap(request2, async ({ auth, request: req }) => {
|
|
223466
223846
|
requireFeature("upstream_pool", "upstream key pool");
|
|
@@ -223552,15 +223932,15 @@ function handleDeleteUpstreamKey(request2, id) {
|
|
|
223552
223932
|
});
|
|
223553
223933
|
}
|
|
223554
223934
|
var AddBody, PatchBody2;
|
|
223555
|
-
var
|
|
223556
|
-
"../agent-sdk/dist/chunk-
|
|
223935
|
+
var init_chunk_JIXRTWYL = __esm({
|
|
223936
|
+
"../agent-sdk/dist/chunk-JIXRTWYL.js"() {
|
|
223557
223937
|
"use strict";
|
|
223558
223938
|
init_chunk_HWWFRSAX();
|
|
223559
223939
|
init_chunk_ABUNDZCE();
|
|
223560
223940
|
init_chunk_23UKWXJH();
|
|
223561
223941
|
init_chunk_FDLQ3IUB();
|
|
223562
223942
|
init_chunk_2N2KL4KM();
|
|
223563
|
-
|
|
223943
|
+
init_chunk_4EKHW6VS();
|
|
223564
223944
|
init_chunk_EZYKRG4W();
|
|
223565
223945
|
init_zod();
|
|
223566
223946
|
AddBody = external_exports.object({
|
|
@@ -223574,7 +223954,7 @@ var init_chunk_GHPBBVDF = __esm({
|
|
|
223574
223954
|
}
|
|
223575
223955
|
});
|
|
223576
223956
|
|
|
223577
|
-
// ../agent-sdk/dist/chunk-
|
|
223957
|
+
// ../agent-sdk/dist/chunk-ZHEE6UTX.js
|
|
223578
223958
|
function handleCreateUserProfile(request2) {
|
|
223579
223959
|
return routeWrap(request2, async ({ auth }) => {
|
|
223580
223960
|
const body = await request2.json().catch(() => null);
|
|
@@ -223640,11 +224020,11 @@ function handleUpdateUserProfile(request2, id) {
|
|
|
223640
224020
|
});
|
|
223641
224021
|
}
|
|
223642
224022
|
var TrustGrantSchema, CreateSchema5, UpdateSchema4;
|
|
223643
|
-
var
|
|
223644
|
-
"../agent-sdk/dist/chunk-
|
|
224023
|
+
var init_chunk_ZHEE6UTX = __esm({
|
|
224024
|
+
"../agent-sdk/dist/chunk-ZHEE6UTX.js"() {
|
|
223645
224025
|
"use strict";
|
|
223646
224026
|
init_chunk_23UKWXJH();
|
|
223647
|
-
|
|
224027
|
+
init_chunk_4EKHW6VS();
|
|
223648
224028
|
init_chunk_YOZ6WDP3();
|
|
223649
224029
|
init_chunk_EZYKRG4W();
|
|
223650
224030
|
init_zod();
|
|
@@ -223666,7 +224046,7 @@ var init_chunk_TIX26S4Y = __esm({
|
|
|
223666
224046
|
}
|
|
223667
224047
|
});
|
|
223668
224048
|
|
|
223669
|
-
// ../agent-sdk/dist/chunk-
|
|
224049
|
+
// ../agent-sdk/dist/chunk-CZ4N5FJW.js
|
|
223670
224050
|
function zeroTotals() {
|
|
223671
224051
|
return {
|
|
223672
224052
|
session_count: 0,
|
|
@@ -224026,12 +224406,12 @@ function handleGetApiMetrics(request2) {
|
|
|
224026
224406
|
});
|
|
224027
224407
|
}
|
|
224028
224408
|
var BUCKET_MS, TOP_N, MAX_POINTS_PER_SERIES, MAX_TOTAL_CELLS;
|
|
224029
|
-
var
|
|
224030
|
-
"../agent-sdk/dist/chunk-
|
|
224409
|
+
var init_chunk_CZ4N5FJW = __esm({
|
|
224410
|
+
"../agent-sdk/dist/chunk-CZ4N5FJW.js"() {
|
|
224031
224411
|
"use strict";
|
|
224032
224412
|
init_chunk_23UKWXJH();
|
|
224033
224413
|
init_chunk_2N2KL4KM();
|
|
224034
|
-
|
|
224414
|
+
init_chunk_4EKHW6VS();
|
|
224035
224415
|
init_chunk_D2XITRN6();
|
|
224036
224416
|
init_chunk_AGIXZFHQ();
|
|
224037
224417
|
init_chunk_EZYKRG4W();
|
|
@@ -224047,7 +224427,7 @@ var init_chunk_ROJCTM3K = __esm({
|
|
|
224047
224427
|
}
|
|
224048
224428
|
});
|
|
224049
224429
|
|
|
224050
|
-
// ../agent-sdk/dist/chunk-
|
|
224430
|
+
// ../agent-sdk/dist/chunk-JDAOTVWV.js
|
|
224051
224431
|
function handleListModels(request2) {
|
|
224052
224432
|
return routeWrap(request2, async ({ request: req }) => {
|
|
224053
224433
|
const url2 = new URL(req.url);
|
|
@@ -224058,11 +224438,11 @@ function handleListModels(request2) {
|
|
|
224058
224438
|
return jsonOk({ data: models });
|
|
224059
224439
|
});
|
|
224060
224440
|
}
|
|
224061
|
-
var
|
|
224062
|
-
"../agent-sdk/dist/chunk-
|
|
224441
|
+
var init_chunk_JDAOTVWV = __esm({
|
|
224442
|
+
"../agent-sdk/dist/chunk-JDAOTVWV.js"() {
|
|
224063
224443
|
"use strict";
|
|
224064
224444
|
init_chunk_UTGP4X74();
|
|
224065
|
-
|
|
224445
|
+
init_chunk_4EKHW6VS();
|
|
224066
224446
|
}
|
|
224067
224447
|
});
|
|
224068
224448
|
|
|
@@ -224085,7 +224465,7 @@ var init_chunk_IMJTHYN3 = __esm({
|
|
|
224085
224465
|
}
|
|
224086
224466
|
});
|
|
224087
224467
|
|
|
224088
|
-
// ../agent-sdk/dist/chunk-
|
|
224468
|
+
// ../agent-sdk/dist/chunk-3EI7IPMI.js
|
|
224089
224469
|
async function checkLocalProvider(name) {
|
|
224090
224470
|
try {
|
|
224091
224471
|
const provider = await resolveContainerProvider(name);
|
|
@@ -224124,10 +224504,10 @@ async function handleGetProviderStatus(request2) {
|
|
|
224124
224504
|
});
|
|
224125
224505
|
}
|
|
224126
224506
|
var LOCAL_PROVIDERS, CLOUD_PROVIDERS, CLOUD_KEY_MAP;
|
|
224127
|
-
var
|
|
224128
|
-
"../agent-sdk/dist/chunk-
|
|
224507
|
+
var init_chunk_3EI7IPMI = __esm({
|
|
224508
|
+
"../agent-sdk/dist/chunk-3EI7IPMI.js"() {
|
|
224129
224509
|
"use strict";
|
|
224130
|
-
|
|
224510
|
+
init_chunk_4EKHW6VS();
|
|
224131
224511
|
init_chunk_XLMNSDUJ();
|
|
224132
224512
|
init_chunk_6EIONZ7F();
|
|
224133
224513
|
LOCAL_PROVIDERS = ["docker", "apple-container", "podman"];
|
|
@@ -224143,7 +224523,7 @@ var init_chunk_W7MPHRTW = __esm({
|
|
|
224143
224523
|
}
|
|
224144
224524
|
});
|
|
224145
224525
|
|
|
224146
|
-
// ../agent-sdk/dist/chunk-
|
|
224526
|
+
// ../agent-sdk/dist/chunk-LR6FK2J7.js
|
|
224147
224527
|
function assertSessionTenant2(auth, sessionId) {
|
|
224148
224528
|
const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
|
|
224149
224529
|
if (row) {
|
|
@@ -224231,11 +224611,11 @@ function handleDeleteResource(request2, sessionId, resourceId) {
|
|
|
224231
224611
|
});
|
|
224232
224612
|
}
|
|
224233
224613
|
var MAX_RESOURCES_PER_SESSION, AddResourceSchema, UpdateResourceSchema;
|
|
224234
|
-
var
|
|
224235
|
-
"../agent-sdk/dist/chunk-
|
|
224614
|
+
var init_chunk_LR6FK2J7 = __esm({
|
|
224615
|
+
"../agent-sdk/dist/chunk-LR6FK2J7.js"() {
|
|
224236
224616
|
"use strict";
|
|
224237
224617
|
init_chunk_23UKWXJH();
|
|
224238
|
-
|
|
224618
|
+
init_chunk_4EKHW6VS();
|
|
224239
224619
|
init_chunk_DZKBUOYU();
|
|
224240
224620
|
init_chunk_ZC7OR65K();
|
|
224241
224621
|
init_chunk_GCT7A5KR();
|
|
@@ -224266,7 +224646,7 @@ var init_chunk_7XWAEIPU = __esm({
|
|
|
224266
224646
|
}
|
|
224267
224647
|
});
|
|
224268
224648
|
|
|
224269
|
-
// ../agent-sdk/dist/chunk-
|
|
224649
|
+
// ../agent-sdk/dist/chunk-6NFK5RJX.js
|
|
224270
224650
|
function maskSecret(value) {
|
|
224271
224651
|
if (!value) return "";
|
|
224272
224652
|
if (value.length <= 12) return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
@@ -224301,10 +224681,10 @@ function handleGetSetting(request2, key) {
|
|
|
224301
224681
|
});
|
|
224302
224682
|
}
|
|
224303
224683
|
var NON_SECRET_KEYS, ALLOWED_KEYS, SECRET_KEYS;
|
|
224304
|
-
var
|
|
224305
|
-
"../agent-sdk/dist/chunk-
|
|
224684
|
+
var init_chunk_6NFK5RJX = __esm({
|
|
224685
|
+
"../agent-sdk/dist/chunk-6NFK5RJX.js"() {
|
|
224306
224686
|
"use strict";
|
|
224307
|
-
|
|
224687
|
+
init_chunk_4EKHW6VS();
|
|
224308
224688
|
init_chunk_6EIONZ7F();
|
|
224309
224689
|
init_chunk_EZYKRG4W();
|
|
224310
224690
|
NON_SECRET_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -224346,7 +224726,7 @@ var init_chunk_K2YPC2GW = __esm({
|
|
|
224346
224726
|
}
|
|
224347
224727
|
});
|
|
224348
224728
|
|
|
224349
|
-
// ../agent-sdk/dist/chunk-
|
|
224729
|
+
// ../agent-sdk/dist/chunk-75US4UAE.js
|
|
224350
224730
|
import { inflateRawSync } from "zlib";
|
|
224351
224731
|
function extractFromZipRaw(buffer) {
|
|
224352
224732
|
const files2 = /* @__PURE__ */ new Map();
|
|
@@ -224525,12 +224905,12 @@ function handleDeleteSkillVersion(request2, skillId, version3) {
|
|
|
224525
224905
|
});
|
|
224526
224906
|
}
|
|
224527
224907
|
var TEXT_EXTENSIONS2, CreateSkillSchema, CreateVersionSchema;
|
|
224528
|
-
var
|
|
224529
|
-
"../agent-sdk/dist/chunk-
|
|
224908
|
+
var init_chunk_75US4UAE = __esm({
|
|
224909
|
+
"../agent-sdk/dist/chunk-75US4UAE.js"() {
|
|
224530
224910
|
"use strict";
|
|
224531
224911
|
init_chunk_TTDMQ54U();
|
|
224532
224912
|
init_chunk_23UKWXJH();
|
|
224533
|
-
|
|
224913
|
+
init_chunk_4EKHW6VS();
|
|
224534
224914
|
init_chunk_EZYKRG4W();
|
|
224535
224915
|
init_zod();
|
|
224536
224916
|
TEXT_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
@@ -224690,8 +225070,8 @@ __export(init_exports4, {
|
|
|
224690
225070
|
var init_init = __esm({
|
|
224691
225071
|
"../agent-sdk/dist/init.js"() {
|
|
224692
225072
|
"use strict";
|
|
224693
|
-
|
|
224694
|
-
|
|
225073
|
+
init_chunk_P7V3S2T3();
|
|
225074
|
+
init_chunk_KYKVHH7I();
|
|
224695
225075
|
init_chunk_PJZ5TQYW();
|
|
224696
225076
|
init_chunk_AU4NAQGA();
|
|
224697
225077
|
init_chunk_H6TQGV4L();
|
|
@@ -224706,10 +225086,10 @@ var init_init = __esm({
|
|
|
224706
225086
|
init_chunk_WK33IBKY();
|
|
224707
225087
|
init_chunk_3NUTTKE5();
|
|
224708
225088
|
init_chunk_3MQ2FWXS();
|
|
224709
|
-
|
|
224710
|
-
|
|
225089
|
+
init_chunk_ZACPJA3G();
|
|
225090
|
+
init_chunk_K3LM6O44();
|
|
224711
225091
|
init_chunk_LAWTTG2E();
|
|
224712
|
-
|
|
225092
|
+
init_chunk_ZCCHLDLC();
|
|
224713
225093
|
init_chunk_4XXQAVKE();
|
|
224714
225094
|
init_chunk_JNSJKHYX();
|
|
224715
225095
|
init_chunk_5ZFOKZGR();
|
|
@@ -224727,7 +225107,7 @@ var init_init = __esm({
|
|
|
224727
225107
|
init_chunk_G7KUVNDY();
|
|
224728
225108
|
init_chunk_6U6HEVSN();
|
|
224729
225109
|
init_chunk_YTBVILAH();
|
|
224730
|
-
|
|
225110
|
+
init_chunk_V5RHOS43();
|
|
224731
225111
|
init_chunk_J7F2OFWQ();
|
|
224732
225112
|
init_chunk_B6E6BVNK();
|
|
224733
225113
|
init_chunk_6SD6MC2B();
|
|
@@ -224746,25 +225126,25 @@ var init_init = __esm({
|
|
|
224746
225126
|
init_chunk_UY3VT3HQ();
|
|
224747
225127
|
init_chunk_PDWLVL34();
|
|
224748
225128
|
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();
|
|
225129
|
+
init_chunk_65XY7HRS();
|
|
224756
225130
|
init_chunk_TPMZO6S2();
|
|
224757
225131
|
init_chunk_M72ERPMT();
|
|
224758
225132
|
init_chunk_AQHYCRTO();
|
|
224759
|
-
init_chunk_KJ2GJLPQ();
|
|
224760
225133
|
init_chunk_7TSTCMII();
|
|
224761
|
-
|
|
225134
|
+
init_chunk_KJ2GJLPQ();
|
|
225135
|
+
init_chunk_IBYOMAZ3();
|
|
225136
|
+
init_chunk_WEUPM3IN();
|
|
225137
|
+
init_chunk_PJYCPDV5();
|
|
225138
|
+
init_chunk_SIO4LO2M();
|
|
224762
225139
|
init_chunk_NMZMRH3E();
|
|
224763
|
-
init_chunk_CULYZ3VA();
|
|
224764
225140
|
init_chunk_XJYR5HE3();
|
|
225141
|
+
init_chunk_CULYZ3VA();
|
|
225142
|
+
init_chunk_JN3DHH7Z();
|
|
225143
|
+
init_chunk_VRRGSQI7();
|
|
225144
|
+
init_chunk_D6RQPBRG();
|
|
225145
|
+
init_chunk_YJCH35J4();
|
|
224765
225146
|
init_chunk_YE2RMJY7();
|
|
224766
|
-
|
|
224767
|
-
init_chunk_SIO4LO2M();
|
|
225147
|
+
init_chunk_CY6AWCC6();
|
|
224768
225148
|
init_chunk_FX2AEKOV();
|
|
224769
225149
|
init_chunk_J6T3W6RY();
|
|
224770
225150
|
init_chunk_F4WUVOLE();
|
|
@@ -224781,7 +225161,7 @@ var init_init = __esm({
|
|
|
224781
225161
|
}
|
|
224782
225162
|
});
|
|
224783
225163
|
|
|
224784
|
-
// ../agent-sdk/dist/chunk-
|
|
225164
|
+
// ../agent-sdk/dist/chunk-6NEWWPL4.js
|
|
224785
225165
|
import { randomBytes } from "crypto";
|
|
224786
225166
|
function handleEnrollmentUrl(request2, profileId) {
|
|
224787
225167
|
return routeWrap(request2, async ({ auth }) => {
|
|
@@ -224945,11 +225325,11 @@ async function handleOAuthCallback(request2) {
|
|
|
224945
225325
|
}
|
|
224946
225326
|
}
|
|
224947
225327
|
var pendingEnrollments, EnrollmentSchema;
|
|
224948
|
-
var
|
|
224949
|
-
"../agent-sdk/dist/chunk-
|
|
225328
|
+
var init_chunk_6NEWWPL4 = __esm({
|
|
225329
|
+
"../agent-sdk/dist/chunk-6NEWWPL4.js"() {
|
|
224950
225330
|
"use strict";
|
|
224951
225331
|
init_chunk_23UKWXJH();
|
|
224952
|
-
|
|
225332
|
+
init_chunk_4EKHW6VS();
|
|
224953
225333
|
init_chunk_YOZ6WDP3();
|
|
224954
225334
|
init_chunk_WK33IBKY();
|
|
224955
225335
|
init_chunk_EZYKRG4W();
|
|
@@ -224977,7 +225357,7 @@ var init_chunk_I6WSRROX = __esm({
|
|
|
224977
225357
|
}
|
|
224978
225358
|
});
|
|
224979
225359
|
|
|
224980
|
-
// ../agent-sdk/dist/chunk-
|
|
225360
|
+
// ../agent-sdk/dist/chunk-VQM2MCQR.js
|
|
224981
225361
|
function assertFileTenantByScope(auth, scopeType, scopeId) {
|
|
224982
225362
|
if (!scopeId || scopeType !== "session") {
|
|
224983
225363
|
if (!auth.isGlobalAdmin) throw notFound("file not found");
|
|
@@ -225112,34 +225492,34 @@ function handleDeleteFile(request2, fileId) {
|
|
|
225112
225492
|
return jsonOk(result);
|
|
225113
225493
|
});
|
|
225114
225494
|
}
|
|
225115
|
-
var
|
|
225116
|
-
"../agent-sdk/dist/chunk-
|
|
225495
|
+
var init_chunk_VQM2MCQR = __esm({
|
|
225496
|
+
"../agent-sdk/dist/chunk-VQM2MCQR.js"() {
|
|
225117
225497
|
"use strict";
|
|
225118
225498
|
init_chunk_STPT3SWU();
|
|
225119
225499
|
init_chunk_YKPRNV6J();
|
|
225120
225500
|
init_chunk_23UKWXJH();
|
|
225121
|
-
|
|
225501
|
+
init_chunk_4EKHW6VS();
|
|
225122
225502
|
init_chunk_AGIXZFHQ();
|
|
225123
225503
|
init_chunk_EZYKRG4W();
|
|
225124
225504
|
init_client();
|
|
225125
225505
|
}
|
|
225126
225506
|
});
|
|
225127
225507
|
|
|
225128
|
-
// ../agent-sdk/dist/chunk-
|
|
225508
|
+
// ../agent-sdk/dist/chunk-FCPZF7KJ.js
|
|
225129
225509
|
function handleGetLicense(request2) {
|
|
225130
225510
|
return routeWrap(request2, async () => {
|
|
225131
225511
|
return jsonOk(getLicenseInfo());
|
|
225132
225512
|
});
|
|
225133
225513
|
}
|
|
225134
|
-
var
|
|
225135
|
-
"../agent-sdk/dist/chunk-
|
|
225514
|
+
var init_chunk_FCPZF7KJ = __esm({
|
|
225515
|
+
"../agent-sdk/dist/chunk-FCPZF7KJ.js"() {
|
|
225136
225516
|
"use strict";
|
|
225137
225517
|
init_chunk_2N2KL4KM();
|
|
225138
|
-
|
|
225518
|
+
init_chunk_4EKHW6VS();
|
|
225139
225519
|
}
|
|
225140
225520
|
});
|
|
225141
225521
|
|
|
225142
|
-
// ../agent-sdk/dist/chunk-
|
|
225522
|
+
// ../agent-sdk/dist/chunk-25E64UIV.js
|
|
225143
225523
|
function assertStoreTenant(auth, storeAgentId) {
|
|
225144
225524
|
if (storeAgentId == null) {
|
|
225145
225525
|
if (!auth.isGlobalAdmin) throw notFound("memory store not found");
|
|
@@ -225339,13 +225719,13 @@ function handleDreamMemoryStore(request2, storeId) {
|
|
|
225339
225719
|
});
|
|
225340
225720
|
}
|
|
225341
225721
|
var CreateStoreSchema, UpdateStoreSchema, CreateMemorySchema, UpdateMemorySchema, DreamRequestSchema, dreamCooldowns, DREAM_COOLDOWN_MS;
|
|
225342
|
-
var
|
|
225343
|
-
"../agent-sdk/dist/chunk-
|
|
225722
|
+
var init_chunk_25E64UIV = __esm({
|
|
225723
|
+
"../agent-sdk/dist/chunk-25E64UIV.js"() {
|
|
225344
225724
|
"use strict";
|
|
225345
225725
|
init_chunk_23UKWXJH();
|
|
225346
225726
|
init_chunk_IC2ETYU5();
|
|
225347
225727
|
init_chunk_TVV7AE3G();
|
|
225348
|
-
|
|
225728
|
+
init_chunk_4EKHW6VS();
|
|
225349
225729
|
init_chunk_6EIONZ7F();
|
|
225350
225730
|
init_chunk_AGIXZFHQ();
|
|
225351
225731
|
init_chunk_EZYKRG4W();
|
|
@@ -225380,7 +225760,7 @@ var init_chunk_5U2DDWTW = __esm({
|
|
|
225380
225760
|
}
|
|
225381
225761
|
});
|
|
225382
225762
|
|
|
225383
|
-
// ../agent-sdk/dist/chunk-
|
|
225763
|
+
// ../agent-sdk/dist/chunk-3LYNN5VT.js
|
|
225384
225764
|
function toView3(row) {
|
|
225385
225765
|
return row;
|
|
225386
225766
|
}
|
|
@@ -225551,13 +225931,13 @@ function handleGetApiKeyActivity(request2, id) {
|
|
|
225551
225931
|
});
|
|
225552
225932
|
}
|
|
225553
225933
|
var ScopeSchema, PermissionsSchema, CreateBody2, PatchBody3;
|
|
225554
|
-
var
|
|
225555
|
-
"../agent-sdk/dist/chunk-
|
|
225934
|
+
var init_chunk_3LYNN5VT = __esm({
|
|
225935
|
+
"../agent-sdk/dist/chunk-3LYNN5VT.js"() {
|
|
225556
225936
|
"use strict";
|
|
225557
225937
|
init_chunk_23UKWXJH();
|
|
225558
225938
|
init_chunk_FDLQ3IUB();
|
|
225559
225939
|
init_chunk_2N2KL4KM();
|
|
225560
|
-
|
|
225940
|
+
init_chunk_4EKHW6VS();
|
|
225561
225941
|
init_chunk_3NUTTKE5();
|
|
225562
225942
|
init_chunk_ZC7OR65K();
|
|
225563
225943
|
init_chunk_AGIXZFHQ();
|
|
@@ -225584,7 +225964,7 @@ var init_chunk_LW3AP2XF = __esm({
|
|
|
225584
225964
|
}
|
|
225585
225965
|
});
|
|
225586
225966
|
|
|
225587
|
-
// ../agent-sdk/dist/chunk-
|
|
225967
|
+
// ../agent-sdk/dist/chunk-GBBQD6VY.js
|
|
225588
225968
|
function parseMs2(v2) {
|
|
225589
225969
|
if (!v2) return void 0;
|
|
225590
225970
|
const n = Number(v2);
|
|
@@ -225631,18 +226011,18 @@ function handleListAudit(request2) {
|
|
|
225631
226011
|
});
|
|
225632
226012
|
}
|
|
225633
226013
|
var VALID_OUTCOMES;
|
|
225634
|
-
var
|
|
225635
|
-
"../agent-sdk/dist/chunk-
|
|
226014
|
+
var init_chunk_GBBQD6VY = __esm({
|
|
226015
|
+
"../agent-sdk/dist/chunk-GBBQD6VY.js"() {
|
|
225636
226016
|
"use strict";
|
|
225637
226017
|
init_chunk_23UKWXJH();
|
|
225638
226018
|
init_chunk_FDLQ3IUB();
|
|
225639
|
-
|
|
226019
|
+
init_chunk_4EKHW6VS();
|
|
225640
226020
|
init_chunk_EZYKRG4W();
|
|
225641
226021
|
VALID_OUTCOMES = /* @__PURE__ */ new Set(["success", "denied", "failure"]);
|
|
225642
226022
|
}
|
|
225643
226023
|
});
|
|
225644
226024
|
|
|
225645
|
-
// ../agent-sdk/dist/chunk-
|
|
226025
|
+
// ../agent-sdk/dist/chunk-HHLVVJGT.js
|
|
225646
226026
|
function handleBatch(request2) {
|
|
225647
226027
|
return routeWrap(request2, async () => {
|
|
225648
226028
|
const body = await request2.json();
|
|
@@ -225669,11 +226049,11 @@ function handleBatch(request2) {
|
|
|
225669
226049
|
});
|
|
225670
226050
|
}
|
|
225671
226051
|
var OperationSchema, BatchSchema2;
|
|
225672
|
-
var
|
|
225673
|
-
"../agent-sdk/dist/chunk-
|
|
226052
|
+
var init_chunk_HHLVVJGT = __esm({
|
|
226053
|
+
"../agent-sdk/dist/chunk-HHLVVJGT.js"() {
|
|
225674
226054
|
"use strict";
|
|
225675
226055
|
init_chunk_I2RVN7CP();
|
|
225676
|
-
|
|
226056
|
+
init_chunk_4EKHW6VS();
|
|
225677
226057
|
init_chunk_EZYKRG4W();
|
|
225678
226058
|
init_zod();
|
|
225679
226059
|
OperationSchema = external_exports.object({
|
|
@@ -225687,7 +226067,7 @@ var init_chunk_IJGOOH73 = __esm({
|
|
|
225687
226067
|
}
|
|
225688
226068
|
});
|
|
225689
226069
|
|
|
225690
|
-
// ../agent-sdk/dist/chunk-
|
|
226070
|
+
// ../agent-sdk/dist/chunk-GFZ2WIVH.js
|
|
225691
226071
|
function getVaultTenantId(id) {
|
|
225692
226072
|
const row = getDb().prepare(`SELECT tenant_id FROM vaults WHERE id = ?`).get(id);
|
|
225693
226073
|
return row?.tenant_id;
|
|
@@ -225826,11 +226206,11 @@ function handleDeleteEntry(request2, vaultId, key) {
|
|
|
225826
226206
|
});
|
|
225827
226207
|
}
|
|
225828
226208
|
var CreateVaultSchema, PutEntrySchema, UpdateVaultSchema;
|
|
225829
|
-
var
|
|
225830
|
-
"../agent-sdk/dist/chunk-
|
|
226209
|
+
var init_chunk_GFZ2WIVH = __esm({
|
|
226210
|
+
"../agent-sdk/dist/chunk-GFZ2WIVH.js"() {
|
|
225831
226211
|
"use strict";
|
|
225832
226212
|
init_chunk_23UKWXJH();
|
|
225833
|
-
|
|
226213
|
+
init_chunk_4EKHW6VS();
|
|
225834
226214
|
init_chunk_MUARVVXF();
|
|
225835
226215
|
init_chunk_6U6HEVSN();
|
|
225836
226216
|
init_chunk_AGIXZFHQ();
|
|
@@ -225862,7 +226242,7 @@ var init_chunk_MKPG7QMU = __esm({
|
|
|
225862
226242
|
}
|
|
225863
226243
|
});
|
|
225864
226244
|
|
|
225865
|
-
// ../agent-sdk/dist/chunk-
|
|
226245
|
+
// ../agent-sdk/dist/chunk-2R4IT7HG.js
|
|
225866
226246
|
function handleCreateCredential(request2, vaultId) {
|
|
225867
226247
|
return routeWrap(request2, async ({ auth }) => {
|
|
225868
226248
|
loadVaultForCaller(auth, vaultId);
|
|
@@ -226053,11 +226433,11 @@ function handleMcpOauthValidate(request2, vaultId, credentialId) {
|
|
|
226053
226433
|
});
|
|
226054
226434
|
}
|
|
226055
226435
|
var TokenEndpointAuthSchema, OAuthRefreshSchema, StaticBearerAuthSchema, McpOauthAuthSchema, CreateCredentialSchema, UpdateStaticBearerAuthSchema, UpdateMcpOauthAuthSchema, UpdateAuthSchema, UpdateCredentialSchema;
|
|
226056
|
-
var
|
|
226057
|
-
"../agent-sdk/dist/chunk-
|
|
226436
|
+
var init_chunk_2R4IT7HG = __esm({
|
|
226437
|
+
"../agent-sdk/dist/chunk-2R4IT7HG.js"() {
|
|
226058
226438
|
"use strict";
|
|
226059
|
-
|
|
226060
|
-
|
|
226439
|
+
init_chunk_GFZ2WIVH();
|
|
226440
|
+
init_chunk_4EKHW6VS();
|
|
226061
226441
|
init_chunk_WK33IBKY();
|
|
226062
226442
|
init_chunk_EZYKRG4W();
|
|
226063
226443
|
init_zod();
|
|
@@ -226130,10 +226510,12 @@ __export(handlers_exports, {
|
|
|
226130
226510
|
handleArchiveThread: () => handleArchiveThread,
|
|
226131
226511
|
handleArchiveVault: () => handleArchiveVault,
|
|
226132
226512
|
handleBatch: () => handleBatch,
|
|
226513
|
+
handleCancelInteraction: () => handleCancelInteraction,
|
|
226133
226514
|
handleCreateAgent: () => handleCreateAgent,
|
|
226134
226515
|
handleCreateApiKey: () => handleCreateApiKey,
|
|
226135
226516
|
handleCreateCredential: () => handleCreateCredential,
|
|
226136
226517
|
handleCreateEnvironment: () => handleCreateEnvironment,
|
|
226518
|
+
handleCreateGoogleAgent: () => handleCreateGoogleAgent,
|
|
226137
226519
|
handleCreateInteraction: () => handleCreateInteraction,
|
|
226138
226520
|
handleCreateMemory: () => handleCreateMemory,
|
|
226139
226521
|
handleCreateMemoryStore: () => handleCreateMemoryStore,
|
|
@@ -226148,6 +226530,8 @@ __export(handlers_exports, {
|
|
|
226148
226530
|
handleDeleteEntry: () => handleDeleteEntry,
|
|
226149
226531
|
handleDeleteEnvironment: () => handleDeleteEnvironment,
|
|
226150
226532
|
handleDeleteFile: () => handleDeleteFile,
|
|
226533
|
+
handleDeleteGoogleAgent: () => handleDeleteGoogleAgent,
|
|
226534
|
+
handleDeleteInteraction: () => handleDeleteInteraction,
|
|
226151
226535
|
handleDeleteMemory: () => handleDeleteMemory,
|
|
226152
226536
|
handleDeleteMemoryStore: () => handleDeleteMemoryStore,
|
|
226153
226537
|
handleDeleteResource: () => handleDeleteResource,
|
|
@@ -226167,8 +226551,11 @@ __export(handlers_exports, {
|
|
|
226167
226551
|
handleGetDocs: () => handleGetDocs,
|
|
226168
226552
|
handleGetEntry: () => handleGetEntry,
|
|
226169
226553
|
handleGetEnvironment: () => handleGetEnvironment,
|
|
226554
|
+
handleGetEnvironmentFiles: () => handleGetEnvironmentFiles,
|
|
226170
226555
|
handleGetFile: () => handleGetFile,
|
|
226171
226556
|
handleGetFileContent: () => handleGetFileContent,
|
|
226557
|
+
handleGetGoogleAgent: () => handleGetGoogleAgent,
|
|
226558
|
+
handleGetInteraction: () => handleGetInteraction,
|
|
226172
226559
|
handleGetLicense: () => handleGetLicense,
|
|
226173
226560
|
handleGetMemory: () => handleGetMemory,
|
|
226174
226561
|
handleGetMemoryStore: () => handleGetMemoryStore,
|
|
@@ -226205,6 +226592,7 @@ __export(handlers_exports, {
|
|
|
226205
226592
|
handleListEnvironments: () => handleListEnvironments,
|
|
226206
226593
|
handleListEvents: () => handleListEvents,
|
|
226207
226594
|
handleListFiles: () => handleListFiles,
|
|
226595
|
+
handleListGoogleAgents: () => handleListGoogleAgents,
|
|
226208
226596
|
handleListMemories: () => handleListMemories,
|
|
226209
226597
|
handleListMemoryStores: () => handleListMemoryStores,
|
|
226210
226598
|
handleListMemoryVersions: () => handleListMemoryVersions,
|
|
@@ -226253,43 +226641,45 @@ __export(handlers_exports, {
|
|
|
226253
226641
|
var init_handlers3 = __esm({
|
|
226254
226642
|
"../agent-sdk/dist/handlers/index.js"() {
|
|
226255
226643
|
"use strict";
|
|
226256
|
-
|
|
226257
|
-
|
|
226258
|
-
|
|
226259
|
-
|
|
226644
|
+
init_chunk_IYE5USSW();
|
|
226645
|
+
init_chunk_QZE37OGX();
|
|
226646
|
+
init_chunk_X7UWCDYG();
|
|
226647
|
+
init_chunk_SUEPFZN2();
|
|
226648
|
+
init_chunk_6CODFATQ();
|
|
226649
|
+
init_chunk_FHOJOLXU();
|
|
226260
226650
|
init_chunk_DF34ESOO();
|
|
226261
|
-
|
|
226262
|
-
|
|
226263
|
-
|
|
226264
|
-
|
|
226651
|
+
init_chunk_AD2WPGDN();
|
|
226652
|
+
init_chunk_XXAO5YYL();
|
|
226653
|
+
init_chunk_ZAUWB5DQ();
|
|
226654
|
+
init_chunk_3EWEKBVC();
|
|
226265
226655
|
init_chunk_3XGUMXGR();
|
|
226266
|
-
|
|
226267
|
-
|
|
226268
|
-
|
|
226269
|
-
|
|
226656
|
+
init_chunk_JIXRTWYL();
|
|
226657
|
+
init_chunk_ZHEE6UTX();
|
|
226658
|
+
init_chunk_CZ4N5FJW();
|
|
226659
|
+
init_chunk_JDAOTVWV();
|
|
226270
226660
|
init_chunk_UTGP4X74();
|
|
226271
226661
|
init_chunk_IMJTHYN3();
|
|
226272
|
-
|
|
226273
|
-
|
|
226274
|
-
|
|
226662
|
+
init_chunk_3EI7IPMI();
|
|
226663
|
+
init_chunk_LR6FK2J7();
|
|
226664
|
+
init_chunk_BSAF4YJB();
|
|
226275
226665
|
init_chunk_AUEKXYNE();
|
|
226276
|
-
|
|
226277
|
-
|
|
226666
|
+
init_chunk_6NFK5RJX();
|
|
226667
|
+
init_chunk_75US4UAE();
|
|
226278
226668
|
init_chunk_F27XQZ2O();
|
|
226279
|
-
|
|
226280
|
-
|
|
226281
|
-
|
|
226669
|
+
init_chunk_6NEWWPL4();
|
|
226670
|
+
init_chunk_LKHJLSYG();
|
|
226671
|
+
init_chunk_OEYLPPID();
|
|
226282
226672
|
init_chunk_HWWFRSAX();
|
|
226283
|
-
|
|
226284
|
-
|
|
226285
|
-
|
|
226673
|
+
init_chunk_VQM2MCQR();
|
|
226674
|
+
init_chunk_FCPZF7KJ();
|
|
226675
|
+
init_chunk_25E64UIV();
|
|
226286
226676
|
init_chunk_STPT3SWU();
|
|
226287
|
-
|
|
226288
|
-
|
|
226289
|
-
|
|
226290
|
-
|
|
226291
|
-
|
|
226292
|
-
|
|
226677
|
+
init_chunk_NQ6BN7WH();
|
|
226678
|
+
init_chunk_3LYNN5VT();
|
|
226679
|
+
init_chunk_GBBQD6VY();
|
|
226680
|
+
init_chunk_HHLVVJGT();
|
|
226681
|
+
init_chunk_2R4IT7HG();
|
|
226682
|
+
init_chunk_GFZ2WIVH();
|
|
226293
226683
|
init_chunk_Z5IENUYV();
|
|
226294
226684
|
init_chunk_UMXXZ6OX();
|
|
226295
226685
|
init_chunk_ABUNDZCE();
|
|
@@ -226310,14 +226700,14 @@ var init_handlers3 = __esm({
|
|
|
226310
226700
|
init_chunk_2N2KL4KM();
|
|
226311
226701
|
init_chunk_I2RVN7CP();
|
|
226312
226702
|
init_chunk_K5J4IN2S();
|
|
226313
|
-
|
|
226703
|
+
init_chunk_4EKHW6VS();
|
|
226314
226704
|
init_chunk_D2XITRN6();
|
|
226315
226705
|
init_chunk_CWB2DQN5();
|
|
226316
226706
|
init_chunk_JFHYXFAL();
|
|
226317
226707
|
init_chunk_W6WKXFHN();
|
|
226318
226708
|
init_chunk_HVUWXUUI();
|
|
226319
|
-
|
|
226320
|
-
|
|
226709
|
+
init_chunk_P7V3S2T3();
|
|
226710
|
+
init_chunk_KYKVHH7I();
|
|
226321
226711
|
init_chunk_PJZ5TQYW();
|
|
226322
226712
|
init_chunk_AU4NAQGA();
|
|
226323
226713
|
init_chunk_H6TQGV4L();
|
|
@@ -226332,10 +226722,10 @@ var init_handlers3 = __esm({
|
|
|
226332
226722
|
init_chunk_WK33IBKY();
|
|
226333
226723
|
init_chunk_3NUTTKE5();
|
|
226334
226724
|
init_chunk_3MQ2FWXS();
|
|
226335
|
-
|
|
226336
|
-
|
|
226725
|
+
init_chunk_ZACPJA3G();
|
|
226726
|
+
init_chunk_K3LM6O44();
|
|
226337
226727
|
init_chunk_LAWTTG2E();
|
|
226338
|
-
|
|
226728
|
+
init_chunk_ZCCHLDLC();
|
|
226339
226729
|
init_chunk_4XXQAVKE();
|
|
226340
226730
|
init_chunk_JNSJKHYX();
|
|
226341
226731
|
init_chunk_5ZFOKZGR();
|
|
@@ -226353,7 +226743,7 @@ var init_handlers3 = __esm({
|
|
|
226353
226743
|
init_chunk_G7KUVNDY();
|
|
226354
226744
|
init_chunk_6U6HEVSN();
|
|
226355
226745
|
init_chunk_YTBVILAH();
|
|
226356
|
-
|
|
226746
|
+
init_chunk_V5RHOS43();
|
|
226357
226747
|
init_chunk_J7F2OFWQ();
|
|
226358
226748
|
init_chunk_B6E6BVNK();
|
|
226359
226749
|
init_chunk_6SD6MC2B();
|
|
@@ -226372,25 +226762,25 @@ var init_handlers3 = __esm({
|
|
|
226372
226762
|
init_chunk_UY3VT3HQ();
|
|
226373
226763
|
init_chunk_PDWLVL34();
|
|
226374
226764
|
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();
|
|
226765
|
+
init_chunk_65XY7HRS();
|
|
226382
226766
|
init_chunk_TPMZO6S2();
|
|
226383
226767
|
init_chunk_M72ERPMT();
|
|
226384
226768
|
init_chunk_AQHYCRTO();
|
|
226385
|
-
init_chunk_KJ2GJLPQ();
|
|
226386
226769
|
init_chunk_7TSTCMII();
|
|
226387
|
-
|
|
226770
|
+
init_chunk_KJ2GJLPQ();
|
|
226771
|
+
init_chunk_IBYOMAZ3();
|
|
226772
|
+
init_chunk_WEUPM3IN();
|
|
226773
|
+
init_chunk_PJYCPDV5();
|
|
226774
|
+
init_chunk_SIO4LO2M();
|
|
226388
226775
|
init_chunk_NMZMRH3E();
|
|
226389
|
-
init_chunk_CULYZ3VA();
|
|
226390
226776
|
init_chunk_XJYR5HE3();
|
|
226777
|
+
init_chunk_CULYZ3VA();
|
|
226778
|
+
init_chunk_JN3DHH7Z();
|
|
226779
|
+
init_chunk_VRRGSQI7();
|
|
226780
|
+
init_chunk_D6RQPBRG();
|
|
226781
|
+
init_chunk_YJCH35J4();
|
|
226391
226782
|
init_chunk_YE2RMJY7();
|
|
226392
|
-
|
|
226393
|
-
init_chunk_SIO4LO2M();
|
|
226783
|
+
init_chunk_CY6AWCC6();
|
|
226394
226784
|
init_chunk_FX2AEKOV();
|
|
226395
226785
|
init_chunk_J6T3W6RY();
|
|
226396
226786
|
init_chunk_F4WUVOLE();
|
|
@@ -241006,6 +241396,14 @@ var init_src = __esm({
|
|
|
241006
241396
|
await next();
|
|
241007
241397
|
});
|
|
241008
241398
|
app.post("/google/v1beta/interactions", (c2) => handleCreateInteraction(c2.req.raw));
|
|
241399
|
+
app.get("/google/v1beta/interactions/:id", (c2) => handleGetInteraction(c2.req.raw, c2.req.param("id")));
|
|
241400
|
+
app.delete("/google/v1beta/interactions/:id", (c2) => handleDeleteInteraction(c2.req.raw, c2.req.param("id")));
|
|
241401
|
+
app.post("/google/v1beta/interactions/:id/cancel", (c2) => handleCancelInteraction(c2.req.raw, c2.req.param("id")));
|
|
241402
|
+
app.post("/google/v1beta/agents", (c2) => handleCreateGoogleAgent(c2.req.raw));
|
|
241403
|
+
app.get("/google/v1beta/agents", (c2) => handleListGoogleAgents(c2.req.raw));
|
|
241404
|
+
app.get("/google/v1beta/agents/:id", (c2) => handleGetGoogleAgent(c2.req.raw, c2.req.param("id")));
|
|
241405
|
+
app.delete("/google/v1beta/agents/:id", (c2) => handleDeleteGoogleAgent(c2.req.raw, c2.req.param("id")));
|
|
241406
|
+
app.get("/google/v1beta/files/:fileRef", (c2) => handleGetEnvironmentFiles(c2.req.raw, c2.req.param("fileRef")));
|
|
241009
241407
|
app.get("*", (c2) => {
|
|
241010
241408
|
const path13 = c2.req.path;
|
|
241011
241409
|
if (path13 === "/v1" || path13.startsWith("/v1/") || path13 === "/api" || path13.startsWith("/api/")) {
|