synabun 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -0
- package/README.md +1 -1
- package/docs/whatsapp.md +11 -11
- package/lib/client-config-repair.js +13 -9
- package/lib/external-tools.js +6 -5
- package/lib/update-snapshot.js +77 -3
- package/lib/virustotal.mjs +12 -1
- package/mcp-server/dist/index.js +1 -1
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/budget-judgments.d.ts +1 -1
- package/mcp-server/dist/services/budget-judgments.d.ts.map +1 -1
- package/mcp-server/dist/services/budget-judgments.js +5 -3
- package/mcp-server/dist/services/budget-judgments.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +2 -2
- package/mcp-server/dist/services/identity.js +2 -2
- package/mcp-server/dist/services/memory-sessions.d.ts +1 -1
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-sessions.js +28 -2
- package/mcp-server/dist/services/memory-sessions.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +2 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/server-instructions.d.ts.map +1 -1
- package/mcp-server/dist/services/server-instructions.js +2 -1
- package/mcp-server/dist/services/server-instructions.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +1 -1
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/services/tool-list.d.ts +1 -1
- package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-runtime.d.ts +2 -2
- package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-runtime.js +1 -1
- package/mcp-server/dist/services/tool-runtime.js.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +1 -1
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +8 -8
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +10 -9
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/choice.d.ts +6 -0
- package/mcp-server/dist/tools/choice.d.ts.map +1 -1
- package/mcp-server/dist/tools/choice.js +18 -13
- package/mcp-server/dist/tools/choice.js.map +1 -1
- package/mcp-server/dist/tools/git-tools.js +2 -2
- package/mcp-server/dist/tools/git-tools.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +9 -6
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +8 -8
- package/mcp-server/dist/tools/skill-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/skill-tools.js +11 -8
- package/mcp-server/dist/tools/skill-tools.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/index.ts +1 -1
- package/mcp-server/src/services/budget-judgments.ts +5 -3
- package/mcp-server/src/services/identity.ts +2 -2
- package/mcp-server/src/services/memory-sessions.ts +24 -3
- package/mcp-server/src/services/neural-interface.ts +2 -1
- package/mcp-server/src/services/server-instructions.ts +2 -1
- package/mcp-server/src/services/tool-catalog.ts +1 -1
- package/mcp-server/src/services/tool-list.ts +1 -1
- package/mcp-server/src/services/tool-runtime.ts +2 -2
- package/mcp-server/src/services/typesafe-config.ts +1 -1
- package/mcp-server/src/tools/agents.ts +10 -9
- package/mcp-server/src/tools/choice.ts +17 -12
- package/mcp-server/src/tools/git-tools.ts +2 -2
- package/mcp-server/src/tools/morelogin.ts +6 -4
- package/mcp-server/src/tools/skill-tools.ts +11 -8
- package/neural-interface/i18n/en.json +504 -39
- package/neural-interface/i18n/pt-BR.json +504 -39
- package/neural-interface/lib/agent-sandbox-elevation.js +6 -0
- package/neural-interface/lib/antigravity/acp-client-host.js +554 -0
- package/neural-interface/lib/antigravity/acp-connection.js +299 -0
- package/neural-interface/lib/antigravity/bypass.js +100 -0
- package/neural-interface/lib/antigravity/catalog.js +273 -0
- package/neural-interface/lib/antigravity/home.js +260 -0
- package/neural-interface/lib/antigravity/migrate-gemini.js +139 -0
- package/neural-interface/lib/antigravity/panel-bridge.js +1058 -0
- package/neural-interface/lib/antigravity/policy-hook.mjs +78 -0
- package/neural-interface/lib/antigravity/policy.js +74 -0
- package/neural-interface/lib/antigravity/tool-call.js +178 -0
- package/neural-interface/lib/antigravity/transcripts.js +252 -0
- package/neural-interface/lib/antigravity/usage.js +43 -0
- package/neural-interface/lib/assistant-api.js +1 -0
- package/neural-interface/lib/assistant-brains/antigravity.js +423 -0
- package/neural-interface/lib/assistant-brains/codex.js +6 -1
- package/neural-interface/lib/assistant-budget-planner.js +7 -3
- package/neural-interface/lib/assistant-budget-split.js +42 -15
- package/neural-interface/lib/assistant-catalog.js +76 -9
- package/neural-interface/lib/assistant-config.js +6 -3
- package/neural-interface/lib/assistant-dispatch.js +211 -50
- package/neural-interface/lib/assistant-envelope.js +153 -1
- package/neural-interface/lib/assistant-evidence.js +80 -0
- package/neural-interface/lib/assistant-hidden-models.js +7 -5
- package/neural-interface/lib/assistant-persona.js +16 -11
- package/neural-interface/lib/assistant-plan-permissions.js +15 -0
- package/neural-interface/lib/assistant-router.js +237 -35
- package/neural-interface/lib/assistant-runtime.js +158 -12
- package/neural-interface/lib/assistant-task-prompt.js +10 -8
- package/neural-interface/lib/assistant-tools.js +2 -2
- package/neural-interface/lib/assistant-usage.js +29 -0
- package/neural-interface/lib/backup-service.js +6 -1
- package/neural-interface/lib/browser-guard-cdp.js +5 -4
- package/neural-interface/lib/browser-network-guard.js +274 -82
- package/neural-interface/lib/browser-tool-policy.js +12 -7
- package/neural-interface/lib/claude-agent-bridge.js +7 -0
- package/neural-interface/lib/claude-history-cache.js +210 -0
- package/neural-interface/lib/claude-model-catalog.js +5 -1
- package/neural-interface/lib/cli-install-api.js +1 -1
- package/neural-interface/lib/cli-install.js +160 -31
- package/neural-interface/lib/cli-resolver.js +9 -2
- package/neural-interface/lib/cli-update-planner.js +25 -15
- package/neural-interface/lib/codex-rollout-reader.js +52 -0
- package/neural-interface/lib/codex-worker-app-server.js +25 -6
- package/neural-interface/lib/editor-git-api.js +3 -20
- package/neural-interface/lib/exec-loop-command.js +9 -2
- package/neural-interface/lib/file-explorer-api.js +74 -40
- package/neural-interface/lib/file-explorer-watch.js +9 -3
- package/neural-interface/lib/git-bash/install.js +52 -6
- package/neural-interface/lib/git-bash/manager.js +59 -17
- package/neural-interface/lib/git-bash/pins.js +12 -0
- package/neural-interface/lib/git-read.js +2 -2
- package/neural-interface/lib/git-status-runner.js +390 -0
- package/neural-interface/lib/git-status-watchdog.js +40 -0
- package/neural-interface/lib/greeting/budgets.js +1 -0
- package/neural-interface/lib/greeting/engine.js +2 -2
- package/neural-interface/lib/greeting/sources.js +10 -12
- package/neural-interface/lib/greeting/writer.js +1 -1
- package/neural-interface/lib/mcp-client-config.js +37 -6
- package/neural-interface/lib/mcp-external-servers.js +40 -7
- package/neural-interface/lib/mcp-installer.js +2 -1
- package/neural-interface/lib/memory-session-capture.js +17 -3
- package/neural-interface/lib/morelogin.js +147 -25
- package/neural-interface/lib/native-loop-providers.js +423 -23
- package/neural-interface/lib/native-loop-runtime.js +23 -2
- package/neural-interface/lib/opencode-native-boundary.js +165 -22
- package/neural-interface/lib/owner-authority.js +1 -1
- package/neural-interface/lib/path-confine.js +12 -9
- package/neural-interface/lib/peer-identity.js +80 -6
- package/neural-interface/lib/pty-host/core.js +28 -1
- package/neural-interface/lib/pty-host/lifetime.js +12 -0
- package/neural-interface/lib/pty-host/manager.js +12 -1
- package/neural-interface/lib/remote-policy.js +1 -1
- package/neural-interface/lib/request-gate.js +3 -0
- package/neural-interface/lib/rulesets/api.js +6 -5
- package/neural-interface/lib/rulesets/fs-safe.js +1 -1
- package/neural-interface/lib/rulesets/installer.js +89 -10
- package/neural-interface/lib/rulesets/render.js +1 -1
- package/neural-interface/lib/session-cache-builder.js +64 -1
- package/neural-interface/lib/skills/catalog.js +5 -1
- package/neural-interface/lib/skills/creation-brief.js +1 -1
- package/neural-interface/lib/skills/creation-sources.js +19 -1
- package/neural-interface/lib/skills/deploy.js +9 -4
- package/neural-interface/lib/skills/draft-confinement.js +3 -1
- package/neural-interface/lib/skills/eval-confinement.js +3 -1
- package/neural-interface/lib/skills/eval-trace.js +16 -0
- package/neural-interface/lib/skills/export.js +5 -2
- package/neural-interface/lib/skills/known-bridge-digests.json +58 -4
- package/neural-interface/lib/skills/ownership.js +1 -1
- package/neural-interface/lib/skills/roots.js +10 -3
- package/neural-interface/lib/skills/runtime-checks.js +6 -3
- package/neural-interface/lib/skills/service.js +15 -7
- package/neural-interface/lib/skills/telemetry.js +6 -0
- package/neural-interface/lib/synabun-version.js +1 -1
- package/neural-interface/lib/system-activity.js +1 -1
- package/neural-interface/lib/whatsapp/brain.js +7 -3
- package/neural-interface/lib/whatsapp/cards.js +22 -9
- package/neural-interface/lib/whatsapp/config.js +1 -1
- package/neural-interface/lib/worker-confinement.js +77 -1
- package/neural-interface/lib/worker-question.js +74 -0
- package/neural-interface/lib/worker-resume.js +13 -4
- package/neural-interface/lib/worker-sandbox.js +46 -16
- package/neural-interface/package-lock.json +18 -2
- package/neural-interface/package.json +2 -1
- package/neural-interface/public/onboarding.html +1 -1
- package/neural-interface/public/shared/agent-runtime-options.js +89 -11
- package/neural-interface/public/shared/agy/agy-bypass.js +47 -0
- package/neural-interface/public/shared/agy/agy-client.js +266 -0
- package/neural-interface/public/shared/agy/agy-commands.js +120 -0
- package/neural-interface/public/shared/agy/agy-copy.js +326 -0
- package/neural-interface/public/shared/agy/agy-diff.js +161 -0
- package/neural-interface/public/shared/agy/agy-events.js +469 -0
- package/neural-interface/public/shared/agy/agy-greeting.js +26 -0
- package/neural-interface/public/shared/agy/agy-options.js +232 -0
- package/neural-interface/public/shared/agy/agy-panel.js +2543 -0
- package/neural-interface/public/shared/agy/agy-render.js +392 -0
- package/neural-interface/public/shared/agy/agy-setup.js +149 -0
- package/neural-interface/public/shared/agy/agy-styles.js +604 -0
- package/neural-interface/public/shared/agy/agy-tabs-logic.js +181 -0
- package/neural-interface/public/shared/api.js +4 -4
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +3 -4
- package/neural-interface/public/shared/assistant/asst-api.js +15 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +56 -9
- package/neural-interface/public/shared/assistant/asst-budget.js +5 -4
- package/neural-interface/public/shared/assistant/asst-computer.js +26 -2
- package/neural-interface/public/shared/assistant/asst-control.js +48 -0
- package/neural-interface/public/shared/assistant/asst-hosts.js +16 -7
- package/neural-interface/public/shared/assistant/asst-limit-dock.js +6 -1
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +38 -5
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +80 -0
- package/neural-interface/public/shared/assistant/asst-panel.js +46 -9
- package/neural-interface/public/shared/assistant/asst-render.js +112 -18
- package/neural-interface/public/shared/assistant/asst-route.js +237 -57
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +9 -8
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +55 -23
- package/neural-interface/public/shared/assistant/asst-scenes.js +279 -80
- package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +4 -4
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +51 -7
- package/neural-interface/public/shared/assistant/asst-slash.js +8 -2
- package/neural-interface/public/shared/assistant/asst-state.js +76 -9
- package/neural-interface/public/shared/assistant/asst-style-cache.js +44 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +58 -4
- package/neural-interface/public/shared/assistant/asst-tool-kinds.js +34 -7
- package/neural-interface/public/shared/assistant/asst-usage.js +2 -1
- package/neural-interface/public/shared/cdx/cdx-output.js +26 -3
- package/neural-interface/public/shared/cdx/cdx-panel.js +14 -2
- package/neural-interface/public/shared/cdx/cdx-preview.js +12 -0
- package/neural-interface/public/shared/cdx/cdx-protocol.js +11 -10
- package/neural-interface/public/shared/cdx/cdx-render.js +10 -9
- package/neural-interface/public/shared/cdx/cdx-requests.js +11 -1
- package/neural-interface/public/shared/cdx/cdx-styles.js +4 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +75 -5
- package/neural-interface/public/shared/cli-install-controller.js +218 -0
- package/neural-interface/public/shared/cli-install-view.js +7 -4
- package/neural-interface/public/shared/cli-status.js +9 -8
- package/neural-interface/public/shared/constants.js +3 -2
- package/neural-interface/public/shared/context-menu-model.js +1 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +12 -0
- package/neural-interface/public/shared/cp/cp-restore.js +162 -0
- package/neural-interface/public/shared/cp/cp-tool-cards.js +10 -3
- package/neural-interface/public/shared/desktop-bridge.js +17 -0
- package/neural-interface/public/shared/desktop-titlebar-view.js +12 -0
- package/neural-interface/public/shared/desktop-titlebar.js +13 -4
- package/neural-interface/public/shared/desktop-update-view.js +1 -0
- package/neural-interface/public/shared/explorer/fx-api.js +4 -4
- package/neural-interface/public/shared/explorer/fx-links.js +3 -3
- package/neural-interface/public/shared/explorer/fx-logic.js +1 -1
- package/neural-interface/public/shared/explorer/fx-main.js +48 -16
- package/neural-interface/public/shared/explorer/fx-tree.js +1 -0
- package/neural-interface/public/shared/greeting/greeting-card.js +2 -2
- package/neural-interface/public/shared/greeting/greeting-view.js +1 -0
- package/neural-interface/public/shared/html-shell.js +21 -4
- package/neural-interface/public/shared/loading-teardown.js +34 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +6 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +28 -7
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +13 -4
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +17 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +6 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +101 -68
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +46 -3
- package/neural-interface/public/shared/provider-icons.js +4 -2
- package/neural-interface/public/shared/settings/settings-rules.js +2 -2
- package/neural-interface/public/shared/settings/settings-skill-folders-pane.js +1 -1
- package/neural-interface/public/shared/settings/settings-skill-folders.js +2 -2
- package/neural-interface/public/shared/showcase-privacy.js +6 -1
- package/neural-interface/public/shared/sidepanel-session-status.js +3 -3
- package/neural-interface/public/shared/skills/ss-creation.js +6 -3
- package/neural-interface/public/shared/skills/ss-dialog.js +5 -2
- package/neural-interface/public/shared/skills/ss-lint.js +9 -1
- package/neural-interface/public/shared/skills/ss-profiles.js +44 -6
- package/neural-interface/public/shared/skills/ss-review-view.js +2 -2
- package/neural-interface/public/shared/skills/studio/sx-actions.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-create-ai-view.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-create-ai.js +2 -1
- package/neural-interface/public/shared/skills/studio/sx-dom.js +2 -1
- package/neural-interface/public/shared/skills/studio/sx-fixes-view.js +359 -0
- package/neural-interface/public/shared/skills/studio/sx-fixes.js +327 -0
- package/neural-interface/public/shared/skills/studio/sx-inspector.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-install-flow.js +9 -6
- package/neural-interface/public/shared/skills/studio/sx-install.js +20 -3
- package/neural-interface/public/shared/skills/studio/sx-library-view.js +144 -35
- package/neural-interface/public/shared/skills/studio/sx-library.js +6 -2
- package/neural-interface/public/shared/skills/studio/sx-main.js +11 -2
- package/neural-interface/public/shared/skills/studio/sx-review-view.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-subject.js +7 -6
- package/neural-interface/public/shared/skills/studio/sx-workspace-view.js +6 -5
- package/neural-interface/public/shared/state.js +1 -1
- package/neural-interface/public/shared/storage-retry.js +47 -0
- package/neural-interface/public/shared/storage.js +25 -4
- package/neural-interface/public/shared/streaming-markdown.js +58 -0
- package/neural-interface/public/shared/styles.css +362 -35
- package/neural-interface/public/shared/synabun-mascot.js +27 -8
- package/neural-interface/public/shared/synabun-ticker.js +147 -12
- package/neural-interface/public/shared/text-cache.js +29 -0
- package/neural-interface/public/shared/tool-list-picker.js +2 -2
- package/neural-interface/public/shared/tool-list-view.js +2 -2
- package/neural-interface/public/shared/topright-overflow-logic.js +54 -0
- package/neural-interface/public/shared/ui-antigravity-panel.js +19 -0
- package/neural-interface/public/shared/ui-assistant.js +2 -0
- package/neural-interface/public/shared/ui-automation-studio.js +20 -12
- package/neural-interface/public/shared/ui-claude-panel.js +374 -134
- package/neural-interface/public/shared/ui-cli-banner.js +23 -167
- package/neural-interface/public/shared/ui-file-explorer.js +48 -6
- package/neural-interface/public/shared/ui-file-links.js +2 -2
- package/neural-interface/public/shared/ui-games.js +2 -2
- package/neural-interface/public/shared/ui-judgments.js +1 -1
- package/neural-interface/public/shared/ui-keybinds.js +8 -2
- package/neural-interface/public/shared/ui-link.js +3 -3
- package/neural-interface/public/shared/ui-loading.js +5 -4
- package/neural-interface/public/shared/ui-menubar.js +2 -2
- package/neural-interface/public/shared/ui-native-loop-router.js +4 -0
- package/neural-interface/public/shared/ui-navbar.js +45 -0
- package/neural-interface/public/shared/ui-notifications.js +1 -0
- package/neural-interface/public/shared/ui-resume.js +9 -7
- package/neural-interface/public/shared/ui-schedules-studio.js +41 -10
- package/neural-interface/public/shared/ui-scroll-follow.js +16 -5
- package/neural-interface/public/shared/ui-sessions.js +22 -12
- package/neural-interface/public/shared/ui-settings.js +90 -65
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +9 -2
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +3 -3
- package/neural-interface/public/shared/ui-sidepanel-tray.js +48 -7
- package/neural-interface/public/shared/ui-sidepanel-windows.js +3 -3
- package/neural-interface/public/shared/ui-terminal.js +146 -10
- package/neural-interface/public/shared/ui-tool-updates.js +3 -3
- package/neural-interface/public/shared/ui-tooltip.js +71 -46
- package/neural-interface/public/shared/ui-topright-overflow.js +233 -0
- package/neural-interface/public/shared/ui-whiteboard.js +1 -1
- package/neural-interface/public/shared/ui-worker-end.js +1 -1
- package/neural-interface/public/shared/whatsapp/wa-view.js +2 -2
- package/neural-interface/public/shared/worker-questions.js +34 -0
- package/neural-interface/public/sidepanel-session.html +1 -1
- package/neural-interface/server.js +731 -466
- package/neural-interface/templates/rulesets/README.md +1 -1
- package/neural-interface/templates/rulesets/legacy-hashes.json +5 -5
- package/neural-interface/templates/rulesets/manifest.json +1 -1
- package/npm-shrinkwrap.json +18 -2
- package/package.json +2 -1
- package/skills/skill-forge/SKILL.md +4 -4
- package/skills/synabun/SKILL.md +1 -1
- package/skills/synabun/modules/schedule.md +3 -3
- /package/neural-interface/templates/rulesets/{gemini.md → antigravity.md} +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Antigravity panel: pickers and permission cards (no DOM)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// Antigravity describes its own choices: a session's `configOptions` (ACP
|
|
6
|
+
// Session Config Options) carry the model, the thinking level and anything
|
|
7
|
+
// else it lets a client set, each with its current value and every value it
|
|
8
|
+
// accepts, and `modes` the agent modes (Agent, Accept edits, Plan, Auto).
|
|
9
|
+
// Nothing here keeps a list of its own: the pickers show what the session
|
|
10
|
+
// says, in its words, and write back the value it gave.
|
|
11
|
+
|
|
12
|
+
/** The first select option of a category ('model', 'thought_level', 'mode'), or null. */
|
|
13
|
+
export function optionByCategory(configOptions, category) {
|
|
14
|
+
return (Array.isArray(configOptions) ? configOptions : []).find((option) => option && option.category === category && (option.type === 'select' || option.type === undefined)) || null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The options a header shows: model and thinking first, then the rest the agent offers (select or boolean). */
|
|
18
|
+
export function orderedOptions(configOptions) {
|
|
19
|
+
const list = (Array.isArray(configOptions) ? configOptions : []).filter((option) => option && typeof option.id === 'string' && (option.type === 'select' || option.type === 'boolean'));
|
|
20
|
+
const rank = (option) => ({ model: 0, thought_level: 1, model_config: 2, mode: 3 }[option.category] ?? 4);
|
|
21
|
+
return [...list].sort((a, b) => rank(a) - rank(b));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** cc-dropdown entries for a select option: flat options, or `{ group, options }` headings. */
|
|
25
|
+
export function dropdownEntries(option) {
|
|
26
|
+
if (!option || !Array.isArray(option.options)) return [];
|
|
27
|
+
const current = option.currentValue;
|
|
28
|
+
const one = (value) => ({ value: String(value.value), label: String(value.name || value.value), selected: value.value === current, title: value.description || '' });
|
|
29
|
+
return option.options.map((entry) => {
|
|
30
|
+
if (entry && Array.isArray(entry.options)) return { group: String(entry.name || entry.group || ''), options: entry.options.filter((v) => v && v.value !== undefined).map(one) };
|
|
31
|
+
return entry && entry.value !== undefined ? one(entry) : null;
|
|
32
|
+
}).filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The label of an option's current value ('Gemini 3.8 Flash'), or the raw value. */
|
|
36
|
+
export function currentLabel(option) {
|
|
37
|
+
if (!option) return '';
|
|
38
|
+
for (const entry of option.options || []) {
|
|
39
|
+
const values = Array.isArray(entry?.options) ? entry.options : [entry];
|
|
40
|
+
for (const value of values) if (value && value.value === option.currentValue) return String(value.name || value.value);
|
|
41
|
+
}
|
|
42
|
+
return option.currentValue === undefined || option.currentValue === null ? '' : String(option.currentValue);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Every value an option accepts (flattened), for validating what a page sends back. */
|
|
46
|
+
export function acceptedValues(option) {
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const entry of option?.options || []) {
|
|
49
|
+
const values = Array.isArray(entry?.options) ? entry.options : [entry];
|
|
50
|
+
for (const value of values) if (value && value.value !== undefined) out.push(value.value);
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Applies a value locally (optimistic), before the agent's answer replaces the whole list. */
|
|
56
|
+
export function withValue(configOptions, configId, value) {
|
|
57
|
+
return (Array.isArray(configOptions) ? configOptions : []).map((option) => (option?.id === configId ? { ...option, currentValue: value } : option));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Mode picker entries from the session's modes ({ currentModeId, availableModes }). */
|
|
61
|
+
export function modeEntries(modes) {
|
|
62
|
+
const list = Array.isArray(modes?.availableModes) ? modes.availableModes : [];
|
|
63
|
+
return list.filter((mode) => mode && typeof mode.id === 'string').map((mode) => ({
|
|
64
|
+
value: mode.id, label: String(mode.name || mode.id), selected: mode.id === modes.currentModeId, title: mode.description || '',
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The name of the current mode. */
|
|
69
|
+
export function currentModeLabel(modes) {
|
|
70
|
+
const found = (modes?.availableModes || []).find((mode) => mode?.id === modes?.currentModeId);
|
|
71
|
+
return found ? String(found.name || found.id) : String(modes?.currentModeId || '');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const KIND_VERBS = Object.freeze({
|
|
75
|
+
read: 'read', edit: 'edit', delete: 'delete', move: 'move', search: 'search',
|
|
76
|
+
execute: 'run', think: 'think', fetch: 'fetch', switch_mode: 'switch mode', other: 'use a tool',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* What a permission card says and offers, from session/request_permission:
|
|
81
|
+
* { title, kind, verb, detail (command, paths or input), options [{ optionId, label, kind, tone }] }.
|
|
82
|
+
* Allow choices come first, then the denials; `tone` is 'allow' | 'deny'.
|
|
83
|
+
*/
|
|
84
|
+
export function permissionCard(request) {
|
|
85
|
+
const toolCall = request?.toolCall && typeof request.toolCall === 'object' ? request.toolCall : {};
|
|
86
|
+
const input = toolCall.rawInput && typeof toolCall.rawInput === 'object' ? toolCall.rawInput : {};
|
|
87
|
+
const kind = typeof toolCall.kind === 'string' && KIND_VERBS[toolCall.kind] ? toolCall.kind : 'other';
|
|
88
|
+
const command = typeof input.command === 'string' ? input.command : Array.isArray(input.command) ? input.command.join(' ') : '';
|
|
89
|
+
const paths = (Array.isArray(toolCall.locations) ? toolCall.locations : []).map((l) => l?.path).filter((p) => typeof p === 'string' && p);
|
|
90
|
+
let detail = command || paths.join('\n');
|
|
91
|
+
if (!detail && input && Object.keys(input).length) {
|
|
92
|
+
try { detail = JSON.stringify(input, null, 2).slice(0, 2000); } catch { detail = ''; }
|
|
93
|
+
}
|
|
94
|
+
const options = (Array.isArray(request?.options) ? request.options : [])
|
|
95
|
+
.filter((option) => option && typeof option.optionId === 'string')
|
|
96
|
+
.map((option) => ({ optionId: option.optionId, label: String(option.name || option.optionId), kind: option.kind || '', tone: String(option.kind || '').startsWith('reject') ? 'deny' : 'allow' }))
|
|
97
|
+
.sort((a, b) => (a.tone === b.tone ? 0 : a.tone === 'allow' ? -1 : 1));
|
|
98
|
+
return { title: String(toolCall.title || ''), kind, verb: KIND_VERBS[kind], detail, command, paths, options, diffs: permissionDiffs(request) };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The option an "Allow once" / "Deny" keyboard shortcut picks: the first of that tone and duration. */
|
|
102
|
+
export function quickOption(card, tone) {
|
|
103
|
+
const want = tone === 'deny' ? ['reject_once', 'reject_always'] : ['allow_once', 'allow_always'];
|
|
104
|
+
for (const kind of want) {
|
|
105
|
+
const found = card.options.find((option) => option.kind === kind);
|
|
106
|
+
if (found) return found.optionId;
|
|
107
|
+
}
|
|
108
|
+
return card.options.find((option) => option.tone === tone)?.optionId || null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The changes a permission request carries (`toolCall.content` diffs): shown above its buttons. */
|
|
112
|
+
export function permissionDiffs(request) {
|
|
113
|
+
const content = Array.isArray(request?.toolCall?.content) ? request.toolCall.content : [];
|
|
114
|
+
return content.filter((item) => item && item.type === 'diff' && typeof item.path === 'string')
|
|
115
|
+
.map((item) => ({ type: 'diff', path: item.path, oldText: item.oldText ?? null, newText: String(item.newText ?? '') }));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ── The options the toolbar does not show ──
|
|
119
|
+
|
|
120
|
+
/** Toolbar pickers: the model, the thinking level and the mode (by category). Everything else goes in Session settings. */
|
|
121
|
+
export const TOOLBAR_CATEGORIES = Object.freeze(['model', 'thought_level', 'mode']);
|
|
122
|
+
|
|
123
|
+
/** The session's other options (select or boolean), in the agent's order: Session settings lists these. */
|
|
124
|
+
export function secondaryOptions(configOptions) {
|
|
125
|
+
const shown = new Set();
|
|
126
|
+
for (const category of TOOLBAR_CATEGORIES) {
|
|
127
|
+
const option = optionByCategory(configOptions, category);
|
|
128
|
+
if (option) shown.add(option.id);
|
|
129
|
+
}
|
|
130
|
+
return (Array.isArray(configOptions) ? configOptions : [])
|
|
131
|
+
.filter((option) => option && typeof option.id === 'string' && !shown.has(option.id) && (option.type === 'select' || option.type === 'boolean'));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The value a boolean option takes when its switch is flipped. */
|
|
135
|
+
export function toggledValue(option) {
|
|
136
|
+
return !(option?.currentValue === true);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ── Elicitation: the agent asks for structured input (ACP elicitation/create) ──
|
|
140
|
+
|
|
141
|
+
const FIELD_TYPES = new Set(['string', 'number', 'integer', 'boolean', 'array']);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The fields of a form-mode elicitation, from its `requestedSchema` (a flat object schema of string / number /
|
|
145
|
+
* integer / boolean / multi-select properties): [{ name, type, title, description, required, choices, multiple,
|
|
146
|
+
* min, max, minLength, maxLength, format, defaultValue }]. A property of a type the panel cannot ask for is kept as
|
|
147
|
+
* `{ type: 'unsupported' }`, so the card can say why it cannot be answered.
|
|
148
|
+
*/
|
|
149
|
+
export function elicitationFields(schema) {
|
|
150
|
+
const properties = schema && typeof schema === 'object' && schema.properties && typeof schema.properties === 'object' ? schema.properties : {};
|
|
151
|
+
const required = new Set(Array.isArray(schema?.required) ? schema.required.filter((name) => typeof name === 'string') : []);
|
|
152
|
+
return Object.entries(properties).slice(0, 50).map(([name, prop]) => {
|
|
153
|
+
const type = FIELD_TYPES.has(prop?.type) ? prop.type : 'unsupported';
|
|
154
|
+
const field = {
|
|
155
|
+
name,
|
|
156
|
+
type,
|
|
157
|
+
title: typeof prop?.title === 'string' && prop.title ? prop.title : name,
|
|
158
|
+
description: typeof prop?.description === 'string' ? prop.description : '',
|
|
159
|
+
required: required.has(name),
|
|
160
|
+
choices: [],
|
|
161
|
+
multiple: type === 'array',
|
|
162
|
+
min: Number.isFinite(prop?.minimum) ? prop.minimum : null,
|
|
163
|
+
max: Number.isFinite(prop?.maximum) ? prop.maximum : null,
|
|
164
|
+
minLength: Number.isInteger(prop?.minLength) ? prop.minLength : null,
|
|
165
|
+
maxLength: Number.isInteger(prop?.maxLength) ? prop.maxLength : null,
|
|
166
|
+
format: typeof prop?.format === 'string' ? prop.format : '',
|
|
167
|
+
defaultValue: prop?.default ?? null,
|
|
168
|
+
};
|
|
169
|
+
if (type === 'string') {
|
|
170
|
+
if (Array.isArray(prop?.oneOf)) field.choices = prop.oneOf.filter((o) => o && typeof o.const === 'string').map((o) => ({ value: o.const, label: String(o.title || o.const) }));
|
|
171
|
+
else if (Array.isArray(prop?.enum)) field.choices = prop.enum.filter((v) => typeof v === 'string').map((v) => ({ value: v, label: v }));
|
|
172
|
+
}
|
|
173
|
+
if (type === 'array') {
|
|
174
|
+
const items = prop?.items || {};
|
|
175
|
+
const list = Array.isArray(items.anyOf) ? items.anyOf : Array.isArray(items.oneOf) ? items.oneOf : null;
|
|
176
|
+
if (list) field.choices = list.filter((o) => o && typeof o.const === 'string').map((o) => ({ value: o.const, label: String(o.title || o.const) }));
|
|
177
|
+
else if (Array.isArray(items.enum)) field.choices = items.enum.filter((v) => typeof v === 'string').map((v) => ({ value: v, label: v }));
|
|
178
|
+
if (!field.choices.length) field.type = 'unsupported';
|
|
179
|
+
field.min = Number.isInteger(prop?.minItems) ? prop.minItems : null;
|
|
180
|
+
field.max = Number.isInteger(prop?.maxItems) ? prop.maxItems : null;
|
|
181
|
+
}
|
|
182
|
+
return field;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* What the form says, as the answer's `content`, from the raw values the inputs hold ({ name: string | boolean |
|
|
190
|
+
* string[] }). Returns { content, errors: { name: key } } — `errors` empty when it may be sent. Keys are copy keys of
|
|
191
|
+
* agy-copy.js (elicitRequired, elicitNumber, elicitRange, elicitLength, elicitEmail, elicitUrl, elicitChoices).
|
|
192
|
+
*/
|
|
193
|
+
export function elicitationContent(fields, values = {}) {
|
|
194
|
+
const content = {};
|
|
195
|
+
const errors = {};
|
|
196
|
+
for (const field of fields) {
|
|
197
|
+
const raw = values[field.name];
|
|
198
|
+
if (field.type === 'unsupported') { if (field.required) errors[field.name] = 'elicitUnsupported'; continue; }
|
|
199
|
+
if (field.type === 'boolean') { content[field.name] = raw === true || raw === 'true'; continue; }
|
|
200
|
+
if (field.type === 'array') {
|
|
201
|
+
const picked = (Array.isArray(raw) ? raw : []).filter((value) => field.choices.some((choice) => choice.value === value));
|
|
202
|
+
if (field.required && !picked.length) { errors[field.name] = 'elicitRequired'; continue; }
|
|
203
|
+
if ((field.min !== null && picked.length < field.min) || (field.max !== null && picked.length > field.max)) { errors[field.name] = 'elicitChoices'; continue; }
|
|
204
|
+
if (picked.length || field.required) content[field.name] = picked;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const text = typeof raw === 'string' ? raw.trim() : raw == null ? '' : String(raw);
|
|
208
|
+
if (!text) { if (field.required) errors[field.name] = 'elicitRequired'; continue; }
|
|
209
|
+
if (field.type === 'number' || field.type === 'integer') {
|
|
210
|
+
const number = Number(text);
|
|
211
|
+
if (!Number.isFinite(number) || (field.type === 'integer' && !Number.isInteger(number))) { errors[field.name] = 'elicitNumber'; continue; }
|
|
212
|
+
if ((field.min !== null && number < field.min) || (field.max !== null && number > field.max)) { errors[field.name] = 'elicitRange'; continue; }
|
|
213
|
+
content[field.name] = number;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (field.choices.length && !field.choices.some((choice) => choice.value === text)) { errors[field.name] = 'elicitRequired'; continue; }
|
|
217
|
+
if ((field.minLength !== null && text.length < field.minLength) || (field.maxLength !== null && text.length > field.maxLength)) { errors[field.name] = 'elicitLength'; continue; }
|
|
218
|
+
if (field.format === 'email' && !EMAIL.test(text)) { errors[field.name] = 'elicitEmail'; continue; }
|
|
219
|
+
if (field.format === 'uri' && !/^[a-z][a-z0-9+.-]*:\S+$/i.test(text)) { errors[field.name] = 'elicitUrl'; continue; }
|
|
220
|
+
content[field.name] = text.slice(0, 10_000);
|
|
221
|
+
}
|
|
222
|
+
return { content, errors };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** A URL-mode elicitation's address, when it is one the panel may open (https, or http on this computer). */
|
|
226
|
+
export function elicitationUrl(request) {
|
|
227
|
+
let url;
|
|
228
|
+
try { url = new URL(String(request?.url || '')); } catch { return null; }
|
|
229
|
+
if (url.protocol === 'https:') return url.href;
|
|
230
|
+
if (url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)) return url.href;
|
|
231
|
+
return null;
|
|
232
|
+
}
|