@xopcai/xopc 0.0.202 → 0.0.204
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DOhnAQOQ.js → activity-store-DJBadfSX.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CAjfa48Q.js → agent-avatar-dicebear-BaH7Poqk.js} +1 -1
- package/dist/gateway/static/root/assets/agents-HctDDhtH.js +68 -0
- package/dist/gateway/static/root/assets/{api-E9Bk-Idp.js → api-B5O7fKXa.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-GNT3iv0V.js → app-management-settings-panel-CCLK9wdi.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BFond2ll.js → appearance-settings-DYSHvGJP.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-kCUkEIoM.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C6qpchzp.js → archive-plugin-CZX6pfRb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B4CcSDdV.js → attachment-load-CGYpcBXN.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-D2Ao4Dwi.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-xYL_41XP.js → binary-plugins-BJ1AQfTa.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-nYiJQItv.js → block-editor-DR6LCljI.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-B_IjOjtT.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_jnndyz.js → browser-workflow-inputs-Bd68yluo.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-pT7Hvwwh.js → browser-workflows-page-BG-hEoGn.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DDC5-wqk.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api--tz0mGLY.js → capability-presets-api-BerPMp6f.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CxpKaTzc.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CkOKF9nc.js → channel-recipient-api-D2d21_XA.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-D7pmMIbZ.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-CZ5P9jbB.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-api-X5ukNasZ.js → connectors-api-Sw0BrUmJ.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DTyM5bMS.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-DfZsNMAq.js +2 -0
- package/dist/gateway/static/root/assets/{date-picker-CGm8EH8G.js → date-picker-DjHSmgq9.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-CRajhh0O.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-a3DXD4IR.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-s4kmnf-W.js → desktop-pet-settings-BWx0Duz-.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DmfFg4Gq.js → directory-picker-path-field-CEZrPGZx.js} +1 -1
- package/dist/gateway/static/root/assets/download-Dk-ZjtO6.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DrLEK8GU.js → extension-debug-page-CwJ-R0DC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DtyFPtMR.js → extension-page-BpXWrZFh.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Xok6T2KD.js → extension-settings-page-D0c4RgxT.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DwSpEYiw.js → gateway-config-api-Dn2FSNBa.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Cv2ywpdb.js → gateway-config-swr-VVcfd3sG.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-B5Zh2rx9.js → gateway-settings-BNamAC3x.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-undf-k5g.js → gateway-startup-retry-qAX_T2t2.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-C2RxqeK0.js → heartbeat-settings-BagVvGe6.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-Ci0h-uKG.js +3 -0
- package/dist/gateway/static/root/assets/index-DHGnTdgl.js +85 -0
- package/dist/gateway/static/root/assets/index-Dm-cvIpl.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BN3p-1wI.js → keyboard-shortcuts-settings-BOoz5DNd.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-B1mLlQT6.js +2 -0
- package/dist/gateway/static/root/assets/local-apps-page-B2mV4Olf.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-CnamlR07.js → locale-store-CbPVxonP.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DLFwiLa6.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-CTIaHfgU.js → management-settings-BEduNvMc.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-C0iKadAm.js → markdown-split-BgE9kKG6.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-B12xeflb.css +1 -0
- package/dist/gateway/static/root/assets/markdown-view-Dl-0_9JR.js +69 -0
- package/dist/gateway/static/root/assets/{media-plugins-DcM72GSJ.js → media-plugins-DNESLGDB.js} +1 -1
- package/dist/gateway/static/root/assets/messages-9zCa8KkW.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-By_EzRhP.js → notes-page-COgmlorx.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Ce5ORQus.js +4 -0
- package/dist/gateway/static/root/assets/plus-Q2yW6OE7.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-BV_58lf7.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-dQ2_5PLu.js → product-open-page-Bh8WERvg.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-C0vjVpKC.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-RGaztvxc.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-C7EfVrqr.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DiPj9FLN.js → runtime-tools-settings-panel-HZYyqA5T.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-BDLYItBP.js → schema-form-C6EnKgW2.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BTpLFg2e.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-RV6nphHJ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Dr4Uf_CY.js → settings-form-section-sAjYWtCZ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-Bqi7tsXj.js → settings-loading-skeleton-Bw56H64J.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BbookgxJ.js → settings-page-aduxT-Nu.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CVg8oOTw.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-SmtgZyVf.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-DNXQwu2U.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DhgLGYw8.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BHBDl1pN.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-b9byH-KL.js → skills-page.utils-D5SnlPVg.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CL_AXjw1.js → system-settings-panel-wiXKgbG9.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DBu-p3Iv.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BDyUTObE.js → theme-store-Bc_eRUev.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CUI3q_I-.js → use-autosave-CiuRY85U.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-B-uZKYIg.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DLXOB1jw.js → voice-api-key-field-CX9xuc7h.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-DrTD6gtS.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-C4Ivt1_C.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DKpUxB-i.js → workflow-run-setup-panel-CG0fSFFv.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CT5g5who.js +5 -0
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-BcyiDXU3.js → working-directory-picker-modal-CYWdZUJ5.js} +1 -1
- package/dist/gateway/static/root/assets/x-B_N4OPjy.js +1 -0
- package/dist/gateway/static/root/index.html +19 -14
- package/dist/package.js +1 -1
- package/dist/packages/realtime-client/src/index.js +11 -7
- package/dist/src/agent/agent-manager.js +3 -2
- package/dist/src/agent/embedded/run-for-session.js +3 -2
- package/dist/src/agent/embedded/run-turn.js +29 -16
- package/dist/src/agent/embedded/types.d.ts +2 -2
- package/dist/src/agent/embedded/xopc-stream-bridge.d.ts +2 -1
- package/dist/src/agent/embedded/xopc-stream-bridge.js +2 -2
- package/dist/src/agent/memory/compaction-planner.js +20 -4
- package/dist/src/agent/memory/compaction.js +22 -4
- package/dist/src/agent/memory/context-budget.d.ts +6 -1
- package/dist/src/agent/memory/context-budget.js +94 -2
- package/dist/src/agent/memory/create-memory-manager.js +1 -1
- package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
- package/dist/src/agent/prompt/cache-boundary.js +10 -1
- package/dist/src/agent/prompt/sections/project-context.d.ts +1 -4
- package/dist/src/agent/prompt/sections/project-context.js +6 -13
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -1
- package/dist/src/agent/prompt/system-prompt.d.ts +1 -3
- package/dist/src/agent/prompt/system-prompt.js +6 -15
- package/dist/src/agent/tools/cache-stability.d.ts +3 -0
- package/dist/src/agent/tools/cache-stability.js +19 -0
- package/dist/src/agent/tools/factory.js +2 -1
- package/dist/src/agent-manifest/schema.d.ts +40 -20
- package/dist/src/agent-manifest/schema.js +4 -5
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/config/schema.d.ts +40 -20
- package/dist/src/extensions/types/providers.d.ts +0 -2
- package/dist/src/gateway/chat-stream/mapper.js +44 -4
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/providers/extension-stream-bridge.js +0 -2
- package/dist/src/providers/google-managed-prompt-cache.d.ts +14 -0
- package/dist/src/providers/google-managed-prompt-cache.js +125 -0
- package/dist/src/providers/index.js +5 -4
- package/dist/src/providers/model-call.js +2 -2
- package/dist/src/providers/model-supplements.d.ts +2 -0
- package/dist/src/providers/model-supplements.js +23 -2
- package/dist/src/providers/prompt-cache-fingerprint.d.ts +4 -0
- package/dist/src/providers/prompt-cache-fingerprint.js +44 -0
- package/dist/src/providers/prompt-cache-lifecycle.d.ts +9 -0
- package/dist/src/providers/prompt-cache-lifecycle.js +31 -0
- package/dist/src/providers/prompt-cache-observability.d.ts +20 -0
- package/dist/src/providers/prompt-cache-observability.js +44 -0
- package/dist/src/providers/prompt-cache-payload.d.ts +10 -3
- package/dist/src/providers/prompt-cache-payload.js +204 -31
- package/dist/src/providers/prompt-cache-plan.d.ts +15 -0
- package/dist/src/providers/prompt-cache-plan.js +29 -0
- package/dist/src/realtime/runtime.js +9 -2
- package/dist/src/realtime/writer.js +5 -0
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agents-Cke8EF5Z.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-B9D-6sJt.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BFS3dH43.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-ELV-Y8rz.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Dbx_nPAI.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DHg_JMUz.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-DjHOlPq-.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DNDvMWpl.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-RY-W6CQt.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-DHY0LrLq.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-DDECr6Hj.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-BoEIRgm2.js +0 -1
- package/dist/gateway/static/root/assets/home-page-DPhkqxEb.js +0 -3
- package/dist/gateway/static/root/assets/index-Bp8I_eX4.css +0 -1
- package/dist/gateway/static/root/assets/index-CKSplmFw.js +0 -152
- package/dist/gateway/static/root/assets/local-app-workbench-page-D7FmunJF.js +0 -2
- package/dist/gateway/static/root/assets/local-apps-page-C7H807zd.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-vrjf-JTk.js +0 -2
- package/dist/gateway/static/root/assets/messages-D7kOD_o_.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-Cp1ierS_.js +0 -4
- package/dist/gateway/static/root/assets/preview-open-alternatives-CpblfmWk.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cp_jfZJj.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DYbmweGw.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-U2qXVyLH.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CtNKNhCi.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-B6IMzhWo.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-mUu0iDlD.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-1M79esSO.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-DadcMA8y.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C3ZzYCz0.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-B3kqZ-ke.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-Bnjpkl4v.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CBgAAZiB.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-BvlvyVJX.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BBpnnnrs.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-Dd_9p9ji.js +0 -5
|
@@ -250,11 +250,16 @@ export declare const RuntimePolicySchema: z.ZodOptional<z.ZodObject<{
|
|
|
250
250
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
251
251
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
252
252
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
253
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
254
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
255
|
+
off: "off";
|
|
256
|
+
auto: "auto";
|
|
257
|
+
}>>;
|
|
258
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
259
|
+
short: "short";
|
|
260
|
+
long: "long";
|
|
261
|
+
}>>;
|
|
262
|
+
}, z.core.$strict>>;
|
|
258
263
|
}, z.core.$strict>>;
|
|
259
264
|
export declare const PromptPolicySchema: z.ZodOptional<z.ZodObject<{
|
|
260
265
|
customInstructions: z.ZodOptional<z.ZodString>;
|
|
@@ -399,11 +404,16 @@ export declare const AgentManifestSchema: z.ZodObject<{
|
|
|
399
404
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
400
405
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
401
406
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
408
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
409
|
+
off: "off";
|
|
410
|
+
auto: "auto";
|
|
411
|
+
}>>;
|
|
412
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
413
|
+
short: "short";
|
|
414
|
+
long: "long";
|
|
415
|
+
}>>;
|
|
416
|
+
}, z.core.$strict>>;
|
|
407
417
|
}, z.core.$strict>>;
|
|
408
418
|
prompt: z.ZodOptional<z.ZodObject<{
|
|
409
419
|
customInstructions: z.ZodOptional<z.ZodString>;
|
|
@@ -536,11 +546,16 @@ export declare const AgentConfigEntrySchema: z.ZodObject<{
|
|
|
536
546
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
537
547
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
538
548
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
549
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
550
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
551
|
+
off: "off";
|
|
552
|
+
auto: "auto";
|
|
553
|
+
}>>;
|
|
554
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
555
|
+
short: "short";
|
|
556
|
+
long: "long";
|
|
557
|
+
}>>;
|
|
558
|
+
}, z.core.$strict>>;
|
|
544
559
|
}, z.core.$strict>>;
|
|
545
560
|
prompt: z.ZodOptional<z.ZodObject<{
|
|
546
561
|
customInstructions: z.ZodOptional<z.ZodString>;
|
|
@@ -659,11 +674,16 @@ export declare const CapabilityPresetSchema: z.ZodObject<{
|
|
|
659
674
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
660
675
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
661
676
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
677
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
678
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
679
|
+
off: "off";
|
|
680
|
+
auto: "auto";
|
|
681
|
+
}>>;
|
|
682
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
683
|
+
short: "short";
|
|
684
|
+
long: "long";
|
|
685
|
+
}>>;
|
|
686
|
+
}, z.core.$strict>>;
|
|
667
687
|
}, z.core.$strict>>;
|
|
668
688
|
locks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
669
689
|
}, z.core.$strict>;
|
|
@@ -157,11 +157,10 @@ var init_schema = __esmMin((() => {
|
|
|
157
157
|
maxTurns: z.number().int().positive().optional(),
|
|
158
158
|
timeoutMs: z.number().int().positive().optional(),
|
|
159
159
|
maxToolFailuresPerTurn: z.number().int().positive().optional(),
|
|
160
|
-
|
|
161
|
-
"
|
|
162
|
-
"short",
|
|
163
|
-
|
|
164
|
-
]).optional()
|
|
160
|
+
promptCache: z.object({
|
|
161
|
+
mode: z.enum(["off", "auto"]).default("auto"),
|
|
162
|
+
lifetime: z.enum(["short", "long"]).default("short")
|
|
163
|
+
}).strict().optional()
|
|
165
164
|
}).strict().optional();
|
|
166
165
|
PromptPolicySchema = z.object({ customInstructions: z.string().optional() }).strict().optional();
|
|
167
166
|
AgentIdentitySchema = z.object({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
1
2
|
import { checkBoundary } from "./boundary-guard.js";
|
|
2
3
|
import { resolveModelRole } from "./model-router.js";
|
|
3
4
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
4
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
5
5
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
6
6
|
import { buildAgentRuntimeProfile } from "./runtime-profile.js";
|
|
7
7
|
import { appendAgentRunEvent, createAgentRunTrace, finishAgentRunTrace, hashEffectiveManifest } from "./run-trace.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildAgentManifestPromptSection } from "../agent-manifest/prompt.js";
|
|
2
2
|
import "../agent-manifest/index.js";
|
|
3
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
3
4
|
import { checkBoundary } from "./boundary-guard.js";
|
|
4
5
|
import { resolveModelRole } from "./model-router.js";
|
|
5
6
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
6
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
7
7
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
8
8
|
//#region src/agent-runtime/runtime-profile.ts
|
|
9
9
|
function buildAgentRuntimeProfile(params) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { init_paths, resolveConfigPath } from "../../../config/paths.js";
|
|
2
2
|
import { loadConfig } from "../../../config/loader.js";
|
|
3
3
|
import "../../../config/index.js";
|
|
4
|
-
import { isRestartEnabled } from "../../../config/commands.flags.js";
|
|
5
4
|
import { resolveGatewayService } from "../../../daemon/service.js";
|
|
5
|
+
import { isRestartEnabled } from "../../../config/commands.flags.js";
|
|
6
6
|
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "../../../infra/restart.js";
|
|
7
7
|
import { findVerifiedGatewayListenerPidsOnPortSync, formatGatewayPidList, signalVerifiedGatewayPidSync } from "../../../infra/gateway-processes.js";
|
|
8
8
|
import { runServiceRestart, runServiceStop } from "./lifecycle-core.js";
|
|
@@ -164,11 +164,16 @@ export declare const AgentsConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
164
164
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
165
165
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
166
166
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
169
|
+
off: "off";
|
|
170
|
+
auto: "auto";
|
|
171
|
+
}>>;
|
|
172
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
173
|
+
short: "short";
|
|
174
|
+
long: "long";
|
|
175
|
+
}>>;
|
|
176
|
+
}, z.core.$strict>>;
|
|
172
177
|
}, z.core.$strict>>;
|
|
173
178
|
locks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
174
179
|
}, z.core.$strict>>>;
|
|
@@ -299,11 +304,16 @@ export declare const AgentsConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
299
304
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
300
305
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
301
306
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
308
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
309
|
+
off: "off";
|
|
310
|
+
auto: "auto";
|
|
311
|
+
}>>;
|
|
312
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
313
|
+
short: "short";
|
|
314
|
+
long: "long";
|
|
315
|
+
}>>;
|
|
316
|
+
}, z.core.$strict>>;
|
|
307
317
|
}, z.core.$strict>>;
|
|
308
318
|
prompt: z.ZodOptional<z.ZodObject<{
|
|
309
319
|
customInstructions: z.ZodOptional<z.ZodString>;
|
|
@@ -1699,11 +1709,16 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
1699
1709
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
1700
1710
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1701
1711
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1712
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
1713
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
1714
|
+
off: "off";
|
|
1715
|
+
auto: "auto";
|
|
1716
|
+
}>>;
|
|
1717
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
1718
|
+
short: "short";
|
|
1719
|
+
long: "long";
|
|
1720
|
+
}>>;
|
|
1721
|
+
}, z.core.$strict>>;
|
|
1707
1722
|
}, z.core.$strict>>;
|
|
1708
1723
|
locks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1709
1724
|
}, z.core.$strict>>>;
|
|
@@ -1834,11 +1849,16 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
1834
1849
|
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
1835
1850
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1836
1851
|
maxToolFailuresPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1852
|
+
promptCache: z.ZodOptional<z.ZodObject<{
|
|
1853
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
1854
|
+
off: "off";
|
|
1855
|
+
auto: "auto";
|
|
1856
|
+
}>>;
|
|
1857
|
+
lifetime: z.ZodDefault<z.ZodEnum<{
|
|
1858
|
+
short: "short";
|
|
1859
|
+
long: "long";
|
|
1860
|
+
}>>;
|
|
1861
|
+
}, z.core.$strict>>;
|
|
1842
1862
|
}, z.core.$strict>>;
|
|
1843
1863
|
prompt: z.ZodOptional<z.ZodObject<{
|
|
1844
1864
|
customInstructions: z.ZodOptional<z.ZodString>;
|
|
@@ -92,8 +92,6 @@ export interface ProviderStreamParams {
|
|
|
92
92
|
maxRetries?: number;
|
|
93
93
|
/** Provider request metadata */
|
|
94
94
|
metadata?: Record<string, unknown>;
|
|
95
|
-
/** Prompt cache retention preference */
|
|
96
|
-
cacheRetention?: string;
|
|
97
95
|
/** Preferred transport, if the provider supports multiple transports */
|
|
98
96
|
transport?: string;
|
|
99
97
|
/** Custom token budgets for thinking levels */
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { resolveToolActivity } from "../../../packages/gateway-contract/src/tool-activity.js";
|
|
2
2
|
import { createPetFeedback } from "./pet-feedback.js";
|
|
3
3
|
//#region src/gateway/chat-stream/mapper.ts
|
|
4
|
+
const MAX_REALTIME_TOOL_RESULT_BYTES = 256 * 1024;
|
|
5
|
+
const MAX_REALTIME_TOOL_RESULT_TEXT_BYTES = 128 * 1024;
|
|
6
|
+
const TOOL_RESULT_TRUNCATION_MARKER = "\n\n[Tool result truncated for realtime delivery. The complete result remains in the session transcript.]";
|
|
4
7
|
let lastTaskPlanRevision = 0;
|
|
5
8
|
function nextTaskPlanRevision() {
|
|
6
9
|
lastTaskPlanRevision = Math.max(Date.now(), lastTaskPlanRevision + 1);
|
|
@@ -321,18 +324,19 @@ var ChatStreamMapper = class {
|
|
|
321
324
|
const toolCallId = String(event.toolCallId ?? "");
|
|
322
325
|
if (!toolCallId) return [];
|
|
323
326
|
const messageId = this.toolCallToMessageId.get(toolCallId) ?? this.ensureAssistantMessageId();
|
|
324
|
-
const
|
|
327
|
+
const fullResult = normalizeToolResult(event.result);
|
|
328
|
+
const result = boundRealtimeToolResult(fullResult);
|
|
325
329
|
const toolName = String(event.toolName ?? "unknown");
|
|
326
330
|
const events = [this.make("tool_end", {
|
|
327
331
|
messageId,
|
|
328
332
|
toolCallId,
|
|
329
333
|
toolName,
|
|
330
334
|
status: event.isError ? "error" : "success",
|
|
331
|
-
activity: resolveToolActivity(toolName, event.isError ? "failed" : "completed",
|
|
335
|
+
activity: resolveToolActivity(toolName, event.isError ? "failed" : "completed", fullResult),
|
|
332
336
|
result,
|
|
333
|
-
errorMessage: event.isError ? result?.text : void 0
|
|
337
|
+
errorMessage: event.isError ? result?.text ?? extractText(result?.content) : void 0
|
|
334
338
|
})];
|
|
335
|
-
const details = asRecord(
|
|
339
|
+
const details = asRecord(fullResult?.details);
|
|
336
340
|
if (toolName === "exec_command" && details) events.push(this.make("command_completed", {
|
|
337
341
|
messageId,
|
|
338
342
|
toolCallId,
|
|
@@ -509,6 +513,42 @@ function normalizeToolResult(value) {
|
|
|
509
513
|
text: extractText(rec.content) ?? (typeof rec.text === "string" ? rec.text : void 0)
|
|
510
514
|
};
|
|
511
515
|
}
|
|
516
|
+
function boundRealtimeToolResult(result) {
|
|
517
|
+
if (!result) return result;
|
|
518
|
+
let serialized;
|
|
519
|
+
try {
|
|
520
|
+
serialized = JSON.stringify(result);
|
|
521
|
+
} catch {
|
|
522
|
+
return result;
|
|
523
|
+
}
|
|
524
|
+
const originalBytes = Buffer.byteLength(serialized);
|
|
525
|
+
if (originalBytes <= MAX_REALTIME_TOOL_RESULT_BYTES) return result;
|
|
526
|
+
return {
|
|
527
|
+
content: [{
|
|
528
|
+
type: "text",
|
|
529
|
+
text: `${truncateUtf8(result.text ?? extractText(result.content) ?? "", MAX_REALTIME_TOOL_RESULT_TEXT_BYTES)}${TOOL_RESULT_TRUNCATION_MARKER}`
|
|
530
|
+
}],
|
|
531
|
+
details: {
|
|
532
|
+
truncated: true,
|
|
533
|
+
reason: "realtime_payload_limit",
|
|
534
|
+
originalBytes
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function truncateUtf8(value, maxBytes) {
|
|
539
|
+
if (Buffer.byteLength(value) <= maxBytes) return value;
|
|
540
|
+
let low = 0;
|
|
541
|
+
let high = value.length;
|
|
542
|
+
while (low < high) {
|
|
543
|
+
const middle = Math.ceil((low + high) / 2);
|
|
544
|
+
if (Buffer.byteLength(value.slice(0, middle)) <= maxBytes) low = middle;
|
|
545
|
+
else high = middle - 1;
|
|
546
|
+
}
|
|
547
|
+
let end = low;
|
|
548
|
+
const code = value.charCodeAt(end - 1);
|
|
549
|
+
if (code >= 55296 && code <= 56319) end -= 1;
|
|
550
|
+
return value.slice(0, Math.max(0, end));
|
|
551
|
+
}
|
|
512
552
|
function extractTurnPlan(details) {
|
|
513
553
|
const plan = (Array.isArray(details.plan) ? details.plan : []).map((item) => {
|
|
514
554
|
const rec = asRecord(item);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { shouldSilence, stripHeartbeatToken } from "../../heartbeat/tokens.js";
|
|
4
|
-
import { appendCronEventLines } from "../../heartbeat/event-prompt.js";
|
|
5
4
|
import { isWithinActiveHours } from "../../heartbeat/active-hours.js";
|
|
6
5
|
import { isHeartbeatContentEmpty } from "../../heartbeat/content-check.js";
|
|
6
|
+
import { appendCronEventLines } from "../../heartbeat/event-prompt.js";
|
|
7
7
|
import { createHeartbeatWake } from "../../heartbeat/wake.js";
|
|
8
8
|
import { resolveHeartbeatMdPath } from "../workspace-heartbeat-path.js";
|
|
9
9
|
import { readFile } from "fs/promises";
|
|
@@ -191,7 +191,10 @@ export declare function buildSafeWebConfigPayload(service: GatewayService, optio
|
|
|
191
191
|
maxTurns?: number;
|
|
192
192
|
timeoutMs?: number;
|
|
193
193
|
maxToolFailuresPerTurn?: number;
|
|
194
|
-
|
|
194
|
+
promptCache?: {
|
|
195
|
+
mode: "off" | "auto";
|
|
196
|
+
lifetime: "short" | "long";
|
|
197
|
+
};
|
|
195
198
|
};
|
|
196
199
|
locks?: string[];
|
|
197
200
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, shouldSilence, stripHeartbeatToken } from "./tokens.js";
|
|
2
|
-
import { appendCronEventLines } from "./event-prompt.js";
|
|
3
2
|
import { isWithinActiveHours } from "./active-hours.js";
|
|
4
3
|
import { isHeartbeatContentEmpty } from "./content-check.js";
|
|
4
|
+
import { appendCronEventLines } from "./event-prompt.js";
|
|
5
5
|
import { createHeartbeatWake } from "./wake.js";
|
|
6
6
|
export { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, appendCronEventLines, createHeartbeatWake, isHeartbeatContentEmpty, isWithinActiveHours, shouldSilence, stripHeartbeatToken };
|
|
@@ -2,8 +2,8 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { init_paths, resolveConfigPath } from "../config/paths.js";
|
|
4
4
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
|
-
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
6
5
|
import { resolveGatewayService } from "../daemon/service.js";
|
|
6
|
+
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
7
7
|
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
8
8
|
import { findVerifiedGatewayListenerPidsOnPortSync, signalVerifiedGatewayPidSync } from "./gateway-processes.js";
|
|
9
9
|
import { refreshGatewayServiceAfterUpdate } from "./update-service-refresh.js";
|
|
@@ -51,7 +51,6 @@ function collectExtraStreamOptions(options) {
|
|
|
51
51
|
"signal",
|
|
52
52
|
"apiKey",
|
|
53
53
|
"transport",
|
|
54
|
-
"cacheRetention",
|
|
55
54
|
"sessionId",
|
|
56
55
|
"onPayload",
|
|
57
56
|
"onResponse",
|
|
@@ -93,7 +92,6 @@ function createExtensionAwareStreamFn() {
|
|
|
93
92
|
timeoutMs: options?.timeoutMs,
|
|
94
93
|
maxRetries: options?.maxRetries,
|
|
95
94
|
metadata: options?.metadata,
|
|
96
|
-
cacheRetention: options?.cacheRetention,
|
|
97
95
|
transport: options?.transport,
|
|
98
96
|
thinkingBudgets: options?.thinkingBudgets,
|
|
99
97
|
extra: collectExtraStreamOptions(options),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Api, Model } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { PromptCachePolicy } from './prompt-cache-plan.js';
|
|
3
|
+
export declare function applyGoogleManagedPromptCache(params: {
|
|
4
|
+
model: Model<Api>;
|
|
5
|
+
context: {
|
|
6
|
+
systemPrompt?: string;
|
|
7
|
+
};
|
|
8
|
+
payload: unknown;
|
|
9
|
+
policy: PromptCachePolicy;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
now?: number;
|
|
13
|
+
}): Promise<unknown>;
|
|
14
|
+
export declare function clearGoogleManagedPromptCaches(): void;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { splitPromptCacheBoundary, stripPromptCacheBoundary } from "../agent/prompt/cache-boundary.js";
|
|
2
|
+
import { canonicalizeCacheValue, digestCacheText } from "./prompt-cache-fingerprint.js";
|
|
3
|
+
//#region src/providers/google-managed-prompt-cache.ts
|
|
4
|
+
const DEFAULT_GOOGLE_API_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
|
|
5
|
+
const MIN_CACHEABLE_PROMPT_CHARS = 4096;
|
|
6
|
+
const FAILURE_BACKOFF_MS = 10 * 6e4;
|
|
7
|
+
const MAX_CACHE_ENTRIES = 128;
|
|
8
|
+
const entries = /* @__PURE__ */ new Map();
|
|
9
|
+
const pendingCreates = /* @__PURE__ */ new Map();
|
|
10
|
+
function asRecord(value) {
|
|
11
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
12
|
+
}
|
|
13
|
+
function resolveBaseUrl(model) {
|
|
14
|
+
return (model.baseUrl?.trim() || DEFAULT_GOOGLE_API_BASE_URL).replace(/\/models(?:\/.*)?$/, "").replace(/\/+$/, "");
|
|
15
|
+
}
|
|
16
|
+
function resolveTtlSeconds(policy) {
|
|
17
|
+
return policy.lifetime === "long" ? 3600 : 300;
|
|
18
|
+
}
|
|
19
|
+
function parseExpiry(expireTime, fallback) {
|
|
20
|
+
if (typeof expireTime !== "string") return fallback;
|
|
21
|
+
const parsed = Date.parse(expireTime);
|
|
22
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
23
|
+
}
|
|
24
|
+
function remember(key, entry) {
|
|
25
|
+
entries.delete(key);
|
|
26
|
+
entries.set(key, entry);
|
|
27
|
+
while (entries.size > MAX_CACHE_ENTRIES) {
|
|
28
|
+
const oldest = entries.keys().next().value;
|
|
29
|
+
if (typeof oldest !== "string") break;
|
|
30
|
+
entries.delete(oldest);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function insertDynamicRuntimeContext(payload, dynamicSuffix) {
|
|
34
|
+
if (!dynamicSuffix || !Array.isArray(payload.contents)) return payload;
|
|
35
|
+
const contents = [...payload.contents];
|
|
36
|
+
const insertAt = Math.max(0, contents.length - 1);
|
|
37
|
+
contents.splice(insertAt, 0, {
|
|
38
|
+
role: "user",
|
|
39
|
+
parts: [{ text: `<runtime_context>\n${dynamicSuffix}\n</runtime_context>` }]
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
...payload,
|
|
43
|
+
contents
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function applyGoogleManagedPromptCache(params) {
|
|
47
|
+
if (params.policy.mode === "off") return params.payload;
|
|
48
|
+
const payload = asRecord(params.payload);
|
|
49
|
+
const config = asRecord(payload?.config);
|
|
50
|
+
const apiKey = params.apiKey?.trim();
|
|
51
|
+
if (!payload || !config || !apiKey) return params.payload;
|
|
52
|
+
const split = splitPromptCacheBoundary(params.context.systemPrompt ?? "");
|
|
53
|
+
const stablePrompt = split?.stablePrefix ?? stripPromptCacheBoundary(params.context.systemPrompt ?? "");
|
|
54
|
+
const dynamicSuffix = split?.dynamicSuffix ?? "";
|
|
55
|
+
if (stablePrompt.length < MIN_CACHEABLE_PROMPT_CHARS) return params.payload;
|
|
56
|
+
const cacheConfig = {
|
|
57
|
+
tools: config.tools,
|
|
58
|
+
toolConfig: config.toolConfig
|
|
59
|
+
};
|
|
60
|
+
const key = digestCacheText(`${params.model.provider}\0${params.model.id}\0${stablePrompt}\0${canonicalizeCacheValue(cacheConfig)}`);
|
|
61
|
+
const now = params.now ?? Date.now();
|
|
62
|
+
const existing = entries.get(key);
|
|
63
|
+
let name;
|
|
64
|
+
if (existing?.status === "ready" && existing.expiresAt - now > 3e4) name = existing.name;
|
|
65
|
+
else if (existing?.status === "failed" && existing.retryAt > now) return params.payload;
|
|
66
|
+
else {
|
|
67
|
+
const ttlSeconds = resolveTtlSeconds(params.policy);
|
|
68
|
+
let pending = pendingCreates.get(key);
|
|
69
|
+
if (!pending) {
|
|
70
|
+
pending = (async () => {
|
|
71
|
+
try {
|
|
72
|
+
const response = await (params.fetchImpl ?? globalThis.fetch)(`${resolveBaseUrl(params.model)}/cachedContents`, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: {
|
|
75
|
+
"content-type": "application/json",
|
|
76
|
+
"x-goog-api-key": apiKey
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify({
|
|
79
|
+
model: params.model.id.startsWith("models/") ? params.model.id : `models/${params.model.id}`,
|
|
80
|
+
ttl: `${ttlSeconds}s`,
|
|
81
|
+
systemInstruction: { parts: [{ text: stablePrompt }] },
|
|
82
|
+
...config.tools ? { tools: config.tools } : {},
|
|
83
|
+
...config.toolConfig ? { toolConfig: config.toolConfig } : {}
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
if (!response.ok) throw new Error(`Google cachedContents returned ${response.status}`);
|
|
87
|
+
const body = await response.json();
|
|
88
|
+
if (typeof body.name !== "string" || !body.name.trim()) throw new Error("Google cachedContents response did not include a name");
|
|
89
|
+
return {
|
|
90
|
+
status: "ready",
|
|
91
|
+
name: body.name.trim(),
|
|
92
|
+
expiresAt: parseExpiry(body.expireTime, now + ttlSeconds * 1e3)
|
|
93
|
+
};
|
|
94
|
+
} catch {
|
|
95
|
+
return {
|
|
96
|
+
status: "failed",
|
|
97
|
+
retryAt: now + FAILURE_BACKOFF_MS
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
pendingCreates.set(key, pending);
|
|
102
|
+
}
|
|
103
|
+
const created = await pending.finally(() => pendingCreates.delete(key));
|
|
104
|
+
remember(key, created);
|
|
105
|
+
if (created.status === "failed") return params.payload;
|
|
106
|
+
name = created.name;
|
|
107
|
+
}
|
|
108
|
+
const nextConfig = {
|
|
109
|
+
...config,
|
|
110
|
+
cachedContent: name
|
|
111
|
+
};
|
|
112
|
+
delete nextConfig.systemInstruction;
|
|
113
|
+
delete nextConfig.tools;
|
|
114
|
+
delete nextConfig.toolConfig;
|
|
115
|
+
return insertDynamicRuntimeContext({
|
|
116
|
+
...payload,
|
|
117
|
+
config: nextConfig
|
|
118
|
+
}, dynamicSuffix);
|
|
119
|
+
}
|
|
120
|
+
function clearGoogleManagedPromptCaches() {
|
|
121
|
+
entries.clear();
|
|
122
|
+
pendingCreates.clear();
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { applyGoogleManagedPromptCache, clearGoogleManagedPromptCaches };
|
|
@@ -7,7 +7,7 @@ import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
|
7
7
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
8
8
|
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
|
-
import { getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
10
|
+
import { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
12
12
|
import { init_provider_auth_service, resolveProviderApiKey } from "./provider-auth-service.js";
|
|
13
13
|
import { getModel, getModels, getProviders } from "@earendil-works/pi-ai/compat";
|
|
@@ -45,11 +45,12 @@ var providers_exports = /* @__PURE__ */ __exportAll({
|
|
|
45
45
|
resolveModel: () => resolveModel
|
|
46
46
|
});
|
|
47
47
|
function normalizeProviderModel(model) {
|
|
48
|
+
const correctedModel = applyOfficialModelMetadataCorrections(model);
|
|
48
49
|
if (model.provider === "openai-codex" && model.api === "openai-codex-responses") return {
|
|
49
|
-
...
|
|
50
|
+
...correctedModel,
|
|
50
51
|
baseUrl: OPENAI_CODEX_CANONICAL_BASE_URL
|
|
51
52
|
};
|
|
52
|
-
return
|
|
53
|
+
return correctedModel;
|
|
53
54
|
}
|
|
54
55
|
/** Map a plugin registry model to the pi-ai {@link Model} shape. */
|
|
55
56
|
function pluginModelToModel(providerId, definition) {
|
|
@@ -91,7 +92,7 @@ function resolveModel(ref) {
|
|
|
91
92
|
const trimmedRef = typeof ref === "string" ? ref.trim() : "";
|
|
92
93
|
if (!trimmedRef) throw new Error("No default model configured. Choose a model in onboarding or set agents.capabilityPresets.default.models.roles.<role>.model.");
|
|
93
94
|
const customModel = getModelRegistry().resolve(trimmedRef);
|
|
94
|
-
if (customModel) return customModel;
|
|
95
|
+
if (customModel) return normalizeProviderModel(customModel);
|
|
95
96
|
const qualifiedRef = splitProviderModelRef(trimmedRef);
|
|
96
97
|
if (qualifiedRef) {
|
|
97
98
|
const { provider, modelId } = qualifiedRef;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { init_constants } from "./constants.js";
|
|
2
2
|
import { getApiKey, init_providers } from "./index.js";
|
|
3
3
|
import { createExtensionAwareStreamFn } from "./extension-stream-bridge.js";
|
|
4
|
-
import {
|
|
4
|
+
import { completeSimple } from "@earendil-works/pi-ai/compat";
|
|
5
5
|
//#region src/providers/model-call.ts
|
|
6
6
|
init_constants();
|
|
7
7
|
init_providers();
|
|
@@ -43,7 +43,7 @@ async function resolveModelCallOptions(model, options = {}, credentialOptions) {
|
|
|
43
43
|
async function completeWithResolvedCredentials(model, context, options = {}, credentialOptions) {
|
|
44
44
|
const resolvedOptions = await resolveModelCallOptions(model, options, credentialOptions);
|
|
45
45
|
if (model.baseUrl === "extension://provider-plugin") return await (await createExtensionAwareStreamFn()(model, context, resolvedOptions)).result();
|
|
46
|
-
return await
|
|
46
|
+
return await completeSimple(model, context, resolvedOptions);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Start a model stream with xopc credential resolution and extension-provider routing.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type Api, type Model } from '@earendil-works/pi-ai/compat';
|
|
2
|
+
/** Correct narrowly scoped upstream catalog metadata while older pi-ai data is still installed. */
|
|
3
|
+
export declare function applyOfficialModelMetadataCorrections(model: Model<Api>): Model<Api>;
|
|
2
4
|
/**
|
|
3
5
|
* Small local supplement for official model aliases that may lag in pi-ai.
|
|
4
6
|
* Keep this list narrow: full provider catalogs should come from pi-ai.
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getModel } from "@earendil-works/pi-ai/compat";
|
|
3
3
|
//#region src/providers/model-supplements.ts
|
|
4
|
+
/** Correct narrowly scoped upstream catalog metadata while older pi-ai data is still installed. */
|
|
5
|
+
function applyOfficialModelMetadataCorrections(model) {
|
|
6
|
+
const correctedContextWindow = OPENAI_CONTEXT_WINDOW_CORRECTIONS.get(model.id);
|
|
7
|
+
if ((model.provider === "openai" || model.provider === "openai-codex") && correctedContextWindow !== void 0 && model.contextWindow === STALE_OPENAI_CONTEXT_WINDOW) return {
|
|
8
|
+
...model,
|
|
9
|
+
contextWindow: correctedContextWindow
|
|
10
|
+
};
|
|
11
|
+
return model;
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Small local supplement for official model aliases that may lag in pi-ai.
|
|
6
15
|
* Keep this list narrow: full provider catalogs should come from pi-ai.
|
|
@@ -14,7 +23,19 @@ function getSupplementalModels() {
|
|
|
14
23
|
name: "GPT-5.6"
|
|
15
24
|
}];
|
|
16
25
|
}
|
|
17
|
-
var
|
|
26
|
+
var STALE_OPENAI_CONTEXT_WINDOW, OPENAI_CONTEXT_WINDOW_CORRECTIONS;
|
|
27
|
+
var init_model_supplements = __esmMin((() => {
|
|
28
|
+
STALE_OPENAI_CONTEXT_WINDOW = 272e3;
|
|
29
|
+
OPENAI_CONTEXT_WINDOW_CORRECTIONS = new Map([
|
|
30
|
+
["gpt-5.4", 105e4],
|
|
31
|
+
["gpt-5.4-mini", 4e5],
|
|
32
|
+
["gpt-5.5", 105e4],
|
|
33
|
+
["gpt-5.6", 105e4],
|
|
34
|
+
["gpt-5.6-luna", 105e4],
|
|
35
|
+
["gpt-5.6-sol", 105e4],
|
|
36
|
+
["gpt-5.6-terra", 105e4]
|
|
37
|
+
]);
|
|
38
|
+
}));
|
|
18
39
|
//#endregion
|
|
19
40
|
init_model_supplements();
|
|
20
|
-
export { getSupplementalModels, init_model_supplements };
|
|
41
|
+
export { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Canonical JSON used only for bounded prompt-cache fingerprints. */
|
|
2
|
+
export declare function canonicalizeCacheValue(value: unknown): string;
|
|
3
|
+
export declare function digestCacheValue(value: unknown): string;
|
|
4
|
+
export declare function digestCacheText(value: string): string;
|