@agntn/harnesses 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,17 @@ export interface PathCandidate {
9
9
  platforms?: Platform[];
10
10
  note?: string;
11
11
  }
12
+ /** The path lists of a harness descriptor, as named in {@link ResolvedPaths}. */
13
+ export type PathCategory = "config" | "sessions" | "instructions" | "skills" | "commands" | "promptTemplates" | "hooks" | "temp";
14
+ /**
15
+ * An environment variable the harness reads to move one of its roots. `path`
16
+ * is the default root, used while the variable is unset or empty.
17
+ */
18
+ export interface EnvOverride extends PathCandidate {
19
+ variable: string;
20
+ /** Categories with entries under this root, which move with it. */
21
+ relocates: PathCategory[];
22
+ }
12
23
  /** One stable user-scope destination used by prompt template synchronization. */
13
24
  export interface PromptTemplateSyncTarget extends PathCandidate {
14
25
  scope: "user";
@@ -49,6 +60,12 @@ export interface HarnessInvocation {
49
60
  readOnlyMinVersion?: string;
50
61
  /** Arguments appended when a model is selected; every "{model}" is replaced. */
51
62
  modelArgs?: string[];
63
+ /**
64
+ * Arguments appended to a plain text run so a CLI that holds its answer until
65
+ * the end reports it as events instead; `invoke` folds them back into that text,
66
+ * so a stopped run keeps what the model had already written.
67
+ */
68
+ streamArgs?: string[];
52
69
  level: EvidenceLevel;
53
70
  note?: string;
54
71
  }
@@ -65,7 +82,10 @@ export interface HarnessInvocationModes {
65
82
  export interface HarnessModelListing {
66
83
  /** Arguments used when no search filter is supplied. */
67
84
  args: string[];
68
- /** Optional argument template for a search filter; every "{search}" is replaced. */
85
+ /**
86
+ * Optional argument template for a native search filter; every "{search}" is replaced.
87
+ * Without it, a search runs `args` and keeps the ids containing the filter, ignoring case.
88
+ */
69
89
  searchArgs?: string[];
70
90
  level: EvidenceLevel;
71
91
  note?: string;
@@ -74,10 +94,13 @@ export interface HarnessModelListing {
74
94
  export interface AvailableModel {
75
95
  provider: string;
76
96
  id: string;
77
- contextWindow: number;
78
- maxOutputTokens: number;
79
- thinking: boolean;
80
- images: boolean;
97
+ /** Absent when the native listing prints only ids, like Grok's. */
98
+ contextWindow?: number;
99
+ maxOutputTokens?: number;
100
+ thinking?: boolean;
101
+ images?: boolean;
102
+ /** Set on the model the harness picks when no model is given, when the listing marks one. */
103
+ default?: boolean;
81
104
  }
82
105
  /** Options for querying the models available to one harness. */
83
106
  export interface ListModelsOptions {
@@ -96,7 +119,7 @@ export interface InvokeOptions {
96
119
  model?: string;
97
120
  /** Enable the spawned harness's tools; defaults to advisor without tools mode. */
98
121
  tools?: boolean;
99
- /** Require native enforcement of read-only tool access. Implies `tools: true`. */
122
+ /** Require native enforcement of read-only tool access. Implies `tools: true` when `tools` is omitted; `tools: false` rejects the run. */
100
123
  readOnly?: boolean;
101
124
  /** Milliseconds before cleanup starts. Unset or 0 disables the deadline. */
102
125
  timeoutMs?: number;
@@ -115,6 +138,8 @@ export interface InvokeResult {
115
138
  timedOut: boolean;
116
139
  /** True when caller cancellation wins over the deadline or completion. */
117
140
  aborted: boolean;
141
+ /** Milliseconds without output on either stream before a deadline or cancellation stopped the process. */
142
+ idleMs?: number;
118
143
  }
119
144
  /** Result of one native model-listing command. */
120
145
  export interface ListModelsResult extends InvokeResult {
@@ -160,6 +185,8 @@ export interface ResolveOptions {
160
185
  homeDir?: string;
161
186
  projectRoot?: string;
162
187
  platform?: Platform;
188
+ /** Replaces `os.tmpdir()` as the value of `${TMPDIR}`. */
189
+ tempDir?: string;
163
190
  }
164
191
  export interface ResolvedPaths {
165
192
  config: PathCandidate[];
@@ -170,6 +197,8 @@ export interface ResolvedPaths {
170
197
  promptTemplates: PathCandidate[];
171
198
  promptTemplateSyncTarget: PromptTemplateSyncTarget | null;
172
199
  hooks: PathCandidate[];
200
+ /** Temp roots, moved by a set `temp` override from {@link EnvOverride}. */
201
+ temp: PathCandidate[];
173
202
  }
174
203
  type InvocationOptions = Readonly<{
175
204
  model?: string;
@@ -192,6 +221,10 @@ export declare abstract class Harness {
192
221
  /** Stable user-scope destination used by prompt template synchronization. */
193
222
  readonly promptTemplateSyncTarget: PromptTemplateSyncTarget | null;
194
223
  abstract readonly hooks: PathCandidate[];
224
+ /** Where the harness keeps its temp files; empty when not verified. */
225
+ readonly temp: PathCandidate[];
226
+ /** Environment variables that move a root of this harness; empty when none is verified. */
227
+ readonly envOverrides: EnvOverride[];
195
228
  abstract readonly capabilities: HarnessCapabilities;
196
229
  abstract readonly detection: HarnessDetection;
197
230
  /** Non-interactive invocation recipe; null when the harness has no headless mode. */
@@ -246,6 +279,15 @@ export declare abstract class Harness {
246
279
  * @returns {Promise<InvokeResult>} The completed process result.
247
280
  */
248
281
  invoke(prompt: string, options?: InvokeOptions): Promise<InvokeResult>;
282
+ /**
283
+ * Turns the events a `streamArgs` run printed back into the text the plain
284
+ * run would have printed.
285
+ *
286
+ * @param _stdout - Event output as captured, possibly cut short.
287
+ * @param _complete - False when a deadline or cancellation stopped the run.
288
+ * @returns {string} The answer text, or what the model had written so far.
289
+ */
290
+ protected foldStreamOutput(_stdout: string, _complete: boolean): string;
249
291
  /**
250
292
  * Explains why the installed CLI cannot run a read-only recipe that carries a
251
293
  * version floor, or returns null when no floor applies or the installed
@@ -258,7 +300,8 @@ export declare abstract class Harness {
258
300
  /**
259
301
  * Expands the native model-listing recipe without spawning anything.
260
302
  *
261
- * @param search - Optional native model search filter.
303
+ * @param search - Optional model search filter; without native `searchArgs` it is applied
304
+ * to the parsed output instead, so the command is the unfiltered one.
262
305
  * @returns {{ command: string, args: string[] } | null} The command, or null when unsupported.
263
306
  */
264
307
  buildModelListInvocation(search?: string): {
@@ -273,6 +316,14 @@ export declare abstract class Harness {
273
316
  * @returns {Promise<ListModelsResult>} The normalized command and model result.
274
317
  */
275
318
  listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
319
+ /**
320
+ * The value `model` takes for one listed model: `provider/id` unless the
321
+ * harness overrides it.
322
+ *
323
+ * @param model - A model returned by {@link listModels}.
324
+ * @returns {string} The selector this harness's `modelArgs` accept.
325
+ */
326
+ modelSelector(model: Readonly<AvailableModel>): string;
276
327
  /**
277
328
  * Converts a successful native model-listing response to the shared shape.
278
329
  *
@@ -290,6 +341,14 @@ export declare abstract class Harness {
290
341
  */
291
342
  resolveCandidates<T extends PathCandidate>(entries: readonly T[], options?: ResolveOptions): T[];
292
343
  resolve(options?: ResolveOptions): ResolvedPaths;
344
+ /**
345
+ * Temp roots for the platform. A `temp` override set in the environment
346
+ * replaces its default root, the same move the harness makes itself.
347
+ *
348
+ * @param options - Platform and path-resolution overrides.
349
+ * @returns {PathCandidate[]} Resolved temp roots.
350
+ */
351
+ private resolveTemp;
293
352
  }
294
353
  export type HarnessConstructor = new () => Harness;
295
354
  /** One resolved config file together with the servers it declares. */
@@ -471,6 +530,9 @@ export interface PromptSyncTargetResult {
471
530
  readonly id: string;
472
531
  readonly path?: string;
473
532
  readonly format?: PromptTemplateSyncTarget["format"];
533
+ /** Outcome for a Markdown destination, which is one link to the whole source directory. */
534
+ readonly action?: PromptSyncAction;
535
+ /** Backup path, skip reason, or a check-mode note. */
474
536
  readonly detail?: string;
475
537
  readonly templates: readonly PromptTemplateTargetResult[];
476
538
  }
@@ -483,8 +545,10 @@ export interface PromptSyncReport {
483
545
  }
484
546
  /**
485
547
  * Synchronizes canonical Markdown prompt templates into each harness's stable
486
- * user-scope destination. Markdown harnesses receive symlinks; Gemini receives
487
- * generated TOML commands. In check mode nothing is written.
548
+ * user-scope destination. A Markdown harness's destination becomes one symlink
549
+ * to the source directory; Gemini's directory holds only TOML commands
550
+ * generated from it. Anything else found there is backed up first. In check
551
+ * mode nothing is written.
488
552
  *
489
553
  * @param harnesses - Harnesses to inspect or update.
490
554
  * @param check - Report intended changes without writing them.
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-sync.d.mts","names":[],"sources":["../../src/types.ts","../../src/harness.ts","../../src/mcp-servers.ts","../../src/agents-sync.ts","../../src/prompt-sync.ts"],"mappings":"AAEA,qBAAa;YAED;YAcA;YACA;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A;WACA,kBAAkB;;;;;;;;;;;;wBAgXb,oBACd,oBAAoB,WACpB,iBACA,UAAS,iBACR"}
1
+ {"version":3,"file":"prompt-sync.d.mts","names":[],"sources":["../../src/types.ts","../../src/harness.ts","../../src/mcp-servers.ts","../../src/agents-sync.ts","../../src/prompt-sync.ts"],"mappings":"AAEA,qBAAa;YAED;YAcA;YACA;iBAEK;EACf;EACA;EACA,OAAO;EACP,YAAY;EACZ;;;YAIU;;;;;iBAcK,oBAAoB;EACnC;;EAEA,WAAW;;;iBAII,iCAAiC;EAChD;EACA;;iBAGe;EACf;EACA,OAAO;EACP;;iBAGe;EACf;EACA;;EAEA;;EAEA;EACA;EACA;;;iBAIe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA;EACA,OAAO;EACP;;;iBAIe;EACf;EACA;EACA;EACA;EACA;EACA;;;iBAIe;;EAEf;;;;;EAKA;EACA,OAAO;EACP;;;iBAIe;EACf;EACA;;EAEA;EACA;EACA;EACA;;EAEA;;;iBAIe;EACf;EACA;EACA,MAAM;;EAEN;;EAEA,SAAS;;iBAGM;EACf;EACA,MAAM;;EAEN;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;EAET;;iBAGe;EACf;EACA;EACA;EACA;;EAEA;EACA;;EAEA;;EAEA;;;iBAIe,yBAAyB;;EAExC,QAAQ;;;iBAIO;EACf;EACA;EACA;EACA;;;;;;EAMA,MAAM;EACN;EACA,UAAU;;EAEV;;;iBAIe,sBAAsB;EACrC;;EAEA;;;;;;EAMA;;iBAGe;;EAEf;;EAEA;;iBAGe;EACf;EACA;EACA,WAAW;;EAEX;;iBAGe;EACf,QAAQ;EACR,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,iBAAiB;EACjB,0BAA0B;EAC1B,OAAO;;EAEP,MAAM;;KCvLH,oBAAoB;EACvB;EACA;EACA;EACA;;8BAoToB;oBACF,IAAI;oBACJ;oBACA;oBACA,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