@weaveintel/core 0.2.0 → 0.3.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/dist/capabilities.d.ts +8 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +8 -0
- package/dist/capabilities.js.map +1 -1
- package/dist/conformance-probe.d.ts +54 -0
- package/dist/conformance-probe.d.ts.map +1 -0
- package/dist/conformance-probe.js +195 -0
- package/dist/conformance-probe.js.map +1 -0
- package/dist/errors.d.ts +3 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/hardened-fetch.d.ts.map +1 -1
- package/dist/hardened-fetch.js +7 -95
- package/dist/hardened-fetch.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/model-profile.d.ts +166 -0
- package/dist/model-profile.d.ts.map +1 -0
- package/dist/model-profile.js +386 -0
- package/dist/model-profile.js.map +1 -0
- package/dist/models.d.ts +35 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/net-address.d.ts +22 -0
- package/dist/net-address.d.ts.map +1 -0
- package/dist/net-address.js +134 -0
- package/dist/net-address.js.map +1 -0
- package/dist/net-guard.d.ts +66 -16
- package/dist/net-guard.d.ts.map +1 -1
- package/dist/net-guard.js +159 -111
- package/dist/net-guard.js.map +1 -1
- package/package.json +1 -1
package/dist/capabilities.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ export declare const Capabilities: {
|
|
|
27
27
|
readonly ImageEditing: CapabilityId;
|
|
28
28
|
readonly Vision: CapabilityId;
|
|
29
29
|
readonly Multimodal: CapabilityId;
|
|
30
|
+
/** Reads PDF files natively (text and page images). */
|
|
31
|
+
readonly PdfInput: CapabilityId;
|
|
32
|
+
/** Reads audio natively in a chat request (not a separate transcription endpoint). */
|
|
33
|
+
readonly AudioInput: CapabilityId;
|
|
34
|
+
/** Reads some non-PDF document files natively (which ones: the capability profile's `documentMimeTypes`). */
|
|
35
|
+
readonly DocumentInput: CapabilityId;
|
|
36
|
+
/** Embeds images (as well as text) into the same vector space. */
|
|
37
|
+
readonly ImageEmbedding: CapabilityId;
|
|
30
38
|
readonly ConnectorList: CapabilityId;
|
|
31
39
|
readonly ConnectorRead: CapabilityId;
|
|
32
40
|
readonly ConnectorSearch: CapabilityId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,0FAA0F;AAC1F,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAExE,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAErD;AAED,sCAAsC;AACtC,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,0FAA0F;AAC1F,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAExE,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAErD;AAED,sCAAsC;AACtC,eAAO,MAAM,YAAY;;;;;;;;;;;;;IAcvB,uDAAuD;;IAEvD,sFAAsF;;IAEtF,6GAA6G;;IAE7G,kEAAkE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqD1D,CAAC;AAEX,2CAA2C;AAC3C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACjD,aAAa,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC;CAC1C;AAED,yCAAyC;AACzC,wBAAgB,mBAAmB,CAAC,GAAG,GAAG,EAAE,YAAY,EAAE,GAAG,eAAe,CAQ3E"}
|
package/dist/capabilities.js
CHANGED
|
@@ -26,6 +26,14 @@ export const Capabilities = {
|
|
|
26
26
|
ImageEditing: capabilityId('model.image_editing'),
|
|
27
27
|
Vision: capabilityId('model.vision'),
|
|
28
28
|
Multimodal: capabilityId('model.multimodal'),
|
|
29
|
+
/** Reads PDF files natively (text and page images). */
|
|
30
|
+
PdfInput: capabilityId('model.input.pdf'),
|
|
31
|
+
/** Reads audio natively in a chat request (not a separate transcription endpoint). */
|
|
32
|
+
AudioInput: capabilityId('model.input.audio'),
|
|
33
|
+
/** Reads some non-PDF document files natively (which ones: the capability profile's `documentMimeTypes`). */
|
|
34
|
+
DocumentInput: capabilityId('model.input.document'),
|
|
35
|
+
/** Embeds images (as well as text) into the same vector space. */
|
|
36
|
+
ImageEmbedding: capabilityId('model.embedding.image'),
|
|
29
37
|
// Connector capabilities
|
|
30
38
|
ConnectorList: capabilityId('connector.list'),
|
|
31
39
|
ConnectorRead: capabilityId('connector.read'),
|
package/dist/capabilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,UAAU,YAAY,CAAC,EAAU;IACrC,OAAO,EAAkB,CAAC;AAC5B,CAAC;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,qBAAqB;IACrB,IAAI,EAAE,YAAY,CAAC,YAAY,CAAC;IAChC,SAA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C,UAAU,EAAE,YAAY,CAAC,mBAAmB,CAAC;IAC7C,eAAe,EAAE,YAAY,CAAC,wBAAwB,CAAC;IACvD,WAAW,EAAE,YAAY,CAAC,oBAAoB,CAAC;IAE/C,8BAA8B;IAC9B,UAAU,EAAE,YAAY,CAAC,qBAAqB,CAAC;IAC/C,YAAY,EAAE,YAAY,CAAC,uBAAuB,CAAC;IAEnD,oCAAoC;IACpC,kBAAkB,EAAE,YAAY,CAAC,gBAAgB,CAAC;IAClD,mBAAmB,EAAE,YAAY,CAAC,uBAAuB,CAAC;IAE1D,0BAA0B;IAC1B,UAAU,EAAE,YAAY,CAAC,qBAAqB,CAAC;IAE/C,2BAA2B;IAC3B,UAAU,EAAE,YAAY,CAAC,mBAAmB,CAAC;IAE7C,qBAAqB;IACrB,aAAa,EAAE,YAAY,CAAC,gBAAgB,CAAC;IAC7C,YAAY,EAAE,YAAY,CAAC,gBAAgB,CAAC;IAC5C,eAAe,EAAE,YAAY,CAAC,kBAAkB,CAAC;IACjD,eAAe,EAAE,YAAY,CAAC,kBAAkB,CAAC;CACzC,CAAC;AAeX,yCAAyC;AACzC,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAmB;IACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAA8B,CAAC;IACtD,OAAO;QACL,YAAY,EAAE,GAAG;QACjB,aAAa,CAAC,EAAgB;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weaveintel/core — Conformance probe
|
|
3
|
+
*
|
|
4
|
+
* In plain words: when an operator adds a connection ("our Azure deployment",
|
|
5
|
+
* "a vLLM server in the tenant's network"), what it can really do is not known
|
|
6
|
+
* until it is tried. This probe sends a handful of TINY requests — a one-word
|
|
7
|
+
* chat, a 32×32 red square, a one-line PDF, a JSON-schema question, one tool
|
|
8
|
+
* offer, one embedding — and writes down what worked as a measured
|
|
9
|
+
* `ModelCapabilityProfile`. Hosts run it when a connection is saved and on a
|
|
10
|
+
* schedule, and route on the result.
|
|
11
|
+
*
|
|
12
|
+
* It makes real calls through the models it is given. It never sends tenant
|
|
13
|
+
* content: every input is fixed and harmless. Tests pass deterministic stand-ins.
|
|
14
|
+
*/
|
|
15
|
+
import type { ExecutionContext } from './context.js';
|
|
16
|
+
import type { EmbeddingModel, Model } from './models.js';
|
|
17
|
+
import { type ModelCapabilityProfile, type ModelFeature, type ProbeEvidence } from './model-profile.js';
|
|
18
|
+
/** A 32×32 solid red PNG. */
|
|
19
|
+
export declare const PROBE_RED_PNG_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAJ0lEQVR42u3NsQkAAAjAsP7/tF7hIASyp6lTCQQCgUAgEAgEgi/BAjLD/C5w/SM9AAAAAElFTkSuQmCC";
|
|
20
|
+
/** The number written in the probe PDF. */
|
|
21
|
+
export declare const PROBE_PDF_CODE = "4721";
|
|
22
|
+
/** A one-page PDF that says "Probe code 4721". Built here so no fixture file is needed. */
|
|
23
|
+
export declare function buildProbePdfBase64(text?: string): string;
|
|
24
|
+
export interface ProbeAudioSample {
|
|
25
|
+
readonly base64: string;
|
|
26
|
+
readonly mimeType: string;
|
|
27
|
+
/** A word that must appear (case-insensitively) in the model's answer. */
|
|
28
|
+
readonly expectWord: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ProbeOptions {
|
|
31
|
+
/** The chat model to probe. */
|
|
32
|
+
readonly chat?: Model;
|
|
33
|
+
/** The embedding model to probe. */
|
|
34
|
+
readonly embedding?: EmbeddingModel;
|
|
35
|
+
/** Audio is probed only with a sample the host provides (the library ships no recordings). */
|
|
36
|
+
readonly audioSample?: ProbeAudioSample;
|
|
37
|
+
/** Features to skip (each costs one small call). */
|
|
38
|
+
readonly skip?: readonly ModelFeature[];
|
|
39
|
+
/** Clock, for tests. */
|
|
40
|
+
readonly now?: () => number;
|
|
41
|
+
}
|
|
42
|
+
/** The measured profile, plus whether the plain chat round trip worked at all. */
|
|
43
|
+
export interface ProbeResult {
|
|
44
|
+
readonly profile: ModelCapabilityProfile;
|
|
45
|
+
readonly chatOk: boolean;
|
|
46
|
+
readonly evidence: readonly ProbeEvidence[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Measure what a connection can do. Each check is independent: one failure
|
|
50
|
+
* never stops the rest. A refusal by the adapter (`UNSUPPORTED_CONTENT`) and a
|
|
51
|
+
* wrong answer both count as "not supported".
|
|
52
|
+
*/
|
|
53
|
+
export declare function probeModelProfile(ctx: ExecutionContext, opts: ProbeOptions): Promise<ProbeResult>;
|
|
54
|
+
//# sourceMappingURL=conformance-probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance-probe.d.ts","sourceRoot":"","sources":["../src/conformance-probe.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAA+B,MAAM,aAAa,CAAC;AACtF,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAE5B,6BAA6B;AAC7B,eAAO,MAAM,oBAAoB,qIACmG,CAAC;AAErI,2CAA2C;AAC3C,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,IAAI,SAAiC,GAAG,MAAM,CAqBjF;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IACtB,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IACpC,8FAA8F;IAC9F,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IACxC,oDAAoD;IACpD,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,wBAAwB;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;CAC7C;AAID;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAsJvG"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* @weaveintel/core — Conformance probe
|
|
4
|
+
*
|
|
5
|
+
* In plain words: when an operator adds a connection ("our Azure deployment",
|
|
6
|
+
* "a vLLM server in the tenant's network"), what it can really do is not known
|
|
7
|
+
* until it is tried. This probe sends a handful of TINY requests — a one-word
|
|
8
|
+
* chat, a 32×32 red square, a one-line PDF, a JSON-schema question, one tool
|
|
9
|
+
* offer, one embedding — and writes down what worked as a measured
|
|
10
|
+
* `ModelCapabilityProfile`. Hosts run it when a connection is saved and on a
|
|
11
|
+
* schedule, and route on the result.
|
|
12
|
+
*
|
|
13
|
+
* It makes real calls through the models it is given. It never sends tenant
|
|
14
|
+
* content: every input is fixed and harmless. Tests pass deterministic stand-ins.
|
|
15
|
+
*/
|
|
16
|
+
import { ModelFeatures, isUnsupportedContentError, } from './model-profile.js';
|
|
17
|
+
/** A 32×32 solid red PNG. */
|
|
18
|
+
export const PROBE_RED_PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAJ0lEQVR42u3NsQkAAAjAsP7/tF7hIASyp6lTCQQCgUAgEAgEgi/BAjLD/C5w/SM9AAAAAElFTkSuQmCC';
|
|
19
|
+
/** The number written in the probe PDF. */
|
|
20
|
+
export const PROBE_PDF_CODE = '4721';
|
|
21
|
+
/** A one-page PDF that says "Probe code 4721". Built here so no fixture file is needed. */
|
|
22
|
+
export function buildProbePdfBase64(text = `Probe code ${PROBE_PDF_CODE}`) {
|
|
23
|
+
const escaped = text.replace(/\\/g, '\\\\').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
|
|
24
|
+
const stream = `BT /F1 24 Tf 72 720 Td (${escaped}) Tj ET`;
|
|
25
|
+
const objects = [
|
|
26
|
+
'<< /Type /Catalog /Pages 2 0 R >>',
|
|
27
|
+
'<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
|
|
28
|
+
'<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>',
|
|
29
|
+
`<< /Length ${stream.length} >>\nstream\n${stream}\nendstream`,
|
|
30
|
+
'<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>',
|
|
31
|
+
];
|
|
32
|
+
let out = '%PDF-1.4\n';
|
|
33
|
+
const offsets = [];
|
|
34
|
+
objects.forEach((body, i) => {
|
|
35
|
+
offsets.push(out.length);
|
|
36
|
+
out += `${i + 1} 0 obj\n${body}\nendobj\n`;
|
|
37
|
+
});
|
|
38
|
+
const xrefAt = out.length;
|
|
39
|
+
out += `xref\n0 ${objects.length + 1}\n0000000000 65535 f \n`;
|
|
40
|
+
for (const off of offsets)
|
|
41
|
+
out += `${String(off).padStart(10, '0')} 00000 n \n`;
|
|
42
|
+
out += `trailer\n<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xrefAt}\n%%EOF\n`;
|
|
43
|
+
return btoa(out);
|
|
44
|
+
}
|
|
45
|
+
const short = (s) => (s.length > 60 ? `${s.slice(0, 57)}...` : s);
|
|
46
|
+
/**
|
|
47
|
+
* Measure what a connection can do. Each check is independent: one failure
|
|
48
|
+
* never stops the rest. A refusal by the adapter (`UNSUPPORTED_CONTENT`) and a
|
|
49
|
+
* wrong answer both count as "not supported".
|
|
50
|
+
*/
|
|
51
|
+
export async function probeModelProfile(ctx, opts) {
|
|
52
|
+
const now = opts.now ?? Date.now;
|
|
53
|
+
const evidence = [];
|
|
54
|
+
const skip = new Set(opts.skip ?? []);
|
|
55
|
+
const results = new Map();
|
|
56
|
+
async function check(feature, label, run) {
|
|
57
|
+
if (skip.has(feature))
|
|
58
|
+
return false;
|
|
59
|
+
const started = now();
|
|
60
|
+
try {
|
|
61
|
+
const { ok, note } = await run();
|
|
62
|
+
evidence.push({ feature, ok, note: `${label}: ${note}`, latencyMs: now() - started });
|
|
63
|
+
results.set(feature, ok);
|
|
64
|
+
return ok;
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
const code = err.code ?? 'ERROR';
|
|
68
|
+
const note = isUnsupportedContentError(err) ? 'refused by the adapter' : `failed (${code})`;
|
|
69
|
+
evidence.push({ feature, ok: false, note: `${label}: ${note}`, latencyMs: now() - started });
|
|
70
|
+
results.set(feature, false);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const chat = opts.chat;
|
|
75
|
+
let chatOk = false;
|
|
76
|
+
if (chat) {
|
|
77
|
+
const ask = (request) => chat.generate(ctx, { maxTokens: 64, temperature: 0, ...request });
|
|
78
|
+
const started = now();
|
|
79
|
+
try {
|
|
80
|
+
const res = await ask({ messages: [{ role: 'user', content: 'Reply with the single word PONG.' }] });
|
|
81
|
+
chatOk = /pong/i.test(res.content);
|
|
82
|
+
evidence.push({ feature: 'chat', ok: chatOk, note: `plain chat: replied "${short(res.content)}"`, latencyMs: now() - started });
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
evidence.push({ feature: 'chat', ok: false, note: `plain chat: failed (${err.code ?? 'ERROR'})`, latencyMs: now() - started });
|
|
86
|
+
}
|
|
87
|
+
if (chatOk) {
|
|
88
|
+
await check(ModelFeatures.Vision, 'red square image', async () => {
|
|
89
|
+
const res = await ask({
|
|
90
|
+
messages: [{
|
|
91
|
+
role: 'user',
|
|
92
|
+
content: [
|
|
93
|
+
{ type: 'text', text: 'What single colour fills this image? Answer with one word.' },
|
|
94
|
+
{ type: 'image', base64: PROBE_RED_PNG_BASE64, mimeType: 'image/png' },
|
|
95
|
+
],
|
|
96
|
+
}],
|
|
97
|
+
});
|
|
98
|
+
return { ok: /red/i.test(res.content), note: `replied "${short(res.content)}"` };
|
|
99
|
+
});
|
|
100
|
+
await check(ModelFeatures.Pdf, 'one-line PDF', async () => {
|
|
101
|
+
const res = await ask({
|
|
102
|
+
messages: [{
|
|
103
|
+
role: 'user',
|
|
104
|
+
content: [
|
|
105
|
+
{ type: 'text', text: 'What number is written in this document? Answer with the number only.' },
|
|
106
|
+
{ type: 'file', base64: buildProbePdfBase64(), mimeType: 'application/pdf', filename: 'probe.pdf' },
|
|
107
|
+
],
|
|
108
|
+
}],
|
|
109
|
+
});
|
|
110
|
+
return { ok: res.content.includes(PROBE_PDF_CODE), note: `replied "${short(res.content)}"` };
|
|
111
|
+
});
|
|
112
|
+
await check(ModelFeatures.StructuredOutput, 'JSON schema answer', async () => {
|
|
113
|
+
const res = await ask({
|
|
114
|
+
messages: [{ role: 'user', content: 'What is 2 + 3? Answer in the requested JSON format.' }],
|
|
115
|
+
responseFormat: {
|
|
116
|
+
type: 'json_schema',
|
|
117
|
+
name: 'probe_answer',
|
|
118
|
+
strict: true,
|
|
119
|
+
schema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: { answer: { type: 'integer' } },
|
|
122
|
+
required: ['answer'],
|
|
123
|
+
additionalProperties: false,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
let parsed;
|
|
128
|
+
try {
|
|
129
|
+
parsed = JSON.parse(res.content);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return { ok: false, note: 'the answer was not JSON' };
|
|
133
|
+
}
|
|
134
|
+
const ok = typeof parsed === 'object' && parsed !== null && parsed.answer === 5;
|
|
135
|
+
return { ok, note: ok ? 'valid JSON with the right answer' : 'JSON without the right answer' };
|
|
136
|
+
});
|
|
137
|
+
await check(ModelFeatures.ToolUse, 'one tool offer', async () => {
|
|
138
|
+
const res = await ask({
|
|
139
|
+
messages: [{ role: 'user', content: 'Call the probe_value tool.' }],
|
|
140
|
+
tools: [{ name: 'probe_value', description: 'Returns a fixed probe value.', parameters: { type: 'object', properties: {} } }],
|
|
141
|
+
toolChoice: { name: 'probe_value' },
|
|
142
|
+
});
|
|
143
|
+
const ok = (res.toolCalls ?? []).some((c) => c.name === 'probe_value');
|
|
144
|
+
return { ok, note: ok ? 'called the tool' : 'did not call the tool' };
|
|
145
|
+
});
|
|
146
|
+
const sample = opts.audioSample;
|
|
147
|
+
if (sample) {
|
|
148
|
+
await check(ModelFeatures.AudioIn, 'host audio sample', async () => {
|
|
149
|
+
const res = await ask({
|
|
150
|
+
messages: [{
|
|
151
|
+
role: 'user',
|
|
152
|
+
content: [
|
|
153
|
+
{ type: 'text', text: 'Transcribe this audio.' },
|
|
154
|
+
{ type: 'audio', base64: sample.base64, mimeType: sample.mimeType },
|
|
155
|
+
],
|
|
156
|
+
}],
|
|
157
|
+
});
|
|
158
|
+
const ok = res.content.toLowerCase().includes(sample.expectWord.toLowerCase());
|
|
159
|
+
return { ok, note: ok ? 'the expected word was heard' : 'the expected word was not heard' };
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let embedding;
|
|
165
|
+
const embedder = opts.embedding;
|
|
166
|
+
if (embedder && !skip.has(ModelFeatures.Embedding)) {
|
|
167
|
+
const started = now();
|
|
168
|
+
try {
|
|
169
|
+
const res = await embedder.embed(ctx, { input: ['probe'] });
|
|
170
|
+
const dims = res.embeddings[0]?.length ?? 0;
|
|
171
|
+
const ok = dims > 0 && res.embeddings[0].every((n) => Number.isFinite(n));
|
|
172
|
+
evidence.push({ feature: ModelFeatures.Embedding, ok, note: `one embedding: ${dims} numbers`, latencyMs: now() - started });
|
|
173
|
+
if (ok)
|
|
174
|
+
embedding = { dimensions: dims, inputs: ['text'] };
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
evidence.push({ feature: ModelFeatures.Embedding, ok: false, note: `one embedding: failed (${err.code ?? 'ERROR'})`, latencyMs: now() - started });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const profile = {
|
|
181
|
+
vision: results.get(ModelFeatures.Vision) ?? false,
|
|
182
|
+
pdf: results.get(ModelFeatures.Pdf) ?? false,
|
|
183
|
+
audioIn: results.get(ModelFeatures.AudioIn) ?? false,
|
|
184
|
+
structuredOutput: results.get(ModelFeatures.StructuredOutput) ?? false,
|
|
185
|
+
toolUse: results.get(ModelFeatures.ToolUse) ?? false,
|
|
186
|
+
...(chat?.info.maxContextTokens !== undefined ? { contextTokens: chat.info.maxContextTokens } : {}),
|
|
187
|
+
...(chat?.info.maxOutputTokens !== undefined ? { maxOutputTokens: chat.info.maxOutputTokens } : {}),
|
|
188
|
+
...(embedding ? { embedding } : {}),
|
|
189
|
+
source: 'measured',
|
|
190
|
+
measuredAt: new Date(now()).toISOString(),
|
|
191
|
+
evidence,
|
|
192
|
+
};
|
|
193
|
+
return { profile, chatOk, evidence };
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=conformance-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance-probe.js","sourceRoot":"","sources":["../src/conformance-probe.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B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EAAE,QAAQ,EAAE,CAAC;AACvC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Why: Normalized errors across all providers. Consumers handle WeaveIntelError,
|
|
5
5
|
* not provider-specific HTTP/SDK errors. Error codes are stable contracts.
|
|
6
6
|
*/
|
|
7
|
-
export type ErrorCode = 'CANCELLED' | 'TIMEOUT' | 'RATE_LIMITED' | 'AUTH_FAILED' | 'PERMISSION_DENIED' | 'NOT_FOUND' | 'INVALID_INPUT' | 'INVALID_CONFIG' | 'MODEL_ERROR' | 'TOOL_ERROR' | 'CONNECTOR_ERROR' | 'VECTOR_STORE_ERROR' | 'MEMORY_ERROR' | 'REDACTION_ERROR' | 'POLICY_DENIED' | 'BUDGET_EXCEEDED' | 'CIRCUIT_OPEN' | 'PROVIDER_ERROR' | 'PROTOCOL_ERROR'
|
|
7
|
+
export type ErrorCode = 'CANCELLED' | 'TIMEOUT' | 'RATE_LIMITED' | 'AUTH_FAILED' | 'PERMISSION_DENIED' | 'NOT_FOUND' | 'INVALID_INPUT' | 'INVALID_CONFIG' | 'MODEL_ERROR' | 'TOOL_ERROR' | 'CONNECTOR_ERROR' | 'VECTOR_STORE_ERROR' | 'MEMORY_ERROR' | 'REDACTION_ERROR' | 'POLICY_DENIED' | 'BUDGET_EXCEEDED' | 'CIRCUIT_OPEN' | 'PROVIDER_ERROR' | 'PROTOCOL_ERROR'
|
|
8
|
+
/** The model or connection cannot read a kind of content in the request (an image, PDF, audio, a file type). */
|
|
9
|
+
| 'UNSUPPORTED_CONTENT' | 'INTERNAL_ERROR';
|
|
8
10
|
export declare class WeaveIntelError extends Error {
|
|
9
11
|
readonly code: ErrorCode;
|
|
10
12
|
readonly provider?: string;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM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AE,KAAK,CAAC;KACf;IAWD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAWlC;AAED,+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,CAwB/E"}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAY;IAChB,QAAQ,CAAU;IAClB,SAAS,CAAU;IACnB,YAAY,CAAU;IACtB,OAAO,CAA2B;IAE3C,YAAY,IAQX;QACC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AAED,+CAA+C;AAC/C,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,QAAiB;IAC5D,IAAI,GAAG,YAAY,eAAe;QAAE,OAAO,GAAG,CAAC;IAC/C,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAC9B,OAAO,IAAI,eAAe,CAAC;gBACzB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,yBAAyB;gBAClC,QAAQ;gBACR,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,eAAe,CAAC;YACzB,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,QAAQ;YACR,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,eAAe,CAAC;QACzB,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC;QACpB,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardened-fetch.d.ts","sourceRoot":"","sources":["../src/hardened-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"hardened-fetch.d.ts","sourceRoot":"","sources":["../src/hardened-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,KAAK,iBAAiB,EAIvB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,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@@
|
|
|
20
20
|
*
|
|
21
21
|
* Depends only on `@weaveintel/core` itself (`net-guard`) + node built-ins.
|
|
22
22
|
*/
|
|
23
|
-
import
|
|
24
|
-
import { assertSafeOutboundUrl, followRedirectsSafely, validateResolvedAddress, } from './net-guard.js';
|
|
25
|
-
/**
|
|
26
|
-
* Phase 5 — TOCTOU DNS-pinning dispatcher.
|
|
27
|
-
*
|
|
28
|
-
* `assertSafeOutboundUrl` resolves DNS once at validation time. Between that
|
|
29
|
-
* resolution and the actual TCP connection, an attacker who controls DNS could
|
|
30
|
-
* rebind the hostname to a private IP — the classic SSRF bypass via DNS
|
|
31
|
-
* rebinding. This factory closes that window.
|
|
32
|
-
*
|
|
33
|
-
* It creates an undici `Agent` with a custom `connect.lookup` hook. Undici
|
|
34
|
-
* calls our hook at connection time (not earlier), so the IP we validate is
|
|
35
|
-
* exactly the IP undici connects to. A rebind between the two resolutions
|
|
36
|
-
* becomes impossible.
|
|
37
|
-
*
|
|
38
|
-
* Graceful degradation: if undici is unavailable (non-Node environments or
|
|
39
|
-
* bundlers that strip it) the function returns `undefined` and callers fall
|
|
40
|
-
* back to the pre-TOCTOU behaviour — still protected by the upfront
|
|
41
|
-
* `assertSafeOutboundUrl` check.
|
|
42
|
-
*/
|
|
43
|
-
async function createSafeDispatcher(policy) {
|
|
44
|
-
let AgentCtor;
|
|
45
|
-
try {
|
|
46
|
-
const undici = await import('undici');
|
|
47
|
-
AgentCtor = undici.Agent;
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return undefined; // undici unavailable — graceful degradation
|
|
51
|
-
}
|
|
52
|
-
// Undici's connect.lookup may ask for either a single resolved address or
|
|
53
|
-
// all candidates (`all:true`). Handle both callback shapes and validate each
|
|
54
|
-
// candidate so we never pass an undefined/unsafe address to the socket layer.
|
|
55
|
-
const lookup = (hostname, options, callback) => {
|
|
56
|
-
const wantsAll = typeof options === 'object' &&
|
|
57
|
-
options !== null &&
|
|
58
|
-
'all' in options &&
|
|
59
|
-
options.all === true;
|
|
60
|
-
if (wantsAll) {
|
|
61
|
-
dns.lookup(hostname, { all: true }, (err, addresses) => {
|
|
62
|
-
if (err) {
|
|
63
|
-
callback(err);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
for (const entry of addresses) {
|
|
68
|
-
validateResolvedAddress(entry.address, policy);
|
|
69
|
-
}
|
|
70
|
-
callback(null, addresses);
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
callback(e);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
dns.lookup(hostname, (err, address, family) => {
|
|
79
|
-
if (err) {
|
|
80
|
-
callback(err);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (!address || typeof address !== 'string') {
|
|
84
|
-
callback(new TypeError(`invalid DNS lookup result for host "${hostname}"`));
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
validateResolvedAddress(address, policy);
|
|
89
|
-
callback(null, address, family);
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
callback(e);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
const agent = new AgentCtor({ connect: { lookup } });
|
|
97
|
-
return { dispatcher: agent };
|
|
98
|
-
}
|
|
23
|
+
import { assertSafeOutboundUrl, followRedirectsSafely, pinnedFetch, } from './net-guard.js';
|
|
99
24
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
100
25
|
const DEFAULT_MAX_BYTES = 50 * 1024 * 1024; // 50 MiB
|
|
101
26
|
function wrapBodyWithSizeCap(body, maxBytes, errorTag) {
|
|
@@ -185,32 +110,19 @@ export async function hardenedFetch(input, init, opts = { errorTag: 'hardened-fe
|
|
|
185
110
|
};
|
|
186
111
|
if (enforceHttps)
|
|
187
112
|
await assertSafeOutboundUrl(input, policy);
|
|
188
|
-
// Phase 5 — attach a DNS-pinning dispatcher so the IP validated above is the
|
|
189
|
-
// same IP undici connects to, closing the TOCTOU DNS-rebinding window.
|
|
190
|
-
// Gracefully absent when undici is unavailable.
|
|
191
|
-
const safeDispatcher = enforceHttps ? await createSafeDispatcher(policy) : undefined;
|
|
192
113
|
const callerSignal = (init?.signal ?? null);
|
|
193
114
|
const signal = composeSignal(callerSignal, timeoutMs);
|
|
194
115
|
const composed = {
|
|
195
116
|
...(init ?? {}),
|
|
196
117
|
redirect: enforceHttps ? 'manual' : redirect,
|
|
197
118
|
...(signal ? { signal } : {}),
|
|
198
|
-
...(safeDispatcher ?? {}),
|
|
199
119
|
};
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
let resp0;
|
|
207
|
-
if (composed.dispatcher !== undefined) {
|
|
208
|
-
const { fetch: undiciFetch } = (await import('undici'));
|
|
209
|
-
resp0 = await undiciFetch(input, composed);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
resp0 = await fetch(input, composed);
|
|
213
|
-
}
|
|
120
|
+
// The connection is pinned to the address that was checked (net-guard `pinnedFetch`, a connect-time
|
|
121
|
+
// lookup hook on undici's own fetch: Node's global fetch is a different undici build and rejects a
|
|
122
|
+
// foreign dispatcher), closing the DNS-rebinding window — on the first request and, inside
|
|
123
|
+
// `followRedirectsSafely`, on every redirect hop. Without undici it degrades to the global fetch;
|
|
124
|
+
// the pre-check above still ran.
|
|
125
|
+
const resp0 = enforceHttps ? await pinnedFetch(input, composed, policy) : await fetch(input, composed);
|
|
214
126
|
let resp = resp0;
|
|
215
127
|
if (enforceHttps && redirect === 'error'
|
|
216
128
|
&& resp0.status >= 300 && resp0.status < 400 && resp0.status !== 304 && resp0.headers.has('location')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardened-fetch.js","sourceRoot":"","sources":["../src/hardened-fetch.ts"],"names":[],"mappings":"AAAA;;;;;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QACnE,MAAM,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE;KAC/D,CAAC,CAAC;IACH,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACrE,WAAW,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAC3B,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { type RunRegistry, type RunListFilter, type KvRunRegistryOptions, create
|
|
|
7
7
|
export { type RunJournal, type RunJournalAppendOptions, type RunJournalReadOptions, type KvRunJournalOptions, createKvRunJournal, RunCursorTooOldError, RUN_JOURNAL_DEFAULTS, } from './run-journal.js';
|
|
8
8
|
export { type ContractTestApi, runRegistryContract, runJournalContract, } from './run-substrate-contract.js';
|
|
9
9
|
export { type WeaveLogger, defaultLogger, setDefaultLogger, createLogger, } from './logger.js';
|
|
10
|
-
export { type OutboundUrlPolicy, assertSafeOutboundUrl, followRedirectsSafely, validateResolvedAddress, } from './net-guard.js';
|
|
10
|
+
export { type OutboundUrlPolicy, type OutboundLookup, assertSafeOutboundUrl, followRedirectsSafely, validateResolvedAddress, pinnedFetch, pinnedLookup, } from './net-guard.js';
|
|
11
11
|
export { type HardenedFetchOptions, type HardenedFetchDefaults, assertSafeForEgress, hardenedFetch, createHardenedFetch, } from './hardened-fetch.js';
|
|
12
12
|
export { type WeaveRuntime, type WeaveRuntimeOptions, type RuntimeEgressSlot, type RuntimePersistenceSlot, type RuntimeKvStore, type RuntimeResilienceSlot, type RuntimeGuardrailsSlot, type RuntimeEncryptionSlot, type RuntimeRoutingSlot, type RuntimeCostSlot, type RuntimeMemorySlot, type RuntimeComplianceSlot, type RuntimeIdentitySlot, type RuntimeCacheSlot, RuntimeCapabilities, weaveRuntime, assertRuntimeRequires, describeRuntimeCapabilities, weaveAudit, weaveLogSafetyDowngrade, weaveInMemoryPersistence, assertTlsFloor, createDurableAuditLogger, createRedactingAuditLogger, } from './runtime.js';
|
|
13
13
|
export { type EnvSecretResolverOptions, envSecretResolver, inMemorySecretResolver, chainSecretResolvers, requireSecret, } from './secrets.js';
|
|
@@ -18,7 +18,9 @@ export { type ErrorClass, type ClassifiedError, parseRetryAfterMs, httpStatusToE
|
|
|
18
18
|
export { type WeaveEvent, type EventHandler, type EventFilter, type EventBus, type Unsubscribe, EventTypes, createEventBus as weaveEventBus, createEvent as weaveEvent, } from './events.js';
|
|
19
19
|
export { type Middleware, Pipeline as WeavePipeline, composeMiddleware as weaveMiddleware, timeoutMiddleware as weaveTimeout, retryMiddleware as weaveRetry, } from './middleware.js';
|
|
20
20
|
export { type PluginDescriptor, type PluginType, type Plugin, type PluginRegistry, createPluginRegistry as weavePluginRegistry, } from './registry.js';
|
|
21
|
-
export { type Role, type TextContent, type ImageContent, type AudioContent, type FileContent, type ContentPart, type Message, type ToolDefinition, type ToolCall, type ToolResult, type JsonSchema, type ResponseFormat, type ModelRequest, type ModelResponse, type TokenUsage, type StreamChunk, type ModelStream, type ModelInfo, type Model, type EmbeddingRequest, type EmbeddingResponse, type EmbeddingModel, type RerankRequest, type RerankResult, type RerankResponse, type RerankerModel, type ImageGenerationRequest, type GeneratedImage, type ImageGenerationResponse, type ImageModel, type SpeechRequest, type TranscriptionRequest, type TranscriptSegment, type TranscriptionResult, type AudioModel, } from './models.js';
|
|
21
|
+
export { type Role, type TextContent, type ImageContent, type AudioContent, type FileContent, type ContentPart, type Message, type ToolDefinition, type ToolCall, type ToolResult, type JsonSchema, type ResponseFormat, type ModelRequest, type ModelResponse, type TokenUsage, type StreamChunk, type ModelStream, type ModelInfo, type Model, type EmbeddingRequest, type EmbeddingResponse, type EmbeddingModel, type EmbeddingInput, type MultimodalEmbeddingRequest, type EmbeddingVector, type MultimodalEmbeddingResponse, type MultimodalEmbeddingModel, type RerankRequest, type RerankResult, type RerankResponse, type RerankerModel, type ImageGenerationRequest, type GeneratedImage, type ImageGenerationResponse, type ImageModel, type SpeechRequest, type TranscriptionRequest, type TranscriptSegment, type TranscriptionResult, type AudioModel, } from './models.js';
|
|
22
|
+
export { ModelFeatures, documentFeature, textOnlyProfile, featureForPart, requiredFeatures, profileSupports, missingFeatures, profileFeatures, featureLabel, profileFromCapabilities, capabilitiesFromProfile, UnsupportedContentError, isUnsupportedContentError, unsupportedPart, assertProfileSupports, asMultimodalEmbeddingModel, type ModelFeature, type ModelCapabilityProfile, type ProbeEvidence, } from './model-profile.js';
|
|
23
|
+
export { probeModelProfile, buildProbePdfBase64, PROBE_RED_PNG_BASE64, PROBE_PDF_CODE, type ProbeOptions, type ProbeResult, type ProbeAudioSample, } from './conformance-probe.js';
|
|
22
24
|
export { type ToolSchema, type ToolInput, type ToolOutput, type Tool, type ToolPolicy, type PolicyDecision, type ToolRegistry, createToolRegistry as weaveToolRegistry, defineTool as weaveTool, } from './tools.js';
|
|
23
25
|
export { type Document, type DocumentChunk, type DocumentMetadata, type SourceReference, type Provenance, type AccessPolicy, } from './documents.js';
|
|
24
26
|
export { type ConnectorConfig, type ConnectorAuth, type ConnectorListOptions, type ConnectorListResult, type ConnectorListItem, type ConnectorReadOptions, type ConnectorSearchOptions, type ConnectorWatchEvent, type Connector, type ListableConnector, type ReadableConnector, type SearchableConnector, type WatchableConnector, type SyncableConnector, isListable, isReadable, isSearchable, isWatchable, isSyncable, } from './connectors.js';
|
|
@@ -63,4 +65,5 @@ export { type UiEventType, type UiEvent, type StreamEnvelope, type ProgressUpdat
|
|
|
63
65
|
export { type RunStatus, type RunOrigin, type RunHandle, type RunEventCursor, } from './runs.js';
|
|
64
66
|
export { type NotificationCategory, type NotificationMessage, type NotificationDelivery, type ChannelTarget, type NotificationChannel, } from './notifications.js';
|
|
65
67
|
export { type SurfaceCatalogRequest, type CatalogEntry, type SurfaceCatalog, type SurfaceCatalogResolver, } from './surface-catalog.js';
|
|
68
|
+
export { classifyAddress, classifyIPv4, classifyIPv6, isPublicAddress, type AddressClass } from './net-address.js';
|
|
66
69
|
//# sourceMappingURL=index.d.ts.map
|