arco-workbench 0.1.3 → 0.1.4
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/CONTRIBUTING.md +1 -1
- package/README.md +5 -1
- package/client/dist/assets/{PhosphorBackdrop-CkVIGkeX.js → PhosphorBackdrop-CNumba2X.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-DHF7CnpE.js → ThemedBackgroundShaderImpl-DX5KyCt3.js} +1 -1
- package/client/dist/assets/{XtermView-SY0UcZUS.js → XtermView-DhS5g8Rt.js} +1 -1
- package/client/dist/assets/{galleryEditor-Ca4F8HiM.js → galleryEditor-fPb76Cjv.js} +1 -1
- package/client/dist/assets/index-CjkHb-_n.js +592 -0
- package/client/dist/assets/index-DIbh3ae5.css +1 -0
- package/client/dist/index.html +2 -2
- package/client/src/App.tsx +2 -0
- package/client/src/alerts/desktopAlerts.ts +13 -1
- package/client/src/brief/briefFacts.ts +22 -0
- package/client/src/brief/briefFromStore.ts +7 -2
- package/client/src/components/ArtifactMoveDialog.tsx +64 -0
- package/client/src/components/BriefControl.tsx +38 -47
- package/client/src/components/CatchMeUp.tsx +25 -25
- package/client/src/components/CheckpointActions.tsx +7 -4
- package/client/src/components/ClusterComposerButtons.tsx +6 -3
- package/client/src/components/ClusterPlanTab.tsx +15 -1
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +6 -2
- package/client/src/components/ClusterTab.tsx +33 -3
- package/client/src/components/ClusterTaskBoardTab.tsx +62 -8
- package/client/src/components/DialogShell.tsx +115 -0
- package/client/src/components/DocsUpdateDialog.tsx +16 -42
- package/client/src/components/ForwardMessages.tsx +28 -32
- package/client/src/components/GitDialog.tsx +52 -52
- package/client/src/components/GitOtherWork.tsx +4 -2
- package/client/src/components/HandoffDialog.tsx +19 -45
- package/client/src/components/Home/HomeView.tsx +36 -8
- package/client/src/components/Home/home.css +7 -0
- package/client/src/components/KeepButton.tsx +23 -0
- package/client/src/components/MdTuneupDialog.tsx +52 -51
- package/client/src/components/MemberCard.tsx +4 -1
- package/client/src/components/MemberPane.tsx +1 -1
- package/client/src/components/NotificationCenter.tsx +4 -3
- package/client/src/components/NotificationChannelsSettings.tsx +25 -7
- package/client/src/components/PlanCandidateBanner.tsx +111 -57
- package/client/src/components/PlanComposerDialog.tsx +55 -87
- package/client/src/components/ProjectStateNotice.tsx +60 -0
- package/client/src/components/PublicProjectBox.tsx +25 -0
- package/client/src/components/ResearchDialog.tsx +15 -24
- package/client/src/components/ReviewDialog.tsx +32 -57
- package/client/src/components/RightPanel/OutputsPanel.tsx +4 -0
- package/client/src/components/RightPanel/PlanTab.tsx +24 -2
- package/client/src/components/RightPanel/UsageTab.tsx +77 -1
- package/client/src/components/SkillEditorDialog.tsx +38 -73
- package/client/src/components/SpawnDialog.tsx +19 -41
- package/client/src/components/StorageWarnings.tsx +21 -0
- package/client/src/components/SystemHeader.tsx +2 -2
- package/client/src/components/TerminalInput.tsx +6 -2
- package/client/src/components/TidyComposer.tsx +24 -41
- package/client/src/components/TranscriptSendDialog.tsx +151 -202
- package/client/src/components/UtilityAgentPicker.tsx +4 -2
- package/client/src/components/WorkflowCreator/index.tsx +2 -0
- package/client/src/components/WorkflowView.tsx +4 -1
- package/client/src/components/clusterNeedsYou.ts +35 -3
- package/client/src/components/compare/CompareDialog.tsx +26 -2
- package/client/src/components/terminalInput/planDraft.ts +33 -4
- package/client/src/components/utilityResult.ts +5 -1
- package/client/src/explorer/ExplorerApp.tsx +5 -2
- package/client/src/explorer/PlansLens.tsx +60 -19
- package/client/src/explorer/StorageLens.tsx +275 -0
- package/client/src/explorer/launch.ts +3 -3
- package/client/src/explorer/plansGrouping.ts +15 -0
- package/client/src/help/content/cluster.tsx +42 -7
- package/client/src/help/content/composer.tsx +26 -6
- package/client/src/help/content/header.tsx +16 -14
- package/client/src/help/content/misc.tsx +141 -6
- package/client/src/help/content/rightPanel.tsx +16 -0
- package/client/src/help/content/settings.tsx +4 -4
- package/client/src/help/manualSections/actions.tsx +19 -4
- package/client/src/help/manualSections/clusters.tsx +29 -16
- package/client/src/help/manualSections/configuration.tsx +6 -4
- package/client/src/help/manualSections/maintenance.tsx +27 -5
- package/client/src/help/manualSections/plans.tsx +96 -2
- package/client/src/help/manualSections/powerFeatures.tsx +2 -2
- package/client/src/help/manualSections/reference.tsx +6 -0
- package/client/src/help/manualSections/workspace.tsx +9 -5
- package/client/src/stores/appStore.ts +10 -1
- package/client/src/stores/appStore.types.ts +2 -0
- package/client/src/stores/mdTuneupStore.ts +5 -4
- package/client/src/stores/memoryTrim.ts +18 -2
- package/client/src/stores/storageWarningStore.ts +18 -0
- package/client/src/utils/gitDialogMemory.ts +26 -0
- package/client/src/utils/historyEvents.ts +1 -0
- package/client/src/utils/homeModel.ts +19 -0
- package/client/src/utils/publicProject.ts +56 -0
- package/client/src/ws/handleServerMessage.ts +7 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CHECKPOINTS.md +2 -0
- package/docs/CLIENT.md +29 -11
- package/docs/FEATURES.md +14 -11
- package/docs/GETTING_STARTED.md +7 -7
- package/docs/GLOSSARY.md +3 -3
- package/docs/GOTCHAS.md +3 -2
- package/docs/HTTP_API.md +31 -1
- package/docs/NOTIFICATIONS.md +13 -14
- package/docs/OPERATIONS.md +27 -1
- package/docs/OPERATOR_ACTIONS.md +1 -1
- package/docs/OUTPUTS.md +9 -0
- package/docs/PERSISTENCE.md +34 -4
- package/docs/PLAN_OR_BOARD.md +7 -0
- package/docs/PRIMITIVES.md +3 -3
- package/docs/PROTOCOL.md +14 -4
- package/docs/PROTOCOL_CLUSTER.md +3 -2
- package/docs/SERVICE_MODE.md +5 -1
- package/docs/SETTINGS.md +8 -6
- package/docs/STORAGE_PLAN.md +324 -0
- package/docs/TASK_LEDGER.md +5 -4
- package/native/linux-arm64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/index.d.ts +2 -0
- package/node_modules/@arco/shared/dist/index.js +2 -0
- package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +1 -1
- package/node_modules/@arco/shared/dist/protocol/autoPickup.js +1 -1
- package/node_modules/@arco/shared/dist/protocol/checkpoints.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
- package/node_modules/@arco/shared/dist/protocol/mdTuneup.d.ts +6 -0
- package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/notifications.js +3 -2
- package/node_modules/@arco/shared/dist/protocol/plans.d.ts +2 -0
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/storage.d.ts +21 -0
- package/node_modules/@arco/shared/dist/protocol/storage.js +3 -0
- package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +3 -0
- package/node_modules/@arco/shared/dist/protocol/utilityAgent.d.ts +2 -2
- package/node_modules/@arco/shared/dist/protocol/utilityAgent.js +2 -2
- package/node_modules/@arco/shared/dist/publicGuardrails.d.ts +7 -0
- package/node_modules/@arco/shared/dist/publicGuardrails.js +47 -0
- package/node_modules/@arco/shared/dist/publicSafetyRules.d.ts +1 -0
- package/node_modules/@arco/shared/dist/publicSafetyRules.js +6 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +3 -2
- package/scripts/packaging/arco.mjs +17 -1
- package/scripts/packaging/services.mjs +35 -5
- package/scripts/packaging/storage.mjs +125 -0
- package/scripts/packaging/update.mjs +3 -3
- package/server/dist/artifactCopy.d.ts +26 -0
- package/server/dist/artifactCopy.js +398 -0
- package/server/dist/atomicFile.d.ts +1 -0
- package/server/dist/atomicFile.js +1 -1
- package/server/dist/attention.d.ts +1 -1
- package/server/dist/attention.js +10 -13
- package/server/dist/catchUp.d.ts +2 -0
- package/server/dist/catchUp.js +46 -23
- package/server/dist/clusterPeerOps.d.ts +2 -0
- package/server/dist/clusterPeerOps.js +2 -0
- package/server/dist/clusterSnapshots.js +22 -12
- package/server/dist/eventLog.d.ts +55 -0
- package/server/dist/eventLog.js +792 -0
- package/server/dist/explorerLaunch.d.ts +4 -1
- package/server/dist/explorerLaunch.js +3 -2
- package/server/dist/explorerPlans.d.ts +4 -0
- package/server/dist/explorerPlans.js +27 -2
- package/server/dist/http/clusterRoutes.js +2 -0
- package/server/dist/http/explorerRoutes.js +2 -1
- package/server/dist/http/publicProjectRoutes.d.ts +2 -0
- package/server/dist/http/publicProjectRoutes.js +68 -0
- package/server/dist/http/router.js +6 -0
- package/server/dist/http/storageRoutes.d.ts +2 -0
- package/server/dist/http/storageRoutes.js +254 -0
- package/server/dist/http/usageStatsRoutes.js +3 -12
- package/server/dist/index.js +4 -0
- package/server/dist/keepStore.d.ts +16 -0
- package/server/dist/keepStore.js +119 -0
- package/server/dist/management/clusterActivity.js +6 -20
- package/server/dist/management/initHubLink.js +10 -43
- package/server/dist/mcp/clusterMcpTools.js +8 -1
- package/server/dist/notifications.d.ts +3 -1
- package/server/dist/notifications.js +5 -4
- package/server/dist/outputStore.d.ts +1 -0
- package/server/dist/outputStore.js +1 -1
- package/server/dist/outputs.js +39 -8
- package/server/dist/planHistory.d.ts +3 -0
- package/server/dist/planHistory.js +60 -0
- package/server/dist/primitives/runMdTuneup.d.ts +5 -1
- package/server/dist/primitives/runMdTuneup.js +43 -2
- package/server/dist/project/taskLedger.d.ts +4 -0
- package/server/dist/project/taskLedger.js +19 -0
- package/server/dist/providers/claude-native/peerTools.js +4 -0
- package/server/dist/providers/claude-native/resumeSummary.js +30 -19
- package/server/dist/providers/index.js +8 -13
- package/server/dist/providers/localProviderQueue.d.ts +2 -0
- package/server/dist/providers/localProviderQueue.js +11 -0
- package/server/dist/publicProject.d.ts +54 -0
- package/server/dist/publicProject.js +135 -0
- package/server/dist/recall/index.js +22 -23
- package/server/dist/server/broadcast.d.ts +2 -1
- package/server/dist/server/broadcast.js +56 -1
- package/server/dist/smartPickupAdapters.d.ts +7 -0
- package/server/dist/smartPickupAdapters.js +172 -8
- package/server/dist/storageActions.d.ts +50 -0
- package/server/dist/storageActions.js +326 -0
- package/server/dist/storageArchive.d.ts +24 -0
- package/server/dist/storageArchive.js +358 -0
- package/server/dist/storageOverview.d.ts +47 -0
- package/server/dist/storageOverview.js +197 -0
- package/server/dist/storageReport.d.ts +48 -0
- package/server/dist/storageReport.js +185 -0
- package/server/dist/storageWarnings.d.ts +4 -0
- package/server/dist/storageWarnings.js +96 -0
- package/server/dist/workers/limits.js +4 -1
- package/server/dist/workflowStore.d.ts +2 -0
- package/server/dist/workflowStore.js +88 -72
- package/server/dist/workflows/purgeWorkflow.d.ts +1 -0
- package/server/dist/workflows/purgeWorkflow.js +15 -2
- package/server/dist/workflows/sessionDiscovery.js +5 -17
- package/server/dist/workflows/sessionIndex.js +22 -17
- package/server/dist/ws/taskLedgerHandlers.js +8 -3
- package/server/dist/ws/workflowHandlers.js +5 -4
- package/server/package.json +1 -1
- package/server/src/artifactCopy.ts +254 -0
- package/server/src/atomicFile.ts +1 -1
- package/server/src/attention.ts +9 -10
- package/server/src/catchUp.ts +37 -15
- package/server/src/clusterPeerOps.ts +5 -0
- package/server/src/clusterSnapshots.ts +20 -13
- package/server/src/eventLog.ts +571 -0
- package/server/src/explorerLaunch.ts +3 -2
- package/server/src/explorerPlans.ts +22 -2
- package/server/src/http/clusterRoutes.ts +4 -1
- package/server/src/http/explorerRoutes.ts +2 -1
- package/server/src/http/publicProjectRoutes.ts +54 -0
- package/server/src/http/router.ts +4 -0
- package/server/src/http/storageRoutes.ts +187 -0
- package/server/src/http/usageStatsRoutes.ts +3 -11
- package/server/src/index.ts +4 -0
- package/server/src/keepStore.ts +102 -0
- package/server/src/management/clusterActivity.ts +6 -16
- package/server/src/management/initHubLink.ts +10 -39
- package/server/src/mcp/clusterMcpTools.ts +8 -2
- package/server/src/notifications.ts +4 -3
- package/server/src/outputStore.ts +5 -2
- package/server/src/outputs.ts +30 -6
- package/server/src/planHistory.ts +48 -0
- package/server/src/primitives/runMdTuneup.ts +32 -2
- package/server/src/project/taskLedger.ts +20 -0
- package/server/src/providers/claude-native/peerTools.ts +4 -0
- package/server/src/providers/claude-native/resumeSummary.ts +32 -18
- package/server/src/providers/index.ts +2 -16
- package/server/src/providers/localProviderQueue.ts +13 -0
- package/server/src/publicProject.ts +142 -0
- package/server/src/recall/index.ts +4 -9
- package/server/src/server/broadcast.ts +53 -1
- package/server/src/smartPickupAdapters.ts +128 -5
- package/server/src/storageActions.ts +216 -0
- package/server/src/storageArchive.ts +277 -0
- package/server/src/storageOverview.ts +184 -0
- package/server/src/storageReport.ts +210 -0
- package/server/src/storageWarnings.ts +84 -0
- package/server/src/workers/limits.ts +4 -1
- package/server/src/workflowStore.ts +78 -61
- package/server/src/workflows/purgeWorkflow.ts +12 -3
- package/server/src/workflows/sessionDiscovery.ts +5 -13
- package/server/src/workflows/sessionIndex.ts +5 -9
- package/server/src/ws/taskLedgerHandlers.ts +8 -3
- package/server/src/ws/workflowHandlers.ts +5 -4
- package/shared/dist/index.d.ts +2 -0
- package/shared/dist/index.js +2 -0
- package/shared/dist/protocol/autoPickup.d.ts +1 -1
- package/shared/dist/protocol/autoPickup.js +1 -1
- package/shared/dist/protocol/checkpoints.d.ts +1 -0
- package/shared/dist/protocol/clusters.d.ts +2 -1
- package/shared/dist/protocol/index.d.ts +1 -0
- package/shared/dist/protocol/index.js +1 -0
- package/shared/dist/protocol/mdTuneup.d.ts +6 -0
- package/shared/dist/protocol/notifications.d.ts +2 -1
- package/shared/dist/protocol/notifications.js +3 -2
- package/shared/dist/protocol/plans.d.ts +2 -0
- package/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/shared/dist/protocol/storage.d.ts +21 -0
- package/shared/dist/protocol/storage.js +3 -0
- package/shared/dist/protocol/tasks.d.ts +3 -0
- package/shared/dist/protocol/utilityAgent.d.ts +2 -2
- package/shared/dist/protocol/utilityAgent.js +2 -2
- package/shared/dist/publicGuardrails.d.ts +7 -0
- package/shared/dist/publicGuardrails.js +47 -0
- package/shared/dist/publicSafetyRules.d.ts +1 -0
- package/shared/dist/publicSafetyRules.js +6 -0
- package/shared/src/index.ts +3 -0
- package/shared/src/protocol/autoPickup.ts +1 -1
- package/shared/src/protocol/checkpoints.ts +4 -0
- package/shared/src/protocol/clusters.ts +6 -1
- package/shared/src/protocol/index.ts +1 -0
- package/shared/src/protocol/mdTuneup.ts +5 -0
- package/shared/src/protocol/notifications.ts +6 -2
- package/shared/src/protocol/plans.ts +2 -0
- package/shared/src/protocol/serverMessages.ts +2 -0
- package/shared/src/protocol/storage.ts +35 -0
- package/shared/src/protocol/tasks.ts +6 -0
- package/shared/src/protocol/utilityAgent.ts +2 -2
- package/shared/src/publicGuardrails.ts +50 -0
- package/shared/src/publicSafetyRules.ts +5 -0
- package/client/dist/assets/index-CcNtMA2y.js +0 -546
- package/client/dist/assets/index-Dl8tYsSp.css +0 -1
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
// Claude Native (no tools field), Cursor (Ask mode, no capabilities), Ollama
|
|
7
7
|
// (no tools field) and Codex (one-shot app-server, read-only sandbox, any
|
|
8
8
|
// tool item or approval request ends the turn).
|
|
9
|
-
export const UTILITY_AGENT_PROVIDERS = ['claude', 'codex', 'cursor', 'ollama'];
|
|
9
|
+
export const UTILITY_AGENT_PROVIDERS = ['claude', 'codex', 'cursor', 'ollama', 'lmstudio', 'llamacpp', 'strata', 'deepseek'];
|
|
10
10
|
export const UTILITY_AGENT_MODEL_MAX = 200;
|
|
11
11
|
// Input beyond this many characters is cut before it is sent.
|
|
12
12
|
export const UTILITY_JOB_INPUT_MAX_CHARS = 24_000;
|
|
13
13
|
export const UTILITY_JOB_TIMEOUT_MS = 60_000;
|
|
14
|
-
export const UTILITY_JOB_MAX_OUTPUT_TOKENS =
|
|
14
|
+
export const UTILITY_JOB_MAX_OUTPUT_TOKENS = 2048;
|
|
15
15
|
export function sanitizeUtilityAgent(raw) {
|
|
16
16
|
if (!raw || typeof raw !== 'object')
|
|
17
17
|
return null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const GUARDRAILS_HEADING = "Privacy and public safety";
|
|
2
|
+
export declare const PUBLIC_GUARDRAILS_TEMPLATE = "## Privacy and public safety\n\nThis project is public, or will be. Every commit, push and release follows these rules.\n\n**Never committed or published**\n- Secrets: tokens, keys, passwords, `.env` files and credentials.\n- Local details: file paths from a machine, machine and host names, IP addresses and usernames.\n- Personal data of anyone.\n- Screenshots, logs and recordings that show any of the above.\n- Private agent state and instruction files kept for local use.\n\n**Identity**\n- Every commit uses the project's chosen author and committer identity, with no other names or tool attributions in commits, pull requests or release notes.\n\n**How the rules are enforced**\n- Ignore rules keep private state, local configuration and scratch files out of the repository.\n- A secret scanner or a pre-commit check runs before every commit.\n- The staged diff is read in full before each commit and each push.\n\n**When something slips**\n- Revoke or rotate the secret first.\n- Rewriting history does not undo a push that was public: assume anything pushed was seen.\n";
|
|
3
|
+
export declare function hasGuardrails(body: string): boolean;
|
|
4
|
+
/** Insert the template before the first phase heading (or at the end). Returns the body unchanged when already present. */
|
|
5
|
+
export declare function insertGuardrails(body: string): string;
|
|
6
|
+
/** Text added to the plan draft prompt when the project is public. */
|
|
7
|
+
export declare const PUBLIC_DRAFT_REQUEST = "This project is public, or will be. Include a \"Privacy and public safety\" section of standing rules fitted to this project, placed before the first phase. Do not use ### headings inside it: ### lines are phases, so use bold labels and flat lists. Start from this template, name the project-specific risks you can see, and say how each rule is enforced:\n\n## Privacy and public safety\n\nThis project is public, or will be. Every commit, push and release follows these rules.\n\n**Never committed or published**\n- Secrets: tokens, keys, passwords, `.env` files and credentials.\n- Local details: file paths from a machine, machine and host names, IP addresses and usernames.\n- Personal data of anyone.\n- Screenshots, logs and recordings that show any of the above.\n- Private agent state and instruction files kept for local use.\n\n**Identity**\n- Every commit uses the project's chosen author and committer identity, with no other names or tool attributions in commits, pull requests or release notes.\n\n**How the rules are enforced**\n- Ignore rules keep private state, local configuration and scratch files out of the repository.\n- A secret scanner or a pre-commit check runs before every commit.\n- The staged diff is read in full before each commit and each push.\n\n**When something slips**\n- Revoke or rotate the secret first.\n- Rewriting history does not undo a push that was public: assume anything pushed was seen.\n";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Shared "Privacy and public safety" plan section. One fixed, generic template
|
|
2
|
+
// used by the plan draft prompt (when a project is public) and by INSERT
|
|
3
|
+
// GUARDRAILS in the plan view. Plain language; no real names or paths.
|
|
4
|
+
export const GUARDRAILS_HEADING = 'Privacy and public safety';
|
|
5
|
+
export const PUBLIC_GUARDRAILS_TEMPLATE = `## ${GUARDRAILS_HEADING}
|
|
6
|
+
|
|
7
|
+
This project is public, or will be. Every commit, push and release follows these rules.
|
|
8
|
+
|
|
9
|
+
**Never committed or published**
|
|
10
|
+
- Secrets: tokens, keys, passwords, \`.env\` files and credentials.
|
|
11
|
+
- Local details: file paths from a machine, machine and host names, IP addresses and usernames.
|
|
12
|
+
- Personal data of anyone.
|
|
13
|
+
- Screenshots, logs and recordings that show any of the above.
|
|
14
|
+
- Private agent state and instruction files kept for local use.
|
|
15
|
+
|
|
16
|
+
**Identity**
|
|
17
|
+
- Every commit uses the project's chosen author and committer identity, with no other names or tool attributions in commits, pull requests or release notes.
|
|
18
|
+
|
|
19
|
+
**How the rules are enforced**
|
|
20
|
+
- Ignore rules keep private state, local configuration and scratch files out of the repository.
|
|
21
|
+
- A secret scanner or a pre-commit check runs before every commit.
|
|
22
|
+
- The staged diff is read in full before each commit and each push.
|
|
23
|
+
|
|
24
|
+
**When something slips**
|
|
25
|
+
- Revoke or rotate the secret first.
|
|
26
|
+
- Rewriting history does not undo a push that was public: assume anything pushed was seen.
|
|
27
|
+
`;
|
|
28
|
+
const HEADING_RE = new RegExp(`^#{1,6}\\s*${GUARDRAILS_HEADING}\\s*$`, 'im');
|
|
29
|
+
export function hasGuardrails(body) {
|
|
30
|
+
return HEADING_RE.test(body);
|
|
31
|
+
}
|
|
32
|
+
/** Insert the template before the first phase heading (or at the end). Returns the body unchanged when already present. */
|
|
33
|
+
export function insertGuardrails(body) {
|
|
34
|
+
if (hasGuardrails(body))
|
|
35
|
+
return body;
|
|
36
|
+
const match = /^### .*$/m.exec(body);
|
|
37
|
+
const block = `${PUBLIC_GUARDRAILS_TEMPLATE}\n`;
|
|
38
|
+
if (!match)
|
|
39
|
+
return `${body.replace(/\s+$/, '')}${body.trim() ? '\n\n' : ''}${PUBLIC_GUARDRAILS_TEMPLATE}`;
|
|
40
|
+
const head = body.slice(0, match.index).replace(/\s+$/, '');
|
|
41
|
+
return `${head}${head ? '\n\n' : ''}${block}${body.slice(match.index)}`;
|
|
42
|
+
}
|
|
43
|
+
/** Text added to the plan draft prompt when the project is public. */
|
|
44
|
+
export const PUBLIC_DRAFT_REQUEST = `This project is public, or will be. Include a "${GUARDRAILS_HEADING}" section of standing rules fitted to this project, placed before the first phase. Do not use ### headings inside it: ### lines are phases, so use bold labels and flat lists. Start from this template, name the project-specific risks you can see, and say how each rule is enforced:
|
|
45
|
+
|
|
46
|
+
${PUBLIC_GUARDRAILS_TEMPLATE}`;
|
|
47
|
+
//# sourceMappingURL=publicGuardrails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const publicSafetyRules: readonly [readonly ["private-key", RegExp], readonly ["provider-token", RegExp], readonly ["credential-assignment", RegExp]];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const publicSafetyRules = [
|
|
2
|
+
['private-key', /-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----/],
|
|
3
|
+
['provider-token', /\b(?:sk-(?:proj-|ant-api\d+-)?[A-Za-z0-9_-]{24,}|gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{40,}|AKIA[0-9A-Z]{16})\b/],
|
|
4
|
+
['credential-assignment', /\b(?:api_key|apiKey|access_token|refresh_token|client_secret)\s*[=:]\s*["'][A-Za-z0-9_./+\-=]{32,}["']/],
|
|
5
|
+
];
|
|
6
|
+
//# sourceMappingURL=publicSafetyRules.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"node-pty": "1.1.0"
|
|
5
5
|
},
|
|
6
6
|
"name": "arco-workbench",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.4",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/ghreprimand/arco.git"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"scripts/packaging/service-logs.mjs",
|
|
38
38
|
"scripts/packaging/native-repair.mjs",
|
|
39
39
|
"scripts/packaging/update.mjs",
|
|
40
|
+
"scripts/packaging/storage.mjs",
|
|
40
41
|
"native",
|
|
41
42
|
"LICENSE"
|
|
42
43
|
],
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"node-pty": "1.1.0",
|
|
48
49
|
"proper-lockfile": "4.1.2",
|
|
49
50
|
"ws": "8.22.0",
|
|
50
|
-
"@arco/shared": "0.1.
|
|
51
|
+
"@arco/shared": "0.1.4"
|
|
51
52
|
},
|
|
52
53
|
"bundleDependencies": [
|
|
53
54
|
"@arco/shared",
|
|
@@ -12,11 +12,12 @@ import { activateRepairedTerminal, nativeSqliteBinding, repairNative, supportedN
|
|
|
12
12
|
import { updatePackage, writeUpdateResult } from './update.mjs';
|
|
13
13
|
import { openArco, shortcuts } from './launch.mjs';
|
|
14
14
|
import { isArcoHome, readPortState } from './ports.mjs';
|
|
15
|
+
import { knownProjects, unsealProjects } from './storage.mjs';
|
|
15
16
|
|
|
16
17
|
const root = fileURLToPath(new URL('../../', import.meta.url));
|
|
17
18
|
const manifest = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
18
19
|
const [command = 'help', ...args] = process.argv.slice(2);
|
|
19
|
-
const help = `Usage: arco <command>\n\n start Run the workbench in the foreground\n open [--tab] Open Arco in an app window or browser tab\n shortcuts <action> add or remove per-user launcher shortcuts\n setup Configure and start a per-user service\n setup --repair-native Repair native modules (build tools may be required)\n service <action> install, uninstall, start, stop, restart, status, logs or refresh\n update Update the installed package\n voice setup Install local voice components\n version Print the installed version\n doctor Check runtime, providers, port and service\n`;
|
|
20
|
+
const help = `Usage: arco <command>\n\n start Run the workbench in the foreground\n open [--tab] Open Arco in an app window or browser tab\n shortcuts <action> add or remove per-user launcher shortcuts\n setup Configure and start a per-user service\n setup --repair-native Repair native modules (build tools may be required)\n service <action> install, uninstall, start, stop, restart, status, logs or refresh\n update Update the installed package\n voice setup Install local voice components\n version Print the installed version\n doctor Check runtime, providers, port and service\n storage unseal [--project <path>]...\n Write compressed conversation logs back to plain files\n before installing an older release (Arco must be stopped)\n`;
|
|
20
21
|
function requireSupportedNode() { if (!supportedNodeVersion()) throw new Error('Unsupported Node.js version. Install Node.js 24 or 26 and retry.'); }
|
|
21
22
|
function checkNative() {
|
|
22
23
|
try {
|
|
@@ -101,6 +102,21 @@ async function main() {
|
|
|
101
102
|
const r = spawnSync(process.execPath, [join(root, 'scripts/voice/run.mjs'), 'setup.py'], { stdio: 'inherit', env: { ...process.env, ARCO_PACKAGED: '1' } });
|
|
102
103
|
if (r.error || r.status !== 0) throw new Error('Voice setup failed.'); return;
|
|
103
104
|
}
|
|
105
|
+
if (command === 'storage') {
|
|
106
|
+
if (args[0] !== 'unseal') throw new Error('Use arco storage unseal [--project <path>]...');
|
|
107
|
+
const projects = [];
|
|
108
|
+
for (let i = 1; i < args.length; i++) {
|
|
109
|
+
if (args[i] !== '--project' || !args[i + 1]) throw new Error('Use arco storage unseal [--project <path>]...');
|
|
110
|
+
projects.push(resolve(args[++i]));
|
|
111
|
+
}
|
|
112
|
+
const paths = servicePaths(process.platform);
|
|
113
|
+
const port = Number(readPortState(paths.home)?.port || process.env.ARCO_PORT || '3001');
|
|
114
|
+
if (Number.isInteger(port) && await isArcoHome(port, paths.home, fetch, process.env.ARCO_HOST).catch(() => false)) {
|
|
115
|
+
throw new Error('Arco is running. Stop it (arco service stop, or Ctrl+C) and run arco storage unseal again.');
|
|
116
|
+
}
|
|
117
|
+
await unsealProjects(projects.length ? projects : await knownProjects(paths.home));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
104
120
|
if (command === 'doctor') {
|
|
105
121
|
const supported = supportedNodeVersion();
|
|
106
122
|
console.log(`Node ${process.versions.node}: ${supported ? 'supported' : 'unsupported; install Node.js 24 or 26'}`);
|
|
@@ -16,6 +16,11 @@ function systemdQuote(value) {
|
|
|
16
16
|
if (/[\r\n\0]/.test(value)) throw new Error('A service path contains an unsupported character.');
|
|
17
17
|
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/%/g, '%%').replace(/\$/g, '$$')}"`;
|
|
18
18
|
}
|
|
19
|
+
function systemdDirectory(value) {
|
|
20
|
+
if (!isAbsolute(value)) throw new Error('The service working directory must be absolute.');
|
|
21
|
+
if (/[\s\x00-\x1f\x7f"']/.test(value)) throw new Error('The service working directory contains an unsupported character.');
|
|
22
|
+
return value.replace(/\\/g, '\\\\').replace(/%/g, '%%');
|
|
23
|
+
}
|
|
19
24
|
// On Windows the task starts node through Windows Script Host (wscript.exe is a
|
|
20
25
|
// GUI-subsystem program, so no console window is created) running a small
|
|
21
26
|
// JScript launcher that starts node hidden and waits for it. conhost.exe
|
|
@@ -25,12 +30,12 @@ export function windowsScriptHost(env = process.env) {
|
|
|
25
30
|
return `${(env.SystemRoot || env.SYSTEMROOT || 'C:\\Windows').replace(/[\\/]+$/, '')}\\System32\\wscript.exe`;
|
|
26
31
|
}
|
|
27
32
|
export const WINDOWS_LAUNCHER = "var a = WScript.Arguments, c = [], i;\r\nfor (i = 0; i < a.length; i++) c.push('\"' + a(i) + '\"');\r\nWScript.Quit(new ActiveXObject('WScript.Shell').Run(c.join(' '), 0, true));\r\n";
|
|
28
|
-
export const WINDOWS_END_TREE = String.raw`$ErrorActionPreference='Stop'; $m=$env:ARCO_SERVICE_MARK; if (-not $m) { exit 1 }; $configPattern='(?i)(?:^|\s|")' + [Regex]::Escape($m) + '(?:"|\s|$)'; $candidates=@(Get-CimInstance Win32_Process | Where-Object { $_.ProcessId -ne $PID -and ($_.Name -eq 'node.exe' -or $_.Name -eq 'wscript.exe') }); if (@($candidates | Where-Object { [String]::IsNullOrWhiteSpace([string]$_.CommandLine) }).Count -gt 0) { throw 'Cannot inspect process command lines.' }; $candidates | Where-Object { $_.CommandLine -match '(?i)(?:^|[\\/\s"])arco\.mjs"?\s+"?service-run"?(?:\s|$)' -and $_.CommandLine -match $configPattern } | ForEach-Object { $id=$_.ProcessId; & taskkill.exe /PID $id /T /F | Out-Null; if ($LASTEXITCODE -ne 0) { $alive=@([System.Diagnostics.Process]::GetProcesses() | Where-Object { $_.Id -eq $id }); if ($alive.Count -gt 0) { throw 'Could not stop the service process.' } } }; exit 0`;
|
|
33
|
+
export const WINDOWS_END_TREE = String.raw`$ErrorActionPreference='Stop'; $m=$env:ARCO_SERVICE_MARK; if (-not $m) { exit 1 }; $configPattern='(?i)(?:^|\s|")' + [Regex]::Escape($m) + '(?:"|\s|$)'; $candidates=@(Get-CimInstance Win32_Process | Where-Object { $_.ProcessId -ne $PID -and ($_.Name -eq 'node.exe' -or $_.Name -eq 'wscript.exe') }); if (@($candidates | Where-Object { [String]::IsNullOrWhiteSpace([string]$_.CommandLine) }).Count -gt 0) { throw 'Cannot inspect process command lines.' }; $candidates | Where-Object { $_.CommandLine -match '(?i)(?:^|[\\/\s"])arco\.mjs"?\s+"?service-run"?(?:\s|$)' -and $_.CommandLine -match $configPattern } | ForEach-Object { $id=$_.ProcessId; $ErrorActionPreference='Continue'; & taskkill.exe /PID $id /T /F 2>$null | Out-Null; $ErrorActionPreference='Stop'; if ($LASTEXITCODE -ne 0) { $alive=@([System.Diagnostics.Process]::GetProcesses() | Where-Object { $_.Id -eq $id }); if ($alive.Count -gt 0) { throw 'Could not stop the service process.' } } }; exit 0`;
|
|
29
34
|
export const windowsLauncherPath = (config) => join(dirname(config), 'launch.js');
|
|
30
35
|
export function renderService(platform, { node, entry, config, home, user, env = process.env }) {
|
|
31
36
|
const args = [node, entry, 'service-run', config];
|
|
32
37
|
if (args.some((arg) => /[\r\n\0]/.test(arg))) throw new Error('A service path contains an unsupported character.');
|
|
33
|
-
if (platform === 'linux') return `[Unit]\nDescription=Arco workbench\nAfter=network.target\n\n[Service]\nType=simple\nWorkingDirectory=${
|
|
38
|
+
if (platform === 'linux') return `[Unit]\nDescription=Arco workbench\nAfter=network.target\n\n[Service]\nType=simple\nWorkingDirectory=${systemdDirectory(home)}\nExecStart=${args.map(systemdQuote).join(' ')}\nRestart=on-failure\n\n[Install]\nWantedBy=default.target\n`;
|
|
34
39
|
if (platform === 'darwin') return `<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0"><dict><key>Label</key><string>${label}</string><key>ProgramArguments</key><array>${args.map((arg) => `<string>${xml(arg)}</string>`).join('')}</array><key>WorkingDirectory</key><string>${xml(home)}</string><key>RunAtLoad</key><true/><key>KeepAlive</key><false/><key>StandardOutPath</key><string>${xml(join(home, 'service.stdout.log'))}</string><key>StandardErrorPath</key><string>${xml(join(home, 'service.stderr.log'))}</string></dict></plist>\n`;
|
|
35
40
|
if (platform === 'win32') {
|
|
36
41
|
if (!user || /[\r\n\0]/.test(user)) throw new Error('Cannot determine the current Windows user.');
|
|
@@ -103,7 +108,9 @@ export async function serviceAction(action, deps = {}) {
|
|
|
103
108
|
// keep running and hold the port. Whatever the task state, also end every
|
|
104
109
|
// wscript.exe or node.exe whose command line names this home's service
|
|
105
110
|
// configuration (the launcher and service-run both do), with its tree.
|
|
106
|
-
const
|
|
111
|
+
const stopArgs = ['/End', '/TN', label];
|
|
112
|
+
const stopOptions = { stdio: 'pipe', encoding: 'utf8', timeout: 30000, env };
|
|
113
|
+
const stopped = await (deps.run ? run('schtasks.exe', stopArgs, stopOptions) : runWindowsProbe('schtasks.exe', stopArgs, stopOptions));
|
|
107
114
|
let ended = !stopped.error && stopped.status === 0;
|
|
108
115
|
if (!ended) {
|
|
109
116
|
const args = ['-NoProfile', '-NonInteractive', '-Command', "$ErrorActionPreference='Stop'; (Get-ScheduledTask -TaskName 'arco-workbench').State.ToString()"];
|
|
@@ -201,11 +208,11 @@ export async function serviceAction(action, deps = {}) {
|
|
|
201
208
|
// that succeeds, so a failure leaves the previous definition in place.
|
|
202
209
|
export async function refreshServiceDefinition(deps = {}) {
|
|
203
210
|
const platform = deps.platform ?? process.platform, env = deps.env ?? process.env;
|
|
204
|
-
if (platform !== 'win32') return 'Nothing to refresh on this platform.';
|
|
211
|
+
if (platform !== 'win32' && platform !== 'linux') return 'Nothing to refresh on this platform.';
|
|
205
212
|
const paths = deps.paths ?? servicePaths(platform, env);
|
|
206
213
|
if (!existsSync(paths.config)) return 'No packaged service is installed.';
|
|
207
214
|
const release = await lockfile.lock(paths.config, { retries: { retries: 50, minTimeout: 100, maxTimeout: 100 } });
|
|
208
|
-
try { return await refreshLocked(paths, env, deps); }
|
|
215
|
+
try { return await refreshLocked(paths, env, { ...deps, platform }); }
|
|
209
216
|
finally { await release(); }
|
|
210
217
|
}
|
|
211
218
|
|
|
@@ -222,6 +229,29 @@ async function refreshLocked(paths, env, deps) {
|
|
|
222
229
|
const stat = lstatSync(paths.unit);
|
|
223
230
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1024 * 1024) throw new Error('Unsafe service definition.');
|
|
224
231
|
if (createHash('sha256').update(readFileSync(paths.unit)).digest('hex') !== saved.unitHash) throw new Error('The service definition changed. Review it before continuing.');
|
|
232
|
+
if (deps.platform === 'linux') {
|
|
233
|
+
const previous = readFileSync(paths.unit);
|
|
234
|
+
const previousConfig = readFileSync(paths.config);
|
|
235
|
+
const bytes = Buffer.from(renderService('linux', { node: deps.node ?? process.execPath, entry: deps.entry ?? cli, config: paths.config, home: paths.home, env }));
|
|
236
|
+
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
237
|
+
if (hash === saved.unitHash) return 'The service definition is current.';
|
|
238
|
+
const staged = `${paths.unit}.new`;
|
|
239
|
+
let created = false, replaced = false;
|
|
240
|
+
try {
|
|
241
|
+
writeFileSync(staged, bytes, { mode: 0o600, flag: 'wx' }); created = true;
|
|
242
|
+
renameSync(staged, paths.unit); replaced = true;
|
|
243
|
+
writeFileSync(paths.config, JSON.stringify({ ...saved, unitHash: hash }, null, 2) + '\n', { mode: 0o600 });
|
|
244
|
+
const reloaded = run('systemctl', ['--user', 'daemon-reload']);
|
|
245
|
+
if (reloaded.error || reloaded.status !== 0) throw new Error('Could not reload the updated service definition.');
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (replaced) {
|
|
248
|
+
writeFileSync(paths.unit, previous, { mode: 0o600 });
|
|
249
|
+
writeFileSync(paths.config, previousConfig, { mode: 0o600 });
|
|
250
|
+
}
|
|
251
|
+
throw error;
|
|
252
|
+
} finally { if (created) rmSync(staged, { force: true }); }
|
|
253
|
+
return 'The service definition was updated; it takes effect the next time the service starts.';
|
|
254
|
+
}
|
|
225
255
|
const domain = env.USERDOMAIN, username = env.USERNAME;
|
|
226
256
|
const user = domain && username ? `${domain}\\${username}` : username;
|
|
227
257
|
const text = renderService('win32', { node: deps.node ?? process.execPath, entry: deps.entry ?? cli, config: paths.config, home: paths.home, user, env });
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// `arco storage unseal` (and `npm run storage:unseal` in a source checkout):
|
|
2
|
+
// write every sealed conversation log back to one plain events.jsonl before a
|
|
3
|
+
// downgrade to a release that reads only plain logs (docs/STORAGE_PLAN.md,
|
|
4
|
+
// P7.3). Lossless: the plain file is complete and checked before the sealed
|
|
5
|
+
// segments and the format marker are removed. Refuses while Arco is running.
|
|
6
|
+
import { promises as fs, readFileSync } from 'node:fs';
|
|
7
|
+
import { createReadStream } from 'node:fs';
|
|
8
|
+
import { createInterface } from 'node:readline';
|
|
9
|
+
import { createBrotliDecompress } from 'node:zlib';
|
|
10
|
+
import { randomUUID } from 'node:crypto';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
const SEGMENT_RE = /^events\.(\d{12})-(\d{12})\.jsonl\.br$/;
|
|
14
|
+
const SEQ_RE = /^\{"seq":(\d+)[,}]/;
|
|
15
|
+
const WFID_RE = /^[a-zA-Z0-9-]{1,64}$/;
|
|
16
|
+
|
|
17
|
+
function lineSeq(line) {
|
|
18
|
+
const m = SEQ_RE.exec(line);
|
|
19
|
+
if (m) return Number(m[1]);
|
|
20
|
+
try { const v = JSON.parse(line); return typeof v.seq === 'number' ? v.seq : null; } catch { return null; }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function* lines(stream) {
|
|
24
|
+
const rl = createInterface({ input: stream, crlfDelay: Infinity });
|
|
25
|
+
try { for await (const line of rl) if (line) yield line; } finally { rl.close(); }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function listSegments(dir) {
|
|
29
|
+
let names = [];
|
|
30
|
+
try { names = await fs.readdir(dir); } catch (error) { if (error.code === 'ENOENT') return []; throw error; }
|
|
31
|
+
return names.map((name) => { const m = SEGMENT_RE.exec(name); return m ? { name, file: join(dir, name), firstSeq: Number(m[1]), lastSeq: Number(m[2]) } : null; })
|
|
32
|
+
.filter(Boolean).sort((a, b) => a.firstSeq - b.firstSeq || a.lastSeq - b.lastSeq);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// One conversation folder. Returns null when nothing is sealed.
|
|
36
|
+
export async function unsealLog(dir) {
|
|
37
|
+
const segments = await listSegments(dir);
|
|
38
|
+
if (!segments.length) return null;
|
|
39
|
+
const parts = [];
|
|
40
|
+
let last = 0;
|
|
41
|
+
for (const seg of segments) {
|
|
42
|
+
const input = createReadStream(seg.file);
|
|
43
|
+
try {
|
|
44
|
+
for await (const line of lines(input.pipe(createBrotliDecompress()))) { parts.push(line); const s = lineSeq(line); if (s !== null) last = Math.max(last, s); }
|
|
45
|
+
} finally { input.destroy(); }
|
|
46
|
+
}
|
|
47
|
+
const live = join(dir, 'events.jsonl');
|
|
48
|
+
try {
|
|
49
|
+
const input = createReadStream(live);
|
|
50
|
+
try {
|
|
51
|
+
for await (const line of lines(input)) { const s = lineSeq(line); if (s !== null && s <= last) continue; parts.push(line); if (s !== null) last = Math.max(last, s); }
|
|
52
|
+
} finally { input.destroy(); }
|
|
53
|
+
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
54
|
+
const text = parts.join('\n') + '\n';
|
|
55
|
+
const tmp = join(dir, `events.jsonl.${randomUUID()}.tmp`);
|
|
56
|
+
const fh = await fs.open(tmp, 'wx', 0o600);
|
|
57
|
+
try { await fh.writeFile(text); await fh.sync(); } finally { await fh.close(); }
|
|
58
|
+
try { await renameWithRetry(tmp, live); }
|
|
59
|
+
catch (error) { await fs.rm(tmp, { force: true }).catch(() => {}); throw error; }
|
|
60
|
+
if (await fs.readFile(live, 'utf8') !== text) throw new Error(`The exported log in ${dir} did not read back correctly; its sealed segments were kept.`);
|
|
61
|
+
for (const seg of segments) await fs.rm(seg.file, { force: true });
|
|
62
|
+
await fs.rm(join(dir, 'log-format.json'), { force: true });
|
|
63
|
+
return { records: parts.length, segments: segments.length };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function readPaths(file) {
|
|
67
|
+
try {
|
|
68
|
+
const value = JSON.parse(readFileSync(file, 'utf8'));
|
|
69
|
+
if (Array.isArray(value)) return value.filter((x) => typeof x === 'string');
|
|
70
|
+
if (Array.isArray(value?.records)) return value.records.map((r) => r?.path).filter((p) => typeof p === 'string');
|
|
71
|
+
} catch { /* absent or unreadable */ }
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Project folders Arco knows about, plus chat and Genesis folders in its home.
|
|
76
|
+
export async function knownProjects(home) {
|
|
77
|
+
const out = new Set([...readPaths(join(home, 'projects.json')), ...readPaths(join(home, 'known-cwds.json'))]);
|
|
78
|
+
for (const sub of ['chats', 'genesis']) {
|
|
79
|
+
try { for (const d of await fs.readdir(join(home, sub), { withFileTypes: true })) if (d.isDirectory()) out.add(join(home, sub, d.name)); } catch { /* none */ }
|
|
80
|
+
}
|
|
81
|
+
return [...out];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Windows refuses a rename over a file another program holds open (a virus
|
|
85
|
+
// scanner, the indexer) for a short moment; retry briefly there.
|
|
86
|
+
async function renameWithRetry(from, to) {
|
|
87
|
+
const started = Date.now();
|
|
88
|
+
for (let delay = 5; ; delay = Math.min(delay * 2, 100)) {
|
|
89
|
+
try { await fs.rename(from, to); return; }
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (process.platform !== 'win32' || !['EPERM', 'EACCES', 'EBUSY'].includes(error.code) || Date.now() - started > 5000) throw error;
|
|
92
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function isLink(p) {
|
|
98
|
+
try { return (await fs.lstat(p)).isSymbolicLink(); } catch { return false; }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function unsealProjects(projects, log = console.log) {
|
|
102
|
+
let conversations = 0, records = 0, failed = 0;
|
|
103
|
+
for (const project of projects) {
|
|
104
|
+
const root = join(project, '.arco', 'workflows');
|
|
105
|
+
// Links are never followed: a linked .arco, .arco/workflows or
|
|
106
|
+
// conversation folder is skipped.
|
|
107
|
+
if (await isLink(join(project, '.arco')) || await isLink(root)) { log(`Skipped ${project}: its .arco or .arco/workflows folder is a link.`); continue; }
|
|
108
|
+
let names = [];
|
|
109
|
+
try { names = await fs.readdir(root); } catch { continue; }
|
|
110
|
+
for (const name of names) {
|
|
111
|
+
if (!WFID_RE.test(name)) continue;
|
|
112
|
+
if (await isLink(join(root, name))) { log(`Skipped conversation ${name}: its folder is a link.`); continue; }
|
|
113
|
+
let result;
|
|
114
|
+
// One conversation that cannot be written back (a file held open, a
|
|
115
|
+
// damaged segment) keeps its segments and does not stop the others.
|
|
116
|
+
try { result = await unsealLog(join(root, name)); }
|
|
117
|
+
catch (error) { failed++; log(`Kept the sealed log of conversation ${name}: ${error.message}`); continue; }
|
|
118
|
+
if (!result) continue;
|
|
119
|
+
conversations++; records += result.records;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
log(conversations ? `Wrote ${conversations} sealed conversation logs back to plain events.jsonl files (${records} records).` : 'No sealed conversation logs found.');
|
|
123
|
+
if (failed) throw new Error(`${failed} conversation logs could not be written back and were left sealed; close other programs using them and run arco storage unseal again.`);
|
|
124
|
+
return { conversations, records };
|
|
125
|
+
}
|
|
@@ -88,11 +88,11 @@ export async function updatePackage(manifest, root, deps = {}) {
|
|
|
88
88
|
const target = deps.target ?? `${manifest.name}@${version}`;
|
|
89
89
|
installed = true;
|
|
90
90
|
call(['install', '--global', '--ignore-scripts', '--no-audit', '--no-fund', '--prefix', prefix, target], { stdio: 'inherit' });
|
|
91
|
-
// The new package may define the service differently
|
|
92
|
-
//
|
|
91
|
+
// The new package may define the service differently. A fresh process loads
|
|
92
|
+
// the new code to
|
|
93
93
|
// rewrite an unmodified Arco-owned definition; a failure keeps the old one.
|
|
94
94
|
let refreshNote = '';
|
|
95
|
-
if (managed && platform === 'win32') {
|
|
95
|
+
if (managed && (platform === 'win32' || platform === 'linux')) {
|
|
96
96
|
const refresh = deps.refresh ?? (() => run(process.execPath, [join(root, 'scripts/packaging/arco.mjs'), 'service', 'refresh'], { windowsHide: true }));
|
|
97
97
|
try { const r = await refresh(); if (r?.error || (r?.status ?? 0) !== 0) refreshNote = ' The service definition was not refreshed; run arco service refresh.'; }
|
|
98
98
|
catch { refreshNote = ' The service definition was not refreshed; run arco service refresh.'; }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare function scanCopyLine(line: string): string[];
|
|
2
|
+
interface FileEntry {
|
|
3
|
+
rel: string;
|
|
4
|
+
bytes: number;
|
|
5
|
+
hash: string;
|
|
6
|
+
media: boolean;
|
|
7
|
+
unscanned: boolean;
|
|
8
|
+
findings: Array<{
|
|
9
|
+
line: number;
|
|
10
|
+
rule: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
interface CopyInspection {
|
|
14
|
+
source: string;
|
|
15
|
+
target: string;
|
|
16
|
+
bytes: number;
|
|
17
|
+
ignored: boolean;
|
|
18
|
+
publicRepository: boolean;
|
|
19
|
+
files: FileEntry[];
|
|
20
|
+
directories: string[];
|
|
21
|
+
token: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function inspectArtifactCopy(cwd: string, workflowId: string, itemPath: string, destinationFolder: string, declaredPublic: boolean): Promise<CopyInspection>;
|
|
24
|
+
export declare function copyReviewedArtifact(cwd: string, workflowId: string, itemPath: string, destinationFolder: string, declaredPublic: boolean, token: string, beforePublish?: (index: number) => Promise<void>, confirmUnscanned?: boolean): Promise<CopyInspection>;
|
|
25
|
+
export declare function ignoreCopyDestination(cwd: string, target: string): Promise<void>;
|
|
26
|
+
export {};
|