@alwith/module-chat 0.5.19 → 0.5.21
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 +240 -1
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/assets/catalogs/alwith/models.json +72 -0
- package/assets/catalogs/custom/models.json +604 -0
- package/assets/catalogs/custom/sources.json +168 -0
- package/assets/catalogs/deepseek/models.json +139 -0
- package/assets/catalogs/openrouter/models.json +231 -0
- package/assets/catalogs/qwen/models.json +253 -0
- package/assets/catalogs/xai/models.json +129 -0
- package/assets/provider-catalog.json +127 -0
- package/dist/activity-host.js +1 -1
- package/dist/approval/choice-elicitation-form.js +1 -1
- package/dist/approval/choice-schema.js +1 -1
- package/dist/approval/permission-options.js +1 -1
- package/dist/approval/permission-view.js +1 -1
- package/dist/approval/schema-elicitation-form.js +1 -1
- package/dist/approval/url-elicitation-card.js +1 -1
- package/dist/chunk-00eytt1z.js +2 -0
- package/dist/chunk-0fs2k5fe.js +1289 -0
- package/dist/chunk-0gersbj0.js +2 -0
- package/dist/chunk-0gy6ngda.js +2 -0
- package/dist/chunk-0mp7tyea.js +2 -0
- package/dist/chunk-0vhkv9ax.js +2 -0
- package/dist/{chunk-b53ky6rb.js → chunk-141kppzb.js} +2 -2
- package/dist/chunk-14exd146.js +2 -0
- package/dist/{chunk-yjtq166b.js → chunk-156m3888.js} +3 -3
- package/dist/{chunk-jx1cngyb.js → chunk-1e6x0018.js} +2 -2
- package/dist/{chunk-01rfnabj.js → chunk-1f628zap.js} +2 -2
- package/dist/{chunk-h3antqdd.js → chunk-1ppfn0e1.js} +2 -2
- package/dist/chunk-1q2cykp4.js +2 -0
- package/dist/chunk-1tkzxktd.js +2 -0
- package/dist/{chunk-9ej4c7a8.js → chunk-23rjsm3a.js} +2 -2
- package/dist/chunk-2ce8gd89.js +2 -0
- package/dist/chunk-2f1qx13s.js +2 -0
- package/dist/{chunk-0vy6cqmw.js → chunk-2nvsvw67.js} +2 -2
- package/dist/chunk-2tce3pc5.js +3 -0
- package/dist/chunk-2tkeevm0.js +2 -0
- package/dist/chunk-33620ca6.js +2 -0
- package/dist/chunk-3aq5c12k.js +2 -0
- package/dist/{chunk-jt8h82c2.js → chunk-3jcmv5qf.js} +2 -2
- package/dist/chunk-3n47hknp.js +2 -0
- package/dist/chunk-3nr5qe41.js +2 -0
- package/dist/chunk-3yvd77ph.js +2 -0
- package/dist/chunk-40bcp4pa.js +2 -0
- package/dist/{chunk-9xkp5x7h.js → chunk-42hkbpey.js} +2 -2
- package/dist/chunk-42nhwnbe.js +4 -0
- package/dist/chunk-4s6gx750.js +2 -0
- package/dist/chunk-4w3g7d6w.js +2 -0
- package/dist/chunk-52p7kyam.js +2 -0
- package/dist/{chunk-kvx8fv1e.js → chunk-59957gfy.js} +2 -2
- package/dist/chunk-59exzf5n.js +2 -0
- package/dist/chunk-5cdr7q6f.js +4 -0
- package/dist/chunk-5nc3dtyt.js +2 -0
- package/dist/chunk-63kxepkh.js +2 -0
- package/dist/chunk-67hrx4kg.js +2 -0
- package/dist/{chunk-eeq8d3x7.js → chunk-6dn3j8a2.js} +2 -2
- package/dist/{chunk-cdrmg9jj.js → chunk-72x7rae0.js} +2 -2
- package/dist/chunk-77j8n5k5.js +2 -0
- package/dist/{chunk-d6c0mnth.js → chunk-78s6h7r4.js} +2 -2
- package/dist/chunk-7p1r1ha9.js +2 -0
- package/dist/{chunk-hwh88n0v.js → chunk-7wk3d01c.js} +4 -4
- package/dist/chunk-80ckz04b.js +2 -0
- package/dist/chunk-82xjggwn.js +2 -0
- package/dist/chunk-85ffkcch.js +2 -0
- package/dist/chunk-8c042xya.js +2 -0
- package/dist/{chunk-09r35ts9.js → chunk-8ch9444t.js} +2 -2
- package/dist/{chunk-2hk04fh3.js → chunk-8hte6dh7.js} +2 -2
- package/dist/{chunk-dj4e0q7k.js → chunk-8jxcdap5.js} +2 -2
- package/dist/chunk-8qw8erv6.js +2 -0
- package/dist/chunk-8t36vprh.js +2 -0
- package/dist/{chunk-a9s3m9fs.js → chunk-8w22ck92.js} +2 -2
- package/dist/chunk-908ndb9r.js +2 -0
- package/dist/chunk-983gkw32.js +2 -0
- package/dist/chunk-9g67z1b4.js +2 -0
- package/dist/chunk-9mky3b7v.js +2 -0
- package/dist/chunk-9n79tr1q.js +2 -0
- package/dist/{chunk-ekd97p2x.js → chunk-9sq2etjk.js} +2 -2
- package/dist/chunk-a8p82wp7.js +2 -0
- package/dist/chunk-ajpxjj5m.js +2 -0
- package/dist/chunk-ap0vmczf.js +2 -0
- package/dist/chunk-aqvy57zs.js +2 -0
- package/dist/{chunk-9ebnn34t.js → chunk-aza82m2p.js} +2 -2
- package/dist/chunk-b2wczqtd.js +2 -0
- package/dist/chunk-b3jg6nzv.js +3 -0
- package/dist/{chunk-qy2prx7m.js → chunk-b614gnnv.js} +2 -2
- package/dist/{chunk-50mckd2p.js → chunk-c1b8z8pa.js} +2 -2
- package/dist/chunk-c38t8809.js +2 -0
- package/dist/chunk-c9nbavk0.js +2 -0
- package/dist/chunk-cbwya2ss.js +2 -0
- package/dist/chunk-cg8ekwka.js +2 -0
- package/dist/chunk-dv65h7z5.js +2 -0
- package/dist/chunk-dya74vts.js +2 -0
- package/dist/chunk-dyqvhn6y.js +5 -0
- package/dist/chunk-dyrgfdxz.js +2 -0
- package/dist/chunk-e9ntencj.js +2 -0
- package/dist/{chunk-e92r4g3v.js → chunk-ec9rgnt3.js} +2 -2
- package/dist/chunk-efrn25h9.js +2 -0
- package/dist/chunk-emcefs0g.js +2 -0
- package/dist/chunk-et8rcxw6.js +2 -0
- package/dist/chunk-f28hhbf4.js +2 -0
- package/dist/chunk-f3924gdb.js +2 -0
- package/dist/chunk-f8zy35gz.js +2 -0
- package/dist/chunk-f98at4r5.js +2 -0
- package/dist/chunk-fke98cj0.js +2 -0
- package/dist/chunk-g242n3dt.js +2 -0
- package/dist/{chunk-q4q4f03j.js → chunk-g73f62qm.js} +2 -2
- package/dist/{chunk-k9mbpf0g.js → chunk-h1bhhqtq.js} +2 -2
- package/dist/chunk-h5m2fpp4.js +2 -0
- package/dist/chunk-hv1ejvhg.js +2 -0
- package/dist/chunk-j86x2rn0.js +2 -0
- package/dist/chunk-jm6zja6h.js +2 -0
- package/dist/{chunk-z5tstgsh.js → chunk-k5rkpqbh.js} +2 -2
- package/dist/chunk-k5wgf59a.js +2 -0
- package/dist/{chunk-4xhvh2dn.js → chunk-k7k6qsqh.js} +2 -2
- package/dist/chunk-kc5k5e59.js +3 -0
- package/dist/chunk-kvc6ewkt.js +4 -0
- package/dist/chunk-kxmajv0m.js +3 -0
- package/dist/{chunk-m2hpfdch.js → chunk-m2b8kzpk.js} +2 -2
- package/dist/{chunk-e44hny11.js → chunk-m7wn4z9x.js} +2 -2
- package/dist/chunk-mcjwwxa1.js +2 -0
- package/dist/chunk-memvzzc6.js +2 -0
- package/dist/{chunk-fgzq0ktw.js → chunk-mg2mkzkk.js} +2 -2
- package/dist/{chunk-0zp04d1m.js → chunk-mgm1x3de.js} +2 -2
- package/dist/chunk-mwpchd85.js +3 -0
- package/dist/chunk-myrdfa3s.js +2 -0
- package/dist/chunk-n0khj68q.js +2 -0
- package/dist/{chunk-c2h76vnt.js → chunk-n929wkw7.js} +2 -2
- package/dist/chunk-nacjea1s.js +2 -0
- package/dist/{chunk-gcx4fk1a.js → chunk-nn25kjm4.js} +2 -2
- package/dist/{chunk-f8wzz84b.js → chunk-nq7gg9vg.js} +2 -2
- package/dist/{chunk-a4wrn6ep.js → chunk-nqw4deag.js} +2 -2
- package/dist/{chunk-gr1nnczz.js → chunk-ns5rnxdj.js} +2 -2
- package/dist/{chunk-6p41wmgs.js → chunk-nxp1b8ny.js} +2 -2
- package/dist/chunk-p4bb313p.js +3 -0
- package/dist/chunk-py837qjk.js +1 -0
- package/dist/chunk-q7nn5xe5.js +2 -0
- package/dist/chunk-qjhkzdhm.js +2 -0
- package/dist/{chunk-eyf9bxyx.js → chunk-qwfwxfhn.js} +2 -2
- package/dist/chunk-qxcnyvps.js +2 -0
- package/dist/chunk-r3qrftds.js +2 -0
- package/dist/chunk-r9dt4bs3.js +2 -0
- package/dist/chunk-rbqn4725.js +2 -0
- package/dist/chunk-rcbb4ke2.js +2 -0
- package/dist/chunk-rekc1q3m.js +2 -0
- package/dist/chunk-rwkkqdcv.js +2 -0
- package/dist/{chunk-fcy4sv9f.js → chunk-rwnz06kr.js} +2 -2
- package/dist/{chunk-5n4mefej.js → chunk-s55n9cby.js} +2 -2
- package/dist/chunk-sxh0pd3y.js +2 -0
- package/dist/chunk-sy5tq3y6.js +2 -0
- package/dist/chunk-t0cr21e3.js +2 -0
- package/dist/chunk-t97yjy4f.js +2 -0
- package/dist/chunk-v4t0p6pp.js +2 -0
- package/dist/{chunk-rsfwc38x.js → chunk-vcy5vyp7.js} +3 -3
- package/dist/chunk-vkrgdqnm.js +2 -0
- package/dist/chunk-vs02ry2r.js +2 -0
- package/dist/chunk-vyk4zh1m.js +7 -0
- package/dist/{chunk-5nj2fjej.js → chunk-w0hpztj7.js} +2 -2
- package/dist/chunk-w6rwngm3.js +2 -0
- package/dist/{chunk-jc52024g.js → chunk-w9dh298r.js} +2 -2
- package/dist/chunk-wvdncbrt.js +2 -0
- package/dist/chunk-x2yc5748.js +2 -0
- package/dist/chunk-x334e7wb.js +3 -0
- package/dist/{chunk-qmc18ejg.js → chunk-x6nz6eyb.js} +2 -2
- package/dist/chunk-xdm2are3.js +2 -0
- package/dist/{chunk-0zph0gwq.js → chunk-xf36kt74.js} +3 -3
- package/dist/{chunk-tzyc5myt.js → chunk-xgjkj9j8.js} +2 -2
- package/dist/chunk-xktybk48.js +2 -0
- package/dist/{chunk-210b2kk6.js → chunk-xmstt6hh.js} +2 -2
- package/dist/chunk-xrs7x5ah.js +2 -0
- package/dist/chunk-xyvqcpjx.js +2 -0
- package/dist/chunk-y7xcync7.js +2 -0
- package/dist/chunk-ye9tsdhn.js +2 -0
- package/dist/{chunk-5e10bzg2.js → chunk-z2fjwkmt.js} +2 -2
- package/dist/{chunk-nkqe2e8s.js → chunk-z2v008kc.js} +2 -2
- package/dist/chunk-z71pp1mb.js +4 -0
- package/dist/chunk-zxkvvecz.js +2 -0
- package/dist/codex/activity-group.js +1 -1
- package/dist/codex/assistant-message.js +1 -1
- package/dist/codex/async-question-card.js +1 -1
- package/dist/codex/disclosure-state.js +1 -1
- package/dist/codex/edited-files-card.js +1 -1
- package/dist/codex/image-view-activity.js +1 -1
- package/dist/codex/markdown-renderer.js +1 -1
- package/dist/codex/navigation-audio.js +1 -1
- package/dist/codex/navigation-preview.js +1 -1
- package/dist/codex/navigation-rail.js +1 -1
- package/dist/codex/patch-view.js +1 -1
- package/dist/codex/plan.js +1 -1
- package/dist/codex/timeline-virtualizer.js +1 -1
- package/dist/codex/turn-activity.js +1 -1
- package/dist/codex/user-message.js +1 -1
- package/dist/codex/virtualized-turn-list.js +1 -1
- package/dist/collections/collection-emoji.d.ts +4 -0
- package/dist/collections/collection-emoji.js +1 -0
- package/dist/collections/collection-menu.d.ts +15 -0
- package/dist/collections/collection-menu.js +1 -0
- package/dist/collections/collection-panel.d.ts +11 -0
- package/dist/collections/collection-panel.js +1 -0
- package/dist/collections/collections.d.ts +6 -0
- package/dist/collections/collections.js +1 -0
- package/dist/collections/host.d.ts +19 -0
- package/dist/collections/host.js +1 -0
- package/dist/collections/locales.d.ts +71 -0
- package/dist/collections/locales.js +1 -0
- package/dist/collections/model.d.ts +95 -0
- package/dist/collections/model.js +1 -0
- package/dist/collections/store.d.ts +30 -0
- package/dist/collections/store.js +1 -0
- package/dist/composer/completion-filter.js +1 -1
- package/dist/composer/completion-menu.js +1 -1
- package/dist/composer/completion-trigger.js +1 -1
- package/dist/composer/effort-slider.js +1 -1
- package/dist/composer/menu-radio.js +1 -1
- package/dist/composer/model-select.js +1 -1
- package/dist/composer/permission-mode-select.js +1 -1
- package/dist/composer/prompt-input-attachments.js +1 -1
- package/dist/composer/prompt-input-clipboard.js +1 -1
- package/dist/composer/prompt-input-context.js +1 -1
- package/dist/composer/prompt-input-textarea.js +1 -1
- package/dist/composer/prompt-input.js +1 -1
- package/dist/conversation/action-card.js +1 -1
- package/dist/conversation/composer/composer.js +1 -1
- package/dist/conversation/composer/config-options.js +1 -1
- package/dist/conversation/composer/context.js +1 -1
- package/dist/conversation/composer/drafts.js +1 -1
- package/dist/conversation/composer/file-items.js +1 -1
- package/dist/conversation/composer/long-text.js +1 -1
- package/dist/conversation/composer/mention-chips.js +1 -1
- package/dist/conversation/composer/mention-uri.js +1 -1
- package/dist/conversation/composer/model-menu.js +1 -1
- package/dist/conversation/composer/pasted-text-attachment.js +1 -1
- package/dist/conversation/composer/permission-mode-menu.js +1 -1
- package/dist/conversation/composer/prediction.js +1 -1
- package/dist/conversation/composer/slash-command-button.js +1 -1
- package/dist/conversation/composer/submit-button.js +1 -1
- package/dist/conversation/composer/usage-meter.js +1 -1
- package/dist/conversation/connection-notice.d.ts +8 -0
- package/dist/conversation/connection-notice.js +1 -0
- package/dist/conversation/context.js +1 -1
- package/dist/conversation/conversation-body.js +1 -1
- package/dist/conversation/conversation-search.d.ts +8 -0
- package/dist/conversation/conversation-search.js +1 -0
- package/dist/conversation/conversation-view.d.ts +1 -0
- package/dist/conversation/conversation-view.js +1 -1
- package/dist/conversation/conversation.d.ts +3 -0
- package/dist/conversation/conversation.js +1 -1
- package/dist/conversation/diff-modal.js +1 -1
- package/dist/conversation/draft-project-picker.d.ts +7 -0
- package/dist/conversation/draft-project-picker.js +1 -0
- package/dist/conversation/session-actions.js +1 -1
- package/dist/conversation/subagent-sessions.js +1 -1
- package/dist/conversation/types.d.ts +6 -1
- package/dist/image-lightbox.js +1 -1
- package/dist/image-preview-dialog.js +1 -1
- package/dist/lib/code-highlighter.js +1 -1
- package/dist/lib/fuzzy.js +1 -1
- package/dist/lib/group-blocks.js +1 -1
- package/dist/lib/image-encode.js +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/markdown-parser.js +1 -1
- package/dist/lib/markdown-rules.js +1 -1
- package/dist/lib/model-name.js +1 -1
- package/dist/lib/pointer-centered-zoom.js +1 -1
- package/dist/lib/prepare-prompt-files.js +1 -1
- package/dist/lib/stream-style.js +1 -1
- package/dist/lib/streaming-markdown.js +1 -1
- package/dist/locales.d.ts +1914 -0
- package/dist/locales.js +1 -1
- package/dist/plugins/catalog-header.d.ts +6 -0
- package/dist/plugins/catalog-header.js +1 -0
- package/dist/plugins/catalog-skeleton.d.ts +3 -0
- package/dist/plugins/catalog-skeleton.js +1 -0
- package/dist/plugins/host.d.ts +49 -0
- package/dist/plugins/host.js +1 -0
- package/dist/plugins/locales.d.ts +1136 -0
- package/dist/plugins/locales.js +1 -0
- package/dist/plugins/new-chat-directory.d.ts +2 -0
- package/dist/plugins/new-chat-directory.js +1 -0
- package/dist/plugins/pane.d.ts +12 -0
- package/dist/plugins/pane.js +1 -0
- package/dist/plugins/panel-item.d.ts +8 -0
- package/dist/plugins/panel-item.js +1 -0
- package/dist/plugins/plugin-detail-page.d.ts +5 -0
- package/dist/plugins/plugin-detail-page.js +1 -0
- package/dist/plugins/plugin-icon.d.ts +7 -0
- package/dist/plugins/plugin-icon.js +1 -0
- package/dist/plugins/plugin-icons.d.ts +1 -0
- package/dist/plugins/plugin-icons.js +1 -0
- package/dist/plugins/plugins-page.d.ts +12 -0
- package/dist/plugins/plugins-page.js +1 -0
- package/dist/plugins/plugins.css +199 -0
- package/dist/plugins/plugins.d.ts +14 -0
- package/dist/plugins/plugins.js +1 -0
- package/dist/plugins/read-skill-document.d.ts +2 -0
- package/dist/plugins/read-skill-document.js +1 -0
- package/dist/plugins/skill-document.d.ts +7 -0
- package/dist/plugins/skill-document.js +1 -0
- package/dist/plugins/skills-tab.d.ts +6 -0
- package/dist/plugins/skills-tab.js +1 -0
- package/dist/plugins/store.d.ts +62 -0
- package/dist/plugins/store.js +1 -0
- package/dist/plugins/toolbox-layout.d.ts +7 -0
- package/dist/plugins/toolbox-layout.js +1 -0
- package/dist/search/chat-search.css +9 -0
- package/dist/search/chat-search.d.ts +1 -0
- package/dist/search/chat-search.js +1 -1
- package/dist/search/codex-source-matches.d.ts +4 -0
- package/dist/search/codex-source-matches.js +1 -0
- package/dist/search/dom-matches.js +1 -1
- package/dist/search/find-bar.js +1 -1
- package/dist/search/literal-matches.js +1 -1
- package/dist/session-list/account-menu.d.ts +26 -0
- package/dist/session-list/account-menu.js +1 -0
- package/dist/session-list/activity-list.d.ts +11 -0
- package/dist/session-list/activity-list.js +1 -0
- package/dist/session-list/archived-sessions.js +1 -1
- package/dist/session-list/help-menu.d.ts +5 -0
- package/dist/session-list/help-menu.js +1 -0
- package/dist/session-list/highlight.js +1 -1
- package/dist/session-list/host.d.ts +2 -0
- package/dist/session-list/host.js +1 -1
- package/dist/session-list/hover-info-card.js +1 -1
- package/dist/session-list/locales.d.ts +91 -0
- package/dist/session-list/locales.js +1 -1
- package/dist/session-list/navigation-header.d.ts +14 -0
- package/dist/session-list/navigation-header.js +1 -0
- package/dist/session-list/navigation-store.d.ts +19 -0
- package/dist/session-list/navigation-store.js +1 -0
- package/dist/session-list/navigation-tabs.d.ts +20 -0
- package/dist/session-list/navigation-tabs.js +1 -0
- package/dist/session-list/navigation.js +1 -1
- package/dist/session-list/overflow-marquee.js +1 -1
- package/dist/session-list/platform.d.ts +2 -0
- package/dist/session-list/platform.js +1 -0
- package/dist/session-list/row-stop-button.js +1 -1
- package/dist/session-list/session-groups.js +1 -1
- package/dist/session-list/session-info-card.js +1 -1
- package/dist/session-list/session-list.d.ts +10 -0
- package/dist/session-list/session-list.js +1 -1
- package/dist/session-list/session-row.js +1 -1
- package/dist/session-list/session-state-dot.js +1 -1
- package/dist/session-list/session-state-menu.js +1 -1
- package/dist/session-list/shortcut-hint.d.ts +14 -0
- package/dist/session-list/shortcut-hint.js +1 -0
- package/dist/session-list/shortcut.d.ts +2 -0
- package/dist/session-list/shortcut.js +1 -0
- package/dist/session-list/sidebar-overlay.js +1 -1
- package/dist/session-list/trailing-swap.js +1 -1
- package/dist/session-list/use-activity-notification.d.ts +1 -0
- package/dist/session-list/use-activity-notification.js +1 -0
- package/dist/session-list/use-activity-preview.js +1 -1
- package/dist/session-list/use-cmd-held.d.ts +1 -0
- package/dist/session-list/use-cmd-held.js +1 -0
- package/dist/session-list/use-project-sessions.js +1 -1
- package/dist/session-list/virtual-session-rows.js +1 -1
- package/dist/session-timeline/activity-group.js +1 -1
- package/dist/session-timeline/activity-projection.js +1 -1
- package/dist/session-timeline/assistant-content.js +1 -1
- package/dist/session-timeline/assistant-turn.js +1 -1
- package/dist/session-timeline/async-questions.js +1 -1
- package/dist/session-timeline/edited-files-card.js +1 -1
- package/dist/session-timeline/history-timeline.js +1 -1
- package/dist/session-timeline/host.js +1 -1
- package/dist/session-timeline/navigation-rail.js +1 -1
- package/dist/session-timeline/plan.js +1 -1
- package/dist/session-timeline/question-reply.js +1 -1
- package/dist/session-timeline/resource-content.js +1 -1
- package/dist/session-timeline/session-timeline.js +1 -1
- package/dist/session-timeline/timeline-registry.js +1 -1
- package/dist/session-timeline/turn-activity.js +1 -1
- package/dist/session-timeline/turn-error.js +1 -1
- package/dist/session-timeline/turn-retry.js +1 -1
- package/dist/session-timeline/turn-time.js +1 -1
- package/dist/session-timeline/turns.js +1 -1
- package/dist/session-timeline/use-timeline-scroll.js +1 -1
- package/dist/session-timeline/user-message.js +1 -1
- package/dist/settings/codex-account-card.d.ts +18 -0
- package/dist/settings/codex-account-card.js +1 -0
- package/dist/settings/login-card.d.ts +6 -0
- package/dist/settings/login-card.js +1 -0
- package/dist/settings/model-alias-settings.d.ts +6 -0
- package/dist/settings/model-alias-settings.js +1 -0
- package/dist/settings/model-aliases.d.ts +17 -0
- package/dist/settings/model-aliases.js +1 -0
- package/dist/settings/provider-logos.d.ts +5 -0
- package/dist/settings/provider-logos.js +1 -0
- package/dist/settings/provider-section.d.ts +52 -0
- package/dist/settings/provider-section.js +1 -0
- package/dist/settings/providers-port.d.ts +32 -0
- package/dist/settings/providers-port.js +1 -0
- package/dist/settings/providers.d.ts +92 -0
- package/dist/settings/providers.js +1 -0
- package/dist/settings/settings-bridge.d.ts +39 -0
- package/dist/settings/settings-bridge.js +1 -0
- package/dist/settings/settings.d.ts +9 -0
- package/dist/settings/settings.js +1 -0
- package/dist/stage.d.ts +1 -0
- package/dist/stage.js +1 -1
- package/emojibase/LICENSE +21 -0
- package/emojibase/en/data.json +51183 -0
- package/emojibase/en/messages.json +124 -0
- package/emojibase/zh/data.json +48992 -0
- package/emojibase/zh/messages.json +124 -0
- package/licenses/_dnd-kit_core-LICENSE +21 -0
- package/licenses/_dnd-kit_sortable-LICENSE +21 -0
- package/licenses/_dnd-kit_utilities-LICENSE +21 -0
- package/licenses/_solar-icons_react-LICENSE +11 -0
- package/licenses/_solar-icons_react-LICENSE-THIRD-PARTY +14 -0
- package/licenses/frimousse-LICENSE +21 -0
- package/package.json +36 -4
- package/rust/Cargo.lock +3844 -0
- package/rust/Cargo.toml +29 -0
- package/rust/build.rs +16 -0
- package/rust/permissions/autogenerated/reference.md +296 -0
- package/rust/permissions/default.toml +20 -0
- package/rust/permissions/schemas/schema.json +292 -0
- package/rust/src/lib.rs +79 -0
- package/rust/src/providers/managed.rs +801 -0
- package/rust/src/providers/tests.rs +681 -0
- package/rust/src/providers.rs +984 -0
- package/rust/src/skills.rs +130 -0
- package/dist/chunk-04mj5ftg.js +0 -7
- package/dist/chunk-0jvfabsq.js +0 -2
- package/dist/chunk-107y8e8x.js +0 -2
- package/dist/chunk-22h5rh2h.js +0 -2
- package/dist/chunk-31yt34hy.js +0 -2
- package/dist/chunk-3hp5t5wf.js +0 -2
- package/dist/chunk-3jcx1ns0.js +0 -2
- package/dist/chunk-3jjc06nd.js +0 -3
- package/dist/chunk-3z8ajtxp.js +0 -2
- package/dist/chunk-4b3g7acq.js +0 -2
- package/dist/chunk-4jkg9p4g.js +0 -2
- package/dist/chunk-4xmbve71.js +0 -4
- package/dist/chunk-54qxv3er.js +0 -2
- package/dist/chunk-5bz1bzsw.js +0 -2
- package/dist/chunk-5dk4xga8.js +0 -2
- package/dist/chunk-5my9w4vd.js +0 -2
- package/dist/chunk-5tqygmg9.js +0 -2
- package/dist/chunk-7dd374an.js +0 -2
- package/dist/chunk-7s7txz2j.js +0 -2
- package/dist/chunk-8hbwf0qe.js +0 -2
- package/dist/chunk-8yj3q7n2.js +0 -2
- package/dist/chunk-9eqezb4k.js +0 -2
- package/dist/chunk-9xfv8jdn.js +0 -2
- package/dist/chunk-a3s36z4s.js +0 -3
- package/dist/chunk-a414w7ah.js +0 -3
- package/dist/chunk-am6tss41.js +0 -2
- package/dist/chunk-b65w6x23.js +0 -2
- package/dist/chunk-cv2j9sjp.js +0 -2
- package/dist/chunk-d1trg76g.js +0 -2
- package/dist/chunk-dgm4gxkj.js +0 -2
- package/dist/chunk-e6ddpdxn.js +0 -2
- package/dist/chunk-e9znmqdj.js +0 -2
- package/dist/chunk-eyfdn4p3.js +0 -2
- package/dist/chunk-fcqwzmkd.js +0 -2
- package/dist/chunk-fkwafga0.js +0 -2
- package/dist/chunk-gap8n0vv.js +0 -5
- package/dist/chunk-j5rd55qs.js +0 -3
- package/dist/chunk-j9q2s4kq.js +0 -2
- package/dist/chunk-jnena0v6.js +0 -2
- package/dist/chunk-kjswq0tx.js +0 -2
- package/dist/chunk-kkps1qd4.js +0 -4
- package/dist/chunk-mpnv2rht.js +0 -2
- package/dist/chunk-mtydzse4.js +0 -2
- package/dist/chunk-mw9k08ky.js +0 -3
- package/dist/chunk-px6nrr87.js +0 -2
- package/dist/chunk-pzmd5d3m.js +0 -2
- package/dist/chunk-q5az5kp2.js +0 -4
- package/dist/chunk-qqm07rfv.js +0 -2
- package/dist/chunk-qv7kkv47.js +0 -2
- package/dist/chunk-rq04p6pn.js +0 -3
- package/dist/chunk-rx9sdjtn.js +0 -2
- package/dist/chunk-s0b5g8nc.js +0 -2
- package/dist/chunk-sf1z4r7v.js +0 -2
- package/dist/chunk-syp06z39.js +0 -2
- package/dist/chunk-t6cfjn19.js +0 -2
- package/dist/chunk-vsff9djs.js +0 -2
- package/dist/chunk-vvq50011.js +0 -2
- package/dist/chunk-wkvm8f2e.js +0 -2
- package/dist/chunk-ww223tm5.js +0 -2
- package/dist/chunk-x0tbzjqc.js +0 -2
- package/dist/chunk-x480gyp7.js +0 -2
- package/dist/chunk-yjhypkmc.js +0 -2
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
//! Account-owned gateway configuration and revocation. Secrets never cross the webview boundary.
|
|
2
|
+
//! The host owns the account: it binds the signed-in identity and passes a fresh access token for
|
|
3
|
+
//! each refresh. An application without an ALwith account never calls these commands.
|
|
4
|
+
use super::*;
|
|
5
|
+
use std::sync::Mutex;
|
|
6
|
+
use std::time::Duration;
|
|
7
|
+
|
|
8
|
+
pub const ID: &str = "litellm";
|
|
9
|
+
const MODEL_PREFIX: &str = "gateway:litellm:";
|
|
10
|
+
|
|
11
|
+
/// Sessions whose account model is no longer available; the payload is a [`RevokedSessions`].
|
|
12
|
+
pub const REVOKED_EVENT: &str = "providers:managed-revoked";
|
|
13
|
+
|
|
14
|
+
#[derive(Clone, Serialize)]
|
|
15
|
+
#[serde(rename_all = "camelCase")]
|
|
16
|
+
pub struct RevokedSessions {
|
|
17
|
+
session_ids: Vec<String>,
|
|
18
|
+
}
|
|
19
|
+
impl RevokedSessions {
|
|
20
|
+
fn emit(&self, app: &AppHandle) {
|
|
21
|
+
if let Err(error) = app.emit(REVOKED_EVENT, self) {
|
|
22
|
+
log::warn!("Provider catalog: cannot emit {REVOKED_EVENT}: {error}");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
28
|
+
pub(super) struct Cache {
|
|
29
|
+
pub account: Account,
|
|
30
|
+
pub provider: Option<CustomProvider>,
|
|
31
|
+
}
|
|
32
|
+
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
33
|
+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
34
|
+
pub struct Account {
|
|
35
|
+
pub api_base_url: String,
|
|
36
|
+
pub user_uuid: String,
|
|
37
|
+
}
|
|
38
|
+
#[derive(Default)]
|
|
39
|
+
pub(super) struct Gate {
|
|
40
|
+
pub generation: u64,
|
|
41
|
+
pub account: Option<Account>,
|
|
42
|
+
pub targets: BTreeSet<String>,
|
|
43
|
+
pub routes: BTreeMap<String, Route>,
|
|
44
|
+
pub models: BTreeSet<String>,
|
|
45
|
+
pub realtime: BTreeMap<String, String>,
|
|
46
|
+
}
|
|
47
|
+
#[derive(Clone)]
|
|
48
|
+
pub(super) struct Route {
|
|
49
|
+
pub model: String,
|
|
50
|
+
pub agent: String,
|
|
51
|
+
pub generation: u64,
|
|
52
|
+
}
|
|
53
|
+
impl Gate {
|
|
54
|
+
fn invalidate(&mut self) -> Result<(), String> {
|
|
55
|
+
self.generation = self.generation.checked_add(1).ok_or("Account generation exhausted")?;
|
|
56
|
+
self.account = None;
|
|
57
|
+
self.models.clear();
|
|
58
|
+
Ok(())
|
|
59
|
+
}
|
|
60
|
+
fn check_selection(&self, requested: Option<&str>, session: Option<&str>) -> Result<(), String> {
|
|
61
|
+
if let Some(model) = requested
|
|
62
|
+
&& model.starts_with(MODEL_PREFIX)
|
|
63
|
+
&& (self.account.is_none() || !self.models.contains(model))
|
|
64
|
+
{
|
|
65
|
+
return Err("The selected ALwith account model is unavailable".into());
|
|
66
|
+
}
|
|
67
|
+
if let Some(route) = session.and_then(|session| self.routes.get(session))
|
|
68
|
+
&& (self.account.is_none() || route.generation != self.generation || !self.models.contains(&route.model))
|
|
69
|
+
{
|
|
70
|
+
return Err("The ALwith account changed. Select a model before sending".into());
|
|
71
|
+
}
|
|
72
|
+
Ok(())
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
fn model_ids(provider: Option<&CustomProvider>) -> BTreeSet<String> {
|
|
76
|
+
provider
|
|
77
|
+
.into_iter()
|
|
78
|
+
.flat_map(|provider| provider.models.iter())
|
|
79
|
+
.map(|model| {
|
|
80
|
+
let encoded: String = url_model_id(&model.api_id);
|
|
81
|
+
format!("{MODEL_PREFIX}{encoded}")
|
|
82
|
+
})
|
|
83
|
+
.collect()
|
|
84
|
+
}
|
|
85
|
+
fn url_model_id(id: &str) -> String {
|
|
86
|
+
// encodeURIComponent's unescaped bytes, matching gatewayModelId in the adapter.
|
|
87
|
+
id.as_bytes()
|
|
88
|
+
.iter()
|
|
89
|
+
.map(|byte| {
|
|
90
|
+
if byte.is_ascii_alphanumeric() || b"-_.!~*'()".contains(byte) {
|
|
91
|
+
(*byte as char).to_string()
|
|
92
|
+
} else {
|
|
93
|
+
format!("%{byte:02X}")
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
.collect()
|
|
97
|
+
}
|
|
98
|
+
#[derive(Default)]
|
|
99
|
+
pub(super) struct State {
|
|
100
|
+
pub gate: Mutex<Gate>,
|
|
101
|
+
pub transition: tokio::sync::Mutex<()>,
|
|
102
|
+
pub refresh: tokio::sync::Mutex<()>,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#[derive(Deserialize)]
|
|
106
|
+
struct IssuedProvider {
|
|
107
|
+
name: String,
|
|
108
|
+
base_url: String,
|
|
109
|
+
api_key: String,
|
|
110
|
+
#[serde(default)]
|
|
111
|
+
hidden: bool,
|
|
112
|
+
models: Vec<IssuedModel>,
|
|
113
|
+
}
|
|
114
|
+
#[derive(Deserialize)]
|
|
115
|
+
struct IssuedModel {
|
|
116
|
+
api_id: String,
|
|
117
|
+
label: String,
|
|
118
|
+
context_window: Option<u64>,
|
|
119
|
+
description: Option<String>,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
pub(super) fn parse_catalog(body: &str) -> Result<Option<CustomProvider>, String> {
|
|
123
|
+
let rows: Vec<Value> = serde_json::from_str(body).map_err(|_| "Invalid ALwith provider response")?;
|
|
124
|
+
let mut selected = rows.into_iter().filter(|row| row["provider_id"] == ID);
|
|
125
|
+
let Some(value) = selected.next() else { return Ok(None) };
|
|
126
|
+
if selected.next().is_some() {
|
|
127
|
+
return Err("Duplicate ALwith provider".into());
|
|
128
|
+
}
|
|
129
|
+
if value["api_key"].as_str().is_none_or(|key| key.trim().is_empty()) {
|
|
130
|
+
return Ok(None);
|
|
131
|
+
}
|
|
132
|
+
let provider: IssuedProvider = serde_json::from_value(value).map_err(|_| "Invalid ALwith provider metadata")?;
|
|
133
|
+
if provider.hidden {
|
|
134
|
+
return Ok(None);
|
|
135
|
+
}
|
|
136
|
+
let mut ids = BTreeSet::new();
|
|
137
|
+
let models = provider
|
|
138
|
+
.models
|
|
139
|
+
.into_iter()
|
|
140
|
+
.map(|model| {
|
|
141
|
+
if model.api_id.trim().is_empty()
|
|
142
|
+
|| model.label.trim().is_empty()
|
|
143
|
+
|| model.context_window == Some(0)
|
|
144
|
+
|| !ids.insert(model.api_id.clone())
|
|
145
|
+
{
|
|
146
|
+
return Err("Invalid or duplicate ALwith model metadata".to_string());
|
|
147
|
+
}
|
|
148
|
+
Ok(CustomModel {
|
|
149
|
+
api_id: model.api_id,
|
|
150
|
+
label: model.label,
|
|
151
|
+
context_window: model.context_window,
|
|
152
|
+
description: model.description,
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
156
|
+
if models.is_empty() {
|
|
157
|
+
return Ok(None);
|
|
158
|
+
}
|
|
159
|
+
if provider.name.trim().is_empty() {
|
|
160
|
+
return Err("Missing ALwith provider name".into());
|
|
161
|
+
}
|
|
162
|
+
Ok(Some(CustomProvider {
|
|
163
|
+
id: ID.into(),
|
|
164
|
+
name: provider.name,
|
|
165
|
+
base_url: responses_base_url(&provider.base_url)?,
|
|
166
|
+
models,
|
|
167
|
+
api_key: provider.api_key,
|
|
168
|
+
}))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
fn responses_base_url(raw: &str) -> Result<String, String> {
|
|
172
|
+
// Account-issued gateways may use internal HTTP, as in the supported /v1/responses contract.
|
|
173
|
+
let url = reqwest::Url::parse(raw.trim()).map_err(|_| "Invalid ALwith gateway URL")?;
|
|
174
|
+
if !matches!(url.scheme(), "http" | "https")
|
|
175
|
+
|| url.host_str().is_none()
|
|
176
|
+
|| url.query().is_some()
|
|
177
|
+
|| url.fragment().is_some()
|
|
178
|
+
|| !url.username().is_empty()
|
|
179
|
+
|| url.password().is_some()
|
|
180
|
+
{
|
|
181
|
+
return Err("Invalid ALwith gateway URL".into());
|
|
182
|
+
}
|
|
183
|
+
let base = url.as_str().trim_end_matches('/').to_string();
|
|
184
|
+
match url.path().trim_end_matches('/') {
|
|
185
|
+
"" => Ok(format!("{base}/v1")),
|
|
186
|
+
path if path.ends_with("/v1") => Ok(base),
|
|
187
|
+
_ => Err("ALwith gateway must supply a root URL or an API base ending in /v1".into()),
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
fn main_window(window: &tauri::WebviewWindow) -> Result<(), String> {
|
|
192
|
+
if window.label() != "main" {
|
|
193
|
+
return Err("ALwith account changes belong to the main window".into());
|
|
194
|
+
}
|
|
195
|
+
Ok(())
|
|
196
|
+
}
|
|
197
|
+
fn validate_account(account: &Account) -> Result<(), String> {
|
|
198
|
+
if !matches!(account.api_base_url.as_str(), "https://api.alwith.ai/service" | "https://api-dev.alwith.ai/service")
|
|
199
|
+
|| account.user_uuid.trim().is_empty()
|
|
200
|
+
{
|
|
201
|
+
return Err("Invalid ALwith account identity".into());
|
|
202
|
+
}
|
|
203
|
+
Ok(())
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#[tauri::command]
|
|
207
|
+
pub(crate) async fn providers_account_bind(window: tauri::WebviewWindow, account: Account) -> Result<u64, String> {
|
|
208
|
+
main_window(&window)?;
|
|
209
|
+
validate_account(&account)?;
|
|
210
|
+
let app = window.app_handle();
|
|
211
|
+
let state = app.state::<Providers>();
|
|
212
|
+
let _transition = state.managed.transition.lock().await;
|
|
213
|
+
let mut inner = state.inner.lock().await;
|
|
214
|
+
let generation = {
|
|
215
|
+
let mut gate = state.managed.gate.lock().unwrap();
|
|
216
|
+
if gate.account.as_ref() == Some(&account) {
|
|
217
|
+
return Ok(gate.generation);
|
|
218
|
+
}
|
|
219
|
+
if !gate.targets.is_empty() {
|
|
220
|
+
return Err("Previous ALwith provider cleanup is incomplete; retry logout".into());
|
|
221
|
+
}
|
|
222
|
+
gate.generation = gate.generation.checked_add(1).ok_or("Account generation exhausted")?;
|
|
223
|
+
gate.account = Some(account.clone());
|
|
224
|
+
gate.generation
|
|
225
|
+
};
|
|
226
|
+
inner.managed_active = inner.saved.managed.as_ref().is_some_and(|cache| cache.account == account);
|
|
227
|
+
state.managed.gate.lock().unwrap().models = if inner.managed_active {
|
|
228
|
+
model_ids(inner.saved.managed.as_ref().and_then(|cache| cache.provider.as_ref()))
|
|
229
|
+
} else {
|
|
230
|
+
BTreeSet::new()
|
|
231
|
+
};
|
|
232
|
+
inner.applied_revision = None;
|
|
233
|
+
emit(app, &inner.snapshot());
|
|
234
|
+
Ok(generation)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
#[tauri::command]
|
|
238
|
+
pub(crate) async fn providers_refresh_managed(
|
|
239
|
+
window: tauri::WebviewWindow, generation: u64, access_token: String,
|
|
240
|
+
) -> Result<Snapshot, Value> {
|
|
241
|
+
main_window(&window).map_err(|message| json!({"message":message}))?;
|
|
242
|
+
let app = window.app_handle();
|
|
243
|
+
let state = app.state::<Providers>();
|
|
244
|
+
let _refresh = state.managed.refresh.lock().await;
|
|
245
|
+
let account = {
|
|
246
|
+
let gate = state.managed.gate.lock().unwrap();
|
|
247
|
+
if gate.generation != generation {
|
|
248
|
+
return Err(json!({"message":"ALwith account changed"}));
|
|
249
|
+
}
|
|
250
|
+
gate.account.clone().ok_or_else(|| json!({"message":"Sign in before loading ALwith models"}))?
|
|
251
|
+
};
|
|
252
|
+
if access_token.trim().is_empty() {
|
|
253
|
+
return Err(json!({"message":"Missing ALwith access token"}));
|
|
254
|
+
}
|
|
255
|
+
let result = fetch_catalog(&account.api_base_url, &access_token).await;
|
|
256
|
+
let mut inner = state.inner.lock().await;
|
|
257
|
+
{
|
|
258
|
+
let mut gate = state.managed.gate.lock().unwrap();
|
|
259
|
+
if gate.generation != generation || gate.account.as_ref() != Some(&account) {
|
|
260
|
+
return Err(json!({"message":"ALwith account changed during refresh"}));
|
|
261
|
+
}
|
|
262
|
+
let provider = match result {
|
|
263
|
+
Ok(provider) => provider,
|
|
264
|
+
Err(error) => {
|
|
265
|
+
inner.error = Some("ALwith model configuration refresh failed".into());
|
|
266
|
+
emit(app, &inner.snapshot());
|
|
267
|
+
return Err(error);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
let mut next = inner.saved.clone();
|
|
271
|
+
next.managed = Some(Cache { account, provider });
|
|
272
|
+
next.revision = next.revision.checked_add(1).ok_or_else(|| json!({"message":"Provider revision exhausted"}))?;
|
|
273
|
+
persist(&state.path, &next).map_err(|_| json!({"message":"Cannot save ALwith model configuration"}))?;
|
|
274
|
+
gate.models = model_ids(next.managed.as_ref().and_then(|cache| cache.provider.as_ref()));
|
|
275
|
+
RevokedSessions {
|
|
276
|
+
session_ids: gate
|
|
277
|
+
.routes
|
|
278
|
+
.iter()
|
|
279
|
+
.filter(|(_, route)| !gate.models.contains(&route.model))
|
|
280
|
+
.map(|(id, _)| id.clone())
|
|
281
|
+
.collect(),
|
|
282
|
+
}
|
|
283
|
+
.emit(app);
|
|
284
|
+
inner.saved = next;
|
|
285
|
+
inner.managed_active = true;
|
|
286
|
+
inner.error = None;
|
|
287
|
+
}
|
|
288
|
+
let snapshot = inner.snapshot();
|
|
289
|
+
emit(app, &snapshot);
|
|
290
|
+
drop(inner);
|
|
291
|
+
schedule_apply(app);
|
|
292
|
+
Ok(snapshot)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async fn fetch_catalog(base: &str, token: &str) -> Result<Option<CustomProvider>, Value> {
|
|
296
|
+
let client = reqwest::Client::builder()
|
|
297
|
+
.timeout(Duration::from_secs(20))
|
|
298
|
+
.redirect(reqwest::redirect::Policy::none())
|
|
299
|
+
.build()
|
|
300
|
+
.map_err(|_| json!({"message":"Cannot create ALwith configuration client"}))?;
|
|
301
|
+
let response = client
|
|
302
|
+
.get(format!("{base}/api/v1/providers"))
|
|
303
|
+
.bearer_auth(token)
|
|
304
|
+
.send()
|
|
305
|
+
.await
|
|
306
|
+
.map_err(|_| json!({"message":"ALwith configuration request failed"}))?;
|
|
307
|
+
if !response.status().is_success() {
|
|
308
|
+
return Err(json!({"status":response.status().as_u16(),"message":"ALwith configuration request rejected"}));
|
|
309
|
+
}
|
|
310
|
+
let body = response.text().await.map_err(|_| json!({"message":"Cannot read ALwith configuration response"}))?;
|
|
311
|
+
parse_catalog(&body).map_err(|message| json!({"message":message}))
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
#[tauri::command]
|
|
315
|
+
pub(crate) async fn providers_clear_managed(window: tauri::WebviewWindow) -> Result<(), String> {
|
|
316
|
+
main_window(&window)?;
|
|
317
|
+
clear(window.app_handle()).await
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
pub(super) async fn clear(app: &AppHandle) -> Result<(), String> {
|
|
321
|
+
let state = app.state::<Providers>();
|
|
322
|
+
// Invalidate before waiting for any network operation or admission lock.
|
|
323
|
+
{
|
|
324
|
+
let mut gate = state.managed.gate.lock().unwrap();
|
|
325
|
+
gate.invalidate()?;
|
|
326
|
+
RevokedSessions { session_ids: gate.routes.keys().cloned().collect() }.emit(app);
|
|
327
|
+
}
|
|
328
|
+
let _transition = tokio::time::timeout(Duration::from_secs(10), state.managed.transition.lock())
|
|
329
|
+
.await
|
|
330
|
+
.map_err(|_| "ALwith account transition did not settle; cleanup is incomplete")?;
|
|
331
|
+
state.managed.gate.lock().unwrap().invalidate()?;
|
|
332
|
+
let saved_error = {
|
|
333
|
+
let mut inner = tokio::time::timeout(Duration::from_secs(10), state.inner.lock())
|
|
334
|
+
.await
|
|
335
|
+
.map_err(|_| "ALwith provider configuration did not settle; cleanup is incomplete")?;
|
|
336
|
+
inner.managed_active = false;
|
|
337
|
+
inner.applied_revision = None;
|
|
338
|
+
inner.saved.managed = None;
|
|
339
|
+
inner.saved.revision = inner.saved.revision.checked_add(1).ok_or("Provider revision exhausted")?;
|
|
340
|
+
let error = persist(&state.path, &inner.saved).err();
|
|
341
|
+
emit(app, &inner.snapshot());
|
|
342
|
+
error
|
|
343
|
+
};
|
|
344
|
+
let cleanup = cleanup(app).await;
|
|
345
|
+
if let Some(error) = saved_error {
|
|
346
|
+
return Err(error);
|
|
347
|
+
}
|
|
348
|
+
cleanup
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
pub(super) async fn cleanup(app: &AppHandle) -> Result<(), String> {
|
|
352
|
+
tokio::time::timeout(Duration::from_secs(30), cleanup_inner(app))
|
|
353
|
+
.await
|
|
354
|
+
.map_err(|_| "ALwith provider cleanup timed out; execution remains blocked")?
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async fn cleanup_inner(app: &AppHandle) -> Result<(), String> {
|
|
358
|
+
let state = app.state::<Providers>();
|
|
359
|
+
{
|
|
360
|
+
let gate = state.managed.gate.lock().unwrap();
|
|
361
|
+
if gate.account.is_some() || gate.targets.is_empty() {
|
|
362
|
+
return Ok(());
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
let runtime = &state.runtime;
|
|
366
|
+
let client = runtime.current(app).map_err(|_| "Runtime unavailable; ALwith cleanup is unconfirmed")?;
|
|
367
|
+
// Drain accepted lifecycle/configuration operations before taking the cancellation snapshot.
|
|
368
|
+
// New requests see the invalid gate. Never hold admission while waiting for turn termination.
|
|
369
|
+
let admission = tokio::time::timeout(Duration::from_secs(10), runtime.admission(app).lock())
|
|
370
|
+
.await
|
|
371
|
+
.map_err(|_| "ALwith request admission did not settle")?;
|
|
372
|
+
let (targets, routes, realtime) = {
|
|
373
|
+
let gate = state.managed.gate.lock().unwrap();
|
|
374
|
+
(gate.targets.clone(), gate.routes.clone(), gate.realtime.clone())
|
|
375
|
+
};
|
|
376
|
+
drop(admission);
|
|
377
|
+
let result = tokio::time::timeout(Duration::from_secs(10), async {
|
|
378
|
+
for (session, agent) in &realtime {
|
|
379
|
+
client
|
|
380
|
+
.acp_request(agent, "_codex/realtime/stop", json!({"sessionId":session}), None, None)
|
|
381
|
+
.await
|
|
382
|
+
.map_err(|error| format!("ALwith Runtime cleanup failed ({})", error.code))?;
|
|
383
|
+
state.managed.gate.lock().unwrap().realtime.remove(session);
|
|
384
|
+
}
|
|
385
|
+
for session in
|
|
386
|
+
client.run_states().await.map_err(|error| format!("ALwith Runtime cleanup failed ({})", error.code))?
|
|
387
|
+
{
|
|
388
|
+
if matches!(session.state, alwith_api::RunState::Running | alwith_api::RunState::RequiresAction)
|
|
389
|
+
&& let Some(route) = routes.get(&session.session_id)
|
|
390
|
+
{
|
|
391
|
+
client
|
|
392
|
+
.cancel(&route.agent, &session.session_id, None)
|
|
393
|
+
.await
|
|
394
|
+
.map_err(|error| format!("ALwith Runtime cleanup failed ({})", error.code))?;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
loop {
|
|
398
|
+
let active =
|
|
399
|
+
client.run_states().await.map_err(|error| format!("ALwith Runtime cleanup failed ({})", error.code))?;
|
|
400
|
+
if !active.iter().any(|session| {
|
|
401
|
+
routes.contains_key(&session.session_id)
|
|
402
|
+
&& matches!(session.state, alwith_api::RunState::Running | alwith_api::RunState::RequiresAction)
|
|
403
|
+
}) {
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
tokio::time::sleep(Duration::from_millis(50)).await;
|
|
407
|
+
}
|
|
408
|
+
Ok::<(), String>(())
|
|
409
|
+
})
|
|
410
|
+
.await
|
|
411
|
+
.map_err(|_| "ALwith turn cancellation timed out".to_string())
|
|
412
|
+
.and_then(|result| result);
|
|
413
|
+
if let Err(error) = result {
|
|
414
|
+
// Dedicated auxiliary agents can be stopped without interrupting unrelated main conversations.
|
|
415
|
+
for target in targets.iter().filter(|target| target.as_str() != MAIN_AGENT) {
|
|
416
|
+
if stop_dedicated(&client, target).await
|
|
417
|
+
&& runtime.current(app).is_ok_and(|current| Arc::ptr_eq(¤t, &client))
|
|
418
|
+
{
|
|
419
|
+
state.managed.gate.lock().unwrap().targets.remove(target);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return Err(error);
|
|
423
|
+
}
|
|
424
|
+
for target in targets {
|
|
425
|
+
let live = client.agents().await.map_err(|error| format!("ALwith Runtime cleanup failed ({})", error.code))?;
|
|
426
|
+
if live.iter().any(|agent| agent["agentId"] == target) {
|
|
427
|
+
let removed = tokio::time::timeout(
|
|
428
|
+
Duration::from_secs(10),
|
|
429
|
+
client.acp_request(
|
|
430
|
+
&target,
|
|
431
|
+
"providers/disable",
|
|
432
|
+
json!({"providerId":"openai","_meta":{"codex":{"id":ID}}}),
|
|
433
|
+
None,
|
|
434
|
+
None,
|
|
435
|
+
),
|
|
436
|
+
)
|
|
437
|
+
.await;
|
|
438
|
+
if !matches!(removed, Ok(Ok(_))) && !stop_dedicated(&client, &target).await {
|
|
439
|
+
return Err("ALwith provider cleanup is incomplete; wait for active sessions and retry".into());
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
// A stale Runtime cannot acknowledge cleanup for its replacement.
|
|
443
|
+
if !runtime.current(app).is_ok_and(|current| Arc::ptr_eq(¤t, &client)) {
|
|
444
|
+
return Err("Runtime changed during ALwith cleanup".into());
|
|
445
|
+
}
|
|
446
|
+
state.managed.gate.lock().unwrap().targets.remove(&target);
|
|
447
|
+
if target == MAIN_AGENT {
|
|
448
|
+
let mut inner = state.inner.lock().await;
|
|
449
|
+
inner.applied.remove(ID);
|
|
450
|
+
inner.applied_revision = None;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
Ok(())
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
async fn stop_dedicated(client: &RuntimeClient, target: &str) -> bool {
|
|
457
|
+
if target == MAIN_AGENT {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
matches!(
|
|
461
|
+
tokio::time::timeout(Duration::from_secs(5), async {
|
|
462
|
+
client.stop(target, None).await?;
|
|
463
|
+
let live = client.agents().await?;
|
|
464
|
+
Ok::<bool, ResponseError>(!live.iter().any(|agent| agent["agentId"] == target))
|
|
465
|
+
})
|
|
466
|
+
.await,
|
|
467
|
+
Ok(Ok(true))
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
pub(super) fn selected_model(value: &Value) -> Option<&str> {
|
|
472
|
+
value
|
|
473
|
+
.get("configOptions")?
|
|
474
|
+
.as_array()?
|
|
475
|
+
.iter()
|
|
476
|
+
.find(|option| option["category"] == "model" || option["configId"] == "model")?
|
|
477
|
+
.get("currentValue")?
|
|
478
|
+
.as_str()
|
|
479
|
+
}
|
|
480
|
+
pub fn observe(app: &AppHandle, agent: &str, session: &str, value: &Value, admitted_generation: Option<u64>) {
|
|
481
|
+
let Some(model) = selected_model(value) else { return };
|
|
482
|
+
let state = app.state::<Providers>();
|
|
483
|
+
let mut gate = state.managed.gate.lock().unwrap();
|
|
484
|
+
if model.starts_with(MODEL_PREFIX) {
|
|
485
|
+
let generation = admitted_generation.unwrap_or(gate.generation);
|
|
486
|
+
if admitted_generation.is_some() || !gate.routes.contains_key(session) {
|
|
487
|
+
gate.routes.insert(session.into(), Route { agent: agent.into(), generation, model: model.into() });
|
|
488
|
+
if gate.account.is_none() || generation != gate.generation || !gate.models.contains(model) {
|
|
489
|
+
RevokedSessions { session_ids: vec![session.into()] }.emit(app);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
} else if admitted_generation == Some(gate.generation) {
|
|
493
|
+
gate.routes.remove(session);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
pub fn observe_event(app: &AppHandle, event: &alwith_api::RuntimeEvent) {
|
|
498
|
+
match event {
|
|
499
|
+
alwith_api::RuntimeEvent::AcpNotification { method, params, .. }
|
|
500
|
+
if method == "_codex/realtime/update" && params["event"] == "closed" =>
|
|
501
|
+
{
|
|
502
|
+
if let Some(session) = params["sessionId"].as_str() {
|
|
503
|
+
app.state::<Providers>().managed.gate.lock().unwrap().realtime.remove(session);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
alwith_api::RuntimeEvent::AcpNotification { agent_id, method, params, .. } if method == "session/update" => {
|
|
507
|
+
if let Some(session) = params["sessionId"].as_str() {
|
|
508
|
+
observe(app, agent_id, session, ¶ms["update"], None);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
alwith_api::RuntimeEvent::Inbound { agent_id, lines } => {
|
|
512
|
+
for line in lines {
|
|
513
|
+
if let Ok(frame) = serde_json::from_str::<Value>(line)
|
|
514
|
+
&& frame["method"] == "session/update"
|
|
515
|
+
&& let Some(session) = frame["params"]["sessionId"].as_str()
|
|
516
|
+
{
|
|
517
|
+
observe(app, agent_id, session, &frame["params"]["update"], None);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
alwith_api::RuntimeEvent::Exit { agent_id } => {
|
|
522
|
+
let state = app.state::<Providers>();
|
|
523
|
+
let mut gate = state.managed.gate.lock().unwrap();
|
|
524
|
+
gate.targets.remove(agent_id);
|
|
525
|
+
gate.realtime.retain(|_, agent| agent != agent_id);
|
|
526
|
+
// Keep revoked selections across adapter restarts until explicit reselection.
|
|
527
|
+
}
|
|
528
|
+
_ => {}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/// All webview request shapes pass here, including drafts and raw ACP configuration changes.
|
|
533
|
+
pub fn check(app: &AppHandle, method: &str, params: Option<&Value>) -> Result<u64, String> {
|
|
534
|
+
let state = app.state::<Providers>();
|
|
535
|
+
let gate = state.managed.gate.lock().unwrap();
|
|
536
|
+
if method == "send" {
|
|
537
|
+
return Err("Use structured Runtime requests for session operations".into());
|
|
538
|
+
}
|
|
539
|
+
let Some(params) = params else { return Ok(gate.generation) };
|
|
540
|
+
let (method, body) = if matches!(method, "acpRequest" | "acpNotify") {
|
|
541
|
+
(params["method"].as_str().unwrap_or(""), ¶ms["params"])
|
|
542
|
+
} else {
|
|
543
|
+
(method, params)
|
|
544
|
+
};
|
|
545
|
+
check_request(&gate, method, body)?;
|
|
546
|
+
Ok(gate.generation)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
pub fn requires_admission(method: &str, params: Option<&Value>) -> bool {
|
|
550
|
+
let Some(params) = params else { return false };
|
|
551
|
+
matches!(method, "acpRequest" | "acpNotify")
|
|
552
|
+
&& matches!(
|
|
553
|
+
params["method"].as_str(),
|
|
554
|
+
Some(
|
|
555
|
+
"_session/steering"
|
|
556
|
+
| "_session/goal"
|
|
557
|
+
| "_codex/session/goal_control"
|
|
558
|
+
| "_codex/session_retry"
|
|
559
|
+
| "_codex/session_prediction_request"
|
|
560
|
+
| "_codex/realtime/start"
|
|
561
|
+
| "_codex/realtime/appendAudio"
|
|
562
|
+
| "_codex/realtime/appendText"
|
|
563
|
+
| "_codex/realtime/appendSpeech"
|
|
564
|
+
)
|
|
565
|
+
)
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
pub fn observe_realtime(app: &AppHandle, method: &str, params: &Value) {
|
|
569
|
+
if method != "acpRequest" {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
let Some(session) = params["params"]["sessionId"].as_str() else {
|
|
573
|
+
return;
|
|
574
|
+
};
|
|
575
|
+
let state = app.state::<Providers>();
|
|
576
|
+
let mut gate = state.managed.gate.lock().unwrap();
|
|
577
|
+
match params["method"].as_str() {
|
|
578
|
+
Some("_codex/realtime/start") => {
|
|
579
|
+
if let Some(route) = gate.routes.get(session) {
|
|
580
|
+
let agent = route.agent.clone();
|
|
581
|
+
gate.realtime.insert(session.into(), agent);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
Some("_codex/realtime/stop") => {
|
|
585
|
+
gate.realtime.remove(session);
|
|
586
|
+
}
|
|
587
|
+
_ => {}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
pub fn confirms_model(method: &str, params: &Value) -> bool {
|
|
592
|
+
let (method, body) = if matches!(method, "acpRequest" | "acpNotify") {
|
|
593
|
+
(params["method"].as_str().unwrap_or(""), ¶ms["params"])
|
|
594
|
+
} else {
|
|
595
|
+
(method, params)
|
|
596
|
+
};
|
|
597
|
+
matches!(
|
|
598
|
+
method,
|
|
599
|
+
"sessionNew"
|
|
600
|
+
| "session/new"
|
|
601
|
+
| "sessionResume"
|
|
602
|
+
| "session/resume"
|
|
603
|
+
| "sessionLoad"
|
|
604
|
+
| "session/load"
|
|
605
|
+
| "sessionFork"
|
|
606
|
+
| "session/fork"
|
|
607
|
+
) || (method == "session/set_config_option" && body["configId"] == "model")
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
fn check_request(gate: &Gate, method: &str, body: &Value) -> Result<(), String> {
|
|
611
|
+
let selection = method == "session/set_config_option" && body["configId"] == "model";
|
|
612
|
+
let lifecycle = matches!(
|
|
613
|
+
method,
|
|
614
|
+
"sessionNew"
|
|
615
|
+
| "session/new"
|
|
616
|
+
| "sessionResume"
|
|
617
|
+
| "session/resume"
|
|
618
|
+
| "sessionLoad"
|
|
619
|
+
| "session/load"
|
|
620
|
+
| "sessionFork"
|
|
621
|
+
| "session/fork"
|
|
622
|
+
);
|
|
623
|
+
let execution = matches!(
|
|
624
|
+
method,
|
|
625
|
+
"prompt"
|
|
626
|
+
| "session/prompt"
|
|
627
|
+
| "_session/steering"
|
|
628
|
+
| "_session/goal"
|
|
629
|
+
| "_codex/session/goal_control"
|
|
630
|
+
| "_codex/session_retry"
|
|
631
|
+
| "_codex/session_prediction_request"
|
|
632
|
+
| "_codex/realtime/start"
|
|
633
|
+
| "_codex/realtime/appendAudio"
|
|
634
|
+
| "_codex/realtime/appendText"
|
|
635
|
+
| "_codex/realtime/appendSpeech"
|
|
636
|
+
);
|
|
637
|
+
if !(method == "session/set_config_option" || lifecycle || execution) {
|
|
638
|
+
return Ok(());
|
|
639
|
+
}
|
|
640
|
+
let explicit_resume = matches!(method, "sessionResume" | "session/resume")
|
|
641
|
+
&& (body
|
|
642
|
+
.pointer("/_meta/alwith/accountModelSelection")
|
|
643
|
+
.or_else(|| body.pointer("/meta/alwith/accountModelSelection"))
|
|
644
|
+
== Some(&Value::Bool(true)));
|
|
645
|
+
let requested = if selection {
|
|
646
|
+
body["value"].as_str()
|
|
647
|
+
} else if lifecycle {
|
|
648
|
+
body.pointer("/_meta/alwith/model").or_else(|| body.pointer("/meta/alwith/model")).and_then(Value::as_str)
|
|
649
|
+
} else {
|
|
650
|
+
None
|
|
651
|
+
};
|
|
652
|
+
// Prompt metadata is not a model selection. Only the adapter's explicit model option
|
|
653
|
+
// can authorize an old session under a new account.
|
|
654
|
+
if explicit_resume && requested.is_none() {
|
|
655
|
+
return Err("Explicit model recovery requires a model".into());
|
|
656
|
+
}
|
|
657
|
+
gate.check_selection(requested, if selection || explicit_resume { None } else { body["sessionId"].as_str() })
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
#[cfg(test)]
|
|
661
|
+
mod tests {
|
|
662
|
+
use super::*;
|
|
663
|
+
|
|
664
|
+
#[test]
|
|
665
|
+
fn revoked_route_cannot_send_under_a_replacement_account() {
|
|
666
|
+
let mut gate = Gate {
|
|
667
|
+
account: Some(Account { api_base_url: "https://api.alwith.ai/service".into(), user_uuid: "a".into() }),
|
|
668
|
+
generation: 1,
|
|
669
|
+
..Gate::default()
|
|
670
|
+
};
|
|
671
|
+
gate.models.insert("gateway:litellm:m".into());
|
|
672
|
+
gate.routes.insert(
|
|
673
|
+
"session".into(),
|
|
674
|
+
Route { agent: "codex".into(), generation: 1, model: "gateway:litellm:m".into() },
|
|
675
|
+
);
|
|
676
|
+
assert!(gate.check_selection(None, Some("session")).is_ok());
|
|
677
|
+
gate.invalidate().unwrap();
|
|
678
|
+
assert!(gate.check_selection(Some("gateway:litellm:m"), None).is_err());
|
|
679
|
+
gate.account = Some(Account { api_base_url: "https://api.alwith.ai/service".into(), user_uuid: "b".into() });
|
|
680
|
+
gate.models.insert("gateway:litellm:m".into());
|
|
681
|
+
assert!(gate.check_selection(None, Some("session")).is_err());
|
|
682
|
+
assert!(gate.check_selection(Some("gpt-native"), Some("session")).is_err());
|
|
683
|
+
// Only an explicit model selection validates the new model without inheriting the old route.
|
|
684
|
+
assert!(gate.check_selection(Some("gpt-native"), None).is_ok());
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
#[test]
|
|
688
|
+
fn automatic_model_hints_do_not_authorize_a_replacement_account() {
|
|
689
|
+
let mut gate = Gate {
|
|
690
|
+
account: Some(Account { api_base_url: "https://api.alwith.ai/service".into(), user_uuid: "b".into() }),
|
|
691
|
+
generation: 2,
|
|
692
|
+
..Gate::default()
|
|
693
|
+
};
|
|
694
|
+
let model = "gateway:litellm:m";
|
|
695
|
+
gate.models.insert(model.into());
|
|
696
|
+
gate.routes.insert("old".into(), Route { agent: "codex".into(), generation: 1, model: model.into() });
|
|
697
|
+
assert!(gate.check_selection(Some(model), Some("old")).is_err());
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
#[test]
|
|
701
|
+
fn execution_hints_cannot_bypass_revocation_and_explicit_selection_can_recover() {
|
|
702
|
+
let mut gate = Gate::default();
|
|
703
|
+
gate.routes
|
|
704
|
+
.insert("old".into(), Route { agent: "codex".into(), generation: 0, model: "gateway:litellm:m".into() });
|
|
705
|
+
let body = json!({"sessionId":"old", "_meta":{"alwith":{"model":"gpt-native"}}});
|
|
706
|
+
for method in [
|
|
707
|
+
"prompt",
|
|
708
|
+
"session/prompt",
|
|
709
|
+
"_session/steering",
|
|
710
|
+
"_session/goal",
|
|
711
|
+
"_codex/session/goal_control",
|
|
712
|
+
"_codex/session_retry",
|
|
713
|
+
"_codex/session_prediction_request",
|
|
714
|
+
"_codex/realtime/start",
|
|
715
|
+
"_codex/realtime/appendAudio",
|
|
716
|
+
"_codex/realtime/appendText",
|
|
717
|
+
"_codex/realtime/appendSpeech",
|
|
718
|
+
"sessionResume",
|
|
719
|
+
"session/resume",
|
|
720
|
+
"sessionFork",
|
|
721
|
+
"session/fork",
|
|
722
|
+
] {
|
|
723
|
+
assert!(check_request(&gate, method, &body).is_err(), "{method}");
|
|
724
|
+
}
|
|
725
|
+
assert!(
|
|
726
|
+
check_request(
|
|
727
|
+
&gate,
|
|
728
|
+
"session/set_config_option",
|
|
729
|
+
&json!({"sessionId":"old", "configId":"model", "value":"gpt-native"})
|
|
730
|
+
)
|
|
731
|
+
.is_ok()
|
|
732
|
+
);
|
|
733
|
+
assert!(
|
|
734
|
+
check_request(
|
|
735
|
+
&gate,
|
|
736
|
+
"session/set_config_option",
|
|
737
|
+
&json!({"sessionId":"old", "configId":"model", "value":"gateway:litellm:m"})
|
|
738
|
+
)
|
|
739
|
+
.is_err()
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
#[test]
|
|
744
|
+
fn explicit_resume_authorizes_only_a_valid_model_and_never_authorizes_prompt_metadata() {
|
|
745
|
+
let mut gate = Gate::default();
|
|
746
|
+
gate.routes
|
|
747
|
+
.insert("old".into(), Route { agent: "codex".into(), generation: 0, model: "gateway:litellm:m".into() });
|
|
748
|
+
let body = json!({"sessionId":"old", "_meta":{"alwith":{"model":"gpt-native", "accountModelSelection":true}}});
|
|
749
|
+
assert!(check_request(&gate, "session/resume", &body).is_ok());
|
|
750
|
+
assert!(check_request(&gate, "session/prompt", &body).is_err());
|
|
751
|
+
assert!(
|
|
752
|
+
check_request(
|
|
753
|
+
&gate,
|
|
754
|
+
"session/resume",
|
|
755
|
+
&json!({"sessionId":"old", "_meta":{"alwith":{"accountModelSelection":true}}})
|
|
756
|
+
)
|
|
757
|
+
.is_err()
|
|
758
|
+
);
|
|
759
|
+
assert!(check_request(&gate, "session/resume", &json!({"sessionId":"old", "_meta":{"alwith":{"accountModelSelection":true,"model":"gateway:litellm:m"}}})).is_err());
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
#[test]
|
|
763
|
+
fn changing_effort_is_not_an_account_model_selection() {
|
|
764
|
+
let mut gate = Gate::default();
|
|
765
|
+
gate.routes
|
|
766
|
+
.insert("old".into(), Route { agent: "codex".into(), generation: 0, model: "gateway:litellm:m".into() });
|
|
767
|
+
let body = json!({"sessionId":"old", "configId":"reasoning_effort", "value":"high"});
|
|
768
|
+
assert!(check_request(&gate, "session/set_config_option", &body).is_err());
|
|
769
|
+
assert!(!confirms_model("acpRequest", &json!({"method":"session/set_config_option", "params":body})));
|
|
770
|
+
assert!(confirms_model(
|
|
771
|
+
"acpRequest",
|
|
772
|
+
&json!({"method":"session/set_config_option", "params":{"configId":"model"}})
|
|
773
|
+
));
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
#[test]
|
|
777
|
+
fn responses_endpoint_accepts_root_or_versioned_base_without_guessing_other_paths() {
|
|
778
|
+
assert_eq!(responses_base_url("http://localhost:8080").unwrap(), "http://localhost:8080/v1");
|
|
779
|
+
assert_eq!(responses_base_url("http://gateway.internal:8080").unwrap(), "http://gateway.internal:8080/v1");
|
|
780
|
+
for invalid in ["file:///v1", "https://key@gateway.test/v1", "https://gateway.test/v1?key=secret"] {
|
|
781
|
+
assert!(responses_base_url(invalid).is_err());
|
|
782
|
+
}
|
|
783
|
+
assert_eq!(responses_base_url("https://gateway.test/v1/").unwrap(), "https://gateway.test/v1");
|
|
784
|
+
assert_eq!(responses_base_url("https://gateway.test/proxy/v1").unwrap(), "https://gateway.test/proxy/v1");
|
|
785
|
+
assert!(responses_base_url("https://gateway.test/proxy").is_err());
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
#[test]
|
|
789
|
+
fn removing_a_model_blocks_new_requests_on_its_existing_route() {
|
|
790
|
+
let mut gate = Gate {
|
|
791
|
+
account: Some(Account { api_base_url: "https://api.alwith.ai/service".into(), user_uuid: "a".into() }),
|
|
792
|
+
..Gate::default()
|
|
793
|
+
};
|
|
794
|
+
gate.routes.insert(
|
|
795
|
+
"session".into(),
|
|
796
|
+
Route { agent: "codex".into(), generation: 0, model: "gateway:litellm:removed".into() },
|
|
797
|
+
);
|
|
798
|
+
assert!(gate.check_selection(None, Some("session")).is_err());
|
|
799
|
+
assert!(gate.check_selection(Some("gateway:litellm:removed"), None).is_err());
|
|
800
|
+
}
|
|
801
|
+
}
|