@jungjaehoon/mama-os 0.51.2 → 0.52.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 +58 -0
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +503 -142
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/claude-cli-wrapper.d.ts.map +1 -1
- package/dist/agent/claude-cli-wrapper.js +3 -2
- package/dist/agent/claude-cli-wrapper.js.map +1 -1
- package/dist/agent/cline-cli-adapter.d.ts +2 -0
- package/dist/agent/cline-cli-adapter.d.ts.map +1 -1
- package/dist/agent/cline-cli-adapter.js +2 -0
- package/dist/agent/cline-cli-adapter.js.map +1 -1
- package/dist/agent/code-act/constants.d.ts +1 -1
- package/dist/agent/code-act/constants.d.ts.map +1 -1
- package/dist/agent/code-act/constants.js +5 -2
- package/dist/agent/code-act/constants.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +102 -4
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/tool-catalog.d.ts +2 -0
- package/dist/agent/code-act/tool-catalog.d.ts.map +1 -1
- package/dist/agent/code-act/tool-catalog.js +20 -7
- package/dist/agent/code-act/tool-catalog.js.map +1 -1
- package/dist/agent/codex-app-server-process.d.ts +112 -0
- package/dist/agent/codex-app-server-process.d.ts.map +1 -1
- package/dist/agent/codex-app-server-process.js +518 -1
- package/dist/agent/codex-app-server-process.js.map +1 -1
- package/dist/agent/gateway-tool-executor.d.ts +17 -0
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +236 -53
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +9 -3
- package/dist/agent/model-runner.d.ts +16 -0
- package/dist/agent/model-runner.d.ts.map +1 -1
- package/dist/agent/model-runner.js.map +1 -1
- package/dist/agent/persistent-cli-adapter.d.ts +5 -0
- package/dist/agent/persistent-cli-adapter.d.ts.map +1 -1
- package/dist/agent/persistent-cli-adapter.js +7 -0
- package/dist/agent/persistent-cli-adapter.js.map +1 -1
- package/dist/agent/persistent-cli-process.d.ts.map +1 -1
- package/dist/agent/persistent-cli-process.js +27 -2
- package/dist/agent/persistent-cli-process.js.map +1 -1
- package/dist/agent/skill-loader.d.ts +7 -2
- package/dist/agent/skill-loader.d.ts.map +1 -1
- package/dist/agent/skill-loader.js +29 -8
- package/dist/agent/skill-loader.js.map +1 -1
- package/dist/agent/subagent-run-reconcile.d.ts +23 -0
- package/dist/agent/subagent-run-reconcile.d.ts.map +1 -0
- package/dist/agent/subagent-run-reconcile.js +56 -0
- package/dist/agent/subagent-run-reconcile.js.map +1 -0
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +126 -3
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +52 -2
- 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 +0 -22
- package/dist/api/graph-api.js.map +1 -1
- package/dist/cli/commands/start.d.ts +8 -7
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +154 -74
- 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 +2 -1
- 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 +1 -0
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +1 -0
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +82 -58
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/db/migrations/operator-procedures.d.ts +4 -0
- package/dist/db/migrations/operator-procedures.d.ts.map +1 -0
- package/dist/db/migrations/operator-procedures.js +63 -0
- package/dist/db/migrations/operator-procedures.js.map +1 -0
- package/dist/gateways/message-router.d.ts +6 -3
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +43 -131
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/telegram-format.d.ts.map +1 -1
- package/dist/gateways/telegram-format.js +2 -0
- package/dist/gateways/telegram-format.js.map +1 -1
- package/dist/gateways/telegram-response-presenter.d.ts.map +1 -1
- package/dist/gateways/telegram-response-presenter.js +4 -0
- package/dist/gateways/telegram-response-presenter.js.map +1 -1
- package/dist/mcp/code-act-mcp-config.d.ts +49 -0
- package/dist/mcp/code-act-mcp-config.d.ts.map +1 -0
- package/dist/mcp/code-act-mcp-config.js +124 -0
- package/dist/mcp/code-act-mcp-config.js.map +1 -0
- package/dist/multi-agent/runtime-process.d.ts +10 -0
- package/dist/multi-agent/runtime-process.d.ts.map +1 -1
- package/dist/multi-agent/runtime-process.js +8 -0
- package/dist/multi-agent/runtime-process.js.map +1 -1
- package/dist/operator/board-delta-gate.d.ts +34 -10
- package/dist/operator/board-delta-gate.d.ts.map +1 -1
- package/dist/operator/board-delta-gate.js +68 -24
- package/dist/operator/board-delta-gate.js.map +1 -1
- package/dist/operator/board-refresh-gate.d.ts +11 -6
- package/dist/operator/board-refresh-gate.d.ts.map +1 -1
- package/dist/operator/board-refresh-gate.js +12 -11
- package/dist/operator/board-refresh-gate.js.map +1 -1
- package/dist/operator/board-slot-instructions.d.ts +30 -0
- package/dist/operator/board-slot-instructions.d.ts.map +1 -1
- package/dist/operator/board-slot-instructions.js +110 -6
- package/dist/operator/board-slot-instructions.js.map +1 -1
- package/dist/operator/console-brief.d.ts +26 -13
- package/dist/operator/console-brief.d.ts.map +1 -1
- package/dist/operator/console-brief.js +159 -83
- package/dist/operator/console-brief.js.map +1 -1
- package/dist/operator/experience-evidence.d.ts +18 -0
- package/dist/operator/experience-evidence.d.ts.map +1 -0
- package/dist/operator/experience-evidence.js +82 -0
- package/dist/operator/experience-evidence.js.map +1 -0
- package/dist/operator/experience-hints.d.ts +44 -0
- package/dist/operator/experience-hints.d.ts.map +1 -0
- package/dist/operator/experience-hints.js +98 -0
- package/dist/operator/experience-hints.js.map +1 -0
- package/dist/operator/mama-memory-port.js +1 -3
- package/dist/operator/mama-memory-port.js.map +1 -1
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +3 -2
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/owner-action-effects.d.ts +13 -1
- package/dist/operator/owner-action-effects.d.ts.map +1 -1
- package/dist/operator/owner-action-effects.js +17 -4
- package/dist/operator/owner-action-effects.js.map +1 -1
- package/dist/operator/owner-event-inbox.d.ts +7 -1
- package/dist/operator/owner-event-inbox.d.ts.map +1 -1
- package/dist/operator/owner-event-inbox.js +8 -0
- package/dist/operator/owner-event-inbox.js.map +1 -1
- package/dist/operator/owner-event-loop.d.ts +28 -2
- package/dist/operator/owner-event-loop.d.ts.map +1 -1
- package/dist/operator/owner-event-loop.js +60 -2
- package/dist/operator/owner-event-loop.js.map +1 -1
- package/dist/operator/owner-event-policy.d.ts +20 -0
- package/dist/operator/owner-event-policy.d.ts.map +1 -1
- package/dist/operator/owner-event-policy.js +34 -5
- package/dist/operator/owner-event-policy.js.map +1 -1
- package/dist/operator/owner-event-prompt.d.ts +13 -4
- package/dist/operator/owner-event-prompt.d.ts.map +1 -1
- package/dist/operator/owner-event-prompt.js +31 -38
- package/dist/operator/owner-event-prompt.js.map +1 -1
- package/dist/operator/owner-runtime-journal.d.ts.map +1 -1
- package/dist/operator/owner-runtime-journal.js +7 -3
- package/dist/operator/owner-runtime-journal.js.map +1 -1
- package/dist/operator/owner-runtime.d.ts +6 -0
- package/dist/operator/owner-runtime.d.ts.map +1 -1
- package/dist/operator/owner-runtime.js +48 -5
- package/dist/operator/owner-runtime.js.map +1 -1
- package/dist/operator/procedure-activation.d.ts +7 -0
- package/dist/operator/procedure-activation.d.ts.map +1 -0
- package/dist/operator/procedure-activation.js +132 -0
- package/dist/operator/procedure-activation.js.map +1 -0
- package/dist/operator/procedure-projection.d.ts +25 -0
- package/dist/operator/procedure-projection.d.ts.map +1 -0
- package/dist/operator/procedure-projection.js +80 -0
- package/dist/operator/procedure-projection.js.map +1 -0
- package/dist/operator/procedure-runtime.d.ts +45 -0
- package/dist/operator/procedure-runtime.d.ts.map +1 -0
- package/dist/operator/procedure-runtime.js +496 -0
- package/dist/operator/procedure-runtime.js.map +1 -0
- package/dist/operator/procedure-store.d.ts +97 -0
- package/dist/operator/procedure-store.d.ts.map +1 -0
- package/dist/operator/procedure-store.js +368 -0
- package/dist/operator/procedure-store.js.map +1 -0
- package/dist/operator/subagent-stimulus.d.ts +34 -0
- package/dist/operator/subagent-stimulus.d.ts.map +1 -0
- package/dist/operator/subagent-stimulus.js +145 -0
- package/dist/operator/subagent-stimulus.js.map +1 -0
- package/dist/operator/task-ledger.d.ts +40 -3
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +63 -10
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/thread-brief-memory.d.ts +29 -0
- package/dist/operator/thread-brief-memory.d.ts.map +1 -0
- package/dist/operator/thread-brief-memory.js +61 -0
- package/dist/operator/thread-brief-memory.js.map +1 -0
- package/dist/operator/trigger-author.d.ts +2 -1
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +23 -0
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/trigger-matcher.js +1 -0
- package/dist/operator/trigger-matcher.js.map +1 -1
- package/dist/operator/trigger-registry.d.ts +5 -4
- package/dist/operator/trigger-registry.d.ts.map +1 -1
- package/dist/operator/trigger-registry.js +78 -24
- package/dist/operator/trigger-registry.js.map +1 -1
- package/dist/operator/trigger-review.d.ts +1 -1
- package/dist/operator/trigger-review.d.ts.map +1 -1
- package/dist/operator/trigger-review.js +24 -4
- package/dist/operator/trigger-review.js.map +1 -1
- package/dist/operator/trigger-types.d.ts +10 -1
- package/dist/operator/trigger-types.d.ts.map +1 -1
- package/dist/operator/worker-run.d.ts +13 -1
- package/dist/operator/worker-run.d.ts.map +1 -1
- package/dist/operator/worker-run.js +5 -2
- package/dist/operator/worker-run.js.map +1 -1
- package/dist/operator/workorder-consumer.d.ts +106 -14
- package/dist/operator/workorder-consumer.d.ts.map +1 -1
- package/dist/operator/workorder-consumer.js +295 -93
- package/dist/operator/workorder-consumer.js.map +1 -1
- package/dist/operator/workorder-hooks.d.ts +42 -9
- package/dist/operator/workorder-hooks.d.ts.map +1 -1
- package/dist/operator/workorder-hooks.js +52 -13
- package/dist/operator/workorder-hooks.js.map +1 -1
- package/dist/operator/workorder-publishers.d.ts +9 -1
- package/dist/operator/workorder-publishers.d.ts.map +1 -1
- package/dist/operator/workorder-publishers.js +21 -2
- package/dist/operator/workorder-publishers.js.map +1 -1
- package/package.json +2 -2
- package/dist/operator/learning-context.d.ts +0 -49
- package/dist/operator/learning-context.d.ts.map +0 -1
- package/dist/operator/learning-context.js +0 -129
- package/dist/operator/learning-context.js.map +0 -1
- package/dist/operator/learning-markers.d.ts +0 -19
- package/dist/operator/learning-markers.d.ts.map +0 -1
- package/dist/operator/learning-markers.js +0 -147
- package/dist/operator/learning-markers.js.map +0 -1
- package/dist/operator/learning-read.d.ts +0 -16
- package/dist/operator/learning-read.d.ts.map +0 -1
- package/dist/operator/learning-read.js +0 -18
- package/dist/operator/learning-read.js.map +0 -1
- package/dist/operator/turn-observer.d.ts +0 -34
- package/dist/operator/turn-observer.d.ts.map +0 -1
- package/dist/operator/turn-observer.js +0 -79
- package/dist/operator/turn-observer.js.map +0 -1
- package/templates/skills/heartbeat-report.md +0 -75
|
@@ -28,6 +28,7 @@ import { type OwnerEventBatch } from '../../operator/owner-event-inbox.js';
|
|
|
28
28
|
import { OwnerActionEffectLedger } from '../../operator/owner-action-effects.js';
|
|
29
29
|
import { OwnerEventEffectLedger } from '../../operator/owner-event-effects.js';
|
|
30
30
|
import { type OwnerEventTerminalReceipt } from '../../operator/owner-event-loop.js';
|
|
31
|
+
import { ADMINISTRATION_TOOLS } from '../../operator/owner-event-policy.js';
|
|
31
32
|
import { type WorkOrderConsumerEvent } from '../../operator/workorder-consumer.js';
|
|
32
33
|
import { type OwnerBackfillRegistry } from '../runtime/owner-backfill.js';
|
|
33
34
|
import type { EnvelopeAuthority } from '../../envelope/authority.js';
|
|
@@ -163,7 +164,7 @@ export declare const ONE_AGENT_TURN_POLICY: {
|
|
|
163
164
|
readonly roleName: "owner_console";
|
|
164
165
|
};
|
|
165
166
|
/** Owner-authored chat only: administration never runs unattended. */
|
|
166
|
-
export
|
|
167
|
+
export { ADMINISTRATION_TOOLS };
|
|
167
168
|
/**
|
|
168
169
|
* Per-turn-kind artifact tools, projected by the HOST. These exist only for scheduled
|
|
169
170
|
* turns and are deliberately absent from the chat grant: a chat turn never publishes a
|
|
@@ -172,10 +173,11 @@ export declare const ADMINISTRATION_TOOLS: ReadonlySet<string>;
|
|
|
172
173
|
*/
|
|
173
174
|
export declare const TURN_KIND_REQUIRED_TOOLS: Record<WorkOrderKind, readonly string[]>;
|
|
174
175
|
/**
|
|
175
|
-
* Blocked on EVERY unattended turn
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
176
|
+
* Blocked on EVERY unattended turn: administration plus the workspace shell and file
|
|
177
|
+
* writer. ONE list with the owner-event turn and native subagents
|
|
178
|
+
* (UNATTENDED_BLOCKED_TOOLS, owner-event-policy.ts) - this used to equal
|
|
179
|
+
* ADMINISTRATION_TOOLS alone, so a scheduled turn still held Bash/Write while both
|
|
180
|
+
* CLAUDE.md and the role comment said it did not.
|
|
179
181
|
*/
|
|
180
182
|
export declare const SCHEDULED_TURN_BLOCKED_TOOLS: ReadonlySet<string>;
|
|
181
183
|
/**
|
|
@@ -188,7 +190,7 @@ export declare const TURN_KIND_BLOCKED_TOOLS: Record<WorkOrderKind, ReadonlySet<
|
|
|
188
190
|
/** Progressive evidence primitives for a scheduled owner-runtime report turn. */
|
|
189
191
|
export declare const OPERATOR_REPORT_TOOL_POLICY: {
|
|
190
192
|
readonly roleName: "owner_console";
|
|
191
|
-
readonly allowedTools: readonly ["code_act", "task_list", "changes_read", "board_read", "audit_findings_read", "schedule_upcoming", "context_compile", "mama_recall", "mama_provenance", "trello_search", "trello_card", "trello_kanban"];
|
|
193
|
+
readonly allowedTools: readonly ["code_act", "task_list", "changes_read", "board_read", "report_publish", "audit_findings_read", "schedule_upcoming", "context_compile", "mama_recall", "mama_provenance", "trello_search", "trello_card", "trello_kanban"];
|
|
192
194
|
};
|
|
193
195
|
export interface WorkOrderAgentPolicy {
|
|
194
196
|
agentContext: AgentContext;
|
|
@@ -258,5 +260,4 @@ export declare function buildStartOnboardingOutput(state: OnboardingState): stri
|
|
|
258
260
|
export declare function runAgentLoop(config: Awaited<ReturnType<typeof loadConfig>>, options?: {
|
|
259
261
|
osAgentMode?: boolean;
|
|
260
262
|
}): Promise<void>;
|
|
261
|
-
export {};
|
|
262
263
|
//# sourceMappingURL=start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EAMX,MAAM,6BAA6B,CAAC;AAOrC,OAAO,KAAK,EACV,YAAY,EACZ,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EAMX,MAAM,6BAA6B,CAAC;AAOrC,OAAO,KAAK,EACV,YAAY,EACZ,2BAA2B,EAC3B,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAK9B,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;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,EAC9C,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,OAAO,CAAC,IAAI,CAAC,CA6mDf"}
|
|
@@ -77,7 +77,6 @@ const gateway_tool_executor_js_1 = require("../../agent/gateway-tool-executor.js
|
|
|
77
77
|
const context_compile_service_js_1 = require("../../agent/context-compile-service.js");
|
|
78
78
|
const read_js_1 = require("../../evidence/read.js");
|
|
79
79
|
const tool_registry_js_1 = require("../../agent/tool-registry.js");
|
|
80
|
-
const prompt_enhancer_js_1 = require("../../agent/prompt-enhancer.js");
|
|
81
80
|
const gateway_tool_catalog_js_1 = require("../../agent/gateway-tool-catalog.js");
|
|
82
81
|
const tool_policy_js_1 = require("../../agent/code-act/tool-policy.js");
|
|
83
82
|
const run_context_registry_js_1 = require("../../agent/code-act/run-context-registry.js");
|
|
@@ -123,6 +122,7 @@ const debugLogger = __importStar(require("@jungjaehoon/mama-core/debug-logger"))
|
|
|
123
122
|
const mama_core_1 = require("@jungjaehoon/mama-core");
|
|
124
123
|
const mamaCore = __importStar(require("@jungjaehoon/mama-core"));
|
|
125
124
|
const owner_runtime_js_1 = require("../../operator/owner-runtime.js");
|
|
125
|
+
const subagent_stimulus_js_1 = require("../../operator/subagent-stimulus.js");
|
|
126
126
|
const console_brief_js_1 = require("../../operator/console-brief.js");
|
|
127
127
|
const task_ledger_js_1 = require("../../operator/task-ledger.js");
|
|
128
128
|
const board_refresh_gate_js_1 = require("../../operator/board-refresh-gate.js");
|
|
@@ -135,10 +135,26 @@ const owner_action_effects_js_1 = require("../../operator/owner-action-effects.j
|
|
|
135
135
|
const owner_event_effects_js_1 = require("../../operator/owner-event-effects.js");
|
|
136
136
|
const owner_event_loop_js_1 = require("../../operator/owner-event-loop.js");
|
|
137
137
|
const board_pipeline_render_js_1 = require("../../operator/board-pipeline-render.js");
|
|
138
|
-
const
|
|
139
|
-
const
|
|
138
|
+
const procedure_store_js_1 = require("../../operator/procedure-store.js");
|
|
139
|
+
const procedure_activation_js_1 = require("../../operator/procedure-activation.js");
|
|
140
140
|
const owner_event_prompt_js_1 = require("../../operator/owner-event-prompt.js");
|
|
141
|
+
const thread_brief_memory_js_1 = require("../../operator/thread-brief-memory.js");
|
|
142
|
+
/**
|
|
143
|
+
* One in-process memory of the console brief already delivered on the owner:runtime
|
|
144
|
+
* thread. Both owner-event batches and scheduled work orders submit to that one thread,
|
|
145
|
+
* so a single memory keeps the standing brief there once instead of once per turn.
|
|
146
|
+
* A daemon restart clears it, which is correct: a resumed thread is fresh for this.
|
|
147
|
+
*/
|
|
148
|
+
const ownerBriefMemory = new thread_brief_memory_js_1.ThreadBriefMemory();
|
|
149
|
+
/**
|
|
150
|
+
* The owner-event loop builds a batch's prompt twice (once to size the run, once in
|
|
151
|
+
* prepareContent, which is the text actually sent). The brief decision must be the same
|
|
152
|
+
* both times, so it is decided once per batch. The loop is serial: one entry suffices.
|
|
153
|
+
*/
|
|
154
|
+
let lastOwnerEventBriefDecision = null;
|
|
155
|
+
const subagent_run_reconcile_js_1 = require("../../agent/subagent-run-reconcile.js");
|
|
141
156
|
const owner_event_policy_js_1 = require("../../operator/owner-event-policy.js");
|
|
157
|
+
Object.defineProperty(exports, "ADMINISTRATION_TOOLS", { enumerable: true, get: function () { return owner_event_policy_js_1.ADMINISTRATION_TOOLS; } });
|
|
142
158
|
const leg_cadence_js_1 = require("../../operator/leg-cadence.js");
|
|
143
159
|
const temporal_worker_js_1 = require("../../operator/temporal-worker.js");
|
|
144
160
|
const temporal_runtime_js_1 = require("../../operator/temporal-runtime.js");
|
|
@@ -209,6 +225,10 @@ function serializeCodeActExecutionResult(result, toolCalls, hostToolExecutions =
|
|
|
209
225
|
}
|
|
210
226
|
const TRUTHY_ENV_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
|
211
227
|
const CODE_ACT_MUTATION_TOOLS = new Set([
|
|
228
|
+
'procedure_update',
|
|
229
|
+
'procedure_retire',
|
|
230
|
+
'procedure_observe',
|
|
231
|
+
'console_brief_update',
|
|
212
232
|
'mama_save',
|
|
213
233
|
'context_compile',
|
|
214
234
|
'mama_update',
|
|
@@ -447,15 +467,6 @@ function buildCodeActRole(policy) {
|
|
|
447
467
|
* splits the advertised catalog from the execution envelope.
|
|
448
468
|
*/
|
|
449
469
|
exports.ONE_AGENT_TURN_POLICY = { roleName: 'owner_console' };
|
|
450
|
-
/** Owner-authored chat only: administration never runs unattended. */
|
|
451
|
-
exports.ADMINISTRATION_TOOLS = new Set([
|
|
452
|
-
'member_register',
|
|
453
|
-
'member_suspend',
|
|
454
|
-
'member_offboard',
|
|
455
|
-
'member_scope_grant',
|
|
456
|
-
'member_scope_revoke',
|
|
457
|
-
'console_brief_update',
|
|
458
|
-
]);
|
|
459
470
|
/**
|
|
460
471
|
* Per-turn-kind artifact tools, projected by the HOST. These exist only for scheduled
|
|
461
472
|
* turns and are deliberately absent from the chat grant: a chat turn never publishes a
|
|
@@ -480,12 +491,13 @@ exports.TURN_KIND_REQUIRED_TOOLS = {
|
|
|
480
491
|
'self-check': ['agent_notices', 'contract_no_update', 'repair_request', 'issue_close'],
|
|
481
492
|
};
|
|
482
493
|
/**
|
|
483
|
-
* Blocked on EVERY unattended turn
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
494
|
+
* Blocked on EVERY unattended turn: administration plus the workspace shell and file
|
|
495
|
+
* writer. ONE list with the owner-event turn and native subagents
|
|
496
|
+
* (UNATTENDED_BLOCKED_TOOLS, owner-event-policy.ts) - this used to equal
|
|
497
|
+
* ADMINISTRATION_TOOLS alone, so a scheduled turn still held Bash/Write while both
|
|
498
|
+
* CLAUDE.md and the role comment said it did not.
|
|
487
499
|
*/
|
|
488
|
-
exports.SCHEDULED_TURN_BLOCKED_TOOLS =
|
|
500
|
+
exports.SCHEDULED_TURN_BLOCKED_TOOLS = owner_event_policy_js_1.UNATTENDED_BLOCKED_TOOLS;
|
|
489
501
|
/**
|
|
490
502
|
* Per-turn-kind blocked lists, projected by the HOST. One principal and one brief do
|
|
491
503
|
* not mean one grant for every trigger: an unattended board or wiki turn has no owner
|
|
@@ -507,6 +519,7 @@ exports.OPERATOR_REPORT_TOOL_POLICY = {
|
|
|
507
519
|
'task_list',
|
|
508
520
|
'changes_read',
|
|
509
521
|
'board_read',
|
|
522
|
+
'report_publish',
|
|
510
523
|
'audit_findings_read',
|
|
511
524
|
'schedule_upcoming',
|
|
512
525
|
'context_compile',
|
|
@@ -546,7 +559,7 @@ function buildProjectedLanePrompt(innerTools, surface, privateConnectorPolicy) {
|
|
|
546
559
|
function buildOperatorReportAgentPolicy(model, backend, privateConnectorPolicy, ownerRole = types_js_1.DEFAULT_ROLES.definitions.owner_console) {
|
|
547
560
|
const requiredPrivatePolicy = requirePrivateConnectorPolicy(privateConnectorPolicy);
|
|
548
561
|
const blockedSet = new Set([
|
|
549
|
-
...
|
|
562
|
+
...owner_event_policy_js_1.ADMINISTRATION_TOOLS,
|
|
550
563
|
...exports.SCHEDULED_TURN_BLOCKED_TOOLS,
|
|
551
564
|
...(ownerRole.blockedTools ?? []),
|
|
552
565
|
]);
|
|
@@ -601,7 +614,7 @@ function buildTurnAgentPolicy(kind, model, backend, privateConnectorPolicy, rawC
|
|
|
601
614
|
// no private connector tools and gets the disabled brief projection.
|
|
602
615
|
const scopedSurface = exports.ONE_AGENT_TURN_POLICY.roleName;
|
|
603
616
|
const blockedSet = new Set([
|
|
604
|
-
...
|
|
617
|
+
...owner_event_policy_js_1.ADMINISTRATION_TOOLS,
|
|
605
618
|
...exports.SCHEDULED_TURN_BLOCKED_TOOLS,
|
|
606
619
|
...kindBlocked,
|
|
607
620
|
...(ownerRole.blockedTools ?? []),
|
|
@@ -898,6 +911,13 @@ async function runAgentLoop(config, options = {}) {
|
|
|
898
911
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
899
912
|
const { getAdapter } = require('@jungjaehoon/mama-core/db-manager');
|
|
900
913
|
const coreAdapter = getAdapter();
|
|
914
|
+
// A native child's model run is closed by the child's own terminal status, which a hard
|
|
915
|
+
// process death never delivers. Nothing at boot can confirm what such a child did, so
|
|
916
|
+
// its run is failed by name rather than left reading as work still in flight.
|
|
917
|
+
const orphanedSubagentRuns = (0, subagent_run_reconcile_js_1.failOrphanedSubagentModelRuns)(coreAdapter);
|
|
918
|
+
if (orphanedSubagentRuns > 0) {
|
|
919
|
+
console.warn(`[subagent] failed ${orphanedSubagentRuns} model run(s) left running by a previous process`);
|
|
920
|
+
}
|
|
901
921
|
const principalRegistry = createCorePrincipalRegistry(coreAdapter);
|
|
902
922
|
toolExecutor.setPrincipalRepository(principalRegistry);
|
|
903
923
|
(0, owner_backfill_js_1.backfillTelegramOwner)({
|
|
@@ -1206,6 +1226,22 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1206
1226
|
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
1207
1227
|
});
|
|
1208
1228
|
};
|
|
1229
|
+
// A native child the owner delegated to keeps working after the parent turn ended, so it
|
|
1230
|
+
// gets its OWN grant with its own wall. The parent's 300-600s envelope, which the child
|
|
1231
|
+
// cannot renew, would refuse every call it made past the parent's clock.
|
|
1232
|
+
//
|
|
1233
|
+
// It keeps the PARENT's channel, not a literal 'subagent': the grant's memory scopes are
|
|
1234
|
+
// derived from the channel (deriveMemoryScopes below), so a hardcoded channel gave the
|
|
1235
|
+
// child a channel scope nobody reads and dropped the parent's channel binding.
|
|
1236
|
+
const issueOwnerSubagentEnvelope = (channelId) => issueOwnerRuntimeEnvelope(channelId, 1800);
|
|
1237
|
+
/** Owner runtime paths must never run unauthorised: no envelope is a loud failure. */
|
|
1238
|
+
const requireOwnerRuntimeEnvelope = async (channelId, wallSeconds) => {
|
|
1239
|
+
const envelope = await issueOwnerRuntimeEnvelope(channelId, wallSeconds);
|
|
1240
|
+
if (!envelope) {
|
|
1241
|
+
throw new Error(`Owner runtime stimulus ${channelId} requires envelope authority`);
|
|
1242
|
+
}
|
|
1243
|
+
return envelope;
|
|
1244
|
+
};
|
|
1209
1245
|
const runOwnerStimulus = async (content, channelId) => {
|
|
1210
1246
|
return await agentLoop.run(content, {
|
|
1211
1247
|
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
@@ -1214,17 +1250,35 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1214
1250
|
sourceMessageRef: `owner-stimulus:${channelId}:${(0, node_crypto_1.randomUUID)()}`,
|
|
1215
1251
|
agentContext: backgroundOwnerContext,
|
|
1216
1252
|
sessionPolicyRole: ownerRole,
|
|
1217
|
-
prepareEnvelope:
|
|
1218
|
-
|
|
1219
|
-
if (!envelope)
|
|
1220
|
-
throw new Error(`Owner runtime stimulus ${channelId} requires envelope authority`);
|
|
1221
|
-
return envelope;
|
|
1222
|
-
},
|
|
1253
|
+
prepareEnvelope: () => requireOwnerRuntimeEnvelope(channelId, 600),
|
|
1254
|
+
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope(channelId),
|
|
1223
1255
|
requestTimeoutMs: 600_000,
|
|
1224
1256
|
});
|
|
1225
1257
|
};
|
|
1258
|
+
// A native subagent the owner delegated to finishes AFTER the owner's turn ended.
|
|
1259
|
+
// Its completion re-enters the one owner subject as a host stimulus, on the same
|
|
1260
|
+
// path heartbeat and cron use, so the owner conversation never waits on long work.
|
|
1261
|
+
const detachSubagentWake = (0, subagent_stimulus_js_1.attachSubagentWake)(agentLoop.getModelRunner(), async (event) => {
|
|
1262
|
+
return await agentLoop.run((0, subagent_stimulus_js_1.buildSubagentStimulus)(event), {
|
|
1263
|
+
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1264
|
+
source: 'operator',
|
|
1265
|
+
channelId: 'subagent',
|
|
1266
|
+
agentContext: backgroundOwnerContext,
|
|
1267
|
+
sessionPolicyRole: ownerRole,
|
|
1268
|
+
// Same fail-loud rule as every sibling owner path: issuance off must stop the turn,
|
|
1269
|
+
// never let it run unauthorised.
|
|
1270
|
+
prepareEnvelope: () => requireOwnerRuntimeEnvelope('subagent', 300),
|
|
1271
|
+
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('subagent'),
|
|
1272
|
+
sourceMessageRef: (0, subagent_stimulus_js_1.subagentStimulusSourceRef)(event),
|
|
1273
|
+
ownerJournalPrompt: (0, subagent_stimulus_js_1.buildSubagentStimulusBlock)(event),
|
|
1274
|
+
lanePriority: 10,
|
|
1275
|
+
});
|
|
1276
|
+
});
|
|
1226
1277
|
const cronOwnerRunner = {
|
|
1227
1278
|
backendType: runtimeBackend,
|
|
1279
|
+
// A facade over agentLoop.run: whether a native subagent can be spawned is decided by
|
|
1280
|
+
// the real runner underneath, not by this shim.
|
|
1281
|
+
supportsNativeSubagents: agentLoop.supportsNativeSubagents,
|
|
1228
1282
|
prompt: async (content) => {
|
|
1229
1283
|
const result = await runOwnerStimulus(content, 'cron');
|
|
1230
1284
|
return {
|
|
@@ -1248,6 +1302,8 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1248
1302
|
// ── Phase 7: Gateways ────────────────────────────────────────────────────
|
|
1249
1303
|
const gatewayInit = await (0, gateway_init_js_1.initGateways)(config, messageRouter, toolExecutor, agentLoop, runtimeBackend, db, principalResolver);
|
|
1250
1304
|
const { discordGateway, slackGateway, telegramGateway, gateways } = gatewayInit;
|
|
1305
|
+
// The wake subscription is a live listener on the runner; shutdown detaches it.
|
|
1306
|
+
gateways.push({ stop: async () => detachSubagentWake() });
|
|
1251
1307
|
// ── Phase 8: Gateway Wiring ──────────────────────────────────────────────
|
|
1252
1308
|
const { pluginLoader } = await (0, gateway_wiring_js_1.wireGateways)({
|
|
1253
1309
|
config,
|
|
@@ -1268,6 +1324,7 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1268
1324
|
agentContext: backgroundOwnerContext,
|
|
1269
1325
|
sessionPolicyRole: ownerRole,
|
|
1270
1326
|
prepareEnvelope: () => issueOwnerRuntimeEnvelope('heartbeat', 300),
|
|
1327
|
+
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('heartbeat'),
|
|
1271
1328
|
};
|
|
1272
1329
|
});
|
|
1273
1330
|
// M2.4 freshness: the connector sink nudges the trigger loop when a poll indexes new rows. The
|
|
@@ -1282,6 +1339,13 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1282
1339
|
const operatorDbPath = (0, config_manager_js_1.expandPath)('~/.mama/operator/triggers.db');
|
|
1283
1340
|
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(operatorDbPath), { recursive: true });
|
|
1284
1341
|
const operatorDb = new sqlite_js_1.default(operatorDbPath);
|
|
1342
|
+
const procedureStore = new procedure_store_js_1.ProcedureStore(operatorDb);
|
|
1343
|
+
toolExecutor.setProcedureStore(procedureStore);
|
|
1344
|
+
messageRouter.setProcedureStore(procedureStore);
|
|
1345
|
+
const readCanonicalOwnerBrief = () => (0, console_brief_js_1.modernizeLegacyBriefMechanism)(procedureStore.read('owner-console-brief', {
|
|
1346
|
+
ownerScope: 'owner:runtime',
|
|
1347
|
+
projectId: (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env),
|
|
1348
|
+
})?.body ?? (0, console_brief_js_1.loadConsoleBrief)());
|
|
1285
1349
|
let taskLedger;
|
|
1286
1350
|
const refreshTaskBoard = { current: null };
|
|
1287
1351
|
try {
|
|
@@ -1452,7 +1516,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1452
1516
|
resolveWorkerRequestTimeoutMs();
|
|
1453
1517
|
let workOrderConsumer = null;
|
|
1454
1518
|
const boardRepairNudge = { current: null };
|
|
1455
|
-
const learningBlockRef = { current: null };
|
|
1456
1519
|
let temporalRuntime = null;
|
|
1457
1520
|
gateways.push({
|
|
1458
1521
|
stop: async () => {
|
|
@@ -1498,6 +1561,9 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1498
1561
|
// AgentLoopClient.runWithContent is optional in its type; a missing method
|
|
1499
1562
|
// is a boot-order fault and must throw, not no-op (WorkerRunner adapter).
|
|
1500
1563
|
const workerRunner = {
|
|
1564
|
+
// The scheduled contract's delegated shape and the `delegated` attempt state both
|
|
1565
|
+
// follow the ACTIVE runner, not the configured backend name.
|
|
1566
|
+
supportsNativeSubagents: agentLoopClient.supportsNativeSubagents === true,
|
|
1501
1567
|
runWithContent: async (content, options) => {
|
|
1502
1568
|
if (!agentLoopClient.runWithContent) {
|
|
1503
1569
|
throw new Error('[stage2] agentLoopClient.runWithContent unavailable');
|
|
@@ -1519,31 +1585,13 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1519
1585
|
hasUnsafeReplayEffects: (wo) => ownerActionEffectLedger.hasUnsafeReplayEffects(`workorder:${wo.idempotencyKey}`),
|
|
1520
1586
|
ledger: taskLedger,
|
|
1521
1587
|
runner: workerRunner,
|
|
1522
|
-
loadOwnerBrief:
|
|
1588
|
+
loadOwnerBrief: readCanonicalOwnerBrief,
|
|
1589
|
+
// One memory for the one owner:runtime thread: whichever lane sends the brief
|
|
1590
|
+
// first satisfies the other, so a correction reaches the thread exactly once.
|
|
1591
|
+
admitOwnerBrief: (brief) => ownerBriefMemory.admit(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY, brief),
|
|
1592
|
+
retractOwnerBrief: () => ownerBriefMemory.forget(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY),
|
|
1523
1593
|
// Host-rendered pipeline: the ledger's own deadline_priority page, published through
|
|
1524
1594
|
// the SAME report publisher report_publish uses (bound after the API routes exist).
|
|
1525
|
-
buildLearningBlock: async (wo) => {
|
|
1526
|
-
const build = learningBlockRef.current;
|
|
1527
|
-
if (!build) {
|
|
1528
|
-
return '';
|
|
1529
|
-
}
|
|
1530
|
-
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
1531
|
-
// Same binding the run's envelope gets: a recheck's lessons live under its task's channel.
|
|
1532
|
-
const temporalBinding = wo.workKind === 'temporal'
|
|
1533
|
-
? temporalTaskBinding(taskLedger, (0, temporal_worker_js_1.buildTemporalWorkerContext)(taskLedger, wo).taskId)
|
|
1534
|
-
: null;
|
|
1535
|
-
const scope = workOrderEnvelopeScope({
|
|
1536
|
-
workKind: wo.workKind,
|
|
1537
|
-
projectId,
|
|
1538
|
-
laneConnectors: codeActRawConnectors,
|
|
1539
|
-
temporalBinding,
|
|
1540
|
-
reconcileChannelKey: wo.workKind === 'board' && typeof wo.payload.channelKey === 'string'
|
|
1541
|
-
? wo.payload.channelKey
|
|
1542
|
-
: null,
|
|
1543
|
-
privateConnectorPolicy,
|
|
1544
|
-
});
|
|
1545
|
-
return build(wo.workKind, scope.memory_scopes, wo.workKind);
|
|
1546
|
-
},
|
|
1547
1595
|
selfCheckInput: () => ({
|
|
1548
1596
|
openIssues: (0, operational_issues_js_1.listOpenOperationalIssues)(issueDb, 20, 'warn').map((issue) => ({
|
|
1549
1597
|
issueId: issue.issueId,
|
|
@@ -1653,6 +1701,25 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1653
1701
|
budget: { wall_seconds: wallSeconds },
|
|
1654
1702
|
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
1655
1703
|
});
|
|
1704
|
+
// A native child the turn delegates long maintenance work to keeps working after
|
|
1705
|
+
// the parent attempt returned, so it needs its OWN grant on the SAME scope with a
|
|
1706
|
+
// wall it can actually finish inside. The parent's 900s envelope, which the child
|
|
1707
|
+
// cannot renew, would refuse every call it made past the parent's clock - the same
|
|
1708
|
+
// reason issueOwnerSubagentEnvelope exists for owner turns.
|
|
1709
|
+
const subagentWallSeconds = 1800;
|
|
1710
|
+
runOptions.prepareSubagentEnvelope = () => workOrderEnvelopeAuthority.buildAndPersist({
|
|
1711
|
+
agent_id: 'mama-owner',
|
|
1712
|
+
instance_id: (0, node_crypto_1.randomUUID)(),
|
|
1713
|
+
source: 'watch',
|
|
1714
|
+
channel_id: `worker:${wo.workKind}`,
|
|
1715
|
+
trigger_context: {
|
|
1716
|
+
user_text: `<stage2 workorder subagent ${wo.workKind}#${wo.id}>`,
|
|
1717
|
+
},
|
|
1718
|
+
scope: workOrderScope,
|
|
1719
|
+
tier: 2,
|
|
1720
|
+
budget: { wall_seconds: subagentWallSeconds },
|
|
1721
|
+
expires_at: new Date(Date.now() + subagentWallSeconds * 1000 + 30_000).toISOString(),
|
|
1722
|
+
});
|
|
1656
1723
|
}
|
|
1657
1724
|
return Object.keys(runOptions).length > 0 ? runOptions : undefined;
|
|
1658
1725
|
},
|
|
@@ -1710,25 +1777,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1710
1777
|
if (connectorSchedulerStop) {
|
|
1711
1778
|
gateways.push({ stop: () => Promise.resolve(connectorSchedulerStop()) });
|
|
1712
1779
|
}
|
|
1713
|
-
// Owner policy and lessons: bound BEFORE the consumer starts (bootAfterRoutes) and
|
|
1714
|
-
// independent of the trigger loop, so scheduled turns carry the block even when
|
|
1715
|
-
// MAMA_TRIGGER_LOOP=0.
|
|
1716
|
-
// Owner policy and lessons for a turn: one bounded read path for event, scheduled
|
|
1717
|
-
// and (via MamaApiClient) chat turns. Returns the rendered block or ''.
|
|
1718
|
-
const learningReader = (0, learning_read_js_1.cappedLearningReader)((params) => mamaCore.queryRelevantTruth({ query: params.query, scopes: params.scopes }), (line) => console.log(line));
|
|
1719
|
-
const buildLearningBlockFor = async (turn, scopes, query) => {
|
|
1720
|
-
try {
|
|
1721
|
-
const context = await (0, learning_context_js_1.buildLearningContext)({ scopes, query, readClaims: learningReader });
|
|
1722
|
-
const channelScopeId = scopes.find((scope) => scope.kind === 'channel')?.id ?? null;
|
|
1723
|
-
console.log((0, learning_context_js_1.formatLearningAuditLine)(turn, channelScopeId, context));
|
|
1724
|
-
return context.promptBlock;
|
|
1725
|
-
}
|
|
1726
|
-
catch (error) {
|
|
1727
|
-
console.error(`[learning] ${turn} block failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1728
|
-
return '';
|
|
1729
|
-
}
|
|
1730
|
-
};
|
|
1731
|
-
learningBlockRef.current = buildLearningBlockFor;
|
|
1732
1780
|
// ── Trigger loop (M1, default-on): agent-evolved triggers on the live stream ──
|
|
1733
1781
|
// MAMA_TRIGGER_LOOP=0 is the explicit opt-out. Placed after initConnectors (which feeds
|
|
1734
1782
|
// connector_event_index) and after mama-core initDB. Read-only: recall/surface/log.
|
|
@@ -1818,6 +1866,7 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1818
1866
|
throw new Error('Owner maintenance requires envelope authority');
|
|
1819
1867
|
return envelope;
|
|
1820
1868
|
},
|
|
1869
|
+
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('trigger-maintenance'),
|
|
1821
1870
|
requestTimeoutMs: 600_000,
|
|
1822
1871
|
});
|
|
1823
1872
|
return result.response;
|
|
@@ -1851,6 +1900,7 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1851
1900
|
throw new Error('Owner report requires envelope authority');
|
|
1852
1901
|
return envelope;
|
|
1853
1902
|
},
|
|
1903
|
+
prepareSubagentEnvelope: () => issueOwnerSubagentEnvelope('report'),
|
|
1854
1904
|
requestTimeoutMs: 600_000,
|
|
1855
1905
|
ownerJournalPrompt: `Report stimulus: ${sourceMessageRef}`,
|
|
1856
1906
|
sourceMessageRef,
|
|
@@ -1943,7 +1993,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1943
1993
|
ownerRole,
|
|
1944
1994
|
privateConnectorPolicy,
|
|
1945
1995
|
});
|
|
1946
|
-
const ownerEventPromptEnhancer = new prompt_enhancer_js_1.PromptEnhancer();
|
|
1947
1996
|
// ONE expression for what an event turn may read: the envelope and the
|
|
1948
1997
|
// packet are both built from it, so they can never disagree.
|
|
1949
1998
|
const ownerEventReadScope = (batch) => {
|
|
@@ -1987,16 +2036,47 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1987
2036
|
runner: agentLoop,
|
|
1988
2037
|
agentContext: ownerEventContext,
|
|
1989
2038
|
ownerRuntimeRole: ownerRole,
|
|
2039
|
+
resolveActivation: (activation, batch) => (0, procedure_activation_js_1.resolveProcedureActivation)(procedureStore, {
|
|
2040
|
+
ownerScope: 'owner:runtime',
|
|
2041
|
+
projectId: ownerEventReadScope(batch).projectRefs[0].id,
|
|
2042
|
+
channelId: ownerEventReadScope(batch).memoryScopes.find((s) => s.kind === 'channel')
|
|
2043
|
+
?.id,
|
|
2044
|
+
}, activation),
|
|
2045
|
+
assertActiveActivations: (batch) => (0, procedure_activation_js_1.assertActiveProcedureActivations)(procedureStore, {
|
|
2046
|
+
ownerScope: 'owner:runtime',
|
|
2047
|
+
projectId: ownerEventReadScope(batch).projectRefs[0].id,
|
|
2048
|
+
channelId: ownerEventReadScope(batch).memoryScopes.find((s) => s.kind === 'channel')
|
|
2049
|
+
?.id,
|
|
2050
|
+
}, batch),
|
|
1990
2051
|
buildPrompt: async (batch) => {
|
|
1991
|
-
const
|
|
2052
|
+
const projectedBrief = (0, console_brief_js_1.projectConsoleBriefForPrompt)(readCanonicalOwnerBrief(), privateConnectorPolicy);
|
|
2053
|
+
const batchId = String(batch.id);
|
|
2054
|
+
const carryBrief = lastOwnerEventBriefDecision?.batchId === batchId
|
|
2055
|
+
? lastOwnerEventBriefDecision.carry
|
|
2056
|
+
: ownerBriefMemory.admit(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY, projectedBrief);
|
|
2057
|
+
lastOwnerEventBriefDecision = { batchId, carry: carryBrief };
|
|
1992
2058
|
return (0, owner_event_prompt_js_1.buildOwnerEventPrompt)({
|
|
1993
2059
|
batch,
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2060
|
+
// Standing policy goes on the thread once; an owner correction to the brief
|
|
2061
|
+
// changes its hash and is carried on the next turn.
|
|
2062
|
+
ownerBrief: carryBrief ? projectedBrief : null,
|
|
1997
2063
|
ownerTelegramChatId: reportChatId,
|
|
1998
2064
|
});
|
|
1999
2065
|
},
|
|
2066
|
+
promptBriefState: (batch) => lastOwnerEventBriefDecision?.batchId === String(batch.id) &&
|
|
2067
|
+
lastOwnerEventBriefDecision.carry
|
|
2068
|
+
? 'sent'
|
|
2069
|
+
: 'omitted',
|
|
2070
|
+
// No model turn ran, so the brief this batch admitted was never delivered on the
|
|
2071
|
+
// owner thread: forget it so the retry carries it again.
|
|
2072
|
+
retractBrief: (batch) => {
|
|
2073
|
+
if (lastOwnerEventBriefDecision?.batchId !== String(batch.id))
|
|
2074
|
+
return;
|
|
2075
|
+
if (lastOwnerEventBriefDecision.carry) {
|
|
2076
|
+
ownerBriefMemory.forget(owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY);
|
|
2077
|
+
}
|
|
2078
|
+
lastOwnerEventBriefDecision = null;
|
|
2079
|
+
},
|
|
2000
2080
|
issueEnvelope: ownerEventIssueEnvelope,
|
|
2001
2081
|
getNoUpdateMaxId: (scope) => taskLedger.maxNoUpdateId(scope),
|
|
2002
2082
|
hasUnsafeReplayEffects: (batch) => ownerActionEffectLedger.hasUnsafeReplayEffects(`owner-event:${batch.id}`),
|
|
@@ -2006,7 +2086,7 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2006
2086
|
ownerActionEffectLedger,
|
|
2007
2087
|
taskLedger,
|
|
2008
2088
|
}),
|
|
2009
|
-
recordTriggerOutcome: (triggerId, outcome) => triggerRegistry.recordOutcome(triggerId, outcome),
|
|
2089
|
+
recordTriggerOutcome: (triggerId, outcome, receiptId) => triggerRegistry.recordOutcome(triggerId, outcome, receiptId),
|
|
2010
2090
|
onDead: async (message) => {
|
|
2011
2091
|
console.error(message);
|
|
2012
2092
|
await (0, leg_cadence_js_1.getLegPageNotifier)()?.(message);
|