@qvac/harness 1.0.0-rc.18 → 1.0.0-rc.19
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 +37 -6
- package/dist-lib/index.d.ts +3 -1
- package/dist-lib/index.js +30 -0
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +3 -2
- package/dist-lib/lib/capabilities/completion-engine/loop.js +4 -1
- package/dist-lib/lib/connect.d.ts +2 -0
- package/dist-lib/lib/connect.js +57 -0
- package/dist-lib/lib/contract/completion.d.ts +2 -0
- package/dist-lib/lib/contract/index.d.ts +1 -0
- package/dist-lib/lib/contract/media.d.ts +51 -0
- package/dist-lib/lib/contract/media.js +1 -0
- package/dist-lib/lib/contract/models.d.ts +2 -0
- package/dist-lib/lib/contract-types.d.ts +3 -1
- package/dist-lib/lib/errors.d.ts +4 -0
- package/dist-lib/lib/errors.js +4 -0
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +1 -1
- package/dist-lib/lib/machine/completion/actions/completion.js +3 -7
- package/dist-lib/lib/machine/completion/implementations.d.ts +3 -3
- package/dist-lib/lib/machine/completion/implementations.js +4 -4
- package/dist-lib/lib/machine/completion/machine.d.ts +3 -3
- package/dist-lib/lib/machine/completion/machine.js +3 -3
- package/dist-lib/lib/machine/index.d.ts +3 -3
- package/dist-lib/lib/media-host.d.ts +12 -0
- package/dist-lib/lib/media-host.js +52 -0
- package/dist-lib/lib/media-port.d.ts +20 -0
- package/dist-lib/lib/media-port.js +77 -0
- package/dist-lib/lib/media-wire.d.ts +8 -0
- package/dist-lib/lib/media-wire.js +96 -0
- package/dist-lib/lib/plugins/registry.d.ts +3 -0
- package/dist-lib/lib/serve.js +37 -1
- package/dist-lib/lib/tools/pdf/pages.js +6 -3
- package/dist-lib/lib/tools/pdf/recognize.js +2 -1
- package/dist-lib/plugins/image/edit-image.js +3 -9
- package/dist-lib/plugins/image/generate-image.d.ts +14 -2
- package/dist-lib/plugins/image/generate-image.js +94 -8
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +8 -3
- package/dist-lib/plugins/music/generate-music.d.ts +18 -2
- package/dist-lib/plugins/music/generate-music.js +98 -16
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +6 -2
- package/dist-lib/plugins/python/bare-floor.js +1 -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/dist-lib/plugins/walkie-talkie/index.d.ts +2 -0
- package/dist-lib/plugins/walkie-talkie/index.js +6 -1
- package/dist-lib/schema/generate.js +8 -1
- package/dist-lib/schema/harness.js +9 -2
- package/dist-lib/spec/hrpc/messages.js +46 -4
- package/dist-lib/spec/hyperschema/index.js +46 -4
- package/dist-lib/spec/hyperschema/schema.json +28 -0
- package/dist-lib/spec/hyperschema/types.d.ts +2 -2
- package/package.json +7 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { MusicSettings, ToolDefinition, ToolExecuteContext } from '../../lib/contract/index.ts';
|
|
1
|
+
import { type AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
|
+
import type { MediaRoundServer, MusicSettings, ToolDefinition, ToolExecuteContext } from '../../lib/contract/index.ts';
|
|
3
3
|
import type { ModelSrc } from '../../lib/models/context.ts';
|
|
4
4
|
import { type MusicClamps, type MusicModelStages } from '../../lib/models/model-catalog.ts';
|
|
5
5
|
import type { LoadRequests, ModelHost, TrackedLoad } from '../../lib/contract/models.ts';
|
|
@@ -89,6 +89,8 @@ export interface MusicRuntime {
|
|
|
89
89
|
gpuRequested: boolean;
|
|
90
90
|
defaultSteps?: number;
|
|
91
91
|
ensureLoaded: (sdk: MusicGenSdk, options?: EnsureMusicLoadedOptions) => Promise<LoadedMusicModel>;
|
|
92
|
+
modelName(modelChoice?: string): string;
|
|
93
|
+
choiceFor(modelChoice?: string): string | undefined;
|
|
92
94
|
unload(): Promise<void>;
|
|
93
95
|
unloadIdle(): Promise<void>;
|
|
94
96
|
acquire(): boolean;
|
|
@@ -99,10 +101,24 @@ export declare function createMusicRuntime({ loadSdk, onProgress, onBeforeLoad,
|
|
|
99
101
|
export declare const BUSY_ERROR = "a music generation is already running; try again when it finishes";
|
|
100
102
|
export interface MusicToolError {
|
|
101
103
|
error: string;
|
|
104
|
+
code?: string;
|
|
102
105
|
}
|
|
103
106
|
export interface GeneratedTrack extends GeneratedAudio {
|
|
104
107
|
stats?: MusicStats;
|
|
105
108
|
}
|
|
109
|
+
export interface MusicOutput extends GeneratedTrack {
|
|
110
|
+
gpuRequested: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface AudioGenOptions {
|
|
113
|
+
readonly modelChoice?: string | undefined;
|
|
114
|
+
readonly inferenceSteps?: number | undefined;
|
|
115
|
+
readonly params: AudioGenParams;
|
|
116
|
+
readonly signal?: BareAbortSignal | undefined;
|
|
117
|
+
readonly onTick?: ((tick: MusicTick) => void) | undefined;
|
|
118
|
+
}
|
|
119
|
+
export declare function audioGen(runtime: MusicRuntime, ctx: ToolExecuteContext, options: AudioGenOptions): Promise<MusicOutput | MusicToolError>;
|
|
120
|
+
export declare function audioGenHere(runtime: MusicRuntime, { modelChoice, inferenceSteps, params, signal, onTick }: AudioGenOptions): Promise<MusicOutput | MusicToolError>;
|
|
121
|
+
export declare function audioGenServer(runtime: MusicRuntime, isCached: ModelHost['isCached'], clamps?: MusicClamps): MediaRoundServer;
|
|
106
122
|
export interface RunAudioGenOptions {
|
|
107
123
|
readonly modelId: string;
|
|
108
124
|
readonly params: AudioGenParams;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
1
2
|
import process from 'process';
|
|
2
3
|
import ScopeLock from 'scope-lock';
|
|
4
|
+
import { HarnessError } from '../../lib/errors.js';
|
|
3
5
|
import { AbortedError, raceAbort } from '../../lib/helpers/race-abort.js';
|
|
4
6
|
import { HarnessLog } from '../../lib/log.js';
|
|
5
7
|
import { AUDIOGEN_CATALOG, musicChoiceForDit, musicDefaultSteps, musicModelSet } from '../../lib/models/model-catalog.js';
|
|
@@ -21,7 +23,7 @@ const MAX_MUSIC_META_CHARS = 32;
|
|
|
21
23
|
const STAGE_WEIGHT = {
|
|
22
24
|
lm: { base: 0, span: 80 },
|
|
23
25
|
dit: { base: 80, span: 17 },
|
|
24
|
-
vae: { base: 97, span:
|
|
26
|
+
vae: { base: 97, span: 2 }
|
|
25
27
|
};
|
|
26
28
|
export function musicPercentTick(onPercent) {
|
|
27
29
|
let last = -1;
|
|
@@ -154,6 +156,8 @@ export function createMusicRuntime({ loadSdk, onProgress, onBeforeLoad, hold, re
|
|
|
154
156
|
});
|
|
155
157
|
return raceAbort(load, signal);
|
|
156
158
|
},
|
|
159
|
+
modelName: (modelChoice) => musicProgressName(stagesFor(modelChoice, base).dit),
|
|
160
|
+
choiceFor: (modelChoice) => musicChoiceForDit(stagesFor(modelChoice, base).dit),
|
|
157
161
|
unload,
|
|
158
162
|
unloadIdle: () => (busy ? Promise.resolve() : unload()),
|
|
159
163
|
acquire: () => (busy ? false : (busy = true)),
|
|
@@ -163,6 +167,92 @@ export function createMusicRuntime({ loadSdk, onProgress, onBeforeLoad, hold, re
|
|
|
163
167
|
};
|
|
164
168
|
}
|
|
165
169
|
export const BUSY_ERROR = 'a music generation is already running; try again when it finishes';
|
|
170
|
+
export function audioGen(runtime, ctx, options) {
|
|
171
|
+
return ctx.mediaRound
|
|
172
|
+
? audioGenThere(ctx.mediaRound, ctx.runId ?? '', {
|
|
173
|
+
...options,
|
|
174
|
+
modelChoice: runtime.choiceFor(options.modelChoice)
|
|
175
|
+
})
|
|
176
|
+
: audioGenHere(runtime, options);
|
|
177
|
+
}
|
|
178
|
+
export async function audioGenHere(runtime, { modelChoice, inferenceSteps, params, signal, onTick }) {
|
|
179
|
+
if (!runtime.acquire()) {
|
|
180
|
+
return { error: BUSY_ERROR, code: 'busy' };
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const sdk = await runtime.loadSdk();
|
|
184
|
+
const { modelId } = await runtime.ensureLoaded(sdk, { signal, modelChoice, inferenceSteps });
|
|
185
|
+
const track = await runAudioGen(sdk, { modelId, params, signal, onTick });
|
|
186
|
+
return 'error' in track ? track : { ...track, gpuRequested: runtime.gpuRequested };
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
runtime.release();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async function audioGenThere(port, runId, { modelChoice, inferenceSteps, params, signal, onTick }) {
|
|
193
|
+
const asked = port({ kind: 'music', runId, modelChoice, params: { ...params, inferenceSteps } }, {
|
|
194
|
+
signal: signal ?? new AbortController().signal,
|
|
195
|
+
tick: ({ stage, step, total }) => onTick?.({ stage: stage ?? '', step, total })
|
|
196
|
+
});
|
|
197
|
+
const result = await raceAbort(asked, signal);
|
|
198
|
+
if ('error' in result) {
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
if (result.kind !== 'music') {
|
|
202
|
+
return { error: 'the serving device sent no audio' };
|
|
203
|
+
}
|
|
204
|
+
const { bytes, format, gpuRequested, stats } = result;
|
|
205
|
+
return { pcm: bytes, ...format, gpuRequested, stats };
|
|
206
|
+
}
|
|
207
|
+
export function audioGenServer(runtime, isCached, clamps) {
|
|
208
|
+
const cap = normalizeClamps(clamps);
|
|
209
|
+
return {
|
|
210
|
+
serve: async ({ modelChoice, params }, io) => {
|
|
211
|
+
const name = runtime.modelName(modelChoice);
|
|
212
|
+
if (!(await isCached(name, 'audiogen'))) {
|
|
213
|
+
throw new HarnessError('MEDIA_MODEL_MISSING', ['music', name]);
|
|
214
|
+
}
|
|
215
|
+
const steps = numberOf(params.inferenceSteps);
|
|
216
|
+
const audio = audioGenParamsFrom(params);
|
|
217
|
+
const track = await audioGenHere(runtime, {
|
|
218
|
+
modelChoice,
|
|
219
|
+
inferenceSteps: steps && Math.min(steps, cap.maxSteps),
|
|
220
|
+
params: { ...audio, duration: audio.duration && Math.min(audio.duration, cap.maxDuration) },
|
|
221
|
+
signal: io.signal,
|
|
222
|
+
onTick: (tick) => io.tick(tick)
|
|
223
|
+
});
|
|
224
|
+
if ('error' in track) {
|
|
225
|
+
return track;
|
|
226
|
+
}
|
|
227
|
+
const { pcm, sampleRate, channels, bitsPerSample, gpuRequested, stats } = track;
|
|
228
|
+
return {
|
|
229
|
+
kind: 'music',
|
|
230
|
+
bytes: pcm,
|
|
231
|
+
format: { sampleRate, channels, bitsPerSample },
|
|
232
|
+
gpuRequested,
|
|
233
|
+
stats
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function audioGenParamsFrom(params) {
|
|
239
|
+
return {
|
|
240
|
+
caption: stringOf(params.caption) ?? '',
|
|
241
|
+
lyrics: stringOf(params.lyrics),
|
|
242
|
+
duration: numberOf(params.duration),
|
|
243
|
+
seed: numberOf(params.seed),
|
|
244
|
+
bpm: numberOf(params.bpm),
|
|
245
|
+
keyscale: stringOf(params.keyscale),
|
|
246
|
+
timesignature: stringOf(params.timesignature),
|
|
247
|
+
vocalLanguage: stringOf(params.vocalLanguage)
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function numberOf(value) {
|
|
251
|
+
return typeof value === 'number' ? value : undefined;
|
|
252
|
+
}
|
|
253
|
+
function stringOf(value) {
|
|
254
|
+
return typeof value === 'string' ? value : undefined;
|
|
255
|
+
}
|
|
166
256
|
export async function runAudioGen(sdk, { modelId, params, signal, onTick }) {
|
|
167
257
|
if (signal?.aborted) {
|
|
168
258
|
return { error: 'music generation canceled' };
|
|
@@ -485,9 +575,6 @@ export function createGenerateMusicTool(runtime, clamps) {
|
|
|
485
575
|
if (!ctx?.attach) {
|
|
486
576
|
return { error: 'this device cannot persist generated audio' };
|
|
487
577
|
}
|
|
488
|
-
if (!runtime.acquire()) {
|
|
489
|
-
return { error: BUSY_ERROR, code: 'busy' };
|
|
490
|
-
}
|
|
491
578
|
const report = ctx.progress;
|
|
492
579
|
const onTick = report && musicPercentTick((percentage) => report({ percentage }));
|
|
493
580
|
const capMax = stepsCap ?? MAX_STEPS;
|
|
@@ -496,20 +583,15 @@ export function createGenerateMusicTool(runtime, clamps) {
|
|
|
496
583
|
settingsSteps(choiceDefault ?? runtime.defaultSteps, capMax) ??
|
|
497
584
|
stepsCap;
|
|
498
585
|
try {
|
|
499
|
-
const sdk = await runtime.loadSdk();
|
|
500
|
-
const { modelId } = await runtime.ensureLoaded(sdk, {
|
|
501
|
-
signal: ctx.signal,
|
|
502
|
-
modelChoice: music.modelChoice,
|
|
503
|
-
inferenceSteps: steps
|
|
504
|
-
});
|
|
505
586
|
const hasVocals = parsed.lyrics !== undefined &&
|
|
506
587
|
parsed.lyrics.trim().toLowerCase() !== INSTRUMENTAL.toLowerCase();
|
|
507
588
|
const instrumental = !hasVocals;
|
|
508
589
|
const vocalLanguage = hasVocals
|
|
509
590
|
? (parsed.vocalLanguage ?? DEFAULT_VOCAL_LANGUAGE)
|
|
510
591
|
: undefined;
|
|
511
|
-
const result = await
|
|
512
|
-
|
|
592
|
+
const result = await audioGen(runtime, ctx, {
|
|
593
|
+
modelChoice: music.modelChoice,
|
|
594
|
+
inferenceSteps: steps,
|
|
513
595
|
params: {
|
|
514
596
|
caption: parsed.caption,
|
|
515
597
|
lyrics: hasVocals ? parsed.lyrics : INSTRUMENTAL,
|
|
@@ -534,12 +616,13 @@ export function createGenerateMusicTool(runtime, clamps) {
|
|
|
534
616
|
raw: true
|
|
535
617
|
});
|
|
536
618
|
const stats = presentStats(result.stats);
|
|
537
|
-
const
|
|
619
|
+
const { gpuRequested } = result;
|
|
620
|
+
const fallback = gpuFallback({ gpuRequested, stats });
|
|
538
621
|
const notice = fallback ? CPU_FALLBACK_NOTICE : undefined;
|
|
539
|
-
logBackendUsed({ gpuRequested
|
|
622
|
+
logBackendUsed({ gpuRequested, stats, fallback });
|
|
540
623
|
ctx.reportBackend?.({
|
|
541
624
|
tool: GENERATE_MUSIC_TOOL,
|
|
542
|
-
requestedGpu:
|
|
625
|
+
requestedGpu: gpuRequested,
|
|
543
626
|
device: backendDevice(stats),
|
|
544
627
|
backend: backendName(stats?.backendId)
|
|
545
628
|
});
|
|
@@ -567,7 +650,6 @@ export function createGenerateMusicTool(runtime, clamps) {
|
|
|
567
650
|
throw err;
|
|
568
651
|
}
|
|
569
652
|
finally {
|
|
570
|
-
runtime.release();
|
|
571
653
|
report?.(null);
|
|
572
654
|
}
|
|
573
655
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MusicClamps, MusicModelStages } from '../../lib/models/model-catalog.ts';
|
|
2
2
|
import type { HarnessPlugin, PluginContext, PluginSetup } from '../../lib/plugins/index.ts';
|
|
3
|
-
export { audioDurationSeconds, backendDevice, backendName, CPU_FALLBACK_NOTICE, createGenerateMusicTool, createMusicRuntime, gpuFallback, musicPercentTick, pcmToWav, presentStats, type GeneratedAudio, type MusicGenSdk, type MusicRuntime, type MusicRuntimeOptions, type MusicStats, type MusicTick } from './generate-music.ts';
|
|
3
|
+
export { audioDurationSeconds, audioGenServer, backendDevice, backendName, CPU_FALLBACK_NOTICE, createGenerateMusicTool, createMusicRuntime, gpuFallback, musicPercentTick, pcmToWav, presentStats, type GeneratedAudio, type MusicGenSdk, type MusicRuntime, type MusicRuntimeOptions, type MusicStats, type MusicTick } from './generate-music.ts';
|
|
4
4
|
export interface MusicOptions {
|
|
5
5
|
model: MusicModelStages & {
|
|
6
6
|
inferenceSteps?: number;
|
|
@@ -13,6 +13,7 @@ export declare class Music implements HarnessPlugin {
|
|
|
13
13
|
readonly name = "music";
|
|
14
14
|
readonly api = 1;
|
|
15
15
|
readonly needs: string[];
|
|
16
|
+
readonly provides: string[];
|
|
16
17
|
readonly addons: {
|
|
17
18
|
'audiogen-ggml': () => Promise<any>;
|
|
18
19
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { HarnessError } from '../../lib/errors.js';
|
|
2
2
|
import { retryMemo } from '../../lib/helpers/retry-memo.js';
|
|
3
3
|
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
4
|
-
import { createGenerateMusicTool, createMusicRuntime } from './generate-music.js';
|
|
5
|
-
export { audioDurationSeconds, backendDevice, backendName, CPU_FALLBACK_NOTICE, createGenerateMusicTool, createMusicRuntime, gpuFallback, musicPercentTick, pcmToWav, presentStats } from './generate-music.js';
|
|
4
|
+
import { audioGenServer, createGenerateMusicTool, createMusicRuntime } from './generate-music.js';
|
|
5
|
+
export { audioDurationSeconds, audioGenServer, backendDevice, backendName, CPU_FALLBACK_NOTICE, createGenerateMusicTool, createMusicRuntime, gpuFallback, musicPercentTick, pcmToWav, presentStats } from './generate-music.js';
|
|
6
6
|
export class Music {
|
|
7
7
|
name = 'music';
|
|
8
8
|
api = PluginRegistry.API_VERSION;
|
|
9
9
|
needs = ['models'];
|
|
10
|
+
provides = ['music-rounds'];
|
|
10
11
|
addons = { 'audiogen-ggml': () => import('@qvac/audiogen-ggml/binding.js') };
|
|
11
12
|
read;
|
|
12
13
|
_options;
|
|
@@ -49,6 +50,9 @@ export class Music {
|
|
|
49
50
|
});
|
|
50
51
|
return {
|
|
51
52
|
tools: [createGenerateMusicTool(runtime, clamps)],
|
|
53
|
+
services: {
|
|
54
|
+
'music-rounds': audioGenServer(runtime, (name, addon) => models.isCached(name, addon), clamps)
|
|
55
|
+
},
|
|
52
56
|
unload: () => runtime.unload(),
|
|
53
57
|
unloadIdle: () => runtime.unloadIdle()
|
|
54
58
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
2
|
-
PluginRegistry.requireBare('python', '1.
|
|
2
|
+
PluginRegistry.requireBare('python', '1.35.0');
|
|
Binary file
|
|
Binary file
|
|
@@ -97,6 +97,7 @@ export declare class WalkieTalkie implements HarnessPlugin {
|
|
|
97
97
|
private readonly _working;
|
|
98
98
|
private readonly _waiters;
|
|
99
99
|
private readonly _dropped;
|
|
100
|
+
private readonly _announced;
|
|
100
101
|
private _stopped;
|
|
101
102
|
constructor(options: WalkieTalkieOptions);
|
|
102
103
|
validate(): string | null;
|
|
@@ -104,6 +105,7 @@ export declare class WalkieTalkie implements HarnessPlugin {
|
|
|
104
105
|
agents(): AgentInfo[];
|
|
105
106
|
crew(options?: CrewOptions): Crew;
|
|
106
107
|
teammates(): string[];
|
|
108
|
+
announced(): Promise<void>;
|
|
107
109
|
teammate(name: string): Promise<void>;
|
|
108
110
|
send(to: string, { text, attachments }: Outgoing, sending?: Sending): Promise<Reply>;
|
|
109
111
|
ask(question: string, signal?: Pick<AbortSignal, 'aborted' | 'addEventListener'>): Promise<Answer>;
|
|
@@ -25,6 +25,7 @@ export class WalkieTalkie {
|
|
|
25
25
|
_working = new Map();
|
|
26
26
|
_waiters = [];
|
|
27
27
|
_dropped = new Map();
|
|
28
|
+
_announced = Promise.withResolvers();
|
|
28
29
|
_stopped = false;
|
|
29
30
|
constructor(options) {
|
|
30
31
|
this._options = options;
|
|
@@ -74,7 +75,8 @@ export class WalkieTalkie {
|
|
|
74
75
|
void joined
|
|
75
76
|
.flushed()
|
|
76
77
|
.then(() => joined.refresh())
|
|
77
|
-
.catch(noop)
|
|
78
|
+
.catch(noop)
|
|
79
|
+
.then(this._announced.resolve);
|
|
78
80
|
const teardown = async () => {
|
|
79
81
|
this._stopped = true;
|
|
80
82
|
swarm.off('connection', onConnection);
|
|
@@ -102,6 +104,9 @@ export class WalkieTalkie {
|
|
|
102
104
|
teammates() {
|
|
103
105
|
return [...this._lines.keys()];
|
|
104
106
|
}
|
|
107
|
+
announced() {
|
|
108
|
+
return this._announced.promise;
|
|
109
|
+
}
|
|
105
110
|
async teammate(name) {
|
|
106
111
|
while (!this._lines.has(name)) {
|
|
107
112
|
await new Promise((resolve) => this._waiters.push(resolve));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from '
|
|
1
|
+
import fs from 'fs';
|
|
2
2
|
function tsName(fqn) {
|
|
3
3
|
return fqn
|
|
4
4
|
.slice(1)
|
|
@@ -87,6 +87,7 @@ export function writeCapabilities(builder, outFile, options = {}) {
|
|
|
87
87
|
s +=
|
|
88
88
|
'// the generated client pre-arms an error observer - a dying stream never crashes a host that only listens to data\n';
|
|
89
89
|
s += 'export interface WatchStream<Frame> extends AsyncIterable<Frame> {\n';
|
|
90
|
+
s += ' readonly destroyed: boolean\n';
|
|
90
91
|
s += " on(event: 'data', listener: (frame: Frame) => void): this\n";
|
|
91
92
|
s += " on(event: 'error', listener: (err: Error) => void): this\n";
|
|
92
93
|
s += " on(event: 'close' | 'end', listener: () => void): this\n";
|
|
@@ -96,6 +97,12 @@ export function writeCapabilities(builder, outFile, options = {}) {
|
|
|
96
97
|
s += ' destroy(): void\n';
|
|
97
98
|
s += '}\n\n';
|
|
98
99
|
s += 'export interface UploadStream<In, Out> extends WatchStream<Out> {\n';
|
|
100
|
+
s += " on(event: 'data', listener: (frame: Out) => void): this\n";
|
|
101
|
+
s += " on(event: 'error', listener: (err: Error) => void): this\n";
|
|
102
|
+
s += " on(event: 'close' | 'end' | 'drain', listener: () => void): this\n";
|
|
103
|
+
s += " off(event: 'data', listener: (frame: Out) => void): this\n";
|
|
104
|
+
s += " off(event: 'error', listener: (err: Error) => void): this\n";
|
|
105
|
+
s += " off(event: 'close' | 'end' | 'drain', listener: () => void): this\n";
|
|
99
106
|
s += ' write(frame: In): boolean\n';
|
|
100
107
|
s += ' end(): void\n';
|
|
101
108
|
s += '}\n\n';
|
|
@@ -96,7 +96,10 @@ export function registerHarnessTypes(ns) {
|
|
|
96
96
|
'model-round-chunk',
|
|
97
97
|
'model-round-retake',
|
|
98
98
|
'model-round-result',
|
|
99
|
-
'round-cut'
|
|
99
|
+
'round-cut',
|
|
100
|
+
'media-round-ask',
|
|
101
|
+
'media-round-tick',
|
|
102
|
+
'media-round-result'
|
|
100
103
|
],
|
|
101
104
|
strings: true
|
|
102
105
|
});
|
|
@@ -180,7 +183,11 @@ export function registerHarnessTypes(ns) {
|
|
|
180
183
|
'model-round-ask',
|
|
181
184
|
'model-round-cancel',
|
|
182
185
|
'model-round-retake',
|
|
183
|
-
'model-round-result'
|
|
186
|
+
'model-round-result',
|
|
187
|
+
'media-round-ask',
|
|
188
|
+
'media-round-cancel',
|
|
189
|
+
'media-round-tick',
|
|
190
|
+
'media-round-result'
|
|
184
191
|
],
|
|
185
192
|
strings: true
|
|
186
193
|
});
|
|
@@ -439,13 +439,16 @@ const encoding10_enum = {
|
|
|
439
439
|
"model-round-chunk": 'model-round-chunk',
|
|
440
440
|
"model-round-retake": 'model-round-retake',
|
|
441
441
|
"model-round-result": 'model-round-result',
|
|
442
|
-
"round-cut": 'round-cut'
|
|
442
|
+
"round-cut": 'round-cut',
|
|
443
|
+
"media-round-ask": 'media-round-ask',
|
|
444
|
+
"media-round-tick": 'media-round-tick',
|
|
445
|
+
"media-round-result": 'media-round-result'
|
|
443
446
|
}
|
|
444
447
|
|
|
445
448
|
// @harness/completion-frame-type enum
|
|
446
449
|
const encoding10 = {
|
|
447
450
|
preencode (state, m) {
|
|
448
|
-
state.end++ // max enum is
|
|
451
|
+
state.end++ // max enum is 20 so always one byte
|
|
449
452
|
},
|
|
450
453
|
encode (state, m) {
|
|
451
454
|
switch (m) {
|
|
@@ -500,6 +503,15 @@ const encoding10 = {
|
|
|
500
503
|
case 'round-cut':
|
|
501
504
|
c.uint.encode(state, 17)
|
|
502
505
|
break
|
|
506
|
+
case 'media-round-ask':
|
|
507
|
+
c.uint.encode(state, 18)
|
|
508
|
+
break
|
|
509
|
+
case 'media-round-tick':
|
|
510
|
+
c.uint.encode(state, 19)
|
|
511
|
+
break
|
|
512
|
+
case 'media-round-result':
|
|
513
|
+
c.uint.encode(state, 20)
|
|
514
|
+
break
|
|
503
515
|
default:
|
|
504
516
|
throw new Error('Unknown enum')
|
|
505
517
|
}
|
|
@@ -540,6 +552,12 @@ const encoding10 = {
|
|
|
540
552
|
return 'model-round-result'
|
|
541
553
|
case 17:
|
|
542
554
|
return 'round-cut'
|
|
555
|
+
case 18:
|
|
556
|
+
return 'media-round-ask'
|
|
557
|
+
case 19:
|
|
558
|
+
return 'media-round-tick'
|
|
559
|
+
case 20:
|
|
560
|
+
return 'media-round-result'
|
|
543
561
|
default: return null
|
|
544
562
|
}
|
|
545
563
|
}
|
|
@@ -764,13 +782,17 @@ const encoding12_enum = {
|
|
|
764
782
|
"model-round-ask": 'model-round-ask',
|
|
765
783
|
"model-round-cancel": 'model-round-cancel',
|
|
766
784
|
"model-round-retake": 'model-round-retake',
|
|
767
|
-
"model-round-result": 'model-round-result'
|
|
785
|
+
"model-round-result": 'model-round-result',
|
|
786
|
+
"media-round-ask": 'media-round-ask',
|
|
787
|
+
"media-round-cancel": 'media-round-cancel',
|
|
788
|
+
"media-round-tick": 'media-round-tick',
|
|
789
|
+
"media-round-result": 'media-round-result'
|
|
768
790
|
}
|
|
769
791
|
|
|
770
792
|
// @harness/completion-event-type enum
|
|
771
793
|
const encoding12 = {
|
|
772
794
|
preencode (state, m) {
|
|
773
|
-
state.end++ // max enum is
|
|
795
|
+
state.end++ // max enum is 37 so always one byte
|
|
774
796
|
},
|
|
775
797
|
encode (state, m) {
|
|
776
798
|
switch (m) {
|
|
@@ -873,6 +895,18 @@ const encoding12 = {
|
|
|
873
895
|
case 'model-round-result':
|
|
874
896
|
c.uint.encode(state, 33)
|
|
875
897
|
break
|
|
898
|
+
case 'media-round-ask':
|
|
899
|
+
c.uint.encode(state, 34)
|
|
900
|
+
break
|
|
901
|
+
case 'media-round-cancel':
|
|
902
|
+
c.uint.encode(state, 35)
|
|
903
|
+
break
|
|
904
|
+
case 'media-round-tick':
|
|
905
|
+
c.uint.encode(state, 36)
|
|
906
|
+
break
|
|
907
|
+
case 'media-round-result':
|
|
908
|
+
c.uint.encode(state, 37)
|
|
909
|
+
break
|
|
876
910
|
default:
|
|
877
911
|
throw new Error('Unknown enum')
|
|
878
912
|
}
|
|
@@ -945,6 +979,14 @@ const encoding12 = {
|
|
|
945
979
|
return 'model-round-retake'
|
|
946
980
|
case 33:
|
|
947
981
|
return 'model-round-result'
|
|
982
|
+
case 34:
|
|
983
|
+
return 'media-round-ask'
|
|
984
|
+
case 35:
|
|
985
|
+
return 'media-round-cancel'
|
|
986
|
+
case 36:
|
|
987
|
+
return 'media-round-tick'
|
|
988
|
+
case 37:
|
|
989
|
+
return 'media-round-result'
|
|
948
990
|
default: return null
|
|
949
991
|
}
|
|
950
992
|
}
|
|
@@ -439,13 +439,16 @@ const encoding10_enum = {
|
|
|
439
439
|
"model-round-chunk": 'model-round-chunk',
|
|
440
440
|
"model-round-retake": 'model-round-retake',
|
|
441
441
|
"model-round-result": 'model-round-result',
|
|
442
|
-
"round-cut": 'round-cut'
|
|
442
|
+
"round-cut": 'round-cut',
|
|
443
|
+
"media-round-ask": 'media-round-ask',
|
|
444
|
+
"media-round-tick": 'media-round-tick',
|
|
445
|
+
"media-round-result": 'media-round-result'
|
|
443
446
|
}
|
|
444
447
|
|
|
445
448
|
// @harness/completion-frame-type enum
|
|
446
449
|
const encoding10 = {
|
|
447
450
|
preencode (state, m) {
|
|
448
|
-
state.end++ // max enum is
|
|
451
|
+
state.end++ // max enum is 20 so always one byte
|
|
449
452
|
},
|
|
450
453
|
encode (state, m) {
|
|
451
454
|
switch (m) {
|
|
@@ -500,6 +503,15 @@ const encoding10 = {
|
|
|
500
503
|
case 'round-cut':
|
|
501
504
|
c.uint.encode(state, 17)
|
|
502
505
|
break
|
|
506
|
+
case 'media-round-ask':
|
|
507
|
+
c.uint.encode(state, 18)
|
|
508
|
+
break
|
|
509
|
+
case 'media-round-tick':
|
|
510
|
+
c.uint.encode(state, 19)
|
|
511
|
+
break
|
|
512
|
+
case 'media-round-result':
|
|
513
|
+
c.uint.encode(state, 20)
|
|
514
|
+
break
|
|
503
515
|
default:
|
|
504
516
|
throw new Error('Unknown enum')
|
|
505
517
|
}
|
|
@@ -540,6 +552,12 @@ const encoding10 = {
|
|
|
540
552
|
return 'model-round-result'
|
|
541
553
|
case 17:
|
|
542
554
|
return 'round-cut'
|
|
555
|
+
case 18:
|
|
556
|
+
return 'media-round-ask'
|
|
557
|
+
case 19:
|
|
558
|
+
return 'media-round-tick'
|
|
559
|
+
case 20:
|
|
560
|
+
return 'media-round-result'
|
|
543
561
|
default: return null
|
|
544
562
|
}
|
|
545
563
|
}
|
|
@@ -764,13 +782,17 @@ const encoding12_enum = {
|
|
|
764
782
|
"model-round-ask": 'model-round-ask',
|
|
765
783
|
"model-round-cancel": 'model-round-cancel',
|
|
766
784
|
"model-round-retake": 'model-round-retake',
|
|
767
|
-
"model-round-result": 'model-round-result'
|
|
785
|
+
"model-round-result": 'model-round-result',
|
|
786
|
+
"media-round-ask": 'media-round-ask',
|
|
787
|
+
"media-round-cancel": 'media-round-cancel',
|
|
788
|
+
"media-round-tick": 'media-round-tick',
|
|
789
|
+
"media-round-result": 'media-round-result'
|
|
768
790
|
}
|
|
769
791
|
|
|
770
792
|
// @harness/completion-event-type enum
|
|
771
793
|
const encoding12 = {
|
|
772
794
|
preencode (state, m) {
|
|
773
|
-
state.end++ // max enum is
|
|
795
|
+
state.end++ // max enum is 37 so always one byte
|
|
774
796
|
},
|
|
775
797
|
encode (state, m) {
|
|
776
798
|
switch (m) {
|
|
@@ -873,6 +895,18 @@ const encoding12 = {
|
|
|
873
895
|
case 'model-round-result':
|
|
874
896
|
c.uint.encode(state, 33)
|
|
875
897
|
break
|
|
898
|
+
case 'media-round-ask':
|
|
899
|
+
c.uint.encode(state, 34)
|
|
900
|
+
break
|
|
901
|
+
case 'media-round-cancel':
|
|
902
|
+
c.uint.encode(state, 35)
|
|
903
|
+
break
|
|
904
|
+
case 'media-round-tick':
|
|
905
|
+
c.uint.encode(state, 36)
|
|
906
|
+
break
|
|
907
|
+
case 'media-round-result':
|
|
908
|
+
c.uint.encode(state, 37)
|
|
909
|
+
break
|
|
876
910
|
default:
|
|
877
911
|
throw new Error('Unknown enum')
|
|
878
912
|
}
|
|
@@ -945,6 +979,14 @@ const encoding12 = {
|
|
|
945
979
|
return 'model-round-retake'
|
|
946
980
|
case 33:
|
|
947
981
|
return 'model-round-result'
|
|
982
|
+
case 34:
|
|
983
|
+
return 'media-round-ask'
|
|
984
|
+
case 35:
|
|
985
|
+
return 'media-round-cancel'
|
|
986
|
+
case 36:
|
|
987
|
+
return 'media-round-tick'
|
|
988
|
+
case 37:
|
|
989
|
+
return 'media-round-result'
|
|
948
990
|
default: return null
|
|
949
991
|
}
|
|
950
992
|
}
|
|
@@ -398,6 +398,18 @@
|
|
|
398
398
|
{
|
|
399
399
|
"key": "round-cut",
|
|
400
400
|
"version": 23
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"key": "media-round-ask",
|
|
404
|
+
"version": 23
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"key": "media-round-tick",
|
|
408
|
+
"version": 23
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"key": "media-round-result",
|
|
412
|
+
"version": 23
|
|
401
413
|
}
|
|
402
414
|
],
|
|
403
415
|
"strings": true
|
|
@@ -711,6 +723,22 @@
|
|
|
711
723
|
{
|
|
712
724
|
"key": "model-round-result",
|
|
713
725
|
"version": 23
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"key": "media-round-ask",
|
|
729
|
+
"version": 23
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"key": "media-round-cancel",
|
|
733
|
+
"version": 23
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
"key": "media-round-tick",
|
|
737
|
+
"version": 23
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
"key": "media-round-result",
|
|
741
|
+
"version": 23
|
|
714
742
|
}
|
|
715
743
|
],
|
|
716
744
|
"strings": true
|
|
@@ -68,7 +68,7 @@ export interface HarnessAttachmentRecord {
|
|
|
68
68
|
byteLength: number
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export type HarnessCompletionFrameType = "start" | "decision" | "attach-result" | "fetch-result" | "rag-result" | "question-result" | "drive-result" | "invoke" | "run-log-result" | "pause" | "steer" | "follow-up" | "model-round-ask" | "model-round-chunk" | "model-round-retake" | "model-round-result" | "round-cut"
|
|
71
|
+
export type HarnessCompletionFrameType = "start" | "decision" | "attach-result" | "fetch-result" | "rag-result" | "question-result" | "drive-result" | "invoke" | "run-log-result" | "pause" | "steer" | "follow-up" | "model-round-ask" | "model-round-chunk" | "model-round-retake" | "model-round-result" | "round-cut" | "media-round-ask" | "media-round-tick" | "media-round-result"
|
|
72
72
|
|
|
73
73
|
export interface HarnessCompletionFrame {
|
|
74
74
|
type: HarnessCompletionFrameType
|
|
@@ -105,7 +105,7 @@ export interface HarnessCompletionFrame {
|
|
|
105
105
|
runId?: string | null
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export type HarnessCompletionEventType = "content" | "thinking" | "tool-call" | "tool-result" | "approval-ask" | "metrics" | "error" | "aborted" | "attach-ask" | "fetch-ask" | "progress" | "rag-ask" | "question-ask" | "done" | "tool-activity" | "drive-ask" | "inference-call" | "inference-sent" | "run-started" | "run-resumed" | "paused" | "recovery-required" | "round-reset" | "run-log-append" | "input" | "goal" | "fold" | "input-rejected" | "context" | "model-round-ask" | "model-round-cancel" | "model-round-retake" | "model-round-result"
|
|
108
|
+
export type HarnessCompletionEventType = "content" | "thinking" | "tool-call" | "tool-result" | "approval-ask" | "metrics" | "error" | "aborted" | "attach-ask" | "fetch-ask" | "progress" | "rag-ask" | "question-ask" | "done" | "tool-activity" | "drive-ask" | "inference-call" | "inference-sent" | "run-started" | "run-resumed" | "paused" | "recovery-required" | "round-reset" | "run-log-append" | "input" | "goal" | "fold" | "input-rejected" | "context" | "model-round-ask" | "model-round-cancel" | "model-round-retake" | "model-round-result" | "media-round-ask" | "media-round-cancel" | "media-round-tick" | "media-round-result"
|
|
109
109
|
|
|
110
110
|
export interface HarnessCompletionEvent {
|
|
111
111
|
type: HarnessCompletionEventType
|