@harness-engineering/types 0.2.0 → 0.3.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/index.d.mts +408 -6
- package/dist/index.d.ts +408 -6
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token usage statistics for an agent turn or session.
|
|
3
|
+
*/
|
|
4
|
+
interface TokenUsage {
|
|
5
|
+
/** Number of tokens used in the input (prompt) */
|
|
6
|
+
inputTokens: number;
|
|
7
|
+
/** Number of tokens generated in the output (response) */
|
|
8
|
+
outputTokens: number;
|
|
9
|
+
/** Combined total tokens used */
|
|
10
|
+
totalTokens: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reference to a blocking issue.
|
|
14
|
+
*/
|
|
15
|
+
interface BlockerRef {
|
|
16
|
+
/** Unique ID of the blocker */
|
|
17
|
+
id: string | null;
|
|
18
|
+
/** Human-readable identifier (e.g., "CORE-123") */
|
|
19
|
+
identifier: string | null;
|
|
20
|
+
/** Current state of the blocker */
|
|
21
|
+
state: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Representation of a work item (issue/feature) in a tracker.
|
|
25
|
+
*/
|
|
26
|
+
interface Issue {
|
|
27
|
+
/** Unique ID in the tracking system */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Human-readable identifier (e.g., "CORE-123") */
|
|
30
|
+
identifier: string;
|
|
31
|
+
/** Title or headline of the issue */
|
|
32
|
+
title: string;
|
|
33
|
+
/** Detailed description, if available */
|
|
34
|
+
description: string | null;
|
|
35
|
+
/** Numerical priority (lower is typically higher priority) */
|
|
36
|
+
priority: number | null;
|
|
37
|
+
/** Current lifecycle state */
|
|
38
|
+
state: string;
|
|
39
|
+
/** Name of the git branch associated with this issue */
|
|
40
|
+
branchName: string | null;
|
|
41
|
+
/** Direct URL to the issue in the tracker */
|
|
42
|
+
url: string | null;
|
|
43
|
+
/** List of labels or tags */
|
|
44
|
+
labels: string[];
|
|
45
|
+
/** References to issues that block this one */
|
|
46
|
+
blockedBy: BlockerRef[];
|
|
47
|
+
/** ISO timestamp of creation */
|
|
48
|
+
createdAt: string | null;
|
|
49
|
+
/** ISO timestamp of last update */
|
|
50
|
+
updatedAt: string | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Categories of errors that can occur during agent execution.
|
|
54
|
+
*/
|
|
55
|
+
type AgentErrorCategory = 'agent_not_found' | 'invalid_workspace_cwd' | 'response_timeout' | 'turn_timeout' | 'process_exit' | 'response_error' | 'turn_failed' | 'turn_cancelled' | 'turn_input_required';
|
|
56
|
+
/**
|
|
57
|
+
* Error returned by an agent backend.
|
|
58
|
+
*/
|
|
59
|
+
interface AgentError {
|
|
60
|
+
/** Machine-readable category */
|
|
61
|
+
category: AgentErrorCategory;
|
|
62
|
+
/** Human-readable message */
|
|
63
|
+
message: string;
|
|
64
|
+
/** Optional additional context */
|
|
65
|
+
details?: unknown;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parameters for starting a new agent session.
|
|
69
|
+
*/
|
|
70
|
+
interface SessionStartParams {
|
|
71
|
+
/** Absolute path to the workspace directory */
|
|
72
|
+
workspacePath: string;
|
|
73
|
+
/** Permission level for the agent (e.g., "readonly", "full") */
|
|
74
|
+
permissionMode: string;
|
|
75
|
+
/** List of tool names the agent is allowed to use */
|
|
76
|
+
allowedTools?: string[];
|
|
77
|
+
/** Custom system instructions for the agent */
|
|
78
|
+
systemPrompt?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents an active session with an agent backend.
|
|
82
|
+
*/
|
|
83
|
+
interface AgentSession {
|
|
84
|
+
/** Unique ID for the session */
|
|
85
|
+
sessionId: string;
|
|
86
|
+
/** Workspace associated with this session */
|
|
87
|
+
workspacePath: string;
|
|
88
|
+
/** Name of the backend provider */
|
|
89
|
+
backendName: string;
|
|
90
|
+
/** ISO timestamp when the session started */
|
|
91
|
+
startedAt: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parameters for a single interaction (turn) with an agent.
|
|
95
|
+
*/
|
|
96
|
+
interface TurnParams {
|
|
97
|
+
/** ID of the active session */
|
|
98
|
+
sessionId: string;
|
|
99
|
+
/** User or system prompt for this turn */
|
|
100
|
+
prompt: string;
|
|
101
|
+
/** Whether this is a continuation of a previous turn */
|
|
102
|
+
isContinuation: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Event emitted by an agent during a turn.
|
|
106
|
+
*/
|
|
107
|
+
interface AgentEvent {
|
|
108
|
+
/** Event type (e.g., "thought", "tool_call", "output") */
|
|
109
|
+
type: string;
|
|
110
|
+
/** ISO timestamp */
|
|
111
|
+
timestamp: string;
|
|
112
|
+
/** Optional subtype for finer-grained classification */
|
|
113
|
+
subtype?: string;
|
|
114
|
+
/** Token usage snapshot if available */
|
|
115
|
+
usage?: TokenUsage;
|
|
116
|
+
/** Event payload */
|
|
117
|
+
content?: unknown;
|
|
118
|
+
/** Session ID if not implicit */
|
|
119
|
+
sessionId?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Result of a completed agent turn.
|
|
123
|
+
*/
|
|
124
|
+
interface TurnResult {
|
|
125
|
+
/** Whether the turn completed successfully */
|
|
126
|
+
success: boolean;
|
|
127
|
+
/** ID of the session */
|
|
128
|
+
sessionId: string;
|
|
129
|
+
/** Cumulative usage for this turn */
|
|
130
|
+
usage: TokenUsage;
|
|
131
|
+
/** Error message if success is false */
|
|
132
|
+
error?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Interface for agent backend implementations (Claude, Mock, etc.)
|
|
136
|
+
*/
|
|
137
|
+
interface AgentBackend {
|
|
138
|
+
/** Unique name of the backend */
|
|
139
|
+
readonly name: string;
|
|
140
|
+
/** Starts a new session */
|
|
141
|
+
startSession(params: SessionStartParams): Promise<Result<AgentSession, AgentError>>;
|
|
142
|
+
/** Runs a turn and streams events */
|
|
143
|
+
runTurn(session: AgentSession, params: TurnParams): AsyncGenerator<AgentEvent, TurnResult, void>;
|
|
144
|
+
/** Stops and cleans up a session */
|
|
145
|
+
stopSession(session: AgentSession): Promise<Result<void, AgentError>>;
|
|
146
|
+
/** Verifies connectivity and health */
|
|
147
|
+
healthCheck(): Promise<Result<void, AgentError>>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Interface for issue tracking systems (Roadmap, Linear, GitHub, etc.)
|
|
151
|
+
*/
|
|
152
|
+
interface IssueTrackerClient {
|
|
153
|
+
/** Fetches issues eligible for agent assignment */
|
|
154
|
+
fetchCandidateIssues(): Promise<Result<Issue[], Error>>;
|
|
155
|
+
/** Fetches issues in specific lifecycle states */
|
|
156
|
+
fetchIssuesByStates(stateNames: string[]): Promise<Result<Issue[], Error>>;
|
|
157
|
+
/** Fetches current state for a set of issue IDs */
|
|
158
|
+
fetchIssueStatesByIds(issueIds: string[]): Promise<Result<Map<string, Issue>, Error>>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for an issue tracker adapter.
|
|
162
|
+
*/
|
|
163
|
+
interface TrackerConfig {
|
|
164
|
+
/** Adapter kind (e.g., "roadmap", "linear") */
|
|
165
|
+
kind: string;
|
|
166
|
+
/** API endpoint if applicable */
|
|
167
|
+
endpoint?: string;
|
|
168
|
+
/** API key or token */
|
|
169
|
+
apiKey?: string;
|
|
170
|
+
/** Project slug or identifier */
|
|
171
|
+
projectSlug?: string;
|
|
172
|
+
/** Local file path for file-based trackers */
|
|
173
|
+
filePath?: string;
|
|
174
|
+
/** States considered "ready for work" */
|
|
175
|
+
activeStates: string[];
|
|
176
|
+
/** States considered "finished" */
|
|
177
|
+
terminalStates: string[];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Polling interval configuration.
|
|
181
|
+
*/
|
|
182
|
+
interface PollingConfig {
|
|
183
|
+
/** Interval in milliseconds */
|
|
184
|
+
intervalMs: number;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Workspace management configuration.
|
|
188
|
+
*/
|
|
189
|
+
interface WorkspaceConfig {
|
|
190
|
+
/** Root directory where agent workspaces are created */
|
|
191
|
+
root: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Lifecycle hooks configuration.
|
|
195
|
+
*/
|
|
196
|
+
interface HooksConfig {
|
|
197
|
+
/** Script to run after creating a workspace */
|
|
198
|
+
afterCreate: string | null;
|
|
199
|
+
/** Script to run before starting an agent */
|
|
200
|
+
beforeRun: string | null;
|
|
201
|
+
/** Script to run after an agent completes */
|
|
202
|
+
afterRun: string | null;
|
|
203
|
+
/** Script to run before removing a workspace */
|
|
204
|
+
beforeRemove: string | null;
|
|
205
|
+
/** Maximum time allowed for hook execution */
|
|
206
|
+
timeoutMs: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Configuration for the agent runner.
|
|
210
|
+
*/
|
|
211
|
+
interface AgentConfig {
|
|
212
|
+
/** Backend type to use */
|
|
213
|
+
backend: string;
|
|
214
|
+
/** Command to launch the agent if applicable */
|
|
215
|
+
command?: string;
|
|
216
|
+
/** Model name/identifier */
|
|
217
|
+
model?: string;
|
|
218
|
+
/** API key for the agent provider */
|
|
219
|
+
apiKey?: string;
|
|
220
|
+
/** Global limit on concurrent agents */
|
|
221
|
+
maxConcurrentAgents: number;
|
|
222
|
+
/** Maximum turns allowed per session */
|
|
223
|
+
maxTurns: number;
|
|
224
|
+
/** Maximum backoff for retries */
|
|
225
|
+
maxRetryBackoffMs: number;
|
|
226
|
+
/** Concurrency limits partitioned by issue state */
|
|
227
|
+
maxConcurrentAgentsByState: Record<string, number>;
|
|
228
|
+
/** Policy for approving tool calls */
|
|
229
|
+
approvalPolicy?: string;
|
|
230
|
+
/** Policy for execution environment isolation */
|
|
231
|
+
sandboxPolicy?: string;
|
|
232
|
+
/** Timeout for a single turn */
|
|
233
|
+
turnTimeoutMs: number;
|
|
234
|
+
/** Timeout for reading from the agent */
|
|
235
|
+
readTimeoutMs: number;
|
|
236
|
+
/** Timeout for agent inactivity */
|
|
237
|
+
stallTimeoutMs: number;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Internal server configuration.
|
|
241
|
+
*/
|
|
242
|
+
interface ServerConfig {
|
|
243
|
+
/** Port to listen on (null to disable) */
|
|
244
|
+
port: number | null;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Root workflow configuration object.
|
|
248
|
+
*/
|
|
249
|
+
interface WorkflowConfig {
|
|
250
|
+
/** Issue tracker settings */
|
|
251
|
+
tracker: TrackerConfig;
|
|
252
|
+
/** Polling loop settings */
|
|
253
|
+
polling: PollingConfig;
|
|
254
|
+
/** Workspace settings */
|
|
255
|
+
workspace: WorkspaceConfig;
|
|
256
|
+
/** Lifecycle hook settings */
|
|
257
|
+
hooks: HooksConfig;
|
|
258
|
+
/** Agent execution settings */
|
|
259
|
+
agent: AgentConfig;
|
|
260
|
+
/** Server settings */
|
|
261
|
+
server: ServerConfig;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Complete workflow definition including config and prompts.
|
|
265
|
+
*/
|
|
266
|
+
interface WorkflowDefinition {
|
|
267
|
+
/** Orchestrator configuration */
|
|
268
|
+
config: WorkflowConfig;
|
|
269
|
+
/** Template used to generate agent prompts */
|
|
270
|
+
promptTemplate: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
1
273
|
/**
|
|
2
274
|
* @harness-engineering/types
|
|
3
275
|
*
|
|
4
276
|
* Core types and interfaces for Harness Engineering toolkit
|
|
5
277
|
*/
|
|
278
|
+
/**
|
|
279
|
+
* Result type for consistent error handling across the toolkit.
|
|
280
|
+
*/
|
|
6
281
|
type Result<T, E = Error> = {
|
|
7
282
|
ok: true;
|
|
8
283
|
value: T;
|
|
@@ -11,124 +286,251 @@ type Result<T, E = Error> = {
|
|
|
11
286
|
error: E;
|
|
12
287
|
};
|
|
13
288
|
/**
|
|
14
|
-
* Creates a successful Result
|
|
289
|
+
* Creates a successful Result.
|
|
15
290
|
*/
|
|
16
291
|
declare function Ok<T>(value: T): Result<T, never>;
|
|
17
292
|
/**
|
|
18
|
-
* Creates a failed Result
|
|
293
|
+
* Creates a failed Result.
|
|
19
294
|
*/
|
|
20
295
|
declare function Err<E>(error: E): Result<never, E>;
|
|
21
296
|
/**
|
|
22
|
-
* Type guard to check if a Result is successful
|
|
297
|
+
* Type guard to check if a Result is successful.
|
|
23
298
|
*/
|
|
24
299
|
declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
25
300
|
ok: true;
|
|
26
301
|
value: T;
|
|
27
302
|
};
|
|
28
303
|
/**
|
|
29
|
-
* Type guard to check if a Result is failed
|
|
304
|
+
* Type guard to check if a Result is failed.
|
|
30
305
|
*/
|
|
31
306
|
declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
32
307
|
ok: false;
|
|
33
308
|
error: E;
|
|
34
309
|
};
|
|
310
|
+
/**
|
|
311
|
+
* A single step in a multi-skill workflow.
|
|
312
|
+
*/
|
|
35
313
|
interface WorkflowStep {
|
|
314
|
+
/** The skill to execute (e.g., "detect-doc-drift") */
|
|
36
315
|
skill: string;
|
|
316
|
+
/** Name of the artifact this step produces */
|
|
37
317
|
produces: string;
|
|
318
|
+
/** Name of the artifact this step expects as input */
|
|
38
319
|
expects?: string;
|
|
320
|
+
/** Whether failure of this step stops the workflow */
|
|
39
321
|
gate?: 'pass-required' | 'advisory';
|
|
40
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Definition of a sequence of steps to achieve a goal.
|
|
325
|
+
*/
|
|
41
326
|
interface Workflow {
|
|
327
|
+
/** Descriptive name of the workflow */
|
|
42
328
|
name: string;
|
|
329
|
+
/** Ordered list of steps */
|
|
43
330
|
steps: WorkflowStep[];
|
|
44
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Possible outcomes for a single workflow step.
|
|
334
|
+
*/
|
|
45
335
|
type StepOutcome = 'pass' | 'fail' | 'skipped';
|
|
336
|
+
/**
|
|
337
|
+
* Detailed result of a workflow step execution.
|
|
338
|
+
*/
|
|
46
339
|
interface WorkflowStepResult {
|
|
340
|
+
/** The step that was executed */
|
|
47
341
|
step: WorkflowStep;
|
|
342
|
+
/** The outcome of the execution */
|
|
48
343
|
outcome: StepOutcome;
|
|
344
|
+
/** Path to the produced artifact, if any */
|
|
49
345
|
artifact?: string;
|
|
346
|
+
/** Error message if outcome is 'fail' */
|
|
50
347
|
error?: string;
|
|
348
|
+
/** Execution time in milliseconds */
|
|
51
349
|
durationMs: number;
|
|
52
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Final result of a complete workflow execution.
|
|
353
|
+
*/
|
|
53
354
|
interface WorkflowResult {
|
|
355
|
+
/** The workflow that was executed */
|
|
54
356
|
workflow: Workflow;
|
|
357
|
+
/** Results for each step in the workflow */
|
|
55
358
|
stepResults: WorkflowStepResult[];
|
|
359
|
+
/** Whether the overall workflow passed (all required gates passed) */
|
|
56
360
|
pass: boolean;
|
|
361
|
+
/** Total execution time in milliseconds */
|
|
57
362
|
totalDurationMs: number;
|
|
58
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Predefined cognitive modes for skills.
|
|
366
|
+
*/
|
|
59
367
|
declare const STANDARD_COGNITIVE_MODES: readonly ["adversarial-reviewer", "constructive-architect", "meticulous-implementer", "diagnostic-investigator", "advisory-guide", "meticulous-verifier"];
|
|
368
|
+
/**
|
|
369
|
+
* Cognitive mode of a skill, determining its behavior and persona.
|
|
370
|
+
*/
|
|
60
371
|
type CognitiveMode = (typeof STANDARD_COGNITIVE_MODES)[number] | (string & {});
|
|
372
|
+
/**
|
|
373
|
+
* Static metadata for a skill.
|
|
374
|
+
*/
|
|
61
375
|
interface SkillMetadata {
|
|
376
|
+
/** Unique name of the skill */
|
|
62
377
|
name: string;
|
|
378
|
+
/** Semantic version string */
|
|
63
379
|
version: string;
|
|
380
|
+
/** Brief description of what the skill does */
|
|
64
381
|
description: string;
|
|
382
|
+
/** The cognitive mode this skill operates in */
|
|
65
383
|
cognitive_mode?: CognitiveMode;
|
|
66
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Contextual information for a skill execution.
|
|
387
|
+
*/
|
|
67
388
|
interface SkillContext {
|
|
389
|
+
/** Name of the executing skill */
|
|
68
390
|
skillName: string;
|
|
391
|
+
/** Current pipeline phase */
|
|
69
392
|
phase: string;
|
|
393
|
+
/** Files relevant to the current execution */
|
|
70
394
|
files: string[];
|
|
71
395
|
/** Optional token budget — uses a plain record to avoid cross-package deps. */
|
|
72
396
|
tokenBudget?: Record<string, number>;
|
|
397
|
+
/** Additional metadata */
|
|
73
398
|
metadata: Record<string, unknown>;
|
|
74
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* Context for a single turn in a multi-turn skill interaction.
|
|
402
|
+
*/
|
|
75
403
|
interface TurnContext extends SkillContext {
|
|
404
|
+
/** Current turn number (1-indexed) */
|
|
76
405
|
turnNumber: number;
|
|
406
|
+
/** Results from previous turns in the same session */
|
|
77
407
|
previousResults: unknown[];
|
|
78
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Error reported by a skill.
|
|
411
|
+
*/
|
|
79
412
|
type SkillError = {
|
|
413
|
+
/** Machine-readable error code */
|
|
80
414
|
code: string;
|
|
415
|
+
/** Human-readable error message */
|
|
81
416
|
message: string;
|
|
417
|
+
/** Phase in which the error occurred */
|
|
82
418
|
phase: string;
|
|
83
419
|
};
|
|
84
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Names of standard CI checks.
|
|
422
|
+
*/
|
|
423
|
+
type CICheckName = 'validate' | 'deps' | 'docs' | 'entropy' | 'security' | 'perf' | 'phase-gate' | 'arch';
|
|
424
|
+
/**
|
|
425
|
+
* Status of a CI check.
|
|
426
|
+
*/
|
|
85
427
|
type CICheckStatus = 'pass' | 'fail' | 'warn' | 'skip';
|
|
428
|
+
/**
|
|
429
|
+
* A specific issue found during a CI check.
|
|
430
|
+
*/
|
|
86
431
|
interface CICheckIssue {
|
|
432
|
+
/** Severity level */
|
|
87
433
|
severity: 'error' | 'warning';
|
|
434
|
+
/** Descriptive message */
|
|
88
435
|
message: string;
|
|
436
|
+
/** Path to the affected file */
|
|
89
437
|
file?: string;
|
|
438
|
+
/** Line number in the affected file */
|
|
90
439
|
line?: number;
|
|
91
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Result of a single CI check execution.
|
|
443
|
+
*/
|
|
92
444
|
interface CICheckResult {
|
|
445
|
+
/** Name of the check */
|
|
93
446
|
name: CICheckName;
|
|
447
|
+
/** Final status of the check */
|
|
94
448
|
status: CICheckStatus;
|
|
449
|
+
/** List of issues discovered */
|
|
95
450
|
issues: CICheckIssue[];
|
|
451
|
+
/** Execution time in milliseconds */
|
|
96
452
|
durationMs: number;
|
|
97
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Summary counts for a set of CI checks.
|
|
456
|
+
*/
|
|
98
457
|
interface CICheckSummary {
|
|
458
|
+
/** Total number of checks run */
|
|
99
459
|
total: number;
|
|
460
|
+
/** Number of passing checks */
|
|
100
461
|
passed: number;
|
|
462
|
+
/** Number of failing checks */
|
|
101
463
|
failed: number;
|
|
464
|
+
/** Number of checks with warnings */
|
|
102
465
|
warnings: number;
|
|
466
|
+
/** Number of skipped checks */
|
|
103
467
|
skipped: number;
|
|
104
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Final report for a CI run.
|
|
471
|
+
*/
|
|
105
472
|
interface CICheckReport {
|
|
473
|
+
/** Schema version */
|
|
106
474
|
version: 1;
|
|
475
|
+
/** Name of the project */
|
|
107
476
|
project: string;
|
|
477
|
+
/** ISO timestamp of the run */
|
|
108
478
|
timestamp: string;
|
|
479
|
+
/** Detailed results for each check */
|
|
109
480
|
checks: CICheckResult[];
|
|
481
|
+
/** Aggregated summary */
|
|
110
482
|
summary: CICheckSummary;
|
|
483
|
+
/** Process exit code suggested for the CI runner */
|
|
111
484
|
exitCode: 0 | 1 | 2;
|
|
112
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Severity level that should trigger a CI failure.
|
|
488
|
+
*/
|
|
113
489
|
type CIFailOnSeverity = 'error' | 'warning';
|
|
490
|
+
/**
|
|
491
|
+
* Configuration options for the CI command.
|
|
492
|
+
*/
|
|
114
493
|
interface CICheckOptions {
|
|
494
|
+
/** Checks to skip */
|
|
115
495
|
skip?: CICheckName[];
|
|
496
|
+
/** Severity level that causes failure */
|
|
116
497
|
failOn?: CIFailOnSeverity;
|
|
498
|
+
/** Custom config file path */
|
|
117
499
|
configPath?: string;
|
|
118
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Supported CI platforms.
|
|
503
|
+
*/
|
|
119
504
|
type CIPlatform = 'github' | 'gitlab' | 'generic';
|
|
505
|
+
/**
|
|
506
|
+
* Options for initializing CI configuration.
|
|
507
|
+
*/
|
|
120
508
|
interface CIInitOptions {
|
|
509
|
+
/** Target CI platform */
|
|
121
510
|
platform?: CIPlatform;
|
|
511
|
+
/** Checks to enable */
|
|
122
512
|
checks?: CICheckName[];
|
|
123
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Result of a skill execution.
|
|
516
|
+
*/
|
|
124
517
|
type SkillResult = {
|
|
518
|
+
/** Whether the skill achieved its goal */
|
|
125
519
|
success: boolean;
|
|
520
|
+
/** List of artifact paths produced */
|
|
126
521
|
artifacts: string[];
|
|
522
|
+
/** One-line summary of the outcome */
|
|
127
523
|
summary: string;
|
|
128
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* Lifecycle hooks for skills.
|
|
527
|
+
*/
|
|
129
528
|
interface SkillLifecycleHooks {
|
|
529
|
+
/** Called before the skill starts execution */
|
|
130
530
|
preExecution?: (context: SkillContext) => SkillContext | null;
|
|
531
|
+
/** Called before each turn in a multi-turn interaction */
|
|
131
532
|
perTurn?: (context: TurnContext) => TurnContext | null;
|
|
533
|
+
/** Called after the skill completes execution */
|
|
132
534
|
postExecution?: (context: SkillContext, result: SkillResult) => void;
|
|
133
535
|
}
|
|
134
536
|
/**
|
|
@@ -187,4 +589,4 @@ interface Roadmap {
|
|
|
187
589
|
milestones: RoadmapMilestone[];
|
|
188
590
|
}
|
|
189
591
|
|
|
190
|
-
export { type CICheckIssue, type CICheckName, type CICheckOptions, type CICheckReport, type CICheckResult, type CICheckStatus, type CICheckSummary, type CIFailOnSeverity, type CIInitOptions, type CIPlatform, type CognitiveMode, Err, type FeatureStatus, Ok, type Result, type Roadmap, type RoadmapFeature, type RoadmapFrontmatter, type RoadmapMilestone, STANDARD_COGNITIVE_MODES, type SkillContext, type SkillError, type SkillLifecycleHooks, type SkillMetadata, type SkillResult, type StepOutcome, type TurnContext, type Workflow, type WorkflowResult, type WorkflowStep, type WorkflowStepResult, isErr, isOk };
|
|
592
|
+
export { type AgentBackend, type AgentConfig, type AgentError, type AgentErrorCategory, type AgentEvent, type AgentSession, type BlockerRef, type CICheckIssue, type CICheckName, type CICheckOptions, type CICheckReport, type CICheckResult, type CICheckStatus, type CICheckSummary, type CIFailOnSeverity, type CIInitOptions, type CIPlatform, type CognitiveMode, Err, type FeatureStatus, type HooksConfig, type Issue, type IssueTrackerClient, Ok, type PollingConfig, type Result, type Roadmap, type RoadmapFeature, type RoadmapFrontmatter, type RoadmapMilestone, STANDARD_COGNITIVE_MODES, type ServerConfig, type SessionStartParams, type SkillContext, type SkillError, type SkillLifecycleHooks, type SkillMetadata, type SkillResult, type StepOutcome, type TokenUsage, type TrackerConfig, type TurnContext, type TurnParams, type TurnResult, type Workflow, type WorkflowConfig, type WorkflowDefinition, type WorkflowResult, type WorkflowStep, type WorkflowStepResult, type WorkspaceConfig, isErr, isOk };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token usage statistics for an agent turn or session.
|
|
3
|
+
*/
|
|
4
|
+
interface TokenUsage {
|
|
5
|
+
/** Number of tokens used in the input (prompt) */
|
|
6
|
+
inputTokens: number;
|
|
7
|
+
/** Number of tokens generated in the output (response) */
|
|
8
|
+
outputTokens: number;
|
|
9
|
+
/** Combined total tokens used */
|
|
10
|
+
totalTokens: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reference to a blocking issue.
|
|
14
|
+
*/
|
|
15
|
+
interface BlockerRef {
|
|
16
|
+
/** Unique ID of the blocker */
|
|
17
|
+
id: string | null;
|
|
18
|
+
/** Human-readable identifier (e.g., "CORE-123") */
|
|
19
|
+
identifier: string | null;
|
|
20
|
+
/** Current state of the blocker */
|
|
21
|
+
state: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Representation of a work item (issue/feature) in a tracker.
|
|
25
|
+
*/
|
|
26
|
+
interface Issue {
|
|
27
|
+
/** Unique ID in the tracking system */
|
|
28
|
+
id: string;
|
|
29
|
+
/** Human-readable identifier (e.g., "CORE-123") */
|
|
30
|
+
identifier: string;
|
|
31
|
+
/** Title or headline of the issue */
|
|
32
|
+
title: string;
|
|
33
|
+
/** Detailed description, if available */
|
|
34
|
+
description: string | null;
|
|
35
|
+
/** Numerical priority (lower is typically higher priority) */
|
|
36
|
+
priority: number | null;
|
|
37
|
+
/** Current lifecycle state */
|
|
38
|
+
state: string;
|
|
39
|
+
/** Name of the git branch associated with this issue */
|
|
40
|
+
branchName: string | null;
|
|
41
|
+
/** Direct URL to the issue in the tracker */
|
|
42
|
+
url: string | null;
|
|
43
|
+
/** List of labels or tags */
|
|
44
|
+
labels: string[];
|
|
45
|
+
/** References to issues that block this one */
|
|
46
|
+
blockedBy: BlockerRef[];
|
|
47
|
+
/** ISO timestamp of creation */
|
|
48
|
+
createdAt: string | null;
|
|
49
|
+
/** ISO timestamp of last update */
|
|
50
|
+
updatedAt: string | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Categories of errors that can occur during agent execution.
|
|
54
|
+
*/
|
|
55
|
+
type AgentErrorCategory = 'agent_not_found' | 'invalid_workspace_cwd' | 'response_timeout' | 'turn_timeout' | 'process_exit' | 'response_error' | 'turn_failed' | 'turn_cancelled' | 'turn_input_required';
|
|
56
|
+
/**
|
|
57
|
+
* Error returned by an agent backend.
|
|
58
|
+
*/
|
|
59
|
+
interface AgentError {
|
|
60
|
+
/** Machine-readable category */
|
|
61
|
+
category: AgentErrorCategory;
|
|
62
|
+
/** Human-readable message */
|
|
63
|
+
message: string;
|
|
64
|
+
/** Optional additional context */
|
|
65
|
+
details?: unknown;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parameters for starting a new agent session.
|
|
69
|
+
*/
|
|
70
|
+
interface SessionStartParams {
|
|
71
|
+
/** Absolute path to the workspace directory */
|
|
72
|
+
workspacePath: string;
|
|
73
|
+
/** Permission level for the agent (e.g., "readonly", "full") */
|
|
74
|
+
permissionMode: string;
|
|
75
|
+
/** List of tool names the agent is allowed to use */
|
|
76
|
+
allowedTools?: string[];
|
|
77
|
+
/** Custom system instructions for the agent */
|
|
78
|
+
systemPrompt?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents an active session with an agent backend.
|
|
82
|
+
*/
|
|
83
|
+
interface AgentSession {
|
|
84
|
+
/** Unique ID for the session */
|
|
85
|
+
sessionId: string;
|
|
86
|
+
/** Workspace associated with this session */
|
|
87
|
+
workspacePath: string;
|
|
88
|
+
/** Name of the backend provider */
|
|
89
|
+
backendName: string;
|
|
90
|
+
/** ISO timestamp when the session started */
|
|
91
|
+
startedAt: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Parameters for a single interaction (turn) with an agent.
|
|
95
|
+
*/
|
|
96
|
+
interface TurnParams {
|
|
97
|
+
/** ID of the active session */
|
|
98
|
+
sessionId: string;
|
|
99
|
+
/** User or system prompt for this turn */
|
|
100
|
+
prompt: string;
|
|
101
|
+
/** Whether this is a continuation of a previous turn */
|
|
102
|
+
isContinuation: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Event emitted by an agent during a turn.
|
|
106
|
+
*/
|
|
107
|
+
interface AgentEvent {
|
|
108
|
+
/** Event type (e.g., "thought", "tool_call", "output") */
|
|
109
|
+
type: string;
|
|
110
|
+
/** ISO timestamp */
|
|
111
|
+
timestamp: string;
|
|
112
|
+
/** Optional subtype for finer-grained classification */
|
|
113
|
+
subtype?: string;
|
|
114
|
+
/** Token usage snapshot if available */
|
|
115
|
+
usage?: TokenUsage;
|
|
116
|
+
/** Event payload */
|
|
117
|
+
content?: unknown;
|
|
118
|
+
/** Session ID if not implicit */
|
|
119
|
+
sessionId?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Result of a completed agent turn.
|
|
123
|
+
*/
|
|
124
|
+
interface TurnResult {
|
|
125
|
+
/** Whether the turn completed successfully */
|
|
126
|
+
success: boolean;
|
|
127
|
+
/** ID of the session */
|
|
128
|
+
sessionId: string;
|
|
129
|
+
/** Cumulative usage for this turn */
|
|
130
|
+
usage: TokenUsage;
|
|
131
|
+
/** Error message if success is false */
|
|
132
|
+
error?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Interface for agent backend implementations (Claude, Mock, etc.)
|
|
136
|
+
*/
|
|
137
|
+
interface AgentBackend {
|
|
138
|
+
/** Unique name of the backend */
|
|
139
|
+
readonly name: string;
|
|
140
|
+
/** Starts a new session */
|
|
141
|
+
startSession(params: SessionStartParams): Promise<Result<AgentSession, AgentError>>;
|
|
142
|
+
/** Runs a turn and streams events */
|
|
143
|
+
runTurn(session: AgentSession, params: TurnParams): AsyncGenerator<AgentEvent, TurnResult, void>;
|
|
144
|
+
/** Stops and cleans up a session */
|
|
145
|
+
stopSession(session: AgentSession): Promise<Result<void, AgentError>>;
|
|
146
|
+
/** Verifies connectivity and health */
|
|
147
|
+
healthCheck(): Promise<Result<void, AgentError>>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Interface for issue tracking systems (Roadmap, Linear, GitHub, etc.)
|
|
151
|
+
*/
|
|
152
|
+
interface IssueTrackerClient {
|
|
153
|
+
/** Fetches issues eligible for agent assignment */
|
|
154
|
+
fetchCandidateIssues(): Promise<Result<Issue[], Error>>;
|
|
155
|
+
/** Fetches issues in specific lifecycle states */
|
|
156
|
+
fetchIssuesByStates(stateNames: string[]): Promise<Result<Issue[], Error>>;
|
|
157
|
+
/** Fetches current state for a set of issue IDs */
|
|
158
|
+
fetchIssueStatesByIds(issueIds: string[]): Promise<Result<Map<string, Issue>, Error>>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for an issue tracker adapter.
|
|
162
|
+
*/
|
|
163
|
+
interface TrackerConfig {
|
|
164
|
+
/** Adapter kind (e.g., "roadmap", "linear") */
|
|
165
|
+
kind: string;
|
|
166
|
+
/** API endpoint if applicable */
|
|
167
|
+
endpoint?: string;
|
|
168
|
+
/** API key or token */
|
|
169
|
+
apiKey?: string;
|
|
170
|
+
/** Project slug or identifier */
|
|
171
|
+
projectSlug?: string;
|
|
172
|
+
/** Local file path for file-based trackers */
|
|
173
|
+
filePath?: string;
|
|
174
|
+
/** States considered "ready for work" */
|
|
175
|
+
activeStates: string[];
|
|
176
|
+
/** States considered "finished" */
|
|
177
|
+
terminalStates: string[];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Polling interval configuration.
|
|
181
|
+
*/
|
|
182
|
+
interface PollingConfig {
|
|
183
|
+
/** Interval in milliseconds */
|
|
184
|
+
intervalMs: number;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Workspace management configuration.
|
|
188
|
+
*/
|
|
189
|
+
interface WorkspaceConfig {
|
|
190
|
+
/** Root directory where agent workspaces are created */
|
|
191
|
+
root: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Lifecycle hooks configuration.
|
|
195
|
+
*/
|
|
196
|
+
interface HooksConfig {
|
|
197
|
+
/** Script to run after creating a workspace */
|
|
198
|
+
afterCreate: string | null;
|
|
199
|
+
/** Script to run before starting an agent */
|
|
200
|
+
beforeRun: string | null;
|
|
201
|
+
/** Script to run after an agent completes */
|
|
202
|
+
afterRun: string | null;
|
|
203
|
+
/** Script to run before removing a workspace */
|
|
204
|
+
beforeRemove: string | null;
|
|
205
|
+
/** Maximum time allowed for hook execution */
|
|
206
|
+
timeoutMs: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Configuration for the agent runner.
|
|
210
|
+
*/
|
|
211
|
+
interface AgentConfig {
|
|
212
|
+
/** Backend type to use */
|
|
213
|
+
backend: string;
|
|
214
|
+
/** Command to launch the agent if applicable */
|
|
215
|
+
command?: string;
|
|
216
|
+
/** Model name/identifier */
|
|
217
|
+
model?: string;
|
|
218
|
+
/** API key for the agent provider */
|
|
219
|
+
apiKey?: string;
|
|
220
|
+
/** Global limit on concurrent agents */
|
|
221
|
+
maxConcurrentAgents: number;
|
|
222
|
+
/** Maximum turns allowed per session */
|
|
223
|
+
maxTurns: number;
|
|
224
|
+
/** Maximum backoff for retries */
|
|
225
|
+
maxRetryBackoffMs: number;
|
|
226
|
+
/** Concurrency limits partitioned by issue state */
|
|
227
|
+
maxConcurrentAgentsByState: Record<string, number>;
|
|
228
|
+
/** Policy for approving tool calls */
|
|
229
|
+
approvalPolicy?: string;
|
|
230
|
+
/** Policy for execution environment isolation */
|
|
231
|
+
sandboxPolicy?: string;
|
|
232
|
+
/** Timeout for a single turn */
|
|
233
|
+
turnTimeoutMs: number;
|
|
234
|
+
/** Timeout for reading from the agent */
|
|
235
|
+
readTimeoutMs: number;
|
|
236
|
+
/** Timeout for agent inactivity */
|
|
237
|
+
stallTimeoutMs: number;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Internal server configuration.
|
|
241
|
+
*/
|
|
242
|
+
interface ServerConfig {
|
|
243
|
+
/** Port to listen on (null to disable) */
|
|
244
|
+
port: number | null;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Root workflow configuration object.
|
|
248
|
+
*/
|
|
249
|
+
interface WorkflowConfig {
|
|
250
|
+
/** Issue tracker settings */
|
|
251
|
+
tracker: TrackerConfig;
|
|
252
|
+
/** Polling loop settings */
|
|
253
|
+
polling: PollingConfig;
|
|
254
|
+
/** Workspace settings */
|
|
255
|
+
workspace: WorkspaceConfig;
|
|
256
|
+
/** Lifecycle hook settings */
|
|
257
|
+
hooks: HooksConfig;
|
|
258
|
+
/** Agent execution settings */
|
|
259
|
+
agent: AgentConfig;
|
|
260
|
+
/** Server settings */
|
|
261
|
+
server: ServerConfig;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Complete workflow definition including config and prompts.
|
|
265
|
+
*/
|
|
266
|
+
interface WorkflowDefinition {
|
|
267
|
+
/** Orchestrator configuration */
|
|
268
|
+
config: WorkflowConfig;
|
|
269
|
+
/** Template used to generate agent prompts */
|
|
270
|
+
promptTemplate: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
1
273
|
/**
|
|
2
274
|
* @harness-engineering/types
|
|
3
275
|
*
|
|
4
276
|
* Core types and interfaces for Harness Engineering toolkit
|
|
5
277
|
*/
|
|
278
|
+
/**
|
|
279
|
+
* Result type for consistent error handling across the toolkit.
|
|
280
|
+
*/
|
|
6
281
|
type Result<T, E = Error> = {
|
|
7
282
|
ok: true;
|
|
8
283
|
value: T;
|
|
@@ -11,124 +286,251 @@ type Result<T, E = Error> = {
|
|
|
11
286
|
error: E;
|
|
12
287
|
};
|
|
13
288
|
/**
|
|
14
|
-
* Creates a successful Result
|
|
289
|
+
* Creates a successful Result.
|
|
15
290
|
*/
|
|
16
291
|
declare function Ok<T>(value: T): Result<T, never>;
|
|
17
292
|
/**
|
|
18
|
-
* Creates a failed Result
|
|
293
|
+
* Creates a failed Result.
|
|
19
294
|
*/
|
|
20
295
|
declare function Err<E>(error: E): Result<never, E>;
|
|
21
296
|
/**
|
|
22
|
-
* Type guard to check if a Result is successful
|
|
297
|
+
* Type guard to check if a Result is successful.
|
|
23
298
|
*/
|
|
24
299
|
declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
25
300
|
ok: true;
|
|
26
301
|
value: T;
|
|
27
302
|
};
|
|
28
303
|
/**
|
|
29
|
-
* Type guard to check if a Result is failed
|
|
304
|
+
* Type guard to check if a Result is failed.
|
|
30
305
|
*/
|
|
31
306
|
declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
32
307
|
ok: false;
|
|
33
308
|
error: E;
|
|
34
309
|
};
|
|
310
|
+
/**
|
|
311
|
+
* A single step in a multi-skill workflow.
|
|
312
|
+
*/
|
|
35
313
|
interface WorkflowStep {
|
|
314
|
+
/** The skill to execute (e.g., "detect-doc-drift") */
|
|
36
315
|
skill: string;
|
|
316
|
+
/** Name of the artifact this step produces */
|
|
37
317
|
produces: string;
|
|
318
|
+
/** Name of the artifact this step expects as input */
|
|
38
319
|
expects?: string;
|
|
320
|
+
/** Whether failure of this step stops the workflow */
|
|
39
321
|
gate?: 'pass-required' | 'advisory';
|
|
40
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Definition of a sequence of steps to achieve a goal.
|
|
325
|
+
*/
|
|
41
326
|
interface Workflow {
|
|
327
|
+
/** Descriptive name of the workflow */
|
|
42
328
|
name: string;
|
|
329
|
+
/** Ordered list of steps */
|
|
43
330
|
steps: WorkflowStep[];
|
|
44
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Possible outcomes for a single workflow step.
|
|
334
|
+
*/
|
|
45
335
|
type StepOutcome = 'pass' | 'fail' | 'skipped';
|
|
336
|
+
/**
|
|
337
|
+
* Detailed result of a workflow step execution.
|
|
338
|
+
*/
|
|
46
339
|
interface WorkflowStepResult {
|
|
340
|
+
/** The step that was executed */
|
|
47
341
|
step: WorkflowStep;
|
|
342
|
+
/** The outcome of the execution */
|
|
48
343
|
outcome: StepOutcome;
|
|
344
|
+
/** Path to the produced artifact, if any */
|
|
49
345
|
artifact?: string;
|
|
346
|
+
/** Error message if outcome is 'fail' */
|
|
50
347
|
error?: string;
|
|
348
|
+
/** Execution time in milliseconds */
|
|
51
349
|
durationMs: number;
|
|
52
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Final result of a complete workflow execution.
|
|
353
|
+
*/
|
|
53
354
|
interface WorkflowResult {
|
|
355
|
+
/** The workflow that was executed */
|
|
54
356
|
workflow: Workflow;
|
|
357
|
+
/** Results for each step in the workflow */
|
|
55
358
|
stepResults: WorkflowStepResult[];
|
|
359
|
+
/** Whether the overall workflow passed (all required gates passed) */
|
|
56
360
|
pass: boolean;
|
|
361
|
+
/** Total execution time in milliseconds */
|
|
57
362
|
totalDurationMs: number;
|
|
58
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Predefined cognitive modes for skills.
|
|
366
|
+
*/
|
|
59
367
|
declare const STANDARD_COGNITIVE_MODES: readonly ["adversarial-reviewer", "constructive-architect", "meticulous-implementer", "diagnostic-investigator", "advisory-guide", "meticulous-verifier"];
|
|
368
|
+
/**
|
|
369
|
+
* Cognitive mode of a skill, determining its behavior and persona.
|
|
370
|
+
*/
|
|
60
371
|
type CognitiveMode = (typeof STANDARD_COGNITIVE_MODES)[number] | (string & {});
|
|
372
|
+
/**
|
|
373
|
+
* Static metadata for a skill.
|
|
374
|
+
*/
|
|
61
375
|
interface SkillMetadata {
|
|
376
|
+
/** Unique name of the skill */
|
|
62
377
|
name: string;
|
|
378
|
+
/** Semantic version string */
|
|
63
379
|
version: string;
|
|
380
|
+
/** Brief description of what the skill does */
|
|
64
381
|
description: string;
|
|
382
|
+
/** The cognitive mode this skill operates in */
|
|
65
383
|
cognitive_mode?: CognitiveMode;
|
|
66
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Contextual information for a skill execution.
|
|
387
|
+
*/
|
|
67
388
|
interface SkillContext {
|
|
389
|
+
/** Name of the executing skill */
|
|
68
390
|
skillName: string;
|
|
391
|
+
/** Current pipeline phase */
|
|
69
392
|
phase: string;
|
|
393
|
+
/** Files relevant to the current execution */
|
|
70
394
|
files: string[];
|
|
71
395
|
/** Optional token budget — uses a plain record to avoid cross-package deps. */
|
|
72
396
|
tokenBudget?: Record<string, number>;
|
|
397
|
+
/** Additional metadata */
|
|
73
398
|
metadata: Record<string, unknown>;
|
|
74
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* Context for a single turn in a multi-turn skill interaction.
|
|
402
|
+
*/
|
|
75
403
|
interface TurnContext extends SkillContext {
|
|
404
|
+
/** Current turn number (1-indexed) */
|
|
76
405
|
turnNumber: number;
|
|
406
|
+
/** Results from previous turns in the same session */
|
|
77
407
|
previousResults: unknown[];
|
|
78
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Error reported by a skill.
|
|
411
|
+
*/
|
|
79
412
|
type SkillError = {
|
|
413
|
+
/** Machine-readable error code */
|
|
80
414
|
code: string;
|
|
415
|
+
/** Human-readable error message */
|
|
81
416
|
message: string;
|
|
417
|
+
/** Phase in which the error occurred */
|
|
82
418
|
phase: string;
|
|
83
419
|
};
|
|
84
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Names of standard CI checks.
|
|
422
|
+
*/
|
|
423
|
+
type CICheckName = 'validate' | 'deps' | 'docs' | 'entropy' | 'security' | 'perf' | 'phase-gate' | 'arch';
|
|
424
|
+
/**
|
|
425
|
+
* Status of a CI check.
|
|
426
|
+
*/
|
|
85
427
|
type CICheckStatus = 'pass' | 'fail' | 'warn' | 'skip';
|
|
428
|
+
/**
|
|
429
|
+
* A specific issue found during a CI check.
|
|
430
|
+
*/
|
|
86
431
|
interface CICheckIssue {
|
|
432
|
+
/** Severity level */
|
|
87
433
|
severity: 'error' | 'warning';
|
|
434
|
+
/** Descriptive message */
|
|
88
435
|
message: string;
|
|
436
|
+
/** Path to the affected file */
|
|
89
437
|
file?: string;
|
|
438
|
+
/** Line number in the affected file */
|
|
90
439
|
line?: number;
|
|
91
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Result of a single CI check execution.
|
|
443
|
+
*/
|
|
92
444
|
interface CICheckResult {
|
|
445
|
+
/** Name of the check */
|
|
93
446
|
name: CICheckName;
|
|
447
|
+
/** Final status of the check */
|
|
94
448
|
status: CICheckStatus;
|
|
449
|
+
/** List of issues discovered */
|
|
95
450
|
issues: CICheckIssue[];
|
|
451
|
+
/** Execution time in milliseconds */
|
|
96
452
|
durationMs: number;
|
|
97
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Summary counts for a set of CI checks.
|
|
456
|
+
*/
|
|
98
457
|
interface CICheckSummary {
|
|
458
|
+
/** Total number of checks run */
|
|
99
459
|
total: number;
|
|
460
|
+
/** Number of passing checks */
|
|
100
461
|
passed: number;
|
|
462
|
+
/** Number of failing checks */
|
|
101
463
|
failed: number;
|
|
464
|
+
/** Number of checks with warnings */
|
|
102
465
|
warnings: number;
|
|
466
|
+
/** Number of skipped checks */
|
|
103
467
|
skipped: number;
|
|
104
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Final report for a CI run.
|
|
471
|
+
*/
|
|
105
472
|
interface CICheckReport {
|
|
473
|
+
/** Schema version */
|
|
106
474
|
version: 1;
|
|
475
|
+
/** Name of the project */
|
|
107
476
|
project: string;
|
|
477
|
+
/** ISO timestamp of the run */
|
|
108
478
|
timestamp: string;
|
|
479
|
+
/** Detailed results for each check */
|
|
109
480
|
checks: CICheckResult[];
|
|
481
|
+
/** Aggregated summary */
|
|
110
482
|
summary: CICheckSummary;
|
|
483
|
+
/** Process exit code suggested for the CI runner */
|
|
111
484
|
exitCode: 0 | 1 | 2;
|
|
112
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Severity level that should trigger a CI failure.
|
|
488
|
+
*/
|
|
113
489
|
type CIFailOnSeverity = 'error' | 'warning';
|
|
490
|
+
/**
|
|
491
|
+
* Configuration options for the CI command.
|
|
492
|
+
*/
|
|
114
493
|
interface CICheckOptions {
|
|
494
|
+
/** Checks to skip */
|
|
115
495
|
skip?: CICheckName[];
|
|
496
|
+
/** Severity level that causes failure */
|
|
116
497
|
failOn?: CIFailOnSeverity;
|
|
498
|
+
/** Custom config file path */
|
|
117
499
|
configPath?: string;
|
|
118
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Supported CI platforms.
|
|
503
|
+
*/
|
|
119
504
|
type CIPlatform = 'github' | 'gitlab' | 'generic';
|
|
505
|
+
/**
|
|
506
|
+
* Options for initializing CI configuration.
|
|
507
|
+
*/
|
|
120
508
|
interface CIInitOptions {
|
|
509
|
+
/** Target CI platform */
|
|
121
510
|
platform?: CIPlatform;
|
|
511
|
+
/** Checks to enable */
|
|
122
512
|
checks?: CICheckName[];
|
|
123
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Result of a skill execution.
|
|
516
|
+
*/
|
|
124
517
|
type SkillResult = {
|
|
518
|
+
/** Whether the skill achieved its goal */
|
|
125
519
|
success: boolean;
|
|
520
|
+
/** List of artifact paths produced */
|
|
126
521
|
artifacts: string[];
|
|
522
|
+
/** One-line summary of the outcome */
|
|
127
523
|
summary: string;
|
|
128
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* Lifecycle hooks for skills.
|
|
527
|
+
*/
|
|
129
528
|
interface SkillLifecycleHooks {
|
|
529
|
+
/** Called before the skill starts execution */
|
|
130
530
|
preExecution?: (context: SkillContext) => SkillContext | null;
|
|
531
|
+
/** Called before each turn in a multi-turn interaction */
|
|
131
532
|
perTurn?: (context: TurnContext) => TurnContext | null;
|
|
533
|
+
/** Called after the skill completes execution */
|
|
132
534
|
postExecution?: (context: SkillContext, result: SkillResult) => void;
|
|
133
535
|
}
|
|
134
536
|
/**
|
|
@@ -187,4 +589,4 @@ interface Roadmap {
|
|
|
187
589
|
milestones: RoadmapMilestone[];
|
|
188
590
|
}
|
|
189
591
|
|
|
190
|
-
export { type CICheckIssue, type CICheckName, type CICheckOptions, type CICheckReport, type CICheckResult, type CICheckStatus, type CICheckSummary, type CIFailOnSeverity, type CIInitOptions, type CIPlatform, type CognitiveMode, Err, type FeatureStatus, Ok, type Result, type Roadmap, type RoadmapFeature, type RoadmapFrontmatter, type RoadmapMilestone, STANDARD_COGNITIVE_MODES, type SkillContext, type SkillError, type SkillLifecycleHooks, type SkillMetadata, type SkillResult, type StepOutcome, type TurnContext, type Workflow, type WorkflowResult, type WorkflowStep, type WorkflowStepResult, isErr, isOk };
|
|
592
|
+
export { type AgentBackend, type AgentConfig, type AgentError, type AgentErrorCategory, type AgentEvent, type AgentSession, type BlockerRef, type CICheckIssue, type CICheckName, type CICheckOptions, type CICheckReport, type CICheckResult, type CICheckStatus, type CICheckSummary, type CIFailOnSeverity, type CIInitOptions, type CIPlatform, type CognitiveMode, Err, type FeatureStatus, type HooksConfig, type Issue, type IssueTrackerClient, Ok, type PollingConfig, type Result, type Roadmap, type RoadmapFeature, type RoadmapFrontmatter, type RoadmapMilestone, STANDARD_COGNITIVE_MODES, type ServerConfig, type SessionStartParams, type SkillContext, type SkillError, type SkillLifecycleHooks, type SkillMetadata, type SkillResult, type StepOutcome, type TokenUsage, type TrackerConfig, type TurnContext, type TurnParams, type TurnResult, type Workflow, type WorkflowConfig, type WorkflowDefinition, type WorkflowResult, type WorkflowStep, type WorkflowStepResult, type WorkspaceConfig, isErr, isOk };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harness-engineering/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "TypeScript types and interfaces for Harness Engineering",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"vitest": "^4.0.18"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
44
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --tsconfig tsconfig.build.json",
|
|
45
45
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
46
46
|
"lint": "eslint src",
|
|
47
47
|
"typecheck": "tsc --noEmit",
|
|
48
48
|
"test": "vitest run",
|
|
49
49
|
"test:watch": "vitest",
|
|
50
|
-
"clean": "
|
|
50
|
+
"clean": "node ../../scripts/clean.mjs dist"
|
|
51
51
|
}
|
|
52
52
|
}
|