@qvac/harness 1.0.0-rc.6 → 1.0.0-rc.7
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 +157 -10
- package/README.md +19 -7
- package/dist-lib/index.d.ts +2 -2
- package/dist-lib/index.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +31 -3
- package/dist-lib/lib/capabilities/completion-engine/driver.js +3 -0
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/index.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/round.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
- package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
- package/dist-lib/lib/capabilities/detect-language.js +14 -2
- package/dist-lib/lib/connect.d.ts +2 -0
- package/dist-lib/lib/connect.js +73 -7
- package/dist-lib/lib/contract-types.d.ts +4 -0
- package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
- package/dist-lib/lib/helpers/require-peers.js +23 -0
- package/dist-lib/lib/models/llm-presets.d.ts +1 -0
- package/dist-lib/lib/models/model-catalog.js +1 -1
- package/dist-lib/lib/models/opencl-cache.js +2 -2
- package/dist-lib/lib/plugins/registry.d.ts +2 -0
- package/dist-lib/lib/plugins/registry.js +4 -0
- package/dist-lib/lib/round-host.d.ts +12 -0
- package/dist-lib/lib/round-host.js +57 -0
- package/dist-lib/lib/round-port.d.ts +24 -0
- package/dist-lib/lib/round-port.js +81 -0
- package/dist-lib/lib/sdk-loader.d.ts +1 -1
- package/dist-lib/lib/sdk-loader.js +30 -6
- package/dist-lib/lib/sdk-storage.d.ts +1 -0
- package/dist-lib/lib/sdk-storage.js +18 -2
- package/dist-lib/lib/serve.js +61 -1
- package/dist-lib/lib/sidecar/index.d.ts +10 -0
- package/dist-lib/lib/sidecar/index.js +35 -3
- package/dist-lib/lib/sidecar/user-plugins.d.ts +1 -0
- package/dist-lib/lib/sidecar/user-plugins.js +1 -1
- package/dist-lib/lib/tools/files/grep.js +113 -15
- package/dist-lib/lib/tools/fs/edit-match.js +75 -7
- package/dist-lib/lib/tools/fs/search.d.ts +1 -1
- package/dist-lib/lib/tools/fs/search.js +2 -1
- package/dist-lib/lib/tools/index.d.ts +2 -1
- package/dist-lib/lib/tools/index.js +2 -2
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
- package/dist-lib/lib/wire.d.ts +13 -0
- package/dist-lib/lib/wire.js +44 -1
- package/dist-lib/plugins/coding/read-only.d.ts +1 -0
- package/dist-lib/plugins/coding/read-only.js +264 -0
- package/dist-lib/plugins/coding/session.d.ts +3 -1
- package/dist-lib/plugins/coding/session.js +19 -2
- package/dist-lib/plugins/egress-proxy/index.d.ts +2 -2
- package/dist-lib/plugins/egress-proxy/index.js +5 -3
- package/dist-lib/plugins/image/index.js +7 -2
- package/dist-lib/plugins/language-hint/index.js +4 -1
- package/dist-lib/plugins/music/index.js +6 -2
- package/dist-lib/plugins/python/index.js +1 -0
- package/dist-lib/plugins/python/loader.d.ts +1 -0
- package/dist-lib/plugins/python/loader.js +8 -0
- package/dist-lib/plugins/quickjs/index.js +4 -0
- package/dist-lib/plugins/quickjs/runtime.js +8 -3
- package/dist-lib/plugins/run-report/index.js +6 -2
- package/dist-lib/plugins/run-report/layout.js +1 -1
- package/dist-lib/plugins/sandbox-vm/index.js +3 -0
- 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/speech/audio-resample.js +2 -1
- package/dist-lib/plugins/speech/index.d.ts +1 -0
- package/dist-lib/plugins/speech/index.js +8 -1
- package/dist-lib/plugins/speech/speech-runtime.js +3 -3
- package/dist-lib/plugins/translation/index.d.ts +1 -1
- package/dist-lib/plugins/translation/index.js +7 -3
- package/dist-lib/plugins/translation/translate.d.ts +2 -2
- package/dist-lib/plugins/translation/translate.js +7 -8
- package/dist-lib/plugins/walkie-talkie/index.d.ts +2 -2
- package/dist-lib/plugins/walkie-talkie/index.js +13 -5
- package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
- package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
- package/dist-lib/schema/harness.js +13 -4
- package/dist-lib/spec/hrpc/messages.js +205 -151
- package/dist-lib/spec/hyperschema/index.js +205 -151
- package/dist-lib/spec/hyperschema/schema.json +125 -89
- package/dist-lib/spec/hyperschema/types.d.ts +4 -4
- package/package.json +149 -24
|
@@ -15,9 +15,9 @@ function voiceSdk(models) {
|
|
|
15
15
|
const sdk = await models.sdk();
|
|
16
16
|
if (typeof globalThis.Bare !== 'undefined') {
|
|
17
17
|
const [{ ttsPlugin }, { parakeetPlugin }, { registerPlugin }] = await Promise.all([
|
|
18
|
-
import('@qvac/
|
|
19
|
-
import('@qvac/
|
|
20
|
-
import('@qvac/
|
|
18
|
+
import('@qvac/inference/tts-ggml/plugin'),
|
|
19
|
+
import('@qvac/inference/parakeet-transcription/plugin'),
|
|
20
|
+
import('@qvac/inference/plugin-registry')
|
|
21
21
|
]);
|
|
22
22
|
for (const [name, plugin] of [
|
|
23
23
|
['tts', ttsPlugin],
|
|
@@ -16,7 +16,7 @@ export declare class TranslationPlugin implements HarnessPlugin {
|
|
|
16
16
|
readonly provides: string[];
|
|
17
17
|
readonly needs: string[];
|
|
18
18
|
readonly addons: {
|
|
19
|
-
translation: () => Promise<typeof import("@qvac/
|
|
19
|
+
translation: () => Promise<typeof import("@qvac/inference/nmtcpp-translation/plugin")>;
|
|
20
20
|
'translation-nmtcpp': () => Promise<typeof import("@qvac/translation-nmtcpp/addonLogging")>;
|
|
21
21
|
};
|
|
22
22
|
setup(ctx: PluginContext): PluginSetup;
|
|
@@ -4,13 +4,17 @@ import { retryMemo } from '../../lib/helpers/retry-memo.js';
|
|
|
4
4
|
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
5
5
|
import { EURONANO_LANGUAGES, NMT_FROM_ENGLISH, NMT_TO_ENGLISH, SLM_LANGUAGE_CODES, SLM_LANGUAGE_NAMES, translationPlanFor } from './nmt-catalog.js';
|
|
6
6
|
import { createTranslate, createTranslateTool, createTranslationRuntime } from './translate.js';
|
|
7
|
+
PluginRegistry.requirePeers('translation', {
|
|
8
|
+
'@qvac/langdetect-text': () => import.meta.resolve('@qvac/langdetect-text'),
|
|
9
|
+
'@qvac/translation-nmtcpp': () => import.meta.resolve('@qvac/translation-nmtcpp/addonLogging')
|
|
10
|
+
});
|
|
7
11
|
function nmtSdk(models) {
|
|
8
12
|
return retryMemo(async () => {
|
|
9
13
|
const sdk = await models.sdk();
|
|
10
14
|
if (typeof globalThis.Bare !== 'undefined') {
|
|
11
15
|
const [{ nmtPlugin }, { registerPlugin }] = await Promise.all([
|
|
12
|
-
import('@qvac/
|
|
13
|
-
import('@qvac/
|
|
16
|
+
import('@qvac/inference/nmtcpp-translation/plugin'),
|
|
17
|
+
import('@qvac/inference/plugin-registry')
|
|
14
18
|
]);
|
|
15
19
|
try {
|
|
16
20
|
registerPlugin(nmtPlugin);
|
|
@@ -47,7 +51,7 @@ export class TranslationPlugin {
|
|
|
47
51
|
provides = ['translation'];
|
|
48
52
|
needs = ['models'];
|
|
49
53
|
addons = {
|
|
50
|
-
translation: () => import('@qvac/
|
|
54
|
+
translation: () => import('@qvac/inference/nmtcpp-translation/plugin'),
|
|
51
55
|
'translation-nmtcpp': () => import('@qvac/translation-nmtcpp/addonLogging')
|
|
52
56
|
};
|
|
53
57
|
setup(ctx) {
|
|
@@ -69,7 +69,7 @@ export type SlmTranslateFn = (model: string, params: {
|
|
|
69
69
|
from: string;
|
|
70
70
|
to: string;
|
|
71
71
|
}, signal?: BareAbortSignal) => Promise<string>;
|
|
72
|
-
export declare function stripLanguageLabel(text: string, ...codes: string[]): string
|
|
72
|
+
export declare function stripLanguageLabel(text: string, ...codes: string[]): Promise<string>;
|
|
73
73
|
export interface TranslateArgs {
|
|
74
74
|
text: string;
|
|
75
75
|
to: string;
|
|
@@ -79,7 +79,7 @@ export interface TranslateError {
|
|
|
79
79
|
error: string;
|
|
80
80
|
}
|
|
81
81
|
export declare function parseTranslateArgs(args: Record<string, unknown>): TranslateArgs | TranslateError;
|
|
82
|
-
export declare function sourceLanguage(text: string, from?: string): string | TranslateError
|
|
82
|
+
export declare function sourceLanguage(text: string, from?: string): Promise<string | TranslateError>;
|
|
83
83
|
export interface TranslateToolOptions {
|
|
84
84
|
slm?: SlmTranslateFn;
|
|
85
85
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import ScopeLock from 'scope-lock';
|
|
2
|
-
import {
|
|
3
|
-
import { detectLanguage, UNDETERMINED } from '../../lib/capabilities/detect-language.js';
|
|
2
|
+
import { detectLanguage, languageName, UNDETERMINED } from '../../lib/capabilities/detect-language.js';
|
|
4
3
|
import { HarnessError } from '../../lib/errors.js';
|
|
5
4
|
import { createLoadStall } from '../../lib/helpers/load-stall.js';
|
|
6
5
|
import { AbortedError, raceAbort } from '../../lib/helpers/race-abort.js';
|
|
@@ -135,13 +134,13 @@ export function createTranslationRuntime({ loadSdk, loads = { track: (pending) =
|
|
|
135
134
|
}
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
|
-
export function stripLanguageLabel(text, ...codes) {
|
|
137
|
+
export async function stripLanguageLabel(text, ...codes) {
|
|
139
138
|
const at = text.indexOf(':');
|
|
140
139
|
if (at === -1) {
|
|
141
140
|
return text;
|
|
142
141
|
}
|
|
143
142
|
const head = text.slice(0, at).trim();
|
|
144
|
-
const labels = codes.map((code) => languageLabel(code) ??
|
|
143
|
+
const labels = await Promise.all(codes.map((code) => languageLabel(code) ?? languageName(code)));
|
|
145
144
|
return labels.includes(head) ? text.slice(at + 1).trim() : text;
|
|
146
145
|
}
|
|
147
146
|
export function parseTranslateArgs(args) {
|
|
@@ -156,10 +155,10 @@ export function parseTranslateArgs(args) {
|
|
|
156
155
|
const from = typeof args.from === 'string' ? args.from.trim() : undefined;
|
|
157
156
|
return { text, to, from };
|
|
158
157
|
}
|
|
159
|
-
export function sourceLanguage(text, from) {
|
|
158
|
+
export async function sourceLanguage(text, from) {
|
|
160
159
|
if (from)
|
|
161
160
|
return from;
|
|
162
|
-
const [{ code }] = detectLanguage({ text });
|
|
161
|
+
const [{ code }] = await detectLanguage({ text });
|
|
163
162
|
if (code === UNDETERMINED) {
|
|
164
163
|
return { error: NEEDS_SOURCE };
|
|
165
164
|
}
|
|
@@ -168,7 +167,7 @@ export function sourceLanguage(text, from) {
|
|
|
168
167
|
const NEEDS_SOURCE = 'could not detect the source language; pass `from` explicitly';
|
|
169
168
|
export function createTranslate(runtime, { slm } = {}) {
|
|
170
169
|
return async (request, signal) => {
|
|
171
|
-
const from = sourceLanguage(request.text, request.from);
|
|
170
|
+
const from = await sourceLanguage(request.text, request.from);
|
|
172
171
|
if (typeof from === 'object') {
|
|
173
172
|
return from;
|
|
174
173
|
}
|
|
@@ -192,7 +191,7 @@ export function createTranslate(runtime, { slm } = {}) {
|
|
|
192
191
|
}
|
|
193
192
|
const text = await slm(plan.model, { text: request.text, from: plan.from, to: plan.to }, signal);
|
|
194
193
|
return {
|
|
195
|
-
text: stripLanguageLabel(text, plan.from, plan.to),
|
|
194
|
+
text: await stripLanguageLabel(text, plan.from, plan.to),
|
|
196
195
|
from,
|
|
197
196
|
to: request.to,
|
|
198
197
|
engine: 'slm',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Hyperswarm from 'hyperswarm';
|
|
1
|
+
import type Hyperswarm from 'hyperswarm';
|
|
2
2
|
import type { TargetEvent } from '../../lib/agent/index.ts';
|
|
3
3
|
import type { HarnessPlugin, PluginSetup } from '../../lib/plugins/index.ts';
|
|
4
4
|
import { type Attachments, type Crew, type CrewOptions, type Outgoing, type Reply } from './crew.ts';
|
|
@@ -100,7 +100,7 @@ export declare class WalkieTalkie implements HarnessPlugin {
|
|
|
100
100
|
private _stopped;
|
|
101
101
|
constructor(options: WalkieTalkieOptions);
|
|
102
102
|
validate(): string | null;
|
|
103
|
-
setup(): PluginSetup
|
|
103
|
+
setup(): Promise<PluginSetup>;
|
|
104
104
|
agents(): AgentInfo[];
|
|
105
105
|
crew(options?: CrewOptions): Crew;
|
|
106
106
|
teammates(): string[];
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import
|
|
3
|
-
import Hyperswarm from 'hyperswarm';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
4
3
|
import { PluginRegistry } from '../../lib/plugins/index.js';
|
|
5
4
|
import { crew } from './crew.js';
|
|
6
5
|
import { openLine } from './wire.js';
|
|
6
|
+
PluginRegistry.requirePeers('walkie-talkie', {
|
|
7
|
+
'hypercore-crypto': () => import.meta.resolve('hypercore-crypto'),
|
|
8
|
+
hyperswarm: () => import.meta.resolve('hyperswarm')
|
|
9
|
+
});
|
|
7
10
|
const NAME = /^[\w.-]+$/;
|
|
8
11
|
const GRACE_MS = 5_000;
|
|
9
12
|
const NOBODY = { by: null, text: null };
|
|
@@ -46,14 +49,19 @@ export class WalkieTalkie {
|
|
|
46
49
|
? null
|
|
47
50
|
: 'the name and each agent name must be letters, digits, dot, dash or underscore';
|
|
48
51
|
}
|
|
49
|
-
setup() {
|
|
52
|
+
async setup() {
|
|
53
|
+
const [{ default: crypto }, { default: Swarm }] = await Promise.all([
|
|
54
|
+
import('hypercore-crypto'),
|
|
55
|
+
import('hyperswarm')
|
|
56
|
+
]);
|
|
50
57
|
const team = b4a.from(this._options.team, 'hex');
|
|
51
58
|
const topic = crypto.discoveryKey(team);
|
|
52
59
|
const lent = this._options.swarm;
|
|
53
|
-
const swarm = lent ?? new
|
|
60
|
+
const swarm = lent ?? new Swarm({ bootstrap: this._options.bootstrap });
|
|
54
61
|
const me = { name: this._options.name, agents: this._infos(), people: this._self.people };
|
|
55
62
|
const onConnection = (connection) => isConnection(connection) &&
|
|
56
63
|
openLine(connection, {
|
|
64
|
+
crypto,
|
|
57
65
|
team,
|
|
58
66
|
me,
|
|
59
67
|
onOpen: (line) => this._onOpen(line),
|
|
@@ -335,6 +343,6 @@ function errorText(error) {
|
|
|
335
343
|
return String(Reflect.get(Object(error), 'message') ?? error);
|
|
336
344
|
}
|
|
337
345
|
function randomId() {
|
|
338
|
-
return b4a.toHex(
|
|
346
|
+
return b4a.toHex(randomBytes(8));
|
|
339
347
|
}
|
|
340
348
|
function noop() { }
|
|
@@ -57,7 +57,12 @@ export interface Connection {
|
|
|
57
57
|
on(event: 'close' | 'error', listener: () => void): unknown;
|
|
58
58
|
destroy(): void;
|
|
59
59
|
}
|
|
60
|
+
export interface TeamCrypto {
|
|
61
|
+
hash(data: Buffer[]): Buffer;
|
|
62
|
+
discoveryKey(key: Buffer): Buffer;
|
|
63
|
+
}
|
|
60
64
|
export interface LineOptions {
|
|
65
|
+
crypto: TeamCrypto;
|
|
61
66
|
team: Buffer;
|
|
62
67
|
me: Pick<Line, 'name' | 'agents' | 'people'>;
|
|
63
68
|
onOpen(line: Line): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
2
|
import { raw } from 'compact-encoding';
|
|
3
|
-
import crypto from 'hypercore-crypto';
|
|
4
3
|
import Protomux from 'protomux';
|
|
5
4
|
import { isRecord } from '../../lib/guards.js';
|
|
6
5
|
const PROTOCOL = 'qvac/walkie-talkie/1';
|
|
@@ -21,11 +20,11 @@ const EVENTS = {
|
|
|
21
20
|
error: 'error'
|
|
22
21
|
};
|
|
23
22
|
const USAGE = ['inputTokens', 'outputTokens', 'costUsd', 'turns'];
|
|
24
|
-
function proof(team, connection) {
|
|
23
|
+
function proof(crypto, team, connection) {
|
|
25
24
|
return b4a.toHex(crypto.hash([team, connection.handshakeHash]));
|
|
26
25
|
}
|
|
27
26
|
export function openLine(connection, options) {
|
|
28
|
-
const { team, me, onOpen, onFrame, onClose } = options;
|
|
27
|
+
const { crypto, team, me, onOpen, onFrame, onClose } = options;
|
|
29
28
|
let line = null;
|
|
30
29
|
const channel = Protomux.from(connection).createChannel({
|
|
31
30
|
protocol: PROTOCOL,
|
|
@@ -40,7 +39,9 @@ export function openLine(connection, options) {
|
|
|
40
39
|
if (line && message && message.type !== 'hello') {
|
|
41
40
|
onFrame(line, { message, bodies });
|
|
42
41
|
}
|
|
43
|
-
else if (!line &&
|
|
42
|
+
else if (!line &&
|
|
43
|
+
message?.type === 'hello' &&
|
|
44
|
+
message.proof === proof(crypto, team, connection)) {
|
|
44
45
|
const { name, agents, people } = message;
|
|
45
46
|
line = { name, agents, people, send, close: () => channel.close() };
|
|
46
47
|
onOpen(line);
|
|
@@ -56,7 +57,7 @@ export function openLine(connection, options) {
|
|
|
56
57
|
const send = (message, bodies = []) => out.send(pack({ head: message, bodies }));
|
|
57
58
|
connection.on('error', noop);
|
|
58
59
|
channel.open();
|
|
59
|
-
send({ type: 'hello', ...me, agents: [...me.agents], proof: proof(team, connection) });
|
|
60
|
+
send({ type: 'hello', ...me, agents: [...me.agents], proof: proof(crypto, team, connection) });
|
|
60
61
|
}
|
|
61
62
|
function pack({ head, bodies }) {
|
|
62
63
|
const parts = [b4a.from(JSON.stringify(head)), ...bodies];
|
|
@@ -53,12 +53,12 @@ export function registerHarnessTypes(ns) {
|
|
|
53
53
|
{ name: 'role', type: '@harness/message-role', required: true },
|
|
54
54
|
{ name: 'content', type: 'string', required: true },
|
|
55
55
|
{ name: 'attachments', type: '@harness/message-attachment', array: true },
|
|
56
|
+
{ name: 'sentAt', type: 'uint' },
|
|
56
57
|
{ name: 'toolCalls', type: 'json' },
|
|
57
58
|
{ name: 'toolCallId', type: 'string' },
|
|
58
59
|
{ name: 'name', type: 'string' },
|
|
59
60
|
{ name: 'id', type: 'string' },
|
|
60
|
-
{ name: 'context', type: 'json' }
|
|
61
|
-
{ name: 'sentAt', type: 'uint' }
|
|
61
|
+
{ name: 'context', type: 'json' }
|
|
62
62
|
]
|
|
63
63
|
});
|
|
64
64
|
ns.register({
|
|
@@ -91,7 +91,12 @@ export function registerHarnessTypes(ns) {
|
|
|
91
91
|
'run-log-result',
|
|
92
92
|
'pause',
|
|
93
93
|
'steer',
|
|
94
|
-
'follow-up'
|
|
94
|
+
'follow-up',
|
|
95
|
+
'model-round-ask',
|
|
96
|
+
'model-round-chunk',
|
|
97
|
+
'model-round-retake',
|
|
98
|
+
'model-round-result',
|
|
99
|
+
'round-cut'
|
|
95
100
|
],
|
|
96
101
|
strings: true
|
|
97
102
|
});
|
|
@@ -171,7 +176,11 @@ export function registerHarnessTypes(ns) {
|
|
|
171
176
|
'goal',
|
|
172
177
|
'fold',
|
|
173
178
|
'input-rejected',
|
|
174
|
-
'context'
|
|
179
|
+
'context',
|
|
180
|
+
'model-round-ask',
|
|
181
|
+
'model-round-cancel',
|
|
182
|
+
'model-round-retake',
|
|
183
|
+
'model-round-result'
|
|
175
184
|
],
|
|
176
185
|
strings: true
|
|
177
186
|
});
|