@ixo/oracle-runtime-workers 0.12.0 → 0.15.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/README.md +32 -10
- package/package.json +14 -9
- package/src/artifacts/config.ts +158 -0
- package/src/artifacts/crypto.ts +94 -0
- package/src/artifacts/routes.ts +73 -0
- package/src/artifacts/store.ts +238 -0
- package/src/artifacts/sweep.ts +200 -0
- package/src/artifacts/tool.ts +103 -0
- package/src/artifacts/viewer-page.ts +614 -0
- package/src/attachments/download.ts +168 -45
- package/src/attachments/index.ts +9 -0
- package/src/attachments/magic.ts +33 -0
- package/src/attachments/pipeline.ts +105 -49
- package/src/attachments/sandbox-archive.ts +9 -8
- package/src/attachments/view-cache.ts +142 -0
- package/src/attachments/view.ts +53 -12
- package/src/channels/auth.ts +267 -0
- package/src/channels/contract.ts +137 -0
- package/src/channels/turns.ts +270 -0
- package/src/core/budgeted-llm.ts +223 -0
- package/src/core/capability-router.ts +273 -0
- package/src/core/context-budget.ts +97 -10
- package/src/core/env.ts +111 -0
- package/src/core/execution-profile.ts +17 -0
- package/src/core/index.ts +267 -9
- package/src/core/llm.ts +30 -9
- package/src/core/main-agent-types.ts +41 -1
- package/src/core/main-agent.ts +367 -65
- package/src/core/manifest.ts +34 -0
- package/src/core/meta-tools.ts +128 -18
- package/src/core/middlewares/capability-gate.ts +130 -12
- package/src/core/middlewares/context-guard.ts +55 -24
- package/src/core/middlewares/index.ts +20 -2
- package/src/core/middlewares/page-context.ts +46 -2
- package/src/core/middlewares/return-direct-first.ts +47 -0
- package/src/core/middlewares/summarization.ts +152 -10
- package/src/core/middlewares/tool-execution.ts +323 -0
- package/src/core/middlewares/tool-repetition-guard.ts +202 -35
- package/src/core/middlewares/turn-boundary.ts +162 -0
- package/src/core/openrouter-pricing.ts +155 -22
- package/src/core/prompt-composer.ts +112 -7
- package/src/core/registries.ts +253 -48
- package/src/core/request-admission.ts +159 -0
- package/src/core/runtime-context.ts +107 -8
- package/src/core/state.ts +1 -1
- package/src/core/sub-agent-fallback.ts +21 -2
- package/src/core/subagent-as-tool.ts +78 -43
- package/src/core/tool-access.ts +189 -0
- package/src/core/tool-scheduler.ts +125 -0
- package/src/core/turn-budget.ts +205 -0
- package/src/core/turn-time-note.ts +43 -0
- package/src/core/user-kv.ts +446 -0
- package/src/core/wrap-plugin-tool.ts +20 -0
- package/src/delivery/plan.ts +278 -0
- package/src/delivery/profile.ts +161 -0
- package/src/delivery/prompt.ts +27 -0
- package/src/delivery/schema.ts +61 -0
- package/src/delivery/shaper.ts +389 -0
- package/src/delivery/types.ts +84 -0
- package/src/do/ambient.ts +51 -15
- package/src/do/contracts.ts +198 -6
- package/src/do/idle-eviction.ts +38 -0
- package/src/do/matrix-turn-ledger.ts +24 -5
- package/src/do/result-store-test-do.ts +137 -3
- package/src/do/result-store.ts +239 -58
- package/src/do/room-mirror.ts +29 -0
- package/src/do/run-buffer.ts +64 -9
- package/src/do/run-coordinator.ts +451 -76
- package/src/do/run-request.ts +2 -0
- package/src/do/run-store-test-do.ts +301 -1
- package/src/do/run-store.ts +385 -43
- package/src/do/secrets-adapter.ts +22 -3
- package/src/do/sse-stream.ts +60 -9
- package/src/do/transcript.ts +48 -5
- package/src/do/turn-body.ts +105 -5
- package/src/do/ucan-service.ts +204 -34
- package/src/do/user-oracle-do.ts +1883 -264
- package/src/feedback/config.ts +127 -0
- package/src/feedback/contract.ts +148 -0
- package/src/feedback/linear-sink.ts +285 -0
- package/src/feedback/privacy.ts +150 -0
- package/src/feedback/reservation.ts +298 -0
- package/src/feedback/submit.ts +247 -0
- package/src/index.ts +138 -6
- package/src/llm/byo-adapter.ts +27 -6
- package/src/llm/byo-catalog.ts +13 -0
- package/src/llm/byo-model-fallback.ts +248 -0
- package/src/llm/byo-service.ts +45 -8
- package/src/llm/provider-error.ts +139 -2
- package/src/matrix/gateway-do.ts +523 -111
- package/src/matrix/group-chat.ts +66 -23
- package/src/matrix/inbox-store.ts +16 -1
- package/src/matrix/ingest.ts +79 -14
- package/src/matrix/media-deadline.ts +130 -0
- package/src/matrix/replay-format.ts +5 -3
- package/src/matrix/reply-parts.ts +92 -0
- package/src/matrix/room-alias.ts +96 -0
- package/src/matrix/user-homeserver.ts +166 -7
- package/src/owner-store/ixo-vfs-store.ts +170 -43
- package/src/owner-store/migrating-store.ts +31 -15
- package/src/owner-store/types.ts +18 -3
- package/src/plugin-api/index.ts +43 -2
- package/src/plugin-api/oracle-plugin.ts +35 -0
- package/src/plugin-api/request-admission.ts +41 -0
- package/src/plugin-api/tool-helper.ts +25 -1
- package/src/plugin-api/tool-plane.ts +92 -0
- package/src/plugin-api/types.ts +194 -6
- package/src/plugins/agui/agui.plugin.ts +31 -16
- package/src/plugins/composio/composio-tools.ts +57 -6
- package/src/plugins/composio/composio-ucan.ts +3 -2
- package/src/plugins/composio/composio.plugin.ts +2 -0
- package/src/plugins/delegated-capabilities.ts +25 -0
- package/src/plugins/editor/content-session.ts +173 -83
- package/src/plugins/editor/content-tools.ts +76 -17
- package/src/plugins/editor/editor-mx.ts +28 -9
- package/src/plugins/editor/editor.plugin.ts +3 -1
- package/src/plugins/editor/failures.ts +28 -7
- package/src/plugins/editor/prompts.ts +2 -1
- package/src/plugins/editor/provider.ts +553 -40
- package/src/plugins/editor/standalone-editor-tool.ts +61 -18
- package/src/plugins/firecrawl/firecrawl-tools.ts +13 -5
- package/src/plugins/flows/action-metadata.ts +111 -11
- package/src/plugins/flows/actions.ts +18 -0
- package/src/plugins/flows/decision-context.ts +31 -0
- package/src/plugins/flows/edit.ts +223 -52
- package/src/plugins/flows/errors.ts +22 -1
- package/src/plugins/flows/flow-doc.ts +92 -9
- package/src/plugins/flows/flows.plugin.ts +11 -5
- package/src/plugins/flows/forms.ts +34 -0
- package/src/plugins/flows/index.ts +2 -0
- package/src/plugins/flows/input-policy.ts +140 -0
- package/src/plugins/flows/prompts.ts +14 -11
- package/src/plugins/flows/read.ts +49 -9
- package/src/plugins/flows/ref-syntax.ts +129 -0
- package/src/plugins/flows/test-homeserver.ts +245 -0
- package/src/plugins/flows/tools/authoring.ts +216 -112
- package/src/plugins/flows/tools/discovery.ts +4 -1
- package/src/plugins/flows/tools/forms.ts +21 -2
- package/src/plugins/flows/tools/settings.ts +34 -13
- package/src/plugins/flows/translator.ts +13 -10
- package/src/plugins/flows/types.ts +167 -42
- package/src/plugins/index.ts +11 -1
- package/src/plugins/ixo-transaction/chain-ids.ts +43 -0
- package/src/plugins/ixo-transaction/index.ts +2 -0
- package/src/plugins/ixo-transaction/ixo-transaction.plugin.ts +119 -0
- package/src/plugins/ixo-transaction/receipts.ts +99 -0
- package/src/plugins/ixo-transaction/tools.ts +329 -0
- package/src/plugins/ixo-transaction/wallet-signing.ts +202 -0
- package/src/plugins/mcp-tool-adapter.ts +23 -2
- package/src/plugins/memory/memory-tools.ts +7 -2
- package/src/plugins/memory/memory-ucan.ts +3 -2
- package/src/plugins/memory/memory.plugin.ts +2 -0
- package/src/plugins/pod-creator/blueprint-store.ts +163 -0
- package/src/plugins/pod-creator/blueprint-types.ts +61 -0
- package/src/plugins/pod-creator/bounded-map.ts +87 -0
- package/src/plugins/pod-creator/capsule-content-client.ts +285 -0
- package/src/plugins/pod-creator/chain-gateway.ts +110 -0
- package/src/plugins/pod-creator/config.ts +85 -0
- package/src/plugins/pod-creator/create-session-store.ts +180 -0
- package/src/plugins/pod-creator/create-tools.ts +538 -0
- package/src/plugins/pod-creator/design-pod-roles.ts +111 -0
- package/src/plugins/pod-creator/index.ts +65 -0
- package/src/plugins/pod-creator/orchestration-tools.ts +172 -0
- package/src/plugins/pod-creator/pod-creator.plugin.ts +190 -0
- package/src/plugins/pod-creator/stage.ts +201 -0
- package/src/plugins/pod-creator/sub-agents.ts +189 -0
- package/src/plugins/portal/action-log.ts +21 -1
- package/src/plugins/portal/declared-tools.ts +90 -0
- package/src/plugins/portal/portal.plugin.ts +42 -16
- package/src/plugins/sandbox/sandbox-bridge.ts +79 -10
- package/src/plugins/sandbox/sandbox-mcp.ts +3 -2
- package/src/plugins/sandbox/sandbox-write-blob.ts +11 -1
- package/src/plugins/sandbox/sandbox.plugin.ts +8 -16
- package/src/plugins/tasks/manifest.ts +1 -1
- package/src/plugins/tasks/middleware.ts +20 -7
- package/src/plugins/tasks/tasks-tools.ts +30 -3
- package/src/plugins/tasks/tasks.plugin.ts +64 -11
- package/src/plugins/user-preferences/schema.ts +12 -1
- package/src/plugins/user-preferences/user-preferences-store.ts +38 -13
- package/src/plugins/user-preferences/user-preferences-tool.ts +3 -2
- package/src/plugins/vfs/vfs-client.ts +250 -71
- package/src/plugins/vfs/vfs-content.ts +30 -11
- package/src/plugins/vfs/vfs-errors.ts +22 -0
- package/src/plugins/vfs/vfs-sandbox-tools.ts +12 -5
- package/src/plugins/vfs/vfs-tools.ts +60 -20
- package/src/realtime/frontend-call-registry.ts +228 -81
- package/src/realtime/realtime-endpoint.ts +215 -44
- package/src/realtime/session-socket-hub.ts +47 -2
- package/src/secrets/secrets-service.ts +9 -3
- package/src/shell/app.ts +529 -82
- package/src/shell/auth.ts +131 -37
- package/src/shell/turn-body-cap.ts +11 -13
- package/src/sqlite/blob-compactor.ts +61 -28
- package/src/sqlite/database.ts +156 -90
- package/src/sqlite/do-vfs.ts +416 -129
- package/src/sqlite/page-tier.ts +133 -40
- package/src/sqlite/serialization.ts +40 -0
- package/src/sqlite/sessions-store.ts +10 -2
- package/src/sqlite/sqlite-saver.ts +139 -19
- package/src/sqlite/user-kv-store.ts +317 -0
- package/src/tasks/schedule.ts +201 -12
- package/src/tasks/scheduler.ts +586 -98
- package/src/tasks/spec.ts +67 -3
- package/src/tasks/store.ts +292 -27
- package/src/tasks/topic-deliverables.ts +70 -0
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* streams a reply.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { isContextOverflowError } from '../core/context-window';
|
|
10
11
|
import {
|
|
11
12
|
BYO_PROVIDER_INFO,
|
|
13
|
+
BYO_PROVIDER_MODELS,
|
|
12
14
|
isByoProvider,
|
|
13
15
|
type ByoProvider,
|
|
14
16
|
} from './byo-catalog';
|
|
@@ -20,6 +22,7 @@ export type ByoFallbackReason =
|
|
|
20
22
|
| 'not_connected'
|
|
21
23
|
| 'reconnect_required'
|
|
22
24
|
| 'unreachable'
|
|
25
|
+
| 'model_unavailable'
|
|
23
26
|
| 'error';
|
|
24
27
|
|
|
25
28
|
export interface ByoFallbackNoticePayload {
|
|
@@ -28,19 +31,51 @@ export interface ByoFallbackNoticePayload {
|
|
|
28
31
|
source: 'byo';
|
|
29
32
|
provider?: ByoProvider;
|
|
30
33
|
providerLabel?: string;
|
|
34
|
+
/** `model_unavailable` only: the provider-native id the provider refused. */
|
|
35
|
+
model?: string;
|
|
31
36
|
reason: ByoFallbackReason;
|
|
32
37
|
retryable: false;
|
|
33
38
|
timestamp: string;
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
export interface ByoFallbackNoticeOptions {
|
|
42
|
+
/** `model_unavailable`: the provider-native model id that was refused. */
|
|
43
|
+
modelId?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Catalog label of a provider-native BYO model id, else the id itself. */
|
|
47
|
+
function byoModelLabel(provider: ByoProvider | undefined, modelId: string) {
|
|
48
|
+
const entry = provider
|
|
49
|
+
? BYO_PROVIDER_MODELS[provider].find((m) => m.id === modelId)
|
|
50
|
+
: undefined;
|
|
51
|
+
return entry?.label ?? modelId;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The user's account as the `model_unavailable` sentence names it: the
|
|
56
|
+
* subscription is a plan, the API-key providers are accounts — the same
|
|
57
|
+
* wording the classified-error messages use (`fallbackMessage`).
|
|
58
|
+
*/
|
|
59
|
+
function byoAccountPhrase(
|
|
60
|
+
provider: ByoProvider | undefined,
|
|
61
|
+
providerLabel: string | undefined,
|
|
62
|
+
): string {
|
|
63
|
+
if (provider === 'chatgpt') return 'Your ChatGPT subscription';
|
|
64
|
+
return providerLabel
|
|
65
|
+
? `Your ${providerLabel} account`
|
|
66
|
+
: 'Your connected AI account';
|
|
67
|
+
}
|
|
68
|
+
|
|
36
69
|
export function buildByoFallbackNotice(
|
|
37
70
|
reason: ByoFallbackReason,
|
|
38
71
|
provider?: ByoProvider,
|
|
72
|
+
opts?: ByoFallbackNoticeOptions,
|
|
39
73
|
): ByoFallbackNoticePayload {
|
|
40
74
|
const providerLabel = provider
|
|
41
75
|
? BYO_PROVIDER_INFO[provider].label
|
|
42
76
|
: undefined;
|
|
43
77
|
const account = providerLabel ?? 'your connected AI account';
|
|
78
|
+
const modelId = reason === 'model_unavailable' ? opts?.modelId : undefined;
|
|
44
79
|
const message =
|
|
45
80
|
reason === 'unreachable'
|
|
46
81
|
? `Your ${account} can't be reached from this oracle right now, so this reply is using the platform model instead.`
|
|
@@ -48,13 +83,16 @@ export function buildByoFallbackNotice(
|
|
|
48
83
|
? `Your ${account} connection has expired, so this reply is using the platform model instead. Reconnect it in your Personal Agent settings.`
|
|
49
84
|
: reason === 'not_connected'
|
|
50
85
|
? `The model you selected needs a connected ${account}, so this reply is using the platform model instead. Connect it in your Personal Agent settings.`
|
|
51
|
-
:
|
|
86
|
+
: reason === 'model_unavailable'
|
|
87
|
+
? `${byoAccountPhrase(provider, providerLabel)} doesn't offer ${modelId ? byoModelLabel(provider, modelId) : 'the model you selected'}, so this reply used the platform model instead. Pick another model in your Personal Agent settings.`
|
|
88
|
+
: `Your connected AI account could not be used for this reply, so it is using the platform model instead.`;
|
|
52
89
|
return {
|
|
53
90
|
error: message,
|
|
54
91
|
kind: BYO_FALLBACK_KIND,
|
|
55
92
|
source: 'byo',
|
|
56
93
|
...(provider && { provider }),
|
|
57
94
|
...(providerLabel && { providerLabel }),
|
|
95
|
+
...(modelId && { model: modelId }),
|
|
58
96
|
reason,
|
|
59
97
|
retryable: false,
|
|
60
98
|
timestamp: new Date().toISOString(),
|
|
@@ -216,6 +254,30 @@ function fallbackMessage(
|
|
|
216
254
|
}
|
|
217
255
|
}
|
|
218
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Failures of the platform model answering for a refused BYO model
|
|
259
|
+
* (byo-model-fallback.ts). The turn is still a BYO turn, but such a failure
|
|
260
|
+
* is the platform's: it must be classified (and redacted) as one, never
|
|
261
|
+
* blamed on the user's account. Identity-keyed, so the error object itself
|
|
262
|
+
* is left untouched.
|
|
263
|
+
*/
|
|
264
|
+
const PLATFORM_FALLBACK_FAILURES = new WeakSet<object>();
|
|
265
|
+
|
|
266
|
+
export function markPlatformFallbackFailure(error: unknown): void {
|
|
267
|
+
if (error && typeof error === 'object') PLATFORM_FALLBACK_FAILURES.add(error);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The error, or one it wraps (`cause`, as LangChain's MiddlewareError does). */
|
|
271
|
+
function isPlatformFallbackFailure(error: unknown): boolean {
|
|
272
|
+
let current: unknown = error;
|
|
273
|
+
for (let depth = 0; depth < 8; depth += 1) {
|
|
274
|
+
if (!current || typeof current !== 'object') return false;
|
|
275
|
+
if (PLATFORM_FALLBACK_FAILURES.has(current)) return true;
|
|
276
|
+
current = 'cause' in current ? current.cause : undefined;
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
|
|
219
281
|
export interface ClassifyLlmErrorContext {
|
|
220
282
|
/** The BYO provider the failing turn ran on, when it was a BYO turn. */
|
|
221
283
|
byoProvider?: ByoProvider | string | null;
|
|
@@ -228,7 +290,9 @@ export function classifyLlmError(
|
|
|
228
290
|
const parts = extractErrorParts(error);
|
|
229
291
|
const kind = detectKind(parts);
|
|
230
292
|
const provider =
|
|
231
|
-
typeof ctx?.byoProvider === 'string' &&
|
|
293
|
+
typeof ctx?.byoProvider === 'string' &&
|
|
294
|
+
isByoProvider(ctx.byoProvider) &&
|
|
295
|
+
!isPlatformFallbackFailure(error)
|
|
232
296
|
? ctx.byoProvider
|
|
233
297
|
: undefined;
|
|
234
298
|
const providerLabel = provider
|
|
@@ -246,6 +310,79 @@ export function classifyLlmError(
|
|
|
246
310
|
};
|
|
247
311
|
}
|
|
248
312
|
|
|
313
|
+
// ── Model refused by the user's own provider ─────────────────────────────
|
|
314
|
+
|
|
315
|
+
/** Provider codes that name the model as the problem. */
|
|
316
|
+
const MODEL_UNAVAILABLE_CODES: ReadonlySet<string> = new Set([
|
|
317
|
+
'model_not_found',
|
|
318
|
+
'unsupported_model',
|
|
319
|
+
]);
|
|
320
|
+
/**
|
|
321
|
+
* Provider texts that name the model as the problem: OpenAI's "The model `x`
|
|
322
|
+
* does not exist or you do not have access to it", the ChatGPT backend's
|
|
323
|
+
* "The 'x' model is not supported when using Codex with a ChatGPT account".
|
|
324
|
+
*/
|
|
325
|
+
const MODEL_UNAVAILABLE_TEXT =
|
|
326
|
+
/model_not_found|unsupported[_ ]model|model\b[^.\n]{0,120}\b(?:does not exist|is not supported|not available)/i;
|
|
327
|
+
/** LangChain's code for a 400 about the request's tool messages. */
|
|
328
|
+
const INVALID_TOOL_RESULTS = 'INVALID_TOOL_RESULTS';
|
|
329
|
+
|
|
330
|
+
export interface ModelUnavailableOptions {
|
|
331
|
+
/**
|
|
332
|
+
* The failing call had already produced output (text, reasoning or a tool
|
|
333
|
+
* call). Such a failure is never this case: the reply is under way and
|
|
334
|
+
* the turn keeps today's error handling.
|
|
335
|
+
*/
|
|
336
|
+
afterOutput?: boolean;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Whether a BYO model call failed because the user's provider does not
|
|
341
|
+
* serve the requested model — the ChatGPT backend answers an immediate
|
|
342
|
+
* `400` with an empty body for a model id the subscription does not offer.
|
|
343
|
+
*
|
|
344
|
+
* Positive: an explicit model code or text (`model_not_found`, "does not
|
|
345
|
+
* exist", "unsupported model", "is not supported") on a 400/403/404 or a
|
|
346
|
+
* status-less error; or a bare HTTP 400/404 that is nothing else this module
|
|
347
|
+
* or LangChain recognises (not a context overflow, not a malformed
|
|
348
|
+
* tool-result history, not a billing/auth/rate/timeout/network/server
|
|
349
|
+
* text). Never once the call produced output (`afterOutput`).
|
|
350
|
+
*/
|
|
351
|
+
export function isModelUnavailableError(
|
|
352
|
+
error: unknown,
|
|
353
|
+
opts?: ModelUnavailableOptions,
|
|
354
|
+
): boolean {
|
|
355
|
+
if (opts?.afterOutput) return false;
|
|
356
|
+
const parts = extractErrorParts(error);
|
|
357
|
+
const { status, code, text } = parts;
|
|
358
|
+
if (
|
|
359
|
+
status !== undefined &&
|
|
360
|
+
status !== 400 &&
|
|
361
|
+
status !== 403 &&
|
|
362
|
+
status !== 404
|
|
363
|
+
) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
if (
|
|
367
|
+
isContextOverflowError(error) ||
|
|
368
|
+
(error instanceof Error && error.name === 'ContextOverflowError')
|
|
369
|
+
) {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
if (code && MODEL_UNAVAILABLE_CODES.has(code)) return true;
|
|
373
|
+
if (MODEL_UNAVAILABLE_TEXT.test(text)) return true;
|
|
374
|
+
if (status !== 400 && status !== 404) return false;
|
|
375
|
+
if (
|
|
376
|
+
error &&
|
|
377
|
+
typeof error === 'object' &&
|
|
378
|
+
'lc_error_code' in error &&
|
|
379
|
+
error.lc_error_code === INVALID_TOOL_RESULTS
|
|
380
|
+
) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
return detectKind(parts) === 'unknown';
|
|
384
|
+
}
|
|
385
|
+
|
|
249
386
|
const OPERATOR_FAULT_KINDS: ReadonlySet<LlmErrorKind> = new Set([
|
|
250
387
|
'billing',
|
|
251
388
|
'auth',
|