@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
@@ -0,0 +1,254 @@
1
+ import b4a from 'b4a';
2
+ import { checkMaxToolRounds } from '../capabilities/tool-turns.js';
3
+ import { RunLog } from '../run-log/index.js';
4
+ import { isRecord } from '../guards.js';
5
+ import { knowledgeGrant } from './skills.js';
6
+ export function decodeDigestKey(value) {
7
+ if (typeof value !== 'string' || !/^[0-9a-f]{64}$/i.test(value)) {
8
+ return undefined;
9
+ }
10
+ return b4a.from(value, 'hex');
11
+ }
12
+ export function isEngineBoot(value) {
13
+ if (!isEngineBootEnvelope(value)) {
14
+ return false;
15
+ }
16
+ try {
17
+ RunLog.validateEngineBoot(value);
18
+ return true;
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ }
24
+ function isEngineBootEnvelope(value) {
25
+ if (!isRecord(value)) {
26
+ return false;
27
+ }
28
+ const counter = (name) => typeof value[name] === 'number' && Number.isSafeInteger(value[name]) && value[name] >= 0;
29
+ const metadata = value.metadata;
30
+ const hasMetadata = metadata === null ||
31
+ (isRecord(metadata) && metadata.version === RunLog.VERSION && metadata.type === 'metadata');
32
+ return (value.protocolVersion === 1 &&
33
+ counter('length') &&
34
+ counter('nextSeq') &&
35
+ counter('deltasSinceCheckpoint') &&
36
+ counter('unredactedLength') &&
37
+ (value.machineVersion === null || typeof value.machineVersion === 'number') &&
38
+ (value.xstateVersion === null || typeof value.xstateVersion === 'string') &&
39
+ hasMetadata &&
40
+ 'eventState' in value &&
41
+ (value.snapshotSavedAt === undefined || typeof value.snapshotSavedAt === 'number') &&
42
+ (value.firstSavedAt === undefined || typeof value.firstSavedAt === 'number') &&
43
+ (value.redactedPendingArgs === null || typeof value.redactedPendingArgs === 'boolean') &&
44
+ typeof value.restoredRedacted === 'boolean' &&
45
+ Array.isArray(value.forkBeforeWrite) &&
46
+ Array.isArray(value.receipts) &&
47
+ Array.isArray(value.intentArgs));
48
+ }
49
+ const EMPTY_IDENTITY_FIELDS = new Set([
50
+ 'model',
51
+ 'cacheKey',
52
+ 'thinkingDefault',
53
+ 'agent.id',
54
+ 'agent.name',
55
+ 'agent.bio'
56
+ ]);
57
+ function optionalNumber(value) {
58
+ return value === undefined || typeof value === 'number';
59
+ }
60
+ function sharedSkillsFrom(values, field) {
61
+ return values.map((value) => {
62
+ const { name, hash, files } = Object(value);
63
+ if (typeof name !== 'string' || typeof hash !== 'string') {
64
+ throw new TypeError(`Invalid ${field} entry`);
65
+ }
66
+ if (files === undefined) {
67
+ return { name, hash };
68
+ }
69
+ if (!Array.isArray(files) || !files.every(isSkillFile)) {
70
+ throw new TypeError(`Invalid ${field} files`);
71
+ }
72
+ return { name, hash, files };
73
+ });
74
+ }
75
+ function isSkillFile(value) {
76
+ const { path, content } = Object(value);
77
+ return typeof path === 'string' && typeof content === 'string';
78
+ }
79
+ function goalFrom(value) {
80
+ const { objective, rounds, ms, tokens, checks, checksProve } = value;
81
+ if (typeof objective !== 'string' ||
82
+ !optionalNumber(rounds) ||
83
+ !optionalNumber(ms) ||
84
+ !optionalNumber(tokens) ||
85
+ (checks !== undefined &&
86
+ (!Array.isArray(checks) || !checks.every((check) => typeof check === 'string'))) ||
87
+ (checksProve !== undefined && typeof checksProve !== 'boolean')) {
88
+ throw new TypeError('Invalid goal');
89
+ }
90
+ return { objective, rounds, ms, tokens, checks, checksProve };
91
+ }
92
+ export function startPayloadFrom(value) {
93
+ if (!isRecord(value)) {
94
+ return {};
95
+ }
96
+ const payload = {};
97
+ if (value.resume === null || typeof value.resume === 'boolean') {
98
+ payload.resume = value.resume;
99
+ }
100
+ if (value.recoveryEvents === null || typeof value.recoveryEvents === 'boolean') {
101
+ payload.recoveryEvents = value.recoveryEvents;
102
+ }
103
+ if (Object.hasOwn(value, 'explicitEmptyIdentity')) {
104
+ if (!Array.isArray(value.explicitEmptyIdentity) ||
105
+ value.explicitEmptyIdentity.length > EMPTY_IDENTITY_FIELDS.size) {
106
+ throw new TypeError('Invalid explicit-empty identity marker');
107
+ }
108
+ const fields = new Set();
109
+ for (const field of value.explicitEmptyIdentity) {
110
+ if (typeof field !== 'string' || !EMPTY_IDENTITY_FIELDS.has(field)) {
111
+ throw new TypeError('Invalid explicit-empty identity marker');
112
+ }
113
+ fields.add(field);
114
+ }
115
+ if (fields.size) {
116
+ payload.explicitEmptyIdentity = [...fields];
117
+ }
118
+ }
119
+ if (Array.isArray(value.resolutions)) {
120
+ payload.resolutions = value.resolutions.map((resolution) => {
121
+ if (!isRecord(resolution) || typeof resolution.operationId !== 'string') {
122
+ throw new TypeError('Invalid run recovery resolution');
123
+ }
124
+ if (resolution.decision === 'retry') {
125
+ return { operationId: resolution.operationId, decision: 'retry' };
126
+ }
127
+ if (resolution.decision === 'result' && 'result' in resolution) {
128
+ return {
129
+ operationId: resolution.operationId,
130
+ decision: 'result',
131
+ result: resolution.result
132
+ };
133
+ }
134
+ if (resolution.decision === 'skip') {
135
+ return { operationId: resolution.operationId, decision: 'skip' };
136
+ }
137
+ throw new TypeError('Invalid run recovery resolution');
138
+ });
139
+ }
140
+ if (isRecord(value.knowledge)) {
141
+ payload.knowledge = knowledgeGrant(value.knowledge);
142
+ }
143
+ if (value.planMode === true) {
144
+ payload.planMode = true;
145
+ }
146
+ if (value.deferTools === true) {
147
+ payload.deferTools = true;
148
+ }
149
+ if (typeof value.parentRunId === 'string') {
150
+ payload.parentRunId = value.parentRunId;
151
+ }
152
+ if (isRecord(value.goal)) {
153
+ payload.goal = goalFrom(value.goal);
154
+ }
155
+ if (typeof value.typedText === 'string') {
156
+ payload.typedText = value.typedText;
157
+ }
158
+ if (typeof value.maxToolRounds === 'number') {
159
+ payload.maxToolRounds = checkMaxToolRounds(value.maxToolRounds);
160
+ }
161
+ if (value.replaysContext === true) {
162
+ payload.replaysContext = true;
163
+ }
164
+ if (value.modelRound === true) {
165
+ payload.modelRound = true;
166
+ }
167
+ if (value.roundCut === true) {
168
+ payload.roundCut = true;
169
+ }
170
+ if (value.showImage === true) {
171
+ payload.showImage = true;
172
+ }
173
+ if (value.mediaRound === true) {
174
+ payload.mediaRound = true;
175
+ }
176
+ if (Array.isArray(value.projectSkills)) {
177
+ payload.projectSkills = sharedSkillsFrom(value.projectSkills, 'projectSkills');
178
+ }
179
+ if (Array.isArray(value.workspaceSkills)) {
180
+ payload.workspaceSkills = sharedSkillsFrom(value.workspaceSkills, 'workspaceSkills');
181
+ }
182
+ if (value.runLog === null) {
183
+ payload.runLog = null;
184
+ }
185
+ else if (value.runLog) {
186
+ const runLog = isRecord(value.runLog) ? value.runLog : {};
187
+ payload.runLog = {
188
+ boot: runLog.boot,
189
+ digestKey: runLog.digestKey,
190
+ hostAppendTimeoutMs: typeof runLog.hostAppendTimeoutMs === 'number' ? runLog.hostAppendTimeoutMs : undefined
191
+ };
192
+ }
193
+ return payload;
194
+ }
195
+ export function assertEmptyIdentityMarkersMatchFrame(frame, fields) {
196
+ for (const field of fields) {
197
+ let value;
198
+ switch (field) {
199
+ case 'model':
200
+ value = frame.model;
201
+ break;
202
+ case 'cacheKey':
203
+ value = frame.cacheKey;
204
+ break;
205
+ case 'thinkingDefault':
206
+ value = frame.thinkingDefault;
207
+ break;
208
+ case 'agent.id':
209
+ if (frame.agent === null || frame.agent === undefined) {
210
+ throw new TypeError('Explicit-empty agent identity requires an agent frame');
211
+ }
212
+ value = frame.agent?.id;
213
+ break;
214
+ case 'agent.name':
215
+ if (frame.agent === null || frame.agent === undefined) {
216
+ throw new TypeError('Explicit-empty agent identity requires an agent frame');
217
+ }
218
+ value = frame.agent?.name;
219
+ break;
220
+ case 'agent.bio':
221
+ if (frame.agent === null || frame.agent === undefined) {
222
+ throw new TypeError('Explicit-empty agent identity requires an agent frame');
223
+ }
224
+ value = frame.agent?.bio;
225
+ break;
226
+ }
227
+ if (value !== null && value !== undefined && value !== '') {
228
+ throw new TypeError('Conflicting explicit-empty identity marker');
229
+ }
230
+ }
231
+ }
232
+ export function normalizeAgentKnobs(agent) {
233
+ const normalized = { ...agent };
234
+ if (normalized.id === null || normalized.id === undefined) {
235
+ delete normalized.id;
236
+ }
237
+ if (normalized.name === null || normalized.name === undefined) {
238
+ delete normalized.name;
239
+ }
240
+ if (normalized.bio === null || normalized.bio === undefined) {
241
+ delete normalized.bio;
242
+ }
243
+ if (normalized.handoffs === null || normalized.handoffs === undefined) {
244
+ delete normalized.handoffs;
245
+ }
246
+ if (normalized.model === null || normalized.model === undefined) {
247
+ delete normalized.model;
248
+ }
249
+ if (normalized.policy === null || normalized.policy === undefined) {
250
+ delete normalized.policy;
251
+ }
252
+ Reflect.deleteProperty(normalized, 'sandboxMode');
253
+ return normalized;
254
+ }
@@ -0,0 +1,32 @@
1
+ import type { KnowledgeGrant } from '../contract/knowledge.ts';
2
+ import type { WireSkillSource } from './requests.ts';
3
+ export interface WireSkill {
4
+ name: string;
5
+ displayName: string | undefined;
6
+ description: string;
7
+ tools: string[];
8
+ credentials: string[];
9
+ allowList: string[];
10
+ platforms: string[];
11
+ status: string;
12
+ requirements: {
13
+ binaries: WireBinary[];
14
+ credentials: readonly string[];
15
+ } | undefined;
16
+ install: unknown;
17
+ setup: unknown;
18
+ setupV2: unknown;
19
+ stub: boolean | undefined;
20
+ minCapabilityProfile: string | undefined;
21
+ emoji: string | undefined;
22
+ }
23
+ interface WireBinary {
24
+ bin: string;
25
+ minVersion: string | undefined;
26
+ command: string | undefined;
27
+ }
28
+ export declare function toWireSkill(skill: WireSkillSource): WireSkill;
29
+ export declare function unsupportedKnowledge(): Error;
30
+ export declare function unsupportedEmbeddingDeviceControl(): Error;
31
+ export declare function knowledgeGrant({ scopes, focus, k }: Record<string, unknown>): KnowledgeGrant;
32
+ export {};
@@ -0,0 +1,46 @@
1
+ import { HarnessError } from '../errors.js';
2
+ import { readSetup, toWireSetup } from '../tools/skills/manifest-parse.js';
3
+ export function toWireSkill(skill) {
4
+ const setupV2 = toWireSetup(readSetup(skill.setup));
5
+ const binaries = (skill.requires?.bins ?? []).map((bin) => ({
6
+ bin,
7
+ minVersion: skill.requires?.binMinVersions?.[bin]?.min,
8
+ command: skill.requires?.binMinVersions?.[bin]?.command
9
+ }));
10
+ return {
11
+ name: skill.name,
12
+ displayName: skill.displayName || undefined,
13
+ description: skill.description,
14
+ tools: skill.tools,
15
+ credentials: skill.credentials,
16
+ allowList: skill.allowList,
17
+ platforms: skill.platform,
18
+ status: skill.status,
19
+ requirements: skill.requires
20
+ ? { binaries, credentials: skill.requires.credentials ?? [] }
21
+ : undefined,
22
+ install: skill.install || undefined,
23
+ setup: skill.setup || undefined,
24
+ setupV2,
25
+ stub: skill.stub,
26
+ minCapabilityProfile: skill.minCapabilityProfile || undefined,
27
+ emoji: skill.emoji || undefined
28
+ };
29
+ }
30
+ export function unsupportedKnowledge() {
31
+ return new Error('harness does not support knowledge');
32
+ }
33
+ export function unsupportedEmbeddingDeviceControl() {
34
+ return new HarnessError('CAPABILITY_UNSUPPORTED', ['embedding device control']);
35
+ }
36
+ export function knowledgeGrant({ scopes, focus, k }) {
37
+ if (!isStrings(scopes) ||
38
+ (focus !== undefined && !isStrings(focus)) ||
39
+ (k !== undefined && !(typeof k === 'number' && Number.isSafeInteger(k) && k > 0))) {
40
+ throw new TypeError('Invalid knowledge grant');
41
+ }
42
+ return { scopes, focus, k };
43
+ }
44
+ function isStrings(value) {
45
+ return Array.isArray(value) && value.every((item) => typeof item === 'string');
46
+ }
@@ -1,3 +1,7 @@
1
1
  import { type Stream } from './rpc-session.ts';
2
2
  import type { HarnessContract } from './contract-types.ts';
3
- export declare function serveHarness(stream: Stream, harness: HarnessContract): void;
3
+ declare function serveHarness(stream: Stream, harness: HarnessContract): void;
4
+ export declare class HarnessServer {
5
+ static serve: typeof serveHarness;
6
+ }
7
+ export {};