chainlesschain 0.166.84 → 0.166.86
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 +17 -4
- package/package.json +3 -2
- package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
- package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
- package/src/assets/web-panel/assets/{AIOps-OYLnAlB5.js → AIOps-DZwiXAIh.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-uc9kbLR6.js → ActionButton-aNzXoIJP.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-BH901FG0.js → Analytics-ETQk4ZXt.js} +3 -3
- package/src/assets/web-panel/assets/{AppLayout-qypKb8GL.js → AppLayout-D5oEbeEC.js} +4 -4
- package/src/assets/web-panel/assets/{Artifacts-Q-uPWyLY.js → Artifacts-ja48FAne.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-B8hMGMim.js → Audit-DlN0YnDt.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-BSs8rJL_.js → BackgroundAgents-CzvyNsRg.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-2YMU_nCd.js → Backup-DXgEC2MQ.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-DyMppTuT.js → BaseInput-D9XqejLx.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-B5QGMaDO.js → Chat-BTwuYUlN.js} +5 -5
- package/src/assets/web-panel/assets/{ChatBubbleRenderer-B8ts_JnN.js → ChatBubbleRenderer-0anIC2Wn.js} +1 -1
- package/src/assets/web-panel/assets/{Checkbox-DAvtgEGd.js → Checkbox-CLuaQbDt.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-BSChEVM3.js → Codegen-KwQUZs8A.js} +1 -1
- package/src/assets/web-panel/assets/{Col-G0zYohIP.js → Col-BCmROkzc.js} +1 -1
- package/src/assets/web-panel/assets/{Community-CzCN0B_p.js → Community-CXlUEHR4.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-DrIN3G8z.js → Compact-Dzx-lWI2.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-CIsLa64Z.js → Compliance-CfXW82FF.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-CGYoafsB.js → Cowork-DIISTRm2.js} +3 -3
- package/src/assets/web-panel/assets/{Cron-DJ1JPXuH.js → Cron-nyJ-KcFE.js} +2 -2
- package/src/assets/web-panel/assets/{Crosschain-B-IqVFJl.js → Crosschain-Dtv1E4cV.js} +1 -1
- package/src/assets/web-panel/assets/{DID-CAAczPz_.js → DID-BCTpektS.js} +2 -2
- package/src/assets/web-panel/assets/{Dashboard-Dkpel8VE.js → Dashboard-C1Q_m0So.js} +2 -2
- package/src/assets/web-panel/assets/{Dropdown-ETNBf8-Z.js → Dropdown-BrQ5_PPL.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-CJGDyjVD.js → EmailListRenderer-DjoNlONP.js} +1 -1
- package/src/assets/web-panel/assets/{EvolutionSettings-CL_hvVYe.js → EvolutionSettings-DaGaE6bX.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-iexOh6Dh.js → FamilyGuardDashboard-nJDWBECt.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-DnDHvV5D.js → Federation-DhMUY_wG.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-DLCDJjUp.js → FormItemContext-CbONJPuc.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-CaCgXCjS.js → GenericCardRenderer-CDdX4dX-.js} +1 -1
- package/src/assets/web-panel/assets/{Git-BVm-euUF.js → Git-DXbDVJdR.js} +2 -2
- package/src/assets/web-panel/assets/{Governance-DPnUvLWr.js → Governance-DbAfAvs1.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-5qCWSYKl.js → Inference-Dy-fGea2.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-DXdv2oEh.js → KnowledgeGraph-DAxRpGUF.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-BF2f7bBA.js → Logs-5L1UCR8X.js} +2 -2
- package/src/assets/web-panel/assets/MarkdownRenderer-u0FPafvT.js +1 -0
- package/src/assets/web-panel/assets/{Marketplace-Bp-0Y7Ng.js → Marketplace-DUk_McDG.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-dm-Xdi63.js → McpTools-B6PNsZ_p.js} +2 -2
- package/src/assets/web-panel/assets/{Memory-TBHK031z.js → Memory-BUUs8j5F.js} +2 -2
- package/src/assets/web-panel/assets/{MobileBridge-BTILAlds.js → MobileBridge-pXRsgyuO.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-DC0Clgzs.js → MobileProjects-D7v-2Hwm.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-BvyWkmRw.js → Mtc-Deaj4faB.js} +4 -4
- package/src/assets/web-panel/assets/{MtcAudit-D7ksLoNa.js → MtcAudit-wUV0VUH1.js} +2 -2
- package/src/assets/web-panel/assets/{Multisig-Dpzu7X1t.js → Multisig-C67IIkts.js} +3 -3
- package/src/assets/web-panel/assets/{NLProgramming-DZ0ADHSB.js → NLProgramming-BCA_CWrW.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-hIdkmRug.js → Notes-D9eu14hQ.js} +4 -4
- package/src/assets/web-panel/assets/{NotificationSettings-R3jyP6Vf.js → NotificationSettings-Cnd-J4LM.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-d1zrFkqx.js → OrderTableRenderer-C4pHUuyZ.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-DoA5WMcc.js → Organization-4YExAbnp.js} +4 -4
- package/src/assets/web-panel/assets/{Overflow-DHjIloAQ.js → Overflow-BF-wFuZz.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-2TMon_Wy.js → P2P-CdiajqCT.js} +2 -2
- package/src/assets/web-panel/assets/{PdhVaultBrowser-DEUxGSWO.js → PdhVaultBrowser-BkjfS6Th.js} +5 -5
- package/src/assets/web-panel/assets/{Permissions-CxKcZ-8X.js → Permissions-DrZ4D78_.js} +4 -4
- package/src/assets/web-panel/assets/{PersonalDataHub-CcYtkHqc.js → PersonalDataHub-lDc6OXjz.js} +6 -6
- package/src/assets/web-panel/assets/{Pipeline-BxwOuq22.js → Pipeline-DqDS9ON1.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-VIx9pdsH.js → Privacy-BMekZRZu.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-COjp_erK.js → ProjectInit-LYS7NFvJ.js} +2 -2
- package/src/assets/web-panel/assets/{ProjectSettings-x9NrZU80.js → ProjectSettings-CcJNHk9A.js} +2 -2
- package/src/assets/web-panel/assets/{Projects-DMgkw7QJ.js → Projects-DrfAHgdF.js} +1 -1
- package/src/assets/web-panel/assets/{Providers-B_fR7Y7Y.js → Providers-aqsly9SR.js} +1 -1
- package/src/assets/web-panel/assets/{QrScannerModal-BUvzrn3V.js → QrScannerModal-ZWvR3zqg.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-C0sJwLy2.js → QuickAsk-BT5CgsvW.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-CJC7Wpce.js → Recommend-Cz8Dz2RN.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-B62J6ZP0.js → RemoteSession-BlxPVbtQ.js} +2 -2
- package/src/assets/web-panel/assets/{Reputation-4f48kVBn.js → Reputation-B3VGBE-1.js} +1 -1
- package/src/assets/web-panel/assets/{Row-EzEMaYoV.js → Row-Bwv7vSEA.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-Dy0wD83j.js → RssFeed-DHI085r_.js} +3 -3
- package/src/assets/web-panel/assets/{Search-GeVRHQND.js → Search-DBler5T0.js} +1 -1
- package/src/assets/web-panel/assets/{Security-omLr1J7w.js → Security-BZdw43NW.js} +3 -3
- package/src/assets/web-panel/assets/{Services-DmGPaDAs.js → Services-Cslk5lUj.js} +2 -2
- package/src/assets/web-panel/assets/{Skeleton-CAla21Gm.js → Skeleton-Bur-C-25.js} +1 -1
- package/src/assets/web-panel/assets/Skills-v0zgLy0X.js +1 -0
- package/src/assets/web-panel/assets/{Sla-Cwi15-pZ.js → Sla-B1OWgQ51.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-Cs8Zi1J8.js → SpeechSettings-CaBcEaV4.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-ipuJsDKP.js → SyncSettings-CBbG8L6J.js} +2 -2
- package/src/assets/web-panel/assets/Tasks-C7EjXrnN.js +1 -0
- package/src/assets/web-panel/assets/{Templates-slUp9yXF.js → Templates-VBBOZ1H5.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-6edCSG5K.js → Tenant-CtQTj7IF.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-DKq84G3h.js → Terminal-DXVTQjnl.js} +2 -2
- package/src/assets/web-panel/assets/{TimelineRenderer-Dg0Aw6se.js → TimelineRenderer-BRIno0aN.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-D63h7qYd.js → Tokens-uiiAfkYN.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-F7gTP_gv.js → Trigger-CPApN8o6.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-zw8Zqp8k.js → Trust-T2jKVwCE.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-C-YBUmod.js → UkeySign-C2U_gbzP.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-AhVxTgmC.js → VideoEditing-BCdlr3Kj.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-C58zxjIg.js → Wallet-CWnjoSc1.js} +4 -4
- package/src/assets/web-panel/assets/{WebAuthn-D-n-rlfI.js → WebAuthn-CqSbYqHq.js} +4 -4
- package/src/assets/web-panel/assets/{WorkflowEditor-Ddc8gGD4.js → WorkflowEditor-Dr_I3jcr.js} +1 -1
- package/src/assets/web-panel/assets/{chat-C66V_U7w.js → chat-Cg21FKdE.js} +1 -1
- package/src/assets/web-panel/assets/{colors-BcJyVZRj.js → colors-CK85tY9e.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-UgUXWcgP.js → compact-item-m-XYPC7W.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-oxEKHKYP.js → createContext-BmiEeNvs.js} +1 -1
- package/src/assets/web-panel/assets/devWarning-CkMEODFC.js +1 -0
- package/src/assets/web-panel/assets/{hasIn-CbqzrKQO.js → hasIn-CCw4KAoc.js} +1 -1
- package/src/assets/web-panel/assets/{index-CH13yc9x.js → index-6jXf-Lln.js} +1 -1
- package/src/assets/web-panel/assets/{index-BdFgUn1S.js → index-8KzhlvJ9.js} +1 -1
- package/src/assets/web-panel/assets/{index-D3xNhHF3.js → index-B7xJkhtJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-DAIuMvVR.js → index-B8IC9ZeZ.js} +1 -1
- package/src/assets/web-panel/assets/{index-CrG-1Kqs.js → index-BGUYgc96.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bu1A2sXy.js → index-BGb1j2z9.js} +1 -1
- package/src/assets/web-panel/assets/{index-BQlGMcZ9.js → index-BHsiSoGY.js} +1 -1
- package/src/assets/web-panel/assets/{index-DWFNv_EG.js → index-BIOTRzaF.js} +1 -1
- package/src/assets/web-panel/assets/{index-BrWZmUdA.js → index-BStyjmLG.js} +1 -1
- package/src/assets/web-panel/assets/{index-C-p9hhAz.js → index-BUYyhYP6.js} +1 -1
- package/src/assets/web-panel/assets/{index-CM2S5TJZ.js → index-BcfVHmFK.js} +1 -1
- package/src/assets/web-panel/assets/{index-7lSY8B9T.js → index-BiVPFsat.js} +1 -1
- package/src/assets/web-panel/assets/index-BjE5qaKn.js +1 -0
- package/src/assets/web-panel/assets/{index-B-h0Jgtj.js → index-Br0ZNdu1.js} +1 -1
- package/src/assets/web-panel/assets/{index-D8rgeCoC.js → index-Br9t_I1X.js} +1 -1
- package/src/assets/web-panel/assets/{index-DRrxJygS.js → index-BtvVupUL.js} +1 -1
- package/src/assets/web-panel/assets/{index-DO-5vgTW.js → index-Bv90WEWa.js} +1 -1
- package/src/assets/web-panel/assets/{index-DBEL07sa.js → index-BvjC3t35.js} +1 -1
- package/src/assets/web-panel/assets/{index-UpN_kC9R.js → index-ByVvAXdl.js} +1 -1
- package/src/assets/web-panel/assets/{index-SzGgAqai.js → index-CBcgIWOe.js} +1 -1
- package/src/assets/web-panel/assets/{index-C3j9jTfB.js → index-CN2xbLGz.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bmhw_Ler.js → index-CYEzWoyZ.js} +1 -1
- package/src/assets/web-panel/assets/{index-Crqqbu-W.js → index-Cf5arJie.js} +1 -1
- package/src/assets/web-panel/assets/index-CsFH-2Zk.js +1 -0
- package/src/assets/web-panel/assets/{index-BMOY4PSW.js → index-D1sU5-XA.js} +1 -1
- package/src/assets/web-panel/assets/{index-BT2PZ9df.js → index-D7gS_TJl.js} +1 -1
- package/src/assets/web-panel/assets/{index-YvNh1UdB.js → index-DAlGVix-.js} +1 -1
- package/src/assets/web-panel/assets/{index-BZ7mv_oS.js → index-DI9GJFcn.js} +1 -1
- package/src/assets/web-panel/assets/{index-Ov77O9mH.js → index-DIlGxS2W.js} +1 -1
- package/src/assets/web-panel/assets/{index-CJluGB2F.js → index-DMbrl43d.js} +1 -1
- package/src/assets/web-panel/assets/{index-C6X26RJu.js → index-DmSgfXuz.js} +1 -1
- package/src/assets/web-panel/assets/{index-DMbJ06sF.js → index-DpIy2HzE.js} +1 -1
- package/src/assets/web-panel/assets/{index-CUmYwZyf.js → index-DxRhnsEC.js} +1 -1
- package/src/assets/web-panel/assets/{index-BNIq0NAn.js → index-IskAKXhx.js} +1 -1
- package/src/assets/web-panel/assets/{index-DR4YKlLt.js → index-J81uvUMN.js} +1 -1
- package/src/assets/web-panel/assets/{index-RnxuL8wM.js → index-OIbfsi-o.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bp9rfr-P.js → index-lhoexBDH.js} +1 -1
- package/src/assets/web-panel/assets/{index-BpqJNeIj.js → index-sWUmvT8H.js} +1 -1
- package/src/assets/web-panel/assets/{index-CuZupgUw.js → index-yYmjkf38.js} +3 -3
- package/src/assets/web-panel/assets/{initDefaultProps-BK9ncFiF.js → initDefaultProps-Cc1XOmNe.js} +1 -1
- package/src/assets/web-panel/assets/{motion-BxzXi1Pe.js → motion-BehsX88u.js} +1 -1
- package/src/assets/web-panel/assets/{move-CRmwRuah.js → move-BPx2YsqY.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-BQq5_Znx.js → mtc-parser-BSFJgFQA.js} +1 -1
- package/src/assets/web-panel/assets/{omit-Ch4VNY2j.js → omit-DBN5KUeo.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-CUioBhrz.js → pickAttrs-BDK1yZ-9.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-Hj3o1CrW.js → placementArrow-C4rMmKNJ.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-PfqJrlkI.js → responsiveObserve-BoeoOnxX.js} +1 -1
- package/src/assets/web-panel/assets/{slide-BXcnR-Lu.js → slide-BKlr1bl9.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-C74a-ofo.js → statusUtils-Ky1apWPI.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-Bq57I3ls.js → styleChecker-DxxR7uXk.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-ITPUjcDw.js → useFlexGapSupport-DmsUqVe9.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-DzPuXDIS.js → useFs-CwkG7sOg.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-DYSgt9L5.js → usePersonalDataHub-CddgeEfF.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-NPs_EJEk.js → vnode-C_-H8i4Y.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-DZzO6KVS.js → zoom-aAsHUMNE.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/commands/permissions.js +27 -2
- package/src/data/changelog.json +26 -0
- package/src/lib/background-interaction-resolver.js +4 -0
- package/src/lib/context-memory-kernel/durable-memory-port.js +71 -15
- package/src/lib/context-memory-kernel/index.js +1 -0
- package/src/lib/context-memory-kernel/memory-service.js +43 -16
- package/src/lib/context-memory-kernel/runtime.js +5 -3
- package/src/lib/context-memory-kernel/segmented-memory-port.js +687 -0
- package/src/lib/packer/pack-update-applier.js +41 -17
- package/src/lib/packer/pkg-config-generator.js +119 -2
- package/src/lib/packer/pkg-runner.js +7 -0
- package/src/lib/packer/pkg-targets.js +83 -0
- package/src/lib/packer/web-panel-builder.js +7 -0
- package/src/lib/permission-authority.js +157 -13
- package/src/lib/process-execution-broker/index.js +11 -0
- package/src/lib/process-execution-broker/linux-subreaper-helper.js +87 -13
- package/src/lib/process-execution-broker/packer-build-policy.js +31 -0
- package/src/lib/process-execution-broker/platform-sandbox.js +11 -3
- package/src/lib/sandbox-egress-authority-monitor.js +62 -5
- package/src/lib/scoped-permission-store.js +119 -6
- package/src/lib/settings-authority-domain.cjs +37 -2
- package/src/lib/settings-loader.cjs +112 -42
- package/src/lib/settings-permission-authority.cjs +373 -0
- package/src/runtime/agent-core.js +79 -383
- package/src/runtime/headless-runner.js +8 -3
- package/src/runtime/headless-stream.js +10 -3
- package/src/runtime/permission-authority-host.js +137 -0
- package/src/runtime/provider-stream-state.js +379 -0
- package/src/assets/web-panel/assets/MarkdownRenderer-qNJS3ygh.js +0 -1
- package/src/assets/web-panel/assets/Skills-QqEyIKOI.js +0 -1
- package/src/assets/web-panel/assets/Tasks-BbVAg9Z7.js +0 -1
- package/src/assets/web-panel/assets/devWarning-BoDvrsgY.js +0 -1
- package/src/assets/web-panel/assets/index-BhqRbl5P.js +0 -1
- package/src/assets/web-panel/assets/index-DreT6MIR.js +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** Explicit Linux controlled-host entry. Provisioning and reopening are separate. */
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import persistentSettings from "../lib/settings-permission-authority.cjs";
|
|
4
|
+
import settingsLoader from "../lib/settings-loader.cjs";
|
|
5
|
+
import { ScopedPermissionStore } from "../lib/scoped-permission-store.js";
|
|
6
|
+
import {
|
|
7
|
+
createPermissionRulesProvider,
|
|
8
|
+
permissionRulesProviderAuthority,
|
|
9
|
+
} from "../lib/permission-authority.js";
|
|
10
|
+
|
|
11
|
+
export const initializePermissionAuthorityHost =
|
|
12
|
+
persistentSettings.initializeSettingsPermissionAuthority;
|
|
13
|
+
|
|
14
|
+
export function openPermissionAuthorityHost({
|
|
15
|
+
launch,
|
|
16
|
+
contextId,
|
|
17
|
+
env = process.env,
|
|
18
|
+
}) {
|
|
19
|
+
const binding = persistentSettings.openSettingsPermissionAuthority({
|
|
20
|
+
launch,
|
|
21
|
+
contextId,
|
|
22
|
+
});
|
|
23
|
+
const bound = persistentSettings.settingsPermissionAuthorityOptions(binding);
|
|
24
|
+
let scopedStore;
|
|
25
|
+
let provider;
|
|
26
|
+
try {
|
|
27
|
+
scopedStore = new ScopedPermissionStore({
|
|
28
|
+
cwd: bound.cwd,
|
|
29
|
+
filePath: bound.scopedFile,
|
|
30
|
+
settingsAuthority: binding,
|
|
31
|
+
});
|
|
32
|
+
provider = createPermissionRulesProvider({
|
|
33
|
+
cwd: bound.cwd,
|
|
34
|
+
settingsAuthority: binding,
|
|
35
|
+
scopedStore,
|
|
36
|
+
env,
|
|
37
|
+
});
|
|
38
|
+
provider();
|
|
39
|
+
} catch (error) {
|
|
40
|
+
persistentSettings.closeSettingsPermissionAuthority(binding);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
let closed = false;
|
|
44
|
+
let running = 0;
|
|
45
|
+
function assertOpen() {
|
|
46
|
+
if (closed)
|
|
47
|
+
throw Object.assign(new Error("Permission authority host is closed"), {
|
|
48
|
+
code: "CC_SETTINGS_PERMISSION_BINDING_INVALID",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function runtimeOptions(options = {}) {
|
|
52
|
+
assertOpen();
|
|
53
|
+
if (
|
|
54
|
+
(options.cwd && path.resolve(options.cwd) !== bound.cwd) ||
|
|
55
|
+
(options.settingsFile &&
|
|
56
|
+
path.resolve(bound.cwd, options.settingsFile) !== bound.settingsFile) ||
|
|
57
|
+
(options.managedSettingsFile &&
|
|
58
|
+
path.resolve(options.managedSettingsFile) !==
|
|
59
|
+
bound.managedSettingsFile) ||
|
|
60
|
+
options.permissionRules ||
|
|
61
|
+
options.permissionRulesProvider ||
|
|
62
|
+
options.hermeticExecution
|
|
63
|
+
)
|
|
64
|
+
throw new TypeError(
|
|
65
|
+
"controlled-host permission authority options mismatch",
|
|
66
|
+
);
|
|
67
|
+
permissionRulesProviderAuthority(provider).assertWritableRoots([
|
|
68
|
+
bound.cwd,
|
|
69
|
+
...(options.additionalDirectories || []).map((root) =>
|
|
70
|
+
path.resolve(bound.cwd, root),
|
|
71
|
+
),
|
|
72
|
+
...(options.sandbox?.policy?.allowWrite || []),
|
|
73
|
+
]);
|
|
74
|
+
provider(); // Reopen/read failures never fall back to sampled permissions.
|
|
75
|
+
return {
|
|
76
|
+
...options,
|
|
77
|
+
cwd: bound.cwd,
|
|
78
|
+
settingsFile: bound.settingsFile,
|
|
79
|
+
managedSettingsFile: bound.managedSettingsFile,
|
|
80
|
+
permissionRulesProvider: provider,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
exportLaunch() {
|
|
85
|
+
assertOpen();
|
|
86
|
+
return persistentSettings.exportSettingsPermissionAuthority(binding);
|
|
87
|
+
},
|
|
88
|
+
runtimeOptions,
|
|
89
|
+
readPermissions() {
|
|
90
|
+
assertOpen();
|
|
91
|
+
return provider();
|
|
92
|
+
},
|
|
93
|
+
addRule(options) {
|
|
94
|
+
assertOpen();
|
|
95
|
+
return settingsLoader.addRule({
|
|
96
|
+
...options,
|
|
97
|
+
cwd: bound.cwd,
|
|
98
|
+
settingsAuthority: binding,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
addScopedRule(options) {
|
|
102
|
+
assertOpen();
|
|
103
|
+
return scopedStore.add(options);
|
|
104
|
+
},
|
|
105
|
+
revokeScopedRule(options) {
|
|
106
|
+
assertOpen();
|
|
107
|
+
return scopedStore.revoke(options);
|
|
108
|
+
},
|
|
109
|
+
async runHeadless(options, deps) {
|
|
110
|
+
const captured = runtimeOptions(options);
|
|
111
|
+
running++;
|
|
112
|
+
try {
|
|
113
|
+
const { runAgentHeadless } = await import("./headless-runner.js");
|
|
114
|
+
return await runAgentHeadless(captured, deps);
|
|
115
|
+
} finally {
|
|
116
|
+
running--;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
async runHeadlessStream(options, deps) {
|
|
120
|
+
const captured = runtimeOptions(options);
|
|
121
|
+
running++;
|
|
122
|
+
try {
|
|
123
|
+
const { runAgentHeadlessStream } = await import("./headless-stream.js");
|
|
124
|
+
return await runAgentHeadlessStream(captured, deps);
|
|
125
|
+
} finally {
|
|
126
|
+
running--;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
close() {
|
|
130
|
+
assertOpen();
|
|
131
|
+
if (running)
|
|
132
|
+
throw new Error("Permission authority host still has active runtimes");
|
|
133
|
+
persistentSettings.closeSettingsPermissionAuthority(binding);
|
|
134
|
+
closed = true;
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider response state and usage normalization.
|
|
3
|
+
* Pure protocol reducers: transport, ingress, retries and settlement remain in
|
|
4
|
+
* agent-core. Shared usage validation also serves non-streamed responses.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export function _isNonNegativeSafeInteger(value) {
|
|
8
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function _providerUsageCount(usage, canonical, alias) {
|
|
12
|
+
if (!usage || typeof usage !== "object" || Array.isArray(usage)) return null;
|
|
13
|
+
const hasCanonical = Object.prototype.hasOwnProperty.call(usage, canonical);
|
|
14
|
+
const hasAlias = Object.prototype.hasOwnProperty.call(usage, alias);
|
|
15
|
+
if (!hasCanonical && !hasAlias) return null;
|
|
16
|
+
if (hasCanonical && hasAlias && usage[canonical] !== usage[alias])
|
|
17
|
+
return null;
|
|
18
|
+
const value = hasCanonical ? usage[canonical] : usage[alias];
|
|
19
|
+
return _isNonNegativeSafeInteger(value) ? value : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function _optionalProviderUsageCount(usage, canonical, alias) {
|
|
23
|
+
if (!usage || typeof usage !== "object" || Array.isArray(usage)) return null;
|
|
24
|
+
const hasCanonical = Object.prototype.hasOwnProperty.call(usage, canonical);
|
|
25
|
+
const hasAlias = Object.prototype.hasOwnProperty.call(usage, alias);
|
|
26
|
+
if (!hasCanonical && !hasAlias) return 0;
|
|
27
|
+
if (hasCanonical && hasAlias && usage[canonical] !== usage[alias])
|
|
28
|
+
return null;
|
|
29
|
+
const value = hasCanonical ? usage[canonical] : usage[alias];
|
|
30
|
+
return _isNonNegativeSafeInteger(value) ? value : null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function _hasCompleteProviderUsage(usage) {
|
|
34
|
+
return (
|
|
35
|
+
_providerUsageCount(usage, "input_tokens", "prompt_tokens") != null &&
|
|
36
|
+
_providerUsageCount(usage, "output_tokens", "completion_tokens") != null &&
|
|
37
|
+
_optionalProviderUsageCount(
|
|
38
|
+
usage,
|
|
39
|
+
"cache_read_input_tokens",
|
|
40
|
+
"cache_read_tokens",
|
|
41
|
+
) != null &&
|
|
42
|
+
_optionalProviderUsageCount(
|
|
43
|
+
usage,
|
|
44
|
+
"cache_creation_input_tokens",
|
|
45
|
+
"cache_creation_tokens",
|
|
46
|
+
) != null
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const PROVIDER_RECEIPT_ID_RE = /^[A-Za-z0-9._:-]{1,256}$/;
|
|
51
|
+
|
|
52
|
+
export function _providerReceiptId(value) {
|
|
53
|
+
return typeof value === "string" && PROVIDER_RECEIPT_ID_RE.test(value)
|
|
54
|
+
? value
|
|
55
|
+
: null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ─── Anthropic streaming (SSE → {message, usage}, tool_use reassembled) ──────
|
|
59
|
+
//
|
|
60
|
+
// Anthropic /messages with stream:true emits SSE: message_start (input usage),
|
|
61
|
+
// content_block_start (text or tool_use header), content_block_delta
|
|
62
|
+
// (text_delta → onToken, or input_json_delta accumulating a tool's JSON args),
|
|
63
|
+
// message_delta (output usage). We reduce per `data:` line and finalize into
|
|
64
|
+
// the same shape chatWithTools returns non-streamed.
|
|
65
|
+
|
|
66
|
+
export function _anthropicInitState() {
|
|
67
|
+
return {
|
|
68
|
+
text: "",
|
|
69
|
+
blocks: {},
|
|
70
|
+
inputTokens: null,
|
|
71
|
+
outputTokens: null,
|
|
72
|
+
cacheReadTokens: 0,
|
|
73
|
+
cacheCreationTokens: 0,
|
|
74
|
+
usageInvalid: false,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function _anthropicReduceLine(state, raw, onToken, onThinking) {
|
|
79
|
+
const line = (raw || "").trim();
|
|
80
|
+
if (!line.startsWith("data:")) return state;
|
|
81
|
+
const payload = line.slice(5).trim();
|
|
82
|
+
if (!payload) return state;
|
|
83
|
+
let obj;
|
|
84
|
+
try {
|
|
85
|
+
obj = JSON.parse(payload);
|
|
86
|
+
} catch {
|
|
87
|
+
return state;
|
|
88
|
+
}
|
|
89
|
+
if (obj.type === "message_start") {
|
|
90
|
+
const usage = obj.message?.usage;
|
|
91
|
+
if (usage != null) {
|
|
92
|
+
const inputTokens = _providerUsageCount(
|
|
93
|
+
usage,
|
|
94
|
+
"input_tokens",
|
|
95
|
+
"prompt_tokens",
|
|
96
|
+
);
|
|
97
|
+
const cacheReadTokens = _optionalProviderUsageCount(
|
|
98
|
+
usage,
|
|
99
|
+
"cache_read_input_tokens",
|
|
100
|
+
"cache_read_tokens",
|
|
101
|
+
);
|
|
102
|
+
const cacheCreationTokens = _optionalProviderUsageCount(
|
|
103
|
+
usage,
|
|
104
|
+
"cache_creation_input_tokens",
|
|
105
|
+
"cache_creation_tokens",
|
|
106
|
+
);
|
|
107
|
+
if (
|
|
108
|
+
inputTokens == null ||
|
|
109
|
+
cacheReadTokens == null ||
|
|
110
|
+
cacheCreationTokens == null
|
|
111
|
+
) {
|
|
112
|
+
state.usageInvalid = true;
|
|
113
|
+
} else {
|
|
114
|
+
state.inputTokens = inputTokens;
|
|
115
|
+
state.cacheReadTokens = cacheReadTokens;
|
|
116
|
+
state.cacheCreationTokens = cacheCreationTokens;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} else if (obj.type === "content_block_start") {
|
|
120
|
+
const cb = obj.content_block || {};
|
|
121
|
+
state.blocks[obj.index] =
|
|
122
|
+
cb.type === "tool_use"
|
|
123
|
+
? { type: "tool_use", id: cb.id, name: cb.name, json: "" }
|
|
124
|
+
: cb.type === "thinking"
|
|
125
|
+
? { type: "thinking", thinking: "", signature: "" }
|
|
126
|
+
: cb.type === "redacted_thinking"
|
|
127
|
+
? { type: "redacted_thinking", data: cb.data || "" }
|
|
128
|
+
: { type: "text" };
|
|
129
|
+
} else if (obj.type === "content_block_delta") {
|
|
130
|
+
const d = obj.delta || {};
|
|
131
|
+
if (d.type === "text_delta" && d.text) {
|
|
132
|
+
state.text += d.text;
|
|
133
|
+
if (typeof onToken === "function") {
|
|
134
|
+
try {
|
|
135
|
+
onToken(d.text);
|
|
136
|
+
} catch {
|
|
137
|
+
// a failing UI hook must never break the run
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} else if (d.type === "input_json_delta" && state.blocks[obj.index]) {
|
|
141
|
+
state.blocks[obj.index].json += d.partial_json || "";
|
|
142
|
+
} else if (d.type === "thinking_delta" && state.blocks[obj.index]) {
|
|
143
|
+
state.blocks[obj.index].thinking =
|
|
144
|
+
(state.blocks[obj.index].thinking || "") + (d.thinking || "");
|
|
145
|
+
if (typeof onThinking === "function" && d.thinking) {
|
|
146
|
+
try {
|
|
147
|
+
onThinking(d.thinking);
|
|
148
|
+
} catch {
|
|
149
|
+
// a failing UI hook must never break the run
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} else if (d.type === "signature_delta" && state.blocks[obj.index]) {
|
|
153
|
+
state.blocks[obj.index].signature =
|
|
154
|
+
(state.blocks[obj.index].signature || "") + (d.signature || "");
|
|
155
|
+
}
|
|
156
|
+
} else if (obj.type === "message_delta") {
|
|
157
|
+
if (obj.usage != null) {
|
|
158
|
+
const outputTokens = _providerUsageCount(
|
|
159
|
+
obj.usage,
|
|
160
|
+
"output_tokens",
|
|
161
|
+
"completion_tokens",
|
|
162
|
+
);
|
|
163
|
+
if (outputTokens == null) {
|
|
164
|
+
state.usageInvalid = true;
|
|
165
|
+
} else {
|
|
166
|
+
state.outputTokens = outputTokens;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return state;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function _anthropicFinalize(state) {
|
|
174
|
+
const toolCalls = [];
|
|
175
|
+
const thinkingBlocks = [];
|
|
176
|
+
for (const k of Object.keys(state.blocks).sort(
|
|
177
|
+
(a, b) => Number(a) - Number(b),
|
|
178
|
+
)) {
|
|
179
|
+
const b = state.blocks[k];
|
|
180
|
+
if (b.type === "tool_use") {
|
|
181
|
+
let input = {};
|
|
182
|
+
try {
|
|
183
|
+
input = b.json ? JSON.parse(b.json) : {};
|
|
184
|
+
} catch {
|
|
185
|
+
input = {};
|
|
186
|
+
}
|
|
187
|
+
toolCalls.push({
|
|
188
|
+
id: b.id,
|
|
189
|
+
type: "function",
|
|
190
|
+
function: { name: b.name, arguments: JSON.stringify(input) },
|
|
191
|
+
});
|
|
192
|
+
} else if (b.type === "thinking") {
|
|
193
|
+
thinkingBlocks.push({
|
|
194
|
+
type: "thinking",
|
|
195
|
+
thinking: b.thinking || "",
|
|
196
|
+
signature: b.signature || "",
|
|
197
|
+
});
|
|
198
|
+
} else if (b.type === "redacted_thinking") {
|
|
199
|
+
thinkingBlocks.push({ type: "redacted_thinking", data: b.data || "" });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const message = { role: "assistant", content: state.text };
|
|
203
|
+
if (toolCalls.length) message.tool_calls = toolCalls;
|
|
204
|
+
// Preserve thinking blocks verbatim (incl. signature) for replay on the next
|
|
205
|
+
// tool turn — required by the API when extended thinking is on.
|
|
206
|
+
if (thinkingBlocks.length) message._thinkingBlocks = thinkingBlocks;
|
|
207
|
+
const out = { message };
|
|
208
|
+
if (
|
|
209
|
+
state.usageInvalid !== true &&
|
|
210
|
+
_isNonNegativeSafeInteger(state.inputTokens) &&
|
|
211
|
+
_isNonNegativeSafeInteger(state.outputTokens)
|
|
212
|
+
) {
|
|
213
|
+
out.usage = {
|
|
214
|
+
input_tokens: state.inputTokens,
|
|
215
|
+
output_tokens: state.outputTokens,
|
|
216
|
+
cache_read_input_tokens: state.cacheReadTokens,
|
|
217
|
+
cache_creation_input_tokens: state.cacheCreationTokens,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Pure reducer over Anthropic SSE lines — exported for tests (no HTTP). */
|
|
224
|
+
export function _accumulateAnthropicStream(lines, onToken, onThinking) {
|
|
225
|
+
const state = _anthropicInitState();
|
|
226
|
+
for (const line of lines)
|
|
227
|
+
_anthropicReduceLine(state, line, onToken, onThinking);
|
|
228
|
+
return _anthropicFinalize(state);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ─── OpenAI-compatible streaming (SSE → {message, usage}) ────────────────────
|
|
232
|
+
//
|
|
233
|
+
// `data:` lines carry choices[0].delta.{content, tool_calls[]}; tool_calls
|
|
234
|
+
// arrive fragmented and keyed by `index` (name in the first chunk, arguments
|
|
235
|
+
// concatenated across chunks). usage rides the terminal chunk when
|
|
236
|
+
// stream_options.include_usage was requested. Terminator: `data: [DONE]`.
|
|
237
|
+
|
|
238
|
+
// OpenAI-compatible cached-prompt-token count. OpenAI / volcengine report it as
|
|
239
|
+
// usage.prompt_tokens_details.cached_tokens; DeepSeek as
|
|
240
|
+
// usage.prompt_cache_hit_tokens. In BOTH, prompt_tokens already INCLUDES the
|
|
241
|
+
// cached count (unlike Anthropic, where input_tokens is the uncached remainder)
|
|
242
|
+
// — so callers subtract it to recover the uncached input and avoid pricing the
|
|
243
|
+
// cached prefix twice. Verified live against volcengine (field present, 0 when
|
|
244
|
+
// the provider does not auto-cache).
|
|
245
|
+
export function _openaiCachedTokens(usage) {
|
|
246
|
+
if (!usage || typeof usage !== "object" || Array.isArray(usage)) return null;
|
|
247
|
+
const candidates = [];
|
|
248
|
+
const hasDirect =
|
|
249
|
+
Object.prototype.hasOwnProperty.call(usage, "cache_read_input_tokens") ||
|
|
250
|
+
Object.prototype.hasOwnProperty.call(usage, "cache_read_tokens");
|
|
251
|
+
if (hasDirect) {
|
|
252
|
+
const direct = _optionalProviderUsageCount(
|
|
253
|
+
usage,
|
|
254
|
+
"cache_read_input_tokens",
|
|
255
|
+
"cache_read_tokens",
|
|
256
|
+
);
|
|
257
|
+
if (direct == null) return null;
|
|
258
|
+
candidates.push(direct);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (Object.prototype.hasOwnProperty.call(usage, "prompt_tokens_details")) {
|
|
262
|
+
const details = usage.prompt_tokens_details;
|
|
263
|
+
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
if (Object.prototype.hasOwnProperty.call(details, "cached_tokens")) {
|
|
267
|
+
if (!_isNonNegativeSafeInteger(details.cached_tokens)) return null;
|
|
268
|
+
candidates.push(details.cached_tokens);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (Object.prototype.hasOwnProperty.call(usage, "prompt_cache_hit_tokens")) {
|
|
273
|
+
if (!_isNonNegativeSafeInteger(usage.prompt_cache_hit_tokens)) return null;
|
|
274
|
+
candidates.push(usage.prompt_cache_hit_tokens);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (candidates.some((value) => value !== candidates[0])) return null;
|
|
278
|
+
return candidates[0] ?? 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function _openaiInitState() {
|
|
282
|
+
return {
|
|
283
|
+
responseId: null,
|
|
284
|
+
text: "",
|
|
285
|
+
tools: [],
|
|
286
|
+
inputTokens: null,
|
|
287
|
+
outputTokens: null,
|
|
288
|
+
cacheReadTokens: 0,
|
|
289
|
+
usageInvalid: false,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function _openaiReduceLine(state, raw, onToken) {
|
|
294
|
+
const line = (raw || "").trim();
|
|
295
|
+
if (!line.startsWith("data:")) return state;
|
|
296
|
+
const payload = line.slice(5).trim();
|
|
297
|
+
if (!payload || payload === "[DONE]") return state;
|
|
298
|
+
let obj;
|
|
299
|
+
try {
|
|
300
|
+
obj = JSON.parse(payload);
|
|
301
|
+
} catch {
|
|
302
|
+
return state;
|
|
303
|
+
}
|
|
304
|
+
if (!state.responseId) state.responseId = _providerReceiptId(obj.id);
|
|
305
|
+
const delta = obj.choices?.[0]?.delta;
|
|
306
|
+
if (delta?.content) {
|
|
307
|
+
state.text += delta.content;
|
|
308
|
+
if (typeof onToken === "function") {
|
|
309
|
+
try {
|
|
310
|
+
onToken(delta.content);
|
|
311
|
+
} catch {
|
|
312
|
+
// a failing UI hook must never break the run
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (Array.isArray(delta?.tool_calls)) {
|
|
317
|
+
for (const tc of delta.tool_calls) {
|
|
318
|
+
const idx = tc.index ?? 0;
|
|
319
|
+
if (!state.tools[idx])
|
|
320
|
+
state.tools[idx] = { id: undefined, name: "", args: "" };
|
|
321
|
+
if (tc.id) state.tools[idx].id = tc.id;
|
|
322
|
+
if (tc.function?.name) state.tools[idx].name = tc.function.name;
|
|
323
|
+
if (tc.function?.arguments)
|
|
324
|
+
state.tools[idx].args += tc.function.arguments;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (obj.usage != null) {
|
|
328
|
+
const usage = obj.usage;
|
|
329
|
+
const prompt = _providerUsageCount(usage, "input_tokens", "prompt_tokens");
|
|
330
|
+
const completion = _providerUsageCount(
|
|
331
|
+
usage,
|
|
332
|
+
"output_tokens",
|
|
333
|
+
"completion_tokens",
|
|
334
|
+
);
|
|
335
|
+
const cached = _openaiCachedTokens(obj.usage);
|
|
336
|
+
if (
|
|
337
|
+
!_hasCompleteProviderUsage(usage) ||
|
|
338
|
+
cached == null ||
|
|
339
|
+
cached > prompt
|
|
340
|
+
) {
|
|
341
|
+
state.usageInvalid = true;
|
|
342
|
+
} else {
|
|
343
|
+
state.inputTokens = Math.max(0, prompt - cached);
|
|
344
|
+
state.outputTokens = completion;
|
|
345
|
+
state.cacheReadTokens = cached;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return state;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function _openaiFinalize(state) {
|
|
352
|
+
const toolCalls = state.tools.filter(Boolean).map((t) => ({
|
|
353
|
+
id: t.id || `call_${t.name || "tool"}`,
|
|
354
|
+
type: "function",
|
|
355
|
+
function: { name: t.name, arguments: t.args || "{}" },
|
|
356
|
+
}));
|
|
357
|
+
const message = { role: "assistant", content: state.text };
|
|
358
|
+
if (toolCalls.length) message.tool_calls = toolCalls;
|
|
359
|
+
const out = { message };
|
|
360
|
+
if (
|
|
361
|
+
state.usageInvalid !== true &&
|
|
362
|
+
_isNonNegativeSafeInteger(state.inputTokens) &&
|
|
363
|
+
_isNonNegativeSafeInteger(state.outputTokens)
|
|
364
|
+
) {
|
|
365
|
+
out.usage = {
|
|
366
|
+
input_tokens: state.inputTokens,
|
|
367
|
+
output_tokens: state.outputTokens,
|
|
368
|
+
cache_read_input_tokens: state.cacheReadTokens,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
return out;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Pure reducer over OpenAI-compatible SSE lines — exported for tests. */
|
|
375
|
+
export function _accumulateOpenAIStream(lines, onToken) {
|
|
376
|
+
const state = _openaiInitState();
|
|
377
|
+
for (const line of lines) _openaiReduceLine(state, line, onToken);
|
|
378
|
+
return _openaiFinalize(state);
|
|
379
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P as c,J as d,b as s}from"./vendor-Bn1JzzAn.js";import{r as a}from"./markdown-Yo_c6Krv.js";import{_ as p}from"./index-CuZupgUw.js";const _={__name:"MarkdownRenderer",props:{content:{type:String,default:""}},setup(t,{expose:o}){o();const e=t,r=s(()=>a(e.content||"")),n={props:e,rendered:r,computed:s,get renderMarkdown(){return a}};return Object.defineProperty(n,"__isScriptSetup",{enumerable:!1,value:!0}),n}},i=["innerHTML"];function m(t,o,e,r,n,u){return c(),d("div",{class:"markdown-content",innerHTML:r.rendered},null,8,i)}const w=p(_,[["render",m],["__scopeId","data-v-0b0b9f63"],["__file","/tmp/cc-web-panel-eIdfn0/repo/packages/web-panel/src/components/MarkdownRenderer.vue"]]);export{w as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as I,b as w,r as b,I as m,J as y,U as a,R as g,c as i,K as u,V as h,F as C,Z as L,N as O,o as M,P as p,Q as S,S as R}from"./vendor-Bn1JzzAn.js";import{u as q,_ as E}from"./index-CuZupgUw.js";import{u as N}from"./useShellMode-CgR0wCYM.js";import{p as P}from"./parsers-YNLm7sQ0.js";import{u as z}from"./chat-C66V_U7w.js";import{aa as V,aq as j,R as B}from"./icons-DG5UD-6K.js";const A=I("skills",()=>{const _=b(!1),t=b([]),n=b(""),e=b("all"),k=w(()=>{const o=new Set(["all"]);return t.value.forEach(l=>{l.category&&o.add(l.category),l.executionMode&&o.add(l.executionMode)}),[...o]}),v=w(()=>{let o=t.value;if(e.value!=="all"&&(o=o.filter(l=>l.category===e.value||l.executionMode===e.value)),n.value){const l=n.value.toLowerCase();o=o.filter(d=>d.name?.toLowerCase().includes(l)||d.description?.toLowerCase().includes(l)||d.title?.toLowerCase().includes(l))}return o});async function f(){const o=q();_.value=!0;try{if(N().isEmbedded){const c=await o.sendRaw({type:"skill.list"},2e4);c?.ok&&Array.isArray(c.result?.skills)?t.value=c.result.skills:(console.error("skill.list custom topic failed:",c?.error),t.value=[]);return}const{output:l}=await o.execute("skill list",2e4),d=P(l);t.value=d}catch(l){console.error("Failed to load skills:",l)}finally{_.value=!1}}return{loading:_,allSkills:t,searchQuery:n,selectedCategory:e,categories:k,filteredSkills:v,loadSkills:f}}),F={__name:"Skills",setup(_,{expose:t}){t();const n=A(),e=z(),k=O(),v=w(()=>n.categories.filter(r=>r!=="all").slice(0,6));function f(r){return{"built-in":"内置","cli-direct":"CLI",agent:"Agent","llm-query":"LLM",hybrid:"混合",workspace:"工作区",marketplace:"市场"}[r]||r}function o(r){return{"cli-direct":"CLI",agent:"Agent","llm-query":"LLM",hybrid:"混合","built-in":"内置"}[r]||r||"未知"}function l(r){return{"cli-direct":"cyan",agent:"purple","llm-query":"blue",hybrid:"orange","built-in":"green"}[r]||"default"}async function d(r){await e.createSession("agent"),k.push("/chat"),setTimeout(()=>{e.currentSessionId&&e.sendMessage(e.currentSessionId,`/skill run ${r}`)},300)}M(()=>{n.allSkills.length||n.loadSkills()});const c={skillsStore:n,chatStore:e,router:k,displayCategories:v,catLabel:f,modeLabel:o,modeColor:l,runSkill:d,computed:w,onMounted:M,get useRouter(){return O},get ReloadOutlined(){return B},get PlayCircleOutlined(){return j},get AppstoreOutlined(){return V},get useSkillsStore(){return A},get useChatStore(){return z}};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}},Q={style:{display:"flex","align-items":"center","justify-content":"space-between","margin-bottom":"24px"}},U={class:"page-sub"},T={style:{display:"flex",gap:"12px","margin-bottom":"20px","flex-wrap":"wrap"}},D={key:0,style:{"text-align":"center",padding:"60px"}},G={class:"skills-grid"},J={style:{display:"flex","justify-content":"space-between","align-items":"flex-start"}},K={style:{flex:"1","min-width":"0"}},W={style:{"font-weight":"500",color:"#e0e0e0","font-size":"14px","margin-bottom":"4px","font-family":"monospace"}},Z={style:{color:"var(--text-secondary)","font-size":"12px","line-height":"1.5"}},H={style:{"margin-left":"12px","flex-shrink":"0"}},X={style:{"margin-top":"10px",display:"flex","justify-content":"flex-end"}},Y={style:{"text-align":"center",padding:"60px",color:"var(--text-muted)"}};function $(_,t,n,e,k,v){const f=m("a-button"),o=m("a-input-search"),l=m("a-radio-button"),d=m("a-radio-group"),c=m("a-spin"),r=m("a-tag"),x=m("a-card");return p(),y("div",null,[a("div",Q,[a("div",null,[t[3]||(t[3]=a("h2",{class:"page-title"},"技能管理",-1)),a("p",U,g(e.skillsStore.allSkills.length)+" 个可用技能",1)]),i(f,{type:"primary",ghost:"",loading:e.skillsStore.loading,onClick:t[0]||(t[0]=s=>e.skillsStore.loadSkills())},{icon:u(()=>[i(e.ReloadOutlined)]),default:u(()=>[t[4]||(t[4]=S(" 刷新 ",-1))]),_:1},8,["loading"])]),h(" Search & Filter "),a("div",T,[i(o,{value:e.skillsStore.searchQuery,"onUpdate:value":t[1]||(t[1]=s=>e.skillsStore.searchQuery=s),placeholder:"搜索技能名称或描述...",style:{width:"300px"},"allow-clear":""},null,8,["value"]),i(d,{value:e.skillsStore.selectedCategory,"onUpdate:value":t[2]||(t[2]=s=>e.skillsStore.selectedCategory=s),"button-style":"solid"},{default:u(()=>[i(l,{value:"all"},{default:u(()=>[...t[5]||(t[5]=[S("全部",-1)])]),_:1}),(p(!0),y(C,null,L(e.displayCategories,s=>(p(),R(l,{key:s,value:s},{default:u(()=>[S(g(e.catLabel(s)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),h(" Loading State "),e.skillsStore.loading?(p(),y("div",D,[i(c,{size:"large"}),t[6]||(t[6]=a("div",{style:{color:"var(--text-muted)","margin-top":"12px"}},"加载技能中...",-1))])):e.skillsStore.filteredSkills.length?(p(),y(C,{key:1},[h(" Skills Grid "),a("div",G,[(p(!0),y(C,null,L(e.skillsStore.filteredSkills,s=>(p(),R(x,{key:s.name,class:"skill-card",size:"small",hoverable:"",style:{background:"var(--bg-card)","border-color":"var(--border-color)",cursor:"default"}},{default:u(()=>[a("div",J,[a("div",K,[a("div",W,g(s.name),1),a("div",Z,g(s.description||"暂无描述"),1)]),a("div",H,[i(r,{color:e.modeColor(s.executionMode),style:{"font-size":"10px"}},{default:u(()=>[S(g(e.modeLabel(s.executionMode)),1)]),_:2},1032,["color"])])]),a("div",X,[i(f,{size:"small",type:"primary",ghost:"",onClick:ee=>e.runSkill(s.name)},{icon:u(()=>[i(e.PlayCircleOutlined)]),default:u(()=>[t[7]||(t[7]=S(" 运行 ",-1))]),_:1},8,["onClick"])])]),_:2},1024))),128))])],2112)):(p(),y(C,{key:2},[h(" Empty State "),a("div",Y,[i(e.AppstoreOutlined,{style:{"font-size":"48px","margin-bottom":"16px",display:"block"}}),a("div",null,g(e.skillsStore.allSkills.length?"没有匹配的技能":"点击刷新加载技能列表"),1)])],2112))])}const ie=E(F,[["render",$],["__scopeId","data-v-d64d43f5"],["__file","/tmp/cc-web-panel-eIdfn0/repo/packages/web-panel/src/views/Skills.vue"]]);export{ie as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as F,b as D,r as R,I as p,J as c,U as _,c as n,K as a,S as C,V as x,o as P,x as V,P as i,Q as k,R as r,F as T,Z as O}from"./vendor-Bn1JzzAn.js";import{u as I,_ as E}from"./index-CuZupgUw.js";import{R as U}from"./icons-DG5UD-6K.js";const B=F("tasks",()=>{const y=R([]),l=R(!1);let u=null,t=null,d=null;const b=D(()=>y.value.filter(e=>e.status==="running")),v=D(()=>y.value.filter(e=>e.status==="pending")),w=D(()=>y.value.filter(e=>e.status==="completed"||e.status==="failed"||e.status==="timeout"));async function s(){const e=I();l.value=!0;try{const g=await e.sendRaw({type:"tasks-list"});g&&Array.isArray(g.tasks)&&(y.value=g.tasks)}catch{}finally{l.value=!1}}async function m(e){const g=I();try{await g.sendRaw({type:"tasks-stop",taskId:e})}catch{}finally{await s()}}const f=R(null);function h(e=5e3){N(),s(),u=setInterval(s,e),S()}function N(){u&&(clearInterval(u),u=null),t&&(t(),t=null),d&&(clearTimeout(d),d=null)}function S(){const e=I();if(t)return;const g=z=>{z.type==="task:notification"&&z.payload?.task&&(f.value=z.payload.task,s(),d&&clearTimeout(d),d=setTimeout(()=>{f.value=null,d=null},8e3))};t=e.onRuntimeEvent(g)}function A(e){return!e||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function o(e){switch(e){case"running":return"processing";case"pending":return"default";case"completed":return"success";case"failed":return"error";case"timeout":return"warning";default:return"default"}}return{tasks:y,loading:l,running:b,pending:v,completed:w,lastNotification:f,fetchTasks:s,stopTask:m,startPolling:h,stopPolling:N,formatDuration:A,getStatusColor:o}}),L={__name:"Tasks",setup(y,{expose:l}){l();const u=B(),t=[{title:"状态",key:"status",width:90},{title:"描述",key:"description",ellipsis:!0},{title:"类型",dataIndex:"type",width:100},{title:"耗时",key:"duration",width:90},{title:"创建时间",key:"createdAt",width:180},{title:"结果",key:"result",ellipsis:!0},{title:"操作",key:"action",width:80}];function d(s){return s.status==="running"&&s.startedAt?u.formatDuration(Date.now()-s.startedAt):s.completedAt&&s.startedAt?u.formatDuration(s.completedAt-s.startedAt):"-"}function b(s){return s?new Date(s).toLocaleString():"-"}function v(s,m){return s?s.length>m?`${s.slice(0,m)}...`:s:""}P(()=>u.startPolling(5e3)),V(()=>u.stopPolling());const w={store:u,columns:t,getDuration:d,formatTime:b,truncate:v,onMounted:P,onUnmounted:V,get ReloadOutlined(){return U},get useTasksStore(){return B}};return Object.defineProperty(w,"__isScriptSetup",{enumerable:!1,value:!0}),w}},j={class:"page-header"},J={key:0,class:"error-text"},K={key:1},M={class:"task-header"},Q={class:"task-desc"},W={class:"task-id"},Z={class:"task-meta"},q=["title"],G={key:0,class:"error-text"},H={key:1,class:"success-text"},X={key:2,class:"muted-text"};function Y(y,l,u,t,d,b){const v=p("a-button"),w=p("a-space"),s=p("a-alert"),m=p("a-statistic"),f=p("a-card"),h=p("a-col"),N=p("a-row"),S=p("a-tag"),A=p("a-table");return i(),c("div",null,[_("div",j,[l[3]||(l[3]=_("div",null,[_("h2",{class:"page-title"},"后台任务"),_("p",{class:"page-sub"},"查看后台任务队列、实时通知和任务执行结果。")],-1)),n(w,null,{default:a(()=>[n(v,{ghost:"",loading:t.store.loading,onClick:l[0]||(l[0]=o=>t.store.fetchTasks())},{icon:a(()=>[n(t.ReloadOutlined)]),default:a(()=>[l[2]||(l[2]=k(" 刷新 ",-1))]),_:1},8,["loading"])]),_:1})]),t.store.lastNotification?(i(),C(s,{key:0,type:t.store.lastNotification.status==="completed"?"success":"error","show-icon":"",closable:"",class:"banner",onClose:l[1]||(l[1]=o=>t.store.lastNotification=null)},{message:a(()=>[k(" 任务"+r(t.store.lastNotification.status==="completed"?"完成":"结束")+": "+r(t.store.lastNotification.description||t.store.lastNotification.id.slice(0,16)),1)]),description:a(()=>[t.store.lastNotification.error?(i(),c("span",J,r(t.store.lastNotification.error),1)):t.store.lastNotification.result?(i(),c("span",K,r(t.truncate(String(t.store.lastNotification.result),120)),1)):x("v-if",!0)]),_:1},8,["type"])):x("v-if",!0),n(N,{gutter:[16,16],class:"stats-row"},{default:a(()=>[n(h,{xs:12,sm:6},{default:a(()=>[n(f,{class:"stat-card",size:"small"},{default:a(()=>[n(m,{title:"全部任务",value:t.store.tasks.length},null,8,["value"])]),_:1})]),_:1}),n(h,{xs:12,sm:6},{default:a(()=>[n(f,{class:"stat-card",size:"small"},{default:a(()=>[n(m,{title:"运行中",value:t.store.running.length},null,8,["value"])]),_:1})]),_:1}),n(h,{xs:12,sm:6},{default:a(()=>[n(f,{class:"stat-card",size:"small"},{default:a(()=>[n(m,{title:"等待中",value:t.store.pending.length},null,8,["value"])]),_:1})]),_:1}),n(h,{xs:12,sm:6},{default:a(()=>[n(f,{class:"stat-card",size:"small"},{default:a(()=>[n(m,{title:"已完成",value:t.store.completed.length},null,8,["value"])]),_:1})]),_:1})]),_:1}),t.store.running.length>0?(i(),C(f,{key:1,title:"运行中的任务",class:"panel-card",size:"small"},{default:a(()=>[(i(!0),c(T,null,O(t.store.running,o=>(i(),c("div",{key:o.id,class:"task-item running"},[_("div",M,[n(S,{color:t.store.getStatusColor(o.status)},{default:a(()=>[k(r(o.status.toUpperCase()),1)]),_:2},1032,["color"]),_("span",Q,r(o.description),1),_("span",W,r(o.id.slice(0,16)),1)]),_("div",Z,[_("span",null,"类型: "+r(o.type||"-"),1),_("span",null,"已运行: "+r(t.store.formatDuration(Date.now()-o.startedAt)),1),n(v,{size:"small",danger:"",onClick:e=>t.store.stopTask(o.id)},{default:a(()=>[...l[4]||(l[4]=[k("停止",-1)])]),_:1},8,["onClick"])])]))),128))]),_:1})):x("v-if",!0),n(f,{class:"panel-card"},{default:a(()=>[n(A,{columns:t.columns,"data-source":t.store.tasks,pagination:{pageSize:15,size:"small"},loading:t.store.loading,"row-key":"id",size:"small"},{bodyCell:a(({column:o,record:e})=>[o.key==="status"?(i(),C(S,{key:0,color:t.store.getStatusColor(e.status)},{default:a(()=>[k(r(e.status),1)]),_:2},1032,["color"])):o.key==="description"?(i(),c("span",{key:1,title:e.command},r(e.description),9,q)):o.key==="duration"?(i(),c(T,{key:2},[k(r(t.getDuration(e)),1)],64)):o.key==="createdAt"?(i(),c(T,{key:3},[k(r(t.formatTime(e.createdAt)),1)],64)):o.key==="result"?(i(),c(T,{key:4},[e.error?(i(),c("span",G,r(t.truncate(e.error,60)),1)):e.result?(i(),c("span",H,r(t.truncate(String(e.result),60)),1)):(i(),c("span",X,"-"))],64)):o.key==="action"?(i(),c(T,{key:5},[e.status==="running"?(i(),C(v,{key:0,size:"small",danger:"",onClick:g=>t.store.stopTask(e.id)},{default:a(()=>[...l[5]||(l[5]=[k(" 停止 ",-1)])]),_:1},8,["onClick"])):x("v-if",!0)],64)):x("v-if",!0)]),_:1},8,["data-source","loading"])]),_:1})])}const st=E(L,[["render",Y],["__scopeId","data-v-da5ff6a2"],["__file","/tmp/cc-web-panel-eIdfn0/repo/packages/web-panel/src/views/Tasks.vue"]]);export{st as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as r}from"./index-CuZupgUw.js";const o=((n,a,e)=>{r(n,`[ant-design-vue: ${a}] ${e}`)});export{o as d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as o}from"./Col-G0zYohIP.js";import{a0 as t}from"./index-CuZupgUw.js";import"./vendor-Bn1JzzAn.js";import"./index-BZ7mv_oS.js";import"./icons-DG5UD-6K.js";const s=t(o);export{s as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as o}from"./Row-EzEMaYoV.js";import{a0 as t}from"./index-CuZupgUw.js";import"./vendor-Bn1JzzAn.js";import"./responsiveObserve-PfqJrlkI.js";import"./useFlexGapSupport-ITPUjcDw.js";import"./styleChecker-Bq57I3ls.js";import"./index-BZ7mv_oS.js";import"./icons-DG5UD-6K.js";const l=t(o);export{l as default};
|