@harness-kernel/core 0.1.0-beta.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/NOTICE +3 -0
- package/README.md +12 -0
- package/dist/agent/context.d.ts +5 -0
- package/dist/agent/context.js +11 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/event.d.ts +3 -0
- package/dist/agent/event.js +50 -0
- package/dist/agent/event.js.map +1 -0
- package/dist/agent/hook.d.ts +6 -0
- package/dist/agent/hook.js +7 -0
- package/dist/agent/hook.js.map +1 -0
- package/dist/agent/mode.d.ts +5 -0
- package/dist/agent/mode.js +7 -0
- package/dist/agent/mode.js.map +1 -0
- package/dist/agent/role.d.ts +1 -0
- package/dist/agent/role.js +27 -0
- package/dist/agent/role.js.map +1 -0
- package/dist/agent/session.d.ts +6 -0
- package/dist/agent/session.js +13 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/tool.d.ts +5 -0
- package/dist/agent/tool.js +7 -0
- package/dist/agent/tool.js.map +1 -0
- package/dist/agent.d.ts +12 -0
- package/dist/agent.js +7 -0
- package/dist/agent.js.map +1 -0
- package/dist/approval-DfvjpbFs.d.ts +247 -0
- package/dist/chunk-4A2P4QU5.js +179 -0
- package/dist/chunk-4A2P4QU5.js.map +1 -0
- package/dist/chunk-4SYLFKIX.js +207 -0
- package/dist/chunk-4SYLFKIX.js.map +1 -0
- package/dist/chunk-4WWSQAWA.js +3778 -0
- package/dist/chunk-4WWSQAWA.js.map +1 -0
- package/dist/chunk-AD3BCYWU.js +37 -0
- package/dist/chunk-AD3BCYWU.js.map +1 -0
- package/dist/chunk-AZVA22HW.js +135 -0
- package/dist/chunk-AZVA22HW.js.map +1 -0
- package/dist/chunk-OBKS4AJR.js +529 -0
- package/dist/chunk-OBKS4AJR.js.map +1 -0
- package/dist/chunk-Q44U2CMM.js +239 -0
- package/dist/chunk-Q44U2CMM.js.map +1 -0
- package/dist/chunk-Q73WH5D7.js +54 -0
- package/dist/chunk-Q73WH5D7.js.map +1 -0
- package/dist/chunk-RRWJUHJG.js +9 -0
- package/dist/chunk-RRWJUHJG.js.map +1 -0
- package/dist/context-75mlon5x.d.ts +394 -0
- package/dist/event-CKV4EeZ3.d.ts +230 -0
- package/dist/events-D4xcDi53.d.ts +69 -0
- package/dist/hook-DMb9fw9Z.d.ts +20 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.js +174 -0
- package/dist/index.js.map +1 -0
- package/dist/model-provider-BrZ2RRmS.d.ts +130 -0
- package/dist/role-BN6KhQxx.d.ts +68 -0
- package/dist/runner/approval.d.ts +9 -0
- package/dist/runner/approval.js +1 -0
- package/dist/runner/approval.js.map +1 -0
- package/dist/runner/event.d.ts +3 -0
- package/dist/runner/event.js +50 -0
- package/dist/runner/event.js.map +1 -0
- package/dist/runner/logging.d.ts +31 -0
- package/dist/runner/logging.js +15 -0
- package/dist/runner/logging.js.map +1 -0
- package/dist/runner/model-provider.d.ts +8 -0
- package/dist/runner/model-provider.js +11 -0
- package/dist/runner/model-provider.js.map +1 -0
- package/dist/runner/sandbox.d.ts +47 -0
- package/dist/runner/sandbox.js +13 -0
- package/dist/runner/sandbox.js.map +1 -0
- package/dist/runner/storage.d.ts +6 -0
- package/dist/runner/storage.js +17 -0
- package/dist/runner/storage.js.map +1 -0
- package/dist/runner-Dxo7ALtp.d.ts +87 -0
- package/dist/runner.d.ts +10 -0
- package/dist/runner.js +18 -0
- package/dist/runner.js.map +1 -0
- package/dist/schema.d.ts +146 -0
- package/dist/schema.js +39 -0
- package/dist/schema.js.map +1 -0
- package/dist/storage-BmOEwW-p.d.ts +118 -0
- package/dist/tool-errors-CygY1Nba.d.ts +27 -0
- package/dist/types-BPmsw-mF.d.ts +80 -0
- package/package.json +114 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { c as HarnessRoleSelector } from './role-BN6KhQxx.js';
|
|
2
|
+
import { E as EventCursor, J as JsonObject, a as HarnessEventClass, d as HarnessEventQuery, e as HarnessEventRecord, H as HarnessEvent, b as HarnessEventEmitOptions } from './events-D4xcDi53.js';
|
|
3
|
+
import { b as HarnessLogClass, c as HarnessLogContext } from './types-BPmsw-mF.js';
|
|
4
|
+
import { HarnessSandboxSession } from './runner/sandbox.js';
|
|
5
|
+
|
|
6
|
+
type AgentMessageRole = "system" | "user" | "assistant" | "tool" | "event" | (string & {});
|
|
7
|
+
interface AgentMessage {
|
|
8
|
+
id: string;
|
|
9
|
+
seq: number;
|
|
10
|
+
branchId: string;
|
|
11
|
+
parentMessageId?: string;
|
|
12
|
+
role: AgentMessageRole;
|
|
13
|
+
authorRole?: string;
|
|
14
|
+
roleType?: string;
|
|
15
|
+
content: unknown;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
modeId?: string;
|
|
18
|
+
turnId?: string;
|
|
19
|
+
hidden?: boolean;
|
|
20
|
+
toolName?: string;
|
|
21
|
+
toolCallId?: string;
|
|
22
|
+
eventCursor?: EventCursor;
|
|
23
|
+
metadata?: JsonObject;
|
|
24
|
+
}
|
|
25
|
+
interface TranscriptQuery {
|
|
26
|
+
limit?: number;
|
|
27
|
+
includeHidden?: boolean;
|
|
28
|
+
includeInactive?: boolean;
|
|
29
|
+
beforeCurrentTurn?: boolean;
|
|
30
|
+
roles?: AgentMessageRole[];
|
|
31
|
+
}
|
|
32
|
+
interface TranscriptCursor {
|
|
33
|
+
id: string;
|
|
34
|
+
branchId: string;
|
|
35
|
+
headMessageId?: string;
|
|
36
|
+
seq: number;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
type TranscriptSeekTarget = "latest" | "start" | {
|
|
40
|
+
messageId: string;
|
|
41
|
+
} | {
|
|
42
|
+
cursor: TranscriptCursor;
|
|
43
|
+
};
|
|
44
|
+
interface TranscriptBranch {
|
|
45
|
+
id: string;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
parentBranchId?: string;
|
|
48
|
+
parentMessageId?: string;
|
|
49
|
+
parentMessageSeq?: number;
|
|
50
|
+
parentEventSeq?: number;
|
|
51
|
+
metadata?: JsonObject;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type HarnessContextProviderClass<TProvider extends HarnessContextProvider = HarnessContextProvider> = abstract new (...args: any[]) => TProvider;
|
|
55
|
+
type HarnessContextProviderSelector<TOptions extends JsonObject = JsonObject> = HarnessContextProvider<TOptions> | HarnessContextProviderClass<HarnessContextProvider<TOptions>>;
|
|
56
|
+
interface ContextProviderBinding<TOptions extends JsonObject = JsonObject> {
|
|
57
|
+
provider: HarnessContextProviderSelector<TOptions>;
|
|
58
|
+
options?: TOptions;
|
|
59
|
+
}
|
|
60
|
+
type ContextProviderReference<TOptions extends JsonObject = JsonObject> = HarnessContextProviderSelector<TOptions> | ContextProviderBinding<TOptions>;
|
|
61
|
+
interface ContextProviderSummary {
|
|
62
|
+
type: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
options?: JsonObject;
|
|
65
|
+
}
|
|
66
|
+
interface ContextContribution {
|
|
67
|
+
providerId?: string;
|
|
68
|
+
providerLabel?: string;
|
|
69
|
+
role: string;
|
|
70
|
+
authorRole?: string;
|
|
71
|
+
roleType?: string;
|
|
72
|
+
content: unknown;
|
|
73
|
+
metadata?: JsonObject;
|
|
74
|
+
}
|
|
75
|
+
declare enum ContextScopes {
|
|
76
|
+
Turn = "turn",
|
|
77
|
+
Run = "run",
|
|
78
|
+
Session = "session"
|
|
79
|
+
}
|
|
80
|
+
declare enum ContextConsume {
|
|
81
|
+
Once = "once",
|
|
82
|
+
WhileActive = "while_active"
|
|
83
|
+
}
|
|
84
|
+
interface ContextRegistrationOptions {
|
|
85
|
+
scope?: ContextScopes;
|
|
86
|
+
on?: HarnessEventClass;
|
|
87
|
+
consume?: ContextConsume;
|
|
88
|
+
id?: string;
|
|
89
|
+
replace?: boolean;
|
|
90
|
+
metadata?: JsonObject;
|
|
91
|
+
}
|
|
92
|
+
interface ContextEntry {
|
|
93
|
+
id: string;
|
|
94
|
+
scope: ContextScopes;
|
|
95
|
+
on: string;
|
|
96
|
+
consume: ContextConsume;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
activatedAt?: string;
|
|
99
|
+
activatedByEventId?: string;
|
|
100
|
+
activatedByEventType?: string;
|
|
101
|
+
runId: string;
|
|
102
|
+
turnId?: string;
|
|
103
|
+
modeId: string;
|
|
104
|
+
contribution: ContextContribution;
|
|
105
|
+
metadata?: JsonObject;
|
|
106
|
+
}
|
|
107
|
+
interface ContextEntryFilter {
|
|
108
|
+
id?: string;
|
|
109
|
+
scope?: ContextScopes;
|
|
110
|
+
consume?: ContextConsume;
|
|
111
|
+
providerId?: string;
|
|
112
|
+
role?: string;
|
|
113
|
+
on?: HarnessEventClass;
|
|
114
|
+
}
|
|
115
|
+
type ContextProviderOutput = string | ContextContributionInput | Array<string | ContextContributionInput> | null | undefined;
|
|
116
|
+
interface ContextContributionInput {
|
|
117
|
+
role?: HarnessRoleSelector;
|
|
118
|
+
content: unknown;
|
|
119
|
+
metadata?: JsonObject;
|
|
120
|
+
}
|
|
121
|
+
interface ContextProviderRenderResult {
|
|
122
|
+
providerId: string;
|
|
123
|
+
providerLabel?: string;
|
|
124
|
+
binding: ContextProviderSummary;
|
|
125
|
+
contributions: ContextContribution[];
|
|
126
|
+
}
|
|
127
|
+
interface ContextSnapshot {
|
|
128
|
+
id: string;
|
|
129
|
+
turnId?: string;
|
|
130
|
+
modeId: string;
|
|
131
|
+
createdAt: string;
|
|
132
|
+
providers: ContextProviderRenderResult[];
|
|
133
|
+
contributions: ContextContribution[];
|
|
134
|
+
systemPrompt: string;
|
|
135
|
+
messages: AgentMessage[];
|
|
136
|
+
}
|
|
137
|
+
declare abstract class HarnessContextProvider<TOptions extends JsonObject = JsonObject> {
|
|
138
|
+
protected readonly __harnessContextProviderBrand: true;
|
|
139
|
+
label?: string;
|
|
140
|
+
priority?: number;
|
|
141
|
+
role?: HarnessRoleSelector;
|
|
142
|
+
get type(): string;
|
|
143
|
+
with(options: TOptions): ContextProviderBinding<TOptions>;
|
|
144
|
+
abstract render(session: AgentReadSession, options?: TOptions): ContextProviderOutput | Promise<ContextProviderOutput>;
|
|
145
|
+
}
|
|
146
|
+
type AgentContextProvider<TOptions extends JsonObject = JsonObject> = HarnessContextProvider<TOptions>;
|
|
147
|
+
|
|
148
|
+
interface HarnessModeSummary {
|
|
149
|
+
type: string;
|
|
150
|
+
label: string;
|
|
151
|
+
}
|
|
152
|
+
declare abstract class HarnessMode {
|
|
153
|
+
protected readonly __harnessModeBrand: true;
|
|
154
|
+
label?: string;
|
|
155
|
+
model?: string;
|
|
156
|
+
prompt?: string | ((session: AgentReadSession) => string | Promise<string>);
|
|
157
|
+
providers?: "all" | ContextProviderReference[];
|
|
158
|
+
excludeProviders?: string[];
|
|
159
|
+
tools?: AgentToolSource[];
|
|
160
|
+
maxTurns?: number;
|
|
161
|
+
toolApproval?: ToolApprovalMode;
|
|
162
|
+
get type(): string;
|
|
163
|
+
getPrompt?(session: AgentReadSession): string | Promise<string>;
|
|
164
|
+
onEnter?(session: AgentActionSession, input?: unknown): void | Promise<void>;
|
|
165
|
+
onExit?(session: AgentActionSession, nextMode: HarnessModeSummary): void | Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
type HarnessModeClass<TMode extends HarnessMode = HarnessMode> = abstract new (...args: any[]) => TMode;
|
|
168
|
+
type HarnessModeSelector<TMode extends HarnessMode = HarnessMode> = TMode | HarnessModeClass<TMode>;
|
|
169
|
+
type AgentModeDefinition = HarnessMode;
|
|
170
|
+
|
|
171
|
+
type AgentSharedState = JsonObject;
|
|
172
|
+
interface AgentSharedStateDefinition {
|
|
173
|
+
initial?: AgentSharedState | (() => AgentSharedState);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface HarnessSnapshotInput {
|
|
177
|
+
label?: string;
|
|
178
|
+
metadata?: JsonObject;
|
|
179
|
+
}
|
|
180
|
+
interface HarnessSnapshotSummary {
|
|
181
|
+
id: string;
|
|
182
|
+
label?: string;
|
|
183
|
+
createdAt: string;
|
|
184
|
+
agentKey: string;
|
|
185
|
+
runId?: string;
|
|
186
|
+
turnId?: string;
|
|
187
|
+
modeId: string;
|
|
188
|
+
model: string;
|
|
189
|
+
transcriptCursor: TranscriptCursor;
|
|
190
|
+
eventCursor: EventCursor;
|
|
191
|
+
metadata?: JsonObject;
|
|
192
|
+
}
|
|
193
|
+
interface HarnessSnapshot extends HarnessSnapshotSummary {
|
|
194
|
+
state: AgentSharedState;
|
|
195
|
+
contextEntries: ContextEntry[];
|
|
196
|
+
contextSnapshot?: ContextSnapshot;
|
|
197
|
+
branches: TranscriptBranch[];
|
|
198
|
+
}
|
|
199
|
+
interface HarnessSnapshotCreator {
|
|
200
|
+
create(input?: HarnessSnapshotInput): Promise<HarnessSnapshot>;
|
|
201
|
+
}
|
|
202
|
+
interface HarnessSnapshotSession extends HarnessSnapshotCreator {
|
|
203
|
+
list(): HarnessSnapshotSummary[];
|
|
204
|
+
get(id: string): HarnessSnapshot | undefined;
|
|
205
|
+
restore(id: string): Promise<HarnessSnapshot>;
|
|
206
|
+
delete(id: string): Promise<boolean>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
interface AgentStateReader<TState extends AgentSharedState = AgentSharedState> {
|
|
210
|
+
get(): TState;
|
|
211
|
+
}
|
|
212
|
+
interface AgentStateSession<TState extends AgentSharedState = AgentSharedState> extends AgentStateReader<TState> {
|
|
213
|
+
update(patch: Partial<TState>): void;
|
|
214
|
+
set(next: TState): void;
|
|
215
|
+
}
|
|
216
|
+
interface AgentHistorySession {
|
|
217
|
+
get(options?: TranscriptQuery): AgentMessage[];
|
|
218
|
+
}
|
|
219
|
+
interface AgentEventReader {
|
|
220
|
+
query<TPayload = unknown>(filter?: HarnessEventQuery<TPayload>): HarnessEventRecord<TPayload>[];
|
|
221
|
+
}
|
|
222
|
+
interface AgentEventSession extends AgentEventReader {
|
|
223
|
+
emit<TPayload, TEvent extends HarnessEvent<TPayload>>(eventClass: HarnessEventClass<TPayload, TEvent>, payload: TPayload, options?: HarnessEventEmitOptions): Promise<TEvent>;
|
|
224
|
+
}
|
|
225
|
+
interface AgentModeReader {
|
|
226
|
+
current(): HarnessModeSummary;
|
|
227
|
+
}
|
|
228
|
+
interface AgentModeSession extends AgentModeReader {
|
|
229
|
+
switch(mode: HarnessModeSelector, input?: unknown): Promise<void>;
|
|
230
|
+
}
|
|
231
|
+
interface AgentToolSession {
|
|
232
|
+
invoke(tool: HarnessToolSelector, args: unknown): Promise<AgentToolResult>;
|
|
233
|
+
}
|
|
234
|
+
interface AgentMessageInput {
|
|
235
|
+
content: string;
|
|
236
|
+
metadata?: JsonObject;
|
|
237
|
+
role?: HarnessRoleSelector;
|
|
238
|
+
id?: string;
|
|
239
|
+
}
|
|
240
|
+
interface AgentMessageEnqueueOptions {
|
|
241
|
+
metadata?: JsonObject;
|
|
242
|
+
}
|
|
243
|
+
interface AgentMessageSession {
|
|
244
|
+
enqueue(input: string | AgentMessageInput, options?: AgentMessageEnqueueOptions): Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
interface HarnessTranscriptSession {
|
|
247
|
+
get(options?: TranscriptQuery): AgentMessage[];
|
|
248
|
+
getCursor(): TranscriptCursor;
|
|
249
|
+
seek(target: TranscriptSeekTarget): Promise<TranscriptCursor>;
|
|
250
|
+
latest(): Promise<TranscriptCursor>;
|
|
251
|
+
}
|
|
252
|
+
interface AgentLogSession {
|
|
253
|
+
debug(message: string, fields?: Record<string, unknown>): void;
|
|
254
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
255
|
+
warn(message: string, fields?: Record<string, unknown>): void;
|
|
256
|
+
error(errorOrMessage: unknown, fields?: Record<string, unknown>): void;
|
|
257
|
+
emit<TFields>(logClass: HarnessLogClass<TFields>, fields: TFields): void;
|
|
258
|
+
}
|
|
259
|
+
interface AgentRuntimeLogger {
|
|
260
|
+
readonly modelDeltas: "none" | "summary" | "full";
|
|
261
|
+
emit<TFields>(logClass: HarnessLogClass<TFields>, fields: TFields, context?: HarnessLogContext): void;
|
|
262
|
+
agent(context: HarnessLogContext): AgentLogSession;
|
|
263
|
+
}
|
|
264
|
+
interface AgentContextReader {
|
|
265
|
+
get(filter?: ContextEntryFilter): ContextEntry[];
|
|
266
|
+
snapshot(): ContextSnapshot | undefined;
|
|
267
|
+
}
|
|
268
|
+
interface AgentContextSession extends AgentContextReader {
|
|
269
|
+
add(input: ContextContributionInput, options?: ContextRegistrationOptions): Promise<ContextEntry>;
|
|
270
|
+
render(binding: ContextProviderReference, options?: ContextRegistrationOptions): Promise<ContextEntry[]>;
|
|
271
|
+
remove(id: string): Promise<boolean>;
|
|
272
|
+
clear(filter?: ContextEntryFilter): Promise<number>;
|
|
273
|
+
}
|
|
274
|
+
interface AgentReadSession<TState extends AgentSharedState = AgentSharedState, TServices extends Record<string, unknown> = Record<string, unknown>> {
|
|
275
|
+
runId: string;
|
|
276
|
+
turnId?: string;
|
|
277
|
+
agentKey: string;
|
|
278
|
+
workDir: string;
|
|
279
|
+
outputDir?: string;
|
|
280
|
+
services: TServices;
|
|
281
|
+
state: AgentStateReader<TState>;
|
|
282
|
+
history: AgentHistorySession;
|
|
283
|
+
events: AgentEventReader;
|
|
284
|
+
mode: AgentModeReader;
|
|
285
|
+
context: AgentContextReader;
|
|
286
|
+
log: AgentLogSession;
|
|
287
|
+
}
|
|
288
|
+
interface AgentActionSession<TState extends AgentSharedState = AgentSharedState, TServices extends Record<string, unknown> = Record<string, unknown>> extends AgentReadSession<TState, TServices> {
|
|
289
|
+
sandbox: HarnessSandboxSession;
|
|
290
|
+
state: AgentStateSession<TState>;
|
|
291
|
+
events: AgentEventSession;
|
|
292
|
+
mode: AgentModeSession;
|
|
293
|
+
tools: AgentToolSession;
|
|
294
|
+
context: AgentContextSession;
|
|
295
|
+
messages: AgentMessageSession;
|
|
296
|
+
snapshots: HarnessSnapshotCreator;
|
|
297
|
+
toolCall?: {
|
|
298
|
+
id?: string;
|
|
299
|
+
name: string;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
interface RunInfo {
|
|
303
|
+
runId: string;
|
|
304
|
+
agentKey: string;
|
|
305
|
+
workDir: string;
|
|
306
|
+
outputDir?: string;
|
|
307
|
+
started: boolean;
|
|
308
|
+
startedAt?: string;
|
|
309
|
+
}
|
|
310
|
+
interface TurnInfo {
|
|
311
|
+
turnId?: string;
|
|
312
|
+
turnCount: number;
|
|
313
|
+
modeId: string;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
type ToolApprovalMode = "auto" | "ask" | "deny" | "tool-default";
|
|
317
|
+
type ToolApprovalDecision = "approved" | "denied";
|
|
318
|
+
type ToolRisk = "safe" | "read" | "write" | "execute" | "network" | "destructive";
|
|
319
|
+
interface ToolPermission {
|
|
320
|
+
kind: "filesystem" | "shell" | "network" | "custom";
|
|
321
|
+
access?: "read" | "write" | "execute";
|
|
322
|
+
path?: string;
|
|
323
|
+
description?: string;
|
|
324
|
+
}
|
|
325
|
+
type ToolRef = {
|
|
326
|
+
kind: "file";
|
|
327
|
+
path: string;
|
|
328
|
+
role?: "created" | "modified" | "read" | "evidence";
|
|
329
|
+
} | {
|
|
330
|
+
kind: "url";
|
|
331
|
+
url: string;
|
|
332
|
+
role?: string;
|
|
333
|
+
} | {
|
|
334
|
+
kind: "command";
|
|
335
|
+
command: string;
|
|
336
|
+
exitCode?: number;
|
|
337
|
+
role?: string;
|
|
338
|
+
} | {
|
|
339
|
+
kind: "tool_call";
|
|
340
|
+
toolName: string;
|
|
341
|
+
callId?: string;
|
|
342
|
+
role?: string;
|
|
343
|
+
} | {
|
|
344
|
+
kind: "session";
|
|
345
|
+
sessionId: string;
|
|
346
|
+
role?: string;
|
|
347
|
+
} | {
|
|
348
|
+
kind: "external";
|
|
349
|
+
label: string;
|
|
350
|
+
uri?: string;
|
|
351
|
+
role?: string;
|
|
352
|
+
};
|
|
353
|
+
interface ToolCatalogEntry {
|
|
354
|
+
name: string;
|
|
355
|
+
description: string;
|
|
356
|
+
risk?: ToolRisk;
|
|
357
|
+
permissions?: ToolPermission[];
|
|
358
|
+
requiresApproval?: boolean;
|
|
359
|
+
}
|
|
360
|
+
type ToolApprovalResolver = (args: unknown, session: AgentActionSession) => boolean | Promise<boolean>;
|
|
361
|
+
interface AgentToolResult<TData = unknown> {
|
|
362
|
+
content: string;
|
|
363
|
+
data?: TData;
|
|
364
|
+
refs?: ToolRef[];
|
|
365
|
+
metadata?: JsonObject;
|
|
366
|
+
isError?: boolean;
|
|
367
|
+
}
|
|
368
|
+
declare abstract class HarnessTool<TInput = unknown, TData = unknown> {
|
|
369
|
+
protected readonly __harnessToolBrand: true;
|
|
370
|
+
label?: string;
|
|
371
|
+
abstract name: string;
|
|
372
|
+
abstract description: string;
|
|
373
|
+
schema?: unknown;
|
|
374
|
+
risk?: ToolRisk;
|
|
375
|
+
permissions?: ToolPermission[];
|
|
376
|
+
requiresApproval?: boolean | ToolApprovalResolver;
|
|
377
|
+
get type(): string;
|
|
378
|
+
get inputSchema(): unknown;
|
|
379
|
+
abstract execute(args: TInput, session: AgentActionSession): AgentToolResult<TData> | Promise<AgentToolResult<TData>>;
|
|
380
|
+
}
|
|
381
|
+
type HarnessToolClass<TTool extends HarnessTool = HarnessTool> = abstract new (...args: any[]) => TTool;
|
|
382
|
+
type HarnessToolSelector<TTool extends HarnessTool = HarnessTool> = TTool | HarnessToolClass<TTool>;
|
|
383
|
+
type AgentToolDefinition<TInput = unknown, TData = unknown> = HarnessTool<TInput, TData>;
|
|
384
|
+
type AgentToolSource = HarnessTool;
|
|
385
|
+
interface ToolApprovalRequest {
|
|
386
|
+
id: string;
|
|
387
|
+
name: string;
|
|
388
|
+
args: unknown;
|
|
389
|
+
modeId: string;
|
|
390
|
+
risk?: ToolRisk;
|
|
391
|
+
permissions?: ToolPermission[];
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export { type HarnessToolSelector as $, type AgentActionSession as A, type ContextContributionInput as B, ContextConsume as C, type ContextEntry as D, type ContextEntryFilter as E, type ContextProviderBinding as F, type ContextProviderOutput as G, type ContextProviderReference as H, type ContextProviderRenderResult as I, type ContextProviderSummary as J, type ContextRegistrationOptions as K, ContextScopes as L, type ContextSnapshot as M, HarnessContextProvider as N, type HarnessContextProviderClass as O, type HarnessContextProviderSelector as P, HarnessMode as Q, type HarnessModeClass as R, type HarnessModeSelector as S, type HarnessModeSummary as T, type HarnessSnapshot as U, type HarnessSnapshotCreator as V, type HarnessSnapshotInput as W, type HarnessSnapshotSession as X, type HarnessSnapshotSummary as Y, HarnessTool as Z, type HarnessToolClass as _, type AgentContextProvider as a, type HarnessTranscriptSession as a0, type RunInfo as a1, type ToolApprovalDecision as a2, type ToolApprovalMode as a3, type ToolApprovalRequest as a4, type ToolApprovalResolver as a5, type ToolCatalogEntry as a6, type ToolPermission as a7, type ToolRef as a8, type ToolRisk as a9, type TranscriptBranch as aa, type TranscriptCursor as ab, type TranscriptQuery as ac, type TranscriptSeekTarget as ad, type TurnInfo as ae, type AgentContextReader as b, type AgentContextSession as c, type AgentEventReader as d, type AgentEventSession as e, type AgentHistorySession as f, type AgentLogSession as g, type AgentMessage as h, type AgentMessageEnqueueOptions as i, type AgentMessageInput as j, type AgentMessageRole as k, type AgentMessageSession as l, type AgentModeDefinition as m, type AgentModeReader as n, type AgentModeSession as o, type AgentReadSession as p, type AgentRuntimeLogger as q, type AgentSharedState as r, type AgentSharedStateDefinition as s, type AgentStateReader as t, type AgentStateSession as u, type AgentToolDefinition as v, type AgentToolResult as w, type AgentToolSession as x, type AgentToolSource as y, type ContextContribution as z };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { H as HarnessEvent } from './events-D4xcDi53.js';
|
|
2
|
+
import { ObjectSchema, StringSchema, NumberSchema, OptionalSchema, LiteralSchema, UnknownSchema, EnumSchema } from './schema.js';
|
|
3
|
+
|
|
4
|
+
declare class RunStartEvent extends HarnessEvent<{
|
|
5
|
+
agentKey: string;
|
|
6
|
+
modeId: string;
|
|
7
|
+
workDir: string;
|
|
8
|
+
outputDir?: string;
|
|
9
|
+
}> {
|
|
10
|
+
static type: string;
|
|
11
|
+
static schema: ObjectSchema<{
|
|
12
|
+
agentKey: StringSchema;
|
|
13
|
+
modeId: StringSchema;
|
|
14
|
+
workDir: StringSchema;
|
|
15
|
+
outputDir: OptionalSchema<unknown, string | undefined>;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
declare class TurnStartEvent extends HarnessEvent<{
|
|
19
|
+
turnId: string;
|
|
20
|
+
input: string;
|
|
21
|
+
}> {
|
|
22
|
+
static type: string;
|
|
23
|
+
static schema: ObjectSchema<{
|
|
24
|
+
turnId: StringSchema;
|
|
25
|
+
input: StringSchema;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
declare class ContextReadyEvent extends HarnessEvent<{
|
|
29
|
+
snapshotId: string;
|
|
30
|
+
providerCount: number;
|
|
31
|
+
contributionCount: number;
|
|
32
|
+
}> {
|
|
33
|
+
static type: string;
|
|
34
|
+
static schema: ObjectSchema<{
|
|
35
|
+
snapshotId: StringSchema;
|
|
36
|
+
providerCount: NumberSchema;
|
|
37
|
+
contributionCount: NumberSchema;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
declare class ModelBeforeEvent extends HarnessEvent<{
|
|
41
|
+
model: string;
|
|
42
|
+
messageCount: number;
|
|
43
|
+
}> {
|
|
44
|
+
static type: string;
|
|
45
|
+
static schema: ObjectSchema<{
|
|
46
|
+
model: StringSchema;
|
|
47
|
+
messageCount: NumberSchema;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
declare class ModelAfterEvent extends HarnessEvent<{
|
|
51
|
+
model: string;
|
|
52
|
+
content: string;
|
|
53
|
+
usage?: unknown;
|
|
54
|
+
finishReason?: string;
|
|
55
|
+
}> {
|
|
56
|
+
static type: string;
|
|
57
|
+
static schema: ObjectSchema<{
|
|
58
|
+
model: StringSchema;
|
|
59
|
+
content: StringSchema;
|
|
60
|
+
usage: OptionalSchema<unknown, unknown>;
|
|
61
|
+
finishReason: OptionalSchema<unknown, string | undefined>;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
declare class ToolStartEvent extends HarnessEvent<{
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
args: unknown;
|
|
68
|
+
}> {
|
|
69
|
+
static type: string;
|
|
70
|
+
static schema: ObjectSchema<{
|
|
71
|
+
id: StringSchema;
|
|
72
|
+
name: StringSchema;
|
|
73
|
+
args: UnknownSchema;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
declare class ToolEndEvent extends HarnessEvent<{
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
durationMs: number;
|
|
80
|
+
result: unknown;
|
|
81
|
+
}> {
|
|
82
|
+
static type: string;
|
|
83
|
+
static schema: ObjectSchema<{
|
|
84
|
+
id: StringSchema;
|
|
85
|
+
name: StringSchema;
|
|
86
|
+
durationMs: NumberSchema;
|
|
87
|
+
result: UnknownSchema;
|
|
88
|
+
}>;
|
|
89
|
+
}
|
|
90
|
+
declare class TurnEndEvent extends HarnessEvent<{
|
|
91
|
+
turnId: string;
|
|
92
|
+
finalAnswer: string;
|
|
93
|
+
}> {
|
|
94
|
+
static type: string;
|
|
95
|
+
static schema: ObjectSchema<{
|
|
96
|
+
turnId: StringSchema;
|
|
97
|
+
finalAnswer: StringSchema;
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
declare class RunEndEvent extends HarnessEvent<{
|
|
101
|
+
metrics: unknown;
|
|
102
|
+
finalAnswer: string;
|
|
103
|
+
}> {
|
|
104
|
+
static type: string;
|
|
105
|
+
static schema: ObjectSchema<{
|
|
106
|
+
metrics: UnknownSchema;
|
|
107
|
+
finalAnswer: StringSchema;
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
110
|
+
declare class ErrorEvent extends HarnessEvent<{
|
|
111
|
+
message: string;
|
|
112
|
+
recoverable?: boolean;
|
|
113
|
+
details?: unknown;
|
|
114
|
+
}> {
|
|
115
|
+
static type: string;
|
|
116
|
+
static schema: ObjectSchema<{
|
|
117
|
+
message: StringSchema;
|
|
118
|
+
recoverable: OptionalSchema<unknown, boolean | undefined>;
|
|
119
|
+
details: OptionalSchema<unknown, unknown>;
|
|
120
|
+
}>;
|
|
121
|
+
}
|
|
122
|
+
declare class MessageStartEvent extends HarnessEvent<{
|
|
123
|
+
role: string;
|
|
124
|
+
}> {
|
|
125
|
+
static type: string;
|
|
126
|
+
static schema: ObjectSchema<{
|
|
127
|
+
role: StringSchema;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
declare class MessageDeltaEvent extends HarnessEvent<{
|
|
131
|
+
role: "assistant";
|
|
132
|
+
text: string;
|
|
133
|
+
}> {
|
|
134
|
+
static type: string;
|
|
135
|
+
static schema: ObjectSchema<{
|
|
136
|
+
role: LiteralSchema<"assistant">;
|
|
137
|
+
text: StringSchema;
|
|
138
|
+
}>;
|
|
139
|
+
}
|
|
140
|
+
declare class MessageEndEvent extends HarnessEvent<{
|
|
141
|
+
message: unknown;
|
|
142
|
+
}> {
|
|
143
|
+
static type: string;
|
|
144
|
+
static schema: ObjectSchema<{
|
|
145
|
+
message: UnknownSchema;
|
|
146
|
+
}>;
|
|
147
|
+
}
|
|
148
|
+
declare class ToolApprovalRequestedEvent extends HarnessEvent<{
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
args: unknown;
|
|
152
|
+
modeId?: string;
|
|
153
|
+
risk?: string;
|
|
154
|
+
permissions?: unknown[];
|
|
155
|
+
}> {
|
|
156
|
+
static type: string;
|
|
157
|
+
static schema: ObjectSchema<{
|
|
158
|
+
id: StringSchema;
|
|
159
|
+
name: StringSchema;
|
|
160
|
+
args: UnknownSchema;
|
|
161
|
+
modeId: OptionalSchema<unknown, string | undefined>;
|
|
162
|
+
risk: OptionalSchema<unknown, string | undefined>;
|
|
163
|
+
permissions: OptionalSchema<unknown[] | undefined, unknown[] | undefined>;
|
|
164
|
+
}>;
|
|
165
|
+
}
|
|
166
|
+
declare class ToolApprovalResolvedEvent extends HarnessEvent<{
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
args: unknown;
|
|
170
|
+
decision: "approved" | "denied";
|
|
171
|
+
modeId?: string;
|
|
172
|
+
}> {
|
|
173
|
+
static type: string;
|
|
174
|
+
static schema: ObjectSchema<{
|
|
175
|
+
id: StringSchema;
|
|
176
|
+
name: StringSchema;
|
|
177
|
+
args: UnknownSchema;
|
|
178
|
+
decision: EnumSchema<readonly ["approved", "denied"]>;
|
|
179
|
+
modeId: OptionalSchema<unknown, string | undefined>;
|
|
180
|
+
}>;
|
|
181
|
+
}
|
|
182
|
+
declare class ModeChangedEvent extends HarnessEvent<{
|
|
183
|
+
previousMode: string;
|
|
184
|
+
mode: string;
|
|
185
|
+
input?: unknown;
|
|
186
|
+
}> {
|
|
187
|
+
static type: string;
|
|
188
|
+
static schema: ObjectSchema<{
|
|
189
|
+
previousMode: StringSchema;
|
|
190
|
+
mode: StringSchema;
|
|
191
|
+
input: OptionalSchema<unknown, unknown>;
|
|
192
|
+
}>;
|
|
193
|
+
}
|
|
194
|
+
declare class SnapshotCreatedEvent extends HarnessEvent<{
|
|
195
|
+
snapshot: unknown;
|
|
196
|
+
}> {
|
|
197
|
+
static type: string;
|
|
198
|
+
static schema: ObjectSchema<{
|
|
199
|
+
snapshot: UnknownSchema;
|
|
200
|
+
}>;
|
|
201
|
+
}
|
|
202
|
+
declare class SnapshotRestoredEvent extends HarnessEvent<{
|
|
203
|
+
snapshot: unknown;
|
|
204
|
+
}> {
|
|
205
|
+
static type: string;
|
|
206
|
+
static schema: ObjectSchema<{
|
|
207
|
+
snapshot: UnknownSchema;
|
|
208
|
+
}>;
|
|
209
|
+
}
|
|
210
|
+
declare class SnapshotDeletedEvent extends HarnessEvent<{
|
|
211
|
+
snapshot: unknown;
|
|
212
|
+
}> {
|
|
213
|
+
static type: string;
|
|
214
|
+
static schema: ObjectSchema<{
|
|
215
|
+
snapshot: UnknownSchema;
|
|
216
|
+
}>;
|
|
217
|
+
}
|
|
218
|
+
declare class TranscriptCursorChangedEvent extends HarnessEvent<{
|
|
219
|
+
previousCursor: unknown;
|
|
220
|
+
cursor: unknown;
|
|
221
|
+
}> {
|
|
222
|
+
static type: string;
|
|
223
|
+
static schema: ObjectSchema<{
|
|
224
|
+
previousCursor: UnknownSchema;
|
|
225
|
+
cursor: UnknownSchema;
|
|
226
|
+
}>;
|
|
227
|
+
}
|
|
228
|
+
declare const runtimeEventClasses: (typeof RunStartEvent | typeof TurnStartEvent | typeof ContextReadyEvent | typeof ModelBeforeEvent | typeof ModelAfterEvent | typeof ToolStartEvent | typeof ToolEndEvent | typeof TurnEndEvent | typeof RunEndEvent | typeof MessageStartEvent | typeof MessageDeltaEvent | typeof MessageEndEvent | typeof ModeChangedEvent | typeof SnapshotCreatedEvent | typeof TranscriptCursorChangedEvent)[];
|
|
229
|
+
|
|
230
|
+
export { ContextReadyEvent as C, ErrorEvent as E, MessageDeltaEvent as M, RunEndEvent as R, SnapshotCreatedEvent as S, ToolApprovalRequestedEvent as T, MessageEndEvent as a, MessageStartEvent as b, ModeChangedEvent as c, ModelAfterEvent as d, ModelBeforeEvent as e, RunStartEvent as f, SnapshotDeletedEvent as g, SnapshotRestoredEvent as h, ToolApprovalResolvedEvent as i, ToolEndEvent as j, ToolStartEvent as k, TranscriptCursorChangedEvent as l, TurnEndEvent as m, TurnStartEvent as n, runtimeEventClasses as r };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type JsonObject = Record<string, unknown>;
|
|
2
|
+
|
|
3
|
+
interface HarnessEventMetadata extends JsonObject {
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
interface HarnessEventSource {
|
|
7
|
+
kind: "runtime" | "model_provider" | "tool" | "hook" | "context_provider" | "mode" | "user" | "custom";
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
}
|
|
11
|
+
interface HarnessEventRecord<TPayload = unknown> {
|
|
12
|
+
id: string;
|
|
13
|
+
seq: number;
|
|
14
|
+
branchId: string;
|
|
15
|
+
type: string;
|
|
16
|
+
eventClassId: string;
|
|
17
|
+
at: string;
|
|
18
|
+
source: HarnessEventSource;
|
|
19
|
+
payload: TPayload;
|
|
20
|
+
runId: string;
|
|
21
|
+
turnId?: string;
|
|
22
|
+
modeId?: string;
|
|
23
|
+
correlationId?: string;
|
|
24
|
+
causationId?: string;
|
|
25
|
+
hidden: true;
|
|
26
|
+
metadata?: HarnessEventMetadata;
|
|
27
|
+
}
|
|
28
|
+
declare abstract class HarnessEvent<TPayload = unknown> {
|
|
29
|
+
readonly record: HarnessEventRecord<TPayload>;
|
|
30
|
+
static type?: string;
|
|
31
|
+
static schema?: unknown;
|
|
32
|
+
constructor(record: HarnessEventRecord<TPayload>);
|
|
33
|
+
get id(): string;
|
|
34
|
+
get type(): string;
|
|
35
|
+
get payload(): TPayload;
|
|
36
|
+
get at(): string;
|
|
37
|
+
}
|
|
38
|
+
type HarnessEventClass<TPayload = unknown, TEvent extends HarnessEvent<TPayload> = HarnessEvent<TPayload>> = {
|
|
39
|
+
readonly type?: string;
|
|
40
|
+
readonly schema?: unknown;
|
|
41
|
+
new (record: HarnessEventRecord<any>): TEvent;
|
|
42
|
+
};
|
|
43
|
+
interface HarnessEventEmitOptions {
|
|
44
|
+
source?: HarnessEventSource;
|
|
45
|
+
correlationId?: string;
|
|
46
|
+
causationId?: string;
|
|
47
|
+
metadata?: HarnessEventMetadata;
|
|
48
|
+
hiddenTranscript?: boolean;
|
|
49
|
+
skipHooks?: boolean;
|
|
50
|
+
}
|
|
51
|
+
interface HarnessEventQuery<TPayload = unknown> {
|
|
52
|
+
event?: HarnessEventClass<TPayload>;
|
|
53
|
+
type?: string;
|
|
54
|
+
sourceKind?: HarnessEventSource["kind"];
|
|
55
|
+
limit?: number;
|
|
56
|
+
since?: string;
|
|
57
|
+
until?: string;
|
|
58
|
+
includeInactive?: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface EventCursor {
|
|
61
|
+
id: string;
|
|
62
|
+
branchId: string;
|
|
63
|
+
headEventId?: string;
|
|
64
|
+
seq: number;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
}
|
|
67
|
+
type RunnerEventListener = (event: HarnessEventRecord) => void | Promise<void>;
|
|
68
|
+
|
|
69
|
+
export { type EventCursor as E, HarnessEvent as H, type JsonObject as J, type RunnerEventListener as R, type HarnessEventClass as a, type HarnessEventEmitOptions as b, type HarnessEventMetadata as c, type HarnessEventQuery as d, type HarnessEventRecord as e, type HarnessEventSource as f };
|