@jungjaehoon/mama-os 0.22.1 → 0.24.0
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/CHANGELOG.md +22 -0
- package/README.md +3 -1
- package/dist/agent/agent-loop.d.ts +3 -9
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +419 -216
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/code-act/constants.d.ts +2 -2
- package/dist/agent/code-act/constants.d.ts.map +1 -1
- package/dist/agent/code-act/constants.js +16 -9
- package/dist/agent/code-act/constants.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts +12 -11
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +92 -15
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/index.d.ts +2 -0
- package/dist/agent/code-act/index.d.ts.map +1 -1
- package/dist/agent/code-act/index.js +5 -1
- package/dist/agent/code-act/index.js.map +1 -1
- package/dist/agent/code-act/tool-policy.d.ts +42 -0
- package/dist/agent/code-act/tool-policy.d.ts.map +1 -0
- package/dist/agent/code-act/tool-policy.js +122 -0
- package/dist/agent/code-act/tool-policy.js.map +1 -0
- package/dist/agent/code-act/type-definition-generator.d.ts +4 -3
- package/dist/agent/code-act/type-definition-generator.d.ts.map +1 -1
- package/dist/agent/code-act/type-definition-generator.js +26 -48
- package/dist/agent/code-act/type-definition-generator.js.map +1 -1
- package/dist/agent/codex-app-server-process.d.ts +116 -0
- package/dist/agent/codex-app-server-process.d.ts.map +1 -0
- package/dist/agent/codex-app-server-process.js +1382 -0
- package/dist/agent/codex-app-server-process.js.map +1 -0
- package/dist/agent/codex-home.d.ts +9 -0
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +626 -4
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/codex-thread-registry.d.ts +63 -0
- package/dist/agent/codex-thread-registry.d.ts.map +1 -0
- package/dist/agent/codex-thread-registry.js +433 -0
- package/dist/agent/codex-thread-registry.js.map +1 -0
- package/dist/agent/gateway-tool-executor.d.ts +20 -7
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +254 -90
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +10 -5
- package/dist/agent/managed-agent-runtime-sync.d.ts.map +1 -1
- package/dist/agent/managed-agent-runtime-sync.js +0 -3
- package/dist/agent/managed-agent-runtime-sync.js.map +1 -1
- package/dist/agent/managed-agent-validation.js +1 -1
- package/dist/agent/managed-agent-validation.js.map +1 -1
- package/dist/agent/model-runner.d.ts +51 -3
- package/dist/agent/model-runner.d.ts.map +1 -1
- package/dist/agent/model-runner.js +1 -1
- package/dist/agent/model-runner.js.map +1 -1
- package/dist/agent/persistent-cli-adapter.d.ts +1 -0
- package/dist/agent/persistent-cli-adapter.d.ts.map +1 -1
- package/dist/agent/persistent-cli-adapter.js +3 -0
- package/dist/agent/persistent-cli-adapter.js.map +1 -1
- package/dist/agent/role-manager.d.ts +22 -1
- package/dist/agent/role-manager.d.ts.map +1 -1
- package/dist/agent/role-manager.js +39 -2
- package/dist/agent/role-manager.js.map +1 -1
- package/dist/agent/session-pool.d.ts +2 -2
- package/dist/agent/session-pool.d.ts.map +1 -1
- package/dist/agent/session-pool.js +6 -6
- package/dist/agent/session-pool.js.map +1 -1
- package/dist/agent/tool-registry.d.ts +14 -0
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +81 -12
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +49 -7
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/graph-api.d.ts.map +1 -1
- package/dist/api/graph-api.js +62 -40
- package/dist/api/graph-api.js.map +1 -1
- package/dist/api/operator-tasks-handler.d.ts.map +1 -1
- package/dist/api/operator-tasks-handler.js +6 -2
- package/dist/api/operator-tasks-handler.js.map +1 -1
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +22 -14
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +7 -4
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/start.d.ts +2 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +259 -23
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config/config-manager.d.ts +0 -5
- package/dist/cli/config/config-manager.d.ts.map +1 -1
- package/dist/cli/config/config-manager.js +78 -6
- package/dist/cli/config/config-manager.js.map +1 -1
- package/dist/cli/config/types.d.ts +4 -4
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +36 -0
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +106 -60
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +3 -0
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +226 -51
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/connector-init.d.ts.map +1 -1
- package/dist/cli/runtime/connector-init.js +13 -17
- package/dist/cli/runtime/connector-init.js.map +1 -1
- package/dist/cli/runtime/envelope-bootstrap.d.ts.map +1 -1
- package/dist/cli/runtime/envelope-bootstrap.js +13 -1
- package/dist/cli/runtime/envelope-bootstrap.js.map +1 -1
- package/dist/cli/runtime/gateway-init.d.ts +1 -1
- package/dist/cli/runtime/gateway-init.d.ts.map +1 -1
- package/dist/cli/runtime/gateway-init.js +5 -0
- package/dist/cli/runtime/gateway-init.js.map +1 -1
- package/dist/cli/runtime/mama-core-init.d.ts +2 -2
- package/dist/cli/runtime/mama-core-init.d.ts.map +1 -1
- package/dist/cli/runtime/mama-core-init.js +17 -0
- package/dist/cli/runtime/mama-core-init.js.map +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts.map +1 -1
- package/dist/cli/runtime/memory-agent-init.js +16 -6
- package/dist/cli/runtime/memory-agent-init.js.map +1 -1
- package/dist/cli/runtime/types.d.ts +4 -26
- package/dist/cli/runtime/types.d.ts.map +1 -1
- package/dist/cli/runtime/utilities.js +2 -2
- package/dist/cli/runtime/utilities.js.map +1 -1
- package/dist/connectors/config-loader.d.ts +24 -0
- package/dist/connectors/config-loader.d.ts.map +1 -0
- package/dist/connectors/config-loader.js +205 -0
- package/dist/connectors/config-loader.js.map +1 -0
- package/dist/connectors/framework/types.d.ts +2 -0
- package/dist/connectors/framework/types.d.ts.map +1 -1
- package/dist/connectors/kagemusha/query-tools.js +2 -2
- package/dist/connectors/kagemusha/query-tools.js.map +1 -1
- package/dist/envelope/reactive-config.d.ts +2 -2
- package/dist/envelope/reactive-config.d.ts.map +1 -1
- package/dist/envelope/reactive-config.js +36 -4
- package/dist/envelope/reactive-config.js.map +1 -1
- package/dist/gateways/context-injector.d.ts +2 -1
- package/dist/gateways/context-injector.d.ts.map +1 -1
- package/dist/gateways/context-injector.js.map +1 -1
- package/dist/gateways/message-router.d.ts +19 -1
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +179 -24
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/telegram.d.ts.map +1 -1
- package/dist/gateways/telegram.js +13 -0
- package/dist/gateways/telegram.js.map +1 -1
- package/dist/gateways/types.d.ts +4 -1
- package/dist/gateways/types.d.ts.map +1 -1
- package/dist/memory/history-extractor.d.ts +0 -24
- package/dist/memory/history-extractor.d.ts.map +1 -1
- package/dist/memory/history-extractor.js +0 -132
- package/dist/memory/history-extractor.js.map +1 -1
- package/dist/memory/save-candidate-extractor.d.ts +3 -0
- package/dist/memory/save-candidate-extractor.d.ts.map +1 -1
- package/dist/memory/save-candidate-extractor.js +12 -1
- package/dist/memory/save-candidate-extractor.js.map +1 -1
- package/dist/memory/secret-filter.d.ts +22 -0
- package/dist/memory/secret-filter.d.ts.map +1 -0
- package/dist/memory/secret-filter.js +77 -0
- package/dist/memory/secret-filter.js.map +1 -0
- package/dist/multi-agent/agent-process-manager.d.ts +9 -1
- package/dist/multi-agent/agent-process-manager.d.ts.map +1 -1
- package/dist/multi-agent/agent-process-manager.js +197 -49
- package/dist/multi-agent/agent-process-manager.js.map +1 -1
- package/dist/multi-agent/multi-agent-base.d.ts.map +1 -1
- package/dist/multi-agent/multi-agent-base.js +2 -1
- package/dist/multi-agent/multi-agent-base.js.map +1 -1
- package/dist/multi-agent/runtime-process.d.ts +18 -15
- package/dist/multi-agent/runtime-process.d.ts.map +1 -1
- package/dist/multi-agent/runtime-process.js +63 -59
- package/dist/multi-agent/runtime-process.js.map +1 -1
- package/dist/multi-agent/types.d.ts +13 -7
- package/dist/multi-agent/types.d.ts.map +1 -1
- package/dist/multi-agent/types.js.map +1 -1
- package/dist/multi-agent/workflow-engine.js +3 -3
- package/dist/multi-agent/workflow-engine.js.map +1 -1
- package/dist/multi-agent/workflow-types.d.ts +2 -2
- package/dist/multi-agent/workflow-types.d.ts.map +1 -1
- package/dist/observability/code-audit.d.ts +4 -0
- package/dist/observability/code-audit.d.ts.map +1 -1
- package/dist/observability/code-audit.js +69 -0
- package/dist/observability/code-audit.js.map +1 -1
- package/dist/operator/briefs.d.ts +26 -0
- package/dist/operator/briefs.d.ts.map +1 -0
- package/dist/operator/briefs.js +128 -0
- package/dist/operator/briefs.js.map +1 -0
- package/dist/operator/operator-trigger-loop.d.ts +27 -0
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +72 -12
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/report-carry.d.ts +29 -0
- package/dist/operator/report-carry.d.ts.map +1 -0
- package/dist/operator/report-carry.js +81 -0
- package/dist/operator/report-carry.js.map +1 -0
- package/dist/operator/report-run.d.ts +4 -4
- package/dist/operator/shadow-capture.d.ts +20 -0
- package/dist/operator/shadow-capture.d.ts.map +1 -0
- package/dist/operator/shadow-capture.js +34 -0
- package/dist/operator/shadow-capture.js.map +1 -0
- package/dist/operator/situation-report.d.ts +9 -0
- package/dist/operator/situation-report.d.ts.map +1 -1
- package/dist/operator/situation-report.js +56 -26
- package/dist/operator/situation-report.js.map +1 -1
- package/dist/operator/task-ledger.d.ts +90 -2
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +359 -23
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/trigger-author.d.ts +35 -1
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +73 -10
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/worker-run.d.ts +89 -0
- package/dist/operator/worker-run.d.ts.map +1 -0
- package/dist/operator/worker-run.js +127 -0
- package/dist/operator/worker-run.js.map +1 -0
- package/dist/operator/workorder-consumer.d.ts +121 -0
- package/dist/operator/workorder-consumer.d.ts.map +1 -0
- package/dist/operator/workorder-consumer.js +253 -0
- package/dist/operator/workorder-consumer.js.map +1 -0
- package/dist/operator/workorder-hooks.d.ts +30 -0
- package/dist/operator/workorder-hooks.d.ts.map +1 -0
- package/dist/operator/workorder-hooks.js +70 -0
- package/dist/operator/workorder-hooks.js.map +1 -0
- package/dist/operator/workorder-publishers.d.ts +68 -0
- package/dist/operator/workorder-publishers.d.ts.map +1 -0
- package/dist/operator/workorder-publishers.js +150 -0
- package/dist/operator/workorder-publishers.js.map +1 -0
- package/dist/security/security-monitor.d.ts +7 -0
- package/dist/security/security-monitor.d.ts.map +1 -1
- package/dist/security/security-monitor.js +17 -0
- package/dist/security/security-monitor.js.map +1 -1
- package/dist/setup/setup-prompt.d.ts +1 -1
- package/dist/setup/setup-prompt.d.ts.map +1 -1
- package/dist/setup/setup-prompt.js +4 -5
- package/dist/setup/setup-prompt.js.map +1 -1
- package/dist/utils/untrusted-content.d.ts +13 -0
- package/dist/utils/untrusted-content.d.ts.map +1 -1
- package/dist/utils/untrusted-content.js +43 -0
- package/dist/utils/untrusted-content.js.map +1 -1
- package/package.json +2 -2
- package/public/viewer/js/modules/agents.js +13 -9
- package/public/viewer/js/modules/settings.js +15 -10
- package/public/viewer/src/modules/agents.ts +12 -10
- package/public/viewer/src/modules/settings.ts +17 -12
- package/public/viewer/src/utils/api.ts +2 -2
- package/templates/AGENTS.codex.md +2 -23
- package/templates/personas/conductor.md +1 -1
- package/dist/agent/codex-mcp-process.d.ts +0 -105
- package/dist/agent/codex-mcp-process.d.ts.map +0 -1
- package/dist/agent/codex-mcp-process.js +0 -748
- package/dist/agent/codex-mcp-process.js.map +0 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - Blocked tools return permission errors instead of executing
|
|
11
11
|
* - Path-based tools (Read, Write) also check path permissions
|
|
12
12
|
*/
|
|
13
|
-
import type { GatewayToolName, GatewayToolInput, GatewayToolResult, GatewayToolExecutorOptions,
|
|
13
|
+
import type { GatewayToolName, GatewayToolInput, GatewayToolResult, GatewayToolExecutorOptions, MAMAApiSetInput, AgentContext, BotPlatform, GatewayToolExecutionContext, BeginModelRunInput, ModelRunRecord } from './types.js';
|
|
14
14
|
import type { AgentProcessManager } from '../multi-agent/agent-process-manager.js';
|
|
15
15
|
import type { DelegationManager } from '../multi-agent/delegation-manager.js';
|
|
16
16
|
import type { AgentEventBus } from '../multi-agent/agent-event-bus.js';
|
|
@@ -72,6 +72,9 @@ export declare class GatewayToolExecutor {
|
|
|
72
72
|
private currentChannelId;
|
|
73
73
|
private disallowedGatewayTools;
|
|
74
74
|
private reportPublisher;
|
|
75
|
+
private reportRequestHandler;
|
|
76
|
+
private workOrderRequestHandler;
|
|
77
|
+
private reportReader;
|
|
75
78
|
private wikiPublisher;
|
|
76
79
|
private wikiPublishAdapter;
|
|
77
80
|
private obsidianVaultPath;
|
|
@@ -118,6 +121,21 @@ export declare class GatewayToolExecutor {
|
|
|
118
121
|
private syncViewerToAgentDetail;
|
|
119
122
|
private resolveManagedAgentId;
|
|
120
123
|
setReportPublisher(fn: (slots: Record<string, string>) => void): void;
|
|
124
|
+
/** Forwarder hook for on-demand full reports (plan v6 S1-T3). */
|
|
125
|
+
setReportRequestHandler(fn: () => {
|
|
126
|
+
accepted: boolean;
|
|
127
|
+
reason?: string;
|
|
128
|
+
}): void;
|
|
129
|
+
/** Forwarder hook for owner-issued workorders (Stage-2 S2-T4; enqueue+ack only). */
|
|
130
|
+
setWorkOrderRequestHandler(fn: (kind: 'board' | 'wiki' | 'memory-curation') => {
|
|
131
|
+
accepted: boolean;
|
|
132
|
+
reason?: string;
|
|
133
|
+
}): void;
|
|
134
|
+
/** Read seam for the owner board slots (plan v6 S1-T4 artifact hub). */
|
|
135
|
+
setReportReader(fn: () => Record<string, {
|
|
136
|
+
html: string;
|
|
137
|
+
updatedAt?: string | null;
|
|
138
|
+
}>): void;
|
|
121
139
|
setWikiPublisher(fn: WikiPagePublisher): void;
|
|
122
140
|
setWikiPublishAdapter(adapter: WikiPublishAdapter | null): void;
|
|
123
141
|
/** Check if a memory agent is available for routing memory writes. */
|
|
@@ -148,7 +166,7 @@ export declare class GatewayToolExecutor {
|
|
|
148
166
|
setContextCompileService(service: GatewayToolExecutorOptions['contextCompileService']): void;
|
|
149
167
|
/** Wire the shared MAMA API built at boot (initMamaCore) so the executor never
|
|
150
168
|
* lazily constructs a second API/adapter stack against the same DB. */
|
|
151
|
-
setMamaApi(api:
|
|
169
|
+
setMamaApi(api: MAMAApiSetInput): void;
|
|
152
170
|
/**
|
|
153
171
|
* Initialize the MAMA API by importing from mcp-server package
|
|
154
172
|
* Called lazily on first tool execution if not provided in constructor
|
|
@@ -355,11 +373,6 @@ export declare class GatewayToolExecutor {
|
|
|
355
373
|
* Execute Obsidian CLI command on the wiki vault.
|
|
356
374
|
*/
|
|
357
375
|
private executeObsidian;
|
|
358
|
-
private resolveCodeActSandboxRole;
|
|
359
|
-
private normalizeCodeActToolPatterns;
|
|
360
|
-
private isKnownCodeActToolPattern;
|
|
361
|
-
private matchesAnyCodeActToolPattern;
|
|
362
|
-
private matchesCodeActToolPattern;
|
|
363
376
|
private executeCodeAct;
|
|
364
377
|
/**
|
|
365
378
|
* Handle mama_add — auto-extract facts from conversation content with derived memory scopes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-tool-executor.d.ts","sourceRoot":"","sources":["../../src/agent/gateway-tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"gateway-tool-executor.d.ts","sourceRoot":"","sources":["../../src/agent/gateway-tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAyBH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EASjB,0BAA0B,EAG1B,eAAe,EASf,YAAY,EASZ,WAAW,EAGX,2BAA2B,EAE3B,kBAAkB,EAClB,cAAc,EAEf,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AA0BnE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,i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 +59,7 @@ const util_1 = require("util");
|
|
|
59
59
|
const debugLogger = __importStar(require("@jungjaehoon/mama-core/debug-logger"));
|
|
60
60
|
const mama_core_1 = require("@jungjaehoon/mama-core");
|
|
61
61
|
const security_monitor_js_1 = require("../security/security-monitor.js");
|
|
62
|
+
const secret_filter_js_1 = require("../memory/secret-filter.js");
|
|
62
63
|
const scope_context_js_1 = require("../memory/scope-context.js");
|
|
63
64
|
const types_js_1 = require("./types.js");
|
|
64
65
|
const sqlite_js_1 = __importDefault(require("../sqlite.js"));
|
|
@@ -292,6 +293,9 @@ class GatewayToolExecutor {
|
|
|
292
293
|
currentChannelId = '';
|
|
293
294
|
disallowedGatewayTools = new Set();
|
|
294
295
|
reportPublisher = null;
|
|
296
|
+
reportRequestHandler = null;
|
|
297
|
+
workOrderRequestHandler = null;
|
|
298
|
+
reportReader = null;
|
|
295
299
|
wikiPublisher = null;
|
|
296
300
|
wikiPublishAdapter = null;
|
|
297
301
|
obsidianVaultPath = null;
|
|
@@ -374,8 +378,11 @@ class GatewayToolExecutor {
|
|
|
374
378
|
sourceMessageRef: executionContext?.sourceMessageRef,
|
|
375
379
|
modelRunId: executionContext?.modelRunId ?? null,
|
|
376
380
|
gatewayCallId: executionContext?.gatewayCallId,
|
|
381
|
+
signal: executionContext?.signal,
|
|
382
|
+
parentToolName: executionContext?.parentToolName,
|
|
377
383
|
backgroundTasks: executionContext?.backgroundTasks,
|
|
378
384
|
disallowedGatewayTools: executionContext?.disallowedGatewayTools,
|
|
385
|
+
reportPublisherOverride: executionContext?.reportPublisherOverride,
|
|
379
386
|
};
|
|
380
387
|
}
|
|
381
388
|
getExecutionState() {
|
|
@@ -405,10 +412,14 @@ class GatewayToolExecutor {
|
|
|
405
412
|
sourceMessageRef: active.sourceMessageRef ?? fallback.sourceMessageRef,
|
|
406
413
|
modelRunId: active.modelRunId ?? fallback.modelRunId,
|
|
407
414
|
gatewayCallId: active.gatewayCallId ?? fallback.gatewayCallId,
|
|
415
|
+
signal: active.signal,
|
|
408
416
|
parentToolName: active.parentToolName ?? fallback.parentToolName,
|
|
409
417
|
backgroundTasks: active.backgroundTasks ?? fallback.backgroundTasks,
|
|
410
418
|
// Never merged from fallback - blocks are strictly per-call.
|
|
411
419
|
disallowedGatewayTools: active.disallowedGatewayTools,
|
|
420
|
+
// Never merged from fallback - a lingering global capture override
|
|
421
|
+
// would swallow LIVE publishes (Stage-2 shadow seam).
|
|
422
|
+
reportPublisherOverride: active.reportPublisherOverride,
|
|
412
423
|
};
|
|
413
424
|
}
|
|
414
425
|
getActiveContext() {
|
|
@@ -533,6 +544,18 @@ class GatewayToolExecutor {
|
|
|
533
544
|
setReportPublisher(fn) {
|
|
534
545
|
this.reportPublisher = fn;
|
|
535
546
|
}
|
|
547
|
+
/** Forwarder hook for on-demand full reports (plan v6 S1-T3). */
|
|
548
|
+
setReportRequestHandler(fn) {
|
|
549
|
+
this.reportRequestHandler = fn;
|
|
550
|
+
}
|
|
551
|
+
/** Forwarder hook for owner-issued workorders (Stage-2 S2-T4; enqueue+ack only). */
|
|
552
|
+
setWorkOrderRequestHandler(fn) {
|
|
553
|
+
this.workOrderRequestHandler = fn;
|
|
554
|
+
}
|
|
555
|
+
/** Read seam for the owner board slots (plan v6 S1-T4 artifact hub). */
|
|
556
|
+
setReportReader(fn) {
|
|
557
|
+
this.reportReader = fn;
|
|
558
|
+
}
|
|
536
559
|
setWikiPublisher(fn) {
|
|
537
560
|
this.wikiPublisher = fn;
|
|
538
561
|
}
|
|
@@ -634,7 +657,35 @@ class GatewayToolExecutor {
|
|
|
634
657
|
/** Wire the shared MAMA API built at boot (initMamaCore) so the executor never
|
|
635
658
|
* lazily constructs a second API/adapter stack against the same DB. */
|
|
636
659
|
setMamaApi(api) {
|
|
637
|
-
|
|
660
|
+
const listDecisions = 'listDecisions' in api ? api.listDecisions : undefined;
|
|
661
|
+
if (typeof listDecisions === 'function') {
|
|
662
|
+
this.mamaApi = api;
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const list = 'list' in api ? api.list : undefined;
|
|
666
|
+
if (typeof list !== 'function') {
|
|
667
|
+
throw new Error('MAMA API must provide listDecisions() or list()');
|
|
668
|
+
}
|
|
669
|
+
const normalizedListDecisions = list.bind(api);
|
|
670
|
+
const boundMethods = new WeakMap();
|
|
671
|
+
this.mamaApi = new Proxy({}, {
|
|
672
|
+
get(_target, property) {
|
|
673
|
+
if (property === 'listDecisions') {
|
|
674
|
+
return normalizedListDecisions;
|
|
675
|
+
}
|
|
676
|
+
const value = Reflect.get(api, property, api);
|
|
677
|
+
if (typeof value !== 'function') {
|
|
678
|
+
return value;
|
|
679
|
+
}
|
|
680
|
+
const cached = boundMethods.get(value);
|
|
681
|
+
if (cached) {
|
|
682
|
+
return cached;
|
|
683
|
+
}
|
|
684
|
+
const bound = value.bind(api);
|
|
685
|
+
boundMethods.set(value, bound);
|
|
686
|
+
return bound;
|
|
687
|
+
},
|
|
688
|
+
});
|
|
638
689
|
}
|
|
639
690
|
/**
|
|
640
691
|
* Initialize the MAMA API by importing from mcp-server package
|
|
@@ -696,6 +747,12 @@ class GatewayToolExecutor {
|
|
|
696
747
|
// If no context set, allow all tools (backward compatibility)
|
|
697
748
|
const context = this.getActiveContext();
|
|
698
749
|
if (!context) {
|
|
750
|
+
if (toolName === 'code_act') {
|
|
751
|
+
return {
|
|
752
|
+
allowed: false,
|
|
753
|
+
error: 'Permission denied: code_act requires an active agent role',
|
|
754
|
+
};
|
|
755
|
+
}
|
|
699
756
|
return { allowed: true };
|
|
700
757
|
}
|
|
701
758
|
const role = context.role;
|
|
@@ -832,6 +889,7 @@ class GatewayToolExecutor {
|
|
|
832
889
|
}
|
|
833
890
|
const startedAt = Date.now();
|
|
834
891
|
const baseCtx = this.mergeWithFallbackExecutionContext(this.executionContextStorage.getStore());
|
|
892
|
+
baseCtx.signal?.throwIfAborted();
|
|
835
893
|
const gatewayCallId = baseCtx.gatewayCallId ?? `gw_${(0, crypto_1.randomUUID)().replace(/-/g, '')}`;
|
|
836
894
|
const ctx = { ...baseCtx, gatewayCallId };
|
|
837
895
|
const effectiveInput = this.applyEnvelopeScopedReadDefaults(toolName, input, ctx);
|
|
@@ -841,6 +899,7 @@ class GatewayToolExecutor {
|
|
|
841
899
|
let result;
|
|
842
900
|
try {
|
|
843
901
|
result = await this.executionContextStorage.run(activeCtx, () => this.executeWithEnvelopeAndPermissions(toolName, effectiveInput, gatewayCallId));
|
|
902
|
+
activeCtx.signal?.throwIfAborted();
|
|
844
903
|
}
|
|
845
904
|
catch (error) {
|
|
846
905
|
await this.appendToolTraceIfNeeded(traceState, activeCtx, toolName, undefined, Date.now() - startedAt, gatewayCallId, error).catch((appendError) => {
|
|
@@ -1254,6 +1313,7 @@ class GatewayToolExecutor {
|
|
|
1254
1313
|
}
|
|
1255
1314
|
}
|
|
1256
1315
|
async executeWithEnvelopeAndPermissions(toolName, input, gatewayCallId) {
|
|
1316
|
+
this.getExecutionState().signal?.throwIfAborted();
|
|
1257
1317
|
if (!VALID_TOOLS.includes(toolName)) {
|
|
1258
1318
|
throw new types_js_1.AgentError(`Unknown tool: ${toolName}. Valid tools: ${VALID_TOOLS.join(', ')}`, 'UNKNOWN_TOOL', undefined, false);
|
|
1259
1319
|
}
|
|
@@ -1564,6 +1624,18 @@ class GatewayToolExecutor {
|
|
|
1564
1624
|
switch (toolName) {
|
|
1565
1625
|
case 'mama_save': {
|
|
1566
1626
|
const saveInput = input;
|
|
1627
|
+
// Secret inviolability (plan v6 S1-T7): a secret saved as a
|
|
1628
|
+
// "decision" would resurface later via mama_search/recall - the one
|
|
1629
|
+
// leak path a chat-reachable tool has. Refuse loudly at the choke.
|
|
1630
|
+
const saveSecretScan = (0, secret_filter_js_1.scanMemoryWriteInput)(saveInput);
|
|
1631
|
+
if (!saveSecretScan.clean) {
|
|
1632
|
+
console.warn(`[Security] mama_save refused: secret-shaped content (${saveSecretScan.matches.join(', ')})`);
|
|
1633
|
+
return {
|
|
1634
|
+
success: false,
|
|
1635
|
+
code: 'secret_material_refused',
|
|
1636
|
+
error: `Refusing to save: content matches secret pattern(s): ${saveSecretScan.matches.join(', ')}. Secrets must never enter memory.`,
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1567
1639
|
const api = await getApi();
|
|
1568
1640
|
let trustedOptions;
|
|
1569
1641
|
let effectiveSaveInput = saveInput;
|
|
@@ -1631,17 +1703,45 @@ class GatewayToolExecutor {
|
|
|
1631
1703
|
return await this.handleMamaRecall(input);
|
|
1632
1704
|
case 'context_compile':
|
|
1633
1705
|
return await this.handleContextCompile(input);
|
|
1634
|
-
case 'mama_update':
|
|
1706
|
+
case 'mama_update': {
|
|
1707
|
+
const updateSecretScan = (0, secret_filter_js_1.scanMemoryWriteInput)(input);
|
|
1708
|
+
if (!updateSecretScan.clean) {
|
|
1709
|
+
console.warn(`[Security] mama_update refused: secret-shaped content (${updateSecretScan.matches.join(', ')})`);
|
|
1710
|
+
return {
|
|
1711
|
+
success: false,
|
|
1712
|
+
code: 'secret_material_refused',
|
|
1713
|
+
error: `Refusing to update: content matches secret pattern(s): ${updateSecretScan.matches.join(', ')}. Secrets must never enter memory.`,
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1635
1716
|
return await (0, mama_tool_handlers_js_1.handleUpdate)(await getApi(), input);
|
|
1717
|
+
}
|
|
1636
1718
|
case 'mama_load_checkpoint':
|
|
1637
1719
|
return await (0, mama_tool_handlers_js_1.handleLoadCheckpoint)(await getApi(), input);
|
|
1638
1720
|
case 'mama_add': {
|
|
1721
|
+
const addSecretScan = (0, secret_filter_js_1.scanMemoryWriteInput)(input);
|
|
1722
|
+
if (!addSecretScan.clean) {
|
|
1723
|
+
console.warn(`[Security] mama_add refused: secret-shaped content (${addSecretScan.matches.join(', ')})`);
|
|
1724
|
+
return {
|
|
1725
|
+
success: false,
|
|
1726
|
+
code: 'secret_material_refused',
|
|
1727
|
+
error: `Refusing to add: content matches secret pattern(s): ${addSecretScan.matches.join(', ')}. Secrets must never enter memory.`,
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1639
1730
|
const api = await getApi();
|
|
1640
1731
|
return await this.handleMamaAdd(input, this.supportsTrustedIngest(api)
|
|
1641
1732
|
? (await this.buildTrustedMemoryWriteOptions('mama_add', gatewayCallId)).options
|
|
1642
1733
|
: undefined);
|
|
1643
1734
|
}
|
|
1644
1735
|
case 'mama_ingest': {
|
|
1736
|
+
const ingestSecretScan = (0, secret_filter_js_1.scanMemoryWriteInput)(input);
|
|
1737
|
+
if (!ingestSecretScan.clean) {
|
|
1738
|
+
console.warn(`[Security] mama_ingest refused: secret-shaped content (${ingestSecretScan.matches.join(', ')})`);
|
|
1739
|
+
return {
|
|
1740
|
+
success: false,
|
|
1741
|
+
code: 'secret_material_refused',
|
|
1742
|
+
error: `Refusing to ingest: content matches secret pattern(s): ${ingestSecretScan.matches.join(', ')}. Secrets must never enter memory.`,
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1645
1745
|
const api = await getApi();
|
|
1646
1746
|
return await this.handleMamaIngest(input, this.supportsTrustedIngest(api)
|
|
1647
1747
|
? (await this.buildTrustedMemoryWriteOptions('mama_ingest', gatewayCallId)).options
|
|
@@ -1652,8 +1752,11 @@ class GatewayToolExecutor {
|
|
|
1652
1752
|
if (!slotsInput || typeof slotsInput !== 'object') {
|
|
1653
1753
|
throw new types_js_1.AgentError('report_publish requires slots object', 'TOOL_ERROR', undefined, false);
|
|
1654
1754
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1755
|
+
// Stage-2 shadow seam: a per-run capture override takes precedence
|
|
1756
|
+
// over the global singleton (capture runs never touch the live store).
|
|
1757
|
+
const activePublisher = this.getExecutionState().reportPublisherOverride ?? this.reportPublisher;
|
|
1758
|
+
if (activePublisher) {
|
|
1759
|
+
activePublisher(slotsInput);
|
|
1657
1760
|
const slotNames = Object.keys(slotsInput);
|
|
1658
1761
|
return {
|
|
1659
1762
|
success: true,
|
|
@@ -1662,6 +1765,111 @@ class GatewayToolExecutor {
|
|
|
1662
1765
|
}
|
|
1663
1766
|
throw new types_js_1.AgentError('Report publisher not configured', 'TOOL_ERROR', undefined, false);
|
|
1664
1767
|
}
|
|
1768
|
+
case 'report_request': {
|
|
1769
|
+
// Owner intent -> the REAL report machinery. Fire-and-forget: the
|
|
1770
|
+
// report runs on the operator lane and is delivered by the owner
|
|
1771
|
+
// leg; awaiting ~260s here would block the chat turn (and the plan
|
|
1772
|
+
// bans nested awaited lane runs).
|
|
1773
|
+
if (!this.reportRequestHandler) {
|
|
1774
|
+
return {
|
|
1775
|
+
success: false,
|
|
1776
|
+
code: 'report_leg_disabled',
|
|
1777
|
+
error: 'Full-report machinery is not enabled (trigger loop off or report channel unset). ' +
|
|
1778
|
+
'The scheduled report legs are inactive on this deployment.',
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
const started = this.reportRequestHandler();
|
|
1782
|
+
if (!started.accepted) {
|
|
1783
|
+
return {
|
|
1784
|
+
success: false,
|
|
1785
|
+
code: `report_${started.reason ?? 'unavailable'}`,
|
|
1786
|
+
error: started.reason === 'busy'
|
|
1787
|
+
? 'The operator lane is busy (a report or tick is in progress). Retry shortly.'
|
|
1788
|
+
: 'Report machinery unavailable (no output sink).',
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
return {
|
|
1792
|
+
success: true,
|
|
1793
|
+
message: 'Full report started. It will be generated fresh (delta-anchored) and delivered to the owner channel - tell the owner it is on its way; do not fabricate its contents.',
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1796
|
+
case 'workorder_request': {
|
|
1797
|
+
// Owner intent -> a priority workorder. Enqueue + ack ONLY - the
|
|
1798
|
+
// run happens on the operator lane later; awaiting it here would
|
|
1799
|
+
// block the chat turn (plan B6: issue tools are enqueue+ack only).
|
|
1800
|
+
const requestedKind = input.kind;
|
|
1801
|
+
if (requestedKind !== 'board' &&
|
|
1802
|
+
requestedKind !== 'wiki' &&
|
|
1803
|
+
requestedKind !== 'memory-curation') {
|
|
1804
|
+
return {
|
|
1805
|
+
success: false,
|
|
1806
|
+
code: 'invalid_workorder_kind',
|
|
1807
|
+
error: `kind must be one of board|wiki|memory-curation, got: ${String(requestedKind)}`,
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
if (!this.workOrderRequestHandler) {
|
|
1811
|
+
return {
|
|
1812
|
+
success: false,
|
|
1813
|
+
code: 'workorder_machinery_disabled',
|
|
1814
|
+
error: 'Stage-2 workorders are not enabled on this deployment (MAMA_STAGE2_WORKORDERS=off).',
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
const enqueued = this.workOrderRequestHandler(requestedKind);
|
|
1818
|
+
if (!enqueued.accepted) {
|
|
1819
|
+
return {
|
|
1820
|
+
success: false,
|
|
1821
|
+
code: `workorder_${enqueued.reason ?? 'unavailable'}`,
|
|
1822
|
+
error: `Workorder enqueue failed: ${enqueued.reason ?? 'unknown'}`,
|
|
1823
|
+
};
|
|
1824
|
+
}
|
|
1825
|
+
return {
|
|
1826
|
+
success: true,
|
|
1827
|
+
message: 'Workorder enqueued at priority high. It will run on the operator lane shortly - tell the owner it is queued; do not wait for it or fabricate its result.',
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
case 'workorder_status': {
|
|
1831
|
+
if (!this.taskLedger) {
|
|
1832
|
+
return {
|
|
1833
|
+
success: false,
|
|
1834
|
+
code: 'ledger_unavailable',
|
|
1835
|
+
error: 'Task ledger is not wired on this deployment.',
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
return { success: true, data: { kinds: this.taskLedger.workOrderStats() } };
|
|
1839
|
+
}
|
|
1840
|
+
case 'board_read': {
|
|
1841
|
+
if (!this.reportReader) {
|
|
1842
|
+
return {
|
|
1843
|
+
success: false,
|
|
1844
|
+
code: 'board_unavailable',
|
|
1845
|
+
error: 'Report store not wired (board_read requires the API server report store).',
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
const slots = this.reportReader();
|
|
1849
|
+
return { success: true, slots };
|
|
1850
|
+
}
|
|
1851
|
+
case 'audit_findings_read': {
|
|
1852
|
+
const auditStatePath = (0, path_1.join)(process.env.HOME || (0, os_1.homedir)(), '.mama', 'state', 'audit-findings.json');
|
|
1853
|
+
try {
|
|
1854
|
+
const raw = (0, fs_1.readFileSync)(auditStatePath, 'utf8');
|
|
1855
|
+
return { success: true, findings: JSON.parse(raw) };
|
|
1856
|
+
}
|
|
1857
|
+
catch (error) {
|
|
1858
|
+
const code = error.code;
|
|
1859
|
+
if (code === 'ENOENT') {
|
|
1860
|
+
return {
|
|
1861
|
+
success: true,
|
|
1862
|
+
findings: null,
|
|
1863
|
+
message: 'No audit findings recorded yet (first audit has not run).',
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
return {
|
|
1867
|
+
success: false,
|
|
1868
|
+
code: 'audit_state_unreadable',
|
|
1869
|
+
error: `Failed to read audit findings: ${error instanceof Error ? error.message : String(error)}`,
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1665
1873
|
case 'wiki_publish': {
|
|
1666
1874
|
const pagesInput = input.pages;
|
|
1667
1875
|
if (!pagesInput || !Array.isArray(pagesInput)) {
|
|
@@ -1696,7 +1904,15 @@ class GatewayToolExecutor {
|
|
|
1696
1904
|
case 'kagemusha_tasks': {
|
|
1697
1905
|
const { queryTasks } = await import('../connectors/kagemusha/query-tools.js');
|
|
1698
1906
|
const taskInput = input;
|
|
1699
|
-
|
|
1907
|
+
// Vocabulary annotation (Stage-2 S2-T7): this source's status set
|
|
1908
|
+
// differs from the native ledger's - an empty result for an
|
|
1909
|
+
// out-of-vocabulary status (e.g. 'blocked') is a vocabulary miss,
|
|
1910
|
+
// not evidence the work disappeared. Observe-only.
|
|
1911
|
+
return {
|
|
1912
|
+
success: true,
|
|
1913
|
+
tasks: queryTasks(taskInput),
|
|
1914
|
+
vocabularyNote: "Statuses in this source: pending|in_progress|review|done|completed|cancelled|dismissed|active. 'blocked' does NOT exist here - if memory mentions blocked work, compare vocabularies instead of reporting a contradiction.",
|
|
1915
|
+
};
|
|
1700
1916
|
}
|
|
1701
1917
|
case 'kagemusha_messages': {
|
|
1702
1918
|
const { queryMessages } = await import('../connectors/kagemusha/query-tools.js');
|
|
@@ -2386,8 +2602,10 @@ class GatewayToolExecutor {
|
|
|
2386
2602
|
config.roles.sourceMapping[mapSource] = role;
|
|
2387
2603
|
}
|
|
2388
2604
|
await (0, config_manager_js_1.saveConfig)(config);
|
|
2389
|
-
// Update RoleManager with new config
|
|
2605
|
+
// Update RoleManager with new config (trust anchor included: telegram
|
|
2606
|
+
// allowed_chats may have changed alongside roles in the saved config)
|
|
2390
2607
|
this.roleManager.updateRolesConfig(config.roles);
|
|
2608
|
+
this.roleManager.setTelegramTrust(config.telegram?.allowed_chats);
|
|
2391
2609
|
return {
|
|
2392
2610
|
success: true,
|
|
2393
2611
|
message: `Role "${role}" updated successfully.${mapSource ? ` Source "${mapSource}" now maps to this role.` : ''}`,
|
|
@@ -2511,8 +2729,9 @@ class GatewayToolExecutor {
|
|
|
2511
2729
|
config.roles.definitions[role].maxTurns = maxTurns;
|
|
2512
2730
|
}
|
|
2513
2731
|
await (0, config_manager_js_1.saveConfig)(config);
|
|
2514
|
-
// Update RoleManager with new config
|
|
2732
|
+
// Update RoleManager with new config (trust anchor included)
|
|
2515
2733
|
this.roleManager.updateRolesConfig(config.roles);
|
|
2734
|
+
this.roleManager.setTelegramTrust(config.telegram?.allowed_chats);
|
|
2516
2735
|
const changes = [`model: ${model}`];
|
|
2517
2736
|
if (maxTurns !== undefined)
|
|
2518
2737
|
changes.push(`maxTurns: ${maxTurns}`);
|
|
@@ -3000,95 +3219,39 @@ class GatewayToolExecutor {
|
|
|
3000
3219
|
};
|
|
3001
3220
|
}
|
|
3002
3221
|
}
|
|
3003
|
-
resolveCodeActSandboxRole(input, activeRole, registryNames) {
|
|
3004
|
-
const allowedResolution = this.normalizeCodeActToolPatterns(input.allowedTools, 'allowedTools', registryNames);
|
|
3005
|
-
if (allowedResolution.error) {
|
|
3006
|
-
return { error: allowedResolution.error };
|
|
3007
|
-
}
|
|
3008
|
-
const blockedResolution = this.normalizeCodeActToolPatterns(input.blockedTools, 'blockedTools', registryNames);
|
|
3009
|
-
if (blockedResolution.error) {
|
|
3010
|
-
return { error: blockedResolution.error };
|
|
3011
|
-
}
|
|
3012
|
-
if (!activeRole && !allowedResolution.patterns && !blockedResolution.patterns) {
|
|
3013
|
-
return {};
|
|
3014
|
-
}
|
|
3015
|
-
let effectiveToolNames = activeRole
|
|
3016
|
-
? registryNames.filter((toolName) => this.roleManager.isToolAllowed(activeRole, toolName))
|
|
3017
|
-
: [...registryNames];
|
|
3018
|
-
const allowedPatterns = allowedResolution.patterns;
|
|
3019
|
-
if (allowedPatterns) {
|
|
3020
|
-
effectiveToolNames = effectiveToolNames.filter((toolName) => this.matchesAnyCodeActToolPattern(toolName, allowedPatterns));
|
|
3021
|
-
}
|
|
3022
|
-
const blockedPatterns = blockedResolution.patterns;
|
|
3023
|
-
if (blockedPatterns) {
|
|
3024
|
-
effectiveToolNames = effectiveToolNames.filter((toolName) => !this.matchesAnyCodeActToolPattern(toolName, blockedPatterns));
|
|
3025
|
-
}
|
|
3026
|
-
return {
|
|
3027
|
-
role: {
|
|
3028
|
-
...activeRole,
|
|
3029
|
-
allowedTools: effectiveToolNames,
|
|
3030
|
-
blockedTools: undefined,
|
|
3031
|
-
allowedPaths: activeRole?.allowedPaths ?? [],
|
|
3032
|
-
systemControl: activeRole?.systemControl ?? false,
|
|
3033
|
-
sensitiveAccess: activeRole?.sensitiveAccess ?? false,
|
|
3034
|
-
},
|
|
3035
|
-
};
|
|
3036
|
-
}
|
|
3037
|
-
normalizeCodeActToolPatterns(value, fieldName, registryNames) {
|
|
3038
|
-
if (value === undefined) {
|
|
3039
|
-
return {};
|
|
3040
|
-
}
|
|
3041
|
-
if (!Array.isArray(value)) {
|
|
3042
|
-
return { error: `${fieldName} must be an array of gateway tool names.` };
|
|
3043
|
-
}
|
|
3044
|
-
const patterns = [];
|
|
3045
|
-
const seen = new Set();
|
|
3046
|
-
for (const item of value) {
|
|
3047
|
-
if (typeof item !== 'string' || item.trim().length === 0) {
|
|
3048
|
-
return { error: `${fieldName} must contain non-empty gateway tool names.` };
|
|
3049
|
-
}
|
|
3050
|
-
const pattern = item.trim();
|
|
3051
|
-
if (seen.has(pattern)) {
|
|
3052
|
-
continue;
|
|
3053
|
-
}
|
|
3054
|
-
if (!this.isKnownCodeActToolPattern(pattern, registryNames)) {
|
|
3055
|
-
return { error: `Unknown Code-Act tool pattern in ${fieldName}: ${pattern}` };
|
|
3056
|
-
}
|
|
3057
|
-
seen.add(pattern);
|
|
3058
|
-
patterns.push(pattern);
|
|
3059
|
-
}
|
|
3060
|
-
return { patterns };
|
|
3061
|
-
}
|
|
3062
|
-
isKnownCodeActToolPattern(pattern, registryNames) {
|
|
3063
|
-
return (pattern === '*' ||
|
|
3064
|
-
registryNames.some((toolName) => this.matchesCodeActToolPattern(toolName, pattern)));
|
|
3065
|
-
}
|
|
3066
|
-
matchesAnyCodeActToolPattern(toolName, patterns) {
|
|
3067
|
-
return patterns.some((pattern) => this.matchesCodeActToolPattern(toolName, pattern));
|
|
3068
|
-
}
|
|
3069
|
-
matchesCodeActToolPattern(toolName, pattern) {
|
|
3070
|
-
return this.roleManager.isToolAllowed({
|
|
3071
|
-
allowedTools: [pattern],
|
|
3072
|
-
allowedPaths: [],
|
|
3073
|
-
systemControl: false,
|
|
3074
|
-
sensitiveAccess: false,
|
|
3075
|
-
}, toolName);
|
|
3076
|
-
}
|
|
3077
3222
|
async executeCodeAct(input) {
|
|
3078
|
-
const { CodeActSandbox, HostBridge } = await import('./code-act/index.js');
|
|
3223
|
+
const { CodeActSandbox, CodeActToolPolicyValidationError, HostBridge, projectCodeActToolPolicy, } = await import('./code-act/index.js');
|
|
3079
3224
|
const sandbox = new CodeActSandbox();
|
|
3080
|
-
const
|
|
3081
|
-
const
|
|
3082
|
-
const
|
|
3083
|
-
|
|
3084
|
-
|
|
3225
|
+
const state = this.getExecutionState();
|
|
3226
|
+
const contextTier = state.agentContext?.tier;
|
|
3227
|
+
const tier = contextTier === undefined ? 1 : contextTier;
|
|
3228
|
+
let policy;
|
|
3229
|
+
try {
|
|
3230
|
+
policy = projectCodeActToolPolicy({
|
|
3231
|
+
tier,
|
|
3232
|
+
role: state.agentContext?.role,
|
|
3233
|
+
disallowedTools: state.disallowedGatewayTools,
|
|
3234
|
+
requestedAllowedTools: input.allowedTools,
|
|
3235
|
+
requestedBlockedTools: input.blockedTools,
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
catch (error) {
|
|
3239
|
+
if (!(error instanceof CodeActToolPolicyValidationError)) {
|
|
3240
|
+
throw error;
|
|
3241
|
+
}
|
|
3085
3242
|
return {
|
|
3086
3243
|
success: false,
|
|
3087
|
-
error:
|
|
3244
|
+
error: error.message,
|
|
3088
3245
|
};
|
|
3089
3246
|
}
|
|
3090
|
-
const
|
|
3091
|
-
|
|
3247
|
+
const nestedExecutionContext = {
|
|
3248
|
+
...state,
|
|
3249
|
+
agentContext: state.agentContext ?? undefined,
|
|
3250
|
+
executionSurface: 'code_act',
|
|
3251
|
+
parentToolName: 'code_act',
|
|
3252
|
+
};
|
|
3253
|
+
const bridge = new HostBridge(this, this.roleManager, nestedExecutionContext);
|
|
3254
|
+
bridge.injectInto(sandbox, policy.names);
|
|
3092
3255
|
const result = await sandbox.execute(input.code);
|
|
3093
3256
|
return {
|
|
3094
3257
|
success: result.success,
|
|
@@ -3265,6 +3428,7 @@ class GatewayToolExecutor {
|
|
|
3265
3428
|
envelope: ctx.envelope,
|
|
3266
3429
|
modelRunId: ctx.modelRunId ?? null,
|
|
3267
3430
|
input,
|
|
3431
|
+
signal: ctx.signal,
|
|
3268
3432
|
});
|
|
3269
3433
|
return {
|
|
3270
3434
|
success: true,
|