@jungjaehoon/mama-os 0.48.4 → 0.49.1
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/agent/agent-loop.d.ts +6 -7
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +106 -80
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +7 -9
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +3 -1
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/gateway-tool-executor.d.ts +0 -16
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +0 -51
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +1 -2
- package/dist/agent/os-agent-capabilities.md +14 -34
- package/dist/agent/role-manager.d.ts.map +1 -1
- package/dist/agent/role-manager.js +6 -3
- package/dist/agent/role-manager.js.map +1 -1
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +27 -8
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +20 -6
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/graph-api-types.d.ts +0 -18
- package/dist/api/graph-api-types.d.ts.map +1 -1
- package/dist/api/graph-api.d.ts.map +1 -1
- package/dist/api/graph-api.js +9 -81
- package/dist/api/graph-api.js.map +1 -1
- package/dist/cli/commands/start.d.ts +7 -16
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +188 -189
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +11 -4
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +31 -11
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +0 -2
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +9 -95
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/api-server-init.d.ts +2 -2
- package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-server-init.js +2 -2
- package/dist/cli/runtime/api-server-init.js.map +1 -1
- package/dist/cli/runtime/scheduler-init.d.ts +3 -4
- package/dist/cli/runtime/scheduler-init.d.ts.map +1 -1
- package/dist/cli/runtime/scheduler-init.js +6 -16
- package/dist/cli/runtime/scheduler-init.js.map +1 -1
- package/dist/cli/runtime/shutdown.d.ts +0 -1
- package/dist/cli/runtime/shutdown.d.ts.map +1 -1
- package/dist/cli/runtime/shutdown.js +1 -1
- package/dist/cli/runtime/shutdown.js.map +1 -1
- package/dist/cli/runtime/types.d.ts +0 -5
- package/dist/cli/runtime/types.d.ts.map +1 -1
- package/dist/concurrency/lane-manager.d.ts +1 -1
- package/dist/concurrency/lane-manager.d.ts.map +1 -1
- package/dist/concurrency/lane-manager.js +4 -2
- package/dist/concurrency/lane-manager.js.map +1 -1
- package/dist/concurrency/types.d.ts +4 -0
- package/dist/concurrency/types.d.ts.map +1 -1
- package/dist/concurrency/types.js.map +1 -1
- package/dist/envelope/types.d.ts +1 -1
- package/dist/envelope/types.d.ts.map +1 -1
- package/dist/envelope/types.js.map +1 -1
- package/dist/gateways/message-router.d.ts +15 -71
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +124 -493
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/session-store.d.ts +3 -23
- package/dist/gateways/session-store.d.ts.map +1 -1
- package/dist/gateways/session-store.js +2 -64
- package/dist/gateways/session-store.js.map +1 -1
- package/dist/gateways/telegram-report-context-store.d.ts +4 -66
- package/dist/gateways/telegram-report-context-store.d.ts.map +1 -1
- package/dist/gateways/telegram-report-context-store.js +11 -235
- package/dist/gateways/telegram-report-context-store.js.map +1 -1
- package/dist/gateways/turn-contract.d.ts +7 -3
- package/dist/gateways/turn-contract.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.d.ts +1 -12
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +6 -40
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/owner-event-loop.d.ts +9 -8
- package/dist/operator/owner-event-loop.d.ts.map +1 -1
- package/dist/operator/owner-event-loop.js +8 -22
- package/dist/operator/owner-event-loop.js.map +1 -1
- package/dist/operator/owner-event-policy.d.ts.map +1 -1
- package/dist/operator/owner-event-policy.js +0 -2
- package/dist/operator/owner-event-policy.js.map +1 -1
- package/dist/operator/owner-event-prompt.d.ts +0 -2
- package/dist/operator/owner-event-prompt.d.ts.map +1 -1
- package/dist/operator/owner-event-prompt.js +1 -8
- package/dist/operator/owner-event-prompt.js.map +1 -1
- package/dist/operator/owner-runtime-journal.d.ts +21 -0
- package/dist/operator/owner-runtime-journal.d.ts.map +1 -0
- package/dist/operator/owner-runtime-journal.js +131 -0
- package/dist/operator/owner-runtime-journal.js.map +1 -0
- package/dist/operator/owner-runtime.d.ts +32 -0
- package/dist/operator/owner-runtime.d.ts.map +1 -0
- package/dist/operator/owner-runtime.js +31 -0
- package/dist/operator/owner-runtime.js.map +1 -0
- package/dist/operator/pending-report-store.d.ts +2 -2
- package/dist/operator/pending-report-store.d.ts.map +1 -1
- package/dist/operator/pending-report-store.js +4 -1
- package/dist/operator/pending-report-store.js.map +1 -1
- package/dist/operator/report-run.d.ts +7 -10
- package/dist/operator/report-run.d.ts.map +1 -1
- package/dist/operator/report-run.js +5 -26
- package/dist/operator/report-run.js.map +1 -1
- package/dist/operator/situation-report.d.ts +25 -6
- package/dist/operator/situation-report.d.ts.map +1 -1
- package/dist/operator/situation-report.js +28 -37
- package/dist/operator/situation-report.js.map +1 -1
- package/dist/operator/task-ledger.d.ts +8 -1
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +51 -16
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/task-list-views.d.ts.map +1 -1
- package/dist/operator/task-list-views.js +45 -24
- package/dist/operator/task-list-views.js.map +1 -1
- package/dist/operator/task-temporal.d.ts +3 -0
- package/dist/operator/task-temporal.d.ts.map +1 -1
- package/dist/operator/task-temporal.js +12 -0
- package/dist/operator/task-temporal.js.map +1 -1
- package/dist/operator/trigger-author.d.ts +0 -45
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +0 -122
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/worker-run.d.ts +9 -23
- package/dist/operator/worker-run.d.ts.map +1 -1
- package/dist/operator/worker-run.js +18 -74
- package/dist/operator/worker-run.js.map +1 -1
- package/dist/operator/workorder-consumer.d.ts.map +1 -1
- package/dist/operator/workorder-consumer.js +7 -0
- package/dist/operator/workorder-consumer.js.map +1 -1
- package/dist/scheduler/cron-worker.d.ts +0 -3
- package/dist/scheduler/cron-worker.d.ts.map +1 -1
- package/dist/scheduler/cron-worker.js +2 -13
- package/dist/scheduler/cron-worker.js.map +1 -1
- package/dist/scheduler/heartbeat.d.ts +3 -1
- package/dist/scheduler/heartbeat.d.ts.map +1 -1
- package/dist/scheduler/heartbeat.js +13 -4
- package/dist/scheduler/heartbeat.js.map +1 -1
- package/dist/validation/types.d.ts +1 -1
- package/dist/validation/types.js +1 -1
- package/package.json +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts +0 -37
- package/dist/cli/runtime/memory-agent-init.d.ts.map +0 -1
- package/dist/cli/runtime/memory-agent-init.js +0 -202
- package/dist/cli/runtime/memory-agent-init.js.map +0 -1
- package/dist/gateways/owner-report-inbox.d.ts +0 -40
- package/dist/gateways/owner-report-inbox.d.ts.map +0 -1
- package/dist/gateways/owner-report-inbox.js +0 -128
- package/dist/gateways/owner-report-inbox.js.map +0 -1
- package/dist/multi-agent/memory-agent-persona.d.ts +0 -11
- package/dist/multi-agent/memory-agent-persona.d.ts.map +0 -1
- package/dist/multi-agent/memory-agent-persona.js +0 -175
- package/dist/multi-agent/memory-agent-persona.js.map +0 -1
- package/dist/operator/report-context.d.ts +0 -184
- package/dist/operator/report-context.d.ts.map +0 -1
- package/dist/operator/report-context.js +0 -1052
- package/dist/operator/report-context.js.map +0 -1
|
@@ -47,10 +47,12 @@ export declare class AgentLoop {
|
|
|
47
47
|
*
|
|
48
48
|
* Claude's persistent CLI cannot narrow native or MCP tools per turn, so a
|
|
49
49
|
* public lane may run only when both surfaces were disabled at construction.
|
|
50
|
-
* Codex
|
|
51
|
-
*
|
|
50
|
+
* Codex native multi-agent and Claude built-ins are construction-wide, so
|
|
51
|
+
* public lanes must use another tool-free runtime. Cline can gate spawn per role.
|
|
52
52
|
*/
|
|
53
53
|
readonly childRuntimeToolCapable: boolean;
|
|
54
|
+
readonly probesDurableSession: boolean;
|
|
55
|
+
readonly ownerRecoveryJournalEnabled: boolean;
|
|
54
56
|
private readonly agent;
|
|
55
57
|
private readonly persistentCLI;
|
|
56
58
|
private readonly mcpExecutor;
|
|
@@ -80,6 +82,7 @@ export declare class AgentLoop {
|
|
|
80
82
|
private readonly clineNativePolicyConfigured;
|
|
81
83
|
private readonly clineAllowSpawnAgent;
|
|
82
84
|
private readonly clineAllowAgentTeams;
|
|
85
|
+
private readonly ownerRuntimeJournal;
|
|
83
86
|
constructor(_oauthManager: OAuthManager | null, options?: AgentLoopOptions, _clientOptions?: ClaudeClientOptions, executorOptions?: GatewayToolExecutorOptions);
|
|
84
87
|
setContextCompileService(service: GatewayToolExecutorOptions['contextCompileService']): void;
|
|
85
88
|
/**
|
|
@@ -119,7 +122,7 @@ export declare class AgentLoop {
|
|
|
119
122
|
*/
|
|
120
123
|
setSessionsDb(db: import('../sqlite.js').default): void;
|
|
121
124
|
/**
|
|
122
|
-
* Set validation service for
|
|
125
|
+
* Set validation service for agent validation flows.
|
|
123
126
|
*/
|
|
124
127
|
setValidationService(svc: import('../validation/session-service.js').ValidationSessionService): void;
|
|
125
128
|
/**
|
|
@@ -142,10 +145,6 @@ export declare class AgentLoop {
|
|
|
142
145
|
compiledAt: string;
|
|
143
146
|
confidence: string;
|
|
144
147
|
}>) => void): void;
|
|
145
|
-
/**
|
|
146
|
-
* Set AgentProcessManager for delegate tool (multi-agent delegation)
|
|
147
|
-
*/
|
|
148
|
-
setAgentProcessManager(pm: import('../multi-agent/agent-process-manager.js').AgentProcessManager): void;
|
|
149
148
|
/**
|
|
150
149
|
* Set AgentEventBus for agent_notices tool
|
|
151
150
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH,OAAO,EAAE,mBAAmB,EAA+B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH,OAAO,EAAE,mBAAmB,EAA+B,MAAM,4BAA4B,CAAC;AAmB9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,KAAK,EAEV,YAAY,EAIZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EAKf,mBAAmB,EACnB,0BAA0B,EAG1B,YAAY,EAGZ,2BAA2B,EAM5B,MAAM,YAAY,CAAC;AA+DpB,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKtD,CAAC;AAmFF;;;;;;;;;;;;;GAaG;AACH;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAyEnE;AAED,wBAAgB,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AI,MAAM;IAIvC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAS;IAElB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAsB5B"}
|
package/dist/agent/agent-loop.js
CHANGED
|
@@ -67,6 +67,7 @@ const index_js_1 = require("./code-act/index.js");
|
|
|
67
67
|
const index_js_2 = require("../concurrency/index.js");
|
|
68
68
|
const session_pool_js_1 = require("./session-pool.js");
|
|
69
69
|
const principal_js_1 = require("../gateways/principal.js");
|
|
70
|
+
const owner_runtime_js_1 = require("../operator/owner-runtime.js");
|
|
70
71
|
const os_1 = require("os");
|
|
71
72
|
const path_1 = require("path");
|
|
72
73
|
const crypto_1 = require("crypto");
|
|
@@ -104,16 +105,13 @@ const DEFAULT_PRIVATE_CONNECTOR_POLICY = (0, private_connector_policy_js_1.resol
|
|
|
104
105
|
config: {},
|
|
105
106
|
enabledNames: [],
|
|
106
107
|
});
|
|
107
|
-
// Sources without an entry stay on their per-session lane.
|
|
108
|
-
//
|
|
109
|
-
//
|
|
108
|
+
// Sources without an entry stay on their per-session lane. Every owner stimulus
|
|
109
|
+
// uses owner:runtime, so its session lane serializes chat, events, reports,
|
|
110
|
+
// maintenance, and heartbeat before any global-lane choice is considered.
|
|
110
111
|
exports.SOURCE_GLOBAL_LANES = {
|
|
111
112
|
viewer: 'viewer',
|
|
112
113
|
system: 'system',
|
|
113
|
-
//
|
|
114
|
-
// itself but must not block owner chat on 'main': a 260s full report was
|
|
115
|
-
// measurably blocking chat replies before this lane existed. Safe only
|
|
116
|
-
// because per-run state is scoped (RunScope), not instance state.
|
|
114
|
+
// Non-owner trigger authoring/review still uses the operator global lane.
|
|
117
115
|
operator: 'operator',
|
|
118
116
|
};
|
|
119
117
|
function applyTemporalCodeActBreakerState(runScope, state) {
|
|
@@ -314,11 +312,6 @@ function loadComposedSystemPrompt(verbose = false, context) {
|
|
|
314
312
|
if (context) {
|
|
315
313
|
layers.push((0, context_prompt_builder_js_1.buildMinimalContext)(context));
|
|
316
314
|
}
|
|
317
|
-
// Load backend-specific AGENTS.md (e.g., AGENTS.claude.md, AGENTS.codex.md)
|
|
318
|
-
const backendAgentsMd = loadBackendAgentsMd(context?.backend, verbose);
|
|
319
|
-
if (backendAgentsMd) {
|
|
320
|
-
layers.push(backendAgentsMd);
|
|
321
|
-
}
|
|
322
315
|
// Load CLAUDE.md (base instructions)
|
|
323
316
|
const claudeMd = loadSystemPrompt(verbose);
|
|
324
317
|
layers.push(claudeMd);
|
|
@@ -425,6 +418,18 @@ function combineCodeActSessionPolicyFingerprint(callerFingerprint, policy) {
|
|
|
425
418
|
codeActPolicy: policy.fingerprintPayload,
|
|
426
419
|
});
|
|
427
420
|
}
|
|
421
|
+
function ownerRuntimeSessionPolicyFingerprint(role, model) {
|
|
422
|
+
return JSON.stringify({
|
|
423
|
+
version: 1,
|
|
424
|
+
subject: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
425
|
+
model: model ?? null,
|
|
426
|
+
allowedTools: [...(role?.allowedTools ?? [])].sort(),
|
|
427
|
+
blockedTools: [...(role?.blockedTools ?? [])].sort(),
|
|
428
|
+
allowedPaths: [...(role?.allowedPaths ?? [])].sort(),
|
|
429
|
+
systemControl: role?.systemControl === true,
|
|
430
|
+
sensitiveAccess: role?.sensitiveAccess === true,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
428
433
|
function roleAllowsOuterCodeAct(role, disallowedTools) {
|
|
429
434
|
if (!role) {
|
|
430
435
|
return false;
|
|
@@ -510,10 +515,12 @@ class AgentLoop {
|
|
|
510
515
|
*
|
|
511
516
|
* Claude's persistent CLI cannot narrow native or MCP tools per turn, so a
|
|
512
517
|
* public lane may run only when both surfaces were disabled at construction.
|
|
513
|
-
* Codex
|
|
514
|
-
*
|
|
518
|
+
* Codex native multi-agent and Claude built-ins are construction-wide, so
|
|
519
|
+
* public lanes must use another tool-free runtime. Cline can gate spawn per role.
|
|
515
520
|
*/
|
|
516
521
|
childRuntimeToolCapable;
|
|
522
|
+
probesDurableSession;
|
|
523
|
+
ownerRecoveryJournalEnabled;
|
|
517
524
|
agent;
|
|
518
525
|
persistentCLI = null;
|
|
519
526
|
mcpExecutor;
|
|
@@ -548,6 +555,7 @@ class AgentLoop {
|
|
|
548
555
|
clineNativePolicyConfigured;
|
|
549
556
|
clineAllowSpawnAgent;
|
|
550
557
|
clineAllowAgentTeams;
|
|
558
|
+
ownerRuntimeJournal;
|
|
551
559
|
constructor(_oauthManager, options = {}, _clientOptions, executorOptions) {
|
|
552
560
|
// Initialize tools config (hybrid Gateway/MCP routing)
|
|
553
561
|
this.toolsConfig = {
|
|
@@ -586,6 +594,8 @@ class AgentLoop {
|
|
|
586
594
|
options.clineNativeDisallowedTools !== undefined;
|
|
587
595
|
this.clineAllowSpawnAgent = options.clineAllowSpawnAgent ?? false;
|
|
588
596
|
this.clineAllowAgentTeams = options.clineAllowAgentTeams ?? false;
|
|
597
|
+
this.ownerRuntimeJournal = options.ownerRuntimeJournal;
|
|
598
|
+
this.ownerRecoveryJournalEnabled = this.ownerRuntimeJournal !== undefined;
|
|
589
599
|
if (useGatewayMode && useMCPMode) {
|
|
590
600
|
logger.debug('🔀 Hybrid mode: Gateway + MCP tools enabled');
|
|
591
601
|
}
|
|
@@ -646,6 +656,7 @@ class AgentLoop {
|
|
|
646
656
|
];
|
|
647
657
|
}
|
|
648
658
|
const backend = options.backend ?? 'claude';
|
|
659
|
+
this.probesDurableSession = backend === 'codex';
|
|
649
660
|
if (this.useCodeAct && options.systemPrompt) {
|
|
650
661
|
promptLayers = [
|
|
651
662
|
{
|
|
@@ -655,11 +666,6 @@ class AgentLoop {
|
|
|
655
666
|
},
|
|
656
667
|
];
|
|
657
668
|
}
|
|
658
|
-
// Load backend-specific AGENTS.md (e.g., AGENTS.claude.md, AGENTS.codex.md)
|
|
659
|
-
const backendAgentsMd = loadBackendAgentsMd(backend);
|
|
660
|
-
if (backendAgentsMd) {
|
|
661
|
-
promptLayers.push({ name: 'backendAgents', content: backendAgentsMd, priority: 2 });
|
|
662
|
-
}
|
|
663
669
|
if (this.isGatewayMode) {
|
|
664
670
|
if (this.useCodeAct &&
|
|
665
671
|
roleAllowsOuterCodeAct(options.agentContext?.role, this.disallowedTools)) {
|
|
@@ -717,7 +723,7 @@ class AgentLoop {
|
|
|
717
723
|
// Choose backend (default: claude)
|
|
718
724
|
this.backend = backend;
|
|
719
725
|
this.childRuntimeToolCapable =
|
|
720
|
-
backend === 'claude' && (useMCPMode || options.builtinTools !== '');
|
|
726
|
+
backend === 'codex' || (backend === 'claude' && (useMCPMode || options.builtinTools !== ''));
|
|
721
727
|
if (this.backend === 'codex') {
|
|
722
728
|
// Codex app-server mode
|
|
723
729
|
const workspaceDir = options.codexCwd ?? (0, path_1.join)((0, os_1.homedir)(), '.mama', 'workspace');
|
|
@@ -911,7 +917,7 @@ class AgentLoop {
|
|
|
911
917
|
this.mcpExecutor.setSessionsDb(db);
|
|
912
918
|
}
|
|
913
919
|
/**
|
|
914
|
-
* Set validation service for
|
|
920
|
+
* Set validation service for agent validation flows.
|
|
915
921
|
*/
|
|
916
922
|
setValidationService(svc) {
|
|
917
923
|
this.mcpExecutor.setValidationService(svc);
|
|
@@ -934,13 +940,6 @@ class AgentLoop {
|
|
|
934
940
|
setWikiPublisher(fn) {
|
|
935
941
|
this.mcpExecutor.setWikiPublisher(fn);
|
|
936
942
|
}
|
|
937
|
-
/**
|
|
938
|
-
* Set AgentProcessManager for delegate tool (multi-agent delegation)
|
|
939
|
-
*/
|
|
940
|
-
setAgentProcessManager(pm) {
|
|
941
|
-
pm.setGatewayToolExecutor(this.mcpExecutor);
|
|
942
|
-
this.mcpExecutor.setAgentProcessManager(pm);
|
|
943
|
-
}
|
|
944
943
|
/**
|
|
945
944
|
* Set AgentEventBus for agent_notices tool
|
|
946
945
|
*/
|
|
@@ -970,7 +969,7 @@ class AgentLoop {
|
|
|
970
969
|
// Use lane-based queueing if enabled
|
|
971
970
|
if (this.useLanes) {
|
|
972
971
|
const globalLane = this.resolveGlobalLaneForSession(sessionKey);
|
|
973
|
-
return this.laneManager.enqueueWithSession(sessionKey, () => this.runWithContentInternal(content, options), globalLane);
|
|
972
|
+
return this.laneManager.enqueueWithSession(sessionKey, () => this.runWithContentInternal(content, options), globalLane, { priority: options?.lanePriority ?? 0 });
|
|
974
973
|
}
|
|
975
974
|
// Direct execution for backward compatibility
|
|
976
975
|
return this.runWithContentInternal(content, options);
|
|
@@ -990,7 +989,7 @@ class AgentLoop {
|
|
|
990
989
|
// Use lane-based queueing if enabled
|
|
991
990
|
if (this.useLanes) {
|
|
992
991
|
const globalLane = this.resolveGlobalLaneForSession(sessionKey);
|
|
993
|
-
return this.laneManager.enqueueWithSession(sessionKey, () => this.runWithContentInternal(content, options), globalLane);
|
|
992
|
+
return this.laneManager.enqueueWithSession(sessionKey, () => this.runWithContentInternal(content, options), globalLane, { priority: options?.lanePriority ?? 0 });
|
|
994
993
|
}
|
|
995
994
|
// Direct execution for backward compatibility
|
|
996
995
|
return this.runWithContentInternal(content, options);
|
|
@@ -1002,6 +1001,18 @@ class AgentLoop {
|
|
|
1002
1001
|
if (this.stopped) {
|
|
1003
1002
|
throw new types_js_1.AgentError('Agent loop is stopping', 'AGENT_STOPPED', undefined, false);
|
|
1004
1003
|
}
|
|
1004
|
+
// Queue wait consumes no execution authority. Never renew a signed envelope implicitly:
|
|
1005
|
+
// only a host-supplied issuer can prepare the current grant after both lane waits.
|
|
1006
|
+
if (options?.prepareEnvelope) {
|
|
1007
|
+
options = {
|
|
1008
|
+
...options,
|
|
1009
|
+
envelope: await options.prepareEnvelope(),
|
|
1010
|
+
prepareEnvelope: undefined,
|
|
1011
|
+
};
|
|
1012
|
+
if (this.stopped) {
|
|
1013
|
+
throw new types_js_1.AgentError('Agent loop is stopping', 'AGENT_STOPPED', undefined, false);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1005
1016
|
if (options?.agentContext) {
|
|
1006
1017
|
options = {
|
|
1007
1018
|
...options,
|
|
@@ -1016,6 +1027,8 @@ class AgentLoop {
|
|
|
1016
1027
|
...(0, temporal_code_act_breaker_js_1.createTemporalCodeActBreakerState)(),
|
|
1017
1028
|
};
|
|
1018
1029
|
const history = [];
|
|
1030
|
+
const ownerJournalPrompt = options?.ownerJournalPrompt ??
|
|
1031
|
+
content.map((block) => (block.type === 'text' ? block.text : `[${block.type}]`)).join('\n');
|
|
1019
1032
|
const totalUsage = { input_tokens: 0, output_tokens: 0 };
|
|
1020
1033
|
// Budget accounting is separate from totalUsage (a published field): it includes cache
|
|
1021
1034
|
// creation and cache reads, which are the bulk of a re-sent context and the cost being
|
|
@@ -1080,24 +1093,36 @@ class AgentLoop {
|
|
|
1080
1093
|
...cline_native_tool_policy_js_1.CLINE_NATIVE_GUARD_BYPASS,
|
|
1081
1094
|
]),
|
|
1082
1095
|
];
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
const
|
|
1096
|
+
const clineDelegationGranted = clineRole?.allowedTools.some((pattern) => pattern === '*' || pattern === 'native_subagent') ??
|
|
1097
|
+
false;
|
|
1098
|
+
const clineDelegationBlocked = clineRole?.blockedTools?.some((pattern) => pattern === '*' || pattern === 'native_subagent') ?? false;
|
|
1099
|
+
const clineAllowSpawnAgent = this.clineAllowSpawnAgent && clineDelegationGranted && !clineDelegationBlocked;
|
|
1100
|
+
const clineAllowAgentTeams = this.clineAllowAgentTeams && clineDelegationGranted && !clineDelegationBlocked;
|
|
1101
|
+
const ownerRuntime = channelKey === owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY;
|
|
1102
|
+
const sessionPolicyRole = ownerRuntime
|
|
1103
|
+
? (options?.sessionPolicyRole ?? options?.agentContext?.role)
|
|
1104
|
+
: options?.agentContext?.role;
|
|
1086
1105
|
const codeActPolicy = this.useCodeAct
|
|
1087
1106
|
? (0, index_js_1.projectCodeActToolPolicy)({
|
|
1088
|
-
tier: runScope.tier,
|
|
1089
|
-
roleName: options?.agentContext?.roleName,
|
|
1090
|
-
role:
|
|
1107
|
+
tier: ownerRuntime ? 1 : runScope.tier,
|
|
1108
|
+
roleName: ownerRuntime ? 'owner_console' : options?.agentContext?.roleName,
|
|
1109
|
+
role: sessionPolicyRole,
|
|
1091
1110
|
disallowedTools: this.disallowedTools,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1111
|
+
...(ownerRuntime
|
|
1112
|
+
? {}
|
|
1113
|
+
: {
|
|
1114
|
+
envelopeDestinationKinds: options?.envelope?.scope.allowed_destinations.map((destination) => destination.kind) ?? [],
|
|
1115
|
+
envelopeRawConnectors: options?.envelope?.scope.raw_connectors ?? [],
|
|
1116
|
+
}),
|
|
1095
1117
|
})
|
|
1096
1118
|
: undefined;
|
|
1097
1119
|
const outerCodeActAllowed = this.useCodeAct && roleAllowsOuterCodeAct(options?.agentContext?.role, this.disallowedTools);
|
|
1120
|
+
const ownerPolicyFingerprint = ownerRuntime
|
|
1121
|
+
? ownerRuntimeSessionPolicyFingerprint(sessionPolicyRole, options?.model ?? this.model)
|
|
1122
|
+
: undefined;
|
|
1098
1123
|
const effectiveSessionPolicyFingerprint = isDurableRuntime && codeActPolicy
|
|
1099
|
-
? combineCodeActSessionPolicyFingerprint(options?.sessionPolicyFingerprint, codeActPolicy)
|
|
1100
|
-
: options?.sessionPolicyFingerprint;
|
|
1124
|
+
? combineCodeActSessionPolicyFingerprint(ownerPolicyFingerprint ?? options?.sessionPolicyFingerprint, codeActPolicy)
|
|
1125
|
+
: (ownerPolicyFingerprint ?? options?.sessionPolicyFingerprint);
|
|
1101
1126
|
let resolvedCliSessionId = options?.cliSessionId ?? null;
|
|
1102
1127
|
const sessionLabel = (isNew) => {
|
|
1103
1128
|
if (isDurableRuntime) {
|
|
@@ -1240,7 +1265,7 @@ class AgentLoop {
|
|
|
1240
1265
|
},
|
|
1241
1266
|
}
|
|
1242
1267
|
: undefined;
|
|
1243
|
-
const prepareSystemPrompt = (requestedSystemPrompt, isResumingSession,
|
|
1268
|
+
const prepareSystemPrompt = (requestedSystemPrompt, isResumingSession, includeOwnerRecovery = false) => {
|
|
1244
1269
|
let baseSystemPrompt = requestedSystemPrompt ?? this.defaultSystemPrompt;
|
|
1245
1270
|
let gatewayToolsPrompt = '';
|
|
1246
1271
|
if (this.isGatewayMode && this.useCodeAct) {
|
|
@@ -1273,25 +1298,15 @@ class AgentLoop {
|
|
|
1273
1298
|
}
|
|
1274
1299
|
}
|
|
1275
1300
|
}
|
|
1276
|
-
const
|
|
1277
|
-
?
|
|
1278
|
-
:
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
: baseWithOwnerReportHistory;
|
|
1301
|
+
const ownerRecovery = includeOwnerRecovery && ownerRuntime && this.ownerRuntimeJournal
|
|
1302
|
+
? this.ownerRuntimeJournal.recoveryBlock()
|
|
1303
|
+
: '';
|
|
1304
|
+
const joinLayers = (base, tools, recovery) => [base, tools, recovery].filter(Boolean).join('\n\n---\n\n');
|
|
1305
|
+
const fullPrompt = joinLayers(baseSystemPrompt, gatewayToolsPrompt, ownerRecovery);
|
|
1282
1306
|
// Monitor and enforce prompt size
|
|
1283
1307
|
const monitor = new prompt_size_monitor_js_1.PromptSizeMonitor();
|
|
1284
1308
|
const runLayers = [
|
|
1285
1309
|
{ name: 'systemPrompt', content: baseSystemPrompt, priority: 1 },
|
|
1286
|
-
...(ownerReportHistoryPrompt
|
|
1287
|
-
? [
|
|
1288
|
-
{
|
|
1289
|
-
name: 'ownerReportHistory',
|
|
1290
|
-
content: ownerReportHistoryPrompt,
|
|
1291
|
-
priority: 3,
|
|
1292
|
-
},
|
|
1293
|
-
]
|
|
1294
|
-
: []),
|
|
1295
1310
|
...(gatewayToolsPrompt
|
|
1296
1311
|
? [
|
|
1297
1312
|
{
|
|
@@ -1307,6 +1322,9 @@ class AgentLoop {
|
|
|
1307
1322
|
},
|
|
1308
1323
|
]
|
|
1309
1324
|
: []),
|
|
1325
|
+
...(ownerRecovery
|
|
1326
|
+
? [{ name: 'ownerRecovery', content: ownerRecovery, priority: 3 }]
|
|
1327
|
+
: []),
|
|
1310
1328
|
];
|
|
1311
1329
|
const checkResult = monitor.check(runLayers);
|
|
1312
1330
|
if (checkResult.warning) {
|
|
@@ -1314,33 +1332,22 @@ class AgentLoop {
|
|
|
1314
1332
|
}
|
|
1315
1333
|
let effectivePrompt = fullPrompt;
|
|
1316
1334
|
if (!checkResult.withinBudget) {
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
: runLayers;
|
|
1320
|
-
const { layers: trimmed, result: enforceResult } = monitor.enforce(boundedLayers);
|
|
1321
|
-
const truncatedLayers = [
|
|
1322
|
-
...(ownerReportHistoryPrompt ? ['ownerReportHistory'] : []),
|
|
1323
|
-
...enforceResult.truncatedLayers,
|
|
1324
|
-
];
|
|
1335
|
+
const { layers: trimmed, result: enforceResult } = monitor.enforce(runLayers);
|
|
1336
|
+
const truncatedLayers = enforceResult.truncatedLayers;
|
|
1325
1337
|
if (truncatedLayers.length > 0) {
|
|
1326
1338
|
console.warn(`[AgentLoop] Truncated layers: ${truncatedLayers.join(', ')}`);
|
|
1327
1339
|
}
|
|
1328
1340
|
const tBase = trimmed.find((l) => l.name === 'systemPrompt')?.content || baseSystemPrompt;
|
|
1329
|
-
const tOwnerReportHistory = trimmed.find((l) => l.name === 'ownerReportHistory')?.content || '';
|
|
1330
1341
|
const tTools = trimmed.find((l) => l.name === 'gatewayTools')?.content || '';
|
|
1331
|
-
const
|
|
1332
|
-
|
|
1333
|
-
: tBase;
|
|
1334
|
-
effectivePrompt = tTools
|
|
1335
|
-
? `${tBaseWithOwnerReportHistory}\n\n---\n\n${tTools}`
|
|
1336
|
-
: tBaseWithOwnerReportHistory;
|
|
1342
|
+
const tRecovery = trimmed.find((l) => l.name === 'ownerRecovery')?.content || '';
|
|
1343
|
+
effectivePrompt = joinLayers(tBase, tTools, tRecovery);
|
|
1337
1344
|
logger.debug(`[AgentLoop] System prompt truncated: ${fullPrompt.length} → ${effectivePrompt.length} chars`);
|
|
1338
1345
|
}
|
|
1339
1346
|
logger.debug(`[AgentLoop] Prepared systemPrompt for this call: ${effectivePrompt.length} chars ` +
|
|
1340
|
-
`(base: ${baseSystemPrompt.length},
|
|
1341
|
-
`tools: ${gatewayToolsPrompt.length})`);
|
|
1347
|
+
`(base: ${baseSystemPrompt.length}, tools: ${gatewayToolsPrompt.length}, recovery: ${ownerRecovery.length})`);
|
|
1342
1348
|
return effectivePrompt;
|
|
1343
1349
|
};
|
|
1350
|
+
const includeInitialOwnerRecovery = ownerRuntime && sessionIsNew && options?.resumeSession !== true;
|
|
1344
1351
|
let perCallSystemPrompt;
|
|
1345
1352
|
if (isCline && this.isGatewayMode && this.useCodeAct && !sessionIsNew) {
|
|
1346
1353
|
// TG-05: a compatible Cline Hub session ignores the per-call system prompt.
|
|
@@ -1349,10 +1356,12 @@ class AgentLoop {
|
|
|
1349
1356
|
perCallSystemPrompt = options?.systemPrompt ?? this.defaultSystemPrompt;
|
|
1350
1357
|
}
|
|
1351
1358
|
else if (options?.systemPrompt ||
|
|
1352
|
-
options?.ownerReportHistoryPrompt ||
|
|
1353
1359
|
options?.gatewayToolsPrompt !== undefined ||
|
|
1354
1360
|
(this.isGatewayMode && this.useCodeAct)) {
|
|
1355
|
-
perCallSystemPrompt = prepareSystemPrompt(options?.systemPrompt, options?.resumeSession === true,
|
|
1361
|
+
perCallSystemPrompt = prepareSystemPrompt(options?.systemPrompt, options?.resumeSession === true, includeInitialOwnerRecovery);
|
|
1362
|
+
}
|
|
1363
|
+
else if (includeInitialOwnerRecovery) {
|
|
1364
|
+
perCallSystemPrompt = prepareSystemPrompt(undefined, false, true);
|
|
1356
1365
|
}
|
|
1357
1366
|
else {
|
|
1358
1367
|
perCallSystemPrompt = this.defaultSystemPrompt;
|
|
@@ -1367,7 +1376,7 @@ class AgentLoop {
|
|
|
1367
1376
|
// invokes only inside the resume branch; a live thread never pays for it.
|
|
1368
1377
|
const freshSystemPromptBuilder = options?.freshSessionSystemPrompt;
|
|
1369
1378
|
const resumeInstructions = isDurableRuntime && freshSystemPromptBuilder
|
|
1370
|
-
? async () => prepareSystemPrompt(await freshSystemPromptBuilder(), false,
|
|
1379
|
+
? async () => prepareSystemPrompt(await freshSystemPromptBuilder(), false, true)
|
|
1371
1380
|
: undefined;
|
|
1372
1381
|
// Reset StopContinuation state for this channel to prevent leaking
|
|
1373
1382
|
// retry counts from previous invocations
|
|
@@ -1427,7 +1436,7 @@ class AgentLoop {
|
|
|
1427
1436
|
// Codex/Cline: resumeSession controls durable session reset/continuation.
|
|
1428
1437
|
let shouldResume = isDurableRuntime
|
|
1429
1438
|
? turn > 1 || (options?.freshSession === true ? false : (options?.resumeSession ?? true))
|
|
1430
|
-
: !sessionIsNew || turn > 1;
|
|
1439
|
+
: !sessionIsNew || turn > 1 || (ownerRuntime && options?.resumeSession === true);
|
|
1431
1440
|
let requestSystemPrompt = perCallSystemPrompt;
|
|
1432
1441
|
let provisionalDurableSessionId;
|
|
1433
1442
|
// All three backends preserve context and receive only the new user message.
|
|
@@ -1523,7 +1532,7 @@ class AgentLoop {
|
|
|
1523
1532
|
provisionalDurableSessionId = newSessionId;
|
|
1524
1533
|
try {
|
|
1525
1534
|
if (options?.freshSessionSystemPrompt) {
|
|
1526
|
-
requestSystemPrompt = prepareSystemPrompt(await options.freshSessionSystemPrompt(), false,
|
|
1535
|
+
requestSystemPrompt = prepareSystemPrompt(await options.freshSessionSystemPrompt(), false, true);
|
|
1527
1536
|
}
|
|
1528
1537
|
}
|
|
1529
1538
|
catch (rebuildError) {
|
|
@@ -1667,7 +1676,7 @@ class AgentLoop {
|
|
|
1667
1676
|
// its own final error, never the mismatch that triggered it.
|
|
1668
1677
|
attemptReportedError = undefined;
|
|
1669
1678
|
if (options?.freshSessionSystemPrompt) {
|
|
1670
|
-
resetSystemPrompt = prepareSystemPrompt(await options.freshSessionSystemPrompt(), false,
|
|
1679
|
+
resetSystemPrompt = prepareSystemPrompt(await options.freshSessionSystemPrompt(), false, true);
|
|
1671
1680
|
}
|
|
1672
1681
|
piResult = await this.agent.prompt(promptText, callbacks, {
|
|
1673
1682
|
model: options?.model,
|
|
@@ -2002,6 +2011,23 @@ class AgentLoop {
|
|
|
2002
2011
|
result.modelRunProvenance = 'commit_failed';
|
|
2003
2012
|
logger.error(`Model run ${ownedModelRunId} may remain uncommitted; provenance reported as commit_failed`);
|
|
2004
2013
|
}
|
|
2014
|
+
if (ownerRuntime && this.ownerRuntimeJournal && finalResponse.trim()) {
|
|
2015
|
+
try {
|
|
2016
|
+
this.ownerRuntimeJournal.append({
|
|
2017
|
+
trust: options?.ownerJournalTrust ?? 'untrusted',
|
|
2018
|
+
source: options?.source ?? 'owner',
|
|
2019
|
+
channelId: options?.channelId ?? owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
2020
|
+
prompt: ownerJournalPrompt,
|
|
2021
|
+
response: finalResponse,
|
|
2022
|
+
...(options?.sourceMessageRef ? { sourceMessageRef: options.sourceMessageRef } : {}),
|
|
2023
|
+
committedAt: new Date().toISOString(),
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
catch (journalError) {
|
|
2027
|
+
result.ownerJournalProvenance = 'commit_failed';
|
|
2028
|
+
logger.warn(`Owner runtime journal append failed: ${journalError instanceof Error ? journalError.message : String(journalError)}`);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2005
2031
|
return result;
|
|
2006
2032
|
}
|
|
2007
2033
|
catch (error) {
|