agentfootprint 9.72.0 → 9.74.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 +160 -0
- package/dist/adapters/identity/azure.js +306 -0
- package/dist/adapters/identity/azure.js.map +1 -0
- package/dist/adapters/llm/FoundryLocalProvider.js +992 -0
- package/dist/adapters/llm/FoundryLocalProvider.js.map +1 -0
- package/dist/adapters/llm/FoundryProvider.js +273 -0
- package/dist/adapters/llm/FoundryProvider.js.map +1 -0
- package/dist/adapters/llm/OllamaProvider.js +171 -12
- package/dist/adapters/llm/OllamaProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +117 -5
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/createProvider.js +143 -10
- package/dist/adapters/llm/createProvider.js.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/esm/adapters/identity/azure.d.ts +188 -0
- package/dist/esm/adapters/identity/azure.js +302 -0
- package/dist/esm/adapters/identity/azure.js.map +1 -0
- package/dist/esm/adapters/llm/FoundryLocalProvider.d.ts +215 -0
- package/dist/esm/adapters/llm/FoundryLocalProvider.js +986 -0
- package/dist/esm/adapters/llm/FoundryLocalProvider.js.map +1 -0
- package/dist/esm/adapters/llm/FoundryProvider.d.ts +178 -0
- package/dist/esm/adapters/llm/FoundryProvider.js +268 -0
- package/dist/esm/adapters/llm/FoundryProvider.js.map +1 -0
- package/dist/esm/adapters/llm/OllamaProvider.js +171 -12
- package/dist/esm/adapters/llm/OllamaProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +111 -0
- package/dist/esm/adapters/llm/OpenAIProvider.js +115 -4
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/createProvider.d.ts +48 -12
- package/dist/esm/adapters/llm/createProvider.js +143 -10
- package/dist/esm/adapters/llm/createProvider.js.map +1 -1
- package/dist/esm/adapters/types.d.ts +4 -2
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/identity.d.ts +1 -0
- package/dist/esm/identity.js +9 -0
- package/dist/esm/identity.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers.d.ts +5 -0
- package/dist/esm/providers.js +14 -0
- package/dist/esm/providers.js.map +1 -1
- package/dist/identity.js +14 -1
- package/dist/identity.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers.js +20 -1
- package/dist/providers.js.map +1 -1
- package/dist/types/adapters/identity/azure.d.ts +189 -0
- package/dist/types/adapters/identity/azure.d.ts.map +1 -0
- package/dist/types/adapters/llm/FoundryLocalProvider.d.ts +216 -0
- package/dist/types/adapters/llm/FoundryLocalProvider.d.ts.map +1 -0
- package/dist/types/adapters/llm/FoundryProvider.d.ts +179 -0
- package/dist/types/adapters/llm/FoundryProvider.d.ts.map +1 -0
- package/dist/types/adapters/llm/OllamaProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts +111 -0
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/createProvider.d.ts +48 -12
- package/dist/types/adapters/llm/createProvider.d.ts.map +1 -1
- package/dist/types/adapters/types.d.ts +4 -2
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/identity.d.ts +1 -0
- package/dist/types/identity.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/providers.d.ts +5 -0
- package/dist/types/providers.d.ts.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoundryLocalProvider.js","sourceRoot":"","sources":["../../../src/adapters/llm/FoundryLocalProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACzC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FoundryProvider — Microsoft Foundry (Azure AI Foundry) projects over the
|
|
4
|
+
* api-version-free v1 OpenAI-compatible inference route.
|
|
5
|
+
*
|
|
6
|
+
* Pattern: Adapter (GoF) + Ports-and-Adapters (Cockburn 2005), composed —
|
|
7
|
+
* a thin vendor file over `openai()`'s machinery, the exact
|
|
8
|
+
* `azureOpenai()` shape.
|
|
9
|
+
* Role: Outer ring — owns EVERY Foundry spelling (the project-endpoint
|
|
10
|
+
* shape, the env-var names, the token audience, the `/openai/v1`
|
|
11
|
+
* derivation) so the `LLMProvider` port and the rest of the library
|
|
12
|
+
* never learn one. Knows nothing about agents, recorders, or
|
|
13
|
+
* compositions.
|
|
14
|
+
* Emits: N/A.
|
|
15
|
+
*
|
|
16
|
+
* ─── Why this exists ─────────────────────────────────────────────────
|
|
17
|
+
*
|
|
18
|
+
* This is the JS answer to Microsoft's
|
|
19
|
+
* `FoundryChatClient(project_endpoint, model, credential)`: point at a
|
|
20
|
+
* Foundry PROJECT, name a DEPLOYMENT, hand over a credential, done. The
|
|
21
|
+
* doc-verified facts it is built on (learn.microsoft.com, Aug 2026):
|
|
22
|
+
*
|
|
23
|
+
* • A Foundry project endpoint
|
|
24
|
+
* (`https://{account}.services.ai.azure.com/api/projects/{project}`)
|
|
25
|
+
* itself serves the v1 inference route by simple suffixing: `+ /openai/v1`.
|
|
26
|
+
* No `api-version` query, no deployment-scoped path.
|
|
27
|
+
* • The wire's `model` field carries the DEPLOYMENT name — Foundry's
|
|
28
|
+
* "model" is a deployment, exactly as on classic Azure OpenAI.
|
|
29
|
+
* • Auth is `Authorization: Bearer <Entra token or api key>` — the v1
|
|
30
|
+
* route accepts a key as a Bearer too.
|
|
31
|
+
*
|
|
32
|
+
* Because that route IS current OpenAI wire, this file is `openai({ baseURL,
|
|
33
|
+
* legacyEndpoint: false, … })` plus Foundry's spellings — the same
|
|
34
|
+
* composition `azureOpenai()` uses, with the modern dialect declared instead
|
|
35
|
+
* of implied away by the custom `baseURL`.
|
|
36
|
+
*
|
|
37
|
+
* ─── Auth: three doors, one refused ambiguity ────────────────────────
|
|
38
|
+
*
|
|
39
|
+
* • `credential` — any `@azure/identity` credential (duck-typed; the SDK
|
|
40
|
+
* is never imported for this door). Tokens are minted per request
|
|
41
|
+
* through `openai()`'s credential-callback seam.
|
|
42
|
+
* • `apiKey` — a static key, or a callback re-read per request.
|
|
43
|
+
* • NEITHER — `new DefaultAzureCredential()` via the optional
|
|
44
|
+
* `@azure/identity` peer: the platform's own blessed zero-config pattern
|
|
45
|
+
* inside a hosted Foundry container (the platform injects
|
|
46
|
+
* `FOUNDRY_PROJECT_ENDPOINT` and gives the agent a managed identity, so
|
|
47
|
+
* `foundry()` with no arguments is a complete configuration there).
|
|
48
|
+
* • BOTH `credential` and `apiKey` — refused by name. Two credentials is a
|
|
49
|
+
* config bug, not extra security.
|
|
50
|
+
*
|
|
51
|
+
* ─── Ceilings (stated, not worked around) ────────────────────────────
|
|
52
|
+
*
|
|
53
|
+
* • DEPLOYMENT NAMES HIDE THE MODEL. o-series auto-detection cannot work on
|
|
54
|
+
* an arbitrary deployment name, so `reasoning` must be declared — the same
|
|
55
|
+
* rationale, word for word, as `azureOpenai()`.
|
|
56
|
+
* • INFERENCE ONLY. The token audience here is the data plane
|
|
57
|
+
* ({@link AZURE_AI_SCOPE}); the ARM control plane is a different audience
|
|
58
|
+
* and a different job — see `entraIdentity()` in the identity adapters.
|
|
59
|
+
* • Everything `openai()` does not do (multi-modal, JSON-mode), this does
|
|
60
|
+
* not do either — it is the same machinery.
|
|
61
|
+
*/
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.foundry = exports.foundryInferenceUrl = void 0;
|
|
64
|
+
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
65
|
+
const OpenAIProvider_js_1 = require("./OpenAIProvider.js");
|
|
66
|
+
const azure_js_1 = require("../identity/azure.js");
|
|
67
|
+
/** Every refusal this file authors opens with this name. */
|
|
68
|
+
const ADAPTER = 'foundry';
|
|
69
|
+
/** The endpoint shape refusals point at — quoted, never guessed at. */
|
|
70
|
+
const ENDPOINT_SHAPE = 'https://{account}.services.ai.azure.com/api/projects/{project}';
|
|
71
|
+
// ─── URL derivation ─────────────────────────────────────────────────
|
|
72
|
+
/**
|
|
73
|
+
* Project endpoint → the base URL the v1 inference route serves.
|
|
74
|
+
*
|
|
75
|
+
* `https://acct.services.ai.azure.com/api/projects/proj`
|
|
76
|
+
* → `https://acct.services.ai.azure.com/api/projects/proj/openai/v1`
|
|
77
|
+
* …with trailing slashes → the same
|
|
78
|
+
* …already ending in `/openai/v1` → the same (idempotent — `azureUrl.ts`'s
|
|
79
|
+
* rule, applied to Foundry's suffix)
|
|
80
|
+
*
|
|
81
|
+
* Validation lives HERE, beside the derivation, so there is exactly ONE owner
|
|
82
|
+
* of what a Foundry endpoint looks like: it must be `https://` and it must
|
|
83
|
+
* contain `/api/projects/` — anything else is some OTHER Azure endpoint
|
|
84
|
+
* (a resource root, an ARM URL) that would 404 or 401 far from the typo.
|
|
85
|
+
* Endpoints are NOT secrets, so a malformed one is echoed back: seeing what
|
|
86
|
+
* arrived is the fastest fix. The one carve-out is cleartext to LOOPBACK
|
|
87
|
+
* (127.0.0.1 / localhost / [::1]) — that is how the wire tests drive the
|
|
88
|
+
* REAL SDK against a local fake, and refusing bytes that cannot leave the
|
|
89
|
+
* machine would buy no safety.
|
|
90
|
+
*
|
|
91
|
+
* A `?` or `#` is refused too, and for a reason particular to a SUFFIXING
|
|
92
|
+
* derivation: `…/api/projects/p?x=1` + `/openai/v1` is
|
|
93
|
+
* `…/api/projects/p?x=1/openai/v1`, where the route lives entirely inside the
|
|
94
|
+
* query string. That URL is well-formed, constructs without complaint, and
|
|
95
|
+
* 404s on every request — the exact "late and far from the typo" failure this
|
|
96
|
+
* validator exists to convert into an early named one. The v1 inference route
|
|
97
|
+
* takes no query parameters at all (that is the point of it: no
|
|
98
|
+
* `api-version`), so there is nothing legitimate to preserve.
|
|
99
|
+
*/
|
|
100
|
+
function foundryInferenceUrl(projectEndpoint) {
|
|
101
|
+
const trimmed = projectEndpoint.replace(/\/+$/, '');
|
|
102
|
+
const loopback = /^http:\/\/(127\.0\.0\.1|localhost|\[::1\])(:\d+)?\//i.test(trimmed);
|
|
103
|
+
const shapeOk = (/^https:\/\//i.test(trimmed) || loopback) && trimmed.includes('/api/projects/');
|
|
104
|
+
if (!shapeOk) {
|
|
105
|
+
throw new Error(`${ADAPTER}: \`projectEndpoint\` does not look like a Foundry project endpoint: ` +
|
|
106
|
+
`${projectEndpoint}\n` +
|
|
107
|
+
` Expected: ${ENDPOINT_SHAPE}\n` +
|
|
108
|
+
' Fix: copy the project endpoint from the Foundry portal (project Overview page), or ' +
|
|
109
|
+
'run where the platform injects FOUNDRY_PROJECT_ENDPOINT.');
|
|
110
|
+
}
|
|
111
|
+
// AFTER the shape check: an endpoint that is wrong in both ways gets the
|
|
112
|
+
// more fundamental diagnosis first.
|
|
113
|
+
const marker = trimmed.includes('?') ? '?' : trimmed.includes('#') ? '#' : undefined;
|
|
114
|
+
if (marker !== undefined) {
|
|
115
|
+
throw new Error(`${ADAPTER}: \`projectEndpoint\` carries a \`${marker}\`, and this route is built by ` +
|
|
116
|
+
`SUFFIXING the endpoint: ${projectEndpoint}\n` +
|
|
117
|
+
` Appending \`/openai/v1\` would put the entire inference path INSIDE the ` +
|
|
118
|
+
`${marker === '?' ? 'query string' : 'fragment'} — a URL that constructs fine and then ` +
|
|
119
|
+
`404s on every request, far from the typo.\n` +
|
|
120
|
+
` Expected: ${ENDPOINT_SHAPE}\n` +
|
|
121
|
+
` Fix: drop everything from the \`${marker}\` onward — the v1 route is ` +
|
|
122
|
+
'api-version-free and takes no query parameters.');
|
|
123
|
+
}
|
|
124
|
+
return trimmed.endsWith('/openai/v1') ? trimmed : `${trimmed}/openai/v1`;
|
|
125
|
+
}
|
|
126
|
+
exports.foundryInferenceUrl = foundryInferenceUrl;
|
|
127
|
+
// ─── Factory ────────────────────────────────────────────────────────
|
|
128
|
+
/**
|
|
129
|
+
* Which roles this wire carries inside `messages` — `inner`'s wire, restated
|
|
130
|
+
* rather than inherited by accident (azureOpenai's stance): the v1 route is
|
|
131
|
+
* OpenAI's chat-completions shape, where the system prompt rides as a message
|
|
132
|
+
* (as `developer` on reasoning deployments), so all three roles survive.
|
|
133
|
+
*/
|
|
134
|
+
const CARRIES_IN_MESSAGES = Object.freeze(['system', 'user', 'assistant']);
|
|
135
|
+
/**
|
|
136
|
+
* Build an `LLMProvider` for a **Microsoft Foundry project**.
|
|
137
|
+
*
|
|
138
|
+
* Inside a hosted Foundry container this is a COMPLETE configuration:
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* import { foundry } from 'agentfootprint/providers';
|
|
142
|
+
*
|
|
143
|
+
* const agent = Agent.create({
|
|
144
|
+
* provider: foundry(), // endpoint injected, managed identity signs
|
|
145
|
+
* model: 'foundry', // → the configured deployment
|
|
146
|
+
* }).build();
|
|
147
|
+
*
|
|
148
|
+
* Anywhere else, name the project and the deployment (and sign in, or pass a
|
|
149
|
+
* credential):
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* const provider = foundry({
|
|
153
|
+
* projectEndpoint: 'https://my-acct.services.ai.azure.com/api/projects/my-proj',
|
|
154
|
+
* deployment: 'gpt-4o-128k',
|
|
155
|
+
* credential: new DefaultAzureCredential(),
|
|
156
|
+
* });
|
|
157
|
+
*
|
|
158
|
+
* The request's `model` is the DEPLOYMENT name: the shorthand `'foundry'`
|
|
159
|
+
* resolves to the configured default, and a concrete deployment id passes
|
|
160
|
+
* through untouched (so one provider can target several deployments — the
|
|
161
|
+
* azureOpenai precedent).
|
|
162
|
+
*/
|
|
163
|
+
function foundry(options = {}) {
|
|
164
|
+
const projectEndpoint = options.projectEndpoint ?? process.env.FOUNDRY_PROJECT_ENDPOINT;
|
|
165
|
+
if (!projectEndpoint) {
|
|
166
|
+
throw new Error(`${ADAPTER}: a \`projectEndpoint\` is required — the shape is ${ENDPOINT_SHAPE}.\n` +
|
|
167
|
+
' Hosted Foundry containers have it injected as FOUNDRY_PROJECT_ENDPOINT; anywhere ' +
|
|
168
|
+
'else, copy it from the Foundry portal.\n' +
|
|
169
|
+
' Fix: pass `projectEndpoint`, or set FOUNDRY_PROJECT_ENDPOINT.');
|
|
170
|
+
}
|
|
171
|
+
const baseURL = foundryInferenceUrl(projectEndpoint);
|
|
172
|
+
const deployment = options.deployment ?? process.env.AZURE_AI_MODEL_DEPLOYMENT_NAME ?? process.env.MODEL_NAME;
|
|
173
|
+
if (!deployment) {
|
|
174
|
+
throw new Error(`${ADAPTER}: a \`deployment\` is required — Foundry's "model" is the DEPLOYMENT name.\n` +
|
|
175
|
+
' Fix: pass `deployment`, or set AZURE_AI_MODEL_DEPLOYMENT_NAME (the azd scaffolding ' +
|
|
176
|
+
'convention) or MODEL_NAME.');
|
|
177
|
+
}
|
|
178
|
+
const apiKey = resolveFoundryAuth(options);
|
|
179
|
+
// Reuse ALL of openai()'s logic. The v1 route is CURRENT OpenAI wire, so the
|
|
180
|
+
// custom baseURL must not demote it to the legacy dialect: `legacyEndpoint:
|
|
181
|
+
// false` is the whole reason that dial is public — max_completion_tokens,
|
|
182
|
+
// stream_options.include_usage, and declared forced tool choice.
|
|
183
|
+
const inner = (0, OpenAIProvider_js_1.openai)({
|
|
184
|
+
baseURL,
|
|
185
|
+
legacyEndpoint: false,
|
|
186
|
+
...(apiKey !== undefined && { apiKey }),
|
|
187
|
+
defaultModel: deployment,
|
|
188
|
+
...(options.reasoning !== undefined && { reasoning: options.reasoning }),
|
|
189
|
+
...(options.defaultMaxTokens !== undefined && { defaultMaxTokens: options.defaultMaxTokens }),
|
|
190
|
+
...(options._client && { _client: options._client }),
|
|
191
|
+
});
|
|
192
|
+
// Foundry's "model" IS the deployment — rewrite the shorthand to it; a
|
|
193
|
+
// concrete id passes through (so you can target multiple deployments).
|
|
194
|
+
const withDeployment = (req) => req.model === 'foundry' ? { ...req, model: deployment } : req;
|
|
195
|
+
return {
|
|
196
|
+
name: 'foundry',
|
|
197
|
+
// The wire is `inner`'s, so the capability is `inner`'s. Re-stating it
|
|
198
|
+
// rather than inheriting by accident: this factory builds a fresh object,
|
|
199
|
+
// and a dropped capability silently becomes the user/assistant floor.
|
|
200
|
+
carriesInMessages: CARRIES_IN_MESSAGES,
|
|
201
|
+
...(inner.carriesForcedToolChoice !== undefined && {
|
|
202
|
+
carriesForcedToolChoice: inner.carriesForcedToolChoice,
|
|
203
|
+
}),
|
|
204
|
+
// `hooks` is FORWARDED, not dropped — see LLMCallHooks in adapters/types.ts.
|
|
205
|
+
complete: (req, hooks) => inner.complete(withDeployment(req), hooks),
|
|
206
|
+
...(inner.stream && {
|
|
207
|
+
stream: (req, hooks) => inner.stream(withDeployment(req), hooks),
|
|
208
|
+
}),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
exports.foundry = foundry;
|
|
212
|
+
// ─── Auth resolution ────────────────────────────────────────────────
|
|
213
|
+
/**
|
|
214
|
+
* Options → what `openai()`'s `apiKey` slot receives. Three doors and one
|
|
215
|
+
* refusal, resolved in one place so the factory above reads as composition.
|
|
216
|
+
*
|
|
217
|
+
* The `credential` door returns a CALLBACK, which is `openai()`'s per-request
|
|
218
|
+
* credential seam: called before every request, and the SDK client is rebuilt
|
|
219
|
+
* only when the returned STRING changes. That is exactly right for
|
|
220
|
+
* MSAL-cached tokens — the cache serves the same string until it refreshes,
|
|
221
|
+
* so a cached token costs one function call and zero client rebuilds, and a
|
|
222
|
+
* refreshed one becomes a new client instead of a 401.
|
|
223
|
+
*/
|
|
224
|
+
function resolveFoundryAuth(options) {
|
|
225
|
+
// Two credentials is not "extra secure" — whichever one this factory
|
|
226
|
+
// silently preferred would be the one the consumer did not think was in use.
|
|
227
|
+
if (options.credential && options.apiKey) {
|
|
228
|
+
throw new Error(`${ADAPTER}: both \`credential\` and \`apiKey\` were given, and they are two answers to ` +
|
|
229
|
+
'the same question — which identity signs the request.\n' +
|
|
230
|
+
' Fix: pass exactly one — `credential` (keyless Entra ID) or `apiKey` (static key).');
|
|
231
|
+
}
|
|
232
|
+
if (options.credential) {
|
|
233
|
+
const credential = options.credential;
|
|
234
|
+
const scope = options.scope ?? azure_js_1.AZURE_AI_SCOPE;
|
|
235
|
+
return async () => (0, OpenAIProvider_js_1.entraBearerToken)(ADAPTER, credential, scope);
|
|
236
|
+
}
|
|
237
|
+
// A string or a callback both pass straight through — `openai()` already
|
|
238
|
+
// owns the re-read-per-request contract for callbacks.
|
|
239
|
+
if (options.apiKey !== undefined)
|
|
240
|
+
return options.apiKey;
|
|
241
|
+
if (options._client) {
|
|
242
|
+
// The injected double replaces the WIRE, not the credential — and with no
|
|
243
|
+
// credential given there is nothing for a test to observe. Constructing a
|
|
244
|
+
// real DefaultAzureCredential underneath a double would reach for genuine
|
|
245
|
+
// cloud identity from inside a unit test, so the double runs keyless.
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
// NEITHER door named → the platform's own blessed zero-config pattern:
|
|
249
|
+
// inside a hosted Foundry container (injected FOUNDRY_PROJECT_ENDPOINT +
|
|
250
|
+
// per-agent managed identity), `new DefaultAzureCredential()` is what
|
|
251
|
+
// Microsoft's own FoundryChatClient does. Constructing the chain fetches
|
|
252
|
+
// NOTHING — tokens are minted per request by the callback below — but the
|
|
253
|
+
// peer-dep is loaded HERE, at factory time, so a missing package is refused
|
|
254
|
+
// where the consumer typed `foundry(...)` (the same stance `openai()` takes
|
|
255
|
+
// on its own SDK).
|
|
256
|
+
let sdk;
|
|
257
|
+
try {
|
|
258
|
+
sdk = (0, lazyRequire_js_1.lazyRequire)('@azure/identity');
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
throw new Error(`${ADAPTER}: keyless zero-config auth needs the \`@azure/identity\` package (an optional ` +
|
|
262
|
+
'peer this library never bundles).\n' +
|
|
263
|
+
' Fix: npm i @azure/identity — or pass `credential` or `apiKey` explicitly.');
|
|
264
|
+
}
|
|
265
|
+
if (typeof sdk.DefaultAzureCredential !== 'function') {
|
|
266
|
+
throw new Error(`${ADAPTER}: \`@azure/identity\` is installed but exports no \`DefaultAzureCredential\`.\n` +
|
|
267
|
+
' Fix: npm i @azure/identity@^4 — or pass `credential` or `apiKey` explicitly.');
|
|
268
|
+
}
|
|
269
|
+
const chain = new sdk.DefaultAzureCredential();
|
|
270
|
+
const scope = options.scope ?? azure_js_1.AZURE_AI_SCOPE;
|
|
271
|
+
return async () => (0, OpenAIProvider_js_1.entraBearerToken)(ADAPTER, chain, scope);
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=FoundryProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoundryProvider.js","sourceRoot":"","sources":["../../../src/adapters/llm/FoundryProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;;;AAGH,6DAAuD;AACvD,2DAA+D;AAE/D,mDAAsD;AAGtD,4DAA4D;AAC5D,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,uEAAuE;AACvE,MAAM,cAAc,GAAG,gEAAgE,CAAC;AA8DxF,uEAAuE;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC"}
|
|
@@ -61,6 +61,8 @@
|
|
|
61
61
|
*/
|
|
62
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
63
|
exports.OllamaProvider = exports.ollama = exports.OllamaUnavailableError = void 0;
|
|
64
|
+
/** Cap for any text the wire supplies before it becomes one of our messages. */
|
|
65
|
+
const ERROR_TEXT_CAP = 200;
|
|
64
66
|
// ─── Errors ─────────────────────────────────────────────────────────
|
|
65
67
|
/**
|
|
66
68
|
* The two failures a local runtime actually has, told in words that
|
|
@@ -158,12 +160,20 @@ function ollama(modelOrOptions, maybeOptions) {
|
|
|
158
160
|
// checked rather than forgotten.
|
|
159
161
|
carriesForcedToolChoice: false,
|
|
160
162
|
async complete(req) {
|
|
163
|
+
// A signal that fired BEFORE the call stops it here, before any socket
|
|
164
|
+
// opens — the `/api/tags` enrichment included. An already-aborted signal
|
|
165
|
+
// never dispatches another 'abort' event, so a listener alone cannot
|
|
166
|
+
// see it.
|
|
167
|
+
throwIfAborted(req.signal);
|
|
161
168
|
const body = buildBody(req, cfg, false);
|
|
162
169
|
const response = await post(body, req);
|
|
163
|
-
|
|
170
|
+
// `fetch` resolves on HEADERS, so reading the body is the stretch where
|
|
171
|
+
// a caller abort would otherwise be inert — honor it for that too.
|
|
172
|
+
const json = (await untilAborted(response.json(), req.signal));
|
|
164
173
|
return fromOllamaResponse(json, nextToolCallId);
|
|
165
174
|
},
|
|
166
175
|
async *stream(req) {
|
|
176
|
+
throwIfAborted(req.signal);
|
|
167
177
|
const body = buildBody(req, cfg, true);
|
|
168
178
|
const response = await post(body, req);
|
|
169
179
|
if (!response.body)
|
|
@@ -175,8 +185,20 @@ function ollama(modelOrOptions, maybeOptions) {
|
|
|
175
185
|
let promptEvalCount = 0;
|
|
176
186
|
let evalCount = 0;
|
|
177
187
|
let tokenIndex = 0;
|
|
178
|
-
|
|
188
|
+
// The signal rides INTO the parser: it is what stops a generation the
|
|
189
|
+
// caller no longer wants, and what cancels the body when it does.
|
|
190
|
+
for await (const chunk of parseNdjson(response.body, req.signal)) {
|
|
179
191
|
const frame = chunk;
|
|
192
|
+
// An already-200 stream can still FAIL mid-generation, and this wire
|
|
193
|
+
// says so IN BAND with an `{"error": "..."}` frame. Such a frame
|
|
194
|
+
// carries no `message` and no `done`, so the guards below would skip
|
|
195
|
+
// it and the terminal chunk would report a truncated answer as
|
|
196
|
+
// `stopReason: 'stop'` with nobody told. Raise instead: a failed
|
|
197
|
+
// generation is a failure, never a shorter answer.
|
|
198
|
+
const failure = frameFailureText(frame);
|
|
199
|
+
if (failure) {
|
|
200
|
+
throw providerError(`[ollama] the stream failed mid-generation — ${failure}`);
|
|
201
|
+
}
|
|
180
202
|
// Counts ride the terminal frame, whose `message.content` is empty —
|
|
181
203
|
// read them before any content guard, or the only token counts the
|
|
182
204
|
// stream reports are thrown away (the failure that made streamed
|
|
@@ -367,7 +389,19 @@ function toOllamaTool(schema) {
|
|
|
367
389
|
},
|
|
368
390
|
};
|
|
369
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Wire response → the port's shape.
|
|
394
|
+
*
|
|
395
|
+
* @throws an `OllamaProviderError` when the 200 body is really a failure
|
|
396
|
+
* (`{"error": "..."}`). Reading it as a response would yield empty content
|
|
397
|
+
* with `stopReason: 'stop'` and zero tokens — a failed call dressed as a
|
|
398
|
+
* successful one.
|
|
399
|
+
*/
|
|
370
400
|
function fromOllamaResponse(response, nextToolCallId) {
|
|
401
|
+
if (response.error !== undefined && response.error !== null) {
|
|
402
|
+
const detail = extractErrorPayload(response.error) || 'the daemon named no reason';
|
|
403
|
+
throw providerError(`[ollama] the daemon answered 200 with an error — ${detail}`);
|
|
404
|
+
}
|
|
371
405
|
const message = response.message;
|
|
372
406
|
const wireToolCalls = message?.tool_calls ?? [];
|
|
373
407
|
const toolCalls = wireToolCalls.map((tc) => toLLMToolCall(tc, nextToolCallId));
|
|
@@ -464,14 +498,24 @@ function normalizeStopReason(raw, hasToolCalls) {
|
|
|
464
498
|
return raw;
|
|
465
499
|
}
|
|
466
500
|
}
|
|
467
|
-
/**
|
|
468
|
-
|
|
501
|
+
/**
|
|
502
|
+
* Parse an NDJSON body — one JSON object per line.
|
|
503
|
+
*
|
|
504
|
+
* Two things here a plain line reader would not do, both because the other
|
|
505
|
+
* end is a model on THIS machine: the caller's `signal` interrupts the read
|
|
506
|
+
* (`fetch` resolved on headers, so this loop is the whole rest of the call),
|
|
507
|
+
* and the body is CANCELLED on the way out — a generation nobody is reading
|
|
508
|
+
* still occupies the machine.
|
|
509
|
+
*/
|
|
510
|
+
async function* parseNdjson(body, signal) {
|
|
469
511
|
const reader = body.getReader();
|
|
470
512
|
const decoder = new TextDecoder();
|
|
471
513
|
let buf = '';
|
|
472
514
|
try {
|
|
473
515
|
for (;;) {
|
|
474
|
-
|
|
516
|
+
// The read is RACED against the caller's signal. A signal that only
|
|
517
|
+
// reached the headers would be a cancellation that cancels nothing.
|
|
518
|
+
const { value, done } = await untilAborted(reader.read(), signal);
|
|
475
519
|
if (done)
|
|
476
520
|
break;
|
|
477
521
|
buf += decoder.decode(value, { stream: true });
|
|
@@ -501,7 +545,23 @@ async function* parseNdjson(body) {
|
|
|
501
545
|
}
|
|
502
546
|
}
|
|
503
547
|
finally {
|
|
504
|
-
|
|
548
|
+
// CANCEL, not merely release the lock. The terminal `done` frame (the
|
|
549
|
+
// stream loop breaks on it), a consumer that breaks out, an error frame,
|
|
550
|
+
// a caller abort — every one of them leaves an open body, and an open
|
|
551
|
+
// body means the local model keeps generating for nobody and the socket
|
|
552
|
+
// stays up.
|
|
553
|
+
try {
|
|
554
|
+
await reader.cancel();
|
|
555
|
+
}
|
|
556
|
+
catch {
|
|
557
|
+
/* already closed or errored — nothing left to close */
|
|
558
|
+
}
|
|
559
|
+
try {
|
|
560
|
+
reader.releaseLock();
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
/* a lock the runtime already dropped */
|
|
564
|
+
}
|
|
505
565
|
}
|
|
506
566
|
}
|
|
507
567
|
/**
|
|
@@ -518,9 +578,16 @@ async function* parseNdjson(body) {
|
|
|
518
578
|
* to break on our behalf. So the timeout wins on its own.
|
|
519
579
|
*
|
|
520
580
|
* A caller's own `AbortSignal` is forwarded and, if IT is what fired, the
|
|
521
|
-
* abort is re-thrown as an abort rather than blamed on the daemon
|
|
581
|
+
* abort is re-thrown as an abort rather than blamed on the daemon —
|
|
582
|
+
* including a signal that was ALREADY aborted when the call was made, which
|
|
583
|
+
* never dispatches an event for a listener to hear.
|
|
522
584
|
*/
|
|
523
585
|
async function fetchUntilHeaders(fetchImpl, url, init, opts) {
|
|
586
|
+
// An already-aborted signal never dispatches another 'abort' event, so the
|
|
587
|
+
// bridge below could not fire and the request would go out on a turn the
|
|
588
|
+
// caller has cancelled. Refuse before the socket opens, and refuse with the
|
|
589
|
+
// caller's own reason: an abort is their call, never a daemon fault.
|
|
590
|
+
throwIfAborted(opts.signal);
|
|
524
591
|
const controller = new AbortController();
|
|
525
592
|
let timedOut = false;
|
|
526
593
|
let timer;
|
|
@@ -579,7 +646,7 @@ async function describeFailure(response, model, baseUrl, fetchImpl, timeoutMs) {
|
|
|
579
646
|
});
|
|
580
647
|
}
|
|
581
648
|
const detail = extractErrorText(bodyText);
|
|
582
|
-
return
|
|
649
|
+
return providerError(`[ollama] ${response.status} ${response.statusText}${detail ? ` — ${detail}` : ''}`.trim(), response.status);
|
|
583
650
|
}
|
|
584
651
|
async function listPulledModels(fetchImpl, baseUrl, timeoutMs) {
|
|
585
652
|
const controller = new AbortController();
|
|
@@ -611,18 +678,110 @@ async function safeText(response) {
|
|
|
611
678
|
return '';
|
|
612
679
|
}
|
|
613
680
|
}
|
|
614
|
-
/**
|
|
681
|
+
/**
|
|
682
|
+
* Native errors are `{"error": "..."}`; the object spelling and raw text are
|
|
683
|
+
* tolerated. Every path is capped — the wire's words help diagnose, but a
|
|
684
|
+
* daemon echoing something enormous (or poisoned) must not become the message.
|
|
685
|
+
*/
|
|
615
686
|
function extractErrorText(bodyText) {
|
|
616
687
|
if (!bodyText)
|
|
617
688
|
return '';
|
|
618
689
|
try {
|
|
619
690
|
const parsed = JSON.parse(bodyText);
|
|
620
|
-
|
|
621
|
-
|
|
691
|
+
const detail = extractErrorPayload(parsed.error);
|
|
692
|
+
if (detail)
|
|
693
|
+
return detail;
|
|
622
694
|
}
|
|
623
695
|
catch {
|
|
624
696
|
/* not JSON — fall through */
|
|
625
697
|
}
|
|
626
|
-
return bodyText.slice(0,
|
|
698
|
+
return bodyText.slice(0, ERROR_TEXT_CAP);
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* The words out of an `error` payload — a bare string on this wire, the
|
|
702
|
+
* `{"message": "..."}` spelling tolerated — capped like every other piece of
|
|
703
|
+
* wire text this file repeats. Empty when there is nothing usable to say, so
|
|
704
|
+
* a caller can tell "no error" from "an error that named no reason".
|
|
705
|
+
*/
|
|
706
|
+
function extractErrorPayload(err) {
|
|
707
|
+
if (typeof err === 'string')
|
|
708
|
+
return err.slice(0, ERROR_TEXT_CAP);
|
|
709
|
+
if (typeof err === 'object' && err !== null) {
|
|
710
|
+
const message = err.message;
|
|
711
|
+
if (typeof message === 'string' && message.length > 0) {
|
|
712
|
+
return message.slice(0, ERROR_TEXT_CAP);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return '';
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* What a mid-stream frame says went wrong — '' when nothing did.
|
|
719
|
+
*
|
|
720
|
+
* One spelling on this wire: an NDJSON frame carrying `error`. It means the
|
|
721
|
+
* generation failed, and it carries neither `message` nor `done`, which is
|
|
722
|
+
* exactly why an unchecked one looks like an ordinary skippable frame. An
|
|
723
|
+
* ordinary frame — the terminal `done` one included, whose content is empty
|
|
724
|
+
* by design — has no `error` key at all, so this guard stays narrow.
|
|
725
|
+
*/
|
|
726
|
+
function frameFailureText(frame) {
|
|
727
|
+
const data = typeof frame === 'object' && frame !== null ? frame : undefined;
|
|
728
|
+
const err = data?.error;
|
|
729
|
+
if (err === undefined || err === null)
|
|
730
|
+
return '';
|
|
731
|
+
return extractErrorPayload(err) || 'the daemon reported an error but named no reason';
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* The provider's own labelled error — one shape for every failure that is not
|
|
735
|
+
* the typed, actionable {@link OllamaUnavailableError}.
|
|
736
|
+
*/
|
|
737
|
+
function providerError(message, status) {
|
|
738
|
+
return Object.assign(new Error(message), {
|
|
739
|
+
name: 'OllamaProviderError',
|
|
740
|
+
...(status !== undefined && { status }),
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* An abort is the CALLER's word, so it must reach them AS an abort — never
|
|
745
|
+
* dressed up as a daemon failure. The signal's own `reason` is used when it
|
|
746
|
+
* is an Error (what every runtime supplies: a DOMException named
|
|
747
|
+
* 'AbortError'); anything else becomes one, keeping the reason as `cause`.
|
|
748
|
+
*/
|
|
749
|
+
function asAbortError(reason) {
|
|
750
|
+
if (reason instanceof Error)
|
|
751
|
+
return reason;
|
|
752
|
+
return Object.assign(new Error('This operation was aborted'), {
|
|
753
|
+
name: 'AbortError',
|
|
754
|
+
...(reason !== undefined && { cause: reason }),
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
/** Stop right here when the caller's signal has already fired. */
|
|
758
|
+
function throwIfAborted(signal) {
|
|
759
|
+
if (signal?.aborted)
|
|
760
|
+
throw asAbortError(signal.reason);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* `promise`, except that a caller abort ends the wait immediately.
|
|
764
|
+
*
|
|
765
|
+
* `fetch` resolves on HEADERS. Everything after that — a streamed body, a
|
|
766
|
+
* large non-streaming JSON read — used to be deaf to the caller's signal, so
|
|
767
|
+
* a cancelled turn kept the local model generating to completion. This is
|
|
768
|
+
* what makes `LLMRequest.signal` honest for the whole call rather than only
|
|
769
|
+
* until the headers land. The CALLER's signal only: `timeoutMs` stays exactly
|
|
770
|
+
* what it always was, a bound on the wait for headers and never on generation.
|
|
771
|
+
*/
|
|
772
|
+
function untilAborted(promise, signal) {
|
|
773
|
+
if (!signal)
|
|
774
|
+
return promise;
|
|
775
|
+
if (signal.aborted) {
|
|
776
|
+
void promise.catch(() => undefined); // the abandoned work must not warn
|
|
777
|
+
return Promise.reject(asAbortError(signal.reason));
|
|
778
|
+
}
|
|
779
|
+
return new Promise((resolve, reject) => {
|
|
780
|
+
const onAbort = () => reject(asAbortError(signal.reason));
|
|
781
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
782
|
+
promise.then(resolve, reject).finally(() => {
|
|
783
|
+
signal.removeEventListener('abort', onAbort);
|
|
784
|
+
});
|
|
785
|
+
});
|
|
627
786
|
}
|
|
628
787
|
//# sourceMappingURL=OllamaProvider.js.map
|