@qvac/harness 1.0.0-rc.20 → 1.0.0-rc.21

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 (191) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist-lib/index.d.ts +7 -5
  3. package/dist-lib/index.js +5 -4
  4. package/dist-lib/lib/agent/resolve.js +2 -1
  5. package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
  6. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +1 -1
  7. package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
  8. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +8 -6
  9. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +1 -1
  10. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +1 -1
  11. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +2 -1
  12. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +8 -3
  13. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +10 -4
  14. package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +2 -1
  15. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +8 -8
  16. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +2 -2
  17. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +3 -2
  18. package/dist-lib/lib/capabilities/completion-engine/loop.js +1 -0
  19. package/dist-lib/lib/capabilities/completion-engine/round.js +9 -9
  20. package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -1
  21. package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -41
  22. package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +4 -133
  23. package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
  24. package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +42 -0
  25. package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
  26. package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
  27. package/dist-lib/lib/capabilities/completion-engine/turns.js +7 -4
  28. package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
  29. package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
  30. package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
  31. package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
  32. package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
  33. package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
  34. package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
  35. package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
  36. package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
  37. package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
  38. package/dist-lib/lib/capabilities/tool-turns.d.ts +8 -54
  39. package/dist-lib/lib/capabilities/tool-turns.js +6 -281
  40. package/dist-lib/lib/client/index.js +3 -3
  41. package/dist-lib/lib/connect/abort.d.ts +6 -0
  42. package/dist-lib/lib/connect/abort.js +52 -0
  43. package/dist-lib/lib/connect/bridges.d.ts +21 -0
  44. package/dist-lib/lib/connect/bridges.js +185 -0
  45. package/dist-lib/lib/connect/decode.d.ts +31 -0
  46. package/dist-lib/lib/connect/decode.js +114 -0
  47. package/dist-lib/lib/connect/host-run-log.d.ts +16 -0
  48. package/dist-lib/lib/connect/host-run-log.js +74 -0
  49. package/dist-lib/lib/connect/served.d.ts +7 -0
  50. package/dist-lib/lib/connect/served.js +45 -0
  51. package/dist-lib/lib/connect.d.ts +3 -3
  52. package/dist-lib/lib/connect.js +24 -468
  53. package/dist-lib/lib/context-window.d.ts +13 -7
  54. package/dist-lib/lib/context-window.js +13 -6
  55. package/dist-lib/lib/contract/agent.d.ts +12 -1
  56. package/dist-lib/lib/contract/completion.d.ts +5 -1
  57. package/dist-lib/lib/contract/drive.d.ts +130 -4
  58. package/dist-lib/lib/contract/ocr.d.ts +5 -1
  59. package/dist-lib/lib/contract-types.d.ts +5 -3
  60. package/dist-lib/lib/errors.js +3 -3
  61. package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
  62. package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
  63. package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
  64. package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
  65. package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
  66. package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
  67. package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
  68. package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
  69. package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
  70. package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
  71. package/dist-lib/lib/helpers/goal-check.d.ts +35 -43
  72. package/dist-lib/lib/helpers/goal-check.js +34 -406
  73. package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
  74. package/dist-lib/lib/helpers/recent-map.js +23 -0
  75. package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
  76. package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
  77. package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
  78. package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
  79. package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
  80. package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
  81. package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
  82. package/dist-lib/lib/helpers/tool-call-markup/strip.js +149 -0
  83. package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
  84. package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
  85. package/dist-lib/lib/machine/completion/actions/completion.d.ts +12 -18
  86. package/dist-lib/lib/machine/completion/actions/completion.js +19 -178
  87. package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
  88. package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
  89. package/dist-lib/lib/machine/completion/actions/prepare.js +2 -1
  90. package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
  91. package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
  92. package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
  93. package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
  94. package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
  95. package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
  96. package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
  97. package/dist-lib/lib/machine/completion/actions/tools.js +16 -161
  98. package/dist-lib/lib/machine/completion/context.js +3 -3
  99. package/dist-lib/lib/machine/completion/implementations.d.ts +2 -2
  100. package/dist-lib/lib/machine/completion/implementations.js +6 -2
  101. package/dist-lib/lib/machine/completion/machine.d.ts +2 -2
  102. package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
  103. package/dist-lib/lib/machine/completion/metrics.js +68 -0
  104. package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
  105. package/dist-lib/lib/machine/completion/nudges.js +33 -0
  106. package/dist-lib/lib/machine/completion/rules.d.ts +5 -34
  107. package/dist-lib/lib/machine/completion/rules.js +4 -120
  108. package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
  109. package/dist-lib/lib/machine/completion/splice.js +19 -0
  110. package/dist-lib/lib/machine/completion/types.d.ts +4 -13
  111. package/dist-lib/lib/machine/index.d.ts +3 -3
  112. package/dist-lib/lib/machine/index.js +2 -2
  113. package/dist-lib/lib/media-host.js +2 -2
  114. package/dist-lib/lib/media-wire.js +2 -2
  115. package/dist-lib/lib/residency/completion-runtime.d.ts +2 -1
  116. package/dist-lib/lib/residency/completion-runtime.js +44 -1
  117. package/dist-lib/lib/residency/index.d.ts +3 -2
  118. package/dist-lib/lib/residency/index.js +2 -2
  119. package/dist-lib/lib/round-host.js +3 -3
  120. package/dist-lib/lib/round-port.js +3 -3
  121. package/dist-lib/lib/run-log/redact.js +7 -7
  122. package/dist-lib/lib/serve/completion.d.ts +7 -0
  123. package/dist-lib/lib/serve/completion.js +553 -0
  124. package/dist-lib/lib/serve/downloads.d.ts +4 -0
  125. package/dist-lib/lib/serve/downloads.js +79 -0
  126. package/dist-lib/lib/serve/models.d.ts +5 -0
  127. package/dist-lib/lib/serve/models.js +120 -0
  128. package/dist-lib/lib/serve/noop.d.ts +1 -0
  129. package/dist-lib/lib/serve/noop.js +1 -0
  130. package/dist-lib/lib/serve/requests.d.ts +147 -0
  131. package/dist-lib/lib/serve/requests.js +1 -0
  132. package/dist-lib/lib/serve/rounds.d.ts +11 -0
  133. package/dist-lib/lib/serve/rounds.js +67 -0
  134. package/dist-lib/lib/serve/run-log-start.d.ts +38 -0
  135. package/dist-lib/lib/serve/run-log-start.js +254 -0
  136. package/dist-lib/lib/serve/skills.d.ts +32 -0
  137. package/dist-lib/lib/serve/skills.js +46 -0
  138. package/dist-lib/lib/serve.d.ts +5 -1
  139. package/dist-lib/lib/serve.js +14 -1071
  140. package/dist-lib/lib/skills-host/index.d.ts +4 -2
  141. package/dist-lib/lib/skills-host/index.js +20 -8
  142. package/dist-lib/lib/tools/fs/drive.d.ts +1 -17
  143. package/dist-lib/lib/tools/fs/remote-protocol.d.ts +1 -81
  144. package/dist-lib/lib/tools/fs/scope.d.ts +2 -17
  145. package/dist-lib/lib/tools/fs/search.d.ts +2 -18
  146. package/dist-lib/lib/tools/fs/walk.d.ts +1 -5
  147. package/dist-lib/lib/tools/pdf/build.d.ts +2 -2
  148. package/dist-lib/lib/tools/pdf/recognize.js +4 -8
  149. package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
  150. package/dist-lib/lib/tools/pdf/request.js +4 -4
  151. package/dist-lib/lib/tools/pdf.d.ts +0 -1
  152. package/dist-lib/lib/tools/pdf.js +0 -1
  153. package/dist-lib/lib/tools/skill.js +13 -4
  154. package/dist-lib/lib/tools/skills/bundled-dir.d.ts +3 -0
  155. package/dist-lib/lib/tools/skills/bundled-dir.js +27 -24
  156. package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
  157. package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
  158. package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
  159. package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
  160. package/dist-lib/lib/tools/skills/catalog.d.ts +5 -8
  161. package/dist-lib/lib/tools/skills/catalog.js +1 -162
  162. package/dist-lib/lib/tools/skills/index.d.ts +1 -0
  163. package/dist-lib/lib/tools/skills/index.js +1 -0
  164. package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
  165. package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
  166. package/dist-lib/lib/wire/download.d.ts +10 -0
  167. package/dist-lib/lib/wire/download.js +35 -0
  168. package/dist-lib/lib/wire/event.d.ts +41 -0
  169. package/dist-lib/lib/wire/event.js +306 -0
  170. package/dist-lib/lib/wire/fields.d.ts +3 -0
  171. package/dist-lib/lib/wire/fields.js +12 -0
  172. package/dist-lib/lib/wire/knowledge.d.ts +9 -0
  173. package/dist-lib/lib/wire/knowledge.js +68 -0
  174. package/dist-lib/lib/wire/round.d.ts +14 -0
  175. package/dist-lib/lib/wire/round.js +45 -0
  176. package/dist-lib/lib/wire/vectors.d.ts +6 -0
  177. package/dist-lib/lib/wire/vectors.js +33 -0
  178. package/dist-lib/lib/wire.d.ts +28 -77
  179. package/dist-lib/lib/wire.js +24 -489
  180. package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
  181. package/dist-lib/plugins/ocr/coverage.js +67 -0
  182. package/dist-lib/plugins/ocr/ocr-runtime.d.ts +4 -2
  183. package/dist-lib/plugins/ocr/ocr-runtime.js +25 -4
  184. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  185. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  186. package/dist-lib/schema/harness.js +4 -1
  187. package/dist-lib/spec/hrpc/messages.js +25 -1
  188. package/dist-lib/spec/hyperschema/index.js +25 -1
  189. package/dist-lib/spec/hyperschema/schema.json +6 -1
  190. package/dist-lib/spec/hyperschema/types.d.ts +1 -0
  191. package/package.json +2 -2
@@ -1,4 +1,130 @@
1
- export type { DriveDir, DriveEntry } from '../tools/fs/remote-protocol.ts';
2
- export type { DriveOpFn, GrantedDrive } from '../tools/fs/remote-protocol.ts';
3
- export type { DriveEntryRequest, DriveGetRequest, DriveListRequest, DriveReadRequest, DriveRequest, DriveResponse, DriveSearchQuery, DriveSearchRequest, DriveWriteRequest } from '../tools/fs/remote-protocol.ts';
4
- export type { SearchHit } from '../tools/fs/search.ts';
1
+ import type { Writable } from 'streamx';
2
+ export interface DriveEntry {
3
+ key: string;
4
+ value: {
5
+ executable: boolean;
6
+ linkname: string | null;
7
+ blob: {
8
+ byteLength: number;
9
+ } | null;
10
+ metadata: unknown;
11
+ };
12
+ mtime?: number;
13
+ }
14
+ export interface DriveDir {
15
+ key: string;
16
+ dir: true;
17
+ }
18
+ export interface GrantedDrive {
19
+ readonly key: string;
20
+ readonly writable: boolean;
21
+ readonly search?: boolean;
22
+ }
23
+ export interface DriveEntryRequest {
24
+ op: 'entry';
25
+ driveKey: string;
26
+ key: string;
27
+ }
28
+ export interface DriveGetRequest {
29
+ op: 'get';
30
+ driveKey: string;
31
+ key: string;
32
+ }
33
+ export interface DriveReadRequest {
34
+ op: 'read';
35
+ driveKey: string;
36
+ key: string;
37
+ }
38
+ export interface DriveListRequest {
39
+ op: 'list';
40
+ driveKey: string;
41
+ folder: string;
42
+ skip: string[];
43
+ recursive: boolean;
44
+ limit: number;
45
+ cursor: string | null;
46
+ }
47
+ export interface DriveWriteRequest {
48
+ op: 'write';
49
+ driveKey: string;
50
+ key: string;
51
+ path: string;
52
+ executable?: boolean;
53
+ }
54
+ export interface DriveSearchQuery {
55
+ folder: string;
56
+ queries: string[];
57
+ regex: boolean;
58
+ caseSensitive: boolean;
59
+ includeIgnored: boolean;
60
+ maxMatches: number;
61
+ maxEntries: number;
62
+ maxMs: number;
63
+ }
64
+ export interface DriveSearchRequest extends DriveSearchQuery {
65
+ op: 'search';
66
+ driveKey: string;
67
+ }
68
+ export type DriveRequest = DriveEntryRequest | DriveGetRequest | DriveReadRequest | DriveListRequest | DriveWriteRequest | DriveSearchRequest;
69
+ export interface DriveResponse {
70
+ error?: string;
71
+ entry?: DriveEntry | null;
72
+ path?: string | null;
73
+ truncated?: boolean;
74
+ entries?: Array<DriveEntry | DriveDir>;
75
+ cursor?: string | null;
76
+ hits?: SearchHit[];
77
+ capped?: boolean;
78
+ cut?: boolean;
79
+ skippedLinks?: number;
80
+ }
81
+ export type DriveOpFn = (request: DriveRequest) => Promise<DriveResponse>;
82
+ export interface DriveListOptions {
83
+ skip?: ReadonlySet<string>;
84
+ recursive?: boolean;
85
+ }
86
+ export interface Drive {
87
+ entry(key: string, opts?: {
88
+ follow?: boolean;
89
+ }): Promise<DriveEntry | null>;
90
+ get(key: string): Promise<Uint8Array | null>;
91
+ list(folder?: string, opts?: DriveListOptions): AsyncIterable<DriveEntry | DriveDir>;
92
+ createReadStream(key: string): AsyncIterable<Uint8Array>;
93
+ createWriteStream(key: string, opts?: {
94
+ executable?: boolean;
95
+ }): Writable;
96
+ }
97
+ export interface SearchHit {
98
+ file: string;
99
+ line: number;
100
+ text: string;
101
+ }
102
+ export interface SearchFile {
103
+ path: string;
104
+ key: string;
105
+ }
106
+ export interface SearchResult {
107
+ hits: SearchHit[];
108
+ capped: boolean;
109
+ cut: boolean;
110
+ }
111
+ export interface WalkSummary {
112
+ truncated: boolean;
113
+ skippedLinks: number;
114
+ }
115
+ export interface FolderSearchResult extends SearchResult, WalkSummary {
116
+ }
117
+ export interface LocalRoot {
118
+ readonly kind: 'local';
119
+ readonly root: string;
120
+ readonly drive: Drive;
121
+ }
122
+ export interface HyperRoot {
123
+ readonly kind: 'hyper';
124
+ readonly key: string;
125
+ readonly writable: boolean;
126
+ readonly prefix: string;
127
+ readonly drive: Drive;
128
+ readonly search?: (query: DriveSearchQuery) => Promise<FolderSearchResult>;
129
+ }
130
+ export type DriveRoot = LocalRoot | HyperRoot;
@@ -4,8 +4,12 @@ export interface OcrImage {
4
4
  readonly height: number;
5
5
  readonly data: Uint8Array;
6
6
  }
7
+ export interface OcrPage {
8
+ readonly text: string;
9
+ readonly coverage: number;
10
+ }
7
11
  export interface OcrService {
8
- read(image: OcrImage, signal?: BareAbortSignal): Promise<string>;
12
+ read(image: OcrImage, signal?: BareAbortSignal): Promise<OcrPage>;
9
13
  }
10
14
  export interface OcrReadContext {
11
15
  readonly image: OcrImage;
@@ -1,6 +1,6 @@
1
1
  import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
2
  import type { HarnessCapabilityProfile } from '../spec/hyperschema/types.d.ts';
3
- import type { AccessPolicy, AgentHandoff, ApproveFn, AskUserFn, AttachFn, FetchAttachmentFn, HistoryToolCall, ProgressFn, ResourceDescriptor, ResponseFormat, MediaRoundIo, MediaRoundPort, MediaRoundRequest, MediaRoundResult, ShowImageFn } from './contract/index.ts';
3
+ import type { AccessPolicy, AgentHandoff, ApproveFn, AskUserFn, AttachFn, FetchAttachmentFn, HistoryToolCall, ProgressFn, WorkspaceSkill, ResourceDescriptor, ResponseFormat, MediaRoundIo, MediaRoundPort, MediaRoundRequest, MediaRoundResult, ShowImageFn, ProjectSkill } from './contract/index.ts';
4
4
  import type { KvCacheDeletionResult } from './capabilities/kv-cache.ts';
5
5
  import type { ModelRoundIo, ModelRoundPort, ModelRoundRequest, ModelRoundResult } from './capabilities/completion-engine/index.ts';
6
6
  import type { ModelSourcePreview, PreviewModelSourceContext } from './capabilities/preview-model-source.ts';
@@ -13,7 +13,7 @@ import type { ListModelsOptions, ModelInfo } from './models/model-list.ts';
13
13
  import type { ToolCatalogEntry } from './tools/catalog.ts';
14
14
  import type { ManagedSkill, SkillFileContent } from './tools/skills/overlay-crud.ts';
15
15
  import type { DriveOpFn, GrantedDrive } from './tools/fs/remote-protocol.ts';
16
- import type { OcrReadContext } from './contract/ocr.ts';
16
+ import type { OcrPage, OcrReadContext } from './contract/ocr.ts';
17
17
  import type { SpeakResult } from './contract/speech.ts';
18
18
  import type { RunInput } from './contract/completion.ts';
19
19
  import type { RunGoal, TurnContext } from './contract/run.ts';
@@ -67,6 +67,8 @@ export interface CompletionContext {
67
67
  recovery?: RecoveryResolution[];
68
68
  model: string;
69
69
  agent: AgentKnobs;
70
+ projectSkills?: readonly ProjectSkill[];
71
+ workspaceSkills?: readonly WorkspaceSkill[];
70
72
  agents?: Record<string, AgentKnobs>;
71
73
  messages: ChatMessage[];
72
74
  typedText?: string;
@@ -268,7 +270,7 @@ export interface HarnessContract {
268
270
  describe?(): Promise<HarnessInfo | null> | HarnessInfo;
269
271
  embed?(context: EmbedContext): Promise<number[][]>;
270
272
  transcribe?(context: TranscribeContext): Promise<string>;
271
- ocrRead?(context: OcrReadContext): Promise<string>;
273
+ ocrRead?(context: OcrReadContext): Promise<OcrPage>;
272
274
  detectLanguage?(context: DetectLanguageContext): DetectedLanguage[] | Promise<DetectedLanguage[]>;
273
275
  speak?(context: SpeakContext): Promise<SpeakResult>;
274
276
  speakStream?(context: SpeakStreamContext): AsyncIterable<SpeakResult>;
@@ -163,16 +163,16 @@ const HARNESS_ERRORS = {
163
163
  SKILL_NOT_FOUND: { code: 102703, message: (name) => `skill not found: ${name}` },
164
164
  BUNDLED_SKILLS_INVALID: {
165
165
  code: 102704,
166
- message: (staging) => `bundled skills staging dir ${staging} failed validation`
166
+ message: (staging) => `skills staging dir ${staging} failed validation`
167
167
  },
168
168
  BUNDLED_SKILLS_TAMPERED: {
169
169
  code: 102705,
170
- message: (dir) => `bundled skills dir ${dir} failed validation after a rewrite — ` +
170
+ message: (dir) => `skills dir ${dir} failed validation after a rewrite — ` +
171
171
  'another process is tampering with it; remove it and restart'
172
172
  },
173
173
  BUNDLED_SKILLS_OCCUPIED: {
174
174
  code: 102706,
175
- message: (dir, why) => `bundled skills dir ${dir} could not be read or replaced${why} — remove it and restart`
175
+ message: (dir, why) => `skills dir ${dir} could not be read or replaced${why} — remove it and restart`
176
176
  },
177
177
  DRIVE_TIMED_OUT: { code: 102707, message: (op) => `drive ${op} timed out` },
178
178
  DRIVE_READ_TRUNCATED: {
@@ -0,0 +1,25 @@
1
+ export declare const GOAL_CHECKS_ASK: string;
2
+ export declare const GOAL_PROOF_ASK: string;
3
+ export declare const GOAL_REVIEW_ASK: string;
4
+ export declare const GOAL_CASES_ASK: string;
5
+ export declare const MAX_PROOF_ASKS = 2;
6
+ export interface AskedGoal {
7
+ checkable?: boolean;
8
+ named?: boolean;
9
+ checks: readonly {
10
+ name: string;
11
+ passed?: boolean;
12
+ }[];
13
+ turns: number;
14
+ deliverable?: readonly string[];
15
+ proving?: readonly string[];
16
+ edited?: readonly string[];
17
+ proof?: string;
18
+ }
19
+ export declare function deliverableAsk(paths: readonly string[]): string;
20
+ export declare function deliverableChecked(goal: AskedGoal): boolean;
21
+ export declare function asksDeliverable(goal: AskedGoal): boolean;
22
+ export declare function runAsk(path: string): string;
23
+ export declare function codeUnrun(goal: AskedGoal): boolean;
24
+ export declare function asksRun(goal: AskedGoal): boolean;
25
+ export declare function asksChecks(goal: AskedGoal): boolean;
@@ -0,0 +1,52 @@
1
+ import { runsDeliverable } from './checks.js';
2
+ export const GOAL_CHECKS_ASK = '[This goal has no checks yet. Name the commands that will prove the task is done: write a ' +
3
+ 'line `Checks:`, then one command per line in backticks, such as `test -s /app/result.json` ' +
4
+ 'or `python3 check.py`. Each must exit 0 only once the task is done, with no pipe, ; or && ' +
5
+ 'in it. The goal is met only once each of them ran on its own and exited 0.]';
6
+ export const GOAL_PROOF_ASK = '[The checks this goal has so far may only show that the output exists, not that it is right. Name the ' +
7
+ 'commands that will prove the result is correct, such as running the program on an input ' +
8
+ "and comparing with what the task asks, or the task's own tests: write a line `Checks:`, " +
9
+ 'then one command per line in backticks, with no pipe, ; or && in it. A command that repeats ' +
10
+ 'one of those checks does not count. The goal is met only once each check ran on its own and exited 0.]';
11
+ export const GOAL_REVIEW_ASK = '[Before the goal is met, read the task again and list each requirement it states, one line ' +
12
+ 'each, with the command that proves it in backticks and the output it gave. Then write a ' +
13
+ 'line `Checks:` and, one per line in backticks, a command for each requirement nothing proved ' +
14
+ 'yet, that exits 0 only when it holds, with no pipe, ; or && in it. If every requirement is ' +
15
+ 'proved, name no command.]';
16
+ export const GOAL_CASES_ASK = '[The checks pass with most of the budget left. Read the task again and quote each case it ' +
17
+ 'names, such as an input, an edge case or an output format, one line each. For each one, ' +
18
+ 'run a command that feeds it to your result and show the output it gave. Fix what does not ' +
19
+ 'hold, then answer.]';
20
+ const GOAL_DELIVERABLE_ASK = '[The checks pass, but none of them runs or reads {paths}, what the task asks for. A check ' +
21
+ 'counts only when its command, or a script it runs that you wrote, names one of those paths. ' +
22
+ 'Write a line `Checks:`, then one command per line in backticks that runs or reads it on an ' +
23
+ 'input and exits 0 only when the result is right, with no pipe, ; or && in it. The checks so ' +
24
+ 'far stay.]';
25
+ const GOAL_RUN_ASK = '[No command ran `{path}` after your last edit. Run a test that exercises it. It counts only ' +
26
+ 'when it exits 0 on its own, with no pipe, `|| true` or ; after it.]';
27
+ export const MAX_PROOF_ASKS = 2;
28
+ export function deliverableAsk(paths) {
29
+ return GOAL_DELIVERABLE_ASK.replaceAll('{paths}', paths.join(', '));
30
+ }
31
+ export function deliverableChecked(goal) {
32
+ const { deliverable, proving = [] } = goal;
33
+ return (!deliverable || goal.checks.some((check) => runsDeliverable(check.name, deliverable, proving)));
34
+ }
35
+ export function asksDeliverable(goal) {
36
+ return (!asksChecks(goal) && goal.checks.every((check) => check.passed) && !deliverableChecked(goal));
37
+ }
38
+ export function runAsk(path) {
39
+ return GOAL_RUN_ASK.replaceAll('{path}', path);
40
+ }
41
+ export function codeUnrun(goal) {
42
+ return !!goal.checkable && !!goal.edited?.length && !goal.proof;
43
+ }
44
+ export function asksRun(goal) {
45
+ return (codeUnrun(goal) &&
46
+ !asksChecks(goal) &&
47
+ goal.checks.every((check) => check.passed) &&
48
+ deliverableChecked(goal));
49
+ }
50
+ export function asksChecks(goal) {
51
+ return !!goal.checkable && !goal.named && goal.turns < MAX_PROOF_ASKS;
52
+ }
@@ -0,0 +1,8 @@
1
+ export declare const MAX_GOAL_CHECKS = 8;
2
+ export declare const MAX_PROVING: number;
3
+ export declare function existenceOnly(checks: readonly string[]): boolean;
4
+ export declare function pathsOf(checks: readonly string[]): string[];
5
+ export declare function runsDeliverable(check: string, deliverable: readonly string[], proving: readonly string[]): boolean;
6
+ export declare function citesPassed(text: string, passed: readonly string[]): boolean;
7
+ export declare function namedChecks(text: string): string[];
8
+ export declare function mergeChecks(host: readonly string[], named: readonly string[]): string[];
@@ -0,0 +1,92 @@
1
+ import { runsCheck, runsTests } from './commands.js';
2
+ import { namesPath, samePath } from './paths.js';
3
+ import { BRACKETS, COMPARISON, SHELL_OPERATOR, commandOf, exitSegments, scriptOf } from './shell.js';
4
+ const CHECKS_HEADING = /^[\s*#_]*checks:?[\s*_]*$/i;
5
+ const CHECK_LINE = /^\s*(?:[-*]|\d+[.)])?\s*`([^`]+)`\s*$/;
6
+ const SPAN = /`([^`\n]+)`/g;
7
+ const FILE_TEST = /^-[sfed]$/;
8
+ const NOT_A_PATH = /^(-\w+|!|!?=+|<|>|\]\]?)$/;
9
+ const NEVER_RUNS = /^(cat|ls|head|tail|stat|file|wc|echo|printf|touch|chmod|chown|cp|mv|mkdir|rm|ln|unlink|rmdir|true|\w*sum)$/;
10
+ export const MAX_GOAL_CHECKS = 8;
11
+ export const MAX_PROVING = MAX_GOAL_CHECKS * 2;
12
+ export function existenceOnly(checks) {
13
+ return (checks.length > 0 &&
14
+ checks.every((check) => check
15
+ .split(SHELL_OPERATOR)
16
+ .filter((part, at) => at % 2 === 0 && part.trim())
17
+ .every((part) => testsExistence(commandOf(part)))));
18
+ }
19
+ function testsExistence(tokens) {
20
+ const close = BRACKETS.get(tokens[0]);
21
+ if ((tokens[0] !== 'test' && !close) || (close && tokens.at(-1) !== close)) {
22
+ return false;
23
+ }
24
+ const path = tokens.slice(2, close ? -1 : undefined);
25
+ return (FILE_TEST.test(tokens[1] ?? '') &&
26
+ path.length > 0 &&
27
+ !path.some((token) => NOT_A_PATH.test(token)));
28
+ }
29
+ export function pathsOf(checks) {
30
+ const paths = checks.flatMap((check) => check
31
+ .split(SHELL_OPERATOR)
32
+ .filter((part, at) => at % 2 === 0)
33
+ .map(commandOf)
34
+ .filter(testsExistence)
35
+ .flatMap((tokens) => tokens.slice(2, BRACKETS.has(tokens[0]) ? -1 : undefined)));
36
+ return [...new Set(paths)];
37
+ }
38
+ export function runsDeliverable(check, deliverable, proving) {
39
+ return (!existenceOnly([check]) &&
40
+ exitSegments(check).some((segment) => {
41
+ const tokens = commandOf(segment);
42
+ const program = tokens[0]?.split('/').at(-1) ?? '';
43
+ const tests = program === 'test' || BRACKETS.has(program);
44
+ if ((tests && !tokens.some((token) => COMPARISON.test(token))) || NEVER_RUNS.test(program)) {
45
+ return false;
46
+ }
47
+ const script = scriptOf(tokens);
48
+ return (namesPath(tokens.join(' '), deliverable) ||
49
+ (script !== undefined && proving.some((path) => samePath(script, path))) ||
50
+ runsTests(tokens));
51
+ }));
52
+ }
53
+ export function citesPassed(text, passed) {
54
+ const lines = text.split('\n');
55
+ const heading = lines.findIndex((line) => CHECKS_HEADING.test(line));
56
+ const cited = lines.slice(0, heading < 0 ? undefined : heading).join('\n');
57
+ return [...cited.matchAll(SPAN)].some(([, span]) => passed.some((command) => runsCheck(span, command)));
58
+ }
59
+ export function namedChecks(text) {
60
+ const lines = text.split('\n');
61
+ const heading = lines.findIndex((line) => CHECKS_HEADING.test(line));
62
+ if (heading < 0) {
63
+ return [];
64
+ }
65
+ const named = [];
66
+ for (const line of lines.slice(heading + 1)) {
67
+ const command = CHECK_LINE.exec(line)?.[1].trim();
68
+ if (!command) {
69
+ if (line.trim() || named.length) {
70
+ break;
71
+ }
72
+ continue;
73
+ }
74
+ if (runsCheck(command, command) && !named.includes(command)) {
75
+ named.push(command);
76
+ }
77
+ }
78
+ return named.slice(0, MAX_GOAL_CHECKS);
79
+ }
80
+ export function mergeChecks(host, named) {
81
+ const known = new Set(host.map(normalize));
82
+ const fresh = named
83
+ .filter((name) => !known.has(normalize(name)))
84
+ .slice(0, host.length ? MAX_GOAL_CHECKS - 1 : MAX_GOAL_CHECKS);
85
+ if (!fresh.length) {
86
+ return [];
87
+ }
88
+ return [...host.slice(0, MAX_GOAL_CHECKS - fresh.length), ...fresh];
89
+ }
90
+ function normalize(command) {
91
+ return command.trim().replace(/\s+/g, ' ');
92
+ }
@@ -0,0 +1,7 @@
1
+ export declare function runsCode(command: string, edited: readonly string[]): string | undefined;
2
+ export declare function runsCodeCheck(command: string, checks: readonly string[]): string | undefined;
3
+ export declare function runsScript(check: string, paths: readonly string[]): boolean;
4
+ export declare function runsTests(tokens: readonly string[]): boolean;
5
+ export declare function provesResult(command: string): string | undefined;
6
+ export declare function proves(segment: string): boolean;
7
+ export declare function runsCheck(command: string, check: string): boolean;
@@ -0,0 +1,130 @@
1
+ import { HEREDOC, samePath, sourceFile } from './paths.js';
2
+ import { BRACKETS, COMPARISON, commandOf, commandStart, exitSegments, invokes, scriptOf, words } from './shell.js';
3
+ const TEST_SCRIPT = /^(tests?|checks?|verify|validate)(?=[_.-]|$)/;
4
+ const PACKAGE_TEST = /^tests?(?=[:_.-]|$)/;
5
+ const PACKAGE_MANAGER = /^(npm|yarn|pnpm|bun)$/;
6
+ const PYTHON = /^python[\d.]*$/;
7
+ const COMPARE = /^(diff|cmp)$/;
8
+ const QUIET = /^(-[a-zA-Z]*q[a-zA-Z]*|--quiet)$/;
9
+ const INTERPRETER = /^(python[\d.]*|bash|sh|zsh|node|bun|deno|go|ruby|perl|php|lua|Rscript|julia|tsx|ts-node|java)$/;
10
+ const SYNTAX_ONLY = /^((ba|z)?sh -n|node (-c|--check)|(perl|ruby) -c|php -l)$/;
11
+ const COMPILER = /^(gcc|g\+\+|cc|c\+\+|clang|clang\+\+|rustc)$/;
12
+ const SYSTEM_BIN = /^\/(usr\/)?s?bin\//;
13
+ const MAKE_DRY_RUN = /^(-n|-q|--dry-run|--just-print|--question)$/;
14
+ const CLEAN = /^(clean|distclean)$/;
15
+ export function runsCode(command, edited) {
16
+ const segments = exitSegments(command.replace(HEREDOC, '$1'));
17
+ return segments.find((segment, at) => {
18
+ const tokens = commandOf(segment);
19
+ const program = tokens[0]?.split('/').at(-1) ?? '';
20
+ if (program === 'test' || BRACKETS.has(program)) {
21
+ return false;
22
+ }
23
+ const script = INTERPRETER.test(program) ? interpreted(tokens) : tokens[0];
24
+ return (runsSuite(tokens) ||
25
+ runsProject(tokens) ||
26
+ (!!tokens[0]?.includes('/') &&
27
+ !SYSTEM_BIN.test(tokens[0]) &&
28
+ segments.slice(0, at).some((part) => builds(commandOf(part)))) ||
29
+ (script !== undefined &&
30
+ (edited.some((path) => samePath(script, path)) ||
31
+ TEST_SCRIPT.test(script.split('/').at(-1) ?? ''))));
32
+ });
33
+ }
34
+ export function runsCodeCheck(command, checks) {
35
+ return checks.find((check) => runsCheck(command, check) &&
36
+ exitSegments(check).some((segment) => {
37
+ const tokens = commandOf(segment);
38
+ return runsSuite(tokens) || sourceFile(scriptOf(tokens) ?? '');
39
+ }));
40
+ }
41
+ function interpreted(tokens) {
42
+ const program = tokens[0]?.split('/').at(-1) ?? '';
43
+ let at = 1;
44
+ for (; tokens[at]?.startsWith('-'); at++) {
45
+ if (tokens[at] === '-m' || SYNTAX_ONLY.test(`${program} ${tokens[at]}`)) {
46
+ return undefined;
47
+ }
48
+ }
49
+ return (program === 'bun' || program === 'deno' || program === 'go') && tokens[at] === 'run'
50
+ ? tokens[at + 1]
51
+ : tokens[at];
52
+ }
53
+ function runsProject(tokens) {
54
+ const program = tokens[0]?.split('/').at(-1) ?? '';
55
+ const [, next, target = ''] = tokens;
56
+ return ((program === 'cargo' && next === 'run') ||
57
+ (program === 'go' && next === 'run' && !target.endsWith('.go')));
58
+ }
59
+ function builds(tokens) {
60
+ const program = tokens[0]?.split('/').at(-1) ?? '';
61
+ const next = tokens[1];
62
+ return ((COMPILER.test(program) && !tokens.includes('-c')) ||
63
+ ((program === 'go' || program === 'cargo') && next === 'build') ||
64
+ (program === 'make' &&
65
+ !tokens.some((token) => MAKE_DRY_RUN.test(token)) &&
66
+ !cleansOnly(tokens.slice(1).filter((token) => !token.startsWith('-')))) ||
67
+ (program === 'cmake' &&
68
+ tokens.includes('--build') &&
69
+ !cleansOnly(tokens.slice(tokens.indexOf('--target') + 1))));
70
+ }
71
+ function cleansOnly(tokens) {
72
+ const end = tokens.findIndex((token) => token.startsWith('-'));
73
+ const targets = end === -1 ? tokens : tokens.slice(0, end);
74
+ return targets.length > 0 && targets.every((target) => CLEAN.test(target));
75
+ }
76
+ export function runsScript(check, paths) {
77
+ return exitSegments(check).some((segment) => {
78
+ const script = scriptOf(commandOf(segment));
79
+ return script !== undefined && paths.some((path) => samePath(script, path));
80
+ });
81
+ }
82
+ export function runsTests(tokens) {
83
+ const program = tokens[0]?.split('/').at(-1) ?? '';
84
+ if (program === 'pytest' || PYTHON.test(program)) {
85
+ return (program === 'pytest' || testRunner(tokens)) && scriptOf(tokens) === undefined;
86
+ }
87
+ return testRunner(tokens);
88
+ }
89
+ function runsSuite(tokens) {
90
+ const program = tokens[0]?.split('/').at(-1) ?? '';
91
+ return (program === 'pytest' ||
92
+ program === 'ctest' ||
93
+ (program === 'node' && tokens.includes('--test')) ||
94
+ testRunner(tokens));
95
+ }
96
+ function testRunner(tokens) {
97
+ const program = tokens[0]?.split('/').at(-1) ?? '';
98
+ const [, next = '', third = ''] = tokens;
99
+ const module = tokens.indexOf('-m');
100
+ return ((PACKAGE_MANAGER.test(program) && PACKAGE_TEST.test(next === 'run' ? third : next)) ||
101
+ ((program === 'cargo' || program === 'go') && next === 'test') ||
102
+ (program === 'make' && (next === 'test' || next === 'check')) ||
103
+ (PYTHON.test(program) && module > 0 && /^(pytest|unittest)$/.test(tokens[module + 1] ?? '')));
104
+ }
105
+ export function provesResult(command) {
106
+ return exitSegments(command).find(proves);
107
+ }
108
+ export function proves(segment) {
109
+ if (segment.split('"').length % 2 === 0 || segment.split("'").length % 2 === 0) {
110
+ return false;
111
+ }
112
+ const tokens = commandOf(segment);
113
+ const program = tokens[0]?.split('/').at(-1) ?? '';
114
+ const python = PYTHON.test(program);
115
+ if (program === 'test' || program === '[' || program === '[[') {
116
+ return tokens.some((token) => COMPARISON.test(token));
117
+ }
118
+ if ((python && tokens.includes('-c')) || (program === 'node' && tokens.includes('-e'))) {
119
+ return /\bassert\b/.test(segment);
120
+ }
121
+ return (COMPARE.test(program) ||
122
+ (program === 'grep' && tokens.some((token) => QUIET.test(token))) ||
123
+ runsSuite(tokens) ||
124
+ TEST_SCRIPT.test(scriptOf(tokens)?.split('/').at(-1) ?? ''));
125
+ }
126
+ export function runsCheck(command, check) {
127
+ const named = words(check);
128
+ const wanted = named.slice(Math.max(commandStart(named), 0));
129
+ return exitSegments(command).some((segment) => invokes(words(segment), wanted));
130
+ }
@@ -0,0 +1,5 @@
1
+ export declare const HEREDOC: RegExp;
2
+ export declare function sourceFile(path: string): boolean;
3
+ export declare function namesPath(text: string, paths: readonly string[]): boolean;
4
+ export declare function writtenTexts(args: Readonly<Record<string, unknown>>): [string, string][];
5
+ export declare function samePath(a: string, b: string): boolean;
@@ -0,0 +1,44 @@
1
+ const SOURCE = /\.(py|js|mjs|cjs|ts|mts|cts|jsx|tsx|sh|bash|zsh|rb|pl|php|lua|r|jl|go|rs|c|h|cc|cpp|cxx|hpp|java)$/i;
2
+ const PATH_BREAK = /[\s'"`(),;:=<>|&[\]{}]+/;
3
+ const WRITE = /(?<![>&\d])>\|?\s*(['"]?)([^\s'";|&<>()]+)\1/g;
4
+ export const HEREDOC = /(<<-?\s*(['"]?)(\w+)\2[^\n]*)\n([\s\S]*?\n)?\t*\3(?=\n|$)/g;
5
+ export function sourceFile(path) {
6
+ return SOURCE.test(path);
7
+ }
8
+ export function namesPath(text, paths) {
9
+ return text
10
+ .split(PATH_BREAK)
11
+ .some((token) => token && paths.some((path) => samePath(token, path)));
12
+ }
13
+ export function writtenTexts(args) {
14
+ const text = args.content ?? args.new;
15
+ if (typeof args.path === 'string' && typeof text === 'string') {
16
+ return [[args.path, text]];
17
+ }
18
+ const { command } = args;
19
+ if (typeof command !== 'string') {
20
+ return [];
21
+ }
22
+ const heredocs = [...command.matchAll(HEREDOC)].map((match) => ({
23
+ opened: match.index + match[1].length,
24
+ end: match.index + match[0].length,
25
+ body: match[4] ?? ''
26
+ }));
27
+ const written = [];
28
+ for (const match of command.matchAll(WRITE)) {
29
+ const [, , target] = match;
30
+ const inBody = heredocs.some(({ opened, end }) => match.index > opened && match.index < end);
31
+ if (inBody || target.startsWith('/dev/')) {
32
+ continue;
33
+ }
34
+ const close = command.indexOf('\n', match.index);
35
+ const line = command.slice(command.lastIndexOf('\n', match.index) + 1, close < 0 ? undefined : close);
36
+ written.push([target, heredocs.find(({ opened }) => opened === close)?.body ?? line]);
37
+ }
38
+ return written;
39
+ }
40
+ export function samePath(a, b) {
41
+ const left = a.replace(/^\.\//, '');
42
+ const right = b.replace(/^\.\//, '');
43
+ return left === right || left.endsWith(`/${right}`) || right.endsWith(`/${left}`);
44
+ }
@@ -0,0 +1,9 @@
1
+ export declare const SHELL_OPERATOR: RegExp;
2
+ export declare const COMPARISON: RegExp;
3
+ export declare const BRACKETS: Map<string, string>;
4
+ export declare function scriptOf(tokens: readonly string[]): string | undefined;
5
+ export declare function exitSegments(command: string): string[];
6
+ export declare function commandOf(segment: string): string[];
7
+ export declare function words(text: string): string[];
8
+ export declare function invokes(tokens: readonly string[], wanted: readonly string[]): boolean;
9
+ export declare function commandStart(tokens: readonly string[]): number;