@qvac/harness 1.0.0-rc.7 → 1.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -13
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +11 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +0 -13
- package/dist-lib/lib/capabilities/completion-engine/driver.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/round.js +24 -8
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +1 -1
- package/dist-lib/lib/capabilities/download.d.ts +1 -1
- package/dist-lib/lib/capabilities/kv-cache.d.ts +1 -1
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +1 -1
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-prompt-log.d.ts +1 -1
- package/dist-lib/lib/capabilities/tool-turns.d.ts +2 -0
- package/dist-lib/lib/capabilities/tool-turns.js +4 -0
- package/dist-lib/lib/contract/completion.d.ts +1 -1
- package/dist-lib/lib/contract/drive.d.ts +2 -2
- package/dist-lib/lib/contract/models.d.ts +1 -1
- package/dist-lib/lib/contract/speech.d.ts +1 -1
- package/dist-lib/lib/contract-types.d.ts +1 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +12 -0
- package/dist-lib/lib/machine/completion/types.d.ts +2 -0
- package/dist-lib/lib/models/context.d.ts +1 -1
- package/dist-lib/lib/models/model-catalog.d.ts +1 -1
- package/dist-lib/lib/models/model-delete.d.ts +1 -1
- package/dist-lib/lib/models/model-fit.d.ts +1 -1
- package/dist-lib/lib/models/model-list.d.ts +1 -1
- package/dist-lib/lib/models/model-pool.d.ts +3 -3
- package/dist-lib/lib/models/model-source.d.ts +2 -2
- package/dist-lib/lib/models/tool-dialect.d.ts +1 -1
- package/dist-lib/lib/policy/index.d.ts +2 -1
- package/dist-lib/lib/policy/index.js +6 -0
- package/dist-lib/lib/tools/fs/drive.d.ts +1 -16
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +23 -1
- package/dist-lib/lib/tools/fs/remote-protocol.js +1 -1
- package/dist-lib/lib/tools/fs/remote.d.ts +1 -8
- package/dist-lib/lib/tools/fs/remote.js +1 -1
- package/dist-lib/lib/tools/skills/frontmatter-parser.d.ts +1 -0
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +1 -0
- package/dist-lib/plugins/sandbox-linux/index.d.ts +3 -1
- package/dist-lib/plugins/sandbox-linux/index.js +10 -3
- package/dist-lib/plugins/sandbox-macos/index.d.ts +3 -1
- package/dist-lib/plugins/sandbox-macos/index.js +10 -5
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/package.json +16 -38
- package/patches/@qvac%2Finference@0.22.0.patch +0 -59
package/CHANGELOG.md
CHANGED
|
@@ -21,6 +21,16 @@ breaking change is listed under Changed and Removed.
|
|
|
21
21
|
|
|
22
22
|
### Added
|
|
23
23
|
|
|
24
|
+
- The macOS and Linux sandboxes take `writable`: absolute folders every shell line may write on
|
|
25
|
+
top of the run's policy, for a toolchain cache outside the project such as Go's build cache.
|
|
26
|
+
The file tools never see them, they are made at setup if missing, and a denied root still wins.
|
|
27
|
+
`Policy.withWrites(policy, roots)` returns a compiled policy that may also write those roots.
|
|
28
|
+
- A call that fails three times in a row, such as a test command the model
|
|
29
|
+
keeps patching against, comes back with a note telling the model to step
|
|
30
|
+
back: re-read the output and the requirements, find what the failures share
|
|
31
|
+
and change approach. The note repeats every third failure and a success
|
|
32
|
+
clears the streak. `wording.toolFailing` replaces the text; `{count}` is the
|
|
33
|
+
streak length.
|
|
24
34
|
- `Tools.product` takes `files: false` to leave the file tools out, for a host
|
|
25
35
|
with no folder to share, such as a phone entry that composes its tools with
|
|
26
36
|
the mcp, web-search and weather plugins. `isDeviceSharedCredentialKey` from
|
|
@@ -430,6 +440,15 @@ breaking change is listed under Changed and Removed.
|
|
|
430
440
|
|
|
431
441
|
### Changed
|
|
432
442
|
|
|
443
|
+
- A host reaches the drive protocol it serves, the skill catalog and the
|
|
444
|
+
user-plugin import map through named entries: `@qvac/harness/drive`
|
|
445
|
+
(`DriveRequest`, `DriveResponse`, `DriveEntry`, `GrantedDrive`, `DriveOpFn`,
|
|
446
|
+
`MAX_DRIVE_BYTES`), `@qvac/harness/skill-catalog` (`loadSkillCatalog`,
|
|
447
|
+
`availableSkills`) and `@qvac/harness/user-plugins` (`sharedImports`), and
|
|
448
|
+
`@qvac/harness/skill-manifest` adds `readSkillSetup`. `test/entry-weight.ts`
|
|
449
|
+
holds every named entry to a ceiling on the files importing it loads, so a
|
|
450
|
+
host that imports a constant never parses the engine. (#636)
|
|
451
|
+
|
|
433
452
|
- Every host that runs python, on Bare or Node, recopies
|
|
434
453
|
`patches/pyodide@314.0.2.patch` into its `patchedDependencies`. Guest Python
|
|
435
454
|
sees: `ctypes` calls to `emscripten_run_script*` do nothing and return 0, a
|
|
@@ -574,27 +593,23 @@ breaking change is listed under Changed and Removed.
|
|
|
574
593
|
(#453, #480)
|
|
575
594
|
- A response cut off by the length limit runs its complete calls; only the
|
|
576
595
|
call the cut truncated is answered, and a truncated call to a tool that is
|
|
577
|
-
not loaded is answered as cut. A cut
|
|
596
|
+
not loaded is answered as cut. A cut at a `predict` cap gets
|
|
578
597
|
`wording.toolCutOff`; any other `length` cut gets
|
|
579
598
|
`wording.toolContextBoundary`, which says the context window filled before
|
|
580
599
|
the arguments were complete. (#155, #450, #454, #458)
|
|
581
600
|
- With tools on, a prose round cut at the context window is retried with the
|
|
582
601
|
history folded, or wrapped up, instead of answered with its fragment. A cut
|
|
583
|
-
|
|
602
|
+
at a `predict` cap (`contextBoundary: false`), or a round with
|
|
584
603
|
no tools, keeps the fragment. `round-reset` fires only when the round is
|
|
585
604
|
retried or wrapped. (#456, #483)
|
|
586
|
-
-
|
|
587
|
-
`
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
cap and any other `length` stop as the context window: a cut call gets
|
|
605
|
+
- The round sets `contextBoundary` on every `length` stop: `true` at the
|
|
606
|
+
context window, `false` at a `predict` cap. Every round, the wrap-up
|
|
607
|
+
included, reads a stop flagged `false` as the output cap and any other
|
|
608
|
+
`length` stop as the context window: a cut call gets
|
|
591
609
|
`wording.toolContextBoundary`, a cut prose round with tools on is retried
|
|
592
610
|
with a fold, a wrap-up answers with the fallback and emits `round-reset`, and
|
|
593
611
|
`RoundSpeed.contextBoundary` is `true`. A stop flagged as the cap no longer
|
|
594
|
-
makes the next round fold.
|
|
595
|
-
`length` stop, a `predict` cap included, reads as the window, and the harness
|
|
596
|
-
logs this once. See [Install](docs/hosting.md#install). (#450, #481, #485,
|
|
597
|
-
#488)
|
|
612
|
+
makes the next round fold. (#450, #481, #485, #488, #647)
|
|
598
613
|
- A host that runs python on Node recopies `patches/pyodide@314.0.2.patch`
|
|
599
614
|
into its `patchedDependencies`. Pyodide now loads `child-process-stub.cjs`
|
|
600
615
|
by path, so guest `os.system` cannot spawn a process on Node either. A Bare
|
|
@@ -654,8 +669,8 @@ breaking change is listed under Changed and Removed.
|
|
|
654
669
|
now ends the run at its fourth identical run. The re-read after a fold carries
|
|
655
670
|
no unchanged note and no progress credit. (#507)
|
|
656
671
|
- A wrap-up cut off at the context window answers with the fallback instead of
|
|
657
|
-
its fragment and emits `round-reset` for what it streamed; a wrap-up
|
|
658
|
-
|
|
672
|
+
its fragment and emits `round-reset` for what it streamed; a wrap-up
|
|
673
|
+
cut at its `predict` cap (`contextBoundary: false`) keeps its
|
|
659
674
|
text as the answer. The run's outcome does not
|
|
660
675
|
change. The wrap-up sends `predict` as `reasoning_budget + 4096`; a host
|
|
661
676
|
`predict` wins. (#452, #480)
|
|
@@ -960,6 +975,15 @@ breaking change is listed under Changed and Removed.
|
|
|
960
975
|
|
|
961
976
|
### Removed
|
|
962
977
|
|
|
978
|
+
- The eight file exports 1.0.0-rc.7 added for hosts:
|
|
979
|
+
`./lib/tools/fs/drive.ts`, `remote.ts` and `remote-protocol.ts`, and
|
|
980
|
+
`./lib/tools/skills/skill-state.ts`, `credential-slots.ts`,
|
|
981
|
+
`manifest-parse.ts`, `overlay-crud.ts` and `scope-key.ts`. Import
|
|
982
|
+
`@qvac/harness/drive`, `@qvac/harness/skill-state` (`SKILL_STATE`,
|
|
983
|
+
`isDeviceSharedCredentialKey`), `@qvac/harness/skill-manifest`
|
|
984
|
+
(`credentialSlots`, `readSkillSetup`), and the `ManagedSkill` and
|
|
985
|
+
`SkillFileContent` types from `@qvac/harness`. (#636)
|
|
986
|
+
|
|
963
987
|
- **Breaking:** `harnessLogEnabled` from `./lib/log.ts`: use
|
|
964
988
|
`HarnessLog.enabled(level)` or `HarnessLog.level()`. (#471, #506, #532)
|
|
965
989
|
- **Breaking:** `./lib/log.ts` exports the `HarnessLog` class in place of the
|
|
@@ -1023,6 +1047,13 @@ breaking change is listed under Changed and Removed.
|
|
|
1023
1047
|
|
|
1024
1048
|
### Fixed
|
|
1025
1049
|
|
|
1050
|
+
- A host needs neither `@qvac/sdk` nor a patch of `@qvac/inference`. The
|
|
1051
|
+
published types import `@qvac/inference`, so a Bare host type-checks
|
|
1052
|
+
without the SDK or a `tsconfig` path, and the round tells a `length` stop at
|
|
1053
|
+
the context window from one at a `predict` cap from the `predict` it sent.
|
|
1054
|
+
A host drops its copy of `patches/@qvac%2Finference@0.22.0.patch`; one that
|
|
1055
|
+
keeps it sees the same behaviour. (#647)
|
|
1056
|
+
|
|
1026
1057
|
- A message keeps the wire layout 0.8.13 shipped: `sentAt` is its fourth
|
|
1027
1058
|
field again, ahead of `toolCalls`, `toolCallId`, `name`, `id` and `context`.
|
|
1028
1059
|
Up to rc.6 a 1.0 harness could not decode a message from a 0.8.13 host that
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { type HarnessSkillsOptions } from './lib/skills-host/index.ts';
|
|
|
26
26
|
import type { CredentialStoreFn, CredentialStoreValue } from './lib/tools/skills/auth-resolver.ts';
|
|
27
27
|
import type { CopyBaseResult, DeleteOverlayResult, ManagedSkill, SkillFileContent } from './lib/tools/skills/overlay-crud.ts';
|
|
28
28
|
import { HarnessLog } from './lib/log.ts';
|
|
29
|
-
import {
|
|
29
|
+
import type { DriveOpFn, GrantedDrive } from './lib/tools/fs/remote-protocol.ts';
|
|
30
30
|
import type { ResolvedSkillCatalogEntry } from './lib/tools/skills/catalog.ts';
|
|
31
31
|
import type { SkillSettingEntry } from './lib/tools/skills/skill-settings.ts';
|
|
32
32
|
export type * from './lib/contract/index.ts';
|
|
@@ -4,7 +4,7 @@ import { spliceFrom } from '../splice.js';
|
|
|
4
4
|
import { answerOf, callSucceeded, readyPreflightFromFacts, reportFailure, settledFailure } from '../tool-execution.js';
|
|
5
5
|
import { directToolHistory } from '../turns.js';
|
|
6
6
|
import { labelOf } from '../loop.js';
|
|
7
|
-
import { DIRECT_CALL_ID, deliversFile, historyPayload, materializeCompletionHistory, withHookContext, toolResultHistoryEntry, toolResultTurn } from '../../tool-turns.js';
|
|
7
|
+
import { DIRECT_CALL_ID, FAILURE_STREAK, TOOL_FAILING_MESSAGE, deliversFile, historyPayload, materializeCompletionHistory, withHookContext, toolResultHistoryEntry, toolResultTurn } from '../../tool-turns.js';
|
|
8
8
|
import { defers, TOOL_SEARCH_TOOL_NAME } from '../../sdk-tool.js';
|
|
9
9
|
import { executionPlan, trustedSources } from './execution-plan.js';
|
|
10
10
|
import { runToolCall } from './execute.js';
|
|
@@ -141,6 +141,15 @@ function textsOf(value) {
|
|
|
141
141
|
}
|
|
142
142
|
return value && typeof value === 'object' ? Object.values(value).flatMap(textsOf) : [];
|
|
143
143
|
}
|
|
144
|
+
function failingNoted(context, { key: callKey, output, outcome }) {
|
|
145
|
+
if (!settledFailure(output, outcome)) {
|
|
146
|
+
return output;
|
|
147
|
+
}
|
|
148
|
+
const streak = (context.failureStreaks?.[callKey] ?? 0) + 1;
|
|
149
|
+
return streak % FAILURE_STREAK === 0
|
|
150
|
+
? withHookContext(output, (context.policy.failingMessage ?? TOOL_FAILING_MESSAGE).replaceAll('{count}', String(streak)))
|
|
151
|
+
: output;
|
|
152
|
+
}
|
|
144
153
|
export function settleCall({ input: { session }, context }, { ran, direct, emit }) {
|
|
145
154
|
const { plan, denied, landedBefore, executed, durationMs } = ran;
|
|
146
155
|
const { call, key: callKey, args: callArgs } = plan.resolved;
|
|
@@ -152,7 +161,7 @@ export function settleCall({ input: { session }, context }, { ran, direct, emit
|
|
|
152
161
|
const unchanged = repeated && !silent(historyPayload(executed.output));
|
|
153
162
|
const output = unchanged && !prior.folded
|
|
154
163
|
? withHookContext(executed.output, context.policy.unchangedMessage.replaceAll('{count}', String(prior.repeats + 2)))
|
|
155
|
-
: executed.output;
|
|
164
|
+
: failingNoted(context, { key: callKey, output: executed.output, outcome });
|
|
156
165
|
if (outcome.kind !== 'success' && session.landed.length > landedBefore) {
|
|
157
166
|
session.landed.length = landedBefore;
|
|
158
167
|
}
|
|
@@ -3,9 +3,6 @@ import { recordWholeRound, runRecoveredRound } from '../round.js';
|
|
|
3
3
|
import { ModelRound } from '../model-round.js';
|
|
4
4
|
import { ToolSets } from '../tool-sets.js';
|
|
5
5
|
import { AbortedError } from '../../../helpers/race-abort.js';
|
|
6
|
-
import { HarnessLog } from '../../../log.js';
|
|
7
|
-
const BOUNDARY_UNFLAGGED = "length stop without contextBoundary: the host's @qvac/inference patch lacks the contextBoundary hunk";
|
|
8
|
-
let boundaryUnflaggedLogged = false;
|
|
9
6
|
export async function forwardStream({ stream, emit }) {
|
|
10
7
|
try {
|
|
11
8
|
while (true) {
|
|
@@ -39,7 +36,6 @@ export async function runRound({ sdk, modelRound, kind, args, session, emit }) {
|
|
|
39
36
|
emit
|
|
40
37
|
});
|
|
41
38
|
session.liveRound = null;
|
|
42
|
-
logUnflaggedBoundary(round.final, args.round, kind);
|
|
43
39
|
return round;
|
|
44
40
|
}
|
|
45
41
|
catch (error) {
|
|
@@ -83,15 +79,6 @@ async function remoteRound({ port, kind, args, runId, emit }) {
|
|
|
83
79
|
cut: result.cut
|
|
84
80
|
};
|
|
85
81
|
}
|
|
86
|
-
function logUnflaggedBoundary(final, round, kind) {
|
|
87
|
-
if (boundaryUnflaggedLogged || final.stopReason !== 'length')
|
|
88
|
-
return;
|
|
89
|
-
if (final.stats?.contextBoundary !== undefined)
|
|
90
|
-
return;
|
|
91
|
-
boundaryUnflaggedLogged = true;
|
|
92
|
-
const log = HarnessLog.enabled('info') ? HarnessLog.info : HarnessLog.diag;
|
|
93
|
-
log(BOUNDARY_UNFLAGGED, { round, kind });
|
|
94
|
-
}
|
|
95
82
|
export async function assembleAnswer({ contentText, replay, landed, emit }) {
|
|
96
83
|
let response = replay || contentText;
|
|
97
84
|
if (replay) {
|
|
@@ -361,6 +361,7 @@ function runPolicy({ maxToolRounds, goal, wording }) {
|
|
|
361
361
|
roundCutMessage: wording?.toolRoundCut ?? TOOL_ROUND_CUT_MESSAGE,
|
|
362
362
|
repeatedCallMessage: wording?.toolRepeated ?? TOOL_REPEATED_MESSAGE,
|
|
363
363
|
unchangedMessage: wording?.toolUnchanged ?? TOOL_UNCHANGED_MESSAGE,
|
|
364
|
+
failingMessage: wording?.toolFailing,
|
|
364
365
|
goalNudge: wording?.goalContinuation ?? GOAL_CONTINUATION_NUDGE
|
|
365
366
|
};
|
|
366
367
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompletionFinal, Tool as SdkTool, ToolDialect } from '@qvac/
|
|
1
|
+
import type { CompletionFinal, Tool as SdkTool, ToolDialect } from '@qvac/inference';
|
|
2
2
|
import { type AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { TextEvent } from '../../helpers/thinking.ts';
|
|
4
4
|
import type { CompletionSdk, LlmGenerationParams, Message, ResponseFormat, RoundModelLease, RunLifecycleEvent } from '../../contract/index.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompletionFinal, CompletionStats, Tool as SdkTool, ToolDialect } from '@qvac/
|
|
1
|
+
import type { CompletionFinal, CompletionStats, Tool as SdkTool, ToolDialect } from '@qvac/inference';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import { type KnownTool } from '../../helpers/tool-call-markup.ts';
|
|
4
4
|
import { type TextEvent } from '../../helpers/thinking.ts';
|
|
@@ -218,11 +218,22 @@ export function foldTokens(stats, cacheable) {
|
|
|
218
218
|
return undefined;
|
|
219
219
|
return stats.promptTokens + (stats.generatedTokens ?? 0);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function slotStats(stats, previous) {
|
|
222
222
|
if (!stats)
|
|
223
223
|
return undefined;
|
|
224
224
|
const { cacheTokens: _summed, ...rest } = stats;
|
|
225
|
-
|
|
225
|
+
if (previous === undefined || stats.promptTokens === undefined) {
|
|
226
|
+
return rest;
|
|
227
|
+
}
|
|
228
|
+
return { ...rest, cacheTokens: previous + stats.promptTokens + (stats.generatedTokens ?? 0) };
|
|
229
|
+
}
|
|
230
|
+
function boundaryStats(final, predict) {
|
|
231
|
+
const stats = copy(final.stats);
|
|
232
|
+
if (final.stopReason !== 'length' || stats?.contextBoundary !== undefined) {
|
|
233
|
+
return stats;
|
|
234
|
+
}
|
|
235
|
+
const capped = predict !== undefined && predict > 0 && (stats?.generatedTokens ?? 0) >= predict;
|
|
236
|
+
return { ...stats, contextBoundary: !capped };
|
|
226
237
|
}
|
|
227
238
|
function roundTokens(stats) {
|
|
228
239
|
if (!stats)
|
|
@@ -256,7 +267,7 @@ export async function* runRecoveredRound(sdk, args) {
|
|
|
256
267
|
}
|
|
257
268
|
const ctxSize = lease?.ctxSize ?? args.fold?.ctxSize;
|
|
258
269
|
const slotted = (lease?.slots ?? 1) > 1;
|
|
259
|
-
const attempts = { sent: 0, uncached:
|
|
270
|
+
const attempts = { sent: 0, uncached: false, overflows: 0, unsettled };
|
|
260
271
|
const round = yield* runRecoveredRoundWith({
|
|
261
272
|
sdk: roundSdk,
|
|
262
273
|
args,
|
|
@@ -264,16 +275,21 @@ export async function* runRecoveredRound(sdk, args) {
|
|
|
264
275
|
ctxSize,
|
|
265
276
|
attempts
|
|
266
277
|
});
|
|
278
|
+
const final = slotted
|
|
279
|
+
? {
|
|
280
|
+
...round.final,
|
|
281
|
+
stats: slotStats(round.final.stats, round.cacheable !== false && args.cacheKey
|
|
282
|
+
? (Fold.reading(args.cacheKey)?.cacheTokens ?? 0)
|
|
283
|
+
: undefined)
|
|
284
|
+
}
|
|
285
|
+
: round.final;
|
|
267
286
|
if (args.fold?.cacheKey) {
|
|
268
287
|
Fold.observe(args.fold.cacheKey, {
|
|
269
|
-
cacheTokens: foldTokens(
|
|
288
|
+
cacheTokens: foldTokens(final.stats, round.cacheable),
|
|
270
289
|
ctxSize
|
|
271
290
|
});
|
|
272
291
|
}
|
|
273
292
|
const overflows = attempts.overflows ? { overflows: attempts.overflows } : {};
|
|
274
|
-
const final = slotted
|
|
275
|
-
? { ...round.final, stats: withoutCacheTokens(round.final.stats) }
|
|
276
|
-
: round.final;
|
|
277
293
|
return { ...round, final, ctxSize: lease?.ctxSize, ...overflows };
|
|
278
294
|
}
|
|
279
295
|
finally {
|
|
@@ -679,7 +695,7 @@ async function* runCandidate({ sdk, args, modelId, candidate, progress, baseHist
|
|
|
679
695
|
...final,
|
|
680
696
|
toolCalls: copy(state.runaway || state.cut !== null ? state.calls : (final.toolCalls ?? [])),
|
|
681
697
|
toolErrors: copy(final.toolErrors ?? []),
|
|
682
|
-
stats:
|
|
698
|
+
stats: boundaryStats(final, params.generationParams?.predict)
|
|
683
699
|
};
|
|
684
700
|
if (args.capture) {
|
|
685
701
|
yield inferenceSent({ args, candidate, final: detachedFinal });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tool as SdkTool } from '@qvac/
|
|
1
|
+
import type { Tool as SdkTool } from '@qvac/inference';
|
|
2
2
|
import type { HookPipeline } from '../../hooks/index.ts';
|
|
3
3
|
import { type RunOutcomeTracker } from '../../helpers/run-outcome.ts';
|
|
4
4
|
import type { AgentPolicy, AgentPorts, CompletionEvent, CliValidator, CompiledPolicy, CompletionSdk, DriveRoot, LlmGenerationParams, OutboundGuard, RunBackendUse, RunBudget, SkillActivation, ToolDefinition } from '../../contract/index.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToolCallWithCall } from '@qvac/
|
|
1
|
+
import type { ToolCallWithCall } from '@qvac/inference';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { HookPipeline } from '../../hooks/index.ts';
|
|
4
4
|
import type { NetworkMode, PreToolCallPayload, ToolFailurePayload } from '../../contract/index.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
-
import type { ModelProgressUpdate } from '@qvac/
|
|
2
|
+
import type { ModelProgressUpdate } from '@qvac/inference';
|
|
3
3
|
import { Readable } from 'streamx';
|
|
4
4
|
import { type ModelAddon, type ModelRegistrySdk } from '../models/model-source.ts';
|
|
5
5
|
export type DownloadProgress = Omit<ModelProgressUpdate, 'type'>;
|
|
@@ -7,7 +7,7 @@ export type KvCacheDeletionResult = {
|
|
|
7
7
|
status: 'unsupported';
|
|
8
8
|
error: string;
|
|
9
9
|
};
|
|
10
|
-
type KvCacheSdk = Pick<typeof import('@qvac/
|
|
10
|
+
type KvCacheSdk = Pick<typeof import('@qvac/inference'), 'deleteCache'>;
|
|
11
11
|
export declare function deleteAllKvCaches(loadSdk: () => Promise<KvCacheSdk>): Promise<KvCacheDeletionResult>;
|
|
12
12
|
export declare function deleteKvCacheKey(loadSdk: () => Promise<KvCacheSdk>, kvCacheKey: string): Promise<KvCacheDeletionResult>;
|
|
13
13
|
export declare function unsupportedKvCacheDeletion(error?: string): KvCacheDeletionResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tool as SdkTool } from '@qvac/
|
|
1
|
+
import type { Tool as SdkTool } from '@qvac/inference';
|
|
2
2
|
import type { AgentSkill, CompletionHistoryEntry, Message, ToolDefinition } from '../contract/index.ts';
|
|
3
3
|
export declare const TOOL_SEARCH_TOOL_NAME: string;
|
|
4
4
|
export declare function defers(tool: ToolDefinition): boolean;
|
|
@@ -11,6 +11,8 @@ export declare const TOOL_CUT_OFF_MESSAGE: string;
|
|
|
11
11
|
export declare const TOOL_ROUND_CUT_MESSAGE: string;
|
|
12
12
|
export declare const TOOL_CONTEXT_BOUNDARY_MESSAGE: string;
|
|
13
13
|
export declare const TOOL_REPEATED_MESSAGE: string;
|
|
14
|
+
export declare const TOOL_FAILING_MESSAGE: string;
|
|
15
|
+
export declare const FAILURE_STREAK = 3;
|
|
14
16
|
export declare const TOOL_UNCHANGED_MESSAGE: string;
|
|
15
17
|
export declare const GOAL_CONTINUATION_NUDGE: string;
|
|
16
18
|
export declare function checkMaxToolRounds(rounds: number): number;
|
|
@@ -24,6 +24,10 @@ export const TOOL_CONTEXT_BOUNDARY_MESSAGE = 'This tool call was not executed: t
|
|
|
24
24
|
'them short.';
|
|
25
25
|
export const TOOL_REPEATED_MESSAGE = 'You sent the same tool call more than once in one response. It ran once, and its result ' +
|
|
26
26
|
'is below. Send each call once.';
|
|
27
|
+
export const TOOL_FAILING_MESSAGE = 'This call has failed {count} times in a row. Before changing anything again, step back: ' +
|
|
28
|
+
're-read the failing output and the requirements, work out what the failures have in common, ' +
|
|
29
|
+
'and change your approach instead of patching the last error.';
|
|
30
|
+
export const FAILURE_STREAK = 3;
|
|
27
31
|
export const TOOL_UNCHANGED_MESSAGE = 'This call returned the same result the last {count} times it ran. Running it again will ' +
|
|
28
32
|
'not change it: use the result you have, try something else, or answer.';
|
|
29
33
|
export const GOAL_CONTINUATION_NUDGE = '[The goal is not met yet. Keep working on it: call the next tool. Track the work with ' +
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompletionEvent as SdkCompletionEvent, CompletionFinal, Tool as SdkTool, ToolCallWithCall, ToolDialect } from '@qvac/
|
|
1
|
+
import type { CompletionEvent as SdkCompletionEvent, CompletionFinal, Tool as SdkTool, ToolCallWithCall, ToolDialect } from '@qvac/inference';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { TextEvent } from '../helpers/thinking.ts';
|
|
4
4
|
import type { LlmGenerationParams } from '../models/llm-presets.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { DriveDir, DriveEntry } from '../tools/fs/
|
|
2
|
-
export type { DriveOpFn, GrantedDrive } from '../tools/fs/remote.ts';
|
|
1
|
+
export type { DriveDir, DriveEntry } from '../tools/fs/remote-protocol.ts';
|
|
2
|
+
export type { DriveOpFn, GrantedDrive } from '../tools/fs/remote-protocol.ts';
|
|
3
3
|
export type { DriveEntryRequest, DriveGetRequest, DriveListRequest, DriveReadRequest, DriveRequest, DriveResponse, DriveSearchQuery, DriveSearchRequest, DriveWriteRequest } from '../tools/fs/remote-protocol.ts';
|
|
4
4
|
export type { SearchHit } from '../tools/fs/search.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { createVectorIndex, loadVectorIndex } from '@qvac/
|
|
1
|
+
import type { createVectorIndex, loadVectorIndex } from '@qvac/inference';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { ModelSrc } from '../models/context.ts';
|
|
4
4
|
import type { HoldFn } from '../models/download-gate.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TextToSpeechStreamClientParams, TextToSpeechStreamSession } from '@qvac/
|
|
1
|
+
import type { TextToSpeechStreamClientParams, TextToSpeechStreamSession } from '@qvac/inference';
|
|
2
2
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
3
3
|
import type { CapabilityProfile } from '../models/model-catalog-constants.ts';
|
|
4
4
|
export type TtsStreamSession = TextToSpeechStreamSession;
|
|
@@ -12,7 +12,7 @@ import type { DeleteModelSummary } from './models/model-delete.ts';
|
|
|
12
12
|
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
|
-
import type { DriveOpFn, GrantedDrive } from './tools/fs/remote.ts';
|
|
15
|
+
import type { DriveOpFn, GrantedDrive } from './tools/fs/remote-protocol.ts';
|
|
16
16
|
import type { SpeakResult } from './contract/speech.ts';
|
|
17
17
|
import type { RunInput } from './contract/completion.ts';
|
|
18
18
|
import type { RunGoal, TurnContext } from './contract/run.ts';
|
|
@@ -158,6 +158,17 @@ function unchangedRound(context, payload) {
|
|
|
158
158
|
function settledSince(settled) {
|
|
159
159
|
return Object.fromEntries(Object.entries(settled).map(([key, result]) => [key, { ...result, repeats: 0 }]));
|
|
160
160
|
}
|
|
161
|
+
function failureStreaks(context, payload) {
|
|
162
|
+
const streaks = context.failureStreaks;
|
|
163
|
+
if (payload.failed) {
|
|
164
|
+
return { ...streaks, [payload.failed.key]: (streaks?.[payload.failed.key] ?? 0) + 1 };
|
|
165
|
+
}
|
|
166
|
+
if (streaks && payload.settled && payload.settled.key in streaks) {
|
|
167
|
+
const { [payload.settled.key]: _cleared, ...rest } = streaks;
|
|
168
|
+
return rest;
|
|
169
|
+
}
|
|
170
|
+
return streaks;
|
|
171
|
+
}
|
|
161
172
|
function applyToolResult(context, payload, call) {
|
|
162
173
|
const failedCalls = payload.failed
|
|
163
174
|
? {
|
|
@@ -184,6 +195,7 @@ function applyToolResult(context, payload, call) {
|
|
|
184
195
|
: context.deniedKeys,
|
|
185
196
|
failedCalls,
|
|
186
197
|
blockedRepeats: context.blockedRepeats + (payload.blockedRepeat || unchangedRound(context, payload) ? 1 : 0),
|
|
198
|
+
failureStreaks: failureStreaks(context, payload),
|
|
187
199
|
settledResults: payload.settled
|
|
188
200
|
? {
|
|
189
201
|
...(payload.progressed ? settledSince(context.settledResults) : context.settledResults),
|
|
@@ -254,6 +254,7 @@ export interface RunPolicy {
|
|
|
254
254
|
roundCutMessage: string;
|
|
255
255
|
repeatedCallMessage: string;
|
|
256
256
|
unchangedMessage: string;
|
|
257
|
+
failingMessage?: string;
|
|
257
258
|
goalNudge: string;
|
|
258
259
|
}
|
|
259
260
|
export interface SettledResult {
|
|
@@ -309,6 +310,7 @@ export interface CompletionContext {
|
|
|
309
310
|
failedCalls: Record<string, SettledCall>;
|
|
310
311
|
blockedRepeats: number;
|
|
311
312
|
settledResults: Record<string, SettledResult>;
|
|
313
|
+
failureStreaks?: Record<string, number>;
|
|
312
314
|
answeredReads?: string[];
|
|
313
315
|
roundProgressed: boolean;
|
|
314
316
|
answer: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelRegistryEntry, ToolDialect } from '@qvac/
|
|
1
|
+
import type { ModelRegistryEntry, ToolDialect } from '@qvac/inference';
|
|
2
2
|
import type { ModelSrc } from './context.ts';
|
|
3
3
|
import type { ModelAddon } from './model-source.ts';
|
|
4
4
|
export interface SdkModelAsset extends ModelRegistryEntry {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssessModelFitInput, AssessModelFitResult } from '@qvac/
|
|
1
|
+
import type { AssessModelFitInput, AssessModelFitResult } from '@qvac/inference';
|
|
2
2
|
export type ModelFitVerdict = AssessModelFitResult['verdict'];
|
|
3
3
|
export type ModelFitBasis = AssessModelFitResult['basis'];
|
|
4
4
|
export type ModelFitEvidence = NonNullable<AssessModelFitResult['evidence']>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as QvacSdk from '@qvac/
|
|
1
|
+
import type * as QvacSdk from '@qvac/inference';
|
|
2
2
|
import { type ModelAddon, type ModelRegistrySdk } from './model-source.ts';
|
|
3
3
|
import { type ModelTaskType } from './model-task.ts';
|
|
4
4
|
import type { ModelFitBasis, ModelFitEvidence, ModelFitVerdict } from './model-fit.ts';
|
|
@@ -4,11 +4,11 @@ import { type ModelSrc } from './context.ts';
|
|
|
4
4
|
import type { CpuPlacement } from '../hardware/cpu-placement.ts';
|
|
5
5
|
import { type ModelAddon } from './model-source.ts';
|
|
6
6
|
import type { GpuFaultState } from './sdk-faults.ts';
|
|
7
|
-
import type { LoadedModelInfo } from '@qvac/
|
|
7
|
+
import type { LoadedModelInfo } from '@qvac/inference';
|
|
8
8
|
import type { LoadedModel } from '../contract-types.ts';
|
|
9
9
|
import type { HoldFn } from './download-gate.ts';
|
|
10
|
-
type SdkModule = typeof import('@qvac/
|
|
11
|
-
type FitModelType = NonNullable<import('@qvac/
|
|
10
|
+
type SdkModule = typeof import('@qvac/inference');
|
|
11
|
+
type FitModelType = NonNullable<import('@qvac/inference').AssessModelFitInput['models'][number]['modelType']>;
|
|
12
12
|
export interface FitProbeSdk {
|
|
13
13
|
getLoadedModelInfo?(params: {
|
|
14
14
|
modelId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type * as QvacSdk from '@qvac/
|
|
2
|
-
import type { ModelRegistryEntryAddon } from '@qvac/
|
|
1
|
+
import type * as QvacSdk from '@qvac/inference';
|
|
2
|
+
import type { ModelRegistryEntryAddon } from '@qvac/inference';
|
|
3
3
|
import type { ModelSrc } from './context.ts';
|
|
4
4
|
export type ModelRegistrySdk = Pick<typeof QvacSdk, 'modelRegistrySearch'>;
|
|
5
5
|
export type ModelAddon = ModelRegistryEntryAddon;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ToolDialect } from '@qvac/
|
|
1
|
+
import type { ToolDialect } from '@qvac/inference';
|
|
2
2
|
export declare function detectToolDialect(src: string, name?: string): ToolDialect | undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { AccessPolicy, CompiledPolicy, PolicyGrants, PolicyProvider, RunRoots } from '../contract/policy.ts';
|
|
1
|
+
import type { AccessPolicy, CompiledPolicy, PolicyGrants, PolicyProvider, PolicyRoot, RunRoots } from '../contract/policy.ts';
|
|
2
2
|
export declare class Policy {
|
|
3
3
|
static narrow(...layers: readonly (AccessPolicy | null | undefined)[]): AccessPolicy;
|
|
4
4
|
static compile(policy: AccessPolicy | null | undefined, grants?: PolicyGrants): CompiledPolicy;
|
|
5
5
|
static enforceable(policy: CompiledPolicy, { enforces }: PolicyProvider): string | null;
|
|
6
6
|
static refusal(policy: CompiledPolicy, providers: readonly PolicyProvider[]): string | null;
|
|
7
7
|
static forRun(layers: readonly (AccessPolicy | null | undefined)[], { fsRoots, fsWriteRoots, deny }: RunRoots, providers: readonly PolicyProvider[]): CompiledPolicy | undefined;
|
|
8
|
+
static withWrites(policy: CompiledPolicy, roots: readonly PolicyRoot[]): CompiledPolicy;
|
|
8
9
|
static hostsOf(policy: CompiledPolicy | undefined): readonly string[] | undefined;
|
|
9
10
|
static allowsHost(hosts: readonly string[], host: string): boolean;
|
|
10
11
|
}
|
|
@@ -90,6 +90,12 @@ export class Policy {
|
|
|
90
90
|
}
|
|
91
91
|
return access;
|
|
92
92
|
}
|
|
93
|
+
static withWrites(policy, roots) {
|
|
94
|
+
if (roots.length === 0) {
|
|
95
|
+
return policy;
|
|
96
|
+
}
|
|
97
|
+
return { ...policy, files: { ...policy.files, write: [...policy.files.write, ...roots] } };
|
|
98
|
+
}
|
|
93
99
|
static hostsOf(policy) {
|
|
94
100
|
return policy?.network.mode === 'hosts' ? policy.network.hosts : undefined;
|
|
95
101
|
}
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import type { Writable } from 'streamx';
|
|
2
2
|
import { HarnessError } from '../../errors.ts';
|
|
3
|
-
|
|
4
|
-
key: string;
|
|
5
|
-
value: {
|
|
6
|
-
executable: boolean;
|
|
7
|
-
linkname: string | null;
|
|
8
|
-
blob: {
|
|
9
|
-
byteLength: number;
|
|
10
|
-
} | null;
|
|
11
|
-
metadata: unknown;
|
|
12
|
-
};
|
|
13
|
-
mtime?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface DriveDir {
|
|
16
|
-
key: string;
|
|
17
|
-
dir: true;
|
|
18
|
-
}
|
|
3
|
+
import type { DriveDir, DriveEntry } from './remote-protocol.ts';
|
|
19
4
|
export interface DriveListOptions {
|
|
20
5
|
skip?: ReadonlySet<string>;
|
|
21
6
|
recursive?: boolean;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import type { DriveDir, DriveEntry } from './drive.ts';
|
|
2
1
|
import type { SearchHit } from './search.ts';
|
|
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 declare const MAX_DRIVE_BYTES: number;
|
|
3
24
|
export interface DriveEntryRequest {
|
|
4
25
|
op: 'entry';
|
|
5
26
|
driveKey: string;
|
|
@@ -58,3 +79,4 @@ export interface DriveResponse {
|
|
|
58
79
|
cut?: boolean;
|
|
59
80
|
skippedLinks?: number;
|
|
60
81
|
}
|
|
82
|
+
export type DriveOpFn = (request: DriveRequest) => Promise<DriveResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const MAX_DRIVE_BYTES = 8 * 1024 * 1024;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DriveOpFn, type GrantedDrive } from './remote-protocol.ts';
|
|
2
2
|
import type { HyperRoot } from './scope.ts';
|
|
3
|
-
export interface GrantedDrive {
|
|
4
|
-
readonly key: string;
|
|
5
|
-
readonly writable: boolean;
|
|
6
|
-
readonly search?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export type DriveOpFn = (request: DriveRequest) => Promise<DriveResponse>;
|
|
9
3
|
export declare const DRIVE_CALL_TIMEOUT_MS = 20000;
|
|
10
4
|
export declare const DRIVE_SEARCH_TIMEOUT_MS: number;
|
|
11
|
-
export declare const MAX_DRIVE_BYTES: number;
|
|
12
5
|
export declare const DRIVE_LIST_PAGE = 256;
|
|
13
6
|
export interface RemoteRootsOptions {
|
|
14
7
|
readonly timeoutMs?: number;
|
|
@@ -3,11 +3,11 @@ import path from 'path';
|
|
|
3
3
|
import { Writable } from 'streamx';
|
|
4
4
|
import { HarnessError } from '../../errors.js';
|
|
5
5
|
import { DriveReadTruncatedError } from './drive.js';
|
|
6
|
+
import { MAX_DRIVE_BYTES } from './remote-protocol.js';
|
|
6
7
|
import { MAX_WALK_MS } from './walk.js';
|
|
7
8
|
import { STAGING_DIR } from '../../staging.js';
|
|
8
9
|
export const DRIVE_CALL_TIMEOUT_MS = 20_000;
|
|
9
10
|
export const DRIVE_SEARCH_TIMEOUT_MS = MAX_WALK_MS + DRIVE_CALL_TIMEOUT_MS;
|
|
10
|
-
export const MAX_DRIVE_BYTES = 8 * 1024 * 1024;
|
|
11
11
|
export const DRIVE_LIST_PAGE = 256;
|
|
12
12
|
const noop = () => { };
|
|
13
13
|
function withTimeout(promise, ms, op) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InstallStep, SkillRequires, SkillSetup } from './manifest.ts';
|
|
2
2
|
export { credentialSlots, type CredentialSlotSource } from './credential-slots.ts';
|
|
3
|
+
export { readSetup as readSkillSetup } from './manifest-parse.ts';
|
|
3
4
|
export interface SkillFrontMatter {
|
|
4
5
|
name?: string;
|
|
5
6
|
displayName?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseManifestBlock } from './manifest-parse.js';
|
|
2
2
|
import { isMentionHandle } from './mention-name.js';
|
|
3
3
|
export { credentialSlots } from './credential-slots.js';
|
|
4
|
+
export { readSetup as readSkillSetup } from './manifest-parse.js';
|
|
4
5
|
const FRONT_MATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
5
6
|
const FIELD_RE = /^([A-Za-z_][\w-]*):(.*)$/;
|
|
6
7
|
export function parseSkillFrontMatter(raw) {
|
|
@@ -4,6 +4,7 @@ import type { PolicyEnforcement } from '../../lib/contract/index.ts';
|
|
|
4
4
|
import { type SeccompArch } from './seccomp.ts';
|
|
5
5
|
export interface LinuxSandboxOptions {
|
|
6
6
|
readonly bwrap?: string;
|
|
7
|
+
readonly writable?: readonly string[];
|
|
7
8
|
}
|
|
8
9
|
export interface BwrapRun {
|
|
9
10
|
readonly read: 'all' | readonly string[];
|
|
@@ -34,9 +35,10 @@ export declare class LinuxSandbox implements HarnessPlugin {
|
|
|
34
35
|
readonly enforces: PolicyEnforcement;
|
|
35
36
|
readonly shell: ExecShell;
|
|
36
37
|
private readonly _bwrap;
|
|
38
|
+
private readonly _writable;
|
|
37
39
|
private _denied;
|
|
38
40
|
private readonly _stubs;
|
|
39
|
-
constructor({ bwrap }?: LinuxSandboxOptions);
|
|
41
|
+
constructor({ bwrap, writable }?: LinuxSandboxOptions);
|
|
40
42
|
validate(): string | null;
|
|
41
43
|
setup(ctx: PluginContext): Promise<PluginSetup>;
|
|
42
44
|
static argv(run: BwrapRun, line: string): string[];
|
|
@@ -42,10 +42,12 @@ export class LinuxSandbox {
|
|
|
42
42
|
enforces = ENFORCES;
|
|
43
43
|
shell;
|
|
44
44
|
_bwrap;
|
|
45
|
+
_writable;
|
|
45
46
|
_denied = [];
|
|
46
47
|
_stubs = new Map();
|
|
47
|
-
constructor({ bwrap = '/usr/bin/bwrap' } = {}) {
|
|
48
|
+
constructor({ bwrap = '/usr/bin/bwrap', writable = [] } = {}) {
|
|
48
49
|
this._bwrap = bwrap;
|
|
50
|
+
this._writable = writable;
|
|
49
51
|
this.shell = {
|
|
50
52
|
name: 'bwrap',
|
|
51
53
|
enforces: ENFORCES,
|
|
@@ -73,10 +75,15 @@ export class LinuxSandbox {
|
|
|
73
75
|
if (process.platform !== 'linux') {
|
|
74
76
|
return `bubblewrap runs on Linux only, not ${process.platform}`;
|
|
75
77
|
}
|
|
76
|
-
|
|
78
|
+
if (!ARCHES[process.arch]) {
|
|
79
|
+
return `has no seccomp program for ${process.arch}`;
|
|
80
|
+
}
|
|
81
|
+
const relative = this._writable.find((folder) => !path.isAbsolute(folder));
|
|
82
|
+
return relative === undefined ? null : `needs absolute writable folders, not ${relative}`;
|
|
77
83
|
}
|
|
78
84
|
async setup(ctx) {
|
|
79
85
|
this._denied = ctx.deniedRoots;
|
|
86
|
+
await Promise.all(this._writable.map((folder) => fs.promises.mkdir(folder, { recursive: true })));
|
|
80
87
|
await this._probe();
|
|
81
88
|
return { exec: { shell: this.shell }, services: { sandbox: this._service() } };
|
|
82
89
|
}
|
|
@@ -132,7 +139,7 @@ export class LinuxSandbox {
|
|
|
132
139
|
if (refused) {
|
|
133
140
|
throw new Error(`${this.name} ${refused}`);
|
|
134
141
|
}
|
|
135
|
-
return policy;
|
|
142
|
+
return Policy.withWrites(policy, this._writable);
|
|
136
143
|
}
|
|
137
144
|
async _workspace(dir, policy) {
|
|
138
145
|
const tmp = await scratch();
|
|
@@ -12,6 +12,7 @@ export interface ProfileCounts {
|
|
|
12
12
|
}
|
|
13
13
|
export interface SeatbeltOptions {
|
|
14
14
|
readonly sandboxExec?: string;
|
|
15
|
+
readonly writable?: readonly string[];
|
|
15
16
|
}
|
|
16
17
|
export declare class SeatbeltSandbox implements HarnessPlugin {
|
|
17
18
|
readonly name = "sandbox-macos";
|
|
@@ -32,10 +33,11 @@ export declare class SeatbeltSandbox implements HarnessPlugin {
|
|
|
32
33
|
};
|
|
33
34
|
readonly shell: ExecShell;
|
|
34
35
|
private readonly _sandboxExec;
|
|
36
|
+
private readonly _writable;
|
|
35
37
|
private _denied;
|
|
36
38
|
private _proxy;
|
|
37
39
|
private _userTemp;
|
|
38
|
-
constructor({ sandboxExec }?: SeatbeltOptions);
|
|
40
|
+
constructor({ sandboxExec, writable }?: SeatbeltOptions);
|
|
39
41
|
get enforces(): PolicyEnforcement;
|
|
40
42
|
validate(): string | null;
|
|
41
43
|
setup(ctx: PluginContext): Promise<PluginSetup>;
|
|
@@ -76,11 +76,13 @@ export class SeatbeltSandbox {
|
|
|
76
76
|
addons = { 'bare-subprocess': () => import('bare-subprocess') };
|
|
77
77
|
shell;
|
|
78
78
|
_sandboxExec;
|
|
79
|
+
_writable;
|
|
79
80
|
_denied = [];
|
|
80
81
|
_proxy = () => undefined;
|
|
81
82
|
_userTemp = null;
|
|
82
|
-
constructor({ sandboxExec = '/usr/bin/sandbox-exec' } = {}) {
|
|
83
|
+
constructor({ sandboxExec = '/usr/bin/sandbox-exec', writable = [] } = {}) {
|
|
83
84
|
this._sandboxExec = sandboxExec;
|
|
85
|
+
this._writable = writable;
|
|
84
86
|
const enforcement = () => this.enforces;
|
|
85
87
|
this.shell = {
|
|
86
88
|
name: 'seatbelt',
|
|
@@ -115,13 +117,16 @@ export class SeatbeltSandbox {
|
|
|
115
117
|
return this._proxy() ? HOSTS : ON_OFF;
|
|
116
118
|
}
|
|
117
119
|
validate() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
if (process.platform !== 'darwin') {
|
|
121
|
+
return `Seatbelt runs on macOS only, not ${process.platform}`;
|
|
122
|
+
}
|
|
123
|
+
const relative = this._writable.find((folder) => !path.isAbsolute(folder));
|
|
124
|
+
return relative === undefined ? null : `needs absolute writable folders, not ${relative}`;
|
|
121
125
|
}
|
|
122
126
|
async setup(ctx) {
|
|
123
127
|
this._denied = ctx.deniedRoots;
|
|
124
128
|
this._proxy = () => ctx.services['egress-proxy'];
|
|
129
|
+
await Promise.all(this._writable.map((folder) => fs.promises.mkdir(folder, { recursive: true })));
|
|
125
130
|
await this._probe();
|
|
126
131
|
this._userTemp = await SeatbeltSandbox._darwinUserTemp();
|
|
127
132
|
return { exec: { shell: this.shell }, services: { sandbox: this._service() } };
|
|
@@ -152,7 +157,7 @@ export class SeatbeltSandbox {
|
|
|
152
157
|
if (refused) {
|
|
153
158
|
throw new Error(`${this.name} ${refused}`);
|
|
154
159
|
}
|
|
155
|
-
return policy;
|
|
160
|
+
return Policy.withWrites(policy, this._writable);
|
|
156
161
|
}
|
|
157
162
|
async _workspace(dir, policy) {
|
|
158
163
|
const tmp = await this._scratch();
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/harness",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"bare": ">=1.34.0",
|
|
@@ -220,6 +220,14 @@
|
|
|
220
220
|
"types": "./dist-lib/lib/tools/skills/skill-state-constants.d.ts",
|
|
221
221
|
"default": "./dist-lib/lib/tools/skills/skill-state-constants.js"
|
|
222
222
|
},
|
|
223
|
+
"./skill-catalog": {
|
|
224
|
+
"types": "./dist-lib/lib/tools/skills/catalog.d.ts",
|
|
225
|
+
"default": "./dist-lib/lib/tools/skills/catalog.js"
|
|
226
|
+
},
|
|
227
|
+
"./drive": {
|
|
228
|
+
"types": "./dist-lib/lib/tools/fs/remote-protocol.d.ts",
|
|
229
|
+
"default": "./dist-lib/lib/tools/fs/remote-protocol.js"
|
|
230
|
+
},
|
|
223
231
|
"./lib/tools/exec/adapters/shell/shell-adapter.ts": {
|
|
224
232
|
"types": "./dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts",
|
|
225
233
|
"default": "./dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js"
|
|
@@ -414,43 +422,15 @@
|
|
|
414
422
|
"types": "./dist-lib/lib/sidecar/index.d.ts",
|
|
415
423
|
"default": "./dist-lib/lib/sidecar/index.js"
|
|
416
424
|
},
|
|
425
|
+
"./user-plugins": {
|
|
426
|
+
"types": "./dist-lib/lib/sidecar/user-plugins.d.ts",
|
|
427
|
+
"default": "./dist-lib/lib/sidecar/user-plugins.js"
|
|
428
|
+
},
|
|
417
429
|
"./worker/harness-sidecar.mjs": "./worker/harness-sidecar.mjs",
|
|
418
430
|
"./worker/stow-entry.mjs": "./worker/stow-entry.mjs",
|
|
419
431
|
"./addon-externals": {
|
|
420
432
|
"types": "./scripts/addon-externals.d.ts",
|
|
421
433
|
"default": "./scripts/addon-externals.cjs"
|
|
422
|
-
},
|
|
423
|
-
"./lib/tools/fs/drive.ts": {
|
|
424
|
-
"types": "./dist-lib/lib/tools/fs/drive.d.ts",
|
|
425
|
-
"default": "./dist-lib/lib/tools/fs/drive.js"
|
|
426
|
-
},
|
|
427
|
-
"./lib/tools/fs/remote-protocol.ts": {
|
|
428
|
-
"types": "./dist-lib/lib/tools/fs/remote-protocol.d.ts",
|
|
429
|
-
"default": "./dist-lib/lib/tools/fs/remote-protocol.js"
|
|
430
|
-
},
|
|
431
|
-
"./lib/tools/fs/remote.ts": {
|
|
432
|
-
"types": "./dist-lib/lib/tools/fs/remote.d.ts",
|
|
433
|
-
"default": "./dist-lib/lib/tools/fs/remote.js"
|
|
434
|
-
},
|
|
435
|
-
"./lib/tools/skills/skill-state.ts": {
|
|
436
|
-
"types": "./dist-lib/lib/tools/skills/skill-state.d.ts",
|
|
437
|
-
"default": "./dist-lib/lib/tools/skills/skill-state.js"
|
|
438
|
-
},
|
|
439
|
-
"./lib/tools/skills/credential-slots.ts": {
|
|
440
|
-
"types": "./dist-lib/lib/tools/skills/credential-slots.d.ts",
|
|
441
|
-
"default": "./dist-lib/lib/tools/skills/credential-slots.js"
|
|
442
|
-
},
|
|
443
|
-
"./lib/tools/skills/manifest-parse.ts": {
|
|
444
|
-
"types": "./dist-lib/lib/tools/skills/manifest-parse.d.ts",
|
|
445
|
-
"default": "./dist-lib/lib/tools/skills/manifest-parse.js"
|
|
446
|
-
},
|
|
447
|
-
"./lib/tools/skills/overlay-crud.ts": {
|
|
448
|
-
"types": "./dist-lib/lib/tools/skills/overlay-crud.d.ts",
|
|
449
|
-
"default": "./dist-lib/lib/tools/skills/overlay-crud.js"
|
|
450
|
-
},
|
|
451
|
-
"./lib/tools/skills/scope-key.ts": {
|
|
452
|
-
"types": "./dist-lib/lib/tools/skills/scope-key.d.ts",
|
|
453
|
-
"default": "./dist-lib/lib/tools/skills/scope-key.js"
|
|
454
434
|
}
|
|
455
435
|
},
|
|
456
436
|
"scripts": {
|
|
@@ -570,12 +550,12 @@
|
|
|
570
550
|
"default": "buffer"
|
|
571
551
|
},
|
|
572
552
|
"#sdk": {
|
|
573
|
-
"types": "@qvac/
|
|
553
|
+
"types": "@qvac/inference",
|
|
574
554
|
"bare": "@qvac/inference",
|
|
575
555
|
"default": "@qvac/sdk"
|
|
576
556
|
},
|
|
577
557
|
"#sdk-logging": {
|
|
578
|
-
"types": "@qvac/
|
|
558
|
+
"types": "@qvac/inference/logging",
|
|
579
559
|
"bare": "@qvac/inference/logging",
|
|
580
560
|
"default": "@qvac/sdk/logging"
|
|
581
561
|
},
|
|
@@ -760,7 +740,6 @@
|
|
|
760
740
|
"lunte": "^1.8.6",
|
|
761
741
|
"lunte-plugin-qvac": "^0.2.0",
|
|
762
742
|
"paparam": "^1.13.0",
|
|
763
|
-
"pdfjs-dist": "^6.3.289",
|
|
764
743
|
"prettier": "^3.6.2",
|
|
765
744
|
"prettier-config-holepunch": "^2.0.0",
|
|
766
745
|
"pyodide": "314.0.2",
|
|
@@ -769,8 +748,7 @@
|
|
|
769
748
|
},
|
|
770
749
|
"patchedDependencies": {
|
|
771
750
|
"pyodide@314.0.2": "patches/pyodide@314.0.2.patch",
|
|
772
|
-
"localwatch@1.4.3": "patches/localwatch@1.4.3.patch"
|
|
773
|
-
"@qvac/inference@0.22.0": "patches/@qvac%2Finference@0.22.0.patch"
|
|
751
|
+
"localwatch@1.4.3": "patches/localwatch@1.4.3.patch"
|
|
774
752
|
},
|
|
775
753
|
"repository": {
|
|
776
754
|
"type": "git",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
diff --git a/dist/plugins/builtin/llamacpp-completion/plugin.js b/dist/plugins/builtin/llamacpp-completion/plugin.js
|
|
2
|
-
index e9b4d9465016822145c7d01373ba3cc0a2770ad2..8a1709c8094d3641247df25dd435741bc72a82cd 100644
|
|
3
|
-
--- a/dist/plugins/builtin/llamacpp-completion/plugin.js
|
|
4
|
-
+++ b/dist/plugins/builtin/llamacpp-completion/plugin.js
|
|
5
|
-
@@ -386,8 +386,12 @@ export const llmPlugin = definePlugin({
|
|
6
|
-
generatedTokens: stats?.generatedTokens,
|
|
7
|
-
stoppedAtContextBoundary
|
|
8
|
-
});
|
|
9
|
-
+ // qvac-harness patch: tell a stop at the context window from one at the predict cap
|
|
10
|
-
+ const finalStats = lengthStop
|
|
11
|
-
+ ? { ...stats, contextBoundary: stoppedAtContextBoundary }
|
|
12
|
-
+ : stats;
|
|
13
|
-
const terminalEvents = normalizer.finish({
|
|
14
|
-
- ...(stats && { stats }),
|
|
15
|
-
+ ...(finalStats && { stats: finalStats }),
|
|
16
|
-
...(toolCalls.length > 0 && { toolCalls }),
|
|
17
|
-
...(cancelled && { stopReason: 'cancelled' }),
|
|
18
|
-
...(lengthStop && { stopReason: 'length' })
|
|
19
|
-
diff --git a/dist/schemas/completion-event.d.ts b/dist/schemas/completion-event.d.ts
|
|
20
|
-
index 7c126fa0750ddc75c5da0a2d54e9468e429a64d8..8207ed48f3ff5c164e99b1a58624449ec4cef1f4 100644
|
|
21
|
-
--- a/dist/schemas/completion-event.d.ts
|
|
22
|
-
+++ b/dist/schemas/completion-event.d.ts
|
|
23
|
-
@@ -5,6 +5,7 @@ export declare const completionStatsSchema: z.ZodObject<{
|
|
24
|
-
timeToFirstToken: z.ZodOptional<z.ZodNumber>;
|
|
25
|
-
tokensPerSecond: z.ZodOptional<z.ZodNumber>;
|
|
26
|
-
promptTokensPerSecond: z.ZodOptional<z.ZodNumber>;
|
|
27
|
-
+ contextBoundary: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
-
cacheTokens: z.ZodOptional<z.ZodNumber>;
|
|
29
|
-
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
30
|
-
generatedTokens: z.ZodOptional<z.ZodNumber>;
|
|
31
|
-
@@ -63,6 +64,7 @@ export declare const statsEventSchema: z.ZodObject<{
|
|
32
|
-
timeToFirstToken: z.ZodOptional<z.ZodNumber>;
|
|
33
|
-
tokensPerSecond: z.ZodOptional<z.ZodNumber>;
|
|
34
|
-
promptTokensPerSecond: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
+ contextBoundary: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
-
cacheTokens: z.ZodOptional<z.ZodNumber>;
|
|
37
|
-
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
38
|
-
generatedTokens: z.ZodOptional<z.ZodNumber>;
|
|
39
|
-
@@ -147,6 +149,7 @@ export declare const completionEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
40
|
-
timeToFirstToken: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
tokensPerSecond: z.ZodOptional<z.ZodNumber>;
|
|
42
|
-
promptTokensPerSecond: z.ZodOptional<z.ZodNumber>;
|
|
43
|
-
+ contextBoundary: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
-
cacheTokens: z.ZodOptional<z.ZodNumber>;
|
|
45
|
-
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
46
|
-
generatedTokens: z.ZodOptional<z.ZodNumber>;
|
|
47
|
-
diff --git a/dist/schemas/completion-event.js b/dist/schemas/completion-event.js
|
|
48
|
-
index 1ef0d68a9a8cf6f590988272e114ac54ea093614..174c2e25b39291c0858079b87db2de84a1b7ebcd 100644
|
|
49
|
-
--- a/dist/schemas/completion-event.js
|
|
50
|
-
+++ b/dist/schemas/completion-event.js
|
|
51
|
-
@@ -4,6 +4,8 @@ export const completionStatsSchema = z.object({
|
|
52
|
-
timeToFirstToken: z.number().optional(),
|
|
53
|
-
tokensPerSecond: z.number().optional(),
|
|
54
|
-
promptTokensPerSecond: z.number().optional(),
|
|
55
|
-
+ // qvac-harness patch: the round stopped at the context window, not at the predict cap
|
|
56
|
-
+ contextBoundary: z.boolean().optional(),
|
|
57
|
-
cacheTokens: z.number().optional(),
|
|
58
|
-
promptTokens: z.number().optional(),
|
|
59
|
-
// Decode count (`llama_perf` `n_eval`) — length / KV-cache budget decisions.
|