@telora/daemon-core 0.2.12 → 0.2.15

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/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { ActivityTracker, type ActivitySnapshot, } from './activity-tracker.js';
16
16
  export { buildOtelEnv, type BuildOtelEnvOptions, } from './otel-env.js';
17
17
  export { ESCALATION_REASONS, type EscalationReasonType, } from './escalation-types.js';
18
18
  export { extractSessionKey, pruneOldLogs, scanLogDirectory, type LogFileInfo, type LogManagerDeps, type LogRetentionConfig, type PruneResult, } from './log-manager.js';
19
- export { buildMcpConfig, resolveMcpServerPath, writeMcpConfigFile, type McpConfigOptions, } from './mcp-resolution.js';
19
+ export { buildMcpConfig, isLegacyMcpConfigShape, resolveMcpServerPath, writeMcpConfigFile, MCP_PRODUCTS_PACKAGE, MCP_PRODUCTS_BIN, type McpConfigOptions, } from './mcp-resolution.js';
20
20
  export { HealthEventBuffer, healthEvents, type HealthEvent, type HealthSeverity, } from './health-events.js';
21
21
  export type { GuardEnforcement, TriggerEvent, TriggerActionType, WorkflowStage, WorkflowTransition, DecisionPath, WorkflowGuard, WorkflowTrigger, GuardConditionNode, ContextDirective, TriggerExecutionTarget, FactoryTemplateContext, ConditionEvalResult, GuardEvalResult, TransitionGuardResult, TransitionEvaluationRecord, TransitionBlockRecord, EvaluationContext, } from './workflow-types.js';
22
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,kBAAkB,EAClB,4BAA4B,EAC5B,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,K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KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ export { ESCALATION_REASONS, } from './escalation-types.js';
34
34
  // Log manager (retention policy and pruning for agent log files)
35
35
  export { extractSessionKey, pruneOldLogs, scanLogDirectory, } from './log-manager.js';
36
36
  // MCP server resolution and config generation
37
- export { buildMcpConfig, resolveMcpServerPath, writeMcpConfigFile, } from './mcp-resolution.js';
37
+ export { buildMcpConfig, isLegacyMcpConfigShape, resolveMcpServerPath, writeMcpConfigFile, MCP_PRODUCTS_PACKAGE, MCP_PRODUCTS_BIN, } from './mcp-resolution.js';
38
38
  // Health event buffer (operational observability for daemon health)
39
39
  export { HealthEventBuffer, healthEvents, } from './health-events.js';
40
40
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAE5E,OAAO,EACL,QAAQ,EACR,cAAc,EACd,gBAAgB,EAIhB,kBAAkB,EAClB,4BAA4B,EAC5B,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,2DAA2D;AAC3D,OAAO,EACL,eAAe,GAGhB,MAAM,iBAAiB,CAAC;AAEzB,6DAA6D;AAC7D,OAAO,EACL,eAAe,EACf,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,qDAAqD;AACrD,OAAO,EACL,sBA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eAAe,EACf,sBAAsB,GAGvB,MAAM,YAAY,CAAC;AASpB,iEAAiE;AACjE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC;AAE7B,2EAA2E;AAC3E,OAAO,EACL,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC;AAEhC,0EAA0E;AAC1E,OAAO,EACL,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,4DAA4D;AAC5D,OAAO,EACL,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAE/B,sFAAsF;AACtF,OAAO,EACL,YAAY,GAEb,MAAM,eAAe,CAAC;AAEvB,oFAAoF;AACpF,OAAO,EACL,kBAAkB,GAEnB,MAAM,uBAAuB,CAAC;AAE/B,iEAAiE;AACjE,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,GAKjB,MAAM,kBAAkB,CAAC;AAE1B,8CAA8C;AAC9C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAE7B,oEAAoE;AACpE,OAAO,EACL,iBAAiB,EACjB,YAAY,GAGb,MAAM,oBAAoB,CAAC"}
@@ -1,17 +1,26 @@
1
1
  /**
2
2
  * MCP server path resolution and config generation.
3
3
  *
4
- * Provides helpers to resolve the @telora/mcp-products entry point and
5
- * generate .mcp.json config files.
4
+ * `.mcp.json` files written by the daemon use a committable, npx-based shape:
5
+ * the command is `npx`, args invoke `@telora/mcp-products@latest` with an
6
+ * explicit bin name, and per-user secrets (TELORA_TRACKER_ID) are NOT inlined.
7
+ * The MCP server reads them from `~/.telora/daemon.json` at startup. This
8
+ * makes a single `.mcp.json` byte-identical across collaborators.
6
9
  *
7
- * Resolution requires the caller's `import.meta.url` so that `createRequire`
8
- * searches from the correct package context. @telora/mcp-products is a
9
- * dependency of @telora/daemon, not daemon-core, so daemon-core's own
10
- * module context cannot resolve it. Callers pass their `import.meta.url`
11
- * to anchor the resolution in their own node_modules tree.
10
+ * `resolveMcpServerPath` is retained for daemon-spawned worktrees that need
11
+ * an absolute node-modules path (e.g. cold-start before npx cache exists).
12
12
  *
13
13
  * The config generation helpers are pure JSON builders with no external deps.
14
14
  */
15
+ /**
16
+ * Canonical bin name for `@telora/mcp-products`. The package's bin map
17
+ * exposes only `telora-mcp-products`; the unscoped package name is
18
+ * `mcp-products`, which does NOT match, so `npx -p @telora/mcp-products
19
+ * @latest` requires the bin to be named explicitly. Same lesson the daemon
20
+ * learned in commit 0368f4b6.
21
+ */
22
+ export declare const MCP_PRODUCTS_PACKAGE = "@telora/mcp-products";
23
+ export declare const MCP_PRODUCTS_BIN = "telora-mcp-products";
15
24
  /**
16
25
  * Resolve the absolute path to the @telora/mcp-products entry point (dist/index.js).
17
26
  *
@@ -26,21 +35,53 @@
26
35
  export declare function resolveMcpServerPath(callerImportMetaUrl: string): string;
27
36
  /**
28
37
  * MCP config generation options.
38
+ *
39
+ * `mcpServerPath` is no longer required for the committable connect-time shape;
40
+ * it is retained for callers (e.g. daemon-spawned worktrees) that prefer an
41
+ * absolute node-modules path over npx.
29
42
  */
30
43
  export interface McpConfigOptions {
31
- /** Absolute path to the MCP server entry point. */
32
- mcpServerPath: string;
33
- /** Telora tracker ID for authentication. */
34
- trackerId: string;
35
- /** Telora API URL. */
36
- teloraUrl: string;
44
+ /** Optional absolute path to the MCP server entry point. When set, emits
45
+ * a node-based command instead of the default npx-based committable shape. */
46
+ mcpServerPath?: string;
47
+ /** Telora tracker ID. Only inlined when `inlineTrackerId` is true (legacy
48
+ * worktree path); the committable shape leaves this off. */
49
+ trackerId?: string;
50
+ /** Telora API URL. Inlined into env unless omitted. */
51
+ teloraUrl?: string;
37
52
  /** MCP profile (e.g. 'execution' for daemon-spawned agents). */
38
53
  profile?: string;
54
+ /** When true, inline TELORA_TRACKER_ID into env (legacy / daemon-spawned
55
+ * worktrees). When false/undefined, omit from env so the file is
56
+ * committable -- the MCP server reads tracker_id from daemon.json. */
57
+ inlineTrackerId?: boolean;
39
58
  }
40
59
  /**
41
60
  * Build the .mcp.json content object.
61
+ *
62
+ * Default shape (committable, written by `telora-daemon connect` to user repos):
63
+ * command: "npx"
64
+ * args: ["-p", "@telora/mcp-products@latest", "telora-mcp-products"]
65
+ * env: { TELORA_URL: "<url>" } (TELORA_TRACKER_ID intentionally absent)
66
+ *
67
+ * Legacy shape (daemon-spawned worktrees, when mcpServerPath is set):
68
+ * command: "node"
69
+ * args: ["<absolute-path>"]
70
+ * env: { TELORA_TRACKER_ID, TELORA_URL, [TELORA_MCP_PROFILE] }
42
71
  */
43
72
  export declare function buildMcpConfig(options: McpConfigOptions): Record<string, unknown>;
73
+ /**
74
+ * Heuristic: is a parsed .mcp.json the legacy embedded-credentials shape?
75
+ *
76
+ * Old shape:
77
+ * - command === "node" with absolute args path into node_modules, OR
78
+ * - env contains a literal TELORA_TRACKER_ID value (a UUID, not a
79
+ * `${...}` interpolation placeholder)
80
+ *
81
+ * Used by the connect flow on re-runs to detect a stale file the user may
82
+ * now expect to commit, so we rewrite it to the credential-free shape.
83
+ */
84
+ export declare function isLegacyMcpConfigShape(parsed: unknown): boolean;
44
85
  /**
45
86
  * Write a .mcp.json file to a directory.
46
87
  *
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-resolution.d.ts","sourceRoot":"","sources":["../src/mcp-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAUxE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBjF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAInF"}
1
+ {"version":3,"file":"mcp-resolution.d.ts","sourceRoot":"","sources":["../src/mcp-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAUxE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B;mFAC+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;iEAC6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;2EAEuE;IACvE,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAa/D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAInF"}
@@ -1,20 +1,29 @@
1
1
  /**
2
2
  * MCP server path resolution and config generation.
3
3
  *
4
- * Provides helpers to resolve the @telora/mcp-products entry point and
5
- * generate .mcp.json config files.
4
+ * `.mcp.json` files written by the daemon use a committable, npx-based shape:
5
+ * the command is `npx`, args invoke `@telora/mcp-products@latest` with an
6
+ * explicit bin name, and per-user secrets (TELORA_TRACKER_ID) are NOT inlined.
7
+ * The MCP server reads them from `~/.telora/daemon.json` at startup. This
8
+ * makes a single `.mcp.json` byte-identical across collaborators.
6
9
  *
7
- * Resolution requires the caller's `import.meta.url` so that `createRequire`
8
- * searches from the correct package context. @telora/mcp-products is a
9
- * dependency of @telora/daemon, not daemon-core, so daemon-core's own
10
- * module context cannot resolve it. Callers pass their `import.meta.url`
11
- * to anchor the resolution in their own node_modules tree.
10
+ * `resolveMcpServerPath` is retained for daemon-spawned worktrees that need
11
+ * an absolute node-modules path (e.g. cold-start before npx cache exists).
12
12
  *
13
13
  * The config generation helpers are pure JSON builders with no external deps.
14
14
  */
15
15
  import { createRequire } from 'node:module';
16
16
  import { writeFileSync } from 'node:fs';
17
17
  import { join } from 'node:path';
18
+ /**
19
+ * Canonical bin name for `@telora/mcp-products`. The package's bin map
20
+ * exposes only `telora-mcp-products`; the unscoped package name is
21
+ * `mcp-products`, which does NOT match, so `npx -p @telora/mcp-products
22
+ * @latest` requires the bin to be named explicitly. Same lesson the daemon
23
+ * learned in commit 0368f4b6.
24
+ */
25
+ export const MCP_PRODUCTS_PACKAGE = '@telora/mcp-products';
26
+ export const MCP_PRODUCTS_BIN = 'telora-mcp-products';
18
27
  /**
19
28
  * Resolve the absolute path to the @telora/mcp-products entry point (dist/index.js).
20
29
  *
@@ -38,25 +47,68 @@ export function resolveMcpServerPath(callerImportMetaUrl) {
38
47
  }
39
48
  /**
40
49
  * Build the .mcp.json content object.
50
+ *
51
+ * Default shape (committable, written by `telora-daemon connect` to user repos):
52
+ * command: "npx"
53
+ * args: ["-p", "@telora/mcp-products@latest", "telora-mcp-products"]
54
+ * env: { TELORA_URL: "<url>" } (TELORA_TRACKER_ID intentionally absent)
55
+ *
56
+ * Legacy shape (daemon-spawned worktrees, when mcpServerPath is set):
57
+ * command: "node"
58
+ * args: ["<absolute-path>"]
59
+ * env: { TELORA_TRACKER_ID, TELORA_URL, [TELORA_MCP_PROFILE] }
41
60
  */
42
61
  export function buildMcpConfig(options) {
43
- const env = {
44
- TELORA_TRACKER_ID: options.trackerId,
45
- TELORA_URL: options.teloraUrl,
46
- };
47
- if (options.profile) {
48
- env.TELORA_MCP_PROFILE = options.profile;
62
+ const env = {};
63
+ if (options.teloraUrl)
64
+ env.TELORA_URL = options.teloraUrl;
65
+ if ((options.inlineTrackerId || options.mcpServerPath) && options.trackerId) {
66
+ env.TELORA_TRACKER_ID = options.trackerId;
49
67
  }
68
+ if (options.profile)
69
+ env.TELORA_MCP_PROFILE = options.profile;
70
+ const useNodePath = !!options.mcpServerPath;
71
+ const command = useNodePath ? 'node' : 'npx';
72
+ const args = useNodePath
73
+ ? [options.mcpServerPath]
74
+ : ['-p', `${MCP_PRODUCTS_PACKAGE}@latest`, MCP_PRODUCTS_BIN];
75
+ const server = { command, args };
76
+ if (Object.keys(env).length > 0)
77
+ server.env = env;
50
78
  return {
51
79
  mcpServers: {
52
- 'telora-products': {
53
- command: 'node',
54
- args: [options.mcpServerPath],
55
- env,
56
- },
80
+ 'telora-products': server,
57
81
  },
58
82
  };
59
83
  }
84
+ /**
85
+ * Heuristic: is a parsed .mcp.json the legacy embedded-credentials shape?
86
+ *
87
+ * Old shape:
88
+ * - command === "node" with absolute args path into node_modules, OR
89
+ * - env contains a literal TELORA_TRACKER_ID value (a UUID, not a
90
+ * `${...}` interpolation placeholder)
91
+ *
92
+ * Used by the connect flow on re-runs to detect a stale file the user may
93
+ * now expect to commit, so we rewrite it to the credential-free shape.
94
+ */
95
+ export function isLegacyMcpConfigShape(parsed) {
96
+ if (!parsed || typeof parsed !== 'object')
97
+ return false;
98
+ const root = parsed;
99
+ const server = root.mcpServers?.['telora-products'];
100
+ if (!server || typeof server !== 'object')
101
+ return false;
102
+ const s = server;
103
+ if (s.command === 'node')
104
+ return true;
105
+ const env = s.env;
106
+ const tracker = env?.TELORA_TRACKER_ID;
107
+ if (typeof tracker === 'string' && tracker.length > 0 && !tracker.includes('${')) {
108
+ return true;
109
+ }
110
+ return false;
111
+ }
60
112
  /**
61
113
  * Write a .mcp.json file to a directory.
62
114
  *
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-resolution.js","sourceRoot":"","sources":["../src/mcp-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,mBAA2B;IAC9D,MAAM,aAAa,GAAG,aAAa,CAAC,mBAAmB,CAAC,CAAC;IACzD,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,iGAAiG;YACjG,mBAAmB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACtE,CAAC;IACJ,CAAC;AACH,CAAC;AAgBD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACtD,MAAM,GAAG,GAA2B;QAClC,iBAAiB,EAAE,OAAO,CAAC,SAAS;QACpC,UAAU,EAAE,OAAO,CAAC,SAAS;KAC9B,CAAC;IAEF,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,UAAU,EAAE;YACV,iBAAiB,EAAE;gBACjB,OAAO,EAAE,MAAM;gBACf,IAAI,EAAE,C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AAE,CAAC,iBAAiB,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,GAAG,MAA8D,CAAC;IACzE,IAAI,CAAC,CAAC,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,GAAG,GAAG,CAAC,CAAC,GAA0C,CAAC;IACzD,MAAM,OAAO,GAAG,GAAG,EAAE,iBAAiB,CAAC;IACvC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,OAAyB;IAC3E,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC9C,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACrF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telora/daemon-core",
3
- "version": "0.2.12",
3
+ "version": "0.2.15",
4
4
  "description": "Shared core infrastructure for Telora daemon and factory - resilience, API client, config, git operations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",