@jungjaehoon/mama-os 0.36.0 → 0.37.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/dist/agent/agent-loop.d.ts +2 -1
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +17 -12
- 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 +27 -2
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/type-definition-generator.d.ts.map +1 -1
- package/dist/agent/code-act/type-definition-generator.js +3 -1
- package/dist/agent/code-act/type-definition-generator.js.map +1 -1
- package/dist/agent/context-compile-service.d.ts +2 -0
- package/dist/agent/context-compile-service.d.ts.map +1 -1
- package/dist/agent/context-compile-service.js +1 -1
- package/dist/agent/context-compile-service.js.map +1 -1
- package/dist/agent/drive-tools.d.ts +27 -1
- package/dist/agent/drive-tools.d.ts.map +1 -1
- package/dist/agent/drive-tools.js +68 -2
- package/dist/agent/drive-tools.js.map +1 -1
- package/dist/agent/gateway-tool-executor.d.ts +11 -6
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +210 -37
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +2 -2
- package/dist/agent/tool-registry.js +2 -2
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +15 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/report-handler.d.ts +9 -5
- package/dist/api/report-handler.d.ts.map +1 -1
- package/dist/api/report-handler.js +26 -13
- package/dist/api/report-handler.js.map +1 -1
- package/dist/api/report-persistence.d.ts.map +1 -1
- package/dist/api/report-persistence.js +6 -3
- package/dist/api/report-persistence.js.map +1 -1
- package/dist/api/runtime-status-handler.d.ts +1 -0
- package/dist/api/runtime-status-handler.d.ts.map +1 -1
- package/dist/api/runtime-status-handler.js +1 -0
- package/dist/api/runtime-status-handler.js.map +1 -1
- package/dist/cli/commands/start.d.ts +14 -20
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +207 -248
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.d.ts +6 -0
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +89 -0
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config/types.d.ts +0 -21
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +0 -7
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/index.js +2 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts +2 -2
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +3 -3
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +7 -1
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +99 -38
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-server-init.js +3 -0
- package/dist/cli/runtime/api-server-init.js.map +1 -1
- package/dist/gateways/message-router.js +10 -10
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/telegram.d.ts +2 -2
- package/dist/gateways/telegram.d.ts.map +1 -1
- package/dist/gateways/telegram.js +13 -7
- package/dist/gateways/telegram.js.map +1 -1
- package/dist/multi-agent/agent-event-bus.d.ts +0 -5
- package/dist/multi-agent/agent-event-bus.d.ts.map +1 -1
- package/dist/multi-agent/agent-event-bus.js.map +1 -1
- package/dist/operator/action-verifier.d.ts +2 -0
- package/dist/operator/action-verifier.d.ts.map +1 -1
- package/dist/operator/action-verifier.js +3 -2
- package/dist/operator/action-verifier.js.map +1 -1
- package/dist/operator/board-reconcile.d.ts +2 -2
- package/dist/operator/board-reconcile.d.ts.map +1 -1
- package/dist/operator/board-reconcile.js +10 -2
- package/dist/operator/board-reconcile.js.map +1 -1
- package/dist/operator/board-refresh-gate.d.ts +34 -0
- package/dist/operator/board-refresh-gate.d.ts.map +1 -0
- package/dist/operator/board-refresh-gate.js +82 -0
- package/dist/operator/board-refresh-gate.js.map +1 -0
- package/dist/operator/briefs.d.ts.map +1 -1
- package/dist/operator/briefs.js +92 -4
- package/dist/operator/briefs.js.map +1 -1
- package/dist/operator/operator-trigger-loop.d.ts +7 -22
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +33 -34
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/owner-event-effects.d.ts +34 -0
- package/dist/operator/owner-event-effects.d.ts.map +1 -0
- package/dist/operator/owner-event-effects.js +131 -0
- package/dist/operator/owner-event-effects.js.map +1 -0
- package/dist/operator/{conductor-inbox.d.ts → owner-event-inbox.d.ts} +23 -12
- package/dist/operator/owner-event-inbox.d.ts.map +1 -0
- package/dist/operator/{conductor-inbox.js → owner-event-inbox.js} +97 -40
- package/dist/operator/owner-event-inbox.js.map +1 -0
- package/dist/operator/owner-event-loop.d.ts +59 -0
- package/dist/operator/owner-event-loop.d.ts.map +1 -0
- package/dist/operator/owner-event-loop.js +141 -0
- package/dist/operator/owner-event-loop.js.map +1 -0
- package/dist/operator/owner-event-outcome.d.ts +30 -0
- package/dist/operator/owner-event-outcome.d.ts.map +1 -0
- package/dist/operator/owner-event-outcome.js +108 -0
- package/dist/operator/owner-event-outcome.js.map +1 -0
- package/dist/operator/owner-event-policy.d.ts +20 -0
- package/dist/operator/owner-event-policy.d.ts.map +1 -0
- package/dist/operator/owner-event-policy.js +50 -0
- package/dist/operator/owner-event-policy.js.map +1 -0
- package/dist/operator/owner-event-prompt.d.ts +10 -0
- package/dist/operator/owner-event-prompt.d.ts.map +1 -0
- package/dist/operator/owner-event-prompt.js +63 -0
- package/dist/operator/owner-event-prompt.js.map +1 -0
- package/dist/operator/task-ledger.d.ts +2 -0
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +12 -1
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/trigger-matcher.d.ts.map +1 -1
- package/dist/operator/trigger-matcher.js +4 -1
- package/dist/operator/trigger-matcher.js.map +1 -1
- package/dist/operator/trigger-registry.d.ts +1 -1
- package/dist/operator/trigger-registry.d.ts.map +1 -1
- package/dist/operator/trigger-registry.js +2 -2
- package/dist/operator/trigger-registry.js.map +1 -1
- package/dist/operator/trigger-types.d.ts +2 -0
- package/dist/operator/trigger-types.d.ts.map +1 -1
- package/dist/operator/workorder-hooks.d.ts +14 -0
- package/dist/operator/workorder-hooks.d.ts.map +1 -1
- package/dist/operator/workorder-hooks.js +64 -0
- package/dist/operator/workorder-hooks.js.map +1 -1
- package/dist/operator/workorder-publishers.d.ts +14 -4
- package/dist/operator/workorder-publishers.d.ts.map +1 -1
- package/dist/operator/workorder-publishers.js +51 -13
- package/dist/operator/workorder-publishers.js.map +1 -1
- package/dist/package-version.d.ts +3 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +18 -0
- package/dist/package-version.js.map +1 -0
- package/package.json +2 -2
- package/public/viewer/js/modules/system.js +1 -0
- package/public/viewer/src/modules/system.ts +2 -0
- package/dist/operator/board-reground.d.ts +0 -19
- package/dist/operator/board-reground.d.ts.map +0 -1
- package/dist/operator/board-reground.js +0 -31
- package/dist/operator/board-reground.js.map +0 -1
- package/dist/operator/conductor-inbox.d.ts.map +0 -1
- package/dist/operator/conductor-inbox.js.map +0 -1
- package/dist/operator/conductor-session.d.ts +0 -55
- package/dist/operator/conductor-session.d.ts.map +0 -1
- package/dist/operator/conductor-session.js +0 -110
- package/dist/operator/conductor-session.js.map +0 -1
- package/dist/operator/conductor.d.ts +0 -69
- package/dist/operator/conductor.d.ts.map +0 -1
- package/dist/operator/conductor.js +0 -90
- package/dist/operator/conductor.js.map +0 -1
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConductorSession = exports.CONDUCTOR_POOL_KEY = exports.CONDUCTOR_SESSION_KEY = exports.CONDUCTOR_CHANNEL_ID = exports.CONDUCTOR_SOURCE = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Session lifecycle for the stateful conductor.
|
|
6
|
-
*
|
|
7
|
-
* Injected text persists in a long-lived buffer - that is the pivot's one new
|
|
8
|
-
* risk, and this class is the antidote: sessions are disposable on age, turn,
|
|
9
|
-
* token, idle, or suspicion budgets, and every fresh session (boot included)
|
|
10
|
-
* owes the board one re-ground before its first judgment. State survives
|
|
11
|
-
* because it lives in cards; the buffer never has to.
|
|
12
|
-
*
|
|
13
|
-
* Recycle does NOT touch the pool directly: agent-loop's `freshSession: true`
|
|
14
|
-
* is the one sanctioned reset path (it resets the pool entry AND marks the
|
|
15
|
-
* run new in the same place - review F5: `pool.resetSession()` alone swaps a
|
|
16
|
-
* UUID while the fallback branch overwrites `resumeSession` with the pool's
|
|
17
|
-
* own `isNew`, so the old buffer survives). The conductor passes
|
|
18
|
-
* `freshSession: true` whenever `needsReground()` is true.
|
|
19
|
-
*/
|
|
20
|
-
const session_pool_js_1 = require("../agent/session-pool.js");
|
|
21
|
-
exports.CONDUCTOR_SOURCE = 'conductor';
|
|
22
|
-
exports.CONDUCTOR_CHANNEL_ID = 'conductor';
|
|
23
|
-
// THREE keys, one identity. The LANE comes from the session key's FIRST
|
|
24
|
-
// `:` segment (agent-loop.ts resolveGlobalLaneForSession) - NOT from
|
|
25
|
-
// options.source. 'operator:conductor' would resolve to the GLOBAL operator
|
|
26
|
-
// lane where Stage-2 workers serialize (review F1), so the key must lead
|
|
27
|
-
// with a segment absent from SOURCE_GLOBAL_LANES.
|
|
28
|
-
exports.CONDUCTOR_SESSION_KEY = 'conductor:main'; // lane: session:conductor:main
|
|
29
|
-
/** Pool identity: agent-loop derives it from (source, channelId). */
|
|
30
|
-
exports.CONDUCTOR_POOL_KEY = (0, session_pool_js_1.buildChannelKey)(exports.CONDUCTOR_SOURCE, exports.CONDUCTOR_CHANNEL_ID);
|
|
31
|
-
const DEFAULTS = {
|
|
32
|
-
maxAgeMs: 6 * 60 * 60 * 1000,
|
|
33
|
-
maxTurns: 400,
|
|
34
|
-
// Below the pool's own 160k context threshold (session-pool.ts
|
|
35
|
-
// CONTEXT_THRESHOLD_TOKENS) so the conductor always recycles BEFORE the
|
|
36
|
-
// pool silently swaps the session out from under it.
|
|
37
|
-
maxTokens: 150_000,
|
|
38
|
-
idleExpiryMs: 25 * 60 * 1000,
|
|
39
|
-
};
|
|
40
|
-
class ConductorSession {
|
|
41
|
-
pool;
|
|
42
|
-
now;
|
|
43
|
-
policy;
|
|
44
|
-
bornAt;
|
|
45
|
-
turns = 0;
|
|
46
|
-
lastRunAt;
|
|
47
|
-
suspicion = null;
|
|
48
|
-
regroundDue = true; // boot = fresh session = restart recovery
|
|
49
|
-
constructor(pool, policy = {}, now = () => Date.now()) {
|
|
50
|
-
this.pool = pool;
|
|
51
|
-
this.now = now;
|
|
52
|
-
this.policy = { ...DEFAULTS, ...policy };
|
|
53
|
-
this.bornAt = this.now();
|
|
54
|
-
this.lastRunAt = this.bornAt;
|
|
55
|
-
}
|
|
56
|
-
noteTurn() {
|
|
57
|
-
this.turns += 1;
|
|
58
|
-
this.lastRunAt = this.now();
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Force a recycle on the next tick. No production detector calls this yet -
|
|
62
|
-
* wiring one (denied-tool patterns, instruction-shaped batch lines) is named
|
|
63
|
-
* S2 work. The recycle path itself is pinned by tests so the hook is live
|
|
64
|
-
* the day a detector exists.
|
|
65
|
-
*/
|
|
66
|
-
flagSuspicion(reason) {
|
|
67
|
-
this.suspicion = reason;
|
|
68
|
-
}
|
|
69
|
-
shouldRecycle() {
|
|
70
|
-
if (this.suspicion) {
|
|
71
|
-
return `suspicion: ${this.suspicion}`;
|
|
72
|
-
}
|
|
73
|
-
if (this.now() - this.bornAt > this.policy.maxAgeMs) {
|
|
74
|
-
return 'max_age';
|
|
75
|
-
}
|
|
76
|
-
if (this.now() - this.lastRunAt > this.policy.idleExpiryMs) {
|
|
77
|
-
return 'idle_expiry';
|
|
78
|
-
}
|
|
79
|
-
if (this.turns >= this.policy.maxTurns) {
|
|
80
|
-
return 'max_turns';
|
|
81
|
-
}
|
|
82
|
-
if (this.pool.getTokenUsage(exports.CONDUCTOR_POOL_KEY) >= this.policy.maxTokens) {
|
|
83
|
-
return 'max_tokens';
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
recycle(reason) {
|
|
88
|
-
this.bornAt = this.now();
|
|
89
|
-
this.lastRunAt = this.bornAt;
|
|
90
|
-
this.turns = 0;
|
|
91
|
-
this.suspicion = null;
|
|
92
|
-
this.regroundDue = true;
|
|
93
|
-
return { needsReground: true, reason };
|
|
94
|
-
}
|
|
95
|
-
/** Read-only: does the next run owe the board a re-ground? */
|
|
96
|
-
needsReground() {
|
|
97
|
-
return this.regroundDue;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Called ONLY after a successful re-grounded run. A failed run must not
|
|
101
|
-
* consume the re-ground - the retry still owes the board its context
|
|
102
|
-
* (review: consume-before-run dropped the re-ground on the floor when the
|
|
103
|
-
* first run of a fresh session threw).
|
|
104
|
-
*/
|
|
105
|
-
markRegrounded() {
|
|
106
|
-
this.regroundDue = false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.ConductorSession = ConductorSession;
|
|
110
|
-
//# sourceMappingURL=conductor-session.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conductor-session.js","sourceRoot":"","sources":["../../src/operator/conductor-session.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;A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AAc;QACZ,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF;AA3ED,4CA2EC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The stateful conductor: consumes the durable inbox, judges each batch in
|
|
3
|
-
* ONE long-lived session, and delegates by COMMITTING work orders only - it
|
|
4
|
-
* never awaits a worker from its model turn.
|
|
5
|
-
*
|
|
6
|
-
* Lane: the session key 'conductor:main' leads with a segment absent from
|
|
7
|
-
* SOURCE_GLOBAL_LANES, so runs land on session:conductor:main - fully
|
|
8
|
-
* separate from the global operator lane where Stage-2 workers serialize
|
|
9
|
-
* (worker-run.ts documents the deadlock seal). The lane is derived from the
|
|
10
|
-
* session key's FIRST segment, not options.source (agent-loop.ts
|
|
11
|
-
* resolveGlobalLaneForSession) - tests pin this axis.
|
|
12
|
-
*
|
|
13
|
-
* Trust boundary: batch lines are connector-channel text - attacker-authored
|
|
14
|
-
* by definition, and this session's buffer is long-lived. Every batch enters
|
|
15
|
-
* the prompt through wrapUntrustedContent (the spec's standing "wrapping
|
|
16
|
-
* remains the first line"), under an owner-authored framing instruction.
|
|
17
|
-
*/
|
|
18
|
-
import type { ConductorInbox } from './conductor-inbox.js';
|
|
19
|
-
import { type ConductorSession } from './conductor-session.js';
|
|
20
|
-
import type { AgentContext } from '../agent/types.js';
|
|
21
|
-
import type { Envelope } from '../envelope/types.js';
|
|
22
|
-
interface RunnerLike {
|
|
23
|
-
run(prompt: string, options?: {
|
|
24
|
-
sessionKey?: string;
|
|
25
|
-
source?: string;
|
|
26
|
-
channelId?: string;
|
|
27
|
-
resumeSession?: boolean;
|
|
28
|
-
freshSession?: boolean;
|
|
29
|
-
agentContext?: AgentContext;
|
|
30
|
-
envelope?: Envelope;
|
|
31
|
-
causeEventIds?: readonly string[];
|
|
32
|
-
}): Promise<{
|
|
33
|
-
response: string;
|
|
34
|
-
}>;
|
|
35
|
-
}
|
|
36
|
-
export declare class Conductor {
|
|
37
|
-
private readonly deps;
|
|
38
|
-
private readonly leaseMs;
|
|
39
|
-
private readonly maxBatchesPerTick;
|
|
40
|
-
constructor(deps: {
|
|
41
|
-
inbox: ConductorInbox;
|
|
42
|
-
session: ConductorSession;
|
|
43
|
-
runner: RunnerLike;
|
|
44
|
-
reground: () => string;
|
|
45
|
-
/**
|
|
46
|
-
* Per-run scoped authority, mirroring the report lane: without an
|
|
47
|
-
* agentContext the executor's permission checks take their documented
|
|
48
|
-
* "no context - allow all" branch, and without an envelope every
|
|
49
|
-
* model_tool call dies 'envelope_missing' while the run still resolves
|
|
50
|
-
* and acks (review F2). Both are REQUIRED wiring in start.ts; optional
|
|
51
|
-
* here only so unit tests can run the loop without the full boot.
|
|
52
|
-
*/
|
|
53
|
-
agentContext?: AgentContext;
|
|
54
|
-
issueEnvelope?: () => Promise<Envelope | null>;
|
|
55
|
-
log?: (line: string) => void;
|
|
56
|
-
leaseMs?: number;
|
|
57
|
-
/** Burst backpressure budget: batches processed per tick before yielding. */
|
|
58
|
-
maxBatchesPerTick?: number;
|
|
59
|
-
});
|
|
60
|
-
tick(): Promise<'idle' | 'processed' | 'failed'>;
|
|
61
|
-
/**
|
|
62
|
-
* A growing inbox must be loud - silence is how backlogs hide. Runs on the
|
|
63
|
-
* failure path too: a batch stuck in retries (attempts 1-4) is exactly when
|
|
64
|
-
* the backlog grows unattended (review).
|
|
65
|
-
*/
|
|
66
|
-
private logDepth;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
69
|
-
//# sourceMappingURL=conductor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conductor.d.ts","sourceRoot":"","sources":["../../src/operator/conductor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,KAAK,gBAAgB,EAItB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAAE,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AAO,CAAC,QAAQ;CAQjB"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Conductor = void 0;
|
|
4
|
-
const conductor_session_js_1 = require("./conductor-session.js");
|
|
5
|
-
const untrusted_content_js_1 = require("../utils/untrusted-content.js");
|
|
6
|
-
class Conductor {
|
|
7
|
-
deps;
|
|
8
|
-
leaseMs;
|
|
9
|
-
maxBatchesPerTick;
|
|
10
|
-
constructor(deps) {
|
|
11
|
-
this.deps = deps;
|
|
12
|
-
this.leaseMs = deps.leaseMs ?? 10 * 60_000;
|
|
13
|
-
this.maxBatchesPerTick = deps.maxBatchesPerTick ?? 8;
|
|
14
|
-
}
|
|
15
|
-
async tick() {
|
|
16
|
-
const replayed = this.deps.inbox.replayStale(this.leaseMs);
|
|
17
|
-
if (replayed > 0) {
|
|
18
|
-
this.deps.log?.(`[conductor] replayed ${replayed} stale claim(s)`);
|
|
19
|
-
}
|
|
20
|
-
const reason = this.deps.session.shouldRecycle();
|
|
21
|
-
if (reason) {
|
|
22
|
-
this.deps.session.recycle(reason);
|
|
23
|
-
this.deps.log?.(`[conductor] session recycled: ${reason}`);
|
|
24
|
-
}
|
|
25
|
-
let processed = 0;
|
|
26
|
-
for (; processed < this.maxBatchesPerTick;) {
|
|
27
|
-
const batch = this.deps.inbox.claimNext();
|
|
28
|
-
if (!batch) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
const fresh = this.deps.session.needsReground();
|
|
32
|
-
const parts = [];
|
|
33
|
-
if (fresh) {
|
|
34
|
-
parts.push(this.deps.reground());
|
|
35
|
-
}
|
|
36
|
-
parts.push(untrusted_content_js_1.UNTRUSTED_EXTERNAL_EVIDENCE_INSTRUCTION, (0, untrusted_content_js_1.wrapUntrustedContent)(`channel:${batch.channelKey}`, batch.lines.join('\n')));
|
|
37
|
-
try {
|
|
38
|
-
// freshSession is the ONE sanctioned reset path: agent-loop resets the
|
|
39
|
-
// pool entry AND marks the run new together. resumeSession alone is
|
|
40
|
-
// overwritten by the pool's own isNew in the fallback branch, so it
|
|
41
|
-
// cannot express "start over" (review F5).
|
|
42
|
-
const envelope = (await this.deps.issueEnvelope?.()) ?? undefined;
|
|
43
|
-
await this.deps.runner.run(parts.join('\n'), {
|
|
44
|
-
sessionKey: conductor_session_js_1.CONDUCTOR_SESSION_KEY, // lane (first segment picks it)
|
|
45
|
-
source: conductor_session_js_1.CONDUCTOR_SOURCE, // pool key half 1
|
|
46
|
-
channelId: conductor_session_js_1.CONDUCTOR_CHANNEL_ID, // pool key half 2
|
|
47
|
-
...(fresh ? { freshSession: true } : { resumeSession: true }),
|
|
48
|
-
agentContext: this.deps.agentContext,
|
|
49
|
-
envelope,
|
|
50
|
-
// The host already holds the batch (inbox identity = the whole
|
|
51
|
-
// batch). Handing it to the run is what makes every judgment-borne
|
|
52
|
-
// board change attributed - the HOST batch wins over anything the
|
|
53
|
-
// agent could restate (S2 review #1: without this one field the
|
|
54
|
-
// conductor's stream is causeless at the source).
|
|
55
|
-
causeEventIds: batch.eventIds,
|
|
56
|
-
});
|
|
57
|
-
this.deps.inbox.ack(batch.id);
|
|
58
|
-
this.deps.session.noteTurn();
|
|
59
|
-
if (fresh) {
|
|
60
|
-
this.deps.session.markRegrounded();
|
|
61
|
-
}
|
|
62
|
-
processed += 1;
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
const outcome = this.deps.inbox.retry(batch.id, error instanceof Error ? error.message : String(error));
|
|
66
|
-
if (outcome === 'dead') {
|
|
67
|
-
// A dead batch is a permanent loss - it must never die quietly.
|
|
68
|
-
this.deps.log?.(`[conductor] batch ${batch.id} (${batch.channelKey}) parked DEAD after repeated failures: ${error instanceof Error ? error.message : String(error)}`);
|
|
69
|
-
}
|
|
70
|
-
this.logDepth(processed);
|
|
71
|
-
return 'failed';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
this.logDepth(processed);
|
|
75
|
-
return processed > 0 ? 'processed' : 'idle';
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* A growing inbox must be loud - silence is how backlogs hide. Runs on the
|
|
79
|
-
* failure path too: a batch stuck in retries (attempts 1-4) is exactly when
|
|
80
|
-
* the backlog grows unattended (review).
|
|
81
|
-
*/
|
|
82
|
-
logDepth(processed) {
|
|
83
|
-
const depth = this.deps.inbox.depth();
|
|
84
|
-
if (depth.pending > 0 || depth.dead > 0) {
|
|
85
|
-
this.deps.log?.(`[conductor] tick budget spent: ${processed} processed, ${depth.pending} pending, ${depth.dead} dead`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.Conductor = Conductor;
|
|
90
|
-
//# sourceMappingURL=conductor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conductor.js","sourceRoot":"","sources":["../../src/operator/conductor.ts"],"names":[],"mappings":";;;AAkBA,iEAKgC;AAChC,wEAGuC;AAoBvC,MAAa,SAAS;IAKD;IAJF,OAAO,CAAS;IAChB,iBAAiB,CAAS;IAE3C,YACmB,IAmBhB;QAnBgB,SAAI,GAAJ,IAAI,CAmBpB;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG,MAAM,CAAC;QAC3C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,wBAAwB,QAAQ,iBAAiB,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC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