@undefineds.co/linx 0.3.25 → 0.3.27
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 +4 -3
- package/dist/index.js +3 -832
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-stream-bridge-contract.js +2 -0
- package/dist/lib/agent-stream-bridge-contract.js.map +1 -0
- package/dist/lib/auto-mode/auth.js +100 -2
- package/dist/lib/auto-mode/auth.js.map +1 -1
- package/dist/lib/auto-mode/backend-kind.js +13 -0
- package/dist/lib/auto-mode/backend-kind.js.map +1 -0
- package/dist/lib/auto-mode/display.js +1 -1
- package/dist/lib/auto-mode/display.js.map +1 -1
- package/dist/lib/auto-mode/format.js +1 -1
- package/dist/lib/auto-mode/format.js.map +1 -1
- package/dist/lib/auto-mode/hooks/{index.js → registry.js} +1 -1
- package/dist/lib/auto-mode/hooks/registry.js.map +1 -0
- package/dist/lib/auto-mode/pod-ai.js +1 -14
- package/dist/lib/auto-mode/pod-ai.js.map +1 -1
- package/dist/lib/auto-mode/pod-approval-store.js +596 -0
- package/dist/lib/auto-mode/pod-approval-store.js.map +1 -0
- package/dist/lib/auto-mode/pod-approval.js +4 -607
- package/dist/lib/auto-mode/pod-approval.js.map +1 -1
- package/dist/lib/auto-mode/pod-persistence-builders.js +266 -0
- package/dist/lib/auto-mode/pod-persistence-builders.js.map +1 -0
- package/dist/lib/auto-mode/pod-persistence.js +1 -281
- package/dist/lib/auto-mode/pod-persistence.js.map +1 -1
- package/dist/lib/auto-mode/runner.js +41 -378
- package/dist/lib/auto-mode/runner.js.map +1 -1
- package/dist/lib/auto-mode/runtime.js +25 -0
- package/dist/lib/auto-mode/runtime.js.map +1 -0
- package/dist/lib/auto-mode/secretary-reaction-window.js +12 -0
- package/dist/lib/auto-mode/secretary-reaction-window.js.map +1 -0
- package/dist/lib/auto-mode/secretary-runtime-config.js +66 -0
- package/dist/lib/auto-mode/secretary-runtime-config.js.map +1 -0
- package/dist/lib/auto-mode/secretary.js +2 -64
- package/dist/lib/auto-mode/secretary.js.map +1 -1
- package/dist/lib/auto-mode/session-log.js +25 -0
- package/dist/lib/auto-mode/session-log.js.map +1 -0
- package/dist/lib/auto-mode/shell-command.js +172 -0
- package/dist/lib/auto-mode/shell-command.js.map +1 -0
- package/dist/lib/auto-mode-command.js +2 -1
- package/dist/lib/auto-mode-command.js.map +1 -1
- package/dist/lib/backend-command-router-contract.js +2 -0
- package/dist/lib/backend-command-router-contract.js.map +1 -0
- package/dist/lib/{pi-adapter/backend-credentials.js → backend-credentials.js} +8 -8
- package/dist/lib/backend-credentials.js.map +1 -0
- package/dist/lib/linx-ai-connect-command.js +201 -0
- package/dist/lib/linx-ai-connect-command.js.map +1 -0
- package/dist/lib/linx-assistant-message-rendering.js +33 -0
- package/dist/lib/linx-assistant-message-rendering.js.map +1 -0
- package/dist/lib/linx-auto-command-routing.js +53 -0
- package/dist/lib/linx-auto-command-routing.js.map +1 -0
- package/dist/lib/linx-auto-editor-indicator-host.js +15 -0
- package/dist/lib/linx-auto-editor-indicator-host.js.map +1 -0
- package/dist/lib/linx-auto-editor-indicator.js +56 -0
- package/dist/lib/linx-auto-editor-indicator.js.map +1 -0
- package/dist/lib/linx-auto-mode-cli-admission.js +16 -0
- package/dist/lib/linx-auto-mode-cli-admission.js.map +1 -0
- package/dist/lib/linx-backend-command-router.js +64 -0
- package/dist/lib/linx-backend-command-router.js.map +1 -0
- package/dist/lib/linx-backend-event-source.js +32 -0
- package/dist/lib/linx-backend-event-source.js.map +1 -0
- package/dist/lib/linx-chat-completion-projection.js +276 -0
- package/dist/lib/linx-chat-completion-projection.js.map +1 -0
- package/dist/lib/linx-cloud-errors.js +1 -0
- package/dist/lib/linx-cloud-errors.js.map +1 -1
- package/dist/lib/linx-cloud-models.js +75 -0
- package/dist/lib/linx-cloud-models.js.map +1 -0
- package/dist/lib/linx-cloud-runtime-auth.js +146 -0
- package/dist/lib/linx-cloud-runtime-auth.js.map +1 -0
- package/dist/lib/linx-cloud-runtime-coordinator.js +102 -0
- package/dist/lib/linx-cloud-runtime-coordinator.js.map +1 -0
- package/dist/lib/linx-codex-plugin-command.js +56 -0
- package/dist/lib/linx-codex-plugin-command.js.map +1 -0
- package/dist/lib/linx-command-autocomplete.js +123 -0
- package/dist/lib/linx-command-autocomplete.js.map +1 -0
- package/dist/lib/linx-completion-backend.js +2 -0
- package/dist/lib/linx-completion-backend.js.map +1 -0
- package/dist/lib/linx-config-command.js +12 -0
- package/dist/lib/linx-config-command.js.map +1 -0
- package/dist/lib/linx-editor-component-router.js +83 -0
- package/dist/lib/linx-editor-component-router.js.map +1 -0
- package/dist/lib/linx-extension-ui-context-router.js +43 -0
- package/dist/lib/linx-extension-ui-context-router.js.map +1 -0
- package/dist/lib/linx-external-open-host.js +8 -0
- package/dist/lib/linx-external-open-host.js.map +1 -0
- package/dist/lib/linx-external-url.js +16 -0
- package/dist/lib/linx-external-url.js.map +1 -0
- package/dist/lib/linx-footer-patch.js +52 -0
- package/dist/lib/linx-footer-patch.js.map +1 -0
- package/dist/lib/linx-input-command-routing.js +65 -0
- package/dist/lib/linx-input-command-routing.js.map +1 -0
- package/dist/lib/linx-interactive-auth-state-host.js +50 -0
- package/dist/lib/linx-interactive-auth-state-host.js.map +1 -0
- package/dist/lib/linx-interactive-autocomplete-host.js +32 -0
- package/dist/lib/linx-interactive-autocomplete-host.js.map +1 -0
- package/dist/lib/linx-interactive-bootstrap.js +66 -0
- package/dist/lib/linx-interactive-bootstrap.js.map +1 -0
- package/dist/lib/linx-interactive-branding.js +24 -0
- package/dist/lib/linx-interactive-branding.js.map +1 -0
- package/dist/lib/linx-interactive-chat-text-host.js +16 -0
- package/dist/lib/linx-interactive-chat-text-host.js.map +1 -0
- package/dist/lib/linx-interactive-command-routing-host.js +31 -0
- package/dist/lib/linx-interactive-command-routing-host.js.map +1 -0
- package/dist/lib/linx-interactive-command-routing.js +75 -0
- package/dist/lib/linx-interactive-command-routing.js.map +1 -0
- package/dist/lib/linx-interactive-command-surface.js +16 -0
- package/dist/lib/linx-interactive-command-surface.js.map +1 -0
- package/dist/lib/linx-interactive-editor-text-host.js +16 -0
- package/dist/lib/linx-interactive-editor-text-host.js.map +1 -0
- package/dist/lib/linx-interactive-error-display.js +8 -0
- package/dist/lib/linx-interactive-error-display.js.map +1 -0
- package/dist/lib/linx-interactive-event-router.js +91 -0
- package/dist/lib/linx-interactive-event-router.js.map +1 -0
- package/dist/lib/linx-interactive-extension-input-host.js +7 -0
- package/dist/lib/linx-interactive-extension-input-host.js.map +1 -0
- package/dist/lib/linx-interactive-extension-selector-host.js +12 -0
- package/dist/lib/linx-interactive-extension-selector-host.js.map +1 -0
- package/dist/lib/linx-interactive-header-host.js +14 -0
- package/dist/lib/linx-interactive-header-host.js.map +1 -0
- package/dist/lib/linx-interactive-lifecycle-host.js +4 -0
- package/dist/lib/linx-interactive-lifecycle-host.js.map +1 -0
- package/dist/lib/linx-interactive-login-ui-router.js +81 -0
- package/dist/lib/linx-interactive-login-ui-router.js.map +1 -0
- package/dist/lib/linx-interactive-model-registry-host.js +14 -0
- package/dist/lib/linx-interactive-model-registry-host.js.map +1 -0
- package/dist/lib/linx-interactive-post-init.js +60 -0
- package/dist/lib/linx-interactive-post-init.js.map +1 -0
- package/dist/lib/linx-interactive-provider-count-host.js +4 -0
- package/dist/lib/linx-interactive-provider-count-host.js.map +1 -0
- package/dist/lib/linx-interactive-run-router.js +43 -0
- package/dist/lib/linx-interactive-run-router.js.map +1 -0
- package/dist/lib/linx-interactive-runtime-host.js +113 -0
- package/dist/lib/linx-interactive-runtime-host.js.map +1 -0
- package/dist/lib/linx-interactive-selector-host.js +12 -0
- package/dist/lib/linx-interactive-selector-host.js.map +1 -0
- package/dist/lib/linx-interactive-shell-state.js +215 -0
- package/dist/lib/linx-interactive-shell-state.js.map +1 -0
- package/dist/lib/linx-interactive-status-display.js +9 -0
- package/dist/lib/linx-interactive-status-display.js.map +1 -0
- package/dist/lib/linx-interactive-stop-router.js +85 -0
- package/dist/lib/linx-interactive-stop-router.js.map +1 -0
- package/dist/lib/linx-interactive-streaming-message-host.js +11 -0
- package/dist/lib/linx-interactive-streaming-message-host.js.map +1 -0
- package/dist/lib/linx-interactive-submit-router.js +63 -0
- package/dist/lib/linx-interactive-submit-router.js.map +1 -0
- package/dist/lib/linx-interactive-update-router.js +78 -0
- package/dist/lib/linx-interactive-update-router.js.map +1 -0
- package/dist/lib/linx-interactive-update-state-host.js +43 -0
- package/dist/lib/linx-interactive-update-state-host.js.map +1 -0
- package/dist/lib/linx-interactive-warning-display.js +4 -0
- package/dist/lib/linx-interactive-warning-display.js.map +1 -0
- package/dist/lib/linx-interrupt-control-host.js +22 -0
- package/dist/lib/linx-interrupt-control-host.js.map +1 -0
- package/dist/lib/linx-interrupt-control.js +96 -0
- package/dist/lib/linx-interrupt-control.js.map +1 -0
- package/dist/lib/linx-login-flow.js +566 -0
- package/dist/lib/linx-login-flow.js.map +1 -0
- package/dist/lib/linx-models-command.js +71 -0
- package/dist/lib/linx-models-command.js.map +1 -0
- package/dist/lib/linx-package-command.js +117 -0
- package/dist/lib/linx-package-command.js.map +1 -0
- package/dist/lib/linx-peer-command-routing.js +20 -0
- package/dist/lib/linx-peer-command-routing.js.map +1 -0
- package/dist/lib/linx-pi-cli-command.js +121 -0
- package/dist/lib/linx-pi-cli-command.js.map +1 -0
- package/dist/lib/linx-pi-completion-events.js +101 -0
- package/dist/lib/linx-pi-completion-events.js.map +1 -0
- package/dist/lib/linx-pi-normalized-event-stream.js +41 -0
- package/dist/lib/linx-pi-normalized-event-stream.js.map +1 -0
- package/dist/lib/linx-pi-resume-cli-admission.js +21 -0
- package/dist/lib/linx-pi-resume-cli-admission.js.map +1 -0
- package/dist/lib/linx-pi-runtime-execution.js +67 -0
- package/dist/lib/linx-pi-runtime-execution.js.map +1 -0
- package/dist/lib/linx-pi-startup-control.js +49 -0
- package/dist/lib/linx-pi-startup-control.js.map +1 -0
- package/dist/lib/linx-pi-startup-plan.js +103 -0
- package/dist/lib/linx-pi-startup-plan.js.map +1 -0
- package/dist/lib/linx-pi-stream-errors.js +10 -0
- package/dist/lib/linx-pi-stream-errors.js.map +1 -0
- package/dist/lib/linx-pod-backed-extension-ui.js +29 -0
- package/dist/lib/linx-pod-backed-extension-ui.js.map +1 -0
- package/dist/lib/linx-pod-data-session-factory.js +19 -0
- package/dist/lib/linx-pod-data-session-factory.js.map +1 -0
- package/dist/lib/linx-pod-mirror-runtime-host.js +50 -0
- package/dist/lib/linx-pod-mirror-runtime-host.js.map +1 -0
- package/dist/lib/linx-pod-mirror-sync-cli-admission.js +18 -0
- package/dist/lib/linx-pod-mirror-sync-cli-admission.js.map +1 -0
- package/dist/lib/linx-pod-mirror-sync-command.js +30 -0
- package/dist/lib/linx-pod-mirror-sync-command.js.map +1 -0
- package/dist/lib/{pi-adapter/sync-recovery.js → linx-pod-mirror-sync-recovery.js} +13 -13
- package/dist/lib/linx-pod-mirror-sync-recovery.js.map +1 -0
- package/dist/lib/{pi-adapter/pod-mirror.js → linx-pod-mirror.js} +63 -40
- package/dist/lib/linx-pod-mirror.js.map +1 -0
- package/dist/lib/linx-restored-auto-startup.js +21 -0
- package/dist/lib/linx-restored-auto-startup.js.map +1 -0
- package/dist/lib/linx-resume-output.js +209 -0
- package/dist/lib/linx-resume-output.js.map +1 -0
- package/dist/lib/linx-retired-command.js +22 -0
- package/dist/lib/linx-retired-command.js.map +1 -0
- package/dist/lib/linx-rewind-command.js +209 -0
- package/dist/lib/linx-rewind-command.js.map +1 -0
- package/dist/lib/linx-runtime-adapter-contract.js +2 -0
- package/dist/lib/linx-runtime-adapter-contract.js.map +1 -0
- package/dist/lib/linx-runtime-adapter-defaults.js +17 -0
- package/dist/lib/linx-runtime-adapter-defaults.js.map +1 -0
- package/dist/lib/linx-runtime-adapter-dependencies.js +2 -0
- package/dist/lib/linx-runtime-adapter-dependencies.js.map +1 -0
- package/dist/lib/linx-runtime-agent-session.js +130 -0
- package/dist/lib/linx-runtime-agent-session.js.map +1 -0
- package/dist/lib/linx-runtime-auth.js +5 -0
- package/dist/lib/linx-runtime-auth.js.map +1 -0
- package/dist/lib/linx-runtime-backend-composition.js +73 -0
- package/dist/lib/linx-runtime-backend-composition.js.map +1 -0
- package/dist/lib/linx-runtime-coding-tools.js +58 -0
- package/dist/lib/linx-runtime-coding-tools.js.map +1 -0
- package/dist/lib/linx-runtime-completion-backend.js +27 -0
- package/dist/lib/linx-runtime-completion-backend.js.map +1 -0
- package/dist/lib/linx-runtime-oauth-provider.js +57 -0
- package/dist/lib/linx-runtime-oauth-provider.js.map +1 -0
- package/dist/lib/linx-runtime-provider-registration.js +33 -0
- package/dist/lib/linx-runtime-provider-registration.js.map +1 -0
- package/dist/lib/linx-runtime-resources.js +167 -0
- package/dist/lib/linx-runtime-resources.js.map +1 -0
- package/dist/lib/linx-runtime-system-prompt.js +27 -0
- package/dist/lib/linx-runtime-system-prompt.js.map +1 -0
- package/dist/lib/linx-runtime-thinking.js +21 -0
- package/dist/lib/linx-runtime-thinking.js.map +1 -0
- package/dist/lib/linx-selector-choice.js +38 -0
- package/dist/lib/linx-selector-choice.js.map +1 -0
- package/dist/lib/linx-self-update.js +113 -0
- package/dist/lib/linx-self-update.js.map +1 -0
- package/dist/lib/linx-session-command-routing-host.js +24 -0
- package/dist/lib/linx-session-command-routing-host.js.map +1 -0
- package/dist/lib/linx-session-command-routing.js +68 -0
- package/dist/lib/linx-session-command-routing.js.map +1 -0
- package/dist/lib/linx-session-cwd-router.js +15 -0
- package/dist/lib/linx-session-cwd-router.js.map +1 -0
- package/dist/lib/linx-session-history.js +388 -0
- package/dist/lib/linx-session-history.js.map +1 -0
- package/dist/lib/{pi-adapter/session.js → linx-session-manager.js} +94 -46
- package/dist/lib/linx-session-manager.js.map +1 -0
- package/dist/lib/linx-session-metadata.js +55 -0
- package/dist/lib/linx-session-metadata.js.map +1 -0
- package/dist/lib/linx-session-selector-ui.js +32 -0
- package/dist/lib/linx-session-selector-ui.js.map +1 -0
- package/dist/lib/linx-session-thinking-capability-router.js +55 -0
- package/dist/lib/linx-session-thinking-capability-router.js.map +1 -0
- package/dist/lib/linx-session-work-control.js +163 -0
- package/dist/lib/linx-session-work-control.js.map +1 -0
- package/dist/lib/linx-shell-command-executor.js +41 -0
- package/dist/lib/linx-shell-command-executor.js.map +1 -0
- package/dist/lib/linx-shell-command-router.js +151 -0
- package/dist/lib/linx-shell-command-router.js.map +1 -0
- package/dist/lib/{pi-adapter/control-state.js → linx-startup-control-state.js} +6 -6
- package/dist/lib/linx-startup-control-state.js.map +1 -0
- package/dist/lib/linx-startup-login-policy.js +48 -0
- package/dist/lib/linx-startup-login-policy.js.map +1 -0
- package/dist/lib/linx-status-line-command.js +382 -0
- package/dist/lib/linx-status-line-command.js.map +1 -0
- package/dist/lib/{status-line-command.js → linx-status-line-config-command.js} +2 -12
- package/dist/lib/linx-status-line-config-command.js.map +1 -0
- package/dist/lib/linx-status-line.js +12 -4
- package/dist/lib/linx-status-line.js.map +1 -1
- package/dist/lib/linx-stream-abort.js +12 -0
- package/dist/lib/linx-stream-abort.js.map +1 -0
- package/dist/lib/linx-stream-error-formatting.js +54 -0
- package/dist/lib/linx-stream-error-formatting.js.map +1 -0
- package/dist/lib/linx-submitted-user-message-recording.js +16 -0
- package/dist/lib/linx-submitted-user-message-recording.js.map +1 -0
- package/dist/lib/linx-symphony-interactive-command.js +493 -0
- package/dist/lib/linx-symphony-interactive-command.js.map +1 -0
- package/dist/lib/linx-terminal-title-router.js +49 -0
- package/dist/lib/linx-terminal-title-router.js.map +1 -0
- package/dist/lib/{pi-adapter/theme.js → linx-theme.js} +2 -2
- package/dist/lib/linx-theme.js.map +1 -0
- package/dist/lib/linx-top-level-command-admission.js +27 -0
- package/dist/lib/linx-top-level-command-admission.js.map +1 -0
- package/dist/lib/linx-update-notification.js +176 -0
- package/dist/lib/linx-update-notification.js.map +1 -0
- package/dist/lib/linx-welcome-header.js +148 -0
- package/dist/lib/linx-welcome-header.js.map +1 -0
- package/dist/lib/linx-workspace-command.js +45 -0
- package/dist/lib/linx-workspace-command.js.map +1 -0
- package/dist/lib/native-backend-command-router.js +25 -0
- package/dist/lib/native-backend-command-router.js.map +1 -0
- package/dist/lib/native-backend-proxy.js +2 -0
- package/dist/lib/native-backend-proxy.js.map +1 -0
- package/dist/lib/native-backend-stream-backend.js +15 -0
- package/dist/lib/native-backend-stream-backend.js.map +1 -0
- package/dist/lib/oidc-auth.js +2 -4
- package/dist/lib/oidc-auth.js.map +1 -1
- package/dist/lib/pi-adapter/runtime.js +32 -841
- package/dist/lib/pi-adapter/runtime.js.map +1 -1
- package/dist/lib/pi-adapter/stream.js +17 -516
- package/dist/lib/pi-adapter/stream.js.map +1 -1
- package/dist/lib/{pi-adapter/pod-approval.js → pod-backed-extension-ui-context.js} +2 -2
- package/dist/lib/pod-backed-extension-ui-context.js.map +1 -0
- package/dist/lib/pod-chat-store-runtime.js +38 -0
- package/dist/lib/pod-chat-store-runtime.js.map +1 -0
- package/dist/lib/pod-chat-store.js +15 -65
- package/dist/lib/pod-chat-store.js.map +1 -1
- package/dist/lib/{pi-adapter/pod-mirror-mapping.js → pod-mirror-mapping.js} +8 -18
- package/dist/lib/pod-mirror-mapping.js.map +1 -0
- package/dist/lib/{pi-adapter/pod-native.js → pod-native.js} +1 -1
- package/dist/lib/pod-native.js.map +1 -0
- package/dist/lib/pod-status-output.js.map +1 -0
- package/dist/lib/{pi-adapter/auto-input-controller.js → secretary-auto-input-controller.js} +62 -77
- package/dist/lib/secretary-auto-input-controller.js.map +1 -0
- package/dist/lib/{pi-adapter/session-control.js → session-control.js} +80 -29
- package/dist/lib/session-control.js.map +1 -0
- package/dist/lib/shell-lifecycle.js +179 -0
- package/dist/lib/shell-lifecycle.js.map +1 -0
- package/dist/lib/solid-local-store.js +3 -3
- package/dist/lib/solid-local-store.js.map +1 -1
- package/dist/lib/symphony/pod-projection.js +1 -31
- package/dist/lib/symphony/pod-projection.js.map +1 -1
- package/dist/lib/{symphony-command.js → symphony/run.js} +11 -16
- package/dist/lib/symphony/run.js.map +1 -0
- package/dist/lib/symphony/runtime.js +30 -0
- package/dist/lib/symphony/runtime.js.map +1 -0
- package/dist/lib/symphony/status.js +242 -0
- package/dist/lib/symphony/status.js.map +1 -0
- package/dist/linx-cli-app.js +70 -0
- package/dist/linx-cli-app.js.map +1 -0
- package/dist/linx-cli-runtime-adapter-factory.js +12 -0
- package/dist/linx-cli-runtime-adapter-factory.js.map +1 -0
- package/dist/plugins/linx-symphony-codex/.codex-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/dist/lib/auto-mode/hooks/index.js.map +0 -1
- package/dist/lib/auto-mode/index.js +0 -10
- package/dist/lib/auto-mode/index.js.map +0 -1
- package/dist/lib/codex-plugin/index.js +0 -5
- package/dist/lib/codex-plugin/index.js.map +0 -1
- package/dist/lib/pi-adapter/auth.js +0 -68
- package/dist/lib/pi-adapter/auth.js.map +0 -1
- package/dist/lib/pi-adapter/auto-input-controller.js.map +0 -1
- package/dist/lib/pi-adapter/backend-command.js +0 -2
- package/dist/lib/pi-adapter/backend-command.js.map +0 -1
- package/dist/lib/pi-adapter/backend-credentials.js.map +0 -1
- package/dist/lib/pi-adapter/branding.js +0 -1188
- package/dist/lib/pi-adapter/branding.js.map +0 -1
- package/dist/lib/pi-adapter/control-state.js.map +0 -1
- package/dist/lib/pi-adapter/index.js +0 -4
- package/dist/lib/pi-adapter/index.js.map +0 -1
- package/dist/lib/pi-adapter/interactive.js +0 -3186
- package/dist/lib/pi-adapter/interactive.js.map +0 -1
- package/dist/lib/pi-adapter/pod-approval.js.map +0 -1
- package/dist/lib/pi-adapter/pod-mirror-mapping.js.map +0 -1
- package/dist/lib/pi-adapter/pod-mirror.js.map +0 -1
- package/dist/lib/pi-adapter/pod-native.js.map +0 -1
- package/dist/lib/pi-adapter/pod-status-output.js.map +0 -1
- package/dist/lib/pi-adapter/pod-tools.js +0 -140
- package/dist/lib/pi-adapter/pod-tools.js.map +0 -1
- package/dist/lib/pi-adapter/session-control.js.map +0 -1
- package/dist/lib/pi-adapter/session.js.map +0 -1
- package/dist/lib/pi-adapter/sync-recovery.js.map +0 -1
- package/dist/lib/pi-adapter/theme.js.map +0 -1
- package/dist/lib/pi-adapter/web-fetch.js +0 -170
- package/dist/lib/pi-adapter/web-fetch.js.map +0 -1
- package/dist/lib/status-line-command.js.map +0 -1
- package/dist/lib/symphony-command.js.map +0 -1
- /package/dist/lib/{pi-adapter/pod-status-output.js → pod-status-output.js} +0 -0
|
@@ -1,852 +1,43 @@
|
|
|
1
1
|
import { createLinxAgentStreamAdapter } from './stream.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ensureLinxPiTheme } from './theme.js';
|
|
5
|
-
import { AuthStorage, ModelRegistry, SettingsManager, createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createCodingTools, createLocalBashOperations, } from '@earendil-works/pi-coding-agent';
|
|
6
|
-
// web_fetch / web_search are now handled by pi-web-access
|
|
7
|
-
import { existsSync, mkdirSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
|
8
|
-
import { homedir } from 'node:os';
|
|
9
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
10
|
-
import { createRequire } from 'node:module';
|
|
11
|
-
import { fileURLToPath } from 'node:url';
|
|
12
|
-
import { RemoteChatRequestError, isRemoteAuthExpiredError } from '../chat-api.js';
|
|
13
|
-
import { formatLinxCloudTransientMessage } from '../linx-cloud-errors.js';
|
|
14
|
-
import { clearDefaultPodDataSession, getDefaultPodDataSession } from '../pod-data-session.js';
|
|
15
|
-
import { loadCredentials } from '../credentials-store.js';
|
|
16
|
-
import { getSolidLinxAppDir, getSolidLinxPiWebAccessConfigPath } from '../solid-local-store.js';
|
|
17
|
-
const UNDEFINEDS_PROVIDER_ID = 'undefineds';
|
|
18
|
-
const UNDEFINEDS_PROVIDER_LABEL = 'LinX Cloud';
|
|
19
|
-
const UNDEFINEDS_PROVIDER_API = 'linx-cloud-chat-completions';
|
|
20
|
-
const UNDEFINEDS_SESSION_ID = 'undefineds_pi_frontend';
|
|
21
|
-
const UNDEFINEDS_AUTH_BRIDGE_ID = 'undefineds-cloud-oauth-bridge';
|
|
22
|
-
export const LINX_RUNTIME_MANAGED_AUTH_KEY = 'linx-runtime-managed-auth';
|
|
23
|
-
const LINX_PACKAGE_SOURCE = '@undefineds.co/linx';
|
|
24
|
-
const LINX_WEB_ACCESS_PACKAGE_SOURCE = 'pi-web-access';
|
|
25
|
-
const LINX_PRODUCT_SKILL_NAMES = new Set(['symphony', 'xpod-cli']);
|
|
26
|
-
const MARKET_XPOD_CLI_SKILL_SOURCE = 'xpod-cli@undefineds';
|
|
27
|
-
export const DEFAULT_LINX_PI_BASH_TIMEOUT_SECONDS = 15;
|
|
28
|
-
const DEFAULT_LINX_CLOUD_CONTEXT_WINDOW = 1_000_000;
|
|
29
|
-
const DEFAULT_LINX_CLOUD_COMPLETION_TIMEOUT_MS = 10 * 60 * 1000;
|
|
30
|
-
export async function resolveLinxStartupLoginPromptDecision(options) {
|
|
31
|
-
if (options.print) {
|
|
32
|
-
return { shouldPrompt: false, reason: 'print-mode' };
|
|
33
|
-
}
|
|
34
|
-
if (options.backend === 'native') {
|
|
35
|
-
return { shouldPrompt: false, reason: 'native-backend' };
|
|
36
|
-
}
|
|
37
|
-
if (!options.resolveSession) {
|
|
38
|
-
return (options.loadStoredCredentials ?? loadCredentials)()
|
|
39
|
-
? { shouldPrompt: false, reason: 'credential-present' }
|
|
40
|
-
: { shouldPrompt: true, reason: 'missing-credential' };
|
|
41
|
-
}
|
|
42
|
-
const resolveSession = options.resolveSession;
|
|
43
|
-
let session = null;
|
|
44
|
-
try {
|
|
45
|
-
session = await resolveSession();
|
|
46
|
-
return session
|
|
47
|
-
? { shouldPrompt: false, reason: 'credential-present' }
|
|
48
|
-
: { shouldPrompt: true, reason: 'missing-credential' };
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
if (isOidcLoginExpiredError(error)) {
|
|
52
|
-
return { shouldPrompt: true, reason: 'expired-credential' };
|
|
53
|
-
}
|
|
54
|
-
if (isOidcTransientRemoteError(error) && (options.loadStoredCredentials ?? loadCredentials)()) {
|
|
55
|
-
return { shouldPrompt: false, reason: 'credential-present' };
|
|
56
|
-
}
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
await session?.close().catch(() => undefined);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export function resolveLinxStartupLoginReason(decision) {
|
|
64
|
-
if (!decision.shouldPrompt) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
return decision.reason === 'expired-credential' ? 'expired' : 'startup';
|
|
68
|
-
}
|
|
69
|
-
export function resolveLinxInteractiveLoginReason(options) {
|
|
70
|
-
if (options.runtimePromptOnStart) {
|
|
71
|
-
return 'expired';
|
|
72
|
-
}
|
|
73
|
-
return resolveLinxStartupLoginReason(options.startupDecision);
|
|
74
|
-
}
|
|
2
|
+
import { createLinxAgentSessionRuntime, } from '../linx-runtime-agent-session.js';
|
|
3
|
+
import { createRuntimeBackendComposition, } from '../linx-runtime-backend-composition.js';
|
|
75
4
|
export function createLinxRuntimeAdapter(dependencies, options = {}) {
|
|
76
|
-
const
|
|
77
|
-
const workerBackend = options.workerBackend ?? (backendMode === 'native' ? 'codex' : undefined);
|
|
78
|
-
const cwd = options.cwd ?? process.cwd();
|
|
79
|
-
const requestedModel = options.model?.trim() || undefined;
|
|
80
|
-
let activeModelId = requestedModel ?? DEFAULT_LINX_CLOUD_MODEL_ID;
|
|
81
|
-
const baseUrl = options.providerConfig?.baseUrl ?? 'https://api.undefineds.co/v1';
|
|
82
|
-
let shouldPromptLoginOnStart = false;
|
|
83
|
-
const providerModels = buildFallbackProviderModels(activeModelId);
|
|
84
|
-
const proxy = backendMode === 'native'
|
|
85
|
-
? dependencies.createNativeProxy?.({
|
|
86
|
-
cwd,
|
|
87
|
-
model: requestedModel,
|
|
88
|
-
listenPort: options.port,
|
|
89
|
-
autoEnabled: options.autoEnabled,
|
|
90
|
-
codexApprovalPolicy: options.codexApprovalPolicy,
|
|
91
|
-
passthroughArgs: options.passthroughArgs,
|
|
92
|
-
env: options.backendEnv,
|
|
93
|
-
resolveEnv: options.resolveBackendEnv,
|
|
94
|
-
})
|
|
95
|
-
: null;
|
|
96
|
-
if (backendMode === 'native' && !proxy) {
|
|
97
|
-
throw new Error('Native LinX runtime backend requires createNativeProxy');
|
|
98
|
-
}
|
|
99
|
-
if (backendMode === 'cloud' && !options.providerConfig?.oauth && !dependencies.createRemoteCompletion) {
|
|
100
|
-
throw new Error('Cloud LinX runtime backend requires createRemoteCompletion');
|
|
101
|
-
}
|
|
5
|
+
const runtime = createRuntimeBackendComposition(dependencies, options);
|
|
102
6
|
const streamAdapter = createLinxAgentStreamAdapter({
|
|
103
|
-
sessionId:
|
|
104
|
-
cwd:
|
|
105
|
-
model:
|
|
106
|
-
backend:
|
|
107
|
-
|
|
108
|
-
sendTurn(input) {
|
|
109
|
-
return proxy.sendTurn(input);
|
|
110
|
-
},
|
|
111
|
-
subscribe(listener) {
|
|
112
|
-
return proxy.subscribe(listener);
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
: undefined,
|
|
116
|
-
completionBackend: !proxy && dependencies.createRemoteCompletion
|
|
117
|
-
? {
|
|
118
|
-
async complete(input) {
|
|
119
|
-
const authFetch = options.providerConfig?.oauth
|
|
120
|
-
? input.authFetch
|
|
121
|
-
?? resolveRuntimeAuthFetchFromApiKey(input.apiKey)
|
|
122
|
-
?? await resolveLinxPiCloudAuthFetch({
|
|
123
|
-
issuerUrl: options.providerConfig?.issuerUrl,
|
|
124
|
-
getPodDataSession: options.getPodDataSession,
|
|
125
|
-
})
|
|
126
|
-
: await resolveLinxPiCloudAuthFetch({
|
|
127
|
-
issuerUrl: options.providerConfig?.issuerUrl,
|
|
128
|
-
getPodDataSession: options.getPodDataSession,
|
|
129
|
-
});
|
|
130
|
-
return completeWithAuthRecovery(authFetch, {
|
|
131
|
-
runtimeUrl: baseUrl,
|
|
132
|
-
model: input.model,
|
|
133
|
-
messages: withSystemPrompt(input.systemPrompt, input.messages),
|
|
134
|
-
tools: input.tools,
|
|
135
|
-
signal: input.signal,
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
}
|
|
139
|
-
: undefined,
|
|
7
|
+
sessionId: runtime.sessionId,
|
|
8
|
+
cwd: runtime.cwd,
|
|
9
|
+
model: runtime.model,
|
|
10
|
+
backend: runtime.streamBackend,
|
|
11
|
+
completionBackend: runtime.completionBackend,
|
|
140
12
|
});
|
|
141
|
-
const backendCommandRouter = proxy && typeof proxy.executeCommand === 'function'
|
|
142
|
-
? {
|
|
143
|
-
backend: proxy.record.backend,
|
|
144
|
-
execute(input) {
|
|
145
|
-
return proxy.executeCommand(input);
|
|
146
|
-
},
|
|
147
|
-
setCwd: typeof proxy.setCwd === 'function'
|
|
148
|
-
? (nextCwd) => proxy.setCwd(nextCwd)
|
|
149
|
-
: undefined,
|
|
150
|
-
subscribe(listener) {
|
|
151
|
-
return proxy.subscribe(listener);
|
|
152
|
-
},
|
|
153
|
-
setSessionControl: typeof proxy.setSessionControl === 'function'
|
|
154
|
-
? (control) => proxy.setSessionControl(control)
|
|
155
|
-
: undefined,
|
|
156
|
-
}
|
|
157
|
-
: undefined;
|
|
158
13
|
return {
|
|
159
|
-
remoteUrl:
|
|
160
|
-
sessionId:
|
|
161
|
-
cwd:
|
|
162
|
-
model:
|
|
14
|
+
remoteUrl: runtime.remoteUrl,
|
|
15
|
+
sessionId: runtime.sessionId,
|
|
16
|
+
cwd: runtime.cwd,
|
|
17
|
+
model: runtime.model,
|
|
163
18
|
backend: 'linx',
|
|
164
|
-
runtimeBackend: workerBackend,
|
|
165
|
-
autoEnabled:
|
|
166
|
-
symphonyEnabled:
|
|
167
|
-
backendCommandRouter,
|
|
19
|
+
runtimeBackend: runtime.workerBackend,
|
|
20
|
+
autoEnabled: runtime.autoEnabled,
|
|
21
|
+
symphonyEnabled: runtime.symphonyEnabled,
|
|
22
|
+
backendCommandRouter: runtime.commandRouter,
|
|
168
23
|
streamAdapter,
|
|
169
|
-
createRuntime: async (context) => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
onAuthUrl(url) {
|
|
184
|
-
callbacks.onAuth({
|
|
185
|
-
url,
|
|
186
|
-
instructions: 'Complete LinX Cloud consent in your browser. If the local callback is blocked, paste the final redirect URL below.',
|
|
187
|
-
});
|
|
188
|
-
},
|
|
189
|
-
manualRedirectUrl: callbacks.onManualCodeInput,
|
|
190
|
-
});
|
|
191
|
-
clearDefaultPodDataSession();
|
|
192
|
-
if (result.reusedExistingSession) {
|
|
193
|
-
callbacks.onProgress?.('Reused existing LinX Cloud session.');
|
|
194
|
-
}
|
|
195
|
-
const authFetch = await resolveLinxPiCloudAuthFetch({
|
|
196
|
-
issuerUrl: options.providerConfig?.issuerUrl,
|
|
197
|
-
getPodDataSession: options.getPodDataSession,
|
|
198
|
-
});
|
|
199
|
-
await syncProviderModels({ runtimeFetch: authFetch });
|
|
200
|
-
return {
|
|
201
|
-
refresh: result.tokenSet.refreshToken ?? '',
|
|
202
|
-
access: LINX_RUNTIME_MANAGED_AUTH_KEY,
|
|
203
|
-
expires: result.tokenSet.expiresAt ? result.tokenSet.expiresAt * 1000 : Date.now() + 60 * 60 * 1000,
|
|
204
|
-
};
|
|
205
|
-
},
|
|
206
|
-
async refreshToken(credentials) {
|
|
207
|
-
clearDefaultPodDataSession();
|
|
208
|
-
const authFetch = await resolveLinxPiCloudAuthFetch({
|
|
209
|
-
issuerUrl: options.providerConfig?.issuerUrl,
|
|
210
|
-
getPodDataSession: options.getPodDataSession,
|
|
211
|
-
});
|
|
212
|
-
await syncProviderModels({ runtimeFetch: authFetch });
|
|
213
|
-
return {
|
|
214
|
-
type: 'oauth',
|
|
215
|
-
refresh: credentials.refresh,
|
|
216
|
-
access: LINX_RUNTIME_MANAGED_AUTH_KEY,
|
|
217
|
-
expires: Date.now() + 60 * 60 * 1000,
|
|
218
|
-
};
|
|
219
|
-
},
|
|
220
|
-
getApiKey(credentials) {
|
|
221
|
-
return credentials.access === LINX_RUNTIME_MANAGED_AUTH_KEY
|
|
222
|
-
? LINX_RUNTIME_MANAGED_AUTH_KEY
|
|
223
|
-
: LINX_RUNTIME_MANAGED_AUTH_KEY;
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
const storedCredentials = options.providerConfig?.oauth ? null : loadCredentials();
|
|
227
|
-
const hasManagedPodSession = !options.providerConfig?.oauth && Boolean(options.getPodDataSession);
|
|
228
|
-
const explicitOAuthCredential = options.providerConfig?.oauth
|
|
229
|
-
? await options.providerConfig.oauth.login()
|
|
230
|
-
: null;
|
|
231
|
-
if (storedCredentials || hasManagedPodSession) {
|
|
232
|
-
const authFetch = await resolveLinxPiCloudAuthFetch({
|
|
233
|
-
issuerUrl: options.providerConfig?.issuerUrl,
|
|
234
|
-
getPodDataSession: options.getPodDataSession,
|
|
235
|
-
});
|
|
236
|
-
await syncProviderModels({ runtimeFetch: authFetch }, { refreshOnAuthExpired: true });
|
|
237
|
-
}
|
|
238
|
-
else if (explicitOAuthCredential?.access) {
|
|
239
|
-
await syncProviderModels({ runtimeFetch: createBearerAuthFetch(explicitOAuthCredential.access) });
|
|
240
|
-
}
|
|
241
|
-
modelRegistry.registerProvider(UNDEFINEDS_PROVIDER_ID, {
|
|
242
|
-
api: UNDEFINEDS_PROVIDER_API,
|
|
243
|
-
baseUrl,
|
|
244
|
-
apiKey: '$LINX_RUNTIME_AUTH',
|
|
245
|
-
oauth: linxOAuthProvider,
|
|
246
|
-
authHeader: false,
|
|
247
|
-
streamSimple: streamAdapter.streamFn,
|
|
248
|
-
models: providerModels,
|
|
249
|
-
});
|
|
250
|
-
if (!options.providerConfig?.oauth) {
|
|
251
|
-
authStorage.setRuntimeApiKey(UNDEFINEDS_PROVIDER_ID, LINX_RUNTIME_MANAGED_AUTH_KEY);
|
|
252
|
-
}
|
|
253
|
-
if (options.providerConfig?.oauth && explicitOAuthCredential) {
|
|
254
|
-
authStorage.set(UNDEFINEDS_PROVIDER_ID, { type: 'oauth', ...explicitOAuthCredential });
|
|
255
|
-
}
|
|
256
|
-
const settingsManager = SettingsManager.create(context.cwd, context.agentDir);
|
|
257
|
-
ensureLinxPiTheme(context.agentDir);
|
|
258
|
-
ensurePiWebAccessConfig();
|
|
259
|
-
settingsManager.setTheme('linx');
|
|
260
|
-
const defaultModelId = sanitizeLinxCloudDefaults(settingsManager, requestedModel, providerModels);
|
|
261
|
-
activeModelId = defaultModelId;
|
|
262
|
-
const bundledSkillsDir = resolveBundledLinxSkillsDir();
|
|
263
|
-
const marketSkillDirs = resolveInstalledMarketSkillDirs();
|
|
264
|
-
const additionalSkillPaths = [
|
|
265
|
-
...(bundledSkillsDir ? [bundledSkillsDir] : []),
|
|
266
|
-
...marketSkillDirs,
|
|
267
|
-
];
|
|
268
|
-
const bundledPackagePaths = [
|
|
269
|
-
resolveBundledPiPackageRoot(LINX_WEB_ACCESS_PACKAGE_SOURCE),
|
|
270
|
-
].filter((path) => Boolean(path));
|
|
271
|
-
const services = await createAgentSessionServices({
|
|
272
|
-
cwd: context.cwd,
|
|
273
|
-
agentDir: context.agentDir,
|
|
274
|
-
authStorage,
|
|
275
|
-
settingsManager,
|
|
276
|
-
modelRegistry,
|
|
277
|
-
resourceLoaderOptions: {
|
|
278
|
-
// Built-in: pi-web-access handles web_search, fetch_content, and related web tools.
|
|
279
|
-
additionalExtensionPaths: bundledPackagePaths,
|
|
280
|
-
additionalSkillPaths,
|
|
281
|
-
skillsOverride: (base) => withLinxSkillSourceInfo(base, {
|
|
282
|
-
bundledSkillsDir,
|
|
283
|
-
marketSkillDirs,
|
|
284
|
-
}),
|
|
285
|
-
systemPromptOverride: overrideLinxSystemPrompt,
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
const selectedModel = modelRegistry.find(UNDEFINEDS_PROVIDER_ID, defaultModelId)
|
|
289
|
-
?? modelRegistry.getAvailable().find((candidate) => candidate.provider === UNDEFINEDS_PROVIDER_ID);
|
|
290
|
-
if (!selectedModel) {
|
|
291
|
-
throw new Error('Failed to resolve undefineds model from the LinX runtime adapter');
|
|
292
|
-
}
|
|
293
|
-
const created = await createAgentSessionFromServices({
|
|
294
|
-
services,
|
|
295
|
-
sessionManager: context.sessionManager,
|
|
296
|
-
sessionStartEvent: context.sessionStartEvent,
|
|
297
|
-
model: selectedModel,
|
|
298
|
-
});
|
|
299
|
-
const session = created.session;
|
|
300
|
-
enableLinxXhighThinking(session);
|
|
301
|
-
if (session.model?.provider !== selectedModel.provider || session.model.id !== selectedModel.id) {
|
|
302
|
-
await session.setModel(selectedModel);
|
|
303
|
-
}
|
|
304
|
-
const runtime = await createAgentSessionRuntime(async () => ({
|
|
305
|
-
...created,
|
|
306
|
-
session,
|
|
307
|
-
services,
|
|
308
|
-
diagnostics: services.diagnostics,
|
|
309
|
-
}), {
|
|
310
|
-
cwd: context.cwd,
|
|
311
|
-
agentDir: context.agentDir,
|
|
312
|
-
sessionManager: context.sessionManager,
|
|
313
|
-
sessionStartEvent: context.sessionStartEvent,
|
|
314
|
-
});
|
|
315
|
-
runtime.backend = 'linx';
|
|
316
|
-
runtime.runtimeBackend = workerBackend;
|
|
317
|
-
runtime.autoEnabled = options.autoEnabled === true;
|
|
318
|
-
runtime.symphonyEnabled = options.symphonyEnabled === true;
|
|
319
|
-
runtime.linxAuthBridge = {
|
|
320
|
-
description: UNDEFINEDS_AUTH_BRIDGE_ID,
|
|
321
|
-
providerId: UNDEFINEDS_PROVIDER_ID,
|
|
322
|
-
providerLabel: UNDEFINEDS_PROVIDER_LABEL,
|
|
323
|
-
runtimeUrl: baseUrl,
|
|
324
|
-
shouldPromptLoginOnStart,
|
|
325
|
-
};
|
|
326
|
-
if (backendCommandRouter) {
|
|
327
|
-
;
|
|
328
|
-
runtime.backendCommandRouter = backendCommandRouter;
|
|
329
|
-
}
|
|
330
|
-
if (proxy) {
|
|
331
|
-
;
|
|
332
|
-
runtime.backendSessionRef = proxy.record;
|
|
333
|
-
}
|
|
334
|
-
if (options.getPodDataSession) {
|
|
335
|
-
;
|
|
336
|
-
runtime.getPodDataSession = options.getPodDataSession;
|
|
337
|
-
}
|
|
338
|
-
return runtime;
|
|
339
|
-
},
|
|
340
|
-
async start() {
|
|
341
|
-
await proxy?.start();
|
|
342
|
-
},
|
|
343
|
-
async close() {
|
|
344
|
-
await proxy?.close();
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
async function syncProviderModels(authSession, options = {}) {
|
|
348
|
-
if (!dependencies.listRemoteModels) {
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
const remoteModels = await listRemoteModelsWithAuthRecovery(authSession.runtimeFetch, options);
|
|
352
|
-
if (remoteModels.length === 0) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
const mergedModels = mergeLinxProviderModels(remoteModels.map((entry) => ({
|
|
356
|
-
id: entry.id,
|
|
357
|
-
contextWindow: entry.contextWindow,
|
|
358
|
-
})), activeModelId);
|
|
359
|
-
const nextModels = mergedModels.map((entry) => buildProviderModel(entry));
|
|
360
|
-
providerModels.splice(0, providerModels.length, ...nextModels);
|
|
361
|
-
if (!requestedModel) {
|
|
362
|
-
activeModelId = resolvePreferredLinxCloudModelId(nextModels, activeModelId);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
async function listRemoteModelsWithAuthRecovery(authFetch, recoveryOptions) {
|
|
366
|
-
try {
|
|
367
|
-
return await dependencies.listRemoteModels(authFetch, baseUrl, { fallback: false, timeoutMs: 5000 });
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
if (!isAuthExpiredError(error)) {
|
|
371
|
-
return [];
|
|
372
|
-
}
|
|
373
|
-
if (recoveryOptions.refreshOnAuthExpired) {
|
|
374
|
-
try {
|
|
375
|
-
const refreshedAuthFetch = await resolveRefreshedLinxPiCloudAuthFetch();
|
|
376
|
-
if (refreshedAuthFetch) {
|
|
377
|
-
return await dependencies.listRemoteModels(refreshedAuthFetch, baseUrl, { fallback: false, timeoutMs: 5000 });
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
catch (retryError) {
|
|
381
|
-
if (!isAuthExpiredError(retryError)) {
|
|
382
|
-
return [];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
shouldPromptLoginOnStart = true;
|
|
387
|
-
if (recoveryOptions.throwAuthExpired) {
|
|
388
|
-
throw error;
|
|
389
|
-
}
|
|
390
|
-
return [];
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
async function completeWithAuthRecovery(authFetch, request) {
|
|
394
|
-
try {
|
|
395
|
-
return await dependencies.createRemoteCompletion({
|
|
396
|
-
...request,
|
|
397
|
-
authFetch,
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
if (!isAuthExpiredError(error)) {
|
|
402
|
-
throw error;
|
|
403
|
-
}
|
|
404
|
-
const refreshedAuthFetch = await resolveRefreshedLinxPiCloudAuthFetch();
|
|
405
|
-
if (!refreshedAuthFetch) {
|
|
406
|
-
throw error;
|
|
407
|
-
}
|
|
408
|
-
return dependencies.createRemoteCompletion({
|
|
409
|
-
...request,
|
|
410
|
-
authFetch: refreshedAuthFetch,
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
async function resolveRefreshedLinxPiCloudAuthFetch() {
|
|
415
|
-
clearDefaultPodDataSession();
|
|
416
|
-
const storedCredentials = loadCredentials();
|
|
417
|
-
if (storedCredentials || options.getPodDataSession) {
|
|
418
|
-
return resolveLinxPiCloudAuthFetch({
|
|
419
|
-
issuerUrl: options.providerConfig?.issuerUrl,
|
|
420
|
-
getPodDataSession: options.getPodDataSession,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
return null;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
/** @deprecated Use createLinxRuntimeAdapter. */
|
|
427
|
-
export const createPiRuntimeAdapter = createLinxRuntimeAdapter;
|
|
428
|
-
export function resolveBundledLinxSkillsDir(importMetaUrl = import.meta.url) {
|
|
429
|
-
const moduleDir = dirname(fileURLToPath(importMetaUrl));
|
|
430
|
-
const candidates = [
|
|
431
|
-
// Published package: dist/lib/pi-adapter/runtime.js -> dist/skills.
|
|
432
|
-
// This directory is a curated product-skill bundle, not the repo skill root.
|
|
433
|
-
join(moduleDir, '..', '..', 'skills'),
|
|
434
|
-
// Test/dev bundle: <tmp>/dist/lib/pi-adapter/runtime.js -> curated product skills.
|
|
435
|
-
resolve(moduleDir, '..', '..', '..', '..', 'skills'),
|
|
436
|
-
// Source-tree fallback when running through a TS loader.
|
|
437
|
-
resolve(moduleDir, '..', '..', '..', '..', '..', 'skills'),
|
|
438
|
-
];
|
|
439
|
-
for (const candidate of candidates) {
|
|
440
|
-
if (existsSync(candidate)) {
|
|
441
|
-
return candidate;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
return null;
|
|
445
|
-
}
|
|
446
|
-
function ensurePiWebAccessConfig() {
|
|
447
|
-
const config = JSON.stringify({ workflow: 'none' }, null, 2) + '\n';
|
|
448
|
-
const linxPath = getSolidLinxPiWebAccessConfigPath();
|
|
449
|
-
const linxDir = getSolidLinxAppDir();
|
|
450
|
-
if (!existsSync(linxDir)) {
|
|
451
|
-
mkdirSync(linxDir, { recursive: true });
|
|
452
|
-
}
|
|
453
|
-
if (!existsSync(linxPath))
|
|
454
|
-
writeFileSync(linxPath, config);
|
|
455
|
-
}
|
|
456
|
-
export function resolveBundledPiPackageRoot(packageName, importMetaUrl = import.meta.url) {
|
|
457
|
-
const moduleDir = dirname(fileURLToPath(importMetaUrl));
|
|
458
|
-
const vendoredCandidates = [
|
|
459
|
-
// Published/built package: dist/lib/pi-adapter/runtime.js -> vendor/<package>.
|
|
460
|
-
resolve(moduleDir, '..', '..', '..', 'vendor', packageName),
|
|
461
|
-
// Defensive fallback for layouts that place vendor under dist.
|
|
462
|
-
resolve(moduleDir, '..', '..', 'vendor', packageName),
|
|
463
|
-
];
|
|
464
|
-
for (const candidate of vendoredCandidates) {
|
|
465
|
-
if (existsSync(join(candidate, 'package.json'))) {
|
|
466
|
-
return candidate;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
try {
|
|
470
|
-
const requireFromRuntime = createRequire(importMetaUrl);
|
|
471
|
-
return dirname(requireFromRuntime.resolve(`${packageName}/package.json`));
|
|
472
|
-
}
|
|
473
|
-
catch {
|
|
474
|
-
return null;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
function withLinxSkillSourceInfo(base, options) {
|
|
478
|
-
const { bundledSkillsDir, marketSkillDirs } = options;
|
|
479
|
-
const bundledProductSkillNames = new Set();
|
|
480
|
-
if (bundledSkillsDir) {
|
|
481
|
-
for (const skill of base.skills) {
|
|
482
|
-
if (skill.filePath.startsWith(bundledSkillsDir) && LINX_PRODUCT_SKILL_NAMES.has(skill.name)) {
|
|
483
|
-
bundledProductSkillNames.add(skill.name);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
const filteredSkills = base.skills.filter((skill) => (!(bundledSkillsDir
|
|
488
|
-
&& skill.filePath.startsWith(bundledSkillsDir)
|
|
489
|
-
&& !LINX_PRODUCT_SKILL_NAMES.has(skill.name))
|
|
490
|
-
&& !(marketSkillDirs.some((dir) => skill.filePath.startsWith(dir))
|
|
491
|
-
&& bundledProductSkillNames.has(skill.name))));
|
|
492
|
-
return {
|
|
493
|
-
...base,
|
|
494
|
-
skills: filteredSkills.map((skill) => {
|
|
495
|
-
if (bundledSkillsDir && skill.filePath.startsWith(bundledSkillsDir)) {
|
|
496
|
-
return {
|
|
497
|
-
...skill,
|
|
498
|
-
sourceInfo: {
|
|
499
|
-
path: skill.filePath,
|
|
500
|
-
source: LINX_PACKAGE_SOURCE,
|
|
501
|
-
scope: 'temporary',
|
|
502
|
-
origin: 'package',
|
|
503
|
-
baseDir: bundledSkillsDir,
|
|
504
|
-
},
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
const marketSkillDir = marketSkillDirs.find((dir) => skill.filePath.startsWith(dir));
|
|
508
|
-
if (marketSkillDir) {
|
|
509
|
-
return {
|
|
510
|
-
...skill,
|
|
511
|
-
sourceInfo: {
|
|
512
|
-
path: skill.filePath,
|
|
513
|
-
source: MARKET_XPOD_CLI_SKILL_SOURCE,
|
|
514
|
-
scope: 'temporary',
|
|
515
|
-
origin: 'marketplace',
|
|
516
|
-
version: resolveMarketSkillVersion(marketSkillDir),
|
|
517
|
-
baseDir: marketSkillDir,
|
|
518
|
-
},
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
return skill;
|
|
24
|
+
createRuntime: async (context) => createLinxAgentSessionRuntime({
|
|
25
|
+
context,
|
|
26
|
+
baseUrl: runtime.baseUrl,
|
|
27
|
+
requestedModel: runtime.requestedModel,
|
|
28
|
+
streamSimple: streamAdapter.streamFn,
|
|
29
|
+
cloudRuntime: runtime.cloudRuntime,
|
|
30
|
+
issuerUrl: runtime.issuerUrl,
|
|
31
|
+
oauth: runtime.oauth,
|
|
32
|
+
getPodDataSession: runtime.getPodDataSession,
|
|
33
|
+
workerBackend: runtime.workerBackend,
|
|
34
|
+
backendCommandRouter: runtime.commandRouter,
|
|
35
|
+
backendSessionRef: runtime.backendSessionRef,
|
|
36
|
+
autoEnabled: runtime.autoEnabled,
|
|
37
|
+
symphonyEnabled: runtime.symphonyEnabled,
|
|
522
38
|
}),
|
|
39
|
+
start: () => runtime.start(),
|
|
40
|
+
close: () => runtime.close(),
|
|
523
41
|
};
|
|
524
42
|
}
|
|
525
|
-
export function resolveInstalledMarketSkillDirs() {
|
|
526
|
-
return [resolveInstalledXpodCliMarketSkillDir()].filter((path) => Boolean(path));
|
|
527
|
-
}
|
|
528
|
-
function resolveInstalledXpodCliMarketSkillDir() {
|
|
529
|
-
const codexHome = process.env.CODEX_HOME?.trim() || join(homedir(), '.codex');
|
|
530
|
-
const versionsRoot = join(codexHome, 'plugins', 'cache', 'undefineds', 'xpod-cli');
|
|
531
|
-
if (!existsSync(versionsRoot)) {
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
const candidates = [];
|
|
535
|
-
for (const entry of safeReadDir(versionsRoot)) {
|
|
536
|
-
const versionDir = join(versionsRoot, entry);
|
|
537
|
-
if (!safeIsDirectory(versionDir)) {
|
|
538
|
-
continue;
|
|
539
|
-
}
|
|
540
|
-
const skillDir = join(versionDir, 'skills', 'xpod-cli');
|
|
541
|
-
if (existsSync(join(skillDir, 'SKILL.md'))) {
|
|
542
|
-
candidates.push({ version: entry, dir: skillDir });
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
candidates.sort((a, b) => compareVersionLike(b.version, a.version));
|
|
546
|
-
return candidates[0]?.dir ?? null;
|
|
547
|
-
}
|
|
548
|
-
function resolveMarketSkillVersion(skillDir) {
|
|
549
|
-
const version = basename(dirname(dirname(skillDir)));
|
|
550
|
-
return version && version !== 'skills' ? version : undefined;
|
|
551
|
-
}
|
|
552
|
-
function safeReadDir(dir) {
|
|
553
|
-
try {
|
|
554
|
-
return readdirSync(dir);
|
|
555
|
-
}
|
|
556
|
-
catch {
|
|
557
|
-
return [];
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function safeIsDirectory(path) {
|
|
561
|
-
try {
|
|
562
|
-
return statSync(path).isDirectory();
|
|
563
|
-
}
|
|
564
|
-
catch {
|
|
565
|
-
return false;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
function compareVersionLike(a, b) {
|
|
569
|
-
const left = a.split(/[.-]/u).map((part) => Number(part));
|
|
570
|
-
const right = b.split(/[.-]/u).map((part) => Number(part));
|
|
571
|
-
const length = Math.max(left.length, right.length);
|
|
572
|
-
for (let i = 0; i < length; i += 1) {
|
|
573
|
-
const l = Number.isFinite(left[i]) ? left[i] : 0;
|
|
574
|
-
const r = Number.isFinite(right[i]) ? right[i] : 0;
|
|
575
|
-
if (l !== r) {
|
|
576
|
-
return l - r;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
return a.localeCompare(b);
|
|
580
|
-
}
|
|
581
|
-
function enableLinxXhighThinking(session) {
|
|
582
|
-
const originalSupportsXhighThinking = session.supportsXhighThinking?.bind(session);
|
|
583
|
-
const originalGetAvailableThinkingLevels = session.getAvailableThinkingLevels?.bind(session);
|
|
584
|
-
session.supportsXhighThinking = () => (session.model?.provider === UNDEFINEDS_PROVIDER_ID && session.model.reasoning
|
|
585
|
-
? (session.getAvailableThinkingLevels?.().includes('xhigh') ?? true)
|
|
586
|
-
: (originalSupportsXhighThinking?.() ?? false));
|
|
587
|
-
if (originalGetAvailableThinkingLevels) {
|
|
588
|
-
session.getAvailableThinkingLevels = () => {
|
|
589
|
-
const levels = originalGetAvailableThinkingLevels();
|
|
590
|
-
if (session.model?.provider === UNDEFINEDS_PROVIDER_ID && session.model.reasoning && !levels.includes('xhigh')) {
|
|
591
|
-
return [...levels, 'xhigh'];
|
|
592
|
-
}
|
|
593
|
-
return levels;
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
export function createLinxPiCodingTools(cwd, options = {}) {
|
|
598
|
-
const localBashOperations = options.bashOperations ?? createLocalBashOperations();
|
|
599
|
-
const bashTimeoutSeconds = options.bashTimeoutSeconds ?? DEFAULT_LINX_PI_BASH_TIMEOUT_SECONDS;
|
|
600
|
-
return createCodingTools(cwd, {
|
|
601
|
-
bash: {
|
|
602
|
-
operations: {
|
|
603
|
-
exec(command, workingDirectory, options) {
|
|
604
|
-
return localBashOperations.exec(command, workingDirectory ?? cwd, {
|
|
605
|
-
...options,
|
|
606
|
-
timeout: typeof options.timeout === 'number'
|
|
607
|
-
? options.timeout
|
|
608
|
-
: bashTimeoutSeconds,
|
|
609
|
-
});
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
},
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
function isAuthExpiredError(error) {
|
|
616
|
-
return isRemoteAuthExpiredError(error);
|
|
617
|
-
}
|
|
618
|
-
function createBearerAuthFetch(apiKey) {
|
|
619
|
-
return async (url, init) => {
|
|
620
|
-
const headers = new Headers(init?.headers);
|
|
621
|
-
headers.set('Authorization', `Bearer ${apiKey}`);
|
|
622
|
-
return fetch(url, { ...init, headers });
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
function resolveRuntimeAuthFetchFromApiKey(apiKey) {
|
|
626
|
-
const trimmed = apiKey?.trim();
|
|
627
|
-
if (!trimmed || trimmed === LINX_RUNTIME_MANAGED_AUTH_KEY) {
|
|
628
|
-
return null;
|
|
629
|
-
}
|
|
630
|
-
return createBearerAuthFetch(trimmed);
|
|
631
|
-
}
|
|
632
|
-
async function resolveLinxPiCloudAuthFetch(options) {
|
|
633
|
-
if (options.getPodDataSession) {
|
|
634
|
-
return createPodDataSessionAuthFetch(options.getPodDataSession);
|
|
635
|
-
}
|
|
636
|
-
const session = await getDefaultPodDataSession();
|
|
637
|
-
if (session) {
|
|
638
|
-
return withCloudCompletionTimeout(session.runtimeFetch);
|
|
639
|
-
}
|
|
640
|
-
throw new Error('No LinX cloud login found. Interactive TUI supports /login in-app. For non-interactive --print mode, run `linx login` first.');
|
|
641
|
-
}
|
|
642
|
-
function createPodDataSessionAuthFetch(getPodDataSession) {
|
|
643
|
-
if (getPodDataSession !== getDefaultPodDataSession) {
|
|
644
|
-
return withCloudCompletionTimeout(async (url, init) => {
|
|
645
|
-
const session = await getPodDataSession();
|
|
646
|
-
if (session) {
|
|
647
|
-
try {
|
|
648
|
-
return await session.runtimeFetch(url, init);
|
|
649
|
-
}
|
|
650
|
-
finally {
|
|
651
|
-
await session.close().catch(() => undefined);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
throw new Error('No LinX cloud login found. Interactive TUI supports /login in-app. For non-interactive --print mode, run `linx login` first.');
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
let cachedSession = null;
|
|
658
|
-
let cachedSessionPromise = null;
|
|
659
|
-
const getCachedSession = async () => {
|
|
660
|
-
if (cachedSession) {
|
|
661
|
-
return cachedSession;
|
|
662
|
-
}
|
|
663
|
-
if (!cachedSessionPromise) {
|
|
664
|
-
cachedSessionPromise = getPodDataSession().then((session) => {
|
|
665
|
-
cachedSession = session;
|
|
666
|
-
return session;
|
|
667
|
-
}).finally(() => {
|
|
668
|
-
cachedSessionPromise = null;
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
return cachedSessionPromise;
|
|
672
|
-
};
|
|
673
|
-
return withCloudCompletionTimeout(async (url, init) => {
|
|
674
|
-
const session = await getCachedSession();
|
|
675
|
-
if (session) {
|
|
676
|
-
return await session.runtimeFetch(url, init);
|
|
677
|
-
}
|
|
678
|
-
throw new Error('No LinX cloud login found. Interactive TUI supports /login in-app. For non-interactive --print mode, run `linx login` first.');
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
function withCloudCompletionTimeout(fetcher) {
|
|
682
|
-
return async (url, init) => {
|
|
683
|
-
if (!isChatCompletionRuntimeUrl(String(url))) {
|
|
684
|
-
return fetcher(url, init);
|
|
685
|
-
}
|
|
686
|
-
const timeoutMs = resolveLinxCloudCompletionTimeoutMs();
|
|
687
|
-
const controller = new AbortController();
|
|
688
|
-
const signal = init?.signal
|
|
689
|
-
? combineAbortSignals(init.signal, controller.signal)
|
|
690
|
-
: controller.signal;
|
|
691
|
-
let timedOut = false;
|
|
692
|
-
const timer = setTimeout(() => {
|
|
693
|
-
timedOut = true;
|
|
694
|
-
controller.abort();
|
|
695
|
-
}, timeoutMs);
|
|
696
|
-
try {
|
|
697
|
-
return await Promise.race([
|
|
698
|
-
fetcher(url, { ...init, signal }),
|
|
699
|
-
new Promise((_resolve, reject) => {
|
|
700
|
-
controller.signal.addEventListener('abort', () => {
|
|
701
|
-
if (timedOut) {
|
|
702
|
-
reject(new RemoteChatRequestError(formatLinxCloudTransientMessage(`Request exceeded ${formatTimeoutSeconds(timeoutMs)}s.`), 0, `Timed out waiting for POST ${url}`));
|
|
703
|
-
}
|
|
704
|
-
}, { once: true });
|
|
705
|
-
}),
|
|
706
|
-
]);
|
|
707
|
-
}
|
|
708
|
-
catch (error) {
|
|
709
|
-
if (timedOut) {
|
|
710
|
-
throw new RemoteChatRequestError(formatLinxCloudTransientMessage(`Request exceeded ${formatTimeoutSeconds(timeoutMs)}s.`), 0, error instanceof Error ? error.message : String(error));
|
|
711
|
-
}
|
|
712
|
-
throw error;
|
|
713
|
-
}
|
|
714
|
-
finally {
|
|
715
|
-
clearTimeout(timer);
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
function resolveLinxCloudCompletionTimeoutMs() {
|
|
720
|
-
const raw = process.env.LINX_CHAT_TIMEOUT_MS;
|
|
721
|
-
if (!raw) {
|
|
722
|
-
return DEFAULT_LINX_CLOUD_COMPLETION_TIMEOUT_MS;
|
|
723
|
-
}
|
|
724
|
-
const parsed = Number(raw);
|
|
725
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_LINX_CLOUD_COMPLETION_TIMEOUT_MS;
|
|
726
|
-
}
|
|
727
|
-
function formatTimeoutSeconds(timeoutMs) {
|
|
728
|
-
return Math.max(1, Math.round(timeoutMs / 1000));
|
|
729
|
-
}
|
|
730
|
-
function isChatCompletionRuntimeUrl(value) {
|
|
731
|
-
try {
|
|
732
|
-
const target = new URL(value);
|
|
733
|
-
const segments = target.pathname.split('/').filter(Boolean);
|
|
734
|
-
return segments.length >= 3
|
|
735
|
-
&& /^v\d+$/.test(segments.at(-3) ?? '')
|
|
736
|
-
&& segments.at(-2) === 'chat'
|
|
737
|
-
&& segments.at(-1) === 'completions';
|
|
738
|
-
}
|
|
739
|
-
catch {
|
|
740
|
-
return false;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
function combineAbortSignals(left, right) {
|
|
744
|
-
if (typeof AbortSignal.any === 'function') {
|
|
745
|
-
return AbortSignal.any([left, right]);
|
|
746
|
-
}
|
|
747
|
-
const controller = new AbortController();
|
|
748
|
-
const abort = () => controller.abort();
|
|
749
|
-
if (left.aborted || right.aborted) {
|
|
750
|
-
abort();
|
|
751
|
-
return controller.signal;
|
|
752
|
-
}
|
|
753
|
-
left.addEventListener('abort', abort, { once: true });
|
|
754
|
-
right.addEventListener('abort', abort, { once: true });
|
|
755
|
-
return controller.signal;
|
|
756
|
-
}
|
|
757
|
-
function sanitizeLinxCloudDefaults(settingsManager, requestedModel, providerModels) {
|
|
758
|
-
const availableModelIds = new Set(providerModels.map((model) => model.id));
|
|
759
|
-
const savedProvider = settingsManager.getDefaultProvider();
|
|
760
|
-
const savedModel = settingsManager.getDefaultModel();
|
|
761
|
-
const savedLinxModel = savedProvider === UNDEFINEDS_PROVIDER_ID && savedModel && availableModelIds.has(savedModel)
|
|
762
|
-
? savedModel
|
|
763
|
-
: undefined;
|
|
764
|
-
const nextModel = requestedModel || savedLinxModel || DEFAULT_LINX_CLOUD_MODEL_ID;
|
|
765
|
-
if (savedProvider !== UNDEFINEDS_PROVIDER_ID || savedModel !== nextModel) {
|
|
766
|
-
settingsManager.setDefaultModelAndProvider(UNDEFINEDS_PROVIDER_ID, nextModel);
|
|
767
|
-
}
|
|
768
|
-
return nextModel;
|
|
769
|
-
}
|
|
770
|
-
function buildProviderModel(input) {
|
|
771
|
-
return {
|
|
772
|
-
id: input.id,
|
|
773
|
-
name: input.id,
|
|
774
|
-
api: UNDEFINEDS_PROVIDER_API,
|
|
775
|
-
reasoning: true,
|
|
776
|
-
thinkingLevelMap: {
|
|
777
|
-
xhigh: 'xhigh',
|
|
778
|
-
},
|
|
779
|
-
input: ['text'],
|
|
780
|
-
cost: {
|
|
781
|
-
input: 0,
|
|
782
|
-
output: 0,
|
|
783
|
-
cacheRead: 0,
|
|
784
|
-
cacheWrite: 0,
|
|
785
|
-
},
|
|
786
|
-
contextWindow: input.contextWindow,
|
|
787
|
-
maxTokens: 64_000,
|
|
788
|
-
compat: {
|
|
789
|
-
supportsStore: false,
|
|
790
|
-
supportsDeveloperRole: false,
|
|
791
|
-
supportsStrictMode: false,
|
|
792
|
-
},
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
function buildFallbackProviderModels(activeModelId) {
|
|
796
|
-
return mergeLinxProviderModels([], activeModelId).map((entry) => buildProviderModel(entry));
|
|
797
|
-
}
|
|
798
|
-
function mergeLinxProviderModels(models, activeModelId) {
|
|
799
|
-
const byId = new Map();
|
|
800
|
-
for (const id of [
|
|
801
|
-
...FALLBACK_LINX_CLOUD_MODEL_IDS,
|
|
802
|
-
activeModelId,
|
|
803
|
-
]) {
|
|
804
|
-
byId.set(id, {
|
|
805
|
-
id,
|
|
806
|
-
contextWindow: normalizeLinxCloudContextWindow(undefined),
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
for (const model of models) {
|
|
810
|
-
const id = model.id.trim();
|
|
811
|
-
if (!id) {
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
byId.set(id, {
|
|
815
|
-
id,
|
|
816
|
-
contextWindow: normalizeLinxCloudContextWindow(model.contextWindow),
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
return [...byId.values()];
|
|
820
|
-
}
|
|
821
|
-
function normalizeLinxCloudContextWindow(contextWindow) {
|
|
822
|
-
return typeof contextWindow === 'number' && Number.isFinite(contextWindow) && contextWindow > 0
|
|
823
|
-
? contextWindow
|
|
824
|
-
: DEFAULT_LINX_CLOUD_CONTEXT_WINDOW;
|
|
825
|
-
}
|
|
826
|
-
function withSystemPrompt(systemPrompt, messages) {
|
|
827
|
-
const prompt = systemPrompt?.trim();
|
|
828
|
-
if (!prompt) {
|
|
829
|
-
return messages;
|
|
830
|
-
}
|
|
831
|
-
if (messages.some((message) => message.role === 'system')) {
|
|
832
|
-
return messages;
|
|
833
|
-
}
|
|
834
|
-
return [{ role: 'system', content: prompt }, ...messages];
|
|
835
|
-
}
|
|
836
|
-
function overrideLinxSystemPrompt(base) {
|
|
837
|
-
const original = base?.trim();
|
|
838
|
-
const identity = [
|
|
839
|
-
'You are LinX, an AI Secretary operating inside the LinX CLI.',
|
|
840
|
-
'When replying in Chinese, describe yourself as "AI主理人".',
|
|
841
|
-
'Use a friendly, direct style like: "你好!我是 LinX,一个 AI 主理人,很高兴为你服务!"',
|
|
842
|
-
'Keep Pi-compatible coding agent behavior: read files, run commands, edit code, use tools, and follow project instructions.',
|
|
843
|
-
'When introducing capabilities, describe only user-facing LinX product abilities and the currently available runtime actions.',
|
|
844
|
-
'Do not advertise repository-local agent instructions, internal command names, bundled plugin skill names, package names, or developer-only workflows as features the user can call.',
|
|
845
|
-
'If a capability depends on the current workspace, installed tools, login state, backend, or Symphony mode, state that dependency instead of implying it is always available.',
|
|
846
|
-
].join('\n');
|
|
847
|
-
if (!original) {
|
|
848
|
-
return identity;
|
|
849
|
-
}
|
|
850
|
-
return `${identity}\n\n${original.replace(/\bpi\b/g, 'LinX').replace(/\bPi\b/g, 'LinX')}`;
|
|
851
|
-
}
|
|
852
43
|
//# sourceMappingURL=runtime.js.map
|