@telora/daemon 0.16.7 → 0.16.16
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/build-info.json +7 -3
- package/dist/audit-phase.d.ts +14 -0
- package/dist/audit-phase.d.ts.map +1 -1
- package/dist/audit-phase.js +52 -12
- package/dist/audit-phase.js.map +1 -1
- package/dist/backends/agent-backend.d.ts +63 -0
- package/dist/backends/agent-backend.d.ts.map +1 -0
- package/dist/backends/agent-backend.js +19 -0
- package/dist/backends/agent-backend.js.map +1 -0
- package/dist/backends/availability.d.ts +28 -0
- package/dist/backends/availability.d.ts.map +1 -0
- package/dist/backends/availability.js +49 -0
- package/dist/backends/availability.js.map +1 -0
- package/dist/backends/claude/claude-backend.d.ts +12 -0
- package/dist/backends/claude/claude-backend.d.ts.map +1 -0
- package/dist/backends/claude/claude-backend.js +86 -0
- package/dist/backends/claude/claude-backend.js.map +1 -0
- package/dist/backends/codex/codex-backend.d.ts +23 -0
- package/dist/backends/codex/codex-backend.d.ts.map +1 -0
- package/dist/backends/codex/codex-backend.js +116 -0
- package/dist/backends/codex/codex-backend.js.map +1 -0
- package/dist/backends/index.d.ts +13 -0
- package/dist/backends/index.d.ts.map +1 -0
- package/dist/backends/index.js +20 -0
- package/dist/backends/index.js.map +1 -0
- package/dist/backends/registry.d.ts +29 -0
- package/dist/backends/registry.d.ts.map +1 -0
- package/dist/backends/registry.js +45 -0
- package/dist/backends/registry.js.map +1 -0
- package/dist/backends/resolve.d.ts +44 -0
- package/dist/backends/resolve.d.ts.map +1 -0
- package/dist/backends/resolve.js +57 -0
- package/dist/backends/resolve.js.map +1 -0
- package/dist/completion-detector.d.ts +18 -16
- package/dist/completion-detector.d.ts.map +1 -1
- package/dist/completion-detector.js +36 -36
- package/dist/completion-detector.js.map +1 -1
- package/dist/directive-executor.d.ts +6 -1
- package/dist/directive-executor.d.ts.map +1 -1
- package/dist/directive-executor.js +26 -11
- package/dist/directive-executor.js.map +1 -1
- package/dist/focus-completion-event.d.ts +20 -7
- package/dist/focus-completion-event.d.ts.map +1 -1
- package/dist/focus-completion-event.js +29 -10
- package/dist/focus-completion-event.js.map +1 -1
- package/dist/focus-executor.d.ts +15 -1
- package/dist/focus-executor.d.ts.map +1 -1
- package/dist/focus-executor.js +129 -62
- package/dist/focus-executor.js.map +1 -1
- package/dist/focus-spawn-helpers.d.ts +2 -0
- package/dist/focus-spawn-helpers.d.ts.map +1 -1
- package/dist/focus-spawn-helpers.js +42 -37
- package/dist/focus-spawn-helpers.js.map +1 -1
- package/dist/git-merge.d.ts.map +1 -1
- package/dist/git-merge.js +42 -16
- package/dist/git-merge.js.map +1 -1
- package/dist/heartbeat.d.ts.map +1 -1
- package/dist/heartbeat.js +7 -0
- package/dist/heartbeat.js.map +1 -1
- package/dist/listener.d.ts.map +1 -1
- package/dist/listener.js +4 -1
- package/dist/listener.js.map +1 -1
- package/dist/merge-back-loop.d.ts.map +1 -1
- package/dist/merge-back-loop.js +1 -0
- package/dist/merge-back-loop.js.map +1 -1
- package/dist/output-monitor.d.ts +11 -6
- package/dist/output-monitor.d.ts.map +1 -1
- package/dist/output-monitor.js +53 -41
- package/dist/output-monitor.js.map +1 -1
- package/dist/queries/deliveries.d.ts +15 -0
- package/dist/queries/deliveries.d.ts.map +1 -1
- package/dist/queries/deliveries.js +6 -0
- package/dist/queries/deliveries.js.map +1 -1
- package/dist/queries/focuses.d.ts +13 -1
- package/dist/queries/focuses.d.ts.map +1 -1
- package/dist/queries/focuses.js +17 -1
- package/dist/queries/focuses.js.map +1 -1
- package/dist/queries/schemas.d.ts +12 -0
- package/dist/queries/schemas.d.ts.map +1 -1
- package/dist/queries/schemas.js +15 -0
- package/dist/queries/schemas.js.map +1 -1
- package/dist/session-lifecycle.d.ts.map +1 -1
- package/dist/session-lifecycle.js +4 -2
- package/dist/session-lifecycle.js.map +1 -1
- package/dist/session-lineage.d.ts +68 -0
- package/dist/session-lineage.d.ts.map +1 -0
- package/dist/session-lineage.js +63 -0
- package/dist/session-lineage.js.map +1 -0
- package/dist/spawn-environment.d.ts +11 -0
- package/dist/spawn-environment.d.ts.map +1 -1
- package/dist/spawn-environment.js +27 -0
- package/dist/spawn-environment.js.map +1 -1
- package/dist/spawner-lifecycle.d.ts +27 -7
- package/dist/spawner-lifecycle.d.ts.map +1 -1
- package/dist/spawner-lifecycle.js +40 -21
- package/dist/spawner-lifecycle.js.map +1 -1
- package/dist/spawner-stream-handlers.d.ts +3 -2
- package/dist/spawner-stream-handlers.d.ts.map +1 -1
- package/dist/spawner-stream-handlers.js +37 -34
- package/dist/spawner-stream-handlers.js.map +1 -1
- package/dist/spawner.d.ts +8 -17
- package/dist/spawner.d.ts.map +1 -1
- package/dist/spawner.js +8 -319
- package/dist/spawner.js.map +1 -1
- package/dist/team-prompt-base.d.ts +35 -2
- package/dist/team-prompt-base.d.ts.map +1 -1
- package/dist/team-prompt-base.js +93 -9
- package/dist/team-prompt-base.js.map +1 -1
- package/dist/team-spawner.d.ts +21 -3
- package/dist/team-spawner.d.ts.map +1 -1
- package/dist/team-spawner.js +49 -34
- package/dist/team-spawner.js.map +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/focus.d.ts +10 -0
- package/dist/types/focus.d.ts.map +1 -1
- package/dist/types/session.d.ts +4 -4
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +17 -0
- package/dist/types/workflow.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-backend.js","sourceRoot":"","sources":["../../../src/backends/codex/codex-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AA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AC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,OAAe;QACzB,mEAAmE;QACnE,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAoB;QAC1C,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO;gBACL,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE,oCAAoC,OAAO,6FAA6F;aACjJ,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YAC9B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;YACvD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QACD,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,uBAAuB,OAAO,uFAAuF;SAC9H,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent backend layer -- engine-agnostic spawn seam.
|
|
3
|
+
*
|
|
4
|
+
* Importing this barrel registers all built-in backends as a side effect, so
|
|
5
|
+
* any module that resolves a backend from the registry first imports from here.
|
|
6
|
+
*/
|
|
7
|
+
export { type AgentBackend, type AgentSpawnContext, type AgentResumeContext, type BackendAvailability, } from './agent-backend.js';
|
|
8
|
+
export { DEFAULT_BACKEND_ID, registerBackend, getBackend, hasBackend, listBackends, _resetRegistry, } from './registry.js';
|
|
9
|
+
export { claudeBackend } from './claude/claude-backend.js';
|
|
10
|
+
export { codexBackend } from './codex/codex-backend.js';
|
|
11
|
+
export { resolveBackend, type EnginePass, type EngineOverride, type EngineSource, type ResolvedEngine, type ResolveBackendArgs, } from './resolve.js';
|
|
12
|
+
export { probeAllBackends, _resetAvailabilityCache, type BackendAvailabilityReport, } from './availability.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EACL,cAAc,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent backend layer -- engine-agnostic spawn seam.
|
|
3
|
+
*
|
|
4
|
+
* Importing this barrel registers all built-in backends as a side effect, so
|
|
5
|
+
* any module that resolves a backend from the registry first imports from here.
|
|
6
|
+
*/
|
|
7
|
+
import { registerBackend } from './registry.js';
|
|
8
|
+
import { claudeBackend } from './claude/claude-backend.js';
|
|
9
|
+
import { codexBackend } from './codex/codex-backend.js';
|
|
10
|
+
// Register built-in backends. `claude` is the default; `codex` is selectable
|
|
11
|
+
// once per-spawn engine resolution (D3) lands -- registering it here makes it
|
|
12
|
+
// resolvable and lets the availability probe (D4) report it.
|
|
13
|
+
registerBackend(claudeBackend);
|
|
14
|
+
registerBackend(codexBackend);
|
|
15
|
+
export { DEFAULT_BACKEND_ID, registerBackend, getBackend, hasBackend, listBackends, _resetRegistry, } from './registry.js';
|
|
16
|
+
export { claudeBackend } from './claude/claude-backend.js';
|
|
17
|
+
export { codexBackend } from './codex/codex-backend.js';
|
|
18
|
+
export { resolveBackend, } from './resolve.js';
|
|
19
|
+
export { probeAllBackends, _resetAvailabilityCache, } from './availability.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,6EAA6E;AAC7E,8EAA8E;AAC9E,6DAA6D;AAC7D,eAAe,CAAC,aAAa,CAAC,CAAC;AAC/B,eAAe,CAAC,YAAY,CAAC,CAAC;AAS9B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EACL,cAAc,GAMf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GAExB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentBackend registry -- resolves an engine id to its implementation.
|
|
3
|
+
*
|
|
4
|
+
* Backends register themselves at module load (see ./index.ts, which imports
|
|
5
|
+
* and registers the built-in `claude` backend). Spawn paths resolve a backend
|
|
6
|
+
* by id; selection of WHICH id to use (org default + per-focus override) is a
|
|
7
|
+
* later delivery -- this registry only maps id -> implementation.
|
|
8
|
+
*
|
|
9
|
+
* Built N-backends-ready by design: adding Codex/Gemini later is a register
|
|
10
|
+
* call, not a rewrite.
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentBackend } from './agent-backend.js';
|
|
13
|
+
/** The default backend id used when no selection is provided. */
|
|
14
|
+
export declare const DEFAULT_BACKEND_ID = "claude";
|
|
15
|
+
/** Register (or replace) a backend implementation under its id. */
|
|
16
|
+
export declare function registerBackend(backend: AgentBackend): void;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a backend by id. Falls back to the default backend when the id is
|
|
19
|
+
* null/undefined. Throws when an explicitly requested id is not registered --
|
|
20
|
+
* a misconfigured engine should fail loudly, not silently run on the wrong one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getBackend(id?: string | null): AgentBackend;
|
|
23
|
+
/** True when a backend is registered for the given id. */
|
|
24
|
+
export declare function hasBackend(id: string): boolean;
|
|
25
|
+
/** List all registered backends (for availability probing + the picker). */
|
|
26
|
+
export declare function listBackends(): AgentBackend[];
|
|
27
|
+
/** Test-only: clear the registry. */
|
|
28
|
+
export declare function _resetRegistry(): void;
|
|
29
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/backends/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,iEAAiE;AACjE,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY,CAQ3D;AAED,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,IAAI,YAAY,EAAE,CAE7C;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentBackend registry -- resolves an engine id to its implementation.
|
|
3
|
+
*
|
|
4
|
+
* Backends register themselves at module load (see ./index.ts, which imports
|
|
5
|
+
* and registers the built-in `claude` backend). Spawn paths resolve a backend
|
|
6
|
+
* by id; selection of WHICH id to use (org default + per-focus override) is a
|
|
7
|
+
* later delivery -- this registry only maps id -> implementation.
|
|
8
|
+
*
|
|
9
|
+
* Built N-backends-ready by design: adding Codex/Gemini later is a register
|
|
10
|
+
* call, not a rewrite.
|
|
11
|
+
*/
|
|
12
|
+
const registry = new Map();
|
|
13
|
+
/** The default backend id used when no selection is provided. */
|
|
14
|
+
export const DEFAULT_BACKEND_ID = 'claude';
|
|
15
|
+
/** Register (or replace) a backend implementation under its id. */
|
|
16
|
+
export function registerBackend(backend) {
|
|
17
|
+
registry.set(backend.id, backend);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a backend by id. Falls back to the default backend when the id is
|
|
21
|
+
* null/undefined. Throws when an explicitly requested id is not registered --
|
|
22
|
+
* a misconfigured engine should fail loudly, not silently run on the wrong one.
|
|
23
|
+
*/
|
|
24
|
+
export function getBackend(id) {
|
|
25
|
+
const resolvedId = id ?? DEFAULT_BACKEND_ID;
|
|
26
|
+
const backend = registry.get(resolvedId);
|
|
27
|
+
if (!backend) {
|
|
28
|
+
const known = Array.from(registry.keys()).join(', ') || '(none)';
|
|
29
|
+
throw new Error(`No agent backend registered for id "${resolvedId}". Registered: ${known}`);
|
|
30
|
+
}
|
|
31
|
+
return backend;
|
|
32
|
+
}
|
|
33
|
+
/** True when a backend is registered for the given id. */
|
|
34
|
+
export function hasBackend(id) {
|
|
35
|
+
return registry.has(id);
|
|
36
|
+
}
|
|
37
|
+
/** List all registered backends (for availability probing + the picker). */
|
|
38
|
+
export function listBackends() {
|
|
39
|
+
return Array.from(registry.values());
|
|
40
|
+
}
|
|
41
|
+
/** Test-only: clear the registry. */
|
|
42
|
+
export function _resetRegistry() {
|
|
43
|
+
registry.clear();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/backends/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;AAEjD,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAE3C,mEAAmE;AACnE,MAAM,UAAU,eAAe,CAAC,OAAqB;IACnD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,EAAkB;IAC3C,MAAM,UAAU,GAAG,EAAE,IAAI,kBAAkB,CAAC;IAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,uCAAuC,UAAU,kBAAkB,KAAK,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,YAAY;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-spawn engine resolution -- the single place the daemon decides WHICH
|
|
3
|
+
* engine a spawn runs on.
|
|
4
|
+
*
|
|
5
|
+
* Selection is one knob (the engine) with a default + one override layer,
|
|
6
|
+
* most-specific wins, resolution always logged (the no-invisible-cascading
|
|
7
|
+
* principle). Mirrors the centralization of `shouldRunLoop()` in
|
|
8
|
+
* focus-engine.ts: one exported pure function, no side effects, easy to test.
|
|
9
|
+
*
|
|
10
|
+
* Resolution order for a pass (coding | review):
|
|
11
|
+
* 1. per-focus override for that pass (focusOverride[pass], if a truthy id)
|
|
12
|
+
* 2. org-level default (orgDefault, if a truthy id)
|
|
13
|
+
* 3. the global default (DEFAULT_BACKEND_ID = 'claude')
|
|
14
|
+
*
|
|
15
|
+
* Guard: a resolved id that is not a registered backend (typo, or an engine the
|
|
16
|
+
* host lacks) falls back to the default rather than spawning on a bogus engine.
|
|
17
|
+
* With no override and no org default, this returns 'claude' -- behavior parity.
|
|
18
|
+
*/
|
|
19
|
+
/** A spawn "pass" -- the coding vs review lineage. */
|
|
20
|
+
export type EnginePass = 'coding' | 'review';
|
|
21
|
+
/** Per-focus engine override: an engine id per pass; absent/null = inherit. */
|
|
22
|
+
export interface EngineOverride {
|
|
23
|
+
coding?: string | null;
|
|
24
|
+
review?: string | null;
|
|
25
|
+
}
|
|
26
|
+
/** Where the resolved engine came from (always logged). */
|
|
27
|
+
export type EngineSource = 'focus-override' | 'org-default' | 'default' | 'fallback';
|
|
28
|
+
export interface ResolvedEngine {
|
|
29
|
+
engineId: string;
|
|
30
|
+
source: EngineSource;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolveBackendArgs {
|
|
33
|
+
/** Per-focus override map (null/absent = inherit the org default). */
|
|
34
|
+
focusOverride?: EngineOverride | null;
|
|
35
|
+
/** The pass being spawned. */
|
|
36
|
+
pass: EnginePass;
|
|
37
|
+
/** Org-level default engine id (null/absent = the global default). */
|
|
38
|
+
orgDefault?: string | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the engine id (and its source) for a spawn pass. Pure + deterministic.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveBackend(args: ResolveBackendArgs): ResolvedEngine;
|
|
44
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/backends/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,sDAAsD;AACtD,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7C,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,2DAA2D;AAC3D,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC;AAErF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,8BAA8B;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AASD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc,CA4BvE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-spawn engine resolution -- the single place the daemon decides WHICH
|
|
3
|
+
* engine a spawn runs on.
|
|
4
|
+
*
|
|
5
|
+
* Selection is one knob (the engine) with a default + one override layer,
|
|
6
|
+
* most-specific wins, resolution always logged (the no-invisible-cascading
|
|
7
|
+
* principle). Mirrors the centralization of `shouldRunLoop()` in
|
|
8
|
+
* focus-engine.ts: one exported pure function, no side effects, easy to test.
|
|
9
|
+
*
|
|
10
|
+
* Resolution order for a pass (coding | review):
|
|
11
|
+
* 1. per-focus override for that pass (focusOverride[pass], if a truthy id)
|
|
12
|
+
* 2. org-level default (orgDefault, if a truthy id)
|
|
13
|
+
* 3. the global default (DEFAULT_BACKEND_ID = 'claude')
|
|
14
|
+
*
|
|
15
|
+
* Guard: a resolved id that is not a registered backend (typo, or an engine the
|
|
16
|
+
* host lacks) falls back to the default rather than spawning on a bogus engine.
|
|
17
|
+
* With no override and no org default, this returns 'claude' -- behavior parity.
|
|
18
|
+
*/
|
|
19
|
+
import { DEFAULT_BACKEND_ID, hasBackend } from './registry.js';
|
|
20
|
+
/** Normalize a candidate id to a non-empty trimmed string, or null. */
|
|
21
|
+
function clean(id) {
|
|
22
|
+
if (typeof id !== 'string')
|
|
23
|
+
return null;
|
|
24
|
+
const trimmed = id.trim();
|
|
25
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the engine id (and its source) for a spawn pass. Pure + deterministic.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveBackend(args) {
|
|
31
|
+
const overrideId = clean(args.focusOverride?.[args.pass]);
|
|
32
|
+
const orgId = clean(args.orgDefault);
|
|
33
|
+
let candidate;
|
|
34
|
+
let source;
|
|
35
|
+
if (overrideId) {
|
|
36
|
+
candidate = overrideId;
|
|
37
|
+
source = 'focus-override';
|
|
38
|
+
}
|
|
39
|
+
else if (orgId) {
|
|
40
|
+
candidate = orgId;
|
|
41
|
+
source = 'org-default';
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
candidate = DEFAULT_BACKEND_ID;
|
|
45
|
+
source = 'default';
|
|
46
|
+
}
|
|
47
|
+
// Never spawn on an unregistered engine -- fall back to the global default.
|
|
48
|
+
if (!hasBackend(candidate)) {
|
|
49
|
+
if (candidate !== DEFAULT_BACKEND_ID) {
|
|
50
|
+
console.warn(`[engine] Resolved engine "${candidate}" (source: ${source}) is not a registered backend; ` +
|
|
51
|
+
`falling back to "${DEFAULT_BACKEND_ID}".`);
|
|
52
|
+
return { engineId: DEFAULT_BACKEND_ID, source: 'fallback' };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { engineId: candidate, source };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/backends/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA4B/D,uEAAuE;AACvE,SAAS,KAAK,CAAC,EAA6B;IAC1C,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAC1B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAwB;IACrD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAErC,IAAI,SAAiB,CAAC;IACtB,IAAI,MAAoB,CAAC;IACzB,IAAI,UAAU,EAAE,CAAC;QACf,SAAS,GAAG,UAAU,CAAC;QACvB,MAAM,GAAG,gBAAgB,CAAC;IAC5B,CAAC;SAAM,IAAI,KAAK,EAAE,CAAC;QACjB,SAAS,GAAG,KAAK,CAAC;QAClB,MAAM,GAAG,aAAa,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,kBAAkB,CAAC;QAC/B,MAAM,GAAG,SAAS,CAAC;IACrB,CAAC;IAED,4EAA4E;IAC5E,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;YACrC,OAAO,CAAC,IAAI,CACV,6BAA6B,SAAS,cAAc,MAAM,iCAAiC;gBAC3F,oBAAoB,kBAAkB,IAAI,CAC3C,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Completion detector for interactive
|
|
2
|
+
* Completion detector for interactive agent sessions.
|
|
3
3
|
*
|
|
4
|
-
* Observes
|
|
5
|
-
* agent has finished all work. With stream
|
|
6
|
-
* doesn't exit on its own
|
|
4
|
+
* Observes the provider-neutral AgentEvent stream from a backend's parser and
|
|
5
|
+
* determines when the agent has finished all work. With interactive stream I/O
|
|
6
|
+
* the process doesn't exit on its own -- we detect idle state and trigger
|
|
7
7
|
* graceful shutdown.
|
|
8
8
|
*
|
|
9
9
|
* Detection focus:
|
|
10
|
-
* 1. Track
|
|
10
|
+
* 1. Track subagent lifecycle (spawned, idle, completed)
|
|
11
11
|
* 2. When we receive a `result` event (turn complete), check if any
|
|
12
|
-
*
|
|
13
|
-
* 3. If the lead is idle and no
|
|
12
|
+
* subagents are still active
|
|
13
|
+
* 3. If the lead is idle and no subagents are active, signal completion
|
|
14
14
|
* 4. Use an inactivity timeout as a fallback safety net
|
|
15
15
|
*/
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
|
-
import type {
|
|
17
|
+
import type { AgentEvent, AgentEventParser } from '@telora/daemon-core';
|
|
18
18
|
export interface CompletionDetectorEvents {
|
|
19
19
|
/** Fired when the agent team appears to have completed all work. */
|
|
20
20
|
complete: (info: CompletionInfo) => void;
|
|
@@ -23,8 +23,10 @@ export interface CompletionDetectorEvents {
|
|
|
23
23
|
}
|
|
24
24
|
export interface CompletionInfo {
|
|
25
25
|
/** The result event that triggered completion detection. */
|
|
26
|
-
result:
|
|
27
|
-
|
|
26
|
+
result: Extract<AgentEvent, {
|
|
27
|
+
kind: 'result';
|
|
28
|
+
}>;
|
|
29
|
+
/** Whether all subagents have completed. */
|
|
28
30
|
allTeammatesComplete: boolean;
|
|
29
31
|
/** Total number of result events seen (turns completed). */
|
|
30
32
|
turnCount: number;
|
|
@@ -34,11 +36,11 @@ export interface CompletionInfo {
|
|
|
34
36
|
export interface IdleInfo {
|
|
35
37
|
/** How long the session has been idle (ms). */
|
|
36
38
|
idleDurationMs: number;
|
|
37
|
-
/** Number of active
|
|
39
|
+
/** Number of active subagents when idle was detected. */
|
|
38
40
|
activeTeammateCount: number;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
|
-
* Monitors stream
|
|
43
|
+
* Monitors the neutral AgentEvent stream to detect when an interactive agent
|
|
42
44
|
* team session has completed its work.
|
|
43
45
|
*/
|
|
44
46
|
export declare class CompletionDetector extends EventEmitter {
|
|
@@ -54,11 +56,11 @@ export declare class CompletionDetector extends EventEmitter {
|
|
|
54
56
|
idleTimeoutMs?: number;
|
|
55
57
|
});
|
|
56
58
|
/**
|
|
57
|
-
* Attach the detector to
|
|
59
|
+
* Attach the detector to an AgentEventParser.
|
|
58
60
|
*/
|
|
59
|
-
attach(parser:
|
|
61
|
+
attach(parser: AgentEventParser): void;
|
|
60
62
|
private handleResult;
|
|
61
|
-
private
|
|
63
|
+
private handleSubagent;
|
|
62
64
|
private checkCompletion;
|
|
63
65
|
private signalComplete;
|
|
64
66
|
private startIdleTimer;
|
|
@@ -75,7 +77,7 @@ export declare class CompletionDetector extends EventEmitter {
|
|
|
75
77
|
/**
|
|
76
78
|
* Reset the detector for a new work cycle.
|
|
77
79
|
*
|
|
78
|
-
* Clears per-cycle state (completion flag, active
|
|
80
|
+
* Clears per-cycle state (completion flag, active subagents, last result,
|
|
79
81
|
* idle timer) so the detector can fire 'complete' again on new work.
|
|
80
82
|
* Cumulative counters (turnCount, totalCostUsd) are preserved as
|
|
81
83
|
* session-lifetime metrics.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion-detector.d.ts","sourceRoot":"","sources":["../src/completion-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"completion-detector.d.ts","sourceRoot":"","sources":["../src/completion-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,sEAAsE;IACtE,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAA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AOG;IACH,KAAK,IAAI,IAAI;IAOb,uBAAuB;IACvB,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Completion detector for interactive
|
|
2
|
+
* Completion detector for interactive agent sessions.
|
|
3
3
|
*
|
|
4
|
-
* Observes
|
|
5
|
-
* agent has finished all work. With stream
|
|
6
|
-
* doesn't exit on its own
|
|
4
|
+
* Observes the provider-neutral AgentEvent stream from a backend's parser and
|
|
5
|
+
* determines when the agent has finished all work. With interactive stream I/O
|
|
6
|
+
* the process doesn't exit on its own -- we detect idle state and trigger
|
|
7
7
|
* graceful shutdown.
|
|
8
8
|
*
|
|
9
9
|
* Detection focus:
|
|
10
|
-
* 1. Track
|
|
10
|
+
* 1. Track subagent lifecycle (spawned, idle, completed)
|
|
11
11
|
* 2. When we receive a `result` event (turn complete), check if any
|
|
12
|
-
*
|
|
13
|
-
* 3. If the lead is idle and no
|
|
12
|
+
* subagents are still active
|
|
13
|
+
* 3. If the lead is idle and no subagents are active, signal completion
|
|
14
14
|
* 4. Use an inactivity timeout as a fallback safety net
|
|
15
15
|
*/
|
|
16
16
|
import { EventEmitter } from 'node:events';
|
|
17
17
|
/**
|
|
18
|
-
* Monitors stream
|
|
18
|
+
* Monitors the neutral AgentEvent stream to detect when an interactive agent
|
|
19
19
|
* team session has completed its work.
|
|
20
20
|
*/
|
|
21
21
|
export class CompletionDetector extends EventEmitter {
|
|
22
|
-
activeTeammates = new Map(); //
|
|
22
|
+
activeTeammates = new Map(); // agentId -> agentName
|
|
23
23
|
turnCount = 0;
|
|
24
24
|
totalCostUsd = 0;
|
|
25
25
|
lastResultEvent = null;
|
|
@@ -32,43 +32,43 @@ export class CompletionDetector extends EventEmitter {
|
|
|
32
32
|
this.idleTimeoutMs = options?.idleTimeoutMs ?? 30000;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Attach the detector to
|
|
35
|
+
* Attach the detector to an AgentEventParser.
|
|
36
36
|
*/
|
|
37
37
|
attach(parser) {
|
|
38
|
-
parser.on('
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
parser.on('teammate', (event) => {
|
|
42
|
-
this.handleTeammate(event);
|
|
43
|
-
});
|
|
44
|
-
// Track any activity to reset idle detection
|
|
45
|
-
parser.on('event', (_event) => {
|
|
38
|
+
parser.on('agent_event', (event) => {
|
|
39
|
+
// Any activity resets idle detection.
|
|
46
40
|
this.resetIdleTimer();
|
|
41
|
+
if (event.kind === 'result') {
|
|
42
|
+
this.handleResult(event);
|
|
43
|
+
}
|
|
44
|
+
else if (event.kind === 'subagent_activity') {
|
|
45
|
+
this.handleSubagent(event);
|
|
46
|
+
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
handleResult(result) {
|
|
50
50
|
this.turnCount++;
|
|
51
51
|
this.lastResultEvent = result;
|
|
52
|
-
if (result.
|
|
53
|
-
this.totalCostUsd += result.
|
|
52
|
+
if (result.totalCostUsd) {
|
|
53
|
+
this.totalCostUsd += result.totalCostUsd;
|
|
54
54
|
}
|
|
55
55
|
// A result event means the lead agent finished a turn.
|
|
56
|
-
// Check if all
|
|
56
|
+
// Check if all subagents are done too.
|
|
57
57
|
this.checkCompletion();
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
switch (event.
|
|
61
|
-
case '
|
|
62
|
-
this.activeTeammates.set(event.
|
|
63
|
-
// New
|
|
59
|
+
handleSubagent(event) {
|
|
60
|
+
switch (event.phase) {
|
|
61
|
+
case 'spawned':
|
|
62
|
+
this.activeTeammates.set(event.agentId, event.agentName);
|
|
63
|
+
// New subagent spawned -- cancel any pending completion
|
|
64
64
|
this.clearIdleTimer();
|
|
65
65
|
break;
|
|
66
|
-
case '
|
|
67
|
-
//
|
|
66
|
+
case 'idle':
|
|
67
|
+
// Subagent is idle but not done yet -- keep tracking
|
|
68
68
|
break;
|
|
69
|
-
case '
|
|
70
|
-
this.activeTeammates.delete(event.
|
|
71
|
-
//
|
|
69
|
+
case 'completed':
|
|
70
|
+
this.activeTeammates.delete(event.agentId);
|
|
71
|
+
// Subagent finished -- check if we can signal completion
|
|
72
72
|
if (this.lastResultEvent && this.activeTeammates.size === 0) {
|
|
73
73
|
this.checkCompletion();
|
|
74
74
|
}
|
|
@@ -80,15 +80,15 @@ export class CompletionDetector extends EventEmitter {
|
|
|
80
80
|
return;
|
|
81
81
|
if (!this.lastResultEvent)
|
|
82
82
|
return;
|
|
83
|
-
// If no
|
|
83
|
+
// If no subagents were ever spawned, or all subagents have completed,
|
|
84
84
|
// the session is complete after the lead finishes its turn.
|
|
85
85
|
if (this.activeTeammates.size === 0) {
|
|
86
86
|
this.signalComplete();
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
//
|
|
90
|
-
// The lead is idle waiting for input, but
|
|
91
|
-
// Wait for all
|
|
89
|
+
// Subagents still active -- start idle timer as fallback.
|
|
90
|
+
// The lead is idle waiting for input, but subagents are still running.
|
|
91
|
+
// Wait for all subagents to finish.
|
|
92
92
|
this.startIdleTimer();
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -140,7 +140,7 @@ export class CompletionDetector extends EventEmitter {
|
|
|
140
140
|
/**
|
|
141
141
|
* Reset the detector for a new work cycle.
|
|
142
142
|
*
|
|
143
|
-
* Clears per-cycle state (completion flag, active
|
|
143
|
+
* Clears per-cycle state (completion flag, active subagents, last result,
|
|
144
144
|
* idle timer) so the detector can fire 'complete' again on new work.
|
|
145
145
|
* Cumulative counters (turnCount, totalCostUsd) are preserved as
|
|
146
146
|
* session-lifetime metrics.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion-detector.js","sourceRoot":"","sources":["../src/completion-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"completion-detector.js","sourceRoot":"","sources":["../src/completion-detector.ts"],"names":[],"mappings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AAE,CAAC;IACxB,CAAC;IAED,uBAAuB;IACvB,OAAO;QACL,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import type { DaemonConfig, StageDirective } from './types.js';
|
|
10
10
|
import { type AssemblyManifestEntry } from './assembly-engine.js';
|
|
11
11
|
import './assembly-resolvers.js';
|
|
12
|
+
import { type SessionContinuity, type LineageSpec } from './session-lineage.js';
|
|
12
13
|
import { type CloseLoopDecision } from './close-loop-dispatcher.js';
|
|
13
14
|
import { createEscalation } from './queries/issues.js';
|
|
14
15
|
/** Seed the last-processed stage for a focus (used on daemon startup). */
|
|
@@ -23,6 +24,10 @@ export interface PendingSpawnDirective {
|
|
|
23
24
|
message: string;
|
|
24
25
|
model: string | null;
|
|
25
26
|
sessionType: 'coding' | 'review';
|
|
27
|
+
/** Session-id map slot this spawn reads/writes (INJ-B). */
|
|
28
|
+
lineage: string;
|
|
29
|
+
/** Resume-vs-fresh policy for this spawn's lineage (INJ-B). */
|
|
30
|
+
continuity: SessionContinuity;
|
|
26
31
|
/**
|
|
27
32
|
* SHA-256 hash of the directive's identity ({ prompt, assembly, model }).
|
|
28
33
|
* Recorded on FocusTeamState.lastConsumedDirectiveHash when the team
|
|
@@ -100,7 +105,7 @@ export declare function assembleDirectiveContentWithManifest(config: DaemonConfi
|
|
|
100
105
|
/**
|
|
101
106
|
* Inject mode: send /compact + assembled context + prompt to the active team's stdin.
|
|
102
107
|
*/
|
|
103
|
-
export declare function executeInjectDirective(config: DaemonConfig, focusId: string, directive: StageDirective, sessionType?: 'coding' | 'review'): Promise<void>;
|
|
108
|
+
export declare function executeInjectDirective(config: DaemonConfig, focusId: string, directive: StageDirective, sessionType?: 'coding' | 'review', spec?: LineageSpec): Promise<void>;
|
|
104
109
|
/**
|
|
105
110
|
* Decide which workflow stage name a focus should be in.
|
|
106
111
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directive-executor.d.ts","sourceRoot":"","sources":["../src/directive-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"directive-executor.d.ts","sourceRoot":"","sources":["../src/directive-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,EAAsB,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUpG,OAAO,EAML,KAAK,iBAAiB,EAEvB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAYvD,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7E;AAED,2DAA2D;AAC3D,wBAAgB,sBAAsB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpE;AAID;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACjC,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,UAAU,EAAE,iBAAiB,CAAC;IAC9B;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAID;;;;;GAKG;A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