@qvac/harness 0.4.0 → 0.6.0
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 +740 -141
- package/README.md +75 -7
- package/dist/harness.bundle +72 -50
- package/dist-lib/index.d.ts +49 -39
- package/dist-lib/index.js +448 -161
- package/dist-lib/lib/audio-transcode-bare.d.ts +2 -2
- package/dist-lib/lib/audio-transcode-bare.js +28 -18
- package/dist-lib/lib/audio-transcode-node.d.ts +2 -2
- package/dist-lib/lib/capabilities/audio-resample.d.ts +7 -6
- package/dist-lib/lib/capabilities/audio-resample.js +30 -18
- package/dist-lib/lib/capabilities/completion.d.ts +20 -19
- package/dist-lib/lib/capabilities/completion.js +193 -132
- package/dist-lib/lib/capabilities/download.d.ts +6 -6
- package/dist-lib/lib/capabilities/download.js +15 -8
- package/dist-lib/lib/capabilities/embed.js +2 -1
- package/dist-lib/lib/capabilities/enhance.d.ts +6 -1
- package/dist-lib/lib/capabilities/enhance.js +7 -4
- package/dist-lib/lib/capabilities/invoke.js +7 -4
- package/dist-lib/lib/capabilities/kv-cache.js +2 -1
- package/dist-lib/lib/capabilities/preview-model-source.d.ts +9 -7
- package/dist-lib/lib/capabilities/preview-model-source.js +80 -28
- package/dist-lib/lib/capabilities/speech-text.js +5 -4
- package/dist-lib/lib/capabilities/tool-selection.js +10 -9
- package/dist-lib/lib/capabilities/tool-turns.js +30 -16
- package/dist-lib/lib/capabilities/usage-breakdown.js +2 -1
- package/dist-lib/lib/capabilities/voice.d.ts +5 -1
- package/dist-lib/lib/capabilities/voice.js +22 -12
- package/dist-lib/lib/connect.d.ts +13 -32
- package/dist-lib/lib/connect.js +170 -112
- package/dist-lib/lib/context-window.js +25 -21
- package/dist-lib/lib/contract-types.d.ts +35 -15
- package/dist-lib/lib/diagram-repair.d.ts +4 -4
- package/dist-lib/lib/diagram-repair.js +6 -3
- package/dist-lib/lib/docx/index.d.ts +3 -2
- package/dist-lib/lib/{error-fields.d.ts → guards.d.ts} +1 -0
- package/dist-lib/lib/{error-fields.js → guards.js} +3 -0
- package/dist-lib/lib/hardware/capability-probe.js +20 -10
- package/dist-lib/lib/hardware/gpu-classify.js +6 -3
- package/dist-lib/lib/hardware/gpu-probe-addon.js +8 -4
- package/dist-lib/lib/hardware/gpu-probe.js +4 -2
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +8 -9
- package/dist-lib/lib/hardware/parsers.js +8 -4
- package/dist-lib/lib/helpers/buffer-burst.js +4 -2
- package/dist-lib/lib/helpers/control-tokens.js +4 -2
- package/dist-lib/lib/helpers/join-guard.d.ts +2 -2
- package/dist-lib/lib/helpers/join-guard.js +4 -2
- package/dist-lib/lib/helpers/load-stall.js +4 -2
- package/dist-lib/lib/helpers/markup-stream-filter.d.ts +2 -2
- package/dist-lib/lib/helpers/markup-stream-filter.js +6 -3
- package/dist-lib/lib/helpers/race-abort.js +2 -1
- package/dist-lib/lib/helpers/race-timeout.d.ts +5 -0
- package/dist-lib/lib/helpers/race-timeout.js +14 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +6 -8
- package/dist-lib/lib/helpers/run-outcome.js +36 -20
- package/dist-lib/lib/helpers/spawn-path.js +6 -3
- package/dist-lib/lib/helpers/text-coalescer.js +6 -3
- package/dist-lib/lib/helpers/thinking.js +38 -45
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +9 -7
- package/dist-lib/lib/helpers/tool-call-markup.js +36 -20
- package/dist-lib/lib/helpers/tool-intent.d.ts +3 -2
- package/dist-lib/lib/helpers/tool-intent.js +4 -2
- package/dist-lib/lib/helpers/tool-label.js +18 -9
- package/dist-lib/lib/hooks/built-in/arg-repair.js +23 -13
- package/dist-lib/lib/hooks/built-in/egress.js +2 -1
- package/dist-lib/lib/hooks/built-in/skill-catalog.js +2 -1
- package/dist-lib/lib/hooks/pipeline.d.ts +5 -4
- package/dist-lib/lib/hooks/pipeline.js +6 -3
- package/dist-lib/lib/hooks/run.js +12 -8
- package/dist-lib/lib/model-download-progress.js +10 -8
- package/dist-lib/lib/models/context.d.ts +1 -1
- package/dist-lib/lib/models/context.js +5 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +10 -1
- package/dist-lib/lib/models/custom-model-cache.js +43 -15
- package/dist-lib/lib/models/gguf-header.d.ts +3 -2
- package/dist-lib/lib/models/gguf-header.js +44 -22
- package/dist-lib/lib/models/idle-unload.d.ts +14 -0
- package/dist-lib/lib/models/idle-unload.js +51 -0
- package/dist-lib/lib/models/kv-cache.d.ts +3 -2
- package/dist-lib/lib/models/kv-cache.js +4 -3
- package/dist-lib/lib/models/llm-presets.d.ts +2 -2
- package/dist-lib/lib/models/llm-presets.js +4 -2
- package/dist-lib/lib/models/model-catalog-constants.js +3 -2
- package/dist-lib/lib/models/model-catalog.d.ts +15 -20
- package/dist-lib/lib/models/model-catalog.js +66 -31
- package/dist-lib/lib/models/model-delete.js +18 -8
- package/dist-lib/lib/models/model-handle.js +2 -1
- package/dist-lib/lib/models/model-list.d.ts +8 -3
- package/dist-lib/lib/models/model-list.js +11 -6
- package/dist-lib/lib/models/model-pool.d.ts +48 -10
- package/dist-lib/lib/models/model-pool.js +106 -45
- package/dist-lib/lib/models/model-source.js +10 -5
- package/dist-lib/lib/models/music-catalog.d.ts +2 -2
- package/dist-lib/lib/models/nmt-catalog.d.ts +4 -3
- package/dist-lib/lib/models/nmt-catalog.js +10 -5
- package/dist-lib/lib/models/opencl-cache.d.ts +6 -1
- package/dist-lib/lib/models/opencl-cache.js +5 -3
- package/dist-lib/lib/models/sdk-faults.d.ts +11 -8
- package/dist-lib/lib/models/sdk-faults.js +9 -6
- package/dist-lib/lib/models/shards.d.ts +11 -0
- package/dist-lib/lib/models/shards.js +15 -0
- package/dist-lib/lib/models/tool-dialect.js +10 -5
- package/dist-lib/lib/no-redirect-fetch-bare.d.ts +3 -3
- package/dist-lib/lib/no-redirect-fetch-bare.js +1 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +6 -3
- package/dist-lib/lib/no-redirect-fetch-node.d.ts +1 -1
- package/dist-lib/lib/no-redirect-fetch-node.js +9 -9
- package/dist-lib/lib/office/index.d.ts +3 -2
- package/dist-lib/lib/office/python.d.ts +3 -2
- package/dist-lib/lib/office/python.js +2 -1
- package/dist-lib/lib/prompt.d.ts +5 -4
- package/dist-lib/lib/prompt.js +8 -4
- package/dist-lib/lib/queue.js +10 -5
- package/dist-lib/lib/resolution-detector.js +21 -11
- package/dist-lib/lib/rpc-session.js +2 -1
- package/dist-lib/lib/sdk-loader.js +2 -1
- package/dist-lib/lib/sdk-storage.js +4 -2
- package/dist-lib/lib/serve.js +122 -66
- package/dist-lib/lib/spawn.js +7 -4
- package/dist-lib/lib/tmp-path.d.ts +7 -6
- package/dist-lib/lib/tool-call-display.d.ts +2 -2
- package/dist-lib/lib/tools/create-documents.js +18 -10
- package/dist-lib/lib/tools/edit-documents.js +23 -13
- package/dist-lib/lib/tools/edit-image.d.ts +2 -2
- package/dist-lib/lib/tools/edit-image.js +60 -36
- package/dist-lib/lib/tools/exec/adapters/adapter.d.ts +10 -10
- package/dist-lib/lib/tools/exec/adapters/python/attachments.d.ts +17 -11
- package/dist-lib/lib/tools/exec/adapters/python/attachments.js +53 -40
- package/dist-lib/lib/tools/exec/adapters/python/create-effect.d.ts +2 -2
- package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +60 -32
- package/dist-lib/lib/tools/exec/adapters/python/guarded-fetch.d.ts +33 -22
- package/dist-lib/lib/tools/exec/adapters/python/guarded-fetch.js +58 -29
- package/dist-lib/lib/tools/exec/adapters/python/interrupt-timer.d.ts +2 -2
- package/dist-lib/lib/tools/exec/adapters/python/loader.js +23 -12
- package/dist-lib/lib/tools/exec/adapters/python/memfs.d.ts +13 -11
- package/dist-lib/lib/tools/exec/adapters/python/memfs.js +10 -5
- package/dist-lib/lib/tools/exec/adapters/python/net-shim.js +3 -1
- package/dist-lib/lib/tools/exec/adapters/python/output-policy.d.ts +6 -4
- package/dist-lib/lib/tools/exec/adapters/python/output-policy.js +20 -10
- package/dist-lib/lib/tools/exec/adapters/python/pyodide.d.ts +2 -2
- package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +14 -7
- package/dist-lib/lib/tools/exec/adapters/python/python-adapter.d.ts +41 -34
- package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +316 -166
- package/dist-lib/lib/tools/exec/adapters/python/run-session.d.ts +9 -8
- package/dist-lib/lib/tools/exec/adapters/python/run-session.js +56 -28
- package/dist-lib/lib/tools/exec/adapters/python/wheels.d.ts +8 -10
- package/dist-lib/lib/tools/exec/adapters/python/wheels.js +22 -11
- package/dist-lib/lib/tools/exec/adapters/python/worker/client.d.ts +3 -2
- package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +41 -26
- package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +27 -18
- package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.d.ts +2 -2
- package/dist-lib/lib/tools/exec/adapters/python/worker/protocol.js +14 -13
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.d.ts +4 -4
- package/dist-lib/lib/tools/exec/adapters/python/worker/spawn-node.js +10 -5
- package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.d.ts +4 -4
- package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +2 -1
- package/dist-lib/lib/tools/exec/obsidian/cli-process.d.ts +6 -1
- package/dist-lib/lib/tools/exec/obsidian/cli-process.js +8 -5
- package/dist-lib/lib/tools/exec/obsidian/cli.d.ts +6 -6
- package/dist-lib/lib/tools/exec/obsidian/cli.js +4 -4
- package/dist-lib/lib/tools/exec/obsidian/command.d.ts +3 -2
- package/dist-lib/lib/tools/exec/obsidian/command.js +6 -3
- package/dist-lib/lib/tools/exec/obsidian/output.js +2 -1
- package/dist-lib/lib/tools/exec/obsidian/route.d.ts +4 -6
- package/dist-lib/lib/tools/exec/obsidian/route.js +17 -11
- package/dist-lib/lib/tools/exec/obsidian/safe-path.js +2 -1
- package/dist-lib/lib/tools/exec/obsidian/vault-create.js +15 -7
- package/dist-lib/lib/tools/exec/obsidian/vault-paths.d.ts +2 -2
- package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +20 -10
- package/dist-lib/lib/tools/exec/obsidian/vault-read.js +20 -13
- package/dist-lib/lib/tools/exec/obsidian/vault-write.js +24 -12
- package/dist-lib/lib/tools/exec/runner.d.ts +14 -14
- package/dist-lib/lib/tools/exec/runner.js +5 -3
- package/dist-lib/lib/tools/exec/scope.js +52 -28
- package/dist-lib/lib/tools/exec/shell-argv.js +31 -18
- package/dist-lib/lib/tools/exec/shell-guidance.d.ts +6 -1
- package/dist-lib/lib/tools/exec/shell-guidance.js +35 -20
- package/dist-lib/lib/tools/exec/video-tools.js +2 -2
- package/dist-lib/lib/tools/exec.d.ts +6 -8
- package/dist-lib/lib/tools/exec.js +113 -54
- package/dist-lib/lib/tools/file-glob.d.ts +4 -5
- package/dist-lib/lib/tools/file-glob.js +16 -11
- package/dist-lib/lib/tools/fs/glob.js +13 -18
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +10 -10
- package/dist-lib/lib/tools/fs/remote.d.ts +3 -2
- package/dist-lib/lib/tools/fs/remote.js +13 -7
- package/dist-lib/lib/tools/fs/scope.d.ts +8 -3
- package/dist-lib/lib/tools/fs/scope.js +20 -12
- package/dist-lib/lib/tools/fs/walk.js +6 -3
- package/dist-lib/lib/tools/fs/write.d.ts +3 -2
- package/dist-lib/lib/tools/generate-image.d.ts +11 -9
- package/dist-lib/lib/tools/generate-image.js +73 -37
- package/dist-lib/lib/tools/generate-music.d.ts +22 -11
- package/dist-lib/lib/tools/generate-music.js +79 -48
- package/dist-lib/lib/tools/grep.js +66 -41
- package/dist-lib/lib/tools/http-request/encode-fields.js +18 -9
- package/dist-lib/lib/tools/http-request/{utils.js → request.js} +20 -11
- package/dist-lib/lib/tools/http-request/truncate-response.js +57 -46
- package/dist-lib/lib/tools/http-request.d.ts +1 -1
- package/dist-lib/lib/tools/http-request.js +33 -18
- package/dist-lib/lib/tools/mcp/protocol.d.ts +53 -0
- package/dist-lib/lib/tools/mcp/{utils.js → protocol.js} +45 -23
- package/dist-lib/lib/tools/mcp-call.d.ts +1 -1
- package/dist-lib/lib/tools/mcp-call.js +37 -16
- package/dist-lib/lib/tools/operations/builders.js +10 -6
- package/dist-lib/lib/tools/operations/compile.js +20 -10
- package/dist-lib/lib/tools/operations/decoders.js +12 -6
- package/dist-lib/lib/tools/operations/gmail-message.js +3 -2
- package/dist-lib/lib/tools/outbound-guard.d.ts +4 -3
- package/dist-lib/lib/tools/outbound-guard.js +14 -8
- package/dist-lib/lib/tools/private-ip.js +8 -7
- package/dist-lib/lib/tools/rag-search.js +14 -7
- package/dist-lib/lib/tools/read-files.js +23 -20
- package/dist-lib/lib/tools/skill.js +19 -10
- package/dist-lib/lib/tools/skills/auth-resolver.d.ts +11 -18
- package/dist-lib/lib/tools/skills/auth-resolver.js +30 -18
- package/dist-lib/lib/tools/skills/bin-check.d.ts +3 -2
- package/dist-lib/lib/tools/skills/bin-check.js +10 -3
- package/dist-lib/lib/tools/skills/bundled-dir.js +20 -10
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +3 -2
- package/dist-lib/lib/tools/skills/bundled-hash.js +6 -1
- package/dist-lib/lib/tools/skills/catalog.d.ts +3 -2
- package/dist-lib/lib/tools/skills/catalog.js +33 -28
- package/dist-lib/lib/tools/skills/cli-argv.d.ts +3 -2
- package/dist-lib/lib/tools/skills/cli-argv.js +55 -52
- package/dist-lib/lib/tools/skills/cli-schema-check.js +21 -10
- package/dist-lib/lib/tools/skills/cli-schema-load.js +28 -20
- package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +6 -6
- package/dist-lib/lib/tools/skills/cli-schema.js +2 -1
- package/dist-lib/lib/tools/skills/credential-check.d.ts +6 -3
- package/dist-lib/lib/tools/skills/credential-check.js +24 -12
- package/dist-lib/lib/tools/skills/credential-grants.js +1 -6
- package/dist-lib/lib/tools/skills/credential-health.d.ts +5 -1
- package/dist-lib/lib/tools/skills/credential-health.js +5 -3
- package/dist-lib/lib/tools/skills/frontmatter-parser.js +10 -5
- package/dist-lib/lib/tools/skills/manifest-parse.js +84 -64
- package/dist-lib/lib/tools/skills/mention.js +7 -6
- package/dist-lib/lib/tools/skills/obsidian-readiness.d.ts +2 -2
- package/dist-lib/lib/tools/skills/obsidian-readiness.js +11 -3
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +6 -4
- package/dist-lib/lib/tools/skills/overlay-crud.js +12 -6
- package/dist-lib/lib/tools/skills/overlay-dir.js +4 -2
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +3 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +8 -4
- package/dist-lib/lib/tools/skills/setup-routes.js +1 -3
- package/dist-lib/lib/tools/skills/skill-settings.js +4 -1
- package/dist-lib/lib/tools/skills/skill-state.d.ts +6 -11
- package/dist-lib/lib/tools/skills/skill-state.js +48 -29
- package/dist-lib/lib/tools/skills/tool-grants.js +6 -3
- package/dist-lib/lib/tools/toolsets.js +2 -1
- package/dist-lib/lib/tools/translate.d.ts +4 -5
- package/dist-lib/lib/tools/translate.js +31 -14
- package/dist-lib/lib/tools/url-guard.js +2 -1
- package/dist-lib/lib/tools/weather-lookup/place.js +8 -4
- package/dist-lib/lib/tools/weather-lookup/report.d.ts +7 -1
- package/dist-lib/lib/tools/weather-lookup/report.js +46 -9
- package/dist-lib/lib/tools/weather-lookup.js +18 -12
- package/dist-lib/lib/tools/web-fetch.js +47 -24
- package/dist-lib/lib/tools/web-search.js +8 -3
- package/dist-lib/lib/validating-lookup.d.ts +4 -4
- package/dist-lib/lib/wav-encode.d.ts +1 -1
- package/dist-lib/lib/wav-encode.js +11 -10
- package/dist-lib/lib/web-fetch/embedded-state.js +24 -12
- package/dist-lib/lib/web-fetch/extract.js +4 -2
- package/dist-lib/lib/web-fetch/images.js +8 -4
- package/dist-lib/lib/web-fetch/video.d.ts +2 -2
- package/dist-lib/lib/web-fetch/video.js +8 -4
- package/dist-lib/lib/web-search/engine-registry.d.ts +2 -2
- package/dist-lib/lib/web-search/engines/aol.js +1 -1
- package/dist-lib/lib/web-search/engines/bing.js +1 -1
- package/dist-lib/lib/web-search/engines/brave.js +4 -1
- package/dist-lib/lib/web-search/engines/duckduckgo.js +3 -2
- package/dist-lib/lib/web-search/engines/google.js +7 -3
- package/dist-lib/lib/web-search/engines/wikipedia.js +5 -4
- package/dist-lib/lib/web-search/engines/yahoo.js +1 -1
- package/dist-lib/lib/web-search/fetch-html.d.ts +5 -4
- package/dist-lib/lib/web-search/fetch-html.js +13 -7
- package/dist-lib/lib/web-search/orchestrator.d.ts +9 -5
- package/dist-lib/lib/web-search/orchestrator.js +3 -3
- package/dist-lib/lib/wire.d.ts +3 -2
- package/dist-lib/lib/wire.js +23 -15
- package/dist-lib/schema/baseline.js +10 -5
- package/dist-lib/schema/build.js +2 -1
- package/dist-lib/schema/harness.d.ts +15 -2
- package/dist-lib/schema/harness.js +39 -2
- package/dist-lib/schema/release-tags.d.ts +3 -2
- package/dist-lib/schema/release-tags.js +6 -3
- package/dist-lib/spec/bind.js +9 -0
- package/dist-lib/spec/calls.js +3 -0
- package/dist-lib/spec/hrpc/hrpc.json +39 -0
- package/dist-lib/spec/hrpc/index.js +39 -3
- package/dist-lib/spec/hrpc/messages.js +105 -8
- package/dist-lib/spec/hyperschema/index.js +105 -8
- package/dist-lib/spec/hyperschema/schema.json +77 -1
- package/dist-lib/spec/hyperschema/types.d.ts +25 -1
- package/package.json +14 -14
- package/worker/harness-sidecar.mjs +15 -22
- package/worker/stow-entry.mjs +7 -4
- package/dist-lib/lib/tools/mcp/utils.d.ts +0 -47
- /package/dist-lib/lib/tools/http-request/{utils.d.ts → request.d.ts} +0 -0
|
@@ -48,8 +48,9 @@ export function runNoRedirectFetch(request, url, init = {}) {
|
|
|
48
48
|
if (init.maxBytes !== undefined && received > init.maxBytes) {
|
|
49
49
|
if (init.truncate) {
|
|
50
50
|
const allowed = chunk.byteLength - (received - init.maxBytes);
|
|
51
|
-
if (allowed > 0)
|
|
51
|
+
if (allowed > 0) {
|
|
52
52
|
chunks.push(chunk.subarray(0, allowed));
|
|
53
|
+
}
|
|
53
54
|
respond();
|
|
54
55
|
req.destroy();
|
|
55
56
|
return;
|
|
@@ -72,12 +73,14 @@ export function runNoRedirectFetch(request, url, init = {}) {
|
|
|
72
73
|
req.destroy(err);
|
|
73
74
|
reject(err);
|
|
74
75
|
};
|
|
75
|
-
if (init.signal.aborted)
|
|
76
|
+
if (init.signal.aborted) {
|
|
76
77
|
return abort();
|
|
78
|
+
}
|
|
77
79
|
init.signal.addEventListener('abort', abort);
|
|
78
80
|
}
|
|
79
|
-
if (init.body !== undefined)
|
|
81
|
+
if (init.body !== undefined) {
|
|
80
82
|
req.write(init.body);
|
|
83
|
+
}
|
|
81
84
|
req.end();
|
|
82
85
|
});
|
|
83
86
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as http from 'node:http';
|
|
2
2
|
import { type NoRedirectFetchInit, type NoRedirectFetchResponse } from './no-redirect-fetch-impl.ts';
|
|
3
|
-
export
|
|
3
|
+
export declare function noRedirectFetch(url: URL, init?: NoRedirectFetchInit): Promise<NoRedirectFetchResponse>;
|
|
4
4
|
export declare function createLookup(validatedAddresses: readonly string[] | undefined): NonNullable<http.RequestOptions['lookup']>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as dns from 'node:dns';
|
|
2
2
|
import * as http from 'node:http';
|
|
3
3
|
import * as https from 'node:https';
|
|
4
|
+
import { isRecord } from './guards.js';
|
|
4
5
|
import { isPrivateOrBlocked } from './tools/private-ip.js';
|
|
5
6
|
import { runNoRedirectFetch } from './no-redirect-fetch-impl.js';
|
|
6
|
-
export
|
|
7
|
+
export function noRedirectFetch(url, init = {}) {
|
|
7
8
|
const request = (target, options, onresponse) => {
|
|
8
9
|
const common = {
|
|
9
10
|
method: options.method,
|
|
@@ -17,22 +18,21 @@ export default function noRedirectFetch(url, init = {}) {
|
|
|
17
18
|
}
|
|
18
19
|
export function createLookup(validatedAddresses) {
|
|
19
20
|
return (hostname, options, callback) => {
|
|
20
|
-
const wantsAll =
|
|
21
|
-
const cb = callback;
|
|
21
|
+
const wantsAll = isRecord(options) && options.all === true;
|
|
22
22
|
const fail = () => {
|
|
23
|
-
|
|
23
|
+
callback(new Error(`Requests to "${hostname}" resolve to a blocked address.`), '', 0);
|
|
24
24
|
};
|
|
25
25
|
const respond = (records) => {
|
|
26
|
-
|
|
26
|
+
const [first] = records;
|
|
27
|
+
if (!first || records.some((record) => isPrivateOrBlocked(record.address))) {
|
|
27
28
|
fail();
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
if (wantsAll) {
|
|
31
|
-
|
|
32
|
+
callback(null, records);
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
cb(null, first.address, first.family);
|
|
35
|
+
callback(null, first.address, first.family);
|
|
36
36
|
};
|
|
37
37
|
if (validatedAddresses !== undefined) {
|
|
38
38
|
respond(validatedAddresses.map((address) => ({
|
|
@@ -43,7 +43,7 @@ export function createLookup(validatedAddresses) {
|
|
|
43
43
|
}
|
|
44
44
|
dns.lookup(hostname, { all: true }, (err, records) => {
|
|
45
45
|
if (err) {
|
|
46
|
-
|
|
46
|
+
callback(err, '', 0);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
respond(records);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
2
|
export { closePythonWorker as closeOfficeWorker } from '../tools/exec/adapters/python/worker/client.ts';
|
|
3
|
-
export
|
|
3
|
+
export interface OfficeExtractOptions {
|
|
4
4
|
readonly signal?: AbortSignal | undefined;
|
|
5
5
|
readonly mimeType?: string | undefined;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare function extractOfficeText(bytes: Uint8Array, fileName: string, options?: OfficeExtractOptions): Promise<string>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
|
-
export
|
|
2
|
+
export interface PythonExtractOptions {
|
|
3
3
|
readonly format: string;
|
|
4
4
|
readonly packages: readonly string[];
|
|
5
5
|
readonly source: string;
|
|
6
6
|
readonly signal?: AbortSignal | undefined;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
export declare function extractWithPython(bytes: Uint8Array, fileName: string, { format, packages, source, signal }: PythonExtractOptions): Promise<string>;
|
|
@@ -22,8 +22,9 @@ export async function extractWithPython(bytes, fileName, { format, packages, sou
|
|
|
22
22
|
outputs: ['extracted.txt'],
|
|
23
23
|
signal
|
|
24
24
|
});
|
|
25
|
-
if (result.exitCode !== 0)
|
|
25
|
+
if (result.exitCode !== 0) {
|
|
26
26
|
throw new Error(`${fileName}: ${result.stderr.trim()}`);
|
|
27
|
+
}
|
|
27
28
|
const output = result.files?.get('extracted.txt');
|
|
28
29
|
if (!output) {
|
|
29
30
|
throw new Error(result.rejected?.[0]?.reason ?? `${format} extraction produced no text file`);
|
package/dist-lib/lib/prompt.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export interface SystemPromptParts {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function systemPromptParts({ bio, toolNames, skillsSection }: SystemPromptInput): SystemPromptParts;
|
|
18
18
|
export declare function buildSystemPrompt(input: SystemPromptInput): string;
|
|
19
|
-
export
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
}
|
|
19
|
+
export interface PromptSkill {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly description: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function skillsPromptSection(activeSkills: ReadonlyArray<PromptSkill>): string | null;
|
package/dist-lib/lib/prompt.js
CHANGED
|
@@ -34,8 +34,9 @@ export function annotateLastUserTime(turns, now) {
|
|
|
34
34
|
const result = [...turns];
|
|
35
35
|
for (let i = result.length - 1; i >= 0; i--) {
|
|
36
36
|
const turn = result[i];
|
|
37
|
-
if (!turn || turn.role !== 'user')
|
|
37
|
+
if (!turn || turn.role !== 'user') {
|
|
38
38
|
continue;
|
|
39
|
+
}
|
|
39
40
|
result[i] = { ...turn, content: `${currentTimeAnnotation(now)}\n\n${turn.content}` };
|
|
40
41
|
break;
|
|
41
42
|
}
|
|
@@ -43,12 +44,15 @@ export function annotateLastUserTime(turns, now) {
|
|
|
43
44
|
}
|
|
44
45
|
function buildGuidelines(active) {
|
|
45
46
|
const lines = [...BASE_GUIDELINES];
|
|
46
|
-
if (active.size > 0)
|
|
47
|
+
if (active.size > 0) {
|
|
47
48
|
lines.push(...TOOL_GUIDELINES);
|
|
48
|
-
|
|
49
|
+
}
|
|
50
|
+
if (active.has('exec')) {
|
|
49
51
|
lines.push(EXEC_FILE_GUIDELINE, EXEC_ATTACHED_IMAGE_GUIDELINE);
|
|
50
|
-
|
|
52
|
+
}
|
|
53
|
+
if (active.has('skill')) {
|
|
51
54
|
lines.push(...SKILL_GUIDELINES);
|
|
55
|
+
}
|
|
52
56
|
if (active.has('web_search') || active.has('web_fetch')) {
|
|
53
57
|
lines.push(CITATION_GUIDELINE);
|
|
54
58
|
}
|
package/dist-lib/lib/queue.js
CHANGED
|
@@ -16,12 +16,14 @@ export function pushQueue({ highWaterMark = 0 } = {}) {
|
|
|
16
16
|
return items.length;
|
|
17
17
|
},
|
|
18
18
|
push(item) {
|
|
19
|
-
if (ended)
|
|
19
|
+
if (ended) {
|
|
20
20
|
return Promise.resolve();
|
|
21
|
+
}
|
|
21
22
|
items.push(item);
|
|
22
23
|
wakeConsumer();
|
|
23
|
-
if (highWaterMark <= 0 || items.length < highWaterMark)
|
|
24
|
+
if (highWaterMark <= 0 || items.length < highWaterMark) {
|
|
24
25
|
return Promise.resolve();
|
|
26
|
+
}
|
|
25
27
|
drain ??= Promise.withResolvers();
|
|
26
28
|
return drain.promise;
|
|
27
29
|
},
|
|
@@ -33,13 +35,16 @@ export function pushQueue({ highWaterMark = 0 } = {}) {
|
|
|
33
35
|
async *[Symbol.asyncIterator]() {
|
|
34
36
|
while (true) {
|
|
35
37
|
while (items.length) {
|
|
36
|
-
const item = items
|
|
37
|
-
|
|
38
|
+
const item = items[0];
|
|
39
|
+
items.shift();
|
|
40
|
+
if (highWaterMark > 0 && items.length < highWaterMark) {
|
|
38
41
|
wakeProducer();
|
|
42
|
+
}
|
|
39
43
|
yield item;
|
|
40
44
|
}
|
|
41
|
-
if (ended)
|
|
45
|
+
if (ended) {
|
|
42
46
|
return;
|
|
47
|
+
}
|
|
43
48
|
wake = Promise.withResolvers();
|
|
44
49
|
await wake.promise;
|
|
45
50
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorMessage, isRecord } from './guards.js';
|
|
1
2
|
import { hlog } from './log.js';
|
|
2
3
|
function readValue(value, key) {
|
|
3
4
|
if (value === null)
|
|
@@ -12,29 +13,34 @@ function readString(value, key) {
|
|
|
12
13
|
}
|
|
13
14
|
function readCandidates(err) {
|
|
14
15
|
const found = readValue(err, 'candidates');
|
|
15
|
-
if (!Array.isArray(found))
|
|
16
|
+
if (!Array.isArray(found)) {
|
|
16
17
|
return undefined;
|
|
18
|
+
}
|
|
17
19
|
return found.map((candidate) => readString(candidate, 'href') ?? String(candidate));
|
|
18
20
|
}
|
|
19
21
|
export function resolutionDetail(err) {
|
|
20
22
|
const detail = {};
|
|
21
23
|
const code = readString(err, 'code');
|
|
22
|
-
if (code !== null)
|
|
24
|
+
if (code !== null) {
|
|
23
25
|
detail.code = code;
|
|
26
|
+
}
|
|
24
27
|
const specifier = readString(err, 'specifier');
|
|
25
|
-
if (specifier !== null)
|
|
28
|
+
if (specifier !== null) {
|
|
26
29
|
detail.specifier = specifier;
|
|
30
|
+
}
|
|
27
31
|
const referrer = readString(readValue(err, 'referrer'), 'href');
|
|
28
|
-
if (referrer !== null)
|
|
32
|
+
if (referrer !== null) {
|
|
29
33
|
detail.referrer = referrer;
|
|
34
|
+
}
|
|
30
35
|
const candidates = readCandidates(err);
|
|
31
|
-
if (candidates !== undefined)
|
|
36
|
+
if (candidates !== undefined) {
|
|
32
37
|
detail.candidates = candidates;
|
|
38
|
+
}
|
|
33
39
|
return detail;
|
|
34
40
|
}
|
|
35
41
|
function readCache(meta) {
|
|
36
42
|
const cache = readValue(meta, 'cache');
|
|
37
|
-
return
|
|
43
|
+
return isRecord(cache) ? cache : null;
|
|
38
44
|
}
|
|
39
45
|
export function isReferrerLost(referrer, parent, cache) {
|
|
40
46
|
if (referrer !== null && referrer !== undefined)
|
|
@@ -48,23 +54,27 @@ export function resolutionFailure(specifier, parent, err) {
|
|
|
48
54
|
specifier,
|
|
49
55
|
parent,
|
|
50
56
|
...resolutionDetail(err),
|
|
51
|
-
err:
|
|
57
|
+
err: errorMessage(err)
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
60
|
let uninstall = null;
|
|
55
61
|
export function installResolutionDetector(meta) {
|
|
56
62
|
const cacheRecord = readCache(meta);
|
|
57
|
-
if (cacheRecord === null)
|
|
63
|
+
if (cacheRecord === null) {
|
|
58
64
|
return noop;
|
|
59
|
-
|
|
65
|
+
}
|
|
66
|
+
if (uninstall !== null) {
|
|
60
67
|
return noop;
|
|
68
|
+
}
|
|
61
69
|
const self = Reflect.get(cacheRecord, meta.url);
|
|
62
70
|
const Module = readValue(self, 'constructor');
|
|
63
|
-
if (typeof Module !== 'function')
|
|
71
|
+
if (typeof Module !== 'function') {
|
|
64
72
|
return noop;
|
|
73
|
+
}
|
|
65
74
|
const resolve = readValue(Module, 'resolve');
|
|
66
|
-
if (typeof resolve !== 'function')
|
|
75
|
+
if (typeof resolve !== 'function') {
|
|
67
76
|
return noop;
|
|
77
|
+
}
|
|
68
78
|
const startedAt = Date.now();
|
|
69
79
|
const original = resolve.bind(Module);
|
|
70
80
|
const wrapped = (specifier, parentURL, opts = {}) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorMessage } from './guards.js';
|
|
1
2
|
import { retryMemo } from './helpers/retry-memo.js';
|
|
2
3
|
import { hlog } from './log.js';
|
|
3
4
|
const defaultImports = {
|
|
@@ -15,7 +16,7 @@ function register(registry, name, plugin) {
|
|
|
15
16
|
catch (err) {
|
|
16
17
|
hlog('plugin registration skipped', {
|
|
17
18
|
plugin: name,
|
|
18
|
-
err:
|
|
19
|
+
err: errorMessage(err)
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -14,10 +14,12 @@ export function configureSdkStorage(storage, channels = {}) {
|
|
|
14
14
|
writeFileSync(configPath, `${JSON.stringify({ cacheDirectory: storage.models }, null, 2)}\n`);
|
|
15
15
|
const openclCacheDir = join(storage.home, 'opencl-cache');
|
|
16
16
|
mkdirSync(openclCacheDir, { recursive: true });
|
|
17
|
-
if (argv)
|
|
17
|
+
if (argv) {
|
|
18
18
|
argv[0] = storage.home;
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
20
21
|
env[SDK_HOME_ENV] = storage.home;
|
|
22
|
+
}
|
|
21
23
|
env[SDK_CONFIG_PATH_ENV] = configPath;
|
|
22
24
|
env[OPENCL_CACHE_DIR_ENV] = openclCacheDir;
|
|
23
25
|
return configPath;
|