@elyracode/agent-core 0.1.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.
Files changed (98) hide show
  1. package/README.md +488 -0
  2. package/dist/agent-loop.d.ts +24 -0
  3. package/dist/agent-loop.d.ts.map +1 -0
  4. package/dist/agent-loop.js +479 -0
  5. package/dist/agent-loop.js.map +1 -0
  6. package/dist/agent.d.ts +118 -0
  7. package/dist/agent.d.ts.map +1 -0
  8. package/dist/agent.js +402 -0
  9. package/dist/agent.js.map +1 -0
  10. package/dist/harness/agent-harness.d.ts +78 -0
  11. package/dist/harness/agent-harness.d.ts.map +1 -0
  12. package/dist/harness/agent-harness.js +602 -0
  13. package/dist/harness/agent-harness.js.map +1 -0
  14. package/dist/harness/compaction/branch-summarization.d.ts +88 -0
  15. package/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
  16. package/dist/harness/compaction/branch-summarization.js +243 -0
  17. package/dist/harness/compaction/branch-summarization.js.map +1 -0
  18. package/dist/harness/compaction/compaction.d.ts +122 -0
  19. package/dist/harness/compaction/compaction.d.ts.map +1 -0
  20. package/dist/harness/compaction/compaction.js +616 -0
  21. package/dist/harness/compaction/compaction.js.map +1 -0
  22. package/dist/harness/compaction/utils.d.ts +38 -0
  23. package/dist/harness/compaction/utils.d.ts.map +1 -0
  24. package/dist/harness/compaction/utils.js +153 -0
  25. package/dist/harness/compaction/utils.js.map +1 -0
  26. package/dist/harness/env/nodejs.d.ts +44 -0
  27. package/dist/harness/env/nodejs.d.ts.map +1 -0
  28. package/dist/harness/env/nodejs.js +348 -0
  29. package/dist/harness/env/nodejs.js.map +1 -0
  30. package/dist/harness/execution-env.d.ts +4 -0
  31. package/dist/harness/execution-env.d.ts.map +1 -0
  32. package/dist/harness/execution-env.js +3 -0
  33. package/dist/harness/execution-env.js.map +1 -0
  34. package/dist/harness/messages.d.ts +51 -0
  35. package/dist/harness/messages.d.ts.map +1 -0
  36. package/dist/harness/messages.js +102 -0
  37. package/dist/harness/messages.js.map +1 -0
  38. package/dist/harness/prompt-templates.d.ts +45 -0
  39. package/dist/harness/prompt-templates.d.ts.map +1 -0
  40. package/dist/harness/prompt-templates.js +200 -0
  41. package/dist/harness/prompt-templates.js.map +1 -0
  42. package/dist/harness/session/repo/jsonl.d.ts +20 -0
  43. package/dist/harness/session/repo/jsonl.d.ts.map +1 -0
  44. package/dist/harness/session/repo/jsonl.js +92 -0
  45. package/dist/harness/session/repo/jsonl.js.map +1 -0
  46. package/dist/harness/session/repo/memory.d.ts +18 -0
  47. package/dist/harness/session/repo/memory.d.ts.map +1 -0
  48. package/dist/harness/session/repo/memory.js +42 -0
  49. package/dist/harness/session/repo/memory.js.map +1 -0
  50. package/dist/harness/session/repo/shared.d.ts +10 -0
  51. package/dist/harness/session/repo/shared.d.ts.map +1 -0
  52. package/dist/harness/session/repo/shared.js +31 -0
  53. package/dist/harness/session/repo/shared.js.map +1 -0
  54. package/dist/harness/session/session.d.ts +32 -0
  55. package/dist/harness/session/session.d.ts.map +1 -0
  56. package/dist/harness/session/session.js +196 -0
  57. package/dist/harness/session/session.js.map +1 -0
  58. package/dist/harness/session/storage/jsonl.d.ts +30 -0
  59. package/dist/harness/session/storage/jsonl.d.ts.map +1 -0
  60. package/dist/harness/session/storage/jsonl.js +170 -0
  61. package/dist/harness/session/storage/jsonl.js.map +1 -0
  62. package/dist/harness/session/storage/memory.d.ts +26 -0
  63. package/dist/harness/session/storage/memory.d.ts.map +1 -0
  64. package/dist/harness/session/storage/memory.js +90 -0
  65. package/dist/harness/session/storage/memory.js.map +1 -0
  66. package/dist/harness/skills.d.ts +41 -0
  67. package/dist/harness/skills.d.ts.map +1 -0
  68. package/dist/harness/skills.js +259 -0
  69. package/dist/harness/skills.js.map +1 -0
  70. package/dist/harness/system-prompt.d.ts +3 -0
  71. package/dist/harness/system-prompt.d.ts.map +1 -0
  72. package/dist/harness/system-prompt.js +30 -0
  73. package/dist/harness/system-prompt.js.map +1 -0
  74. package/dist/harness/types.d.ts +497 -0
  75. package/dist/harness/types.d.ts.map +1 -0
  76. package/dist/harness/types.js +16 -0
  77. package/dist/harness/types.js.map +1 -0
  78. package/dist/harness/utils/shell-output.d.ts +14 -0
  79. package/dist/harness/utils/shell-output.d.ts.map +1 -0
  80. package/dist/harness/utils/shell-output.js +97 -0
  81. package/dist/harness/utils/shell-output.js.map +1 -0
  82. package/dist/harness/utils/truncate.d.ts +70 -0
  83. package/dist/harness/utils/truncate.d.ts.map +1 -0
  84. package/dist/harness/utils/truncate.js +205 -0
  85. package/dist/harness/utils/truncate.js.map +1 -0
  86. package/dist/index.d.ts +20 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +25 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/proxy.d.ts +69 -0
  91. package/dist/proxy.d.ts.map +1 -0
  92. package/dist/proxy.js +278 -0
  93. package/dist/proxy.js.map +1 -0
  94. package/dist/types.d.ts +386 -0
  95. package/dist/types.d.ts.map +1 -0
  96. package/dist/types.js +2 -0
  97. package/dist/types.js.map +1 -0
  98. package/package.json +47 -0
@@ -0,0 +1,497 @@
1
+ import type { ImageContent, Model, TextContent } from "@elyracode/ai";
2
+ import type { QueueMode } from "../agent.js";
3
+ import type { AgentEvent, AgentMessage, AgentTool, ThinkingLevel } from "../index.js";
4
+ import type { Session } from "./session/session.js";
5
+ /**
6
+ * Skill loaded from a `SKILL.md` file or provided by an application.
7
+ *
8
+ * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.
9
+ * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.
10
+ */
11
+ export interface Skill {
12
+ /** Stable skill name used for lookup and model-visible listings. */
13
+ name: string;
14
+ /** Short model-visible description of when to use the skill. */
15
+ description: string;
16
+ /** Full skill instructions. */
17
+ content: string;
18
+ /** Absolute path to the skill file. Used for model-visible location and resolving relative references. */
19
+ filePath: string;
20
+ /** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */
21
+ disableModelInvocation?: boolean;
22
+ }
23
+ /** Prompt template that can be formatted into a prompt for explicit invocation. */
24
+ export interface PromptTemplate {
25
+ /** Stable template name used for lookup or application command routing. */
26
+ name: string;
27
+ /** Optional description for command lists or autocomplete. */
28
+ description?: string;
29
+ /** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */
30
+ content: string;
31
+ }
32
+ /** Resources made available to explicit invocation methods and system-prompt callbacks. */
33
+ export interface AgentHarnessResources<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> {
34
+ /** Prompt templates available for explicit invocation. */
35
+ promptTemplates?: TPromptTemplate[];
36
+ /** Skills available to the model and explicit skill invocation. */
37
+ skills?: TSkill[];
38
+ }
39
+ /** Kind of filesystem object as addressed by an {@link ExecutionEnv}. Symlinks are not followed automatically. */
40
+ export type FileKind = "file" | "directory" | "symlink";
41
+ /** Stable, backend-independent file error codes thrown by {@link ExecutionEnv} file operations. */
42
+ export type FileErrorCode = "not_found" | "permission_denied" | "not_directory" | "is_directory" | "invalid" | "not_supported" | "unknown";
43
+ /** Error thrown by {@link ExecutionEnv} file operations. */
44
+ export declare class FileError extends Error {
45
+ /** Backend-independent error code. */
46
+ code: FileErrorCode;
47
+ /** Absolute addressed path associated with the failure, when available. */
48
+ path?: string | undefined;
49
+ constructor(
50
+ /** Backend-independent error code. */
51
+ code: FileErrorCode, message: string,
52
+ /** Absolute addressed path associated with the failure, when available. */
53
+ path?: string | undefined, options?: ErrorOptions);
54
+ }
55
+ /** Metadata for one filesystem object in an {@link ExecutionEnv}. */
56
+ export interface FileInfo {
57
+ /** Basename of {@link path}. */
58
+ name: string;
59
+ /** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */
60
+ path: string;
61
+ /** Object kind. Symlink targets are not followed; use {@link ExecutionEnv.resolvePath} explicitly. */
62
+ kind: FileKind;
63
+ /** Size in bytes for the addressed filesystem object. */
64
+ size: number;
65
+ /** Modification time as milliseconds since Unix epoch. */
66
+ mtimeMs: number;
67
+ }
68
+ /** Options for {@link ExecutionEnv.exec}. */
69
+ export interface ExecutionEnvExecOptions {
70
+ /** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. */
71
+ cwd?: string;
72
+ /** Additional environment variables for the command. Values override the environment defaults. */
73
+ env?: Record<string, string>;
74
+ /** Timeout in seconds. Implementations should reject when the command exceeds this duration. */
75
+ timeout?: number;
76
+ /** Abort signal used to terminate the command. */
77
+ signal?: AbortSignal;
78
+ /** Called with stdout chunks as they are produced. */
79
+ onStdout?: (chunk: string) => void;
80
+ /** Called with stderr chunks as they are produced. */
81
+ onStderr?: (chunk: string) => void;
82
+ }
83
+ /**
84
+ * Filesystem and process execution environment used by the harness.
85
+ *
86
+ * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by this interface are absolute
87
+ * addressed paths in the environment, but are not canonicalized through symlinks unless returned by {@link resolvePath}.
88
+ *
89
+ * File operations throw {@link FileError} for expected filesystem failures such as missing paths or permission errors.
90
+ */
91
+ export interface ExecutionEnv {
92
+ /** Current working directory for relative paths and command execution. */
93
+ cwd: string;
94
+ /** Execute a shell command in {@link cwd} unless `options.cwd` is provided. */
95
+ exec(command: string, options?: ExecutionEnvExecOptions): Promise<{
96
+ stdout: string;
97
+ stderr: string;
98
+ exitCode: number;
99
+ }>;
100
+ /** Read a UTF-8 text file. Throws {@link FileError}. */
101
+ readTextFile(path: string): Promise<string>;
102
+ /** Read a binary file. Throws {@link FileError}. */
103
+ readBinaryFile(path: string): Promise<Uint8Array>;
104
+ /** Create or overwrite a file, creating parent directories when supported. Throws {@link FileError}. */
105
+ writeFile(path: string, content: string | Uint8Array): Promise<void>;
106
+ /** Return metadata for the addressed path without following symlinks. Throws {@link FileError}. */
107
+ fileInfo(path: string): Promise<FileInfo>;
108
+ /** List direct children of a directory without following symlinks. Throws {@link FileError}. */
109
+ listDir(path: string): Promise<FileInfo[]>;
110
+ /** Return the canonical path for a path, following symlinks. Throws {@link FileError}. */
111
+ realPath(path: string): Promise<string>;
112
+ /** Return false for missing paths. Other errors, such as permission failures, may throw {@link FileError}. */
113
+ exists(path: string): Promise<boolean>;
114
+ /** Create a directory. */
115
+ createDir(path: string, options?: {
116
+ recursive?: boolean;
117
+ }): Promise<void>;
118
+ /** Remove a file or directory. */
119
+ remove(path: string, options?: {
120
+ recursive?: boolean;
121
+ force?: boolean;
122
+ }): Promise<void>;
123
+ /** Create a temporary directory and return its absolute path. */
124
+ createTempDir(prefix?: string): Promise<string>;
125
+ /** Create a temporary file and return its absolute path. */
126
+ createTempFile(options?: {
127
+ prefix?: string;
128
+ suffix?: string;
129
+ }): Promise<string>;
130
+ /** Release resources owned by the environment. */
131
+ cleanup(): Promise<void>;
132
+ }
133
+ export interface SessionTreeEntryBase {
134
+ type: string;
135
+ id: string;
136
+ parentId: string | null;
137
+ timestamp: string;
138
+ }
139
+ export interface MessageEntry extends SessionTreeEntryBase {
140
+ type: "message";
141
+ message: AgentMessage;
142
+ }
143
+ export interface ThinkingLevelChangeEntry extends SessionTreeEntryBase {
144
+ type: "thinking_level_change";
145
+ thinkingLevel: string;
146
+ }
147
+ export interface ModelChangeEntry extends SessionTreeEntryBase {
148
+ type: "model_change";
149
+ provider: string;
150
+ modelId: string;
151
+ }
152
+ export interface CompactionEntry<T = unknown> extends SessionTreeEntryBase {
153
+ type: "compaction";
154
+ summary: string;
155
+ firstKeptEntryId: string;
156
+ tokensBefore: number;
157
+ details?: T;
158
+ fromHook?: boolean;
159
+ }
160
+ export interface BranchSummaryEntry<T = unknown> extends SessionTreeEntryBase {
161
+ type: "branch_summary";
162
+ fromId: string;
163
+ summary: string;
164
+ details?: T;
165
+ fromHook?: boolean;
166
+ }
167
+ export interface CustomEntry<T = unknown> extends SessionTreeEntryBase {
168
+ type: "custom";
169
+ customType: string;
170
+ data?: T;
171
+ }
172
+ export interface CustomMessageEntry<T = unknown> extends SessionTreeEntryBase {
173
+ type: "custom_message";
174
+ customType: string;
175
+ content: string | (TextContent | ImageContent)[];
176
+ details?: T;
177
+ display: boolean;
178
+ }
179
+ export interface LabelEntry extends SessionTreeEntryBase {
180
+ type: "label";
181
+ targetId: string;
182
+ label: string | undefined;
183
+ }
184
+ export interface SessionInfoEntry extends SessionTreeEntryBase {
185
+ type: "session_info";
186
+ name?: string;
187
+ }
188
+ export type SessionTreeEntry = MessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | SessionInfoEntry;
189
+ export interface SessionContext {
190
+ messages: AgentMessage[];
191
+ thinkingLevel: string;
192
+ model: {
193
+ provider: string;
194
+ modelId: string;
195
+ } | null;
196
+ }
197
+ export interface SessionMetadata {
198
+ id: string;
199
+ createdAt: string;
200
+ }
201
+ export interface JsonlSessionMetadata extends SessionMetadata {
202
+ cwd: string;
203
+ path: string;
204
+ parentSessionPath?: string;
205
+ }
206
+ export interface SessionStorage<TMetadata extends SessionMetadata = SessionMetadata> {
207
+ getMetadata(): Promise<TMetadata>;
208
+ getLeafId(): Promise<string | null>;
209
+ setLeafId(leafId: string | null): Promise<void>;
210
+ createEntryId(): Promise<string>;
211
+ appendEntry(entry: SessionTreeEntry): Promise<void>;
212
+ getEntry(id: string): Promise<SessionTreeEntry | undefined>;
213
+ findEntries<TType extends SessionTreeEntry["type"]>(type: TType): Promise<Array<Extract<SessionTreeEntry, {
214
+ type: TType;
215
+ }>>>;
216
+ getLabel(id: string): Promise<string | undefined>;
217
+ getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]>;
218
+ getEntries(): Promise<SessionTreeEntry[]>;
219
+ }
220
+ export type { Session } from "./session/session.js";
221
+ export interface SessionCreateOptions {
222
+ id?: string;
223
+ }
224
+ export interface SessionForkOptions {
225
+ entryId?: string;
226
+ position?: "before" | "at";
227
+ id?: string;
228
+ }
229
+ export interface SessionRepo<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends SessionCreateOptions = SessionCreateOptions, TListOptions = void> {
230
+ create(options: TCreateOptions): Promise<Session<TMetadata>>;
231
+ open(metadata: TMetadata): Promise<Session<TMetadata>>;
232
+ list(options?: TListOptions): Promise<TMetadata[]>;
233
+ delete(metadata: TMetadata): Promise<void>;
234
+ fork(source: TMetadata, options: SessionForkOptions & TCreateOptions): Promise<Session<TMetadata>>;
235
+ }
236
+ export interface JsonlSessionCreateOptions extends SessionCreateOptions {
237
+ cwd: string;
238
+ parentSessionPath?: string;
239
+ }
240
+ export interface JsonlSessionListOptions {
241
+ cwd?: string;
242
+ }
243
+ export interface JsonlSessionRepoApi extends SessionRepo<JsonlSessionMetadata, JsonlSessionCreateOptions, JsonlSessionListOptions> {
244
+ }
245
+ export type AgentHarnessPhase = "idle" | "turn" | "compaction" | "branch_summary" | "retry";
246
+ export type PendingSessionWrite = SessionTreeEntry extends infer TEntry ? TEntry extends SessionTreeEntry ? Omit<TEntry, "id" | "parentId" | "timestamp"> : never : never;
247
+ export interface AgentHarnessTurnState<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate, TTool extends AgentTool = AgentTool> {
248
+ messages: AgentMessage[];
249
+ resources: AgentHarnessResources<TSkill, TPromptTemplate>;
250
+ systemPrompt: string;
251
+ model: Model<any>;
252
+ thinkingLevel: ThinkingLevel;
253
+ tools: TTool[];
254
+ activeTools: TTool[];
255
+ }
256
+ export interface QueueUpdateEvent {
257
+ type: "queue_update";
258
+ steer: AgentMessage[];
259
+ followUp: AgentMessage[];
260
+ nextTurn: AgentMessage[];
261
+ }
262
+ export interface SavePointEvent {
263
+ type: "save_point";
264
+ hadPendingMutations: boolean;
265
+ }
266
+ export interface AbortEvent {
267
+ type: "abort";
268
+ clearedSteer: AgentMessage[];
269
+ clearedFollowUp: AgentMessage[];
270
+ }
271
+ export interface SettledEvent {
272
+ type: "settled";
273
+ nextTurnCount: number;
274
+ }
275
+ export interface BeforeAgentStartEvent<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> {
276
+ type: "before_agent_start";
277
+ prompt: string;
278
+ images?: ImageContent[];
279
+ systemPrompt: string;
280
+ resources: AgentHarnessResources<TSkill, TPromptTemplate>;
281
+ }
282
+ export interface ContextEvent {
283
+ type: "context";
284
+ messages: AgentMessage[];
285
+ }
286
+ export interface BeforeProviderRequestEvent {
287
+ type: "before_provider_request";
288
+ payload: unknown;
289
+ }
290
+ export interface AfterProviderResponseEvent {
291
+ type: "after_provider_response";
292
+ status: number;
293
+ headers: Record<string, string>;
294
+ }
295
+ export interface ToolCallEvent {
296
+ type: "tool_call";
297
+ toolCallId: string;
298
+ toolName: string;
299
+ input: Record<string, unknown>;
300
+ }
301
+ export interface ToolResultEvent {
302
+ type: "tool_result";
303
+ toolCallId: string;
304
+ toolName: string;
305
+ input: Record<string, unknown>;
306
+ content: Array<TextContent | ImageContent>;
307
+ details: unknown;
308
+ isError: boolean;
309
+ }
310
+ export interface SessionBeforeCompactEvent {
311
+ type: "session_before_compact";
312
+ preparation: CompactionPreparation;
313
+ branchEntries: SessionTreeEntry[];
314
+ customInstructions?: string;
315
+ signal: AbortSignal;
316
+ }
317
+ export interface SessionCompactEvent {
318
+ type: "session_compact";
319
+ compactionEntry: CompactionEntry;
320
+ fromHook: boolean;
321
+ }
322
+ export interface SessionBeforeTreeEvent {
323
+ type: "session_before_tree";
324
+ preparation: TreePreparation;
325
+ signal: AbortSignal;
326
+ }
327
+ export interface SessionTreeEvent {
328
+ type: "session_tree";
329
+ newLeafId: string | null;
330
+ oldLeafId: string | null;
331
+ summaryEntry?: BranchSummaryEntry;
332
+ fromHook?: boolean;
333
+ }
334
+ export interface ModelSelectEvent {
335
+ type: "model_select";
336
+ model: Model<any>;
337
+ previousModel: Model<any> | undefined;
338
+ source: "set" | "restore";
339
+ }
340
+ export interface ThinkingLevelSelectEvent {
341
+ type: "thinking_level_select";
342
+ level: ThinkingLevel;
343
+ previousLevel: ThinkingLevel;
344
+ }
345
+ export interface ResourcesUpdateEvent<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> {
346
+ type: "resources_update";
347
+ resources: AgentHarnessResources<TSkill, TPromptTemplate>;
348
+ previousResources: AgentHarnessResources<TSkill, TPromptTemplate>;
349
+ }
350
+ export type AgentHarnessOwnEvent<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> = QueueUpdateEvent | SavePointEvent | AbortEvent | SettledEvent | BeforeAgentStartEvent<TSkill, TPromptTemplate> | ContextEvent | BeforeProviderRequestEvent | AfterProviderResponseEvent | ToolCallEvent | ToolResultEvent | SessionBeforeCompactEvent | SessionCompactEvent | SessionBeforeTreeEvent | SessionTreeEvent | ModelSelectEvent | ThinkingLevelSelectEvent | ResourcesUpdateEvent<TSkill, TPromptTemplate>;
351
+ export type AgentHarnessEvent<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> = AgentEvent | AgentHarnessOwnEvent<TSkill, TPromptTemplate>;
352
+ export interface BeforeAgentStartResult {
353
+ messages?: AgentMessage[];
354
+ systemPrompt?: string;
355
+ }
356
+ export interface ContextResult {
357
+ messages: AgentMessage[];
358
+ }
359
+ export interface BeforeProviderRequestResult {
360
+ payload: unknown;
361
+ }
362
+ export interface ToolCallResult {
363
+ block?: boolean;
364
+ reason?: string;
365
+ }
366
+ export interface ToolResultPatch {
367
+ content?: Array<TextContent | ImageContent>;
368
+ details?: unknown;
369
+ isError?: boolean;
370
+ terminate?: boolean;
371
+ }
372
+ export interface SessionBeforeCompactResult {
373
+ cancel?: boolean;
374
+ compaction?: CompactResult;
375
+ }
376
+ export interface SessionBeforeTreeResult {
377
+ cancel?: boolean;
378
+ summary?: {
379
+ summary: string;
380
+ details?: unknown;
381
+ };
382
+ customInstructions?: string;
383
+ replaceInstructions?: boolean;
384
+ label?: string;
385
+ }
386
+ export type AgentHarnessEventResultMap = {
387
+ before_agent_start: BeforeAgentStartResult | undefined;
388
+ context: ContextResult | undefined;
389
+ before_provider_request: BeforeProviderRequestResult | undefined;
390
+ after_provider_response: undefined;
391
+ tool_call: ToolCallResult | undefined;
392
+ tool_result: ToolResultPatch | undefined;
393
+ session_before_compact: SessionBeforeCompactResult | undefined;
394
+ session_compact: undefined;
395
+ session_before_tree: SessionBeforeTreeResult | undefined;
396
+ session_tree: undefined;
397
+ model_select: undefined;
398
+ thinking_level_select: undefined;
399
+ resources_update: undefined;
400
+ queue_update: undefined;
401
+ save_point: undefined;
402
+ abort: undefined;
403
+ settled: undefined;
404
+ };
405
+ export interface AgentHarnessPromptOptions {
406
+ images?: ImageContent[];
407
+ }
408
+ export interface AbortResult {
409
+ clearedSteer: AgentMessage[];
410
+ clearedFollowUp: AgentMessage[];
411
+ }
412
+ export interface CompactResult {
413
+ summary: string;
414
+ firstKeptEntryId: string;
415
+ tokensBefore: number;
416
+ details?: unknown;
417
+ }
418
+ export interface NavigateTreeResult {
419
+ cancelled: boolean;
420
+ editorText?: string;
421
+ summaryEntry?: BranchSummaryEntry;
422
+ }
423
+ export interface CompactionSettings {
424
+ enabled: boolean;
425
+ reserveTokens: number;
426
+ keepRecentTokens: number;
427
+ }
428
+ export interface CompactionPreparation {
429
+ firstKeptEntryId: string;
430
+ messagesToSummarize: AgentMessage[];
431
+ turnPrefixMessages: AgentMessage[];
432
+ isSplitTurn: boolean;
433
+ tokensBefore: number;
434
+ previousSummary?: string;
435
+ fileOps: FileOperations;
436
+ settings: CompactionSettings;
437
+ }
438
+ export interface FileOperations {
439
+ read: Set<string>;
440
+ written: Set<string>;
441
+ edited: Set<string>;
442
+ }
443
+ export interface TreePreparation {
444
+ targetId: string;
445
+ oldLeafId: string | null;
446
+ commonAncestorId: string | null;
447
+ entriesToSummarize: SessionTreeEntry[];
448
+ userWantsSummary: boolean;
449
+ customInstructions?: string;
450
+ replaceInstructions?: boolean;
451
+ label?: string;
452
+ }
453
+ export interface GenerateBranchSummaryOptions {
454
+ model: Model<any>;
455
+ apiKey: string;
456
+ headers?: Record<string, string>;
457
+ signal: AbortSignal;
458
+ customInstructions?: string;
459
+ replaceInstructions?: boolean;
460
+ reserveTokens?: number;
461
+ }
462
+ export interface BranchSummaryResult {
463
+ summary?: string;
464
+ readFiles?: string[];
465
+ modifiedFiles?: string[];
466
+ aborted?: boolean;
467
+ error?: string;
468
+ }
469
+ export interface AgentHarnessOptions<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate, TTool extends AgentTool = AgentTool> {
470
+ env: ExecutionEnv;
471
+ session: Session;
472
+ tools?: TTool[];
473
+ /**
474
+ * Concrete resources available to explicit invocation methods and system-prompt callbacks.
475
+ * Applications own loading/reloading resources and should call `setResources()` with new values.
476
+ */
477
+ resources?: AgentHarnessResources<TSkill, TPromptTemplate>;
478
+ systemPrompt?: string | ((context: {
479
+ env: ExecutionEnv;
480
+ session: Session;
481
+ model: Model<any>;
482
+ thinkingLevel: ThinkingLevel;
483
+ activeTools: TTool[];
484
+ resources: AgentHarnessResources<TSkill, TPromptTemplate>;
485
+ }) => string | Promise<string>);
486
+ getApiKeyAndHeaders?: (model: Model<any>) => Promise<{
487
+ apiKey: string;
488
+ headers?: Record<string, string>;
489
+ } | undefined>;
490
+ model: Model<any>;
491
+ thinkingLevel?: ThinkingLevel;
492
+ activeToolNames?: string[];
493
+ steeringMode?: QueueMode;
494
+ followUpMode?: QueueMode;
495
+ }
496
+ export type { AgentHarness } from "./agent-harness.js";
497
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CA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AE;QACX,GAAG,EAAE,YAAY,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAClB,aAAa,EAAE,aAAa,CAAC;QAC7B,WAAW,EAAE,KAAK,EAAE,CAAC;QACrB,SAAS,EAAE,qBAAqB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;KACzD,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACnC,mBAAmB,CAAC,EAAE,CACrB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KACb,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAC/E,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;CACzB;AAED,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["import type { ImageContent, Model, TextContent } from \"@elyracode/ai\";\nimport type { QueueMode } from \"../agent.js\";\nimport type { AgentEvent, AgentMessage, AgentTool, ThinkingLevel } from \"../index.js\";\nimport type { Session } from \"./session/session.js\";\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Kind of filesystem object as addressed by an {@link ExecutionEnv}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes thrown by {@link ExecutionEnv} file operations. */\nexport type FileErrorCode =\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error thrown by {@link ExecutionEnv} file operations. */\nexport class FileError extends Error {\n\tconstructor(\n\t\t/** Backend-independent error code. */\n\t\tpublic code: FileErrorCode,\n\t\tmessage: string,\n\t\t/** Absolute addressed path associated with the failure, when available. */\n\t\tpublic path?: string,\n\t\toptions?: ErrorOptions,\n\t) {\n\t\tsuper(message, options);\n\t\tthis.name = \"FileError\";\n\t}\n}\n\n/** Metadata for one filesystem object in an {@link ExecutionEnv}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link ExecutionEnv.resolvePath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/** Options for {@link ExecutionEnv.exec}. */\nexport interface ExecutionEnvExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Additional environment variables for the command. Values override the environment defaults. */\n\tenv?: Record<string, string>;\n\t/** Timeout in seconds. Implementations should reject when the command exceeds this duration. */\n\ttimeout?: number;\n\t/** Abort signal used to terminate the command. */\n\tsignal?: AbortSignal;\n\t/** Called with stdout chunks as they are produced. */\n\tonStdout?: (chunk: string) => void;\n\t/** Called with stderr chunks as they are produced. */\n\tonStderr?: (chunk: string) => void;\n}\n\n/**\n * Filesystem and process execution environment used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by this interface are absolute\n * addressed paths in the environment, but are not canonicalized through symlinks unless returned by {@link resolvePath}.\n *\n * File operations throw {@link FileError} for expected filesystem failures such as missing paths or permission errors.\n */\nexport interface ExecutionEnv {\n\t/** Current working directory for relative paths and command execution. */\n\tcwd: string;\n\n\t/** Execute a shell command in {@link cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions?: ExecutionEnvExecOptions,\n\t): Promise<{ stdout: string; stderr: string; exitCode: number }>;\n\n\t/** Read a UTF-8 text file. Throws {@link FileError}. */\n\treadTextFile(path: string): Promise<string>;\n\t/** Read a binary file. Throws {@link FileError}. */\n\treadBinaryFile(path: string): Promise<Uint8Array>;\n\t/** Create or overwrite a file, creating parent directories when supported. Throws {@link FileError}. */\n\twriteFile(path: string, content: string | Uint8Array): Promise<void>;\n\t/** Return metadata for the addressed path without following symlinks. Throws {@link FileError}. */\n\tfileInfo(path: string): Promise<FileInfo>;\n\t/** List direct children of a directory without following symlinks. Throws {@link FileError}. */\n\tlistDir(path: string): Promise<FileInfo[]>;\n\t/** Return the canonical path for a path, following symlinks. Throws {@link FileError}. */\n\trealPath(path: string): Promise<string>;\n\t/** Return false for missing paths. Other errors, such as permission failures, may throw {@link FileError}. */\n\texists(path: string): Promise<boolean>;\n\t/** Create a directory. */\n\tcreateDir(path: string, options?: { recursive?: boolean }): Promise<void>;\n\t/** Remove a file or directory. */\n\tremove(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void>;\n\t/** Create a temporary directory and return its absolute path. */\n\tcreateTempDir(prefix?: string): Promise<string>;\n\t/** Create a temporary file and return its absolute path. */\n\tcreateTempFile(options?: { prefix?: string; suffix?: string }): Promise<string>;\n\n\t/** Release resources owned by the environment. */\n\tcleanup(): Promise<void>;\n}\n\nexport interface SessionTreeEntryBase {\n\ttype: string;\n\tid: string;\n\tparentId: string | null;\n\ttimestamp: string;\n}\n\nexport interface MessageEntry extends SessionTreeEntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n}\n\nexport interface ThinkingLevelChangeEntry extends SessionTreeEntryBase {\n\ttype: \"thinking_level_change\";\n\tthinkingLevel: string;\n}\n\nexport interface ModelChangeEntry extends SessionTreeEntryBase {\n\ttype: \"model_change\";\n\tprovider: string;\n\tmodelId: string;\n}\n\nexport interface CompactionEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\tdetails?: T;\n\tfromHook?: boolean;\n}\n\nexport interface BranchSummaryEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string;\n\tsummary: string;\n\tdetails?: T;\n\tfromHook?: boolean;\n}\n\nexport interface CustomEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: T;\n}\n\nexport interface CustomMessageEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"custom_message\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdetails?: T;\n\tdisplay: boolean;\n}\n\nexport interface LabelEntry extends SessionTreeEntryBase {\n\ttype: \"label\";\n\ttargetId: string;\n\tlabel: string | undefined;\n}\n\nexport interface SessionInfoEntry extends SessionTreeEntryBase {\n\ttype: \"session_info\"; // legacy name, kept for backwards compatibility\n\tname?: string;\n}\n\nexport type SessionTreeEntry =\n\t| MessageEntry\n\t| ThinkingLevelChangeEntry\n\t| ModelChangeEntry\n\t| CompactionEntry\n\t| BranchSummaryEntry\n\t| CustomEntry\n\t| CustomMessageEntry\n\t| LabelEntry\n\t| SessionInfoEntry;\n\nexport interface SessionContext {\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n}\n\nexport interface SessionMetadata {\n\tid: string;\n\tcreatedAt: string;\n}\n\nexport interface JsonlSessionMetadata extends SessionMetadata {\n\tcwd: string;\n\tpath: string;\n\tparentSessionPath?: string;\n}\n\nexport interface SessionStorage<TMetadata extends SessionMetadata = SessionMetadata> {\n\tgetMetadata(): Promise<TMetadata>;\n\tgetLeafId(): Promise<string | null>;\n\tsetLeafId(leafId: string | null): Promise<void>;\n\tcreateEntryId(): Promise<string>;\n\tappendEntry(entry: SessionTreeEntry): Promise<void>;\n\tgetEntry(id: string): Promise<SessionTreeEntry | undefined>;\n\tfindEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>>;\n\tgetLabel(id: string): Promise<string | undefined>;\n\tgetPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]>;\n\tgetEntries(): Promise<SessionTreeEntry[]>;\n}\n\nexport type { Session } from \"./session/session.js\";\n\nexport interface SessionCreateOptions {\n\tid?: string;\n}\n\nexport interface SessionForkOptions {\n\tentryId?: string;\n\tposition?: \"before\" | \"at\";\n\tid?: string;\n}\n\nexport interface SessionRepo<\n\tTMetadata extends SessionMetadata = SessionMetadata,\n\tTCreateOptions extends SessionCreateOptions = SessionCreateOptions,\n\tTListOptions = void,\n> {\n\tcreate(options: TCreateOptions): Promise<Session<TMetadata>>;\n\topen(metadata: TMetadata): Promise<Session<TMetadata>>;\n\tlist(options?: TListOptions): Promise<TMetadata[]>;\n\tdelete(metadata: TMetadata): Promise<void>;\n\tfork(source: TMetadata, options: SessionForkOptions & TCreateOptions): Promise<Session<TMetadata>>;\n}\n\nexport interface JsonlSessionCreateOptions extends SessionCreateOptions {\n\tcwd: string;\n\tparentSessionPath?: string;\n}\n\nexport interface JsonlSessionListOptions {\n\tcwd?: string;\n}\n\nexport interface JsonlSessionRepoApi\n\textends SessionRepo<JsonlSessionMetadata, JsonlSessionCreateOptions, JsonlSessionListOptions> {}\n\nexport type AgentHarnessPhase = \"idle\" | \"turn\" | \"compaction\" | \"branch_summary\" | \"retry\";\n\nexport type PendingSessionWrite = SessionTreeEntry extends infer TEntry\n\t? TEntry extends SessionTreeEntry\n\t\t? Omit<TEntry, \"id\" | \"parentId\" | \"timestamp\">\n\t\t: never\n\t: never;\n\nexport interface AgentHarnessTurnState<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n\tTTool extends AgentTool = AgentTool,\n> {\n\tmessages: AgentMessage[];\n\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n\tsystemPrompt: string;\n\tmodel: Model<any>;\n\tthinkingLevel: ThinkingLevel;\n\ttools: TTool[];\n\tactiveTools: TTool[];\n}\n\nexport interface QueueUpdateEvent {\n\ttype: \"queue_update\";\n\tsteer: AgentMessage[];\n\tfollowUp: AgentMessage[];\n\tnextTurn: AgentMessage[];\n}\n\nexport interface SavePointEvent {\n\ttype: \"save_point\";\n\thadPendingMutations: boolean;\n}\n\nexport interface AbortEvent {\n\ttype: \"abort\";\n\tclearedSteer: AgentMessage[];\n\tclearedFollowUp: AgentMessage[];\n}\n\nexport interface SettledEvent {\n\ttype: \"settled\";\n\tnextTurnCount: number;\n}\n\nexport interface BeforeAgentStartEvent<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\ttype: \"before_agent_start\";\n\tprompt: string;\n\timages?: ImageContent[];\n\tsystemPrompt: string;\n\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n}\n\nexport interface ContextEvent {\n\ttype: \"context\";\n\tmessages: AgentMessage[];\n}\n\nexport interface BeforeProviderRequestEvent {\n\ttype: \"before_provider_request\";\n\tpayload: unknown;\n}\n\nexport interface AfterProviderResponseEvent {\n\ttype: \"after_provider_response\";\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\nexport interface ToolCallEvent {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\nexport interface ToolResultEvent {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n\tcontent: Array<TextContent | ImageContent>;\n\tdetails: unknown;\n\tisError: boolean;\n}\n\nexport interface SessionBeforeCompactEvent {\n\ttype: \"session_before_compact\";\n\tpreparation: CompactionPreparation;\n\tbranchEntries: SessionTreeEntry[];\n\tcustomInstructions?: string;\n\tsignal: AbortSignal;\n}\n\nexport interface SessionCompactEvent {\n\ttype: \"session_compact\";\n\tcompactionEntry: CompactionEntry;\n\tfromHook: boolean;\n}\n\nexport interface SessionBeforeTreeEvent {\n\ttype: \"session_before_tree\";\n\tpreparation: TreePreparation;\n\tsignal: AbortSignal;\n}\n\nexport interface SessionTreeEvent {\n\ttype: \"session_tree\";\n\tnewLeafId: string | null;\n\toldLeafId: string | null;\n\tsummaryEntry?: BranchSummaryEntry;\n\tfromHook?: boolean;\n}\n\nexport interface ModelSelectEvent {\n\ttype: \"model_select\";\n\tmodel: Model<any>;\n\tpreviousModel: Model<any> | undefined;\n\tsource: \"set\" | \"restore\";\n}\n\nexport interface ThinkingLevelSelectEvent {\n\ttype: \"thinking_level_select\";\n\tlevel: ThinkingLevel;\n\tpreviousLevel: ThinkingLevel;\n}\n\nexport interface ResourcesUpdateEvent<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\ttype: \"resources_update\";\n\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n\tpreviousResources: AgentHarnessResources<TSkill, TPromptTemplate>;\n}\n\nexport type AgentHarnessOwnEvent<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> =\n\t| QueueUpdateEvent\n\t| SavePointEvent\n\t| AbortEvent\n\t| SettledEvent\n\t| BeforeAgentStartEvent<TSkill, TPromptTemplate>\n\t| ContextEvent\n\t| BeforeProviderRequestEvent\n\t| AfterProviderResponseEvent\n\t| ToolCallEvent\n\t| ToolResultEvent\n\t| SessionBeforeCompactEvent\n\t| SessionCompactEvent\n\t| SessionBeforeTreeEvent\n\t| SessionTreeEvent\n\t| ModelSelectEvent\n\t| ThinkingLevelSelectEvent\n\t| ResourcesUpdateEvent<TSkill, TPromptTemplate>;\n\nexport type AgentHarnessEvent<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> =\n\t| AgentEvent\n\t| AgentHarnessOwnEvent<TSkill, TPromptTemplate>;\n\nexport interface BeforeAgentStartResult {\n\tmessages?: AgentMessage[];\n\tsystemPrompt?: string;\n}\n\nexport interface ContextResult {\n\tmessages: AgentMessage[];\n}\n\nexport interface BeforeProviderRequestResult {\n\tpayload: unknown;\n}\n\nexport interface ToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n}\n\nexport interface ToolResultPatch {\n\tcontent?: Array<TextContent | ImageContent>;\n\tdetails?: unknown;\n\tisError?: boolean;\n\tterminate?: boolean;\n}\n\nexport interface SessionBeforeCompactResult {\n\tcancel?: boolean;\n\tcompaction?: CompactResult;\n}\n\nexport interface SessionBeforeTreeResult {\n\tcancel?: boolean;\n\tsummary?: { summary: string; details?: unknown };\n\tcustomInstructions?: string;\n\treplaceInstructions?: boolean;\n\tlabel?: string;\n}\n\nexport type AgentHarnessEventResultMap = {\n\tbefore_agent_start: BeforeAgentStartResult | undefined;\n\tcontext: ContextResult | undefined;\n\tbefore_provider_request: BeforeProviderRequestResult | undefined;\n\tafter_provider_response: undefined;\n\ttool_call: ToolCallResult | undefined;\n\ttool_result: ToolResultPatch | undefined;\n\tsession_before_compact: SessionBeforeCompactResult | undefined;\n\tsession_compact: undefined;\n\tsession_before_tree: SessionBeforeTreeResult | undefined;\n\tsession_tree: undefined;\n\tmodel_select: undefined;\n\tthinking_level_select: undefined;\n\tresources_update: undefined;\n\tqueue_update: undefined;\n\tsave_point: undefined;\n\tabort: undefined;\n\tsettled: undefined;\n};\n\nexport interface AgentHarnessPromptOptions {\n\timages?: ImageContent[];\n}\n\nexport interface AbortResult {\n\tclearedSteer: AgentMessage[];\n\tclearedFollowUp: AgentMessage[];\n}\n\nexport interface CompactResult {\n\tsummary: string;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\tdetails?: unknown;\n}\n\nexport interface NavigateTreeResult {\n\tcancelled: boolean;\n\teditorText?: string;\n\tsummaryEntry?: BranchSummaryEntry;\n}\n\nexport interface CompactionSettings {\n\tenabled: boolean;\n\treserveTokens: number;\n\tkeepRecentTokens: number;\n}\n\nexport interface CompactionPreparation {\n\tfirstKeptEntryId: string;\n\tmessagesToSummarize: AgentMessage[];\n\tturnPrefixMessages: AgentMessage[];\n\tisSplitTurn: boolean;\n\ttokensBefore: number;\n\tpreviousSummary?: string;\n\tfileOps: FileOperations;\n\tsettings: CompactionSettings;\n}\n\nexport interface FileOperations {\n\tread: Set<string>;\n\twritten: Set<string>;\n\tedited: Set<string>;\n}\n\nexport interface TreePreparation {\n\ttargetId: string;\n\toldLeafId: string | null;\n\tcommonAncestorId: string | null;\n\tentriesToSummarize: SessionTreeEntry[];\n\tuserWantsSummary: boolean;\n\tcustomInstructions?: string;\n\treplaceInstructions?: boolean;\n\tlabel?: string;\n}\n\nexport interface GenerateBranchSummaryOptions {\n\tmodel: Model<any>;\n\tapiKey: string;\n\theaders?: Record<string, string>;\n\tsignal: AbortSignal;\n\tcustomInstructions?: string;\n\treplaceInstructions?: boolean;\n\treserveTokens?: number;\n}\n\nexport interface BranchSummaryResult {\n\tsummary?: string;\n\treadFiles?: string[];\n\tmodifiedFiles?: string[];\n\taborted?: boolean;\n\terror?: string;\n}\n\nexport interface AgentHarnessOptions<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n\tTTool extends AgentTool = AgentTool,\n> {\n\tenv: ExecutionEnv;\n\tsession: Session;\n\ttools?: TTool[];\n\t/**\n\t * Concrete resources available to explicit invocation methods and system-prompt callbacks.\n\t * Applications own loading/reloading resources and should call `setResources()` with new values.\n\t */\n\tresources?: AgentHarnessResources<TSkill, TPromptTemplate>;\n\tsystemPrompt?:\n\t\t| string\n\t\t| ((context: {\n\t\t\t\tenv: ExecutionEnv;\n\t\t\t\tsession: Session;\n\t\t\t\tmodel: Model<any>;\n\t\t\t\tthinkingLevel: ThinkingLevel;\n\t\t\t\tactiveTools: TTool[];\n\t\t\t\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n\t\t }) => string | Promise<string>);\n\tgetApiKeyAndHeaders?: (\n\t\tmodel: Model<any>,\n\t) => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tmodel: Model<any>;\n\tthinkingLevel?: ThinkingLevel;\n\tactiveToolNames?: string[];\n\tsteeringMode?: QueueMode;\n\tfollowUpMode?: QueueMode;\n}\n\nexport type { AgentHarness } from \"./agent-harness.js\";\n"]}
@@ -0,0 +1,16 @@
1
+ /** Error thrown by {@link ExecutionEnv} file operations. */
2
+ export class FileError extends Error {
3
+ code;
4
+ path;
5
+ constructor(
6
+ /** Backend-independent error code. */
7
+ code, message,
8
+ /** Absolute addressed path associated with the failure, when available. */
9
+ path, options) {
10
+ super(message, options);
11
+ this.code = code;
12
+ this.path = path;
13
+ this.name = "FileError";
14
+ }
15
+ }
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AA0DA,4DAA4D;AAC5D,MAAM,OAAO,SAAU,SAAQ,KAAK;IAG3B,IAAI;IAGJ,IAAI;IALZ;IACC,sCAAsC;IAC/B,IAAmB,EAC1B,OAAe;IACf,2EAA2E;IACpE,IAAa,EACpB,OAAsB,EACrB;QACD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBANjB,IAAI;oBAGJ,IAAI;QAIX,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAAA,CACxB;CACD","sourcesContent":["import type { ImageContent, Model, TextContent } from \"@elyracode/ai\";\nimport type { QueueMode } from \"../agent.js\";\nimport type { AgentEvent, AgentMessage, AgentTool, ThinkingLevel } from \"../index.js\";\nimport type { Session } from \"./session/session.js\";\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Kind of filesystem object as addressed by an {@link ExecutionEnv}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes thrown by {@link ExecutionEnv} file operations. */\nexport type FileErrorCode =\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error thrown by {@link ExecutionEnv} file operations. */\nexport class FileError extends Error {\n\tconstructor(\n\t\t/** Backend-independent error code. */\n\t\tpublic code: FileErrorCode,\n\t\tmessage: string,\n\t\t/** Absolute addressed path associated with the failure, when available. */\n\t\tpublic path?: string,\n\t\toptions?: ErrorOptions,\n\t) {\n\t\tsuper(message, options);\n\t\tthis.name = \"FileError\";\n\t}\n}\n\n/** Metadata for one filesystem object in an {@link ExecutionEnv}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link ExecutionEnv.resolvePath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/** Options for {@link ExecutionEnv.exec}. */\nexport interface ExecutionEnvExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Additional environment variables for the command. Values override the environment defaults. */\n\tenv?: Record<string, string>;\n\t/** Timeout in seconds. Implementations should reject when the command exceeds this duration. */\n\ttimeout?: number;\n\t/** Abort signal used to terminate the command. */\n\tsignal?: AbortSignal;\n\t/** Called with stdout chunks as they are produced. */\n\tonStdout?: (chunk: string) => void;\n\t/** Called with stderr chunks as they are produced. */\n\tonStderr?: (chunk: string) => void;\n}\n\n/**\n * Filesystem and process execution environment used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by this interface are absolute\n * addressed paths in the environment, but are not canonicalized through symlinks unless returned by {@link resolvePath}.\n *\n * File operations throw {@link FileError} for expected filesystem failures such as missing paths or permission errors.\n */\nexport interface ExecutionEnv {\n\t/** Current working directory for relative paths and command execution. */\n\tcwd: string;\n\n\t/** Execute a shell command in {@link cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions?: ExecutionEnvExecOptions,\n\t): Promise<{ stdout: string; stderr: string; exitCode: number }>;\n\n\t/** Read a UTF-8 text file. Throws {@link FileError}. */\n\treadTextFile(path: string): Promise<string>;\n\t/** Read a binary file. Throws {@link FileError}. */\n\treadBinaryFile(path: string): Promise<Uint8Array>;\n\t/** Create or overwrite a file, creating parent directories when supported. Throws {@link FileError}. */\n\twriteFile(path: string, content: string | Uint8Array): Promise<void>;\n\t/** Return metadata for the addressed path without following symlinks. Throws {@link FileError}. */\n\tfileInfo(path: string): Promise<FileInfo>;\n\t/** List direct children of a directory without following symlinks. Throws {@link FileError}. */\n\tlistDir(path: string): Promise<FileInfo[]>;\n\t/** Return the canonical path for a path, following symlinks. Throws {@link FileError}. */\n\trealPath(path: string): Promise<string>;\n\t/** Return false for missing paths. Other errors, such as permission failures, may throw {@link FileError}. */\n\texists(path: string): Promise<boolean>;\n\t/** Create a directory. */\n\tcreateDir(path: string, options?: { recursive?: boolean }): Promise<void>;\n\t/** Remove a file or directory. */\n\tremove(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void>;\n\t/** Create a temporary directory and return its absolute path. */\n\tcreateTempDir(prefix?: string): Promise<string>;\n\t/** Create a temporary file and return its absolute path. */\n\tcreateTempFile(options?: { prefix?: string; suffix?: string }): Promise<string>;\n\n\t/** Release resources owned by the environment. */\n\tcleanup(): Promise<void>;\n}\n\nexport interface SessionTreeEntryBase {\n\ttype: string;\n\tid: string;\n\tparentId: string | null;\n\ttimestamp: string;\n}\n\nexport interface MessageEntry extends SessionTreeEntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n}\n\nexport interface ThinkingLevelChangeEntry extends SessionTreeEntryBase {\n\ttype: \"thinking_level_change\";\n\tthinkingLevel: string;\n}\n\nexport interface ModelChangeEntry extends SessionTreeEntryBase {\n\ttype: \"model_change\";\n\tprovider: string;\n\tmodelId: string;\n}\n\nexport interface CompactionEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\tdetails?: T;\n\tfromHook?: boolean;\n}\n\nexport interface BranchSummaryEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string;\n\tsummary: string;\n\tdetails?: T;\n\tfromHook?: boolean;\n}\n\nexport interface CustomEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: T;\n}\n\nexport interface CustomMessageEntry<T = unknown> extends SessionTreeEntryBase {\n\ttype: \"custom_message\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdetails?: T;\n\tdisplay: boolean;\n}\n\nexport interface LabelEntry extends SessionTreeEntryBase {\n\ttype: \"label\";\n\ttargetId: string;\n\tlabel: string | undefined;\n}\n\nexport interface SessionInfoEntry extends SessionTreeEntryBase {\n\ttype: \"session_info\"; // legacy name, kept for backwards compatibility\n\tname?: string;\n}\n\nexport type SessionTreeEntry =\n\t| MessageEntry\n\t| ThinkingLevelChangeEntry\n\t| ModelChangeEntry\n\t| CompactionEntry\n\t| BranchSummaryEntry\n\t| CustomEntry\n\t| CustomMessageEntry\n\t| LabelEntry\n\t| SessionInfoEntry;\n\nexport interface SessionContext {\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n}\n\nexport interface SessionMetadata {\n\tid: string;\n\tcreatedAt: string;\n}\n\nexport interface JsonlSessionMetadata extends SessionMetadata {\n\tcwd: string;\n\tpath: string;\n\tparentSessionPath?: string;\n}\n\nexport interface SessionStorage<TMetadata extends SessionMetadata = SessionMetadata> {\n\tgetMetadata(): Promise<TMetadata>;\n\tgetLeafId(): Promise<string | null>;\n\tsetLeafId(leafId: string | null): Promise<void>;\n\tcreateEntryId(): Promise<string>;\n\tappendEntry(entry: SessionTreeEntry): Promise<void>;\n\tgetEntry(id: string): Promise<SessionTreeEntry | undefined>;\n\tfindEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>>;\n\tgetLabel(id: string): Promise<string | undefined>;\n\tgetPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]>;\n\tgetEntries(): Promise<SessionTreeEntry[]>;\n}\n\nexport type { Session } from \"./session/session.js\";\n\nexport interface SessionCreateOptions {\n\tid?: string;\n}\n\nexport interface SessionForkOptions {\n\tentryId?: string;\n\tposition?: \"before\" | \"at\";\n\tid?: string;\n}\n\nexport interface SessionRepo<\n\tTMetadata extends SessionMetadata = SessionMetadata,\n\tTCreateOptions extends SessionCreateOptions = SessionCreateOptions,\n\tTListOptions = void,\n> {\n\tcreate(options: TCreateOptions): Promise<Session<TMetadata>>;\n\topen(metadata: TMetadata): Promise<Session<TMetadata>>;\n\tlist(options?: TListOptions): Promise<TMetadata[]>;\n\tdelete(metadata: TMetadata): Promise<void>;\n\tfork(source: TMetadata, options: SessionForkOptions & TCreateOptions): Promise<Session<TMetadata>>;\n}\n\nexport interface JsonlSessionCreateOptions extends SessionCreateOptions {\n\tcwd: string;\n\tparentSessionPath?: string;\n}\n\nexport interface JsonlSessionListOptions {\n\tcwd?: string;\n}\n\nexport interface JsonlSessionRepoApi\n\textends SessionRepo<JsonlSessionMetadata, JsonlSessionCreateOptions, JsonlSessionListOptions> {}\n\nexport type AgentHarnessPhase = \"idle\" | \"turn\" | \"compaction\" | \"branch_summary\" | \"retry\";\n\nexport type PendingSessionWrite = SessionTreeEntry extends infer TEntry\n\t? TEntry extends SessionTreeEntry\n\t\t? Omit<TEntry, \"id\" | \"parentId\" | \"timestamp\">\n\t\t: never\n\t: never;\n\nexport interface AgentHarnessTurnState<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n\tTTool extends AgentTool = AgentTool,\n> {\n\tmessages: AgentMessage[];\n\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n\tsystemPrompt: string;\n\tmodel: Model<any>;\n\tthinkingLevel: ThinkingLevel;\n\ttools: TTool[];\n\tactiveTools: TTool[];\n}\n\nexport interface QueueUpdateEvent {\n\ttype: \"queue_update\";\n\tsteer: AgentMessage[];\n\tfollowUp: AgentMessage[];\n\tnextTurn: AgentMessage[];\n}\n\nexport interface SavePointEvent {\n\ttype: \"save_point\";\n\thadPendingMutations: boolean;\n}\n\nexport interface AbortEvent {\n\ttype: \"abort\";\n\tclearedSteer: AgentMessage[];\n\tclearedFollowUp: AgentMessage[];\n}\n\nexport interface SettledEvent {\n\ttype: \"settled\";\n\tnextTurnCount: number;\n}\n\nexport interface BeforeAgentStartEvent<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\ttype: \"before_agent_start\";\n\tprompt: string;\n\timages?: ImageContent[];\n\tsystemPrompt: string;\n\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n}\n\nexport interface ContextEvent {\n\ttype: \"context\";\n\tmessages: AgentMessage[];\n}\n\nexport interface BeforeProviderRequestEvent {\n\ttype: \"before_provider_request\";\n\tpayload: unknown;\n}\n\nexport interface AfterProviderResponseEvent {\n\ttype: \"after_provider_response\";\n\tstatus: number;\n\theaders: Record<string, string>;\n}\n\nexport interface ToolCallEvent {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\nexport interface ToolResultEvent {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n\tcontent: Array<TextContent | ImageContent>;\n\tdetails: unknown;\n\tisError: boolean;\n}\n\nexport interface SessionBeforeCompactEvent {\n\ttype: \"session_before_compact\";\n\tpreparation: CompactionPreparation;\n\tbranchEntries: SessionTreeEntry[];\n\tcustomInstructions?: string;\n\tsignal: AbortSignal;\n}\n\nexport interface SessionCompactEvent {\n\ttype: \"session_compact\";\n\tcompactionEntry: CompactionEntry;\n\tfromHook: boolean;\n}\n\nexport interface SessionBeforeTreeEvent {\n\ttype: \"session_before_tree\";\n\tpreparation: TreePreparation;\n\tsignal: AbortSignal;\n}\n\nexport interface SessionTreeEvent {\n\ttype: \"session_tree\";\n\tnewLeafId: string | null;\n\toldLeafId: string | null;\n\tsummaryEntry?: BranchSummaryEntry;\n\tfromHook?: boolean;\n}\n\nexport interface ModelSelectEvent {\n\ttype: \"model_select\";\n\tmodel: Model<any>;\n\tpreviousModel: Model<any> | undefined;\n\tsource: \"set\" | \"restore\";\n}\n\nexport interface ThinkingLevelSelectEvent {\n\ttype: \"thinking_level_select\";\n\tlevel: ThinkingLevel;\n\tpreviousLevel: ThinkingLevel;\n}\n\nexport interface ResourcesUpdateEvent<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\ttype: \"resources_update\";\n\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n\tpreviousResources: AgentHarnessResources<TSkill, TPromptTemplate>;\n}\n\nexport type AgentHarnessOwnEvent<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> =\n\t| QueueUpdateEvent\n\t| SavePointEvent\n\t| AbortEvent\n\t| SettledEvent\n\t| BeforeAgentStartEvent<TSkill, TPromptTemplate>\n\t| ContextEvent\n\t| BeforeProviderRequestEvent\n\t| AfterProviderResponseEvent\n\t| ToolCallEvent\n\t| ToolResultEvent\n\t| SessionBeforeCompactEvent\n\t| SessionCompactEvent\n\t| SessionBeforeTreeEvent\n\t| SessionTreeEvent\n\t| ModelSelectEvent\n\t| ThinkingLevelSelectEvent\n\t| ResourcesUpdateEvent<TSkill, TPromptTemplate>;\n\nexport type AgentHarnessEvent<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate> =\n\t| AgentEvent\n\t| AgentHarnessOwnEvent<TSkill, TPromptTemplate>;\n\nexport interface BeforeAgentStartResult {\n\tmessages?: AgentMessage[];\n\tsystemPrompt?: string;\n}\n\nexport interface ContextResult {\n\tmessages: AgentMessage[];\n}\n\nexport interface BeforeProviderRequestResult {\n\tpayload: unknown;\n}\n\nexport interface ToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n}\n\nexport interface ToolResultPatch {\n\tcontent?: Array<TextContent | ImageContent>;\n\tdetails?: unknown;\n\tisError?: boolean;\n\tterminate?: boolean;\n}\n\nexport interface SessionBeforeCompactResult {\n\tcancel?: boolean;\n\tcompaction?: CompactResult;\n}\n\nexport interface SessionBeforeTreeResult {\n\tcancel?: boolean;\n\tsummary?: { summary: string; details?: unknown };\n\tcustomInstructions?: string;\n\treplaceInstructions?: boolean;\n\tlabel?: string;\n}\n\nexport type AgentHarnessEventResultMap = {\n\tbefore_agent_start: BeforeAgentStartResult | undefined;\n\tcontext: ContextResult | undefined;\n\tbefore_provider_request: BeforeProviderRequestResult | undefined;\n\tafter_provider_response: undefined;\n\ttool_call: ToolCallResult | undefined;\n\ttool_result: ToolResultPatch | undefined;\n\tsession_before_compact: SessionBeforeCompactResult | undefined;\n\tsession_compact: undefined;\n\tsession_before_tree: SessionBeforeTreeResult | undefined;\n\tsession_tree: undefined;\n\tmodel_select: undefined;\n\tthinking_level_select: undefined;\n\tresources_update: undefined;\n\tqueue_update: undefined;\n\tsave_point: undefined;\n\tabort: undefined;\n\tsettled: undefined;\n};\n\nexport interface AgentHarnessPromptOptions {\n\timages?: ImageContent[];\n}\n\nexport interface AbortResult {\n\tclearedSteer: AgentMessage[];\n\tclearedFollowUp: AgentMessage[];\n}\n\nexport interface CompactResult {\n\tsummary: string;\n\tfirstKeptEntryId: string;\n\ttokensBefore: number;\n\tdetails?: unknown;\n}\n\nexport interface NavigateTreeResult {\n\tcancelled: boolean;\n\teditorText?: string;\n\tsummaryEntry?: BranchSummaryEntry;\n}\n\nexport interface CompactionSettings {\n\tenabled: boolean;\n\treserveTokens: number;\n\tkeepRecentTokens: number;\n}\n\nexport interface CompactionPreparation {\n\tfirstKeptEntryId: string;\n\tmessagesToSummarize: AgentMessage[];\n\tturnPrefixMessages: AgentMessage[];\n\tisSplitTurn: boolean;\n\ttokensBefore: number;\n\tpreviousSummary?: string;\n\tfileOps: FileOperations;\n\tsettings: CompactionSettings;\n}\n\nexport interface FileOperations {\n\tread: Set<string>;\n\twritten: Set<string>;\n\tedited: Set<string>;\n}\n\nexport interface TreePreparation {\n\ttargetId: string;\n\toldLeafId: string | null;\n\tcommonAncestorId: string | null;\n\tentriesToSummarize: SessionTreeEntry[];\n\tuserWantsSummary: boolean;\n\tcustomInstructions?: string;\n\treplaceInstructions?: boolean;\n\tlabel?: string;\n}\n\nexport interface GenerateBranchSummaryOptions {\n\tmodel: Model<any>;\n\tapiKey: string;\n\theaders?: Record<string, string>;\n\tsignal: AbortSignal;\n\tcustomInstructions?: string;\n\treplaceInstructions?: boolean;\n\treserveTokens?: number;\n}\n\nexport interface BranchSummaryResult {\n\tsummary?: string;\n\treadFiles?: string[];\n\tmodifiedFiles?: string[];\n\taborted?: boolean;\n\terror?: string;\n}\n\nexport interface AgentHarnessOptions<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n\tTTool extends AgentTool = AgentTool,\n> {\n\tenv: ExecutionEnv;\n\tsession: Session;\n\ttools?: TTool[];\n\t/**\n\t * Concrete resources available to explicit invocation methods and system-prompt callbacks.\n\t * Applications own loading/reloading resources and should call `setResources()` with new values.\n\t */\n\tresources?: AgentHarnessResources<TSkill, TPromptTemplate>;\n\tsystemPrompt?:\n\t\t| string\n\t\t| ((context: {\n\t\t\t\tenv: ExecutionEnv;\n\t\t\t\tsession: Session;\n\t\t\t\tmodel: Model<any>;\n\t\t\t\tthinkingLevel: ThinkingLevel;\n\t\t\t\tactiveTools: TTool[];\n\t\t\t\tresources: AgentHarnessResources<TSkill, TPromptTemplate>;\n\t\t }) => string | Promise<string>);\n\tgetApiKeyAndHeaders?: (\n\t\tmodel: Model<any>,\n\t) => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tmodel: Model<any>;\n\tthinkingLevel?: ThinkingLevel;\n\tactiveToolNames?: string[];\n\tsteeringMode?: QueueMode;\n\tfollowUpMode?: QueueMode;\n}\n\nexport type { AgentHarness } from \"./agent-harness.js\";\n"]}
@@ -0,0 +1,14 @@
1
+ import type { ExecutionEnv, ExecutionEnvExecOptions } from "../types.js";
2
+ export interface ShellCaptureOptions extends Omit<ExecutionEnvExecOptions, "onStdout" | "onStderr"> {
3
+ onChunk?: (chunk: string) => void;
4
+ }
5
+ export interface ShellCaptureResult {
6
+ output: string;
7
+ exitCode: number | undefined;
8
+ cancelled: boolean;
9
+ truncated: boolean;
10
+ fullOutputPath?: string;
11
+ }
12
+ export declare function sanitizeBinaryOutput(str: string): string;
13
+ export declare function executeShellWithCapture(env: ExecutionEnv, command: string, options?: ShellCaptureOptions): Promise<ShellCaptureResult>;
14
+ //# sourceMappingURL=shell-output.d.ts.map