@telora/daemon-core 0.2.5
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/activity-tracker.d.ts +69 -0
- package/dist/activity-tracker.d.ts.map +1 -0
- package/dist/activity-tracker.js +155 -0
- package/dist/activity-tracker.js.map +1 -0
- package/dist/api-client.d.ts +94 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +145 -0
- package/dist/api-client.js.map +1 -0
- package/dist/config.d.ts +117 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +348 -0
- package/dist/config.js.map +1 -0
- package/dist/engine.d.ts +120 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +18 -0
- package/dist/engine.js.map +1 -0
- package/dist/escalation-types.d.ts +31 -0
- package/dist/escalation-types.d.ts.map +1 -0
- package/dist/escalation-types.js +24 -0
- package/dist/escalation-types.js.map +1 -0
- package/dist/event-logger.d.ts +13 -0
- package/dist/event-logger.d.ts.map +1 -0
- package/dist/event-logger.js +82 -0
- package/dist/event-logger.js.map +1 -0
- package/dist/git.d.ts +39 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +72 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle.d.ts +104 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +192 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/log-manager.d.ts +83 -0
- package/dist/log-manager.d.ts.map +1 -0
- package/dist/log-manager.js +217 -0
- package/dist/log-manager.js.map +1 -0
- package/dist/otel-env.d.ts +29 -0
- package/dist/otel-env.d.ts.map +1 -0
- package/dist/otel-env.js +44 -0
- package/dist/otel-env.js.map +1 -0
- package/dist/resilience.d.ts +127 -0
- package/dist/resilience.d.ts.map +1 -0
- package/dist/resilience.js +300 -0
- package/dist/resilience.js.map +1 -0
- package/dist/resource-governor.d.ts +83 -0
- package/dist/resource-governor.d.ts.map +1 -0
- package/dist/resource-governor.js +184 -0
- package/dist/resource-governor.js.map +1 -0
- package/dist/spawn.d.ts +72 -0
- package/dist/spawn.d.ts.map +1 -0
- package/dist/spawn.js +82 -0
- package/dist/spawn.js.map +1 -0
- package/dist/stream-json.d.ts +885 -0
- package/dist/stream-json.d.ts.map +1 -0
- package/dist/stream-json.js +298 -0
- package/dist/stream-json.js.map +1 -0
- package/dist/token-usage.d.ts +67 -0
- package/dist/token-usage.d.ts.map +1 -0
- package/dist/token-usage.js +150 -0
- package/dist/token-usage.js.map +1 -0
- package/dist/transforms.d.ts +64 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/transforms.js +78 -0
- package/dist/transforms.js.map +1 -0
- package/dist/unified-config.d.ts +62 -0
- package/dist/unified-config.d.ts.map +1 -0
- package/dist/unified-config.js +155 -0
- package/dist/unified-config.js.map +1 -0
- package/dist/workflow-types.d.ts +202 -0
- package/dist/workflow-types.d.ts.map +1 -0
- package/dist/workflow-types.js +15 -0
- package/dist/workflow-types.js.map +1 -0
- package/dist/worktree.d.ts +92 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +221 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative key mapping utilities for camelCase <-> snake_case transforms.
|
|
3
|
+
*
|
|
4
|
+
* These utilities are used by query modules in both the daemon and factory
|
|
5
|
+
* engines to transform API response objects (snake_case DB columns) into
|
|
6
|
+
* application types (camelCase TypeScript interfaces).
|
|
7
|
+
*
|
|
8
|
+
* Extracted from packages/daemon/src/queries/shared.ts.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Transform an object's keys using a declarative mapping config.
|
|
12
|
+
*
|
|
13
|
+
* Each target key maps to either:
|
|
14
|
+
* - A source key name (direct copy)
|
|
15
|
+
* - `{ from: sourceKey, default: fallback }` (copy with default if null/undefined)
|
|
16
|
+
* - `{ value: literal }` (hardcoded constant)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const toAppType = createTransform<ApiRole, AgentRole>({
|
|
21
|
+
* id: 'id',
|
|
22
|
+
* organization_id: 'organizationId',
|
|
23
|
+
* allowed_tools: { from: 'allowedTools', default: [] as string[] },
|
|
24
|
+
* });
|
|
25
|
+
* const role = toAppType(apiRole);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function createTransform(mapping) {
|
|
29
|
+
return (source) => {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [targetKey, spec] of Object.entries(mapping)) {
|
|
32
|
+
if (typeof spec === 'string') {
|
|
33
|
+
// Direct key mapping
|
|
34
|
+
result[targetKey] = source[spec];
|
|
35
|
+
}
|
|
36
|
+
else if (spec !== null && typeof spec === 'object' && 'from' in spec) {
|
|
37
|
+
// Key with default
|
|
38
|
+
const { from, default: defaultVal } = spec;
|
|
39
|
+
result[targetKey] = source[from] ?? defaultVal;
|
|
40
|
+
}
|
|
41
|
+
else if (spec !== null && typeof spec === 'object' && 'value' in spec) {
|
|
42
|
+
// Hardcoded value
|
|
43
|
+
result[targetKey] = spec.value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// mapDefinedKeys -- map only keys that are present and not undefined
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
/**
|
|
53
|
+
* Transform an updates object by mapping keys (e.g. snake_case -> camelCase).
|
|
54
|
+
* Only includes keys that are present and not undefined in the source.
|
|
55
|
+
*
|
|
56
|
+
* This is useful for building partial update payloads where you only want
|
|
57
|
+
* to include fields that were actually provided.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const fields = mapDefinedKeys(updates, {
|
|
62
|
+
* exit_reason: 'exitReason',
|
|
63
|
+
* started_at: 'startedAt',
|
|
64
|
+
* });
|
|
65
|
+
* // If updates = { exit_reason: 'done', started_at: undefined }
|
|
66
|
+
* // Result = { exitReason: 'done' } (started_at omitted because undefined)
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export function mapDefinedKeys(source, keyMap) {
|
|
70
|
+
const result = {};
|
|
71
|
+
for (const [sourceKey, targetKey] of Object.entries(keyMap)) {
|
|
72
|
+
if (source[sourceKey] !== undefined) {
|
|
73
|
+
result[targetKey] = source[sourceKey];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=transforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.js","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAqC;IAErC,OAAO,CAAC,MAAe,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,EAA6B,CAAC;QAC7C,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACxD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,qBAAqB;gBACrB,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,IAAqB,CAAC,CAAC;YACpD,CAAC;iBAAM,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAK,IAAgC,EAAE,CAAC;gBACpG,mBAAmB;gBACnB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,IAAiD,CAAC;gBACxF,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC;YACjD,CAAC;iBAAM,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAK,IAAgC,EAAE,CAAC;gBACrG,kBAAkB;gBAClB,MAAM,CAAC,SAAS,CAAC,GAAI,IAA2B,CAAC,KAAK,CAAC;YACzD,CAAC;QACH,CAAC;QACD,OAAO,MAAiB,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,qEAAqE;AACrE,8EAA8E;AAE9E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA+B,EAC/B,MAA8B;IAE9B,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5D,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified configuration for the daemon process shell.
|
|
3
|
+
*
|
|
4
|
+
* Loads a single .telora/daemon.json that contains shared fields (BaseConfig)
|
|
5
|
+
* plus engine-specific sections under an `engines` key:
|
|
6
|
+
*
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "teloraUrl": "...",
|
|
10
|
+
* "trackerId": "...",
|
|
11
|
+
* "organizationId": "...",
|
|
12
|
+
* "productId": "...",
|
|
13
|
+
* "repoPath": "...",
|
|
14
|
+
* "engines": {
|
|
15
|
+
* "strategy": { "enabled": true, "worktreeDir": "...", ... },
|
|
16
|
+
* "factory": { "enabled": true, "factoryWorktreeDir": "...", ... }
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Backward compatible: if the `engines` key is missing, both engines are
|
|
22
|
+
* enabled with default values. If the file is a legacy daemon-only config
|
|
23
|
+
* (with `worktreeDir` at the top level), it is treated as strategy-only.
|
|
24
|
+
*/
|
|
25
|
+
import type { BaseConfig } from './config.js';
|
|
26
|
+
/** Configuration for a single engine within the unified config. */
|
|
27
|
+
export interface EngineSection {
|
|
28
|
+
/** Whether this engine is enabled. Default: true. */
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
/** Engine-specific fields (e.g. worktreeDir, integrationBranch, ...). */
|
|
31
|
+
fields: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/** The parsed unified config returned by loadUnifiedConfig(). */
|
|
34
|
+
export interface UnifiedConfig {
|
|
35
|
+
/** Shared base config (teloraUrl, trackerId, organizationId, etc.). */
|
|
36
|
+
base: Partial<BaseConfig>;
|
|
37
|
+
/** Strategy engine section (null if not present in config). */
|
|
38
|
+
strategy: EngineSection;
|
|
39
|
+
/** Factory engine section (null if not present in config). */
|
|
40
|
+
factory: EngineSection;
|
|
41
|
+
/** Raw file config for engines that need to apply their own defaults. */
|
|
42
|
+
rawFileConfig: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Load the unified daemon configuration from disk and environment.
|
|
46
|
+
*
|
|
47
|
+
* The function:
|
|
48
|
+
* 1. Reads daemon.json (or explicit configPath)
|
|
49
|
+
* 2. Resolves BaseConfig fields via env-over-file priority
|
|
50
|
+
* 3. Extracts engine sections from the `engines` key
|
|
51
|
+
* 4. Returns a UnifiedConfig with everything the shell needs
|
|
52
|
+
*
|
|
53
|
+
* @param configPath Explicit config file path, or undefined for .telora/daemon.json.
|
|
54
|
+
* @param env Environment variables (default: process.env).
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadUnifiedConfig(configPath?: string, env?: Record<string, string | undefined>): UnifiedConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Build a flat config object for an engine by merging BaseConfig fields
|
|
59
|
+
* with engine-specific fields. The result can be passed to engine.init().
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildEngineConfig(base: Partial<BaseConfig>, engineSection: EngineSection): BaseConfig & Record<string, unknown>;
|
|
62
|
+
//# sourceMappingURL=unified-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-config.d.ts","sourceRoot":"","sources":["../src/unified-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,EAAE,aAAa,CAAC;IACxB,8DAA8D;IAC9D,OAAO,EAAE,aAAa,CAAC;IACvB,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,CAAC,EAAE,MAAM,EACnB,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAqD,GAC1F,aAAa,CAsEf;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,EACzB,aAAa,EAAE,aAAa,GAC3B,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKtC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified configuration for the daemon process shell.
|
|
3
|
+
*
|
|
4
|
+
* Loads a single .telora/daemon.json that contains shared fields (BaseConfig)
|
|
5
|
+
* plus engine-specific sections under an `engines` key:
|
|
6
|
+
*
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "teloraUrl": "...",
|
|
10
|
+
* "trackerId": "...",
|
|
11
|
+
* "organizationId": "...",
|
|
12
|
+
* "productId": "...",
|
|
13
|
+
* "repoPath": "...",
|
|
14
|
+
* "engines": {
|
|
15
|
+
* "strategy": { "enabled": true, "worktreeDir": "...", ... },
|
|
16
|
+
* "factory": { "enabled": true, "factoryWorktreeDir": "...", ... }
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Backward compatible: if the `engines` key is missing, both engines are
|
|
22
|
+
* enabled with default values. If the file is a legacy daemon-only config
|
|
23
|
+
* (with `worktreeDir` at the top level), it is treated as strategy-only.
|
|
24
|
+
*/
|
|
25
|
+
import { loadConfigFile } from './config.js';
|
|
26
|
+
import { resolveBaseConfig } from './config.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Loader
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Load the unified daemon configuration from disk and environment.
|
|
32
|
+
*
|
|
33
|
+
* The function:
|
|
34
|
+
* 1. Reads daemon.json (or explicit configPath)
|
|
35
|
+
* 2. Resolves BaseConfig fields via env-over-file priority
|
|
36
|
+
* 3. Extracts engine sections from the `engines` key
|
|
37
|
+
* 4. Returns a UnifiedConfig with everything the shell needs
|
|
38
|
+
*
|
|
39
|
+
* @param configPath Explicit config file path, or undefined for .telora/daemon.json.
|
|
40
|
+
* @param env Environment variables (default: process.env).
|
|
41
|
+
*/
|
|
42
|
+
export function loadUnifiedConfig(configPath, env = process.env) {
|
|
43
|
+
// Load the JSON config file
|
|
44
|
+
const fileConfig = loadConfigFile(configPath, 'daemon.json');
|
|
45
|
+
// Resolve base fields (env vars override file values)
|
|
46
|
+
const base = resolveBaseConfig(fileConfig, env);
|
|
47
|
+
// Extract the engines section (if present)
|
|
48
|
+
const enginesRaw = fileConfig.engines;
|
|
49
|
+
const hasEnginesSection = typeof enginesRaw === 'object' && enginesRaw !== null && !Array.isArray(enginesRaw);
|
|
50
|
+
let strategySection;
|
|
51
|
+
let factorySection;
|
|
52
|
+
if (hasEnginesSection) {
|
|
53
|
+
const engines = enginesRaw;
|
|
54
|
+
strategySection = parseEngineSection(engines.strategy, 'strategy');
|
|
55
|
+
factorySection = parseEngineSection(engines.factory, 'factory');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// No engines section -- detect legacy config shape.
|
|
59
|
+
// If worktreeDir or integrationBranch exist at top level, it's a legacy daemon config.
|
|
60
|
+
const isLegacyDaemon = 'worktreeDir' in fileConfig || 'integrationBranch' in fileConfig;
|
|
61
|
+
// If factoryWorktreeDir exists at top level, it's a legacy factory config.
|
|
62
|
+
const isLegacyFactory = 'factoryWorktreeDir' in fileConfig;
|
|
63
|
+
if (isLegacyDaemon && !isLegacyFactory) {
|
|
64
|
+
// Legacy daemon-only config: strategy enabled with all top-level fields
|
|
65
|
+
console.warn('[unified-config] WARNING: Legacy config format detected ' +
|
|
66
|
+
'(integrationBranch/worktreeDir at top level). ' +
|
|
67
|
+
'Factory engine is DISABLED. To enable both engines, migrate to the engines section:\n' +
|
|
68
|
+
' { "engines": { "strategy": { "integrationBranch": "integration" }, "factory": {} } }\n' +
|
|
69
|
+
'Run telora_connector_start to regenerate daemon.json with the correct format.');
|
|
70
|
+
strategySection = {
|
|
71
|
+
enabled: true,
|
|
72
|
+
fields: extractNonBaseFields(fileConfig),
|
|
73
|
+
};
|
|
74
|
+
factorySection = { enabled: false, fields: {} };
|
|
75
|
+
}
|
|
76
|
+
else if (isLegacyFactory && !isLegacyDaemon) {
|
|
77
|
+
// Legacy factory-only config
|
|
78
|
+
strategySection = { enabled: false, fields: {} };
|
|
79
|
+
factorySection = {
|
|
80
|
+
enabled: true,
|
|
81
|
+
fields: extractNonBaseFields(fileConfig),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// Unknown or empty config: both engines enabled with defaults
|
|
86
|
+
strategySection = { enabled: true, fields: {} };
|
|
87
|
+
factorySection = { enabled: true, fields: {} };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Allow env-var override for engine enable/disable
|
|
91
|
+
const strategyEnvEnabled = env.TELORA_ENGINE_STRATEGY_ENABLED;
|
|
92
|
+
if (strategyEnvEnabled !== undefined) {
|
|
93
|
+
strategySection.enabled = strategyEnvEnabled !== '0' && strategyEnvEnabled !== 'false';
|
|
94
|
+
}
|
|
95
|
+
const factoryEnvEnabled = env.TELORA_ENGINE_FACTORY_ENABLED;
|
|
96
|
+
if (factoryEnvEnabled !== undefined) {
|
|
97
|
+
factorySection.enabled = factoryEnvEnabled !== '0' && factoryEnvEnabled !== 'false';
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
base,
|
|
101
|
+
strategy: strategySection,
|
|
102
|
+
factory: factorySection,
|
|
103
|
+
rawFileConfig: fileConfig,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build a flat config object for an engine by merging BaseConfig fields
|
|
108
|
+
* with engine-specific fields. The result can be passed to engine.init().
|
|
109
|
+
*/
|
|
110
|
+
export function buildEngineConfig(base, engineSection) {
|
|
111
|
+
return {
|
|
112
|
+
...base,
|
|
113
|
+
...engineSection.fields,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Helpers
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
/** Parse a single engine section from the engines object. */
|
|
120
|
+
function parseEngineSection(raw, engineName) {
|
|
121
|
+
if (raw === undefined || raw === null) {
|
|
122
|
+
// Engine not mentioned in config -- default to enabled with no fields
|
|
123
|
+
return { enabled: true, fields: {} };
|
|
124
|
+
}
|
|
125
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
126
|
+
throw new Error(`engines.${engineName} must be an object, got ${typeof raw}`);
|
|
127
|
+
}
|
|
128
|
+
const section = raw;
|
|
129
|
+
const enabled = section.enabled !== false; // default true
|
|
130
|
+
// Everything except 'enabled' is an engine-specific field
|
|
131
|
+
const fields = {};
|
|
132
|
+
for (const [key, value] of Object.entries(section)) {
|
|
133
|
+
if (key !== 'enabled') {
|
|
134
|
+
fields[key] = value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { enabled, fields };
|
|
138
|
+
}
|
|
139
|
+
/** Known BaseConfig field names (to separate from engine-specific fields). */
|
|
140
|
+
const BASE_FIELD_NAMES = new Set([
|
|
141
|
+
'teloraUrl', 'trackerId', 'organizationId', 'productId',
|
|
142
|
+
'repoPath', 'products', 'claudeCodePath', 'logDir', 'sessionTimeoutMs',
|
|
143
|
+
'mcpConfigPath', 'engines',
|
|
144
|
+
]);
|
|
145
|
+
/** Extract fields from a config object that are NOT BaseConfig fields. */
|
|
146
|
+
function extractNonBaseFields(config) {
|
|
147
|
+
const result = {};
|
|
148
|
+
for (const [key, value] of Object.entries(config)) {
|
|
149
|
+
if (!BASE_FIELD_NAMES.has(key)) {
|
|
150
|
+
result[key] = value;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=unified-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-config.js","sourceRoot":"","sources":["../src/unified-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA2BhD,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E;;;;;;;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EAAE,CAAC;QAClD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared workflow types for daemon and factory engines.
|
|
3
|
+
*
|
|
4
|
+
* These types mirror the workflow database tables (snake_case fields)
|
|
5
|
+
* and are used by both the daemon guard engine and the factory
|
|
6
|
+
* workflow transition system. They represent the runtime evaluation
|
|
7
|
+
* model -- guards, triggers, conditions, and evaluation results.
|
|
8
|
+
*
|
|
9
|
+
* Frontend types (src/types/workflow.ts) use camelCase and serve
|
|
10
|
+
* a different purpose; they are NOT consolidated here.
|
|
11
|
+
*
|
|
12
|
+
* Canonical definition: @telora/daemon-core/workflow-types
|
|
13
|
+
*/
|
|
14
|
+
/** Guard enforcement level -- hard blocks transition, soft logs warning. */
|
|
15
|
+
export type GuardEnforcement = 'hard' | 'soft';
|
|
16
|
+
/** Trigger event types -- when the trigger fires relative to the transition. */
|
|
17
|
+
export type TriggerEvent = 'on_enter' | 'on_exit' | 'on_guard_fail' | 'on_guard_pass';
|
|
18
|
+
/** Action types for triggers. */
|
|
19
|
+
export type TriggerActionType = 'spawn_agent' | 'create_issue' | 'block_transition' | 'emit_warning' | 'set_field' | 'notify' | 'webhook' | 'inject_prompt' | 'manage_context';
|
|
20
|
+
/** A single stage within a workflow. */
|
|
21
|
+
export interface WorkflowStage {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description: string | null;
|
|
25
|
+
sort_order: number;
|
|
26
|
+
}
|
|
27
|
+
/** A workflow transition between two stages. */
|
|
28
|
+
export interface WorkflowTransition {
|
|
29
|
+
id: string;
|
|
30
|
+
workflow_id: string;
|
|
31
|
+
from_stage_id: string;
|
|
32
|
+
to_stage_id: string;
|
|
33
|
+
name: string | null;
|
|
34
|
+
is_automatic: boolean;
|
|
35
|
+
sort_order: number;
|
|
36
|
+
}
|
|
37
|
+
/** Decision path for block_transition triggers. */
|
|
38
|
+
export interface DecisionPath {
|
|
39
|
+
path: string;
|
|
40
|
+
label: string;
|
|
41
|
+
directive_template?: string | null;
|
|
42
|
+
}
|
|
43
|
+
/** A workflow guard on a transition. */
|
|
44
|
+
export interface WorkflowGuard {
|
|
45
|
+
id: string;
|
|
46
|
+
transition_id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string | null;
|
|
49
|
+
enforcement: GuardEnforcement;
|
|
50
|
+
conditions: GuardConditionNode[];
|
|
51
|
+
parameter_schema: Record<string, unknown>;
|
|
52
|
+
sort_order: number;
|
|
53
|
+
}
|
|
54
|
+
/** A workflow trigger on a transition. */
|
|
55
|
+
export interface WorkflowTrigger {
|
|
56
|
+
id: string;
|
|
57
|
+
transition_id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
trigger_event: TriggerEvent;
|
|
60
|
+
action_type: TriggerActionType;
|
|
61
|
+
action_config: Record<string, unknown>;
|
|
62
|
+
directive_template: string | null;
|
|
63
|
+
decision_paths: DecisionPath[] | null;
|
|
64
|
+
sort_order: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A condition node in the guard's condition tree (JSONB).
|
|
68
|
+
* Stored as nested JSON in workflow_guards.conditions.
|
|
69
|
+
*/
|
|
70
|
+
export interface GuardConditionNode {
|
|
71
|
+
condition_type?: string;
|
|
72
|
+
expression?: Record<string, unknown>;
|
|
73
|
+
logical_operator?: 'AND' | 'OR';
|
|
74
|
+
children?: GuardConditionNode[];
|
|
75
|
+
}
|
|
76
|
+
/** Directive for AI session context management operations. */
|
|
77
|
+
export interface ContextDirective {
|
|
78
|
+
type: 'compact' | 'reset' | 'load_files';
|
|
79
|
+
files?: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Interface for delivering trigger actions to active AI sessions.
|
|
83
|
+
* The factory engine implements this; the guard engine calls it.
|
|
84
|
+
* When absent (daemon delivery context), session-targeted triggers skip gracefully.
|
|
85
|
+
*/
|
|
86
|
+
export interface TriggerExecutionTarget {
|
|
87
|
+
injectPrompt(prompt: string): Promise<void>;
|
|
88
|
+
manageContext(directive: ContextDirective): Promise<void>;
|
|
89
|
+
setField(fieldName: string, fieldValue: unknown): Promise<void>;
|
|
90
|
+
notify(recipients: string[], message: string): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Factory-specific template interpolation context.
|
|
94
|
+
* Provides additional variables for prompt injection templates.
|
|
95
|
+
*/
|
|
96
|
+
export interface FactoryTemplateContext {
|
|
97
|
+
instanceId?: string;
|
|
98
|
+
workUnitTitle?: string;
|
|
99
|
+
workUnitDescription?: string;
|
|
100
|
+
cycleNumber?: number;
|
|
101
|
+
gateType?: string;
|
|
102
|
+
gateOutput?: string;
|
|
103
|
+
tokensUsed?: number;
|
|
104
|
+
tokenBudget?: number | null;
|
|
105
|
+
wallClockElapsed?: string;
|
|
106
|
+
}
|
|
107
|
+
/** Result of evaluating a single condition leaf. */
|
|
108
|
+
export interface ConditionEvalResult {
|
|
109
|
+
condition_id: string;
|
|
110
|
+
condition_type: string;
|
|
111
|
+
passed: boolean;
|
|
112
|
+
observed_value: unknown;
|
|
113
|
+
expected_value: unknown;
|
|
114
|
+
message: string;
|
|
115
|
+
}
|
|
116
|
+
/** Result of evaluating a single guard's condition tree. */
|
|
117
|
+
export interface GuardEvalResult {
|
|
118
|
+
guard_id: string;
|
|
119
|
+
guard_name: string;
|
|
120
|
+
enforcement: GuardEnforcement;
|
|
121
|
+
passed: boolean;
|
|
122
|
+
condition_details: ConditionEvalResult[];
|
|
123
|
+
}
|
|
124
|
+
/** Result of evaluating all guards at a transition. */
|
|
125
|
+
export interface TransitionGuardResult {
|
|
126
|
+
/** Whether the transition should proceed */
|
|
127
|
+
should_proceed: boolean;
|
|
128
|
+
/** All individual guard evaluation results */
|
|
129
|
+
evaluations: GuardEvalResult[];
|
|
130
|
+
/** Triggers to execute (from failed/passed guards) */
|
|
131
|
+
triggers_to_execute: Array<{
|
|
132
|
+
trigger: WorkflowTrigger;
|
|
133
|
+
guard: WorkflowGuard | null;
|
|
134
|
+
eval_result: GuardEvalResult | null;
|
|
135
|
+
}>;
|
|
136
|
+
/** Warnings (from soft-enforcement failures) */
|
|
137
|
+
warnings: GuardEvalResult[];
|
|
138
|
+
/** Hard blocks (from hard-enforcement failures) */
|
|
139
|
+
blocks: GuardEvalResult[];
|
|
140
|
+
}
|
|
141
|
+
/** Transition evaluation record for audit trail. */
|
|
142
|
+
export interface TransitionEvaluationRecord {
|
|
143
|
+
organization_id: string;
|
|
144
|
+
entity_type: string;
|
|
145
|
+
entity_id: string;
|
|
146
|
+
transition_id: string;
|
|
147
|
+
guard_id: string | null;
|
|
148
|
+
result: 'passed' | 'failed' | 'error';
|
|
149
|
+
blocked: boolean;
|
|
150
|
+
enforcement_level: GuardEnforcement | null;
|
|
151
|
+
evaluation_details: Record<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
/** Transition block record for the transition_blocks table. */
|
|
154
|
+
export interface TransitionBlockRecord {
|
|
155
|
+
entity_type: string;
|
|
156
|
+
entity_id: string;
|
|
157
|
+
organization_id: string;
|
|
158
|
+
transition_id: string;
|
|
159
|
+
guard_id: string | null;
|
|
160
|
+
evaluation_id: string | null;
|
|
161
|
+
decision_paths: DecisionPath[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Context data for guard condition evaluation.
|
|
165
|
+
* Gathered once before evaluating all guards at a transition.
|
|
166
|
+
*
|
|
167
|
+
* Factory fields are optional -- present when evaluating factory guards,
|
|
168
|
+
* absent for daemon delivery guards.
|
|
169
|
+
*/
|
|
170
|
+
export interface EvaluationContext {
|
|
171
|
+
deliveryId: string;
|
|
172
|
+
openIssueCount: number;
|
|
173
|
+
totalIssueCount: number;
|
|
174
|
+
issuesByStatus: Record<string, number>;
|
|
175
|
+
issuesByPriority: Record<string, number>;
|
|
176
|
+
lastExitCode: number;
|
|
177
|
+
sessionCount: number;
|
|
178
|
+
/** Recent gate results for condition evaluation. */
|
|
179
|
+
gateResults?: Array<{
|
|
180
|
+
strategyId: string;
|
|
181
|
+
gateType: string;
|
|
182
|
+
iteration: number;
|
|
183
|
+
passed: boolean;
|
|
184
|
+
}>;
|
|
185
|
+
/** Current token consumption for the factory instance. */
|
|
186
|
+
tokensUsed?: number;
|
|
187
|
+
/** Blueprint token budget (null = unlimited). */
|
|
188
|
+
tokenBudget?: number | null;
|
|
189
|
+
/** Count of work units per status. */
|
|
190
|
+
workUnitsByStatus?: Record<string, number>;
|
|
191
|
+
/** Total number of work units in the instance. */
|
|
192
|
+
totalWorkUnitCount?: number;
|
|
193
|
+
/** Completion gate iteration count. */
|
|
194
|
+
cycleCount?: number;
|
|
195
|
+
/** Elapsed wall clock time in seconds. */
|
|
196
|
+
wallClockSeconds?: number;
|
|
197
|
+
/** Blueprint wall clock limit in seconds (null = unlimited). */
|
|
198
|
+
wallClockLimitSeconds?: number | null;
|
|
199
|
+
/** Named config values for dynamic guard thresholds (e.g., blueprint.maxInstanceIterations). */
|
|
200
|
+
configValues?: Record<string, number>;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=workflow-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-types.d.ts","sourceRoot":"","sources":["../src/workflow-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,gFAAgF;AAChF,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,GAAG,eAAe,CAAC;AAEtF,iCAAiC;AACjC,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,cAAc,GACd,kBAAkB,GAClB,cAAc,GACd,WAAW,GACX,QAAQ,GAC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;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,gGAAgG;IAChG,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared workflow types for daemon and factory engines.
|
|
3
|
+
*
|
|
4
|
+
* These types mirror the workflow database tables (snake_case fields)
|
|
5
|
+
* and are used by both the daemon guard engine and the factory
|
|
6
|
+
* workflow transition system. They represent the runtime evaluation
|
|
7
|
+
* model -- guards, triggers, conditions, and evaluation results.
|
|
8
|
+
*
|
|
9
|
+
* Frontend types (src/types/workflow.ts) use camelCase and serve
|
|
10
|
+
* a different purpose; they are NOT consolidated here.
|
|
11
|
+
*
|
|
12
|
+
* Canonical definition: @telora/daemon-core/workflow-types
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=workflow-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-types.js","sourceRoot":"","sources":["../src/workflow-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared worktree operations for daemon and factory.
|
|
3
|
+
*
|
|
4
|
+
* Provides the common building blocks that both engines use for worktree
|
|
5
|
+
* lifecycle management: pruning, WIP commits, removal, existence checks,
|
|
6
|
+
* and creation. Engine-specific extensions (daemon's safety guards,
|
|
7
|
+
* merge-before-remove, orphan cleanup; factory's branch naming) live in
|
|
8
|
+
* their respective packages.
|
|
9
|
+
*/
|
|
10
|
+
/** Result of {@link createWorktreeBase}. */
|
|
11
|
+
export interface CreateWorktreeResult {
|
|
12
|
+
/** Absolute path to the worktree directory. */
|
|
13
|
+
worktreePath: string;
|
|
14
|
+
/** Whether a new branch was created (`true`) or an existing branch was reused (`false`). */
|
|
15
|
+
created: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Prune stale worktree bookkeeping entries.
|
|
19
|
+
*
|
|
20
|
+
* Calls `git worktree prune` to clean up internal git state for worktrees
|
|
21
|
+
* whose directories no longer exist on disk. Both daemon and factory call
|
|
22
|
+
* this identically during startup and before worktree creation.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pruneWorktrees(repoPath: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Commit all uncommitted changes in a worktree as a WIP safety commit.
|
|
27
|
+
*
|
|
28
|
+
* Stages everything (`git add -A`), commits with a WIP-prefixed message,
|
|
29
|
+
* and returns the resulting commit SHA. Returns `null` if the worktree
|
|
30
|
+
* does not exist, has no uncommitted changes, or if any git operation fails.
|
|
31
|
+
*
|
|
32
|
+
* @param worktreePath Absolute path to the worktree.
|
|
33
|
+
* @param label Human-readable context for the commit message
|
|
34
|
+
* (e.g. delivery name, blueprint name, instance ID).
|
|
35
|
+
* @returns Commit SHA if a WIP commit was created, `null` otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export declare function commitWip(worktreePath: string, label: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Remove a worktree directory and clean up git bookkeeping.
|
|
40
|
+
*
|
|
41
|
+
* This is the base removal operation shared by both engines. It handles:
|
|
42
|
+
* - Already-removed worktrees (just prune git state)
|
|
43
|
+
* - `git worktree remove --force` as the primary removal path
|
|
44
|
+
* - Fallback to `rmSync` if git removal fails
|
|
45
|
+
* - Final `git worktree prune` to clean up bookkeeping
|
|
46
|
+
*
|
|
47
|
+
* Engine-specific safety guards (daemon's unmerged-commit checks,
|
|
48
|
+
* merge-before-remove) are layered on top of this function.
|
|
49
|
+
*
|
|
50
|
+
* @param repoPath Absolute path to the main git repository.
|
|
51
|
+
* @param worktreePath Absolute path to the worktree to remove.
|
|
52
|
+
* @returns `true` if the worktree was removed (or already gone),
|
|
53
|
+
* `false` if removal failed.
|
|
54
|
+
*/
|
|
55
|
+
export declare function removeWorktreeBase(repoPath: string, worktreePath: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a worktree is currently checked out for a given branch.
|
|
58
|
+
*
|
|
59
|
+
* Parses `git worktree list --porcelain` output and checks for a matching
|
|
60
|
+
* `branch refs/heads/{branchName}` entry.
|
|
61
|
+
*
|
|
62
|
+
* @param branchName Branch name to search for (e.g. `agent/dev/my-feature`).
|
|
63
|
+
* @param repoPath Absolute path to the main git repository.
|
|
64
|
+
* @returns `true` if a worktree is attached to the branch.
|
|
65
|
+
*/
|
|
66
|
+
export declare function worktreeExistsForBranch(branchName: string, repoPath: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Create a worktree with an isolated branch.
|
|
69
|
+
*
|
|
70
|
+
* This is the shared worktree creation logic used by both engines:
|
|
71
|
+
* 1. Ensure the parent `worktreeDir` exists
|
|
72
|
+
* 2. Remove any existing directory at the target path (clean start)
|
|
73
|
+
* 3. Prune stale worktree entries
|
|
74
|
+
* 4. Remove any lingering worktree registration for the branch
|
|
75
|
+
* 5. Create the worktree using the existing branch or a new branch
|
|
76
|
+
*
|
|
77
|
+
* The `baseBranch` parameter controls what the new branch forks from:
|
|
78
|
+
* - Daemon passes the integration branch
|
|
79
|
+
* - Factory omits it (forks from HEAD of the default branch)
|
|
80
|
+
*
|
|
81
|
+
* @param repoPath Absolute path to the main git repository.
|
|
82
|
+
* @param worktreeDir Parent directory for worktrees
|
|
83
|
+
* (e.g. `.telora/worktrees/` or `.telora/factory-worktrees/`).
|
|
84
|
+
* @param branchName Full branch name (e.g. `agent/dev/feat-abc12345`
|
|
85
|
+
* or `factory/my-blueprint-a1b2c3d4`).
|
|
86
|
+
* @param baseBranch Branch to fork from when creating a new branch.
|
|
87
|
+
* If omitted, `git worktree add -b` forks from HEAD.
|
|
88
|
+
* @returns The worktree path and whether a new branch was created.
|
|
89
|
+
* @throws If the worktree cannot be created.
|
|
90
|
+
*/
|
|
91
|
+
export declare function createWorktreeBase(repoPath: string, worktreeDir: string, branchName: string, baseBranch?: string): CreateWorktreeResult;
|
|
92
|
+
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../src/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACnC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAKrD;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0C5E;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAmClF;AAMD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMrF;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,oBAAoB,CA0DtB"}
|