@ixo/oracle-runtime-workers 0.13.0 → 0.16.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 +13 -8
- 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 +310 -0
- package/src/channels/contract.ts +246 -0
- package/src/channels/turns.ts +280 -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 +170 -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 +2003 -274
- 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 +504 -108
- 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 +562 -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
package/src/core/llm.ts
CHANGED
|
@@ -82,7 +82,7 @@ export const TIER_DISPLAY: Record<
|
|
|
82
82
|
export const MODEL_CATALOG: readonly ModelCatalogEntry[] = [
|
|
83
83
|
// ── $ Everyday — fast and cheap ─────────────────────────────────────────
|
|
84
84
|
{
|
|
85
|
-
id:
|
|
85
|
+
id: 'openai/gpt-5.4-nano',
|
|
86
86
|
label: 'GPT-5.4 Nano',
|
|
87
87
|
family: 'openai',
|
|
88
88
|
tier: 'everyday',
|
|
@@ -120,7 +120,7 @@ export const MODEL_CATALOG: readonly ModelCatalogEntry[] = [
|
|
|
120
120
|
|
|
121
121
|
// ── $$ Balanced — smarter, still affordable ─────────────────────────────
|
|
122
122
|
{
|
|
123
|
-
id:
|
|
123
|
+
id: DEFAULT_MODEL_ID,
|
|
124
124
|
label: 'GPT-5.6 Luna',
|
|
125
125
|
family: 'openai',
|
|
126
126
|
tier: 'balanced',
|
|
@@ -239,7 +239,10 @@ export function getDefaultModelId(
|
|
|
239
239
|
return override.length > 0 ? override : DEFAULT_MODEL_ID;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
/** Native input capabilities per catalog id (every key is a `MODEL_CATALOG` id). */
|
|
243
|
+
export const MODEL_INPUT_CAPS: Readonly<
|
|
244
|
+
Record<string, ModelInputCapabilities>
|
|
245
|
+
> = {
|
|
243
246
|
'openai/gpt-5.4-nano': {
|
|
244
247
|
image: true,
|
|
245
248
|
file: true,
|
|
@@ -396,12 +399,19 @@ export async function listModels(
|
|
|
396
399
|
OPEN_ROUTER_API_KEY?: unknown;
|
|
397
400
|
}
|
|
398
401
|
| undefined,
|
|
402
|
+
options: {
|
|
403
|
+
/** Keeps a background price refresh alive past the response (`ctx.waitUntil`). */
|
|
404
|
+
waitUntil?: (work: Promise<unknown>) => void;
|
|
405
|
+
} = {},
|
|
399
406
|
): Promise<ModelListing> {
|
|
400
407
|
const apiKey =
|
|
401
408
|
typeof env?.OPEN_ROUTER_API_KEY === 'string' && env.OPEN_ROUTER_API_KEY
|
|
402
409
|
? env.OPEN_ROUTER_API_KEY
|
|
403
410
|
: undefined;
|
|
404
|
-
const livePrices = await fetchOpenRouterPrices({
|
|
411
|
+
const livePrices = await fetchOpenRouterPrices({
|
|
412
|
+
apiKey,
|
|
413
|
+
...(options.waitUntil ? { waitUntil: options.waitUntil } : {}),
|
|
414
|
+
});
|
|
405
415
|
return listModelCatalog(env, livePrices);
|
|
406
416
|
}
|
|
407
417
|
|
|
@@ -446,6 +456,20 @@ export const OPENROUTER_MAIN_FALLBACKS: readonly string[] = [
|
|
|
446
456
|
|
|
447
457
|
export const OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1';
|
|
448
458
|
|
|
459
|
+
/**
|
|
460
|
+
* Attribution headers OpenRouter asks callers to send. Shared by the chat
|
|
461
|
+
* models and the `openrouter-jev` Decision adapter so every request the
|
|
462
|
+
* oracle makes is credited to the same app.
|
|
463
|
+
*/
|
|
464
|
+
export function openRouterAttributionHeaders(
|
|
465
|
+
oracleName?: string,
|
|
466
|
+
): Record<string, string> {
|
|
467
|
+
return {
|
|
468
|
+
'HTTP-Referer': 'oracle-app.com',
|
|
469
|
+
'X-Title': oracleName ?? 'Oracle App',
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
449
473
|
// ── Nebius (self-hosted deployments) ────────────────────────────────────────
|
|
450
474
|
|
|
451
475
|
export const NEBIUS_BASE_URL = 'https://api.tokenfactory.nebius.com/v1/';
|
|
@@ -561,10 +585,7 @@ export function createLlmAdapter(
|
|
|
561
585
|
if (env.LLM_PROVIDER === 'nebius') return createNebiusAdapter(env, logger);
|
|
562
586
|
const defaultModelId = getDefaultModelId(env);
|
|
563
587
|
const mainEffort = env.MAIN_REASONING_EFFORT ?? 'medium';
|
|
564
|
-
const headers
|
|
565
|
-
'HTTP-Referer': 'oracle-app.com',
|
|
566
|
-
'X-Title': env.ORACLE_NAME ?? 'Oracle App',
|
|
567
|
-
};
|
|
588
|
+
const headers = openRouterAttributionHeaders(env.ORACLE_NAME);
|
|
568
589
|
|
|
569
590
|
const modelForRole = (role: ModelRole): string => {
|
|
570
591
|
if (role === 'main') return defaultModelId;
|
|
@@ -758,7 +779,7 @@ export interface ResolveLangsmithTracingArgs {
|
|
|
758
779
|
/** The turn's user DID — from the authenticated payload, never client-set metadata. */
|
|
759
780
|
userDid: string;
|
|
760
781
|
/** Ingress surface, so latency can be sliced per client in LangSmith. */
|
|
761
|
-
client: 'portal' | 'matrix' | 'slack';
|
|
782
|
+
client: 'portal' | 'matrix' | 'slack' | 'channel';
|
|
762
783
|
env: LangsmithTracingEnv;
|
|
763
784
|
}
|
|
764
785
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { TaskExecutionProfile } from '../core/execution-profile';
|
|
1
2
|
import type { ContextBudget } from './context-budget';
|
|
2
3
|
import type { ContextGuardEvent } from './middlewares/context-guard';
|
|
3
4
|
import type { ResultCapConfig } from './middlewares/result-cap';
|
|
4
5
|
import type { ReadResultOutcome } from '../do/result-store';
|
|
5
6
|
import type { AgentMiddleware } from 'langchain';
|
|
7
|
+
import type { TurnBudget } from './turn-budget';
|
|
6
8
|
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
7
9
|
import type { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
8
10
|
import type { ReactAgent } from 'langchain';
|
|
@@ -12,7 +14,9 @@ import type {
|
|
|
12
14
|
MergedConfig,
|
|
13
15
|
ModelRole,
|
|
14
16
|
OracleIdentity,
|
|
17
|
+
PluginTool,
|
|
15
18
|
} from '../plugin-api/types';
|
|
19
|
+
import type { DeliveryProfile } from '../delivery/types';
|
|
16
20
|
import type { Registries } from './registries';
|
|
17
21
|
import type { AmbientServices, RunConfigContext } from './runtime-context';
|
|
18
22
|
import type { TMainAgentGraphState } from './state';
|
|
@@ -30,7 +34,7 @@ export const mainAgentRequestContextSchema = z.object({
|
|
|
30
34
|
}),
|
|
31
35
|
session: z.object({
|
|
32
36
|
id: z.string(),
|
|
33
|
-
client: z.enum(['portal', 'matrix', 'slack']),
|
|
37
|
+
client: z.enum(['portal', 'matrix', 'slack', 'channel']),
|
|
34
38
|
requestId: z.string(),
|
|
35
39
|
wsId: z.string().optional(),
|
|
36
40
|
roomId: z.string().optional(),
|
|
@@ -85,6 +89,14 @@ export interface MainAgentHooks {
|
|
|
85
89
|
* write-ahead tool marks of durable runs and the result cap live here.
|
|
86
90
|
*/
|
|
87
91
|
toolMiddlewares?: AgentMiddleware[];
|
|
92
|
+
/**
|
|
93
|
+
* The tool-execution middleware (budget, scheduling, write claims). It
|
|
94
|
+
* must see a tool's own thrown error, so on the main agent it is placed
|
|
95
|
+
* innermost — inside the retry middlewares, which turn a thrown error into
|
|
96
|
+
* an error ToolMessage — and each retry attempt passes through it. Every
|
|
97
|
+
* sub-agent gets it after `toolMiddlewares`.
|
|
98
|
+
*/
|
|
99
|
+
toolExecution?: AgentMiddleware;
|
|
88
100
|
/**
|
|
89
101
|
* The turn's result cap (result-cap.ts), applied inside every wrapped
|
|
90
102
|
* tool — plugin, meta and sub-agent inner tools — so a large result is
|
|
@@ -110,9 +122,16 @@ export interface MainAgentHooks {
|
|
|
110
122
|
offset: number,
|
|
111
123
|
length: number,
|
|
112
124
|
) => Promise<ReadResultOutcome>;
|
|
125
|
+
/**
|
|
126
|
+
* Tools the host binds for this turn only, outside every plugin and the
|
|
127
|
+
* capability gate (chat delivery's `create_artifact`). `returnDirect` ends
|
|
128
|
+
* the run once the tool has answered, without another model call.
|
|
129
|
+
*/
|
|
130
|
+
turnTools?: Array<{ tool: PluginTool; returnDirect?: boolean }>;
|
|
113
131
|
}
|
|
114
132
|
|
|
115
133
|
export interface MainAgentArgs {
|
|
134
|
+
executionProfile?: TaskExecutionProfile;
|
|
116
135
|
registries: MainAgentRegistries;
|
|
117
136
|
identity: OracleIdentity;
|
|
118
137
|
config: MergedConfig;
|
|
@@ -120,6 +139,12 @@ export interface MainAgentArgs {
|
|
|
120
139
|
ambient: AmbientServices;
|
|
121
140
|
state: Partial<TMainAgentGraphState>;
|
|
122
141
|
availablePlugins: ReadonlySet<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Plugins the capability router chose for this turn. The gate admits their
|
|
144
|
+
* tools and tool handlers see them as loaded, but they are never written
|
|
145
|
+
* to the graph's `loadedPlugins` channel: the preload lasts one turn.
|
|
146
|
+
*/
|
|
147
|
+
preloadedPlugins?: ReadonlySet<string>;
|
|
123
148
|
/**
|
|
124
149
|
* Checkpointer for the user's thread state. On Workers the Durable Object
|
|
125
150
|
* owns it (SQLite over DO storage) and passes it in per turn; omit for a
|
|
@@ -141,6 +166,19 @@ export interface MainAgentArgs {
|
|
|
141
166
|
* size. Omitted → the legacy fixed thresholds (tests, stateless builds).
|
|
142
167
|
*/
|
|
143
168
|
contextBudget?: ContextBudget;
|
|
169
|
+
/**
|
|
170
|
+
* The turn's resource budget (turn-budget.ts). Model calls are charged by
|
|
171
|
+
* the metered LLM adapter and tool calls by the host's tool-execution
|
|
172
|
+
* middleware; the build itself only uses it to skip a summary after the
|
|
173
|
+
* deadline. Omitted → unbudgeted (tests, stateless builds).
|
|
174
|
+
*/
|
|
175
|
+
turnBudget?: TurnBudget;
|
|
176
|
+
/**
|
|
177
|
+
* Where the reply lands (chat delivery). A `chat` profile adds the surface
|
|
178
|
+
* section to the prompt; tools see it as `ctx.session.surface`. Omitted →
|
|
179
|
+
* a Portal turn.
|
|
180
|
+
*/
|
|
181
|
+
delivery?: DeliveryProfile;
|
|
144
182
|
hooks?: MainAgentHooks;
|
|
145
183
|
}
|
|
146
184
|
|
|
@@ -160,6 +198,8 @@ export interface MainAgentBuildResult {
|
|
|
160
198
|
* turn, `write` never does). Declared by the plugin, else by name.
|
|
161
199
|
*/
|
|
162
200
|
toolEffects: Map<string, 'read' | 'write'>;
|
|
201
|
+
/** Names of the sub-agent dispatch tools (`call_*_agent`): scheduled in their own lane. */
|
|
202
|
+
subAgentToolNames: ReadonlySet<string>;
|
|
163
203
|
/**
|
|
164
204
|
* The request's `{ user, session }` channel. Tools already fall back to it,
|
|
165
205
|
* but pass it as `context` in the `invoke` / `stream` config so LangChain
|