@telora/daemon 0.19.17 → 0.19.23

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.
Files changed (61) hide show
  1. package/build-info.json +5 -3
  2. package/dist/backends/lacuna/index.d.ts +11 -0
  3. package/dist/backends/lacuna/index.d.ts.map +1 -0
  4. package/dist/backends/lacuna/index.js +11 -0
  5. package/dist/backends/lacuna/index.js.map +1 -0
  6. package/dist/backends/lacuna/launch-adapter.d.ts +100 -0
  7. package/dist/backends/lacuna/launch-adapter.d.ts.map +1 -0
  8. package/dist/backends/lacuna/launch-adapter.js +162 -0
  9. package/dist/backends/lacuna/launch-adapter.js.map +1 -0
  10. package/dist/backends/lacuna/lifecycle.d.ts +21 -0
  11. package/dist/backends/lacuna/lifecycle.d.ts.map +1 -0
  12. package/dist/backends/lacuna/lifecycle.js +45 -0
  13. package/dist/backends/lacuna/lifecycle.js.map +1 -0
  14. package/dist/backends/lacuna/routing.d.ts +31 -0
  15. package/dist/backends/lacuna/routing.d.ts.map +1 -0
  16. package/dist/backends/lacuna/routing.js +46 -0
  17. package/dist/backends/lacuna/routing.js.map +1 -0
  18. package/dist/backends/lacuna/supervisor.d.ts +81 -0
  19. package/dist/backends/lacuna/supervisor.d.ts.map +1 -0
  20. package/dist/backends/lacuna/supervisor.js +244 -0
  21. package/dist/backends/lacuna/supervisor.js.map +1 -0
  22. package/dist/completion/event.d.ts +11 -0
  23. package/dist/completion/event.d.ts.map +1 -1
  24. package/dist/completion/event.js +43 -2
  25. package/dist/completion/event.js.map +1 -1
  26. package/dist/completion/terminated-work-reconcile.d.ts +72 -0
  27. package/dist/completion/terminated-work-reconcile.d.ts.map +1 -0
  28. package/dist/completion/terminated-work-reconcile.js +170 -0
  29. package/dist/completion/terminated-work-reconcile.js.map +1 -0
  30. package/dist/config.d.ts.map +1 -1
  31. package/dist/config.js +32 -0
  32. package/dist/config.js.map +1 -1
  33. package/dist/control-state.d.ts +70 -2
  34. package/dist/control-state.d.ts.map +1 -1
  35. package/dist/control-state.js +146 -18
  36. package/dist/control-state.js.map +1 -1
  37. package/dist/listener.d.ts.map +1 -1
  38. package/dist/listener.js +6 -1
  39. package/dist/listener.js.map +1 -1
  40. package/dist/merge-back-loop.d.ts.map +1 -1
  41. package/dist/merge-back-loop.js +37 -1
  42. package/dist/merge-back-loop.js.map +1 -1
  43. package/dist/prompt-sections/execution-sections.d.ts.map +1 -1
  44. package/dist/prompt-sections/execution-sections.js +44 -6
  45. package/dist/prompt-sections/execution-sections.js.map +1 -1
  46. package/dist/spawn-environment.d.ts.map +1 -1
  47. package/dist/spawn-environment.js +11 -0
  48. package/dist/spawn-environment.js.map +1 -1
  49. package/dist/types/config.d.ts +26 -0
  50. package/dist/types/config.d.ts.map +1 -1
  51. package/dist/unified-engine-lifecycle.d.ts.map +1 -1
  52. package/dist/unified-engine-lifecycle.js +7 -2
  53. package/dist/unified-engine-lifecycle.js.map +1 -1
  54. package/dist/unified-shell-config.d.ts +13 -1
  55. package/dist/unified-shell-config.d.ts.map +1 -1
  56. package/dist/unified-shell-config.js +51 -0
  57. package/dist/unified-shell-config.js.map +1 -1
  58. package/dist/unified-shell.d.ts.map +1 -1
  59. package/dist/unified-shell.js +19 -2
  60. package/dist/unified-shell.js.map +1 -1
  61. package/package.json +2 -2
package/build-info.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "commitSha": "a66c844dd",
3
- "builtAt": "2026-06-30T10:45:04.804Z",
2
+ "commitSha": "4ae4eafcc",
3
+ "builtAt": "2026-06-30T18:13:29.439Z",
4
4
  "expectedMigrations": [
5
5
  "20250829113330_create_org_nodes_table.sql",
6
6
  "20250829113402_fix_function_security_search_path.sql",
@@ -693,6 +693,8 @@
693
693
  "20260629212538_loop_document_embeddings.sql",
694
694
  "20260629214208_loop_context_code_anchor.sql",
695
695
  "20260629214737_loop_item_lock_state.sql",
696
- "20260629220420_loop_items_due.sql"
696
+ "20260629220420_loop_items_due.sql",
697
+ "20260630073050_product_show_on_dashboard.sql",
698
+ "20260630080221_agent_cfd_functions.sql"
697
699
  ]
698
700
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Lacuna backend: the daemon-managed context-compression sidecar.
3
+ *
4
+ * Barrel for the Lacuna deploy/launch adapter. The lifecycle supervisor
5
+ * (added in a later delivery) consumes these pure builders.
6
+ */
7
+ export { LACUNA_CONTRACT_VERSION, LACUNA_DEFAULT_UPSTREAM_BASE_URL, resolveLacunaSource, buildInstallPlan, buildLaunchCommand, type LacunaSource, type LacunaPaths, type InstallStep, type LacunaLaunchCommand, } from './launch-adapter.js';
8
+ export { startLacunaSidecar, __resetLacunaSupervisorForTest, type LacunaHandle, type LacunaHealth, type LacunaSupervisorDeps, type ProcLike, } from './supervisor.js';
9
+ export { startLacunaSidecarIfEnabled, stopLacunaSidecar, getLacunaHandle, } from './lifecycle.js';
10
+ export { lacunaSpawnEnv, type LacunaRoutingInput, } from './routing.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/backends/lacuna/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,8BAA8B,EAC9B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Lacuna backend: the daemon-managed context-compression sidecar.
3
+ *
4
+ * Barrel for the Lacuna deploy/launch adapter. The lifecycle supervisor
5
+ * (added in a later delivery) consumes these pure builders.
6
+ */
7
+ export { LACUNA_CONTRACT_VERSION, LACUNA_DEFAULT_UPSTREAM_BASE_URL, resolveLacunaSource, buildInstallPlan, buildLaunchCommand, } from './launch-adapter.js';
8
+ export { startLacunaSidecar, __resetLacunaSupervisorForTest, } from './supervisor.js';
9
+ export { startLacunaSidecarIfEnabled, stopLacunaSidecar, getLacunaHandle, } from './lifecycle.js';
10
+ export { lacunaSpawnEnv, } from './routing.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/backends/lacuna/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GAKnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,8BAA8B,GAK/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,GAEf,MAAM,cAAc,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Lacuna deploy/launch adapter.
3
+ *
4
+ * Turns the daemon's `config.lacuna` block + Lacuna's delivered deploy/launch
5
+ * contract into (a) an ordered install plan that takes a host from
6
+ * not-installed to a launchable artifact, and (b) the exact start command +
7
+ * environment for `python -m lacuna`.
8
+ *
9
+ * Everything here is PURE: it constructs plain data (commands, args, env). It
10
+ * never spawns a process, touches the network, or writes the filesystem -- the
11
+ * lifecycle supervisor executes the returned plan/command. This keeps the seam
12
+ * fully unit-testable with no real I/O.
13
+ *
14
+ * Cross-product contract (Nexus request d0a7d9cf, delivered): build-from-source
15
+ * is the ONLY supported path -- no PyPI package or release artifact exists yet.
16
+ * The bare-process path (git clone -> python venv -> `pip install -c
17
+ * constraints.txt .` -> `python -m lacuna`) is implemented here; it is lighter
18
+ * than the container path and closer to the daemon's existing local-process
19
+ * supervision. Every LACUNA_* env var is optional; the provider API key is
20
+ * NEVER a Lacuna env var -- it rides each request's auth headers, relayed
21
+ * verbatim, so this adapter must never emit a credential into the launch env.
22
+ *
23
+ * Cite: wiki `what-lacuna-is/lacuna-deploy-launch-contract`;
24
+ * `docs/daemon-launch-contract.md` in the Lacuna repo (gitea/lacuna).
25
+ */
26
+ import type { LacunaConfig } from '../../types.js';
27
+ /**
28
+ * The revision of the deploy/launch contract this adapter was integrated
29
+ * against. Compared against the running artifact's `/health.contract_version`
30
+ * by the supervisor to surface a contract mismatch.
31
+ */
32
+ export declare const LACUNA_CONTRACT_VERSION = "1";
33
+ /** Upstream Anthropic API base URL Lacuna defaults to when none is configured. */
34
+ export declare const LACUNA_DEFAULT_UPSTREAM_BASE_URL = "https://api.anthropic.com";
35
+ /** Where the Lacuna artifact source is obtained from. */
36
+ export interface LacunaSource {
37
+ /** 'git' => clone/fetch a repo; 'path' => a local checkout already on disk. */
38
+ kind: 'git' | 'path';
39
+ /** Git URL (kind 'git') or local filesystem path (kind 'path'). */
40
+ location: string;
41
+ /** Optional pinned git revision/tag/branch (from a `#ref` suffix). */
42
+ ref?: string;
43
+ }
44
+ /** Filesystem locations the daemon owns for the Lacuna install. */
45
+ export interface LacunaPaths {
46
+ /**
47
+ * Directory holding the Lacuna source checkout. For a git source the daemon
48
+ * clones into here; for a path source this is the configured path itself.
49
+ */
50
+ sourceDir: string;
51
+ /** Python virtualenv directory the artifact is installed into. */
52
+ venvDir: string;
53
+ }
54
+ /** One ordered, side-effect-free install step the supervisor executes. */
55
+ export interface InstallStep {
56
+ /** Human-readable description for logs. */
57
+ description: string;
58
+ /** Executable to run. */
59
+ command: string;
60
+ /** Arguments. */
61
+ args: string[];
62
+ /** Working directory, when the step is path-relative. */
63
+ cwd?: string;
64
+ }
65
+ /** The resolved start command for the Lacuna sidecar process. */
66
+ export interface LacunaLaunchCommand {
67
+ command: string;
68
+ args: string[];
69
+ env: Record<string, string>;
70
+ cwd: string;
71
+ }
72
+ /**
73
+ * Resolve `config.lacuna.source` into a {@link LacunaSource}, or null when no
74
+ * source is configured (the install step then has nothing to fetch and the
75
+ * supervisor must surface that the sidecar cannot be installed).
76
+ */
77
+ export declare function resolveLacunaSource(lacuna: LacunaConfig): LacunaSource | null;
78
+ /**
79
+ * Build the ordered install plan that takes a host from not-installed to a
80
+ * launchable Lacuna artifact (bare-process path). Pure data -- the supervisor
81
+ * runs the steps in order, stopping on the first failure.
82
+ *
83
+ * @param source resolved source (git clone/fetch, or a local path checkout)
84
+ * @param paths daemon-owned source + venv directories
85
+ * @param opts.sourceExists true when the git checkout dir already exists (use
86
+ * fetch+checkout instead of a fresh clone)
87
+ */
88
+ export declare function buildInstallPlan(source: LacunaSource, paths: LacunaPaths, opts: {
89
+ sourceExists: boolean;
90
+ }): InstallStep[];
91
+ /**
92
+ * Build the exact start command + env for `python -m lacuna`, per the contract.
93
+ *
94
+ * Every emitted env var is one the daemon legitimately sets; the provider API
95
+ * key is deliberately absent (it rides request auth headers). The upstream base
96
+ * URL is emitted only when configured -- otherwise Lacuna applies its own
97
+ * default ({@link LACUNA_DEFAULT_UPSTREAM_BASE_URL}).
98
+ */
99
+ export declare function buildLaunchCommand(lacuna: LacunaConfig, paths: LacunaPaths): LacunaLaunchCommand;
100
+ //# sourceMappingURL=launch-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-adapter.d.ts","sourceRoot":"","sources":["../../../src/backends/lacuna/launch-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,k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acuna deploy/launch adapter.
3
+ *
4
+ * Turns the daemon's `config.lacuna` block + Lacuna's delivered deploy/launch
5
+ * contract into (a) an ordered install plan that takes a host from
6
+ * not-installed to a launchable artifact, and (b) the exact start command +
7
+ * environment for `python -m lacuna`.
8
+ *
9
+ * Everything here is PURE: it constructs plain data (commands, args, env). It
10
+ * never spawns a process, touches the network, or writes the filesystem -- the
11
+ * lifecycle supervisor executes the returned plan/command. This keeps the seam
12
+ * fully unit-testable with no real I/O.
13
+ *
14
+ * Cross-product contract (Nexus request d0a7d9cf, delivered): build-from-source
15
+ * is the ONLY supported path -- no PyPI package or release artifact exists yet.
16
+ * The bare-process path (git clone -> python venv -> `pip install -c
17
+ * constraints.txt .` -> `python -m lacuna`) is implemented here; it is lighter
18
+ * than the container path and closer to the daemon's existing local-process
19
+ * supervision. Every LACUNA_* env var is optional; the provider API key is
20
+ * NEVER a Lacuna env var -- it rides each request's auth headers, relayed
21
+ * verbatim, so this adapter must never emit a credential into the launch env.
22
+ *
23
+ * Cite: wiki `what-lacuna-is/lacuna-deploy-launch-contract`;
24
+ * `docs/daemon-launch-contract.md` in the Lacuna repo (gitea/lacuna).
25
+ */
26
+ /**
27
+ * The revision of the deploy/launch contract this adapter was integrated
28
+ * against. Compared against the running artifact's `/health.contract_version`
29
+ * by the supervisor to surface a contract mismatch.
30
+ */
31
+ export const LACUNA_CONTRACT_VERSION = '1';
32
+ /** Upstream Anthropic API base URL Lacuna defaults to when none is configured. */
33
+ export const LACUNA_DEFAULT_UPSTREAM_BASE_URL = 'https://api.anthropic.com';
34
+ /**
35
+ * A source string is treated as a git URL when it looks like one:
36
+ * - ssh://... (e.g. ssh://git@git.syntelyos.com:3122/org/lacuna.git)
37
+ * - scp-style git@host:org/repo(.git)
38
+ * - http(s)://...(.git)
39
+ * - any string ending in .git
40
+ * Anything else is a local filesystem path (an existing checkout).
41
+ */
42
+ function isGitUrl(s) {
43
+ if (s.endsWith('.git'))
44
+ return true;
45
+ if (s.startsWith('ssh://') || s.startsWith('git://'))
46
+ return true;
47
+ if (/^git@[^/]+:/.test(s))
48
+ return true;
49
+ if (/^https?:\/\//.test(s) && s.includes('.git'))
50
+ return true;
51
+ return false;
52
+ }
53
+ /**
54
+ * Split an optional `#ref` pin off the end of a source string. A bare scp-style
55
+ * `git@host:org/repo` has no `#`, so this only splits on the LAST '#'.
56
+ */
57
+ function splitRef(raw) {
58
+ const hash = raw.lastIndexOf('#');
59
+ if (hash === -1)
60
+ return { location: raw };
61
+ const location = raw.slice(0, hash);
62
+ const ref = raw.slice(hash + 1).trim();
63
+ return ref ? { location, ref } : { location };
64
+ }
65
+ /**
66
+ * Resolve `config.lacuna.source` into a {@link LacunaSource}, or null when no
67
+ * source is configured (the install step then has nothing to fetch and the
68
+ * supervisor must surface that the sidecar cannot be installed).
69
+ */
70
+ export function resolveLacunaSource(lacuna) {
71
+ const raw = lacuna.source?.trim();
72
+ if (!raw)
73
+ return null;
74
+ const { location, ref } = splitRef(raw);
75
+ return {
76
+ kind: isGitUrl(location) ? 'git' : 'path',
77
+ location,
78
+ ref,
79
+ };
80
+ }
81
+ /** Path to the `pip`/`python` executables inside a POSIX virtualenv. */
82
+ function venvBin(venvDir, exe) {
83
+ return `${venvDir}/bin/${exe}`;
84
+ }
85
+ /**
86
+ * Build the ordered install plan that takes a host from not-installed to a
87
+ * launchable Lacuna artifact (bare-process path). Pure data -- the supervisor
88
+ * runs the steps in order, stopping on the first failure.
89
+ *
90
+ * @param source resolved source (git clone/fetch, or a local path checkout)
91
+ * @param paths daemon-owned source + venv directories
92
+ * @param opts.sourceExists true when the git checkout dir already exists (use
93
+ * fetch+checkout instead of a fresh clone)
94
+ */
95
+ export function buildInstallPlan(source, paths, opts) {
96
+ const steps = [];
97
+ if (source.kind === 'git') {
98
+ if (opts.sourceExists) {
99
+ steps.push({
100
+ description: `Fetch latest Lacuna source in ${paths.sourceDir}`,
101
+ command: 'git',
102
+ args: ['-C', paths.sourceDir, 'fetch', '--tags', '--prune', 'origin'],
103
+ });
104
+ steps.push({
105
+ description: `Check out ${source.ref ?? 'origin/HEAD'}`,
106
+ command: 'git',
107
+ args: ['-C', paths.sourceDir, 'checkout', '--force', source.ref ?? 'origin/HEAD'],
108
+ });
109
+ }
110
+ else {
111
+ const cloneArgs = ['clone'];
112
+ if (source.ref)
113
+ cloneArgs.push('--branch', source.ref);
114
+ cloneArgs.push(source.location, paths.sourceDir);
115
+ steps.push({
116
+ description: `Clone Lacuna source from ${source.location}`,
117
+ command: 'git',
118
+ args: cloneArgs,
119
+ });
120
+ }
121
+ }
122
+ // kind 'path': the source already lives at paths.sourceDir (= location); no
123
+ // acquisition step -- we install straight from the existing checkout.
124
+ steps.push({
125
+ description: `Create Python virtualenv at ${paths.venvDir}`,
126
+ command: 'python3',
127
+ args: ['-m', 'venv', paths.venvDir],
128
+ });
129
+ steps.push({
130
+ description: 'Install Lacuna (pinned) into the virtualenv',
131
+ command: venvBin(paths.venvDir, 'pip'),
132
+ args: ['install', '-c', 'constraints.txt', '.'],
133
+ cwd: paths.sourceDir,
134
+ });
135
+ return steps;
136
+ }
137
+ /**
138
+ * Build the exact start command + env for `python -m lacuna`, per the contract.
139
+ *
140
+ * Every emitted env var is one the daemon legitimately sets; the provider API
141
+ * key is deliberately absent (it rides request auth headers). The upstream base
142
+ * URL is emitted only when configured -- otherwise Lacuna applies its own
143
+ * default ({@link LACUNA_DEFAULT_UPSTREAM_BASE_URL}).
144
+ */
145
+ export function buildLaunchCommand(lacuna, paths) {
146
+ const env = {
147
+ LACUNA_HOST: lacuna.host,
148
+ LACUNA_PORT: String(lacuna.port),
149
+ LACUNA_ENGINE: 'anthropic',
150
+ LACUNA_COMPRESS_ENABLED: lacuna.compressEnabled ? 'true' : 'false',
151
+ };
152
+ if (lacuna.upstreamBaseUrl) {
153
+ env.LACUNA_UPSTREAM_BASE_URL = lacuna.upstreamBaseUrl;
154
+ }
155
+ return {
156
+ command: venvBin(paths.venvDir, 'python'),
157
+ args: ['-m', 'lacuna'],
158
+ env,
159
+ cwd: paths.sourceDir,
160
+ };
161
+ }
162
+ //# sourceMappingURL=launch-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-adapter.js","sourceRoot":"","sources":["../../../src/backends/lacuna/launch-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,kFAAkF;AAClF,MAAM,CAAC,MAAM,gCAAgC,GAAG,2BAA2B,CAAC;AA2C5E;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,CAAS;IACzB,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CAAC,GAAW;IAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,OAAO,GAAG,CAAC,CAAC,CAAC,EAA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QAC1B,uBAAuB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;KACnE,CAAC;IACF,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,GAAG,CAAC,wBAAwB,GAAG,MAAM,CAAC,eAAe,CAAC;IACxD,CAAC;IACD,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;QACzC,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC;QACtB,GAAG;QACH,GAAG,EAAE,KAAK,CAAC,SAAS;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Process-scoped holder for the daemon-managed Lacuna sidecar.
3
+ *
4
+ * Keeps unified-shell thin: it calls startLacunaSidecarIfEnabled() at startup
5
+ * and stopLacunaSidecar() on shutdown, and the routing layer reads
6
+ * getLacunaHandle() at spawn time to decide whether to route a team through the
7
+ * sidecar. All fail-open: a disabled or failed sidecar yields a null/not-ready
8
+ * handle and the daemon proceeds normally.
9
+ */
10
+ import type { LacunaConfig } from '../../types.js';
11
+ import { type LacunaHandle, type LacunaSupervisorDeps } from './supervisor.js';
12
+ /**
13
+ * Start the sidecar when lacuna.enabled; otherwise no-op. Never throws -- a
14
+ * start failure is logged and leaves the handle null (agents route direct).
15
+ */
16
+ export declare function startLacunaSidecarIfEnabled(lacuna: LacunaConfig, deps?: LacunaSupervisorDeps): Promise<LacunaHandle | null>;
17
+ /** Graceful, idempotent teardown of the daemon-managed sidecar. */
18
+ export declare function stopLacunaSidecar(): Promise<void>;
19
+ /** The current sidecar handle, or null when disabled / not started. */
20
+ export declare function getLacunaHandle(): LacunaHandle | null;
21
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/backends/lacuna/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAInG;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE,oBAAoB,GAC1B,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAmB9B;AAED,mEAAmE;AACnE,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMvD;AAED,uEAAuE;AACvE,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAErD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Process-scoped holder for the daemon-managed Lacuna sidecar.
3
+ *
4
+ * Keeps unified-shell thin: it calls startLacunaSidecarIfEnabled() at startup
5
+ * and stopLacunaSidecar() on shutdown, and the routing layer reads
6
+ * getLacunaHandle() at spawn time to decide whether to route a team through the
7
+ * sidecar. All fail-open: a disabled or failed sidecar yields a null/not-ready
8
+ * handle and the daemon proceeds normally.
9
+ */
10
+ import { startLacunaSidecar } from './supervisor.js';
11
+ let handle = null;
12
+ /**
13
+ * Start the sidecar when lacuna.enabled; otherwise no-op. Never throws -- a
14
+ * start failure is logged and leaves the handle null (agents route direct).
15
+ */
16
+ export async function startLacunaSidecarIfEnabled(lacuna, deps) {
17
+ if (!lacuna.enabled) {
18
+ return null;
19
+ }
20
+ try {
21
+ handle = await startLacunaSidecar(lacuna, deps);
22
+ const where = `http://${lacuna.host}:${lacuna.port}`;
23
+ console.log(`[lacuna] sidecar ${handle.isReady() ? 'ready' : 'started (not yet ready -- failing open)'} at ${where}`);
24
+ return handle;
25
+ }
26
+ catch (err) {
27
+ console.warn(`[lacuna] sidecar start raised unexpectedly (${err instanceof Error ? err.message : String(err)}); ` +
28
+ 'continuing without it (agents route direct).');
29
+ handle = null;
30
+ return null;
31
+ }
32
+ }
33
+ /** Graceful, idempotent teardown of the daemon-managed sidecar. */
34
+ export async function stopLacunaSidecar() {
35
+ const h = handle;
36
+ handle = null;
37
+ if (h) {
38
+ await h.close();
39
+ }
40
+ }
41
+ /** The current sidecar handle, or null when disabled / not started. */
42
+ export function getLacunaHandle() {
43
+ return handle;
44
+ }
45
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/backends/lacuna/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,kBAAkB,EAAgD,MAAM,iBAAiB,CAAC;AAEnG,IAAI,MAAM,GAAwB,IAAI,CAAC;AAEvC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAoB,EACpB,IAA2B;IAE3B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,UAAU,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACrD,OAAO,CAAC,GAAG,CACT,oBAAoB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,yCAAyC,OAAO,KAAK,EAAE,CACzG,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,+CAA+C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK;YACpG,8CAA8C,CAC/C,CAAC;QACF,MAAM,GAAG,IAAI,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjB,MAAM,GAAG,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,CAAC;QACN,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Lacuna spawn routing: decide whether a spawned agent team's LLM traffic is
3
+ * routed through the daemon-managed sidecar, and build the env that does it.
4
+ *
5
+ * Fail-open by construction: routing env is emitted ONLY when Lacuna is enabled
6
+ * AND a ready sidecar handle exists. In every other case -- disabled, no handle,
7
+ * not ready, or a ready-check that throws -- this returns {} and the spawned
8
+ * team routes directly to the upstream Anthropic API. A sidecar fault can never
9
+ * break agent execution.
10
+ *
11
+ * Header format: Claude Code's ANTHROPIC_CUSTOM_HEADERS env var is parsed as
12
+ * newline-separated "Name: Value" lines (the same shape as curl -H), NOT JSON.
13
+ * Lacuna strips the X-Lacuna-* control headers before relaying upstream.
14
+ */
15
+ import type { LacunaHandle } from './supervisor.js';
16
+ export interface LacunaRoutingInput {
17
+ /** config.lacuna.enabled -- the opt-in gate. */
18
+ enabled: boolean;
19
+ /** The current sidecar handle, or null when disabled / not started. */
20
+ handle: LacunaHandle | null;
21
+ /** Agent session id -> X-Lacuna-Session (omitted when absent). */
22
+ sessionId?: string;
23
+ /** Focus id -> X-Lacuna-Focus (omitted when absent). */
24
+ focusId?: string;
25
+ }
26
+ /**
27
+ * Build the spawn-env fragment that routes a team through the sidecar, or {}
28
+ * when routing must fail open. Pure and total -- never throws.
29
+ */
30
+ export declare function lacunaSpawnEnv(input: LacunaRoutingInput): Record<string, string>;
31
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/backends/lacuna/routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBhF"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Lacuna spawn routing: decide whether a spawned agent team's LLM traffic is
3
+ * routed through the daemon-managed sidecar, and build the env that does it.
4
+ *
5
+ * Fail-open by construction: routing env is emitted ONLY when Lacuna is enabled
6
+ * AND a ready sidecar handle exists. In every other case -- disabled, no handle,
7
+ * not ready, or a ready-check that throws -- this returns {} and the spawned
8
+ * team routes directly to the upstream Anthropic API. A sidecar fault can never
9
+ * break agent execution.
10
+ *
11
+ * Header format: Claude Code's ANTHROPIC_CUSTOM_HEADERS env var is parsed as
12
+ * newline-separated "Name: Value" lines (the same shape as curl -H), NOT JSON.
13
+ * Lacuna strips the X-Lacuna-* control headers before relaying upstream.
14
+ */
15
+ /**
16
+ * Build the spawn-env fragment that routes a team through the sidecar, or {}
17
+ * when routing must fail open. Pure and total -- never throws.
18
+ */
19
+ export function lacunaSpawnEnv(input) {
20
+ const { enabled, handle, sessionId, focusId } = input;
21
+ if (!enabled || !handle)
22
+ return {};
23
+ // A throwing ready-check must not break the spawn path -- treat as not ready.
24
+ let ready = false;
25
+ try {
26
+ ready = handle.isReady();
27
+ }
28
+ catch {
29
+ ready = false;
30
+ }
31
+ if (!ready)
32
+ return {};
33
+ const headerLines = [];
34
+ if (sessionId)
35
+ headerLines.push(`X-Lacuna-Session: ${sessionId}`);
36
+ if (focusId)
37
+ headerLines.push(`X-Lacuna-Focus: ${focusId}`);
38
+ const env = {
39
+ ANTHROPIC_BASE_URL: handle.baseUrl,
40
+ };
41
+ if (headerLines.length > 0) {
42
+ env.ANTHROPIC_CUSTOM_HEADERS = headerLines.join('\n');
43
+ }
44
+ return env;
45
+ }
46
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/backends/lacuna/routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEnC,8EAA8E;IAC9E,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,SAAS;QAAE,WAAW,CAAC,IAAI,CAAC,qBAAqB,SAAS,EAAE,CAAC,CAAC;IAClE,IAAI,OAAO;QAAE,WAAW,CAAC,IAAI,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;IAE5D,MAAM,GAAG,GAA2B;QAClC,kBAAkB,EAAE,MAAM,CAAC,OAAO;KACnC,CAAC;IACF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,wBAAwB,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Lacuna sidecar lifecycle supervisor.
3
+ *
4
+ * Keeps exactly one ready Lacuna sidecar alive on the daemon host and tears it
5
+ * down cleanly. Mirrors the codex-mcp-proxy handle pattern (start -> handle with
6
+ * close()), extended for an EXTERNAL process: install-if-needed, launch,
7
+ * /ready-gate, /health version check, restart-on-crash, SIGTERM teardown, and
8
+ * single-instance enforcement (adopt a healthy instance already on the port).
9
+ *
10
+ * All I/O is injected (spawn / fetch / sleep / now / pathExists / logger) so the
11
+ * whole lifecycle is unit-testable with no real process or socket. Defaults bind
12
+ * to node:child_process.spawn and global fetch.
13
+ *
14
+ * Fail-open is structural: a ready-gate timeout resolves a NOT-ready handle
15
+ * (never throws), so the caller routes agents directly to the upstream API.
16
+ *
17
+ * Contract: Nexus request d0a7d9cf (delivered). See ./launch-adapter.ts.
18
+ */
19
+ import { type LacunaPaths } from './launch-adapter.js';
20
+ import type { LacunaConfig } from '../../types.js';
21
+ /** Versions reported by GET /health. */
22
+ export interface LacunaHealth {
23
+ version?: string;
24
+ contractVersion?: string;
25
+ markerVersion?: string;
26
+ }
27
+ /** Handle to the supervised (or adopted) sidecar. */
28
+ export interface LacunaHandle {
29
+ /** http://host:port the daemon routes ANTHROPIC_BASE_URL to. */
30
+ baseUrl: string;
31
+ port: number;
32
+ /** True once GET /ready returned 200 {ready:true} within the timeout. */
33
+ isReady(): boolean;
34
+ /** Last parsed GET /health, or null if never observed. */
35
+ getHealth(): LacunaHealth | null;
36
+ /** True when this handle adopted a pre-existing instance (close() won't kill it). */
37
+ adopted: boolean;
38
+ /** Graceful, idempotent teardown (SIGTERM); a no-op for adopted/down sidecars. */
39
+ close(): Promise<void>;
40
+ }
41
+ /** Minimal child-process surface the supervisor relies on (ChildProcess satisfies it). */
42
+ export interface ProcLike {
43
+ pid?: number;
44
+ kill(signal?: NodeJS.Signals | number): boolean;
45
+ once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): unknown;
46
+ on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): unknown;
47
+ }
48
+ export interface LacunaSupervisorDeps {
49
+ /** Spawn a process; defaults to node:child_process.spawn. */
50
+ spawn?: (command: string, args: string[], opts: {
51
+ cwd?: string;
52
+ env?: NodeJS.ProcessEnv;
53
+ }) => ProcLike;
54
+ /** HTTP fetch; defaults to global fetch. */
55
+ fetchImpl?: typeof fetch;
56
+ /** Sleep; defaults to a real timer. */
57
+ sleep?: (ms: number) => Promise<void>;
58
+ /** Monotonic-ish clock; defaults to Date.now. */
59
+ now?: () => number;
60
+ /** Existence probe for the venv python; defaults to fs.existsSync. */
61
+ pathExists?: (p: string) => boolean;
62
+ logger?: {
63
+ log: (m: string) => void;
64
+ warn: (m: string) => void;
65
+ };
66
+ /** Resolve the install dirs from config; defaults to a state-dir layout. */
67
+ resolvePaths?: (config: LacunaConfig) => LacunaPaths;
68
+ /** Poll interval for the /ready gate (ms); defaults to 500. */
69
+ readyPollIntervalMs?: number;
70
+ /** Max automatic relaunches after an unexpected crash; defaults to 3. */
71
+ maxRestarts?: number;
72
+ }
73
+ /**
74
+ * Start (or adopt) the Lacuna sidecar. Returns a handle; on any soft failure
75
+ * (ready-gate timeout) the handle is simply not-ready so callers fail open.
76
+ * A second call while one is live returns the SAME handle (singleton).
77
+ */
78
+ export declare function startLacunaSidecar(config: LacunaConfig, deps?: LacunaSupervisorDeps): Promise<LacunaHandle>;
79
+ /** Test-only: reset the module singleton (does NOT kill any tracked process). */
80
+ export declare function __resetLacunaSupervisorForTest(): void;
81
+ //# sourceMappingURL=supervisor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/backends/lacuna/supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAA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