@qvac/harness 1.0.0-rc.11 → 1.0.0-rc.12
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/dist-lib/index.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +18 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +8 -0
- package/dist-lib/lib/capabilities/completion-engine/round.js +3 -3
- package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +2 -1
- package/dist-lib/lib/capabilities/tool-turns.js +7 -1
- package/dist-lib/lib/residency/index.d.ts +1 -1
- package/dist-lib/lib/residency/index.js +2 -2
- package/dist-lib/plugins/run-report/story.js +4 -1
- 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 +5 -1
package/dist-lib/index.js
CHANGED
|
@@ -860,7 +860,7 @@ export class Harness extends ReadyResource {
|
|
|
860
860
|
throw new Error(UNLOAD_FAILED);
|
|
861
861
|
}
|
|
862
862
|
const { modelId } = request;
|
|
863
|
-
const { key, acquireRound } = this._residency.servedRound(modelId);
|
|
863
|
+
const { key, acquireRound } = this._residency.servedRound(modelId, request.load);
|
|
864
864
|
let served;
|
|
865
865
|
const round = this._lifecycle.trackCompletion((signal) => this._residency.busyStream(async function* () {
|
|
866
866
|
served = await CompletionEngine.serveModelRound(request, { signal, emit: (event) => io.emit(event), retake: () => io.retake() }, { acquireRound });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompletionEvent, CompletionSdk } from '../../../contract/index.ts';
|
|
1
|
+
import type { AgentConfig, CompletionEvent, CompletionSdk } from '../../../contract/index.ts';
|
|
2
2
|
import { type RecoveredRound, type RoundArgs, type RoundKind } from '../round.ts';
|
|
3
3
|
import { type ModelRoundPort } from '../model-round.ts';
|
|
4
4
|
import type { Session } from '../session.ts';
|
|
@@ -9,6 +9,7 @@ interface ForwardStreamOptions<Result> {
|
|
|
9
9
|
interface RunRoundOptions {
|
|
10
10
|
sdk: CompletionSdk | undefined;
|
|
11
11
|
modelRound?: ModelRoundPort | undefined;
|
|
12
|
+
agent?: AgentConfig | undefined;
|
|
12
13
|
kind: RoundKind;
|
|
13
14
|
args: Omit<RoundArgs, 'live' | 'knownTools'>;
|
|
14
15
|
session: Pick<Session, 'liveRound' | 'enabled' | 'runId'>;
|
|
@@ -21,6 +22,6 @@ export interface AssembleAnswerOptions {
|
|
|
21
22
|
emit: (event: CompletionEvent) => void;
|
|
22
23
|
}
|
|
23
24
|
export declare function forwardStream<Result>({ stream, emit }: ForwardStreamOptions<Result>): Promise<Result>;
|
|
24
|
-
export declare function runRound({ sdk, modelRound, kind, args, session, emit }: RunRoundOptions): Promise<RecoveredRound>;
|
|
25
|
+
export declare function runRound({ sdk, modelRound, agent, kind, args, session, emit }: RunRoundOptions): Promise<RecoveredRound>;
|
|
25
26
|
export declare function assembleAnswer({ contentText, replay, landed, emit }: AssembleAnswerOptions): Promise<string>;
|
|
26
27
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reportUnnamedWrites } from '../loop.js';
|
|
2
|
-
import { recordWholeRound, runRecoveredRound } from '../round.js';
|
|
2
|
+
import { inferenceCall, 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';
|
|
@@ -17,7 +17,7 @@ export async function forwardStream({ stream, emit }) {
|
|
|
17
17
|
await Promise.resolve(stream.return(undefined)).catch(noop);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export async function runRound({ sdk, modelRound, kind, args, session, emit }) {
|
|
20
|
+
export async function runRound({ sdk, modelRound, agent, kind, args, session, emit }) {
|
|
21
21
|
if (args.signal?.aborted)
|
|
22
22
|
throw new AbortedError();
|
|
23
23
|
const live = { round: args.round, kind, startedAt: Date.now(), rawChars: 0, reasoningDeltas: 0 };
|
|
@@ -26,6 +26,7 @@ export async function runRound({ sdk, modelRound, kind, args, session, emit }) {
|
|
|
26
26
|
const round = modelRound
|
|
27
27
|
? await remoteRound({
|
|
28
28
|
port: modelRound,
|
|
29
|
+
agent,
|
|
29
30
|
kind,
|
|
30
31
|
args: { ...args, live },
|
|
31
32
|
runId: session.runId,
|
|
@@ -46,14 +47,28 @@ export async function runRound({ sdk, modelRound, kind, args, session, emit }) {
|
|
|
46
47
|
throw error;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
async function remoteRound({ port, kind, args, runId, emit }) {
|
|
50
|
+
async function remoteRound({ port, agent, kind, args, runId, emit }) {
|
|
50
51
|
const params = await recordWholeRound(args);
|
|
52
|
+
if (args.capture) {
|
|
53
|
+
emit(inferenceCall({
|
|
54
|
+
args,
|
|
55
|
+
droppedTurns: 0,
|
|
56
|
+
modelId: params.modelId,
|
|
57
|
+
params,
|
|
58
|
+
cacheKey: args.cacheKey
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
51
61
|
const result = await ModelRound.run(port, {
|
|
52
62
|
runId,
|
|
53
63
|
round: args.round,
|
|
54
64
|
kind,
|
|
55
65
|
attempt: 0,
|
|
56
66
|
modelId: params.modelId,
|
|
67
|
+
load: agent && {
|
|
68
|
+
ctxSize: agent.ctxSize,
|
|
69
|
+
kvCacheK: agent.kvCacheK,
|
|
70
|
+
kvCacheV: agent.kvCacheV
|
|
71
|
+
},
|
|
57
72
|
history: params.history,
|
|
58
73
|
tools: params.tools,
|
|
59
74
|
toolSet: params.tools && ToolSets.hash(params.tools),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
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
|
-
import type { CompletionSdk, LlmGenerationParams, Message, ResponseFormat, RoundModelLease, RunLifecycleEvent } from '../../contract/index.ts';
|
|
4
|
+
import type { AgentConfig, CompletionSdk, LlmGenerationParams, Message, ResponseFormat, RoundModelLease, RunLifecycleEvent } from '../../contract/index.ts';
|
|
5
5
|
export interface ModelRoundRequest {
|
|
6
6
|
runId: string;
|
|
7
7
|
round: number;
|
|
8
8
|
kind: 'streaming' | 'wrap-up';
|
|
9
9
|
attempt: number;
|
|
10
10
|
modelId: string;
|
|
11
|
+
load?: Pick<AgentConfig, 'ctxSize' | 'kvCacheK' | 'kvCacheV'> | undefined;
|
|
11
12
|
history: Message[];
|
|
12
13
|
tools?: SdkTool[] | undefined;
|
|
13
14
|
toolSet?: string | undefined;
|
|
@@ -69,6 +69,14 @@ type RoundReset = Extract<RunLifecycleEvent, {
|
|
|
69
69
|
type: 'round-reset';
|
|
70
70
|
}>;
|
|
71
71
|
export type RoundEvent = TextEvent | InferenceCallEvent | InferenceSentEvent | RoundReset | FoldEvent;
|
|
72
|
+
interface CallCapture {
|
|
73
|
+
args: RoundArgs;
|
|
74
|
+
droppedTurns: number;
|
|
75
|
+
modelId: string;
|
|
76
|
+
params: CompletionParams;
|
|
77
|
+
cacheKey: string | undefined;
|
|
78
|
+
}
|
|
72
79
|
export declare function runRecoveredRound(sdk: CompletionSdk | undefined, args: RoundArgs): AsyncGenerator<RoundEvent, RecoveredRound>;
|
|
73
80
|
export declare function recordWholeRound(args: RoundArgs): Promise<CompletionParams>;
|
|
81
|
+
export declare function inferenceCall({ args, droppedTurns, modelId, params, cacheKey }: CallCapture): InferenceCallEvent;
|
|
74
82
|
export {};
|
|
@@ -661,7 +661,7 @@ async function* runCandidate({ sdk, args, modelId, candidate, progress, baseHist
|
|
|
661
661
|
if (args.capture) {
|
|
662
662
|
yield inferenceCall({
|
|
663
663
|
args,
|
|
664
|
-
candidate,
|
|
664
|
+
droppedTurns: candidate.droppedTurns,
|
|
665
665
|
modelId,
|
|
666
666
|
params,
|
|
667
667
|
cacheKey: cacheable ? args.cacheKey : undefined
|
|
@@ -724,12 +724,12 @@ function generationParams(args) {
|
|
|
724
724
|
const sent = args.generationParams ? host : undefined;
|
|
725
725
|
return args.tools?.length ? { parallel_tool_calls: true, ...sent } : sent;
|
|
726
726
|
}
|
|
727
|
-
function inferenceCall({ args,
|
|
727
|
+
export function inferenceCall({ args, droppedTurns, modelId, params, cacheKey }) {
|
|
728
728
|
return {
|
|
729
729
|
type: 'inference-call',
|
|
730
730
|
call: {
|
|
731
731
|
round: args.round,
|
|
732
|
-
droppedTurns
|
|
732
|
+
droppedTurns,
|
|
733
733
|
modelId,
|
|
734
734
|
messages: params.history,
|
|
735
735
|
tools: params.tools,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TOOL_FAILED_NOTE = "[This call failed: say so, and never state a value it would have produced.]";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TOOL_FAILED_NOTE = '[This call failed: say so, and never state a value it would have produced.]';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CompletionHistoryEntry, Message, RunGoal, SdkMessage } from '../contract/index.ts';
|
|
2
2
|
import { type FailureResultValue } from '../helpers/failure-result.ts';
|
|
3
|
+
import { TOOL_FAILED_NOTE } from './tool-failed-note.ts';
|
|
3
4
|
export declare const DIRECT_CALL_ID = "call-direct";
|
|
4
5
|
export declare const PRELOAD_ID_PREFIX = "preload-";
|
|
5
6
|
export declare const MAX_TOOL_ROUNDS = 10;
|
|
@@ -8,6 +9,7 @@ export declare const TOOL_CONTINUATION_NUDGE = "[Tool results above. Continue th
|
|
|
8
9
|
export declare const FILE_DELIVERED_NUDGE = "[Tool results above. The file is attached to the chat and shown to the user. Answer now, unless the request still needs a file that is not made yet.]";
|
|
9
10
|
export declare function skillMentionNudge(handle: string): string;
|
|
10
11
|
export declare function isSkillMentionNudge(content: string): boolean;
|
|
12
|
+
export { TOOL_FAILED_NOTE };
|
|
11
13
|
export declare const TOOL_DENIED_MESSAGE: string;
|
|
12
14
|
export declare const TOOL_CUT_OFF_MESSAGE: string;
|
|
13
15
|
export declare const TOOL_ROUND_CUT_MESSAGE: string;
|
|
@@ -43,4 +45,3 @@ export declare function attachmentTurn(name: string, result: unknown): string |
|
|
|
43
45
|
export declare function loadedSkillsFrom(messages: readonly Message[]): Set<string>;
|
|
44
46
|
export declare function loadedSkillFilesFrom(messages: readonly Message[]): Map<string, Set<string>>;
|
|
45
47
|
export declare function historyPayload(output: unknown): unknown;
|
|
46
|
-
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { isRecord } from '../guards.js';
|
|
2
2
|
import { Agent } from '../agent/index.js';
|
|
3
3
|
import { headTail } from '../helpers/head-tail.js';
|
|
4
|
+
import { MALFORMED_CALL_ID } from '../helpers/tool-call-markup.js';
|
|
4
5
|
import { MAX_GOAL_CHECKS } from '../helpers/goal-check.js';
|
|
5
6
|
import { compactContent } from '../context-window.js';
|
|
6
7
|
import { TOOL_SEARCH_TOOL_NAME } from './sdk-tool.js';
|
|
7
8
|
import { isFailureResultReference, readFailureResult } from '../helpers/failure-result.js';
|
|
9
|
+
import { TOOL_FAILED_NOTE } from './tool-failed-note.js';
|
|
8
10
|
export const DIRECT_CALL_ID = 'call-direct';
|
|
9
11
|
export const PRELOAD_ID_PREFIX = 'preload-';
|
|
10
12
|
export const MAX_TOOL_ROUNDS = 10;
|
|
@@ -18,6 +20,7 @@ export function skillMentionNudge(handle) {
|
|
|
18
20
|
export function isSkillMentionNudge(content) {
|
|
19
21
|
return content.startsWith(MENTION_NUDGE_PREFIX);
|
|
20
22
|
}
|
|
23
|
+
export { TOOL_FAILED_NOTE };
|
|
21
24
|
export const TOOL_DENIED_MESSAGE = 'The user declined this call. Do not retry it or call it with different arguments to get ' +
|
|
22
25
|
'around the refusal. Tell the user plainly what you could not do, and never present a ' +
|
|
23
26
|
'result you did not obtain.';
|
|
@@ -105,7 +108,10 @@ export function toolResultTurn(name, id, output) {
|
|
|
105
108
|
return `[Tool: ${name} (${id})]\n${JSON.stringify(historyPayload(rest))}\n\n${content}${context}`;
|
|
106
109
|
}
|
|
107
110
|
const text = name === Agent.SKILL_TOOL_NAME ? JSON.stringify(payload) : fitted(payload);
|
|
108
|
-
|
|
111
|
+
const failed = id !== MALFORMED_CALL_ID && isRecord(shown) && 'error' in shown && shown.guidance !== true
|
|
112
|
+
? `\n${TOOL_FAILED_NOTE}`
|
|
113
|
+
: '';
|
|
114
|
+
return `[Tool: ${name} (${id})]\n${text}${context}${failed}`;
|
|
109
115
|
}
|
|
110
116
|
function fitted(payload) {
|
|
111
117
|
const whole = JSON.stringify(payload);
|
|
@@ -187,7 +187,7 @@ export declare class Residency {
|
|
|
187
187
|
loadOptions(model: string, agent?: LoadOptionKnobs): ModelLoadOptions;
|
|
188
188
|
acquireLease({ pool, key, open, signal, prepare, onLoad }: ModelLeaseOptions): Promise<ModelLease | null>;
|
|
189
189
|
completionRuntime(request: CompletionRuntimeRequest): Promise<import("./completion-runtime.ts").PreparedRuntime>;
|
|
190
|
-
servedRound(model: string): {
|
|
190
|
+
servedRound(model: string, load?: LoadOptionKnobs): {
|
|
191
191
|
key: string;
|
|
192
192
|
acquireRound: (invocationSignal?: BareAbortSignal) => Promise<import("../contract/completion.ts").RoundModelLease>;
|
|
193
193
|
};
|
|
@@ -839,8 +839,8 @@ export class Residency {
|
|
|
839
839
|
releaseWork();
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
|
-
servedRound(model) {
|
|
843
|
-
const loadOpts = this.loadOptions(model);
|
|
842
|
+
servedRound(model, load) {
|
|
843
|
+
const loadOpts = this.loadOptions(model, load);
|
|
844
844
|
const key = modelKey(model, loadOpts);
|
|
845
845
|
return { key, acquireRound: roundAcquirer(this, { model, key, loadOpts }) };
|
|
846
846
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isRecord } from '../../lib/guards.js';
|
|
2
|
+
import { TOOL_FAILED_NOTE } from '../../lib/capabilities/tool-failed-note.js';
|
|
2
3
|
const TOOL_RESULT = /^\[Tool: (.+?) \((.+?)\)\]\n?/;
|
|
3
4
|
export function story(input) {
|
|
4
5
|
const teller = new Teller(input);
|
|
@@ -173,8 +174,10 @@ function request(content) {
|
|
|
173
174
|
return text.replace(/^\[Current local time:[^\]]*\]\s*/, '').trim();
|
|
174
175
|
}
|
|
175
176
|
function parse(text) {
|
|
177
|
+
const note = `\n${TOOL_FAILED_NOTE}`;
|
|
178
|
+
const payload = text.endsWith(note) ? text.slice(0, -note.length) : text;
|
|
176
179
|
try {
|
|
177
|
-
return JSON.parse(
|
|
180
|
+
return JSON.parse(payload);
|
|
178
181
|
}
|
|
179
182
|
catch {
|
|
180
183
|
return text;
|
|
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.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"bare": ">=1.34.0",
|
|
@@ -252,6 +252,10 @@
|
|
|
252
252
|
"types": "./dist-lib/lib/tools/fs/write.d.ts",
|
|
253
253
|
"default": "./dist-lib/lib/tools/fs/write.js"
|
|
254
254
|
},
|
|
255
|
+
"./lib/capabilities/tool-failed-note.ts": {
|
|
256
|
+
"types": "./dist-lib/lib/capabilities/tool-failed-note.d.ts",
|
|
257
|
+
"default": "./dist-lib/lib/capabilities/tool-failed-note.js"
|
|
258
|
+
},
|
|
255
259
|
"./lib/capabilities/tool-turns.ts": {
|
|
256
260
|
"types": "./dist-lib/lib/capabilities/tool-turns.d.ts",
|
|
257
261
|
"default": "./dist-lib/lib/capabilities/tool-turns.js"
|