@harness-engineering/types 0.9.0 → 0.9.1

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
@@ -1,814 +1,813 @@
1
1
  /**
2
- * Represents a ticket created in an external tracking service.
2
+ * Result type for consistent error handling across the toolkit.
3
3
  */
4
- interface ExternalTicket {
5
- /** External identifier, e.g., "github:owner/repo#42" */
6
- externalId: string;
7
- /** URL to the ticket in the external service */
8
- url: string;
9
- }
4
+ type Result<T, E = Error> = {
5
+ ok: true;
6
+ value: T;
7
+ } | {
8
+ ok: false;
9
+ error: E;
10
+ };
10
11
  /**
11
- * Current state of a ticket in the external service.
12
- * Pulled during syncFromExternal.
12
+ * Creates a successful Result.
13
13
  */
14
- interface ExternalTicketState {
15
- /** External identifier */
16
- externalId: string;
17
- /** Ticket title in the external service */
18
- title: string;
19
- /** External status (e.g., "open", "closed") */
20
- status: string;
21
- /** External labels (used for status disambiguation on GitHub) */
22
- labels: string[];
23
- /** Current assignee in the external service, or null */
24
- assignee: string | null;
25
- }
14
+ declare function Ok<T>(value: T): Result<T, never>;
26
15
  /**
27
- * Result of a sync operation. Collects successes and errors per-feature.
16
+ * Creates a failed Result.
28
17
  */
29
- interface SyncResult {
30
- /** Tickets created during this sync */
31
- created: ExternalTicket[];
32
- /** External IDs of tickets that were updated */
33
- updated: string[];
34
- /** Assignment changes detected during pull */
35
- assignmentChanges: Array<{
36
- feature: string;
37
- from: string | null;
38
- to: string | null;
39
- }>;
40
- /** Per-feature errors (sync never throws) */
41
- errors: Array<{
42
- featureOrId: string;
43
- error: Error;
44
- }>;
45
- }
18
+ declare function Err<E>(error: E): Result<never, E>;
46
19
  /**
47
- * Configuration for external tracker sync.
20
+ * Type guard to check if a Result is successful.
48
21
  */
49
- interface TrackerSyncConfig {
50
- /** Adapter kind -- narrowed to GitHub-only for now */
51
- kind: 'github';
52
- /** Repository in "owner/repo" format (for GitHub) */
53
- repo?: string;
54
- /** Labels auto-applied to created tickets for filtering + identification */
55
- labels?: string[];
56
- /** Maps roadmap status -> external status string */
57
- statusMap: Record<FeatureStatus, string>;
58
- /**
59
- * Maps external status (+ optional label) -> roadmap status.
60
- * Compound keys like "open:in-progress" express state + label.
61
- * Optional — when absent, syncFromExternal preserves current roadmap status.
62
- */
63
- reverseStatusMap?: Record<string, FeatureStatus>;
64
- }
65
-
22
+ declare function isOk<T, E>(result: Result<T, E>): result is {
23
+ ok: true;
24
+ value: T;
25
+ };
66
26
  /**
67
- * Token usage statistics for an agent turn or session.
27
+ * Type guard to check if a Result is failed.
68
28
  */
69
- interface TokenUsage {
70
- /** Number of tokens used in the input (prompt) */
71
- inputTokens: number;
72
- /** Number of tokens generated in the output (response) */
73
- outputTokens: number;
74
- /** Combined total tokens used */
75
- totalTokens: number;
76
- }
29
+ declare function isErr<T, E>(result: Result<T, E>): result is {
30
+ ok: false;
31
+ error: E;
32
+ };
33
+
77
34
  /**
78
- * Reference to a blocking issue.
35
+ * A single step in a multi-skill workflow.
79
36
  */
80
- interface BlockerRef {
81
- /** Unique ID of the blocker */
82
- id: string | null;
83
- /** Human-readable identifier (e.g., "CORE-123") */
84
- identifier: string | null;
85
- /** Current state of the blocker */
86
- state: string | null;
37
+ interface WorkflowStep {
38
+ /** The skill to execute (e.g., "detect-doc-drift") */
39
+ skill: string;
40
+ /** Name of the artifact this step produces */
41
+ produces: string;
42
+ /** Name of the artifact this step expects as input */
43
+ expects?: string;
44
+ /** Whether failure of this step stops the workflow */
45
+ gate?: 'pass-required' | 'advisory';
87
46
  }
88
47
  /**
89
- * Representation of a work item (issue/feature) in a tracker.
48
+ * Definition of a sequence of steps to achieve a goal.
90
49
  */
91
- interface Issue {
92
- /** Unique ID in the tracking system */
93
- id: string;
94
- /** Human-readable identifier (e.g., "CORE-123") */
95
- identifier: string;
96
- /** Title or headline of the issue */
97
- title: string;
98
- /** Detailed description, if available */
99
- description: string | null;
100
- /** Numerical priority (lower is typically higher priority) */
101
- priority: number | null;
102
- /** Current lifecycle state */
103
- state: string;
104
- /** Name of the git branch associated with this issue */
105
- branchName: string | null;
106
- /** Direct URL to the issue in the tracker */
107
- url: string | null;
108
- /** List of labels or tags */
109
- labels: string[];
110
- /** References to issues that block this one */
111
- blockedBy: BlockerRef[];
112
- /** ISO timestamp of creation */
113
- createdAt: string | null;
114
- /** ISO timestamp of last update */
115
- updatedAt: string | null;
50
+ interface Workflow {
51
+ /** Descriptive name of the workflow */
52
+ name: string;
53
+ /** Ordered list of steps */
54
+ steps: WorkflowStep[];
116
55
  }
117
56
  /**
118
- * Categories of errors that can occur during agent execution.
57
+ * Possible outcomes for a single workflow step.
119
58
  */
120
- type AgentErrorCategory = 'agent_not_found' | 'invalid_workspace_cwd' | 'response_timeout' | 'turn_timeout' | 'process_exit' | 'response_error' | 'turn_failed' | 'turn_cancelled' | 'turn_input_required';
59
+ type StepOutcome = 'pass' | 'fail' | 'skipped';
121
60
  /**
122
- * Error returned by an agent backend.
61
+ * Detailed result of a workflow step execution.
123
62
  */
124
- interface AgentError {
125
- /** Machine-readable category */
126
- category: AgentErrorCategory;
127
- /** Human-readable message */
128
- message: string;
129
- /** Optional additional context */
130
- details?: unknown;
63
+ interface WorkflowStepResult {
64
+ /** The step that was executed */
65
+ step: WorkflowStep;
66
+ /** The outcome of the execution */
67
+ outcome: StepOutcome;
68
+ /** Path to the produced artifact, if any */
69
+ artifact?: string;
70
+ /** Error message if outcome is 'fail' */
71
+ error?: string;
72
+ /** Execution time in milliseconds */
73
+ durationMs: number;
131
74
  }
132
75
  /**
133
- * Parameters for starting a new agent session.
76
+ * Final result of a complete workflow execution.
134
77
  */
135
- interface SessionStartParams {
136
- /** Absolute path to the workspace directory */
137
- workspacePath: string;
138
- /** Permission level for the agent (e.g., "readonly", "full") */
139
- permissionMode: string;
140
- /** List of tool names the agent is allowed to use */
141
- allowedTools?: string[];
142
- /** Custom system instructions for the agent */
143
- systemPrompt?: string;
78
+ interface WorkflowResult {
79
+ /** The workflow that was executed */
80
+ workflow: Workflow;
81
+ /** Results for each step in the workflow */
82
+ stepResults: WorkflowStepResult[];
83
+ /** Whether the overall workflow passed (all required gates passed) */
84
+ pass: boolean;
85
+ /** Total execution time in milliseconds */
86
+ totalDurationMs: number;
144
87
  }
88
+
145
89
  /**
146
- * Represents an active session with an agent backend.
90
+ * Predefined cognitive modes for skills.
147
91
  */
148
- interface AgentSession {
149
- /** Unique ID for the session */
150
- sessionId: string;
151
- /** Workspace associated with this session */
152
- workspacePath: string;
153
- /** Name of the backend provider */
154
- backendName: string;
155
- /** ISO timestamp when the session started */
156
- startedAt: string;
157
- }
92
+ declare const STANDARD_COGNITIVE_MODES: readonly ["adversarial-reviewer", "constructive-architect", "meticulous-implementer", "diagnostic-investigator", "advisory-guide", "meticulous-verifier"];
158
93
  /**
159
- * Parameters for a single interaction (turn) with an agent.
94
+ * Cognitive mode of a skill, determining its behavior and persona.
160
95
  */
161
- interface TurnParams {
162
- /** ID of the active session */
163
- sessionId: string;
164
- /** User or system prompt for this turn */
165
- prompt: string;
166
- /** Whether this is a continuation of a previous turn */
167
- isContinuation: boolean;
168
- }
96
+ type CognitiveMode = (typeof STANDARD_COGNITIVE_MODES)[number] | (string & {});
169
97
  /**
170
- * Event emitted by an agent during a turn.
98
+ * Static metadata for a skill.
171
99
  */
172
- interface AgentEvent {
173
- /** Event type (e.g., "thought", "tool_call", "output") */
174
- type: string;
175
- /** ISO timestamp */
176
- timestamp: string;
177
- /** Optional subtype for finer-grained classification */
178
- subtype?: string;
179
- /** Token usage snapshot if available */
180
- usage?: TokenUsage;
181
- /** Event payload */
182
- content?: unknown;
183
- /** Session ID if not implicit */
184
- sessionId?: string;
100
+ interface SkillMetadata {
101
+ /** Unique name of the skill */
102
+ name: string;
103
+ /** Semantic version string */
104
+ version: string;
105
+ /** Brief description of what the skill does */
106
+ description: string;
107
+ /** The cognitive mode this skill operates in */
108
+ cognitive_mode?: CognitiveMode;
185
109
  }
186
110
  /**
187
- * Result of a completed agent turn.
111
+ * Contextual information for a skill execution.
188
112
  */
189
- interface TurnResult {
190
- /** Whether the turn completed successfully */
191
- success: boolean;
192
- /** ID of the session */
193
- sessionId: string;
194
- /** Cumulative usage for this turn */
195
- usage: TokenUsage;
196
- /** Error message if success is false */
197
- error?: string;
113
+ interface SkillContext {
114
+ /** Name of the executing skill */
115
+ skillName: string;
116
+ /** Current pipeline phase */
117
+ phase: string;
118
+ /** Files relevant to the current execution */
119
+ files: string[];
120
+ /** Optional token budget uses a plain record to avoid cross-package deps. */
121
+ tokenBudget?: Record<string, number>;
122
+ /** Additional metadata */
123
+ metadata: Record<string, unknown>;
198
124
  }
199
125
  /**
200
- * Interface for agent backend implementations (Claude, Mock, etc.)
126
+ * Context for a single turn in a multi-turn skill interaction.
201
127
  */
202
- interface AgentBackend {
203
- /** Unique name of the backend */
204
- readonly name: string;
205
- /** Starts a new session */
206
- startSession(params: SessionStartParams): Promise<Result<AgentSession, AgentError>>;
207
- /** Runs a turn and streams events */
208
- runTurn(session: AgentSession, params: TurnParams): AsyncGenerator<AgentEvent, TurnResult, void>;
209
- /** Stops and cleans up a session */
210
- stopSession(session: AgentSession): Promise<Result<void, AgentError>>;
211
- /** Verifies connectivity and health */
212
- healthCheck(): Promise<Result<void, AgentError>>;
128
+ interface TurnContext extends SkillContext {
129
+ /** Current turn number (1-indexed) */
130
+ turnNumber: number;
131
+ /** Results from previous turns in the same session */
132
+ previousResults: unknown[];
213
133
  }
214
134
  /**
215
- * Interface for issue tracking systems (Roadmap, Linear, GitHub, etc.)
135
+ * Error reported by a skill.
216
136
  */
217
- interface IssueTrackerClient {
218
- /** Fetches issues eligible for agent assignment */
219
- fetchCandidateIssues(): Promise<Result<Issue[], Error>>;
220
- /** Fetches issues in specific lifecycle states */
221
- fetchIssuesByStates(stateNames: string[]): Promise<Result<Issue[], Error>>;
222
- /** Fetches current state for a set of issue IDs */
223
- fetchIssueStatesByIds(issueIds: string[]): Promise<Result<Map<string, Issue>, Error>>;
224
- }
137
+ type SkillError = {
138
+ /** Machine-readable error code */
139
+ code: string;
140
+ /** Human-readable error message */
141
+ message: string;
142
+ /** Phase in which the error occurred */
143
+ phase: string;
144
+ };
225
145
  /**
226
- * Configuration for an issue tracker adapter.
146
+ * Result of a skill execution.
227
147
  */
228
- interface TrackerConfig {
229
- /** Adapter kind (e.g., "roadmap", "linear") */
230
- kind: string;
231
- /** API endpoint if applicable */
232
- endpoint?: string;
233
- /** API key or token */
234
- apiKey?: string;
235
- /** Project slug or identifier */
236
- projectSlug?: string;
237
- /** Local file path for file-based trackers */
238
- filePath?: string;
239
- /** States considered "ready for work" */
240
- activeStates: string[];
241
- /** States considered "finished" */
242
- terminalStates: string[];
243
- }
148
+ type SkillResult = {
149
+ /** Whether the skill achieved its goal */
150
+ success: boolean;
151
+ /** List of artifact paths produced */
152
+ artifacts: string[];
153
+ /** One-line summary of the outcome */
154
+ summary: string;
155
+ };
244
156
  /**
245
- * Polling interval configuration.
157
+ * Lifecycle hooks for skills.
246
158
  */
247
- interface PollingConfig {
248
- /** Interval in milliseconds */
249
- intervalMs: number;
159
+ interface SkillLifecycleHooks {
160
+ /** Called before the skill starts execution */
161
+ preExecution?: (context: SkillContext) => SkillContext | null;
162
+ /** Called before each turn in a multi-turn interaction */
163
+ perTurn?: (context: TurnContext) => TurnContext | null;
164
+ /** Called after the skill completes execution */
165
+ postExecution?: (context: SkillContext, result: SkillResult) => void;
250
166
  }
167
+
251
168
  /**
252
- * Workspace management configuration.
169
+ * Names of standard CI checks.
253
170
  */
254
- interface WorkspaceConfig {
255
- /** Root directory where agent workspaces are created */
256
- root: string;
257
- }
171
+ type CICheckName = 'validate' | 'deps' | 'docs' | 'entropy' | 'security' | 'perf' | 'phase-gate' | 'arch' | 'traceability';
258
172
  /**
259
- * Lifecycle hooks configuration.
173
+ * Status of a CI check.
260
174
  */
261
- interface HooksConfig {
262
- /** Script to run after creating a workspace */
263
- afterCreate: string | null;
264
- /** Script to run before starting an agent */
265
- beforeRun: string | null;
266
- /** Script to run after an agent completes */
267
- afterRun: string | null;
268
- /** Script to run before removing a workspace */
269
- beforeRemove: string | null;
270
- /** Maximum time allowed for hook execution */
271
- timeoutMs: number;
272
- }
175
+ type CICheckStatus = 'pass' | 'fail' | 'warn' | 'skip';
273
176
  /**
274
- * Configuration for the agent runner.
177
+ * A specific issue found during a CI check.
275
178
  */
276
- interface AgentConfig {
277
- /** Backend type to use */
278
- backend: string;
279
- /** Command to launch the agent if applicable */
280
- command?: string;
281
- /** Model name/identifier */
282
- model?: string;
283
- /** API key for the agent provider */
284
- apiKey?: string;
285
- /** Global limit on concurrent agents */
286
- maxConcurrentAgents: number;
287
- /** Maximum turns allowed per session */
288
- maxTurns: number;
289
- /** Maximum backoff for retries */
290
- maxRetryBackoffMs: number;
291
- /** Concurrency limits partitioned by issue state */
292
- maxConcurrentAgentsByState: Record<string, number>;
293
- /** Policy for approving tool calls */
294
- approvalPolicy?: string;
295
- /** Policy for execution environment isolation */
296
- sandboxPolicy?: string;
297
- /** Timeout for a single turn */
298
- turnTimeoutMs: number;
299
- /** Timeout for reading from the agent */
300
- readTimeoutMs: number;
301
- /** Timeout for agent inactivity */
302
- stallTimeoutMs: number;
179
+ interface CICheckIssue {
180
+ /** Severity level */
181
+ severity: 'error' | 'warning';
182
+ /** Descriptive message */
183
+ message: string;
184
+ /** Path to the affected file */
185
+ file?: string;
186
+ /** Line number in the affected file */
187
+ line?: number;
303
188
  }
304
189
  /**
305
- * Internal server configuration.
190
+ * Result of a single CI check execution.
306
191
  */
307
- interface ServerConfig {
308
- /** Port to listen on (null to disable) */
309
- port: number | null;
192
+ interface CICheckResult {
193
+ /** Name of the check */
194
+ name: CICheckName;
195
+ /** Final status of the check */
196
+ status: CICheckStatus;
197
+ /** List of issues discovered */
198
+ issues: CICheckIssue[];
199
+ /** Execution time in milliseconds */
200
+ durationMs: number;
310
201
  }
311
202
  /**
312
- * Root workflow configuration object.
203
+ * Summary counts for a set of CI checks.
313
204
  */
314
- interface WorkflowConfig {
315
- /** Issue tracker settings */
316
- tracker: TrackerConfig;
317
- /** Polling loop settings */
318
- polling: PollingConfig;
319
- /** Workspace settings */
320
- workspace: WorkspaceConfig;
321
- /** Lifecycle hook settings */
322
- hooks: HooksConfig;
323
- /** Agent execution settings */
324
- agent: AgentConfig;
325
- /** Server settings */
326
- server: ServerConfig;
205
+ interface CICheckSummary {
206
+ /** Total number of checks run */
207
+ total: number;
208
+ /** Number of passing checks */
209
+ passed: number;
210
+ /** Number of failing checks */
211
+ failed: number;
212
+ /** Number of checks with warnings */
213
+ warnings: number;
214
+ /** Number of skipped checks */
215
+ skipped: number;
327
216
  }
328
217
  /**
329
- * Complete workflow definition including config and prompts.
218
+ * Final report for a CI run.
330
219
  */
331
- interface WorkflowDefinition {
332
- /** Orchestrator configuration */
333
- config: WorkflowConfig;
334
- /** Template used to generate agent prompts */
335
- promptTemplate: string;
220
+ interface CICheckReport {
221
+ /** Schema version */
222
+ version: 1;
223
+ /** Name of the project */
224
+ project: string;
225
+ /** ISO timestamp of the run */
226
+ timestamp: string;
227
+ /** Detailed results for each check */
228
+ checks: CICheckResult[];
229
+ /** Aggregated summary */
230
+ summary: CICheckSummary;
231
+ /** Process exit code suggested for the CI runner */
232
+ exitCode: 0 | 1 | 2;
336
233
  }
337
-
338
234
  /**
339
- * Extended entry for cost tracking storage and display.
340
- * Composes TokenUsage — does not extend it.
235
+ * Severity level that should trigger a CI failure.
341
236
  */
342
- interface UsageRecord {
343
- /** Harness session identifier */
344
- sessionId: string;
345
- /** ISO 8601 timestamp of the usage event */
346
- timestamp: string;
347
- /** Token counts for this event */
348
- tokens: TokenUsage;
349
- /** Tokens used to create prompt cache entries */
350
- cacheCreationTokens?: number;
351
- /** Tokens read from prompt cache */
352
- cacheReadTokens?: number;
353
- /** Model identifier (e.g., "claude-sonnet-4-20250514") */
354
- model?: string;
355
- /** Cost in integer microdollars (USD * 1,000,000), calculated at read time */
356
- costMicroUSD?: number;
357
- }
237
+ type CIFailOnSeverity = 'error' | 'warning';
358
238
  /**
359
- * Per-model pricing rates, all in USD per 1 million tokens.
239
+ * Configuration options for the CI command.
360
240
  */
361
- interface ModelPricing {
362
- /** Input token cost per 1M tokens */
363
- inputPer1M: number;
364
- /** Output token cost per 1M tokens */
365
- outputPer1M: number;
366
- /** Cache read cost per 1M tokens (not all models support caching) */
367
- cacheReadPer1M?: number;
368
- /** Cache write/creation cost per 1M tokens */
369
- cacheWritePer1M?: number;
241
+ interface CICheckOptions {
242
+ /** Checks to skip */
243
+ skip?: CICheckName[];
244
+ /** Severity level that causes failure */
245
+ failOn?: CIFailOnSeverity;
246
+ /** Custom config file path */
247
+ configPath?: string;
370
248
  }
371
249
  /**
372
- * Aggregated usage for a single calendar day.
250
+ * Supported CI platforms.
373
251
  */
374
- interface DailyUsage {
375
- /** ISO 8601 date string (YYYY-MM-DD) */
376
- date: string;
377
- /** Number of distinct sessions that had activity on this day */
378
- sessionCount: number;
379
- /** Summed token counts across all sessions */
380
- tokens: TokenUsage;
381
- /** Summed cache creation tokens (omitted if no cache data) */
382
- cacheCreationTokens?: number;
383
- /** Summed cache read tokens (omitted if no cache data) */
384
- cacheReadTokens?: number;
385
- /** Total cost in integer microdollars, null if any session has unknown pricing */
386
- costMicroUSD: number | null;
387
- /** Distinct model identifiers seen on this day */
388
- models: string[];
389
- }
252
+ type CIPlatform = 'github' | 'gitlab' | 'generic';
390
253
  /**
391
- * Aggregated usage for a single session across all its turns.
254
+ * Options for initializing CI configuration.
392
255
  */
393
- interface SessionUsage {
394
- /** Harness session identifier */
395
- sessionId: string;
396
- /** ISO 8601 timestamp of the first event in this session */
397
- firstTimestamp: string;
398
- /** ISO 8601 timestamp of the last event in this session */
399
- lastTimestamp: string;
400
- /** Summed token counts across all turns */
401
- tokens: TokenUsage;
402
- /** Summed cache creation tokens (omitted if no cache data) */
403
- cacheCreationTokens?: number;
404
- /** Summed cache read tokens (omitted if no cache data) */
405
- cacheReadTokens?: number;
406
- /** Model identifier (may be populated from CC data) */
407
- model?: string;
408
- /** Total cost in integer microdollars, null if pricing unavailable */
409
- costMicroUSD: number | null;
410
- /** Data source: 'harness', 'claude-code', or 'merged' */
411
- source: 'harness' | 'claude-code' | 'merged';
256
+ interface CIInitOptions {
257
+ /** Target CI platform */
258
+ platform?: CIPlatform;
259
+ /** Checks to enable */
260
+ checks?: CICheckName[];
412
261
  }
413
262
 
414
263
  /**
415
- * Session-scoped accumulative state types.
416
- *
417
- * Session memory allows skills to append to shared sections (terminology,
418
- * decisions, constraints, risks, openQuestions, evidence) rather than
419
- * overwriting. Each entry is timestamped and tagged with the authoring skill.
420
- *
421
- * @see docs/changes/ai-foundations-integration/proposal.md
422
- */
423
- /**
424
- * Names of accumulative session sections.
425
- * Runtime array used for iteration and validation.
426
- */
427
- declare const SESSION_SECTION_NAMES: readonly ["terminology", "decisions", "constraints", "risks", "openQuestions", "evidence"];
428
- /**
429
- * Union type of valid session section names.
264
+ * Valid statuses for a roadmap feature.
430
265
  */
431
- type SessionSectionName = (typeof SESSION_SECTION_NAMES)[number];
266
+ type FeatureStatus = 'backlog' | 'planned' | 'in-progress' | 'done' | 'blocked';
432
267
  /**
433
- * Lifecycle status of a session entry.
434
- * - `active` current and relevant
435
- * - `resolved` — addressed or answered (e.g., an open question that was resolved)
436
- * - `superseded` — replaced by a newer entry
268
+ * Priority override levels for roadmap features.
269
+ * When present, priority replaces positional ordering as the primary sort key.
437
270
  */
438
- type SessionEntryStatus = 'active' | 'resolved' | 'superseded';
271
+ type Priority = 'P0' | 'P1' | 'P2' | 'P3';
439
272
  /**
440
- * A single entry in a session section.
441
- * Entries are append-only; skills mark them as `resolved` or `superseded`
442
- * rather than deleting.
273
+ * A feature entry in the project roadmap.
443
274
  */
444
- interface SessionEntry {
445
- /** Auto-generated unique identifier */
446
- id: string;
447
- /** ISO 8601 timestamp of when the entry was created */
448
- timestamp: string;
449
- /** Name of the skill that authored this entry */
450
- authorSkill: string;
451
- /** The entry content (free-form text) */
452
- content: string;
453
- /** Lifecycle status of the entry */
454
- status: SessionEntryStatus;
275
+ interface RoadmapFeature {
276
+ /** Feature name (from the H3 heading, without "Feature:" prefix) */
277
+ name: string;
278
+ /** Current status */
279
+ status: FeatureStatus;
280
+ /** Relative path to the spec file, or null if none */
281
+ spec: string | null;
282
+ /** Relative paths to plan files */
283
+ plans: string[];
284
+ /** Names of blocking features (textual references) */
285
+ blockedBy: string[];
286
+ /** One-line summary */
287
+ summary: string;
288
+ /** GitHub username, email, or display name — null if unassigned */
289
+ assignee: string | null;
290
+ /** Optional priority override — null uses positional ordering */
291
+ priority: Priority | null;
292
+ /** External tracker ID (e.g., "github:owner/repo#42") — null if not synced */
293
+ externalId: string | null;
455
294
  }
456
295
  /**
457
- * Container mapping each section name to its array of entries.
458
- * Used as the shape of session-scoped state in `state.json`.
296
+ * A milestone grouping in the roadmap. The special "Backlog" milestone
297
+ * has `isBacklog: true` and appears as `## Backlog` instead of `## Milestone: <name>`.
459
298
  */
460
- type SessionSections = {
461
- [K in SessionSectionName]: SessionEntry[];
462
- };
463
-
299
+ interface RoadmapMilestone {
300
+ /** Milestone name (e.g., "MVP Release") or "Backlog" */
301
+ name: string;
302
+ /** True for the special Backlog section */
303
+ isBacklog: boolean;
304
+ /** Features in this milestone, in document order */
305
+ features: RoadmapFeature[];
306
+ }
464
307
  /**
465
- * @harness-engineering/types
466
- *
467
- * Core types and interfaces for Harness Engineering toolkit
308
+ * A single record in the assignment history log.
309
+ * Reassignment produces two records: 'unassigned' for previous, 'assigned' for new.
468
310
  */
311
+ interface AssignmentRecord {
312
+ /** Feature name */
313
+ feature: string;
314
+ /** Assignee identifier (username, email, or display name) */
315
+ assignee: string;
316
+ /** What happened */
317
+ action: 'assigned' | 'completed' | 'unassigned';
318
+ /** ISO date string (YYYY-MM-DD) */
319
+ date: string;
320
+ }
469
321
  /**
470
- * Result type for consistent error handling across the toolkit.
322
+ * YAML frontmatter of the roadmap file.
471
323
  */
472
- type Result<T, E = Error> = {
473
- ok: true;
474
- value: T;
475
- } | {
476
- ok: false;
477
- error: E;
478
- };
324
+ interface RoadmapFrontmatter {
325
+ /** Project name */
326
+ project: string;
327
+ /** Schema version (currently 1) */
328
+ version: number;
329
+ /** ISO date when roadmap was created */
330
+ created?: string;
331
+ /** ISO date when roadmap was last updated */
332
+ updated?: string;
333
+ /** ISO timestamp of last automated sync */
334
+ lastSynced: string;
335
+ /** ISO timestamp of last manual edit */
336
+ lastManualEdit: string;
337
+ }
479
338
  /**
480
- * Creates a successful Result.
339
+ * Parsed roadmap document.
481
340
  */
482
- declare function Ok<T>(value: T): Result<T, never>;
341
+ interface Roadmap {
342
+ /** Parsed frontmatter */
343
+ frontmatter: RoadmapFrontmatter;
344
+ /** Milestones in document order (including Backlog) */
345
+ milestones: RoadmapMilestone[];
346
+ /** Assignment history records, in document order */
347
+ assignmentHistory: AssignmentRecord[];
348
+ }
349
+
483
350
  /**
484
- * Creates a failed Result.
351
+ * Represents a ticket created in an external tracking service.
485
352
  */
486
- declare function Err<E>(error: E): Result<never, E>;
353
+ interface ExternalTicket {
354
+ /** External identifier, e.g., "github:owner/repo#42" */
355
+ externalId: string;
356
+ /** URL to the ticket in the external service */
357
+ url: string;
358
+ }
487
359
  /**
488
- * Type guard to check if a Result is successful.
360
+ * Current state of a ticket in the external service.
361
+ * Pulled during syncFromExternal.
489
362
  */
490
- declare function isOk<T, E>(result: Result<T, E>): result is {
491
- ok: true;
492
- value: T;
493
- };
363
+ interface ExternalTicketState {
364
+ /** External identifier */
365
+ externalId: string;
366
+ /** Ticket title in the external service */
367
+ title: string;
368
+ /** External status (e.g., "open", "closed") */
369
+ status: string;
370
+ /** External labels (used for status disambiguation on GitHub) */
371
+ labels: string[];
372
+ /** Current assignee in the external service, or null */
373
+ assignee: string | null;
374
+ }
494
375
  /**
495
- * Type guard to check if a Result is failed.
376
+ * Result of a sync operation. Collects successes and errors per-feature.
496
377
  */
497
- declare function isErr<T, E>(result: Result<T, E>): result is {
498
- ok: false;
499
- error: E;
500
- };
378
+ interface SyncResult {
379
+ /** Tickets created during this sync */
380
+ created: ExternalTicket[];
381
+ /** External IDs of tickets that were updated */
382
+ updated: string[];
383
+ /** Assignment changes detected during pull */
384
+ assignmentChanges: Array<{
385
+ feature: string;
386
+ from: string | null;
387
+ to: string | null;
388
+ }>;
389
+ /** Per-feature errors (sync never throws) */
390
+ errors: Array<{
391
+ featureOrId: string;
392
+ error: Error;
393
+ }>;
394
+ }
501
395
  /**
502
- * A single step in a multi-skill workflow.
396
+ * Configuration for external tracker sync.
503
397
  */
504
- interface WorkflowStep {
505
- /** The skill to execute (e.g., "detect-doc-drift") */
506
- skill: string;
507
- /** Name of the artifact this step produces */
508
- produces: string;
509
- /** Name of the artifact this step expects as input */
510
- expects?: string;
511
- /** Whether failure of this step stops the workflow */
512
- gate?: 'pass-required' | 'advisory';
398
+ interface TrackerSyncConfig {
399
+ /** Adapter kind -- narrowed to GitHub-only for now */
400
+ kind: 'github';
401
+ /** Repository in "owner/repo" format (for GitHub) */
402
+ repo?: string;
403
+ /** Labels auto-applied to created tickets for filtering + identification */
404
+ labels?: string[];
405
+ /** Maps roadmap status -> external status string */
406
+ statusMap: Record<FeatureStatus, string>;
407
+ /**
408
+ * Maps external status (+ optional label) -> roadmap status.
409
+ * Compound keys like "open:in-progress" express state + label.
410
+ * Optional — when absent, syncFromExternal preserves current roadmap status.
411
+ */
412
+ reverseStatusMap?: Record<string, FeatureStatus>;
513
413
  }
414
+
514
415
  /**
515
- * Definition of a sequence of steps to achieve a goal.
416
+ * Token usage statistics for an agent turn or session.
516
417
  */
517
- interface Workflow {
518
- /** Descriptive name of the workflow */
519
- name: string;
520
- /** Ordered list of steps */
521
- steps: WorkflowStep[];
418
+ interface TokenUsage {
419
+ /** Number of tokens used in the input (prompt) */
420
+ inputTokens: number;
421
+ /** Number of tokens generated in the output (response) */
422
+ outputTokens: number;
423
+ /** Combined total tokens used */
424
+ totalTokens: number;
522
425
  }
523
426
  /**
524
- * Possible outcomes for a single workflow step.
427
+ * Reference to a blocking issue.
525
428
  */
526
- type StepOutcome = 'pass' | 'fail' | 'skipped';
429
+ interface BlockerRef {
430
+ /** Unique ID of the blocker */
431
+ id: string | null;
432
+ /** Human-readable identifier (e.g., "CORE-123") */
433
+ identifier: string | null;
434
+ /** Current state of the blocker */
435
+ state: string | null;
436
+ }
527
437
  /**
528
- * Detailed result of a workflow step execution.
438
+ * Representation of a work item (issue/feature) in a tracker.
529
439
  */
530
- interface WorkflowStepResult {
531
- /** The step that was executed */
532
- step: WorkflowStep;
533
- /** The outcome of the execution */
534
- outcome: StepOutcome;
535
- /** Path to the produced artifact, if any */
536
- artifact?: string;
537
- /** Error message if outcome is 'fail' */
538
- error?: string;
539
- /** Execution time in milliseconds */
540
- durationMs: number;
440
+ interface Issue {
441
+ /** Unique ID in the tracking system */
442
+ id: string;
443
+ /** Human-readable identifier (e.g., "CORE-123") */
444
+ identifier: string;
445
+ /** Title or headline of the issue */
446
+ title: string;
447
+ /** Detailed description, if available */
448
+ description: string | null;
449
+ /** Numerical priority (lower is typically higher priority) */
450
+ priority: number | null;
451
+ /** Current lifecycle state */
452
+ state: string;
453
+ /** Name of the git branch associated with this issue */
454
+ branchName: string | null;
455
+ /** Direct URL to the issue in the tracker */
456
+ url: string | null;
457
+ /** List of labels or tags */
458
+ labels: string[];
459
+ /** References to issues that block this one */
460
+ blockedBy: BlockerRef[];
461
+ /** ISO timestamp of creation */
462
+ createdAt: string | null;
463
+ /** ISO timestamp of last update */
464
+ updatedAt: string | null;
541
465
  }
542
466
  /**
543
- * Final result of a complete workflow execution.
467
+ * Categories of errors that can occur during agent execution.
544
468
  */
545
- interface WorkflowResult {
546
- /** The workflow that was executed */
547
- workflow: Workflow;
548
- /** Results for each step in the workflow */
549
- stepResults: WorkflowStepResult[];
550
- /** Whether the overall workflow passed (all required gates passed) */
551
- pass: boolean;
552
- /** Total execution time in milliseconds */
553
- totalDurationMs: number;
554
- }
469
+ type AgentErrorCategory = 'agent_not_found' | 'invalid_workspace_cwd' | 'response_timeout' | 'turn_timeout' | 'process_exit' | 'response_error' | 'turn_failed' | 'turn_cancelled' | 'turn_input_required';
555
470
  /**
556
- * Predefined cognitive modes for skills.
471
+ * Error returned by an agent backend.
557
472
  */
558
- declare const STANDARD_COGNITIVE_MODES: readonly ["adversarial-reviewer", "constructive-architect", "meticulous-implementer", "diagnostic-investigator", "advisory-guide", "meticulous-verifier"];
473
+ interface AgentError {
474
+ /** Machine-readable category */
475
+ category: AgentErrorCategory;
476
+ /** Human-readable message */
477
+ message: string;
478
+ /** Optional additional context */
479
+ details?: unknown;
480
+ }
559
481
  /**
560
- * Cognitive mode of a skill, determining its behavior and persona.
482
+ * Parameters for starting a new agent session.
561
483
  */
562
- type CognitiveMode = (typeof STANDARD_COGNITIVE_MODES)[number] | (string & {});
484
+ interface SessionStartParams {
485
+ /** Absolute path to the workspace directory */
486
+ workspacePath: string;
487
+ /** Permission level for the agent (e.g., "readonly", "full") */
488
+ permissionMode: string;
489
+ /** List of tool names the agent is allowed to use */
490
+ allowedTools?: string[];
491
+ /** Custom system instructions for the agent */
492
+ systemPrompt?: string;
493
+ }
563
494
  /**
564
- * Static metadata for a skill.
495
+ * Represents an active session with an agent backend.
565
496
  */
566
- interface SkillMetadata {
567
- /** Unique name of the skill */
568
- name: string;
569
- /** Semantic version string */
570
- version: string;
571
- /** Brief description of what the skill does */
572
- description: string;
573
- /** The cognitive mode this skill operates in */
574
- cognitive_mode?: CognitiveMode;
497
+ interface AgentSession {
498
+ /** Unique ID for the session */
499
+ sessionId: string;
500
+ /** Workspace associated with this session */
501
+ workspacePath: string;
502
+ /** Name of the backend provider */
503
+ backendName: string;
504
+ /** ISO timestamp when the session started */
505
+ startedAt: string;
575
506
  }
576
507
  /**
577
- * Contextual information for a skill execution.
508
+ * Parameters for a single interaction (turn) with an agent.
578
509
  */
579
- interface SkillContext {
580
- /** Name of the executing skill */
581
- skillName: string;
582
- /** Current pipeline phase */
583
- phase: string;
584
- /** Files relevant to the current execution */
585
- files: string[];
586
- /** Optional token budget — uses a plain record to avoid cross-package deps. */
587
- tokenBudget?: Record<string, number>;
588
- /** Additional metadata */
589
- metadata: Record<string, unknown>;
510
+ interface TurnParams {
511
+ /** ID of the active session */
512
+ sessionId: string;
513
+ /** User or system prompt for this turn */
514
+ prompt: string;
515
+ /** Whether this is a continuation of a previous turn */
516
+ isContinuation: boolean;
590
517
  }
591
518
  /**
592
- * Context for a single turn in a multi-turn skill interaction.
519
+ * Event emitted by an agent during a turn.
593
520
  */
594
- interface TurnContext extends SkillContext {
595
- /** Current turn number (1-indexed) */
596
- turnNumber: number;
597
- /** Results from previous turns in the same session */
598
- previousResults: unknown[];
521
+ interface AgentEvent {
522
+ /** Event type (e.g., "thought", "tool_call", "output") */
523
+ type: string;
524
+ /** ISO timestamp */
525
+ timestamp: string;
526
+ /** Optional subtype for finer-grained classification */
527
+ subtype?: string;
528
+ /** Token usage snapshot if available */
529
+ usage?: TokenUsage;
530
+ /** Event payload */
531
+ content?: unknown;
532
+ /** Session ID if not implicit */
533
+ sessionId?: string;
599
534
  }
600
535
  /**
601
- * Error reported by a skill.
536
+ * Result of a completed agent turn.
602
537
  */
603
- type SkillError = {
604
- /** Machine-readable error code */
605
- code: string;
606
- /** Human-readable error message */
607
- message: string;
608
- /** Phase in which the error occurred */
609
- phase: string;
610
- };
538
+ interface TurnResult {
539
+ /** Whether the turn completed successfully */
540
+ success: boolean;
541
+ /** ID of the session */
542
+ sessionId: string;
543
+ /** Cumulative usage for this turn */
544
+ usage: TokenUsage;
545
+ /** Error message if success is false */
546
+ error?: string;
547
+ }
611
548
  /**
612
- * Names of standard CI checks.
549
+ * Interface for agent backend implementations (Claude, Mock, etc.)
613
550
  */
614
- type CICheckName = 'validate' | 'deps' | 'docs' | 'entropy' | 'security' | 'perf' | 'phase-gate' | 'arch' | 'traceability';
551
+ interface AgentBackend {
552
+ /** Unique name of the backend */
553
+ readonly name: string;
554
+ /** Starts a new session */
555
+ startSession(params: SessionStartParams): Promise<Result<AgentSession, AgentError>>;
556
+ /** Runs a turn and streams events */
557
+ runTurn(session: AgentSession, params: TurnParams): AsyncGenerator<AgentEvent, TurnResult, void>;
558
+ /** Stops and cleans up a session */
559
+ stopSession(session: AgentSession): Promise<Result<void, AgentError>>;
560
+ /** Verifies connectivity and health */
561
+ healthCheck(): Promise<Result<void, AgentError>>;
562
+ }
615
563
  /**
616
- * Status of a CI check.
564
+ * Interface for issue tracking systems (Roadmap, Linear, GitHub, etc.)
617
565
  */
618
- type CICheckStatus = 'pass' | 'fail' | 'warn' | 'skip';
566
+ interface IssueTrackerClient {
567
+ /** Fetches issues eligible for agent assignment */
568
+ fetchCandidateIssues(): Promise<Result<Issue[], Error>>;
569
+ /** Fetches issues in specific lifecycle states */
570
+ fetchIssuesByStates(stateNames: string[]): Promise<Result<Issue[], Error>>;
571
+ /** Fetches current state for a set of issue IDs */
572
+ fetchIssueStatesByIds(issueIds: string[]): Promise<Result<Map<string, Issue>, Error>>;
573
+ }
619
574
  /**
620
- * A specific issue found during a CI check.
575
+ * Configuration for an issue tracker adapter.
621
576
  */
622
- interface CICheckIssue {
623
- /** Severity level */
624
- severity: 'error' | 'warning';
625
- /** Descriptive message */
626
- message: string;
627
- /** Path to the affected file */
628
- file?: string;
629
- /** Line number in the affected file */
630
- line?: number;
577
+ interface TrackerConfig {
578
+ /** Adapter kind (e.g., "roadmap", "linear") */
579
+ kind: string;
580
+ /** API endpoint if applicable */
581
+ endpoint?: string;
582
+ /** API key or token */
583
+ apiKey?: string;
584
+ /** Project slug or identifier */
585
+ projectSlug?: string;
586
+ /** Local file path for file-based trackers */
587
+ filePath?: string;
588
+ /** States considered "ready for work" */
589
+ activeStates: string[];
590
+ /** States considered "finished" */
591
+ terminalStates: string[];
631
592
  }
632
593
  /**
633
- * Result of a single CI check execution.
594
+ * Polling interval configuration.
634
595
  */
635
- interface CICheckResult {
636
- /** Name of the check */
637
- name: CICheckName;
638
- /** Final status of the check */
639
- status: CICheckStatus;
640
- /** List of issues discovered */
641
- issues: CICheckIssue[];
642
- /** Execution time in milliseconds */
643
- durationMs: number;
596
+ interface PollingConfig {
597
+ /** Interval in milliseconds */
598
+ intervalMs: number;
644
599
  }
645
600
  /**
646
- * Summary counts for a set of CI checks.
601
+ * Workspace management configuration.
647
602
  */
648
- interface CICheckSummary {
649
- /** Total number of checks run */
650
- total: number;
651
- /** Number of passing checks */
652
- passed: number;
653
- /** Number of failing checks */
654
- failed: number;
655
- /** Number of checks with warnings */
656
- warnings: number;
657
- /** Number of skipped checks */
658
- skipped: number;
603
+ interface WorkspaceConfig {
604
+ /** Root directory where agent workspaces are created */
605
+ root: string;
659
606
  }
660
607
  /**
661
- * Final report for a CI run.
608
+ * Lifecycle hooks configuration.
662
609
  */
663
- interface CICheckReport {
664
- /** Schema version */
665
- version: 1;
666
- /** Name of the project */
667
- project: string;
668
- /** ISO timestamp of the run */
669
- timestamp: string;
670
- /** Detailed results for each check */
671
- checks: CICheckResult[];
672
- /** Aggregated summary */
673
- summary: CICheckSummary;
674
- /** Process exit code suggested for the CI runner */
675
- exitCode: 0 | 1 | 2;
610
+ interface HooksConfig {
611
+ /** Script to run after creating a workspace */
612
+ afterCreate: string | null;
613
+ /** Script to run before starting an agent */
614
+ beforeRun: string | null;
615
+ /** Script to run after an agent completes */
616
+ afterRun: string | null;
617
+ /** Script to run before removing a workspace */
618
+ beforeRemove: string | null;
619
+ /** Maximum time allowed for hook execution */
620
+ timeoutMs: number;
676
621
  }
677
622
  /**
678
- * Severity level that should trigger a CI failure.
623
+ * Configuration for the agent runner.
679
624
  */
680
- type CIFailOnSeverity = 'error' | 'warning';
625
+ interface AgentConfig {
626
+ /** Backend type to use */
627
+ backend: string;
628
+ /** Command to launch the agent if applicable */
629
+ command?: string;
630
+ /** Model name/identifier */
631
+ model?: string;
632
+ /** API key for the agent provider */
633
+ apiKey?: string;
634
+ /** Global limit on concurrent agents */
635
+ maxConcurrentAgents: number;
636
+ /** Maximum turns allowed per session */
637
+ maxTurns: number;
638
+ /** Maximum backoff for retries */
639
+ maxRetryBackoffMs: number;
640
+ /** Concurrency limits partitioned by issue state */
641
+ maxConcurrentAgentsByState: Record<string, number>;
642
+ /** Policy for approving tool calls */
643
+ approvalPolicy?: string;
644
+ /** Policy for execution environment isolation */
645
+ sandboxPolicy?: string;
646
+ /** Timeout for a single turn */
647
+ turnTimeoutMs: number;
648
+ /** Timeout for reading from the agent */
649
+ readTimeoutMs: number;
650
+ /** Timeout for agent inactivity */
651
+ stallTimeoutMs: number;
652
+ }
681
653
  /**
682
- * Configuration options for the CI command.
654
+ * Internal server configuration.
683
655
  */
684
- interface CICheckOptions {
685
- /** Checks to skip */
686
- skip?: CICheckName[];
687
- /** Severity level that causes failure */
688
- failOn?: CIFailOnSeverity;
689
- /** Custom config file path */
690
- configPath?: string;
656
+ interface ServerConfig {
657
+ /** Port to listen on (null to disable) */
658
+ port: number | null;
691
659
  }
692
660
  /**
693
- * Supported CI platforms.
661
+ * Root workflow configuration object.
694
662
  */
695
- type CIPlatform = 'github' | 'gitlab' | 'generic';
663
+ interface WorkflowConfig {
664
+ /** Issue tracker settings */
665
+ tracker: TrackerConfig;
666
+ /** Polling loop settings */
667
+ polling: PollingConfig;
668
+ /** Workspace settings */
669
+ workspace: WorkspaceConfig;
670
+ /** Lifecycle hook settings */
671
+ hooks: HooksConfig;
672
+ /** Agent execution settings */
673
+ agent: AgentConfig;
674
+ /** Server settings */
675
+ server: ServerConfig;
676
+ }
696
677
  /**
697
- * Options for initializing CI configuration.
678
+ * Complete workflow definition including config and prompts.
698
679
  */
699
- interface CIInitOptions {
700
- /** Target CI platform */
701
- platform?: CIPlatform;
702
- /** Checks to enable */
703
- checks?: CICheckName[];
680
+ interface WorkflowDefinition {
681
+ /** Orchestrator configuration */
682
+ config: WorkflowConfig;
683
+ /** Template used to generate agent prompts */
684
+ promptTemplate: string;
704
685
  }
686
+
705
687
  /**
706
- * Result of a skill execution.
688
+ * Extended entry for cost tracking storage and display.
689
+ * Composes TokenUsage — does not extend it.
707
690
  */
708
- type SkillResult = {
709
- /** Whether the skill achieved its goal */
710
- success: boolean;
711
- /** List of artifact paths produced */
712
- artifacts: string[];
713
- /** One-line summary of the outcome */
714
- summary: string;
715
- };
691
+ interface UsageRecord {
692
+ /** Harness session identifier */
693
+ sessionId: string;
694
+ /** ISO 8601 timestamp of the usage event */
695
+ timestamp: string;
696
+ /** Token counts for this event */
697
+ tokens: TokenUsage;
698
+ /** Tokens used to create prompt cache entries */
699
+ cacheCreationTokens?: number;
700
+ /** Tokens read from prompt cache */
701
+ cacheReadTokens?: number;
702
+ /** Model identifier (e.g., "claude-sonnet-4-20250514") */
703
+ model?: string;
704
+ /** Cost in integer microdollars (USD * 1,000,000), calculated at read time */
705
+ costMicroUSD?: number;
706
+ }
716
707
  /**
717
- * Lifecycle hooks for skills.
708
+ * Per-model pricing rates, all in USD per 1 million tokens.
718
709
  */
719
- interface SkillLifecycleHooks {
720
- /** Called before the skill starts execution */
721
- preExecution?: (context: SkillContext) => SkillContext | null;
722
- /** Called before each turn in a multi-turn interaction */
723
- perTurn?: (context: TurnContext) => TurnContext | null;
724
- /** Called after the skill completes execution */
725
- postExecution?: (context: SkillContext, result: SkillResult) => void;
710
+ interface ModelPricing {
711
+ /** Input token cost per 1M tokens */
712
+ inputPer1M: number;
713
+ /** Output token cost per 1M tokens */
714
+ outputPer1M: number;
715
+ /** Cache read cost per 1M tokens (not all models support caching) */
716
+ cacheReadPer1M?: number;
717
+ /** Cache write/creation cost per 1M tokens */
718
+ cacheWritePer1M?: number;
726
719
  }
727
720
  /**
728
- * Valid statuses for a roadmap feature.
721
+ * Aggregated usage for a single calendar day.
729
722
  */
730
- type FeatureStatus = 'backlog' | 'planned' | 'in-progress' | 'done' | 'blocked';
723
+ interface DailyUsage {
724
+ /** ISO 8601 date string (YYYY-MM-DD) */
725
+ date: string;
726
+ /** Number of distinct sessions that had activity on this day */
727
+ sessionCount: number;
728
+ /** Summed token counts across all sessions */
729
+ tokens: TokenUsage;
730
+ /** Summed cache creation tokens (omitted if no cache data) */
731
+ cacheCreationTokens?: number;
732
+ /** Summed cache read tokens (omitted if no cache data) */
733
+ cacheReadTokens?: number;
734
+ /** Total cost in integer microdollars, null if any session has unknown pricing */
735
+ costMicroUSD: number | null;
736
+ /** Distinct model identifiers seen on this day */
737
+ models: string[];
738
+ }
731
739
  /**
732
- * Priority override levels for roadmap features.
733
- * When present, priority replaces positional ordering as the primary sort key.
740
+ * Aggregated usage for a single session across all its turns.
734
741
  */
735
- type Priority = 'P0' | 'P1' | 'P2' | 'P3';
742
+ interface SessionUsage {
743
+ /** Harness session identifier */
744
+ sessionId: string;
745
+ /** ISO 8601 timestamp of the first event in this session */
746
+ firstTimestamp: string;
747
+ /** ISO 8601 timestamp of the last event in this session */
748
+ lastTimestamp: string;
749
+ /** Summed token counts across all turns */
750
+ tokens: TokenUsage;
751
+ /** Summed cache creation tokens (omitted if no cache data) */
752
+ cacheCreationTokens?: number;
753
+ /** Summed cache read tokens (omitted if no cache data) */
754
+ cacheReadTokens?: number;
755
+ /** Model identifier (may be populated from CC data) */
756
+ model?: string;
757
+ /** Total cost in integer microdollars, null if pricing unavailable */
758
+ costMicroUSD: number | null;
759
+ /** Data source: 'harness', 'claude-code', or 'merged' */
760
+ source: 'harness' | 'claude-code' | 'merged';
761
+ }
762
+
736
763
  /**
737
- * A feature entry in the project roadmap.
764
+ * Session-scoped accumulative state types.
765
+ *
766
+ * Session memory allows skills to append to shared sections (terminology,
767
+ * decisions, constraints, risks, openQuestions, evidence) rather than
768
+ * overwriting. Each entry is timestamped and tagged with the authoring skill.
769
+ *
770
+ * @see docs/changes/ai-foundations-integration/proposal.md
738
771
  */
739
- interface RoadmapFeature {
740
- /** Feature name (from the H3 heading, without "Feature:" prefix) */
741
- name: string;
742
- /** Current status */
743
- status: FeatureStatus;
744
- /** Relative path to the spec file, or null if none */
745
- spec: string | null;
746
- /** Relative paths to plan files */
747
- plans: string[];
748
- /** Names of blocking features (textual references) */
749
- blockedBy: string[];
750
- /** One-line summary */
751
- summary: string;
752
- /** GitHub username, email, or display name — null if unassigned */
753
- assignee: string | null;
754
- /** Optional priority override — null uses positional ordering */
755
- priority: Priority | null;
756
- /** External tracker ID (e.g., "github:owner/repo#42") — null if not synced */
757
- externalId: string | null;
758
- }
759
772
  /**
760
- * A milestone grouping in the roadmap. The special "Backlog" milestone
761
- * has `isBacklog: true` and appears as `## Backlog` instead of `## Milestone: <name>`.
773
+ * Names of accumulative session sections.
774
+ * Runtime array used for iteration and validation.
762
775
  */
763
- interface RoadmapMilestone {
764
- /** Milestone name (e.g., "MVP Release") or "Backlog" */
765
- name: string;
766
- /** True for the special Backlog section */
767
- isBacklog: boolean;
768
- /** Features in this milestone, in document order */
769
- features: RoadmapFeature[];
770
- }
776
+ declare const SESSION_SECTION_NAMES: readonly ["terminology", "decisions", "constraints", "risks", "openQuestions", "evidence"];
771
777
  /**
772
- * A single record in the assignment history log.
773
- * Reassignment produces two records: 'unassigned' for previous, 'assigned' for new.
778
+ * Union type of valid session section names.
774
779
  */
775
- interface AssignmentRecord {
776
- /** Feature name */
777
- feature: string;
778
- /** Assignee identifier (username, email, or display name) */
779
- assignee: string;
780
- /** What happened */
781
- action: 'assigned' | 'completed' | 'unassigned';
782
- /** ISO date string (YYYY-MM-DD) */
783
- date: string;
784
- }
780
+ type SessionSectionName = (typeof SESSION_SECTION_NAMES)[number];
785
781
  /**
786
- * YAML frontmatter of the roadmap file.
782
+ * Lifecycle status of a session entry.
783
+ * - `active` — current and relevant
784
+ * - `resolved` — addressed or answered (e.g., an open question that was resolved)
785
+ * - `superseded` — replaced by a newer entry
787
786
  */
788
- interface RoadmapFrontmatter {
789
- /** Project name */
790
- project: string;
791
- /** Schema version (currently 1) */
792
- version: number;
793
- /** ISO date when roadmap was created */
794
- created?: string;
795
- /** ISO date when roadmap was last updated */
796
- updated?: string;
797
- /** ISO timestamp of last automated sync */
798
- lastSynced: string;
799
- /** ISO timestamp of last manual edit */
800
- lastManualEdit: string;
801
- }
787
+ type SessionEntryStatus = 'active' | 'resolved' | 'superseded';
802
788
  /**
803
- * Parsed roadmap document.
789
+ * A single entry in a session section.
790
+ * Entries are append-only; skills mark them as `resolved` or `superseded`
791
+ * rather than deleting.
804
792
  */
805
- interface Roadmap {
806
- /** Parsed frontmatter */
807
- frontmatter: RoadmapFrontmatter;
808
- /** Milestones in document order (including Backlog) */
809
- milestones: RoadmapMilestone[];
810
- /** Assignment history records, in document order */
811
- assignmentHistory: AssignmentRecord[];
793
+ interface SessionEntry {
794
+ /** Auto-generated unique identifier */
795
+ id: string;
796
+ /** ISO 8601 timestamp of when the entry was created */
797
+ timestamp: string;
798
+ /** Name of the skill that authored this entry */
799
+ authorSkill: string;
800
+ /** The entry content (free-form text) */
801
+ content: string;
802
+ /** Lifecycle status of the entry */
803
+ status: SessionEntryStatus;
812
804
  }
805
+ /**
806
+ * Container mapping each section name to its array of entries.
807
+ * Used as the shape of session-scoped state in `state.json`.
808
+ */
809
+ type SessionSections = {
810
+ [K in SessionSectionName]: SessionEntry[];
811
+ };
813
812
 
814
813
  export { type AgentBackend, type AgentConfig, type AgentError, type AgentErrorCategory, type AgentEvent, type AgentSession, type AssignmentRecord, type BlockerRef, type CICheckIssue, type CICheckName, type CICheckOptions, type CICheckReport, type CICheckResult, type CICheckStatus, type CICheckSummary, type CIFailOnSeverity, type CIInitOptions, type CIPlatform, type CognitiveMode, type DailyUsage, Err, type ExternalTicket, type ExternalTicketState, type FeatureStatus, type HooksConfig, type Issue, type IssueTrackerClient, type ModelPricing, Ok, type PollingConfig, type Priority, type Result, type Roadmap, type RoadmapFeature, type RoadmapFrontmatter, type RoadmapMilestone, SESSION_SECTION_NAMES, STANDARD_COGNITIVE_MODES, type ServerConfig, type SessionEntry, type SessionEntryStatus, type SessionSectionName, type SessionSections, type SessionStartParams, type SessionUsage, type SkillContext, type SkillError, type SkillLifecycleHooks, type SkillMetadata, type SkillResult, type StepOutcome, type SyncResult, type TokenUsage, type TrackerConfig, type TrackerSyncConfig, type TurnContext, type TurnParams, type TurnResult, type UsageRecord, type Workflow, type WorkflowConfig, type WorkflowDefinition, type WorkflowResult, type WorkflowStep, type WorkflowStepResult, type WorkspaceConfig, isErr, isOk };