@cleocode/contracts 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter.d.ts +36 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +8 -0
- package/dist/adapter.js.map +1 -0
- package/dist/archive.d.ts +100 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +7 -0
- package/dist/archive.js.map +1 -0
- package/dist/brain.d.ts +36 -0
- package/dist/brain.d.ts.map +1 -0
- package/dist/brain.js +10 -0
- package/dist/brain.js.map +1 -0
- package/dist/capabilities.d.ts +21 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +7 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/config.d.ts +118 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/context-monitor.d.ts +16 -0
- package/dist/context-monitor.d.ts.map +1 -0
- package/dist/context-monitor.js +7 -0
- package/dist/context-monitor.js.map +1 -0
- package/dist/data-accessor.d.ts +167 -0
- package/dist/data-accessor.d.ts.map +1 -0
- package/dist/data-accessor.js +18 -0
- package/dist/data-accessor.js.map +1 -0
- package/dist/discovery.d.ts +29 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +7 -0
- package/dist/discovery.js.map +1 -0
- package/dist/exit-codes.d.ts +109 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +158 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/hooks.d.ts +17 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +8 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +26 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +8 -0
- package/dist/install.js.map +1 -0
- package/dist/lafs.d.ts +132 -0
- package/dist/lafs.d.ts.map +1 -0
- package/dist/lafs.js +26 -0
- package/dist/lafs.js.map +1 -0
- package/dist/memory.d.ts +51 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +8 -0
- package/dist/memory.js.map +1 -0
- package/dist/operations/index.d.ts +17 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +17 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/issues.d.ts +75 -0
- package/dist/operations/issues.d.ts.map +1 -0
- package/dist/operations/issues.js +10 -0
- package/dist/operations/issues.js.map +1 -0
- package/dist/operations/lifecycle.d.ts +141 -0
- package/dist/operations/lifecycle.d.ts.map +1 -0
- package/dist/operations/lifecycle.js +8 -0
- package/dist/operations/lifecycle.js.map +1 -0
- package/dist/operations/orchestrate.d.ts +202 -0
- package/dist/operations/orchestrate.d.ts.map +1 -0
- package/dist/operations/orchestrate.js +8 -0
- package/dist/operations/orchestrate.js.map +1 -0
- package/dist/operations/release.d.ts +97 -0
- package/dist/operations/release.d.ts.map +1 -0
- package/dist/operations/release.js +7 -0
- package/dist/operations/release.js.map +1 -0
- package/dist/operations/research.d.ts +126 -0
- package/dist/operations/research.d.ts.map +1 -0
- package/dist/operations/research.js +11 -0
- package/dist/operations/research.js.map +1 -0
- package/dist/operations/session.d.ts +99 -0
- package/dist/operations/session.d.ts.map +1 -0
- package/dist/operations/session.js +12 -0
- package/dist/operations/session.js.map +1 -0
- package/dist/operations/skills.d.ts +182 -0
- package/dist/operations/skills.d.ts.map +1 -0
- package/dist/operations/skills.js +10 -0
- package/dist/operations/skills.js.map +1 -0
- package/dist/operations/system.d.ts +147 -0
- package/dist/operations/system.d.ts.map +1 -0
- package/dist/operations/system.js +8 -0
- package/dist/operations/system.js.map +1 -0
- package/dist/operations/tasks.d.ts +231 -0
- package/dist/operations/tasks.d.ts.map +1 -0
- package/dist/operations/tasks.js +13 -0
- package/dist/operations/tasks.js.map +1 -0
- package/dist/operations/validate.d.ts +170 -0
- package/dist/operations/validate.d.ts.map +1 -0
- package/dist/operations/validate.js +8 -0
- package/dist/operations/validate.js.map +1 -0
- package/dist/provider-paths.d.ts +16 -0
- package/dist/provider-paths.d.ts.map +1 -0
- package/dist/provider-paths.js +7 -0
- package/dist/provider-paths.js.map +1 -0
- package/dist/results.d.ts +188 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +10 -0
- package/dist/results.js.map +1 -0
- package/dist/session.d.ts +106 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +77 -0
- package/dist/session.js.map +1 -0
- package/dist/spawn-types.d.ts +119 -0
- package/dist/spawn-types.d.ts.map +1 -0
- package/dist/spawn-types.js +12 -0
- package/dist/spawn-types.js.map +1 -0
- package/dist/spawn.d.ts +30 -0
- package/dist/spawn.d.ts.map +1 -0
- package/dist/spawn.js +7 -0
- package/dist/spawn.js.map +1 -0
- package/dist/status-registry.d.ts +50 -0
- package/dist/status-registry.d.ts.map +1 -0
- package/dist/status-registry.js +125 -0
- package/dist/status-registry.js.map +1 -0
- package/dist/task-record.d.ts +67 -0
- package/dist/task-record.d.ts.map +1 -0
- package/dist/task-record.js +11 -0
- package/dist/task-record.js.map +1 -0
- package/dist/task-sync.d.ts +143 -0
- package/dist/task-sync.d.ts.map +1 -0
- package/dist/task-sync.js +11 -0
- package/dist/task-sync.js.map +1 -0
- package/dist/task.d.ts +294 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +24 -0
- package/dist/task.js.map +1 -0
- package/dist/tessera.d.ts +32 -0
- package/dist/tessera.d.ts.map +1 -0
- package/dist/tessera.js +11 -0
- package/dist/tessera.js.map +1 -0
- package/dist/todowrite.d.ts +53 -0
- package/dist/todowrite.d.ts.map +1 -0
- package/dist/todowrite.js +7 -0
- package/dist/todowrite.js.map +1 -0
- package/dist/transport.d.ts +12 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +7 -0
- package/dist/transport.js.map +1 -0
- package/dist/warp-chain.d.ts +121 -0
- package/dist/warp-chain.d.ts.map +1 -0
- package/dist/warp-chain.js +13 -0
- package/dist/warp-chain.js.map +1 -0
- package/package.json +29 -0
- package/src/adapter.ts +38 -0
- package/src/archive.ts +121 -0
- package/src/brain.ts +39 -0
- package/src/capabilities.ts +21 -0
- package/src/config.ts +135 -0
- package/src/context-monitor.ts +16 -0
- package/src/data-accessor.ts +239 -0
- package/src/discovery.ts +31 -0
- package/src/exit-codes.ts +175 -0
- package/src/hooks.ts +17 -0
- package/src/index.ts +298 -0
- package/src/install.ts +28 -0
- package/src/lafs.ts +194 -0
- package/src/memory.ts +57 -0
- package/src/operations/index.ts +17 -0
- package/src/operations/issues.ts +86 -0
- package/src/operations/lifecycle.ts +176 -0
- package/src/operations/orchestrate.ts +199 -0
- package/src/operations/release.ts +114 -0
- package/src/operations/research.ts +156 -0
- package/src/operations/session.ts +119 -0
- package/src/operations/skills.ts +210 -0
- package/src/operations/system.ts +174 -0
- package/src/operations/tasks.ts +279 -0
- package/src/operations/validate.ts +199 -0
- package/src/provider-paths.ts +16 -0
- package/src/results.ts +207 -0
- package/src/session.ts +157 -0
- package/src/spawn-types.ts +140 -0
- package/src/spawn.ts +32 -0
- package/src/status-registry.ts +166 -0
- package/src/task-record.ts +71 -0
- package/src/task-sync.ts +167 -0
- package/src/task.ts +387 -0
- package/src/tessera.ts +35 -0
- package/src/todowrite.ts +58 -0
- package/src/transport.ts +12 -0
- package/src/warp-chain.ts +174 -0
package/src/session.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session type definitions for CLEO V2.
|
|
3
|
+
*
|
|
4
|
+
* Plain TypeScript interfaces derived from the Drizzle/Zod schemas
|
|
5
|
+
* in src/store/validation-schemas.ts. Contracts must not depend on Zod/Drizzle.
|
|
6
|
+
*
|
|
7
|
+
* @epic T4454
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { SessionStatus } from './status-registry.js';
|
|
11
|
+
export type { SessionStatus };
|
|
12
|
+
|
|
13
|
+
/** Session scope JSON blob shape. */
|
|
14
|
+
export interface SessionScope {
|
|
15
|
+
type: string;
|
|
16
|
+
epicId?: string;
|
|
17
|
+
rootTaskId?: string;
|
|
18
|
+
includeDescendants?: boolean;
|
|
19
|
+
phaseFilter?: string | null;
|
|
20
|
+
labelFilter?: string[] | null;
|
|
21
|
+
maxDepth?: number | null;
|
|
22
|
+
explicitTaskIds?: string[] | null;
|
|
23
|
+
excludeTaskIds?: string[] | null;
|
|
24
|
+
computedTaskIds?: string[];
|
|
25
|
+
computedAt?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Session statistics. */
|
|
29
|
+
export interface SessionStats {
|
|
30
|
+
tasksCompleted: number;
|
|
31
|
+
tasksCreated: number;
|
|
32
|
+
tasksUpdated: number;
|
|
33
|
+
focusChanges: number;
|
|
34
|
+
totalActiveMinutes: number;
|
|
35
|
+
suspendCount: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Active task work state within a session. */
|
|
39
|
+
export interface SessionTaskWork {
|
|
40
|
+
taskId: string | null;
|
|
41
|
+
setAt: string | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Session domain type — plain interface aligned with Drizzle sessions table. */
|
|
45
|
+
export interface Session {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
status: SessionStatus;
|
|
49
|
+
scope: SessionScope;
|
|
50
|
+
taskWork: SessionTaskWork;
|
|
51
|
+
startedAt: string;
|
|
52
|
+
endedAt?: string;
|
|
53
|
+
agent?: string;
|
|
54
|
+
notes?: string[];
|
|
55
|
+
tasksCompleted?: string[];
|
|
56
|
+
tasksCreated?: string[];
|
|
57
|
+
handoffJson?: string | null;
|
|
58
|
+
previousSessionId?: string | null;
|
|
59
|
+
nextSessionId?: string | null;
|
|
60
|
+
agentIdentifier?: string | null;
|
|
61
|
+
handoffConsumedAt?: string | null;
|
|
62
|
+
handoffConsumedBy?: string | null;
|
|
63
|
+
debriefJson?: string | null;
|
|
64
|
+
stats?: SessionStats;
|
|
65
|
+
resumeCount?: number;
|
|
66
|
+
gradeMode?: boolean;
|
|
67
|
+
providerId?: string | null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Result of a session start operation.
|
|
72
|
+
*
|
|
73
|
+
* The `sessionId` field is a convenience alias for `session.id`,
|
|
74
|
+
* provided for consumers that expect it at the top level of the result.
|
|
75
|
+
*/
|
|
76
|
+
export interface SessionStartResult {
|
|
77
|
+
session: Session;
|
|
78
|
+
sessionId: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* SessionView — typed wrapper over Session[] with collection helpers.
|
|
83
|
+
*
|
|
84
|
+
* Provides discoverable query methods for common session lookups.
|
|
85
|
+
* Does NOT change the DataAccessor interface — consumers create views from Session[].
|
|
86
|
+
*/
|
|
87
|
+
export class SessionView {
|
|
88
|
+
private readonly _sessions: Session[];
|
|
89
|
+
|
|
90
|
+
constructor(sessions: Session[]) {
|
|
91
|
+
this._sessions = sessions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Create a SessionView from a Session array. */
|
|
95
|
+
static from(sessions: Session[]): SessionView {
|
|
96
|
+
return new SessionView(sessions);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** All sessions in the view (readonly). */
|
|
100
|
+
get all(): readonly Session[] {
|
|
101
|
+
return this._sessions;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Number of sessions. */
|
|
105
|
+
get length(): number {
|
|
106
|
+
return this._sessions.length;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Find the currently active session (if any). */
|
|
110
|
+
findActive(): Session | undefined {
|
|
111
|
+
return this._sessions.find((s) => s.status === 'active');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Find a session by ID. */
|
|
115
|
+
findById(id: string): Session | undefined {
|
|
116
|
+
return this._sessions.find((s) => s.id === id);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Filter sessions by one or more statuses. */
|
|
120
|
+
filterByStatus(...statuses: SessionStatus[]): Session[] {
|
|
121
|
+
return this._sessions.filter((s) => (statuses as string[]).includes(s.status));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Find sessions matching a scope type and optional rootTaskId. */
|
|
125
|
+
findByScope(type: string, rootTaskId?: string): Session[] {
|
|
126
|
+
return this._sessions.filter((s) => {
|
|
127
|
+
if (s.scope?.type !== type) return false;
|
|
128
|
+
if (rootTaskId && s.scope?.rootTaskId !== rootTaskId) return false;
|
|
129
|
+
return true;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Sort sessions by a date field. Returns a new array (does not mutate). */
|
|
134
|
+
sortByDate(field: 'startedAt' | 'endedAt', descending = true): Session[] {
|
|
135
|
+
return [...this._sessions].sort((a, b) => {
|
|
136
|
+
const aDate = new Date(a[field] || '').getTime();
|
|
137
|
+
const bDate = new Date(b[field] || '').getTime();
|
|
138
|
+
return descending ? bDate - aDate : aDate - bDate;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Get the most recently started session. */
|
|
143
|
+
mostRecent(): Session | undefined {
|
|
144
|
+
if (this._sessions.length === 0) return undefined;
|
|
145
|
+
return this.sortByDate('startedAt', true)[0];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Convert back to a plain Session array (shallow copy). */
|
|
149
|
+
toArray(): Session[] {
|
|
150
|
+
return [...this._sessions];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Support for-of iteration. */
|
|
154
|
+
[Symbol.iterator](): Iterator<Session> {
|
|
155
|
+
return this._sessions[Symbol.iterator]();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLEO Spawn Adapter Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the spawn adapter system that wraps/extends
|
|
5
|
+
* CAAMP SpawnAdapter interface. Self-contained version for contracts
|
|
6
|
+
* (no dependency on @cleocode/caamp).
|
|
7
|
+
*
|
|
8
|
+
* @task T5236
|
|
9
|
+
* @phase 1B
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Provider identifier for spawn operations.
|
|
14
|
+
*/
|
|
15
|
+
export type Provider = string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* CAAMP-compatible spawn options (inlined for zero-dep contracts).
|
|
19
|
+
*/
|
|
20
|
+
export interface CAAMPSpawnOptions {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* CAAMP-compatible spawn result (inlined for zero-dep contracts).
|
|
26
|
+
*/
|
|
27
|
+
export interface CAAMPSpawnResult {
|
|
28
|
+
instanceId: string;
|
|
29
|
+
output: string;
|
|
30
|
+
exitCode: number;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* CLEO-specific spawn context
|
|
36
|
+
* Extends CAAMP options with CLEO task and protocol metadata
|
|
37
|
+
*/
|
|
38
|
+
export interface CLEOSpawnContext {
|
|
39
|
+
/** Task ID being spawned */
|
|
40
|
+
taskId: string;
|
|
41
|
+
|
|
42
|
+
/** Protocol to use for the spawned task */
|
|
43
|
+
protocol: string;
|
|
44
|
+
|
|
45
|
+
/** Fully-resolved prompt to send to subagent */
|
|
46
|
+
prompt: string;
|
|
47
|
+
|
|
48
|
+
/** Provider to use for spawning */
|
|
49
|
+
provider: Provider;
|
|
50
|
+
|
|
51
|
+
/** CAAMP-compatible spawn options */
|
|
52
|
+
options: CAAMPSpawnOptions;
|
|
53
|
+
|
|
54
|
+
/** Project root or working directory for provider-specific files and process execution */
|
|
55
|
+
workingDirectory?: string;
|
|
56
|
+
|
|
57
|
+
/** Token resolution information for the prompt */
|
|
58
|
+
tokenResolution?: TokenResolution;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* CLEO spawn result
|
|
63
|
+
* Extends CAAMP SpawnResult with CLEO-specific timing and metadata
|
|
64
|
+
*/
|
|
65
|
+
export interface CLEOSpawnResult extends CAAMPSpawnResult {
|
|
66
|
+
/** Task ID that was spawned */
|
|
67
|
+
taskId: string;
|
|
68
|
+
|
|
69
|
+
/** Provider ID used for the spawn */
|
|
70
|
+
providerId: string;
|
|
71
|
+
|
|
72
|
+
/** Timing information for the spawn operation */
|
|
73
|
+
timing: {
|
|
74
|
+
/** ISO timestamp when spawn started */
|
|
75
|
+
startTime: string;
|
|
76
|
+
/** ISO timestamp when spawn completed (if finished) */
|
|
77
|
+
endTime?: string;
|
|
78
|
+
/** Duration in milliseconds */
|
|
79
|
+
durationMs?: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Reference to manifest entry if output was captured */
|
|
83
|
+
manifestEntryId?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Spawn adapter interface
|
|
88
|
+
* Wraps CAAMP SpawnAdapter with CLEO-specific context and result types
|
|
89
|
+
*/
|
|
90
|
+
export interface CLEOSpawnAdapter {
|
|
91
|
+
/** Unique identifier for this adapter instance */
|
|
92
|
+
readonly id: string;
|
|
93
|
+
|
|
94
|
+
/** Provider ID this adapter uses */
|
|
95
|
+
readonly providerId: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Check if this adapter can spawn in the current environment
|
|
99
|
+
* @returns Promise resolving to true if spawning is possible
|
|
100
|
+
*/
|
|
101
|
+
canSpawn(): Promise<boolean>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Execute a spawn using the provider's native mechanism
|
|
105
|
+
* @param context - Fully-resolved spawn context
|
|
106
|
+
* @returns Promise resolving to spawn result
|
|
107
|
+
* @throws SpawnExecutionError if spawn fails
|
|
108
|
+
*/
|
|
109
|
+
spawn(context: CLEOSpawnContext): Promise<CLEOSpawnResult>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* List currently running spawns
|
|
113
|
+
* @returns Promise resolving to array of running spawn results
|
|
114
|
+
*/
|
|
115
|
+
listRunning(): Promise<CLEOSpawnResult[]>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Terminate a running spawn
|
|
119
|
+
* @param instanceId - ID of the spawn instance to terminate
|
|
120
|
+
* @returns Promise that resolves when termination is complete
|
|
121
|
+
*/
|
|
122
|
+
terminate(instanceId: string): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Token resolution information for prompt processing
|
|
127
|
+
*/
|
|
128
|
+
export interface TokenResolution {
|
|
129
|
+
/** Array of resolved token identifiers */
|
|
130
|
+
resolved: string[];
|
|
131
|
+
/** Array of unresolved token identifiers */
|
|
132
|
+
unresolved: string[];
|
|
133
|
+
/** Total number of tokens processed */
|
|
134
|
+
totalTokens: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Spawn status values
|
|
139
|
+
*/
|
|
140
|
+
export type SpawnStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
package/src/spawn.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spawn provider interface for CLEO provider adapters.
|
|
3
|
+
*
|
|
4
|
+
* @task T5240
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface AdapterSpawnProvider {
|
|
8
|
+
canSpawn(): Promise<boolean>;
|
|
9
|
+
spawn(context: SpawnContext): Promise<SpawnResult>;
|
|
10
|
+
listRunning(): Promise<SpawnResult[]>;
|
|
11
|
+
terminate(instanceId: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SpawnContext {
|
|
15
|
+
taskId: string;
|
|
16
|
+
prompt: string;
|
|
17
|
+
workingDirectory?: string;
|
|
18
|
+
options?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SpawnResult {
|
|
22
|
+
instanceId: string;
|
|
23
|
+
taskId: string;
|
|
24
|
+
providerId: string;
|
|
25
|
+
/** Output captured from the spawned process. Optional for detached/fire-and-forget spawns. */
|
|
26
|
+
output?: string;
|
|
27
|
+
/** Exit code of the spawned process. Optional for detached/fire-and-forget spawns. */
|
|
28
|
+
exitCode?: number;
|
|
29
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
30
|
+
startTime: string;
|
|
31
|
+
endTime?: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Status Registry — single source of truth for all status enums.
|
|
3
|
+
*
|
|
4
|
+
* ADR-018: All status constants and types MUST be defined here.
|
|
5
|
+
* No other file may define status enum arrays as constants.
|
|
6
|
+
*
|
|
7
|
+
* Dependency direction:
|
|
8
|
+
* status-registry.ts → schema.ts, types/task.ts, validation/engine.ts,
|
|
9
|
+
* mcp/lib/security.ts, dispatch/lib/security.ts, ...
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// === WORKFLOW NAMESPACE ===
|
|
13
|
+
// Statuses for entities representing work being performed.
|
|
14
|
+
|
|
15
|
+
export const TASK_STATUSES = [
|
|
16
|
+
'pending',
|
|
17
|
+
'active',
|
|
18
|
+
'blocked',
|
|
19
|
+
'done',
|
|
20
|
+
'cancelled',
|
|
21
|
+
'archived',
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
export const SESSION_STATUSES = ['active', 'ended', 'orphaned', 'suspended'] as const;
|
|
25
|
+
|
|
26
|
+
export const LIFECYCLE_PIPELINE_STATUSES = [
|
|
27
|
+
'active',
|
|
28
|
+
'completed',
|
|
29
|
+
'blocked',
|
|
30
|
+
'failed',
|
|
31
|
+
'cancelled',
|
|
32
|
+
'aborted',
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
export const LIFECYCLE_STAGE_STATUSES = [
|
|
36
|
+
'not_started',
|
|
37
|
+
'in_progress',
|
|
38
|
+
'blocked',
|
|
39
|
+
'completed',
|
|
40
|
+
'skipped',
|
|
41
|
+
'failed',
|
|
42
|
+
] as const;
|
|
43
|
+
|
|
44
|
+
// === GOVERNANCE NAMESPACE ===
|
|
45
|
+
// Statuses for decisions and approvals.
|
|
46
|
+
|
|
47
|
+
export const ADR_STATUSES = ['proposed', 'accepted', 'superseded', 'deprecated'] as const;
|
|
48
|
+
|
|
49
|
+
export const GATE_STATUSES = ['pending', 'passed', 'failed', 'waived'] as const;
|
|
50
|
+
|
|
51
|
+
// === MANIFEST NAMESPACE ===
|
|
52
|
+
// Statuses for protocol output artifacts.
|
|
53
|
+
// NOTE: 'complete' was the old value — it is now 'completed' everywhere.
|
|
54
|
+
|
|
55
|
+
export const MANIFEST_STATUSES = ['completed', 'partial', 'blocked', 'archived'] as const;
|
|
56
|
+
|
|
57
|
+
// === DERIVED TYPES ===
|
|
58
|
+
|
|
59
|
+
export type TaskStatus = (typeof TASK_STATUSES)[number];
|
|
60
|
+
export type SessionStatus = (typeof SESSION_STATUSES)[number];
|
|
61
|
+
export type PipelineStatus = (typeof LIFECYCLE_PIPELINE_STATUSES)[number];
|
|
62
|
+
export type StageStatus = (typeof LIFECYCLE_STAGE_STATUSES)[number];
|
|
63
|
+
export type AdrStatus = (typeof ADR_STATUSES)[number];
|
|
64
|
+
export type GateStatus = (typeof GATE_STATUSES)[number];
|
|
65
|
+
export type ManifestStatus = (typeof MANIFEST_STATUSES)[number];
|
|
66
|
+
|
|
67
|
+
// === TERMINAL STATE SETS ===
|
|
68
|
+
|
|
69
|
+
export const TERMINAL_TASK_STATUSES: ReadonlySet<TaskStatus> = new Set([
|
|
70
|
+
'done',
|
|
71
|
+
'cancelled',
|
|
72
|
+
'archived',
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
export const TERMINAL_PIPELINE_STATUSES: ReadonlySet<PipelineStatus> = new Set([
|
|
76
|
+
'completed',
|
|
77
|
+
'failed',
|
|
78
|
+
'cancelled',
|
|
79
|
+
'aborted',
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
export const TERMINAL_STAGE_STATUSES: ReadonlySet<StageStatus> = new Set([
|
|
83
|
+
'completed',
|
|
84
|
+
'skipped',
|
|
85
|
+
'failed',
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
// === REGISTRY (for runtime queryability) ===
|
|
89
|
+
|
|
90
|
+
export type EntityType =
|
|
91
|
+
| 'task'
|
|
92
|
+
| 'session'
|
|
93
|
+
| 'lifecycle_pipeline'
|
|
94
|
+
| 'lifecycle_stage'
|
|
95
|
+
| 'adr'
|
|
96
|
+
| 'gate'
|
|
97
|
+
| 'manifest';
|
|
98
|
+
|
|
99
|
+
export const STATUS_REGISTRY: Record<EntityType, readonly string[]> = {
|
|
100
|
+
task: TASK_STATUSES,
|
|
101
|
+
session: SESSION_STATUSES,
|
|
102
|
+
lifecycle_pipeline: LIFECYCLE_PIPELINE_STATUSES,
|
|
103
|
+
lifecycle_stage: LIFECYCLE_STAGE_STATUSES,
|
|
104
|
+
adr: ADR_STATUSES,
|
|
105
|
+
gate: GATE_STATUSES,
|
|
106
|
+
manifest: MANIFEST_STATUSES,
|
|
107
|
+
} as const;
|
|
108
|
+
|
|
109
|
+
export function isValidStatus(entityType: EntityType, value: string): boolean {
|
|
110
|
+
return (STATUS_REGISTRY[entityType] as readonly string[]).includes(value);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// === DISPLAY ICONS ===
|
|
114
|
+
// Typed Record maps — exhaustiveness is enforced by the compiler.
|
|
115
|
+
// All icon consumers MUST import from here instead of hardcoding comparisons.
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Pipeline status → Unicode progress icon.
|
|
119
|
+
* Used wherever lifecycle pipeline status is rendered to a terminal.
|
|
120
|
+
*/
|
|
121
|
+
export const PIPELINE_STATUS_ICONS: Record<PipelineStatus, string> = {
|
|
122
|
+
active: '\u25b6', // pipeline is running
|
|
123
|
+
completed: '\u2713', // all stages done successfully
|
|
124
|
+
blocked: '\u23f8', // cannot advance; waiting
|
|
125
|
+
failed: '\u2717', // terminal failure
|
|
126
|
+
cancelled: '\u2298', // user-initiated abandonment
|
|
127
|
+
aborted: '\u23f9', // system-forced termination
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Stage status → Unicode progress icon.
|
|
132
|
+
* Used wherever pipeline stage status is rendered to a terminal.
|
|
133
|
+
*/
|
|
134
|
+
export const STAGE_STATUS_ICONS: Record<StageStatus, string> = {
|
|
135
|
+
not_started: '\u23f9', // not yet entered
|
|
136
|
+
in_progress: '\u25b6', // actively running
|
|
137
|
+
blocked: '\u23f8', // paused / waiting
|
|
138
|
+
completed: '\u2713', // finished successfully
|
|
139
|
+
skipped: '\u23ed', // intentionally bypassed
|
|
140
|
+
failed: '\u2717', // terminal failure
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Task status → Unicode symbol (rich terminal / Unicode-enabled).
|
|
145
|
+
* Falls back to TASK_STATUS_SYMBOLS_ASCII when Unicode is unavailable.
|
|
146
|
+
*/
|
|
147
|
+
export const TASK_STATUS_SYMBOLS_UNICODE: Record<TaskStatus, string> = {
|
|
148
|
+
pending: '\u25cb', // ○ not yet started
|
|
149
|
+
active: '\u25c9', // ◉ in progress
|
|
150
|
+
blocked: '\u2297', // ⊗ cannot advance
|
|
151
|
+
done: '\u2713', // ✓ complete
|
|
152
|
+
cancelled: '\u2717', // ✗ abandoned
|
|
153
|
+
archived: '\u25a3', // ▣ stored, inactive
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Task status → ASCII fallback symbol (non-Unicode terminals, CI output).
|
|
158
|
+
*/
|
|
159
|
+
export const TASK_STATUS_SYMBOLS_ASCII: Record<TaskStatus, string> = {
|
|
160
|
+
pending: '-',
|
|
161
|
+
active: '*',
|
|
162
|
+
blocked: 'x',
|
|
163
|
+
done: '+',
|
|
164
|
+
cancelled: '~',
|
|
165
|
+
archived: '#',
|
|
166
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TaskRecord — string-widened version of Task for JSON serialization in dispatch/LAFS layer.
|
|
3
|
+
*
|
|
4
|
+
* Union-typed fields (status, priority, origin, etc.) are widened to string
|
|
5
|
+
* so that the dispatch layer does not need to validate enum membership.
|
|
6
|
+
*
|
|
7
|
+
* @task T4657
|
|
8
|
+
* @epic T4654
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { TaskVerification } from './task.js';
|
|
12
|
+
|
|
13
|
+
/** A single task relation entry (string-widened version). */
|
|
14
|
+
export interface TaskRecordRelation {
|
|
15
|
+
taskId: string;
|
|
16
|
+
type: string;
|
|
17
|
+
reason?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Validation history entry. */
|
|
21
|
+
export interface ValidationHistoryEntry {
|
|
22
|
+
round: number;
|
|
23
|
+
agent: string;
|
|
24
|
+
result: string;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** String-widened Task for JSON serialization in dispatch/LAFS layer. */
|
|
29
|
+
export interface TaskRecord {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
status: string;
|
|
34
|
+
priority: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
phase?: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string | null;
|
|
39
|
+
completedAt?: string | null;
|
|
40
|
+
cancelledAt?: string | null;
|
|
41
|
+
parentId?: string | null;
|
|
42
|
+
position?: number | null;
|
|
43
|
+
positionVersion?: number;
|
|
44
|
+
depends?: string[];
|
|
45
|
+
relates?: TaskRecordRelation[];
|
|
46
|
+
files?: string[];
|
|
47
|
+
acceptance?: string[];
|
|
48
|
+
notes?: string[];
|
|
49
|
+
labels?: string[];
|
|
50
|
+
size?: string | null;
|
|
51
|
+
epicLifecycle?: string | null;
|
|
52
|
+
noAutoComplete?: boolean | null;
|
|
53
|
+
verification?: TaskVerification | null;
|
|
54
|
+
origin?: string | null;
|
|
55
|
+
createdBy?: string | null;
|
|
56
|
+
validatedBy?: string | null;
|
|
57
|
+
testedBy?: string | null;
|
|
58
|
+
lifecycleState?: string | null;
|
|
59
|
+
validationHistory?: ValidationHistoryEntry[];
|
|
60
|
+
blockedBy?: string[];
|
|
61
|
+
cancellationReason?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Minimal task representation for find results. */
|
|
65
|
+
export interface MinimalTaskRecord {
|
|
66
|
+
id: string;
|
|
67
|
+
title: string;
|
|
68
|
+
status: string;
|
|
69
|
+
priority: string;
|
|
70
|
+
parentId?: string | null;
|
|
71
|
+
}
|