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
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants, createReadStream } from 'node:fs';
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { execFile } from 'node:child_process';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import { normalizeKeepPath } from './keepStore.js';
|
|
9
|
+
import { outputDirectory } from './outputStore.js';
|
|
10
|
+
import { assertSafePath, confinedPath, isPathWithin, safeDirectory } from './fileAccessPolicy.js';
|
|
11
|
+
import { projectGitEnv, suggestFromRemote } from './publicProject.js';
|
|
12
|
+
import { publicSafetyRules } from '@arco/shared';
|
|
13
|
+
const git = promisify(execFile);
|
|
14
|
+
async function gitCall(cwd, args) {
|
|
15
|
+
await git('git', args, { cwd, timeout: 10000, env: projectGitEnv() });
|
|
16
|
+
}
|
|
17
|
+
const MiB = 1024 * 1024;
|
|
18
|
+
const MB = 1000 * 1000;
|
|
19
|
+
const TEXT = /\.(?:txt|md|markdown|csv|json|ya?ml|xml|html?|svg|js|mjs|cjs|jsx|ts|tsx|py|rs|go|java|css|sh|sql|diff|patch|log|ini|toml|env)$/i;
|
|
20
|
+
const MEDIA = /\.(?:png|jpe?g|webp|gif|bmp|svg|mp3|wav|ogg|flac|m4a|mp4|webm|mov|mkv|avi)$/i;
|
|
21
|
+
const safeUsers = new Set(['operator', 'example', 'user', 'username', 'u', 'op', 'root', 'nobody', 'glob', 'real', 'test', 'runner', 'node']);
|
|
22
|
+
const patterns = [
|
|
23
|
+
...publicSafetyRules,
|
|
24
|
+
['password-or-secret', /\b(?:password|passwd|secret|token|api[_-]?key)\s*[=:]\s*["']?[^\s"']{1,}/i],
|
|
25
|
+
['ip-address', /\b(?:\d{1,3}\.){3}\d{1,3}\b|(?<![A-Za-z0-9])(?:[a-fA-F0-9]{0,4}:){2,}[a-fA-F0-9]{0,4}(?![A-Za-z0-9])/],
|
|
26
|
+
];
|
|
27
|
+
export function scanCopyLine(line) {
|
|
28
|
+
const rules = patterns.filter(([, re]) => re.test(line)).map(([name]) => name);
|
|
29
|
+
if (/[A-Za-z0-9_.+%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/.test(line))
|
|
30
|
+
rules.push('email-address');
|
|
31
|
+
const decoded = line.replace(/%([0-9a-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
32
|
+
for (const m of decoded.matchAll(/(?:(?<![A-Za-z0-9_/])\/(?:home|Users)\/|[A-Za-z]:[\\/]Users[\\/])([A-Za-z0-9_.-]+)(?=[\\/])/g))
|
|
33
|
+
if (!safeUsers.has(m[1]))
|
|
34
|
+
rules.push('personal-home-path');
|
|
35
|
+
return [...new Set(rules)];
|
|
36
|
+
}
|
|
37
|
+
async function scanFile(file, rel, maxFindings = 1000) {
|
|
38
|
+
const fh = await fs.open(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
39
|
+
try {
|
|
40
|
+
const info = await fh.stat();
|
|
41
|
+
if (!info.isFile())
|
|
42
|
+
throw new Error('Only regular files can be copied.');
|
|
43
|
+
const hash = createHash('sha256');
|
|
44
|
+
const findings = [];
|
|
45
|
+
const media = MEDIA.test(rel);
|
|
46
|
+
const scanText = !media || TEXT.test(rel);
|
|
47
|
+
let line = 1;
|
|
48
|
+
let pending = '';
|
|
49
|
+
let unscanned = !scanText;
|
|
50
|
+
const decoder = new TextDecoder('utf-8');
|
|
51
|
+
for await (const chunk of createReadStream('', { fd: fh.fd, autoClose: false, emitClose: false })) {
|
|
52
|
+
const buffer = chunk;
|
|
53
|
+
hash.update(buffer);
|
|
54
|
+
if (!scanText)
|
|
55
|
+
continue;
|
|
56
|
+
const textBuffer = buffer.includes(0) ? Buffer.from(buffer.filter(byte => byte !== 0)) : buffer;
|
|
57
|
+
const text = decoder.decode(textBuffer, { stream: true });
|
|
58
|
+
if (text.includes('\ufffd'))
|
|
59
|
+
unscanned = true;
|
|
60
|
+
pending += text;
|
|
61
|
+
for (;;) {
|
|
62
|
+
const i = pending.indexOf('\n');
|
|
63
|
+
if (i < 0)
|
|
64
|
+
break;
|
|
65
|
+
for (const rule of scanCopyLine(pending.slice(0, i))) {
|
|
66
|
+
if (findings.length >= maxFindings)
|
|
67
|
+
throw new Error('Too many findings to show; split the artifact.');
|
|
68
|
+
findings.push({ line, rule });
|
|
69
|
+
}
|
|
70
|
+
pending = pending.slice(i + 1);
|
|
71
|
+
line++;
|
|
72
|
+
}
|
|
73
|
+
if (pending.length > MiB)
|
|
74
|
+
throw new Error('A text line is too long to scan; split the artifact.');
|
|
75
|
+
}
|
|
76
|
+
if (scanText) {
|
|
77
|
+
const remainder = decoder.decode();
|
|
78
|
+
if (remainder.includes('\ufffd'))
|
|
79
|
+
unscanned = true;
|
|
80
|
+
pending += remainder;
|
|
81
|
+
for (const rule of scanCopyLine(pending)) {
|
|
82
|
+
if (findings.length >= maxFindings)
|
|
83
|
+
throw new Error('Too many findings to show; split the artifact.');
|
|
84
|
+
findings.push({ line, rule });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { rel, bytes: info.size, hash: hash.digest('hex'), media, unscanned, findings };
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await fh.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function gitIgnored(cwd, target) {
|
|
94
|
+
try {
|
|
95
|
+
await gitCall(cwd, ['ls-files', '--error-unmatch', '--', target]);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
const code = e.code;
|
|
100
|
+
if (code !== 1 && code !== 128)
|
|
101
|
+
throw new Error('Git tracking status is unavailable.');
|
|
102
|
+
if (code === 128)
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
await gitCall(cwd, ['check-ignore', '-q', '--no-index', '--', target]);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
const code = e.code;
|
|
111
|
+
if (code === 1)
|
|
112
|
+
return false;
|
|
113
|
+
if (code === 128) {
|
|
114
|
+
try {
|
|
115
|
+
await gitCall(cwd, ['rev-parse', '--is-inside-work-tree']);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
if (err.code === 128)
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
throw new Error('Git ignore status is unavailable.');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function ensureNoLinks(root, rel) {
|
|
126
|
+
let current = root;
|
|
127
|
+
const base = await fs.lstat(root);
|
|
128
|
+
if (base.isSymbolicLink())
|
|
129
|
+
throw new Error('Artifact links cannot be copied.');
|
|
130
|
+
for (const part of rel ? rel.split('/') : []) {
|
|
131
|
+
current = path.join(current, part);
|
|
132
|
+
if ((await fs.lstat(current)).isSymbolicLink())
|
|
133
|
+
throw new Error('Artifact links cannot be copied.');
|
|
134
|
+
}
|
|
135
|
+
if (await fs.realpath(current) !== current)
|
|
136
|
+
throw new Error('Artifact path changed; review it again.');
|
|
137
|
+
}
|
|
138
|
+
async function listSource(root) {
|
|
139
|
+
const out = [];
|
|
140
|
+
const directories = [];
|
|
141
|
+
async function walk(file, rel) {
|
|
142
|
+
const st = await fs.lstat(file);
|
|
143
|
+
if (st.isSymbolicLink())
|
|
144
|
+
throw new Error('Artifact links cannot be copied.');
|
|
145
|
+
if (st.isDirectory()) {
|
|
146
|
+
if (rel)
|
|
147
|
+
directories.push(rel);
|
|
148
|
+
if (directories.length > 10000)
|
|
149
|
+
throw new Error('Too many folders; copy a smaller folder.');
|
|
150
|
+
const names = [];
|
|
151
|
+
for await (const entry of await fs.opendir(file)) {
|
|
152
|
+
if (names.length >= 10000)
|
|
153
|
+
throw new Error('Too many entries; copy a smaller folder.');
|
|
154
|
+
names.push(entry.name);
|
|
155
|
+
}
|
|
156
|
+
for (const name of names.sort())
|
|
157
|
+
await walk(path.join(file, name), rel ? `${rel}/${name}` : name);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (!st.isFile())
|
|
161
|
+
throw new Error('Only regular files and folders can be copied.');
|
|
162
|
+
if (out.length >= 10000)
|
|
163
|
+
throw new Error('Too many files; copy a smaller folder.');
|
|
164
|
+
out.push({ path: file, rel });
|
|
165
|
+
}
|
|
166
|
+
await walk(root, '');
|
|
167
|
+
return { files: out, directories };
|
|
168
|
+
}
|
|
169
|
+
export async function inspectArtifactCopy(cwd, workflowId, itemPath, destinationFolder, declaredPublic) {
|
|
170
|
+
const rel = normalizeKeepPath(itemPath);
|
|
171
|
+
if (!rel || (rel !== 'artifacts' && !rel.startsWith('artifacts/')))
|
|
172
|
+
throw new Error('Choose an artifact file or folder.');
|
|
173
|
+
const dir = await fs.realpath(await outputDirectory(cwd, workflowId));
|
|
174
|
+
let source = dir;
|
|
175
|
+
for (const part of rel.split('/')) {
|
|
176
|
+
source = path.join(source, part);
|
|
177
|
+
const st = await fs.lstat(source);
|
|
178
|
+
if (st.isSymbolicLink())
|
|
179
|
+
throw new Error('Artifact links cannot be copied.');
|
|
180
|
+
}
|
|
181
|
+
source = await fs.realpath(source);
|
|
182
|
+
if (!isPathWithin(path.join(dir, 'artifacts'), source))
|
|
183
|
+
throw new Error('Artifact path changed; review it again.');
|
|
184
|
+
const project = await fs.realpath(safeDirectory(cwd));
|
|
185
|
+
const folder = await fs.realpath(confinedPath(destinationFolder, [cwd], 'directory'));
|
|
186
|
+
const target = path.join(folder, path.basename(source));
|
|
187
|
+
assertSafePath(target);
|
|
188
|
+
if (!isPathWithin(project, target) || target.split(path.sep).includes('.arco'))
|
|
189
|
+
throw new Error('Choose a project folder outside Arco state.');
|
|
190
|
+
try {
|
|
191
|
+
await fs.lstat(target);
|
|
192
|
+
throw new Error('The destination already exists.');
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
if (e.code !== 'ENOENT')
|
|
196
|
+
throw e;
|
|
197
|
+
}
|
|
198
|
+
const listed = await listSource(source);
|
|
199
|
+
const files = [];
|
|
200
|
+
let findingCount = 0;
|
|
201
|
+
let ignored = listed.files.length ? true : await gitIgnored(project, target);
|
|
202
|
+
for (const f of listed.files) {
|
|
203
|
+
const dest = f.rel ? path.join(target, ...f.rel.split('/')) : target;
|
|
204
|
+
assertSafePath(dest);
|
|
205
|
+
ignored = await gitIgnored(project, dest) && ignored;
|
|
206
|
+
await ensureNoLinks(source, f.rel);
|
|
207
|
+
const scanned = await scanFile(f.path, f.rel || path.basename(source));
|
|
208
|
+
findingCount += scanned.findings.length;
|
|
209
|
+
if (findingCount > 2000)
|
|
210
|
+
throw new Error('Too many findings to show; copy a smaller artifact.');
|
|
211
|
+
files.push(scanned);
|
|
212
|
+
await ensureNoLinks(source, f.rel);
|
|
213
|
+
}
|
|
214
|
+
const bytes = files.reduce((n, f) => n + f.bytes, 0);
|
|
215
|
+
const publicRepository = declaredPublic || (await suggestFromRemote(project)).state === 'public';
|
|
216
|
+
const directories = listed.directories;
|
|
217
|
+
for (const rel of directories)
|
|
218
|
+
assertSafePath(path.join(target, ...rel.split('/')));
|
|
219
|
+
const token = createHash('sha256').update(JSON.stringify({ source, target, ignored, publicRepository, files, directories })).digest('hex');
|
|
220
|
+
return { source, target, bytes, ignored, publicRepository, files, directories, token };
|
|
221
|
+
}
|
|
222
|
+
// Re-scan immediately before copying and require an unchanged review token.
|
|
223
|
+
// Each destination is exclusively created; source bytes are checked against
|
|
224
|
+
// the preflight hash before success is reported. Originals are never removed.
|
|
225
|
+
export async function copyReviewedArtifact(cwd, workflowId, itemPath, destinationFolder, declaredPublic, token, beforePublish, confirmUnscanned = false) {
|
|
226
|
+
const check = await inspectArtifactCopy(cwd, workflowId, itemPath, destinationFolder, declaredPublic);
|
|
227
|
+
if (!token || token !== check.token)
|
|
228
|
+
throw new Error('The artifact or destination changed. Review it again.');
|
|
229
|
+
if (!check.ignored && check.publicRepository && check.files.some((file) => file.unscanned) && !confirmUnscanned)
|
|
230
|
+
throw new Error('Confirm the files that were not scanned before copying into a public repository.');
|
|
231
|
+
if (!check.ignored && check.bytes > 100 * MB)
|
|
232
|
+
throw new Error('Over 100 MB cannot be copied into a folder included in Git. Choose an ignored folder.');
|
|
233
|
+
const sourceInfo = await fs.lstat(check.source);
|
|
234
|
+
const tempRoot = await fs.realpath(tmpdir());
|
|
235
|
+
if (isPathWithin(await fs.realpath(safeDirectory(cwd)), tempRoot))
|
|
236
|
+
throw new Error('The temporary folder must be outside the project.');
|
|
237
|
+
for (let ancestor = tempRoot;;) {
|
|
238
|
+
try {
|
|
239
|
+
await fs.lstat(path.join(ancestor, '.git'));
|
|
240
|
+
throw new Error('The temporary folder must be outside Git repositories.');
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
if (err.code !== 'ENOENT')
|
|
244
|
+
throw err;
|
|
245
|
+
}
|
|
246
|
+
const parent = path.dirname(ancestor);
|
|
247
|
+
if (parent === ancestor)
|
|
248
|
+
break;
|
|
249
|
+
ancestor = parent;
|
|
250
|
+
}
|
|
251
|
+
const temp = await fs.mkdtemp(path.join(tempRoot, 'arco-reviewed-copy-'));
|
|
252
|
+
let published = false;
|
|
253
|
+
try {
|
|
254
|
+
// Stage outside the project in a private temporary directory. Only the
|
|
255
|
+
// exact bytes reviewed above can be published, even if a worker edits the
|
|
256
|
+
// artifact while it is being read.
|
|
257
|
+
for (let i = 0; i < check.files.length; i++) {
|
|
258
|
+
const entry = check.files[i];
|
|
259
|
+
const rel = sourceInfo.isDirectory() ? entry.rel : '';
|
|
260
|
+
const inputPath = rel ? path.join(check.source, ...rel.split('/')) : check.source;
|
|
261
|
+
await ensureNoLinks(check.source, rel);
|
|
262
|
+
const input = await fs.open(inputPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
263
|
+
try {
|
|
264
|
+
const st = await input.stat();
|
|
265
|
+
if (!st.isFile() || st.size !== entry.bytes)
|
|
266
|
+
throw new Error('The artifact changed. Review it again.');
|
|
267
|
+
const output = await fs.open(path.join(temp, String(i)), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);
|
|
268
|
+
try {
|
|
269
|
+
const hash = createHash('sha256');
|
|
270
|
+
for await (const chunk of createReadStream('', { fd: input.fd, autoClose: false, emitClose: false })) {
|
|
271
|
+
hash.update(chunk);
|
|
272
|
+
await output.writeFile(chunk);
|
|
273
|
+
}
|
|
274
|
+
if (hash.digest('hex') !== entry.hash)
|
|
275
|
+
throw new Error('The artifact changed. Review it again.');
|
|
276
|
+
await ensureNoLinks(check.source, rel);
|
|
277
|
+
await output.sync();
|
|
278
|
+
}
|
|
279
|
+
finally {
|
|
280
|
+
await output.close();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
finally {
|
|
284
|
+
await input.close();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
let ignored = check.files.length ? true : await gitIgnored(cwd, check.target);
|
|
288
|
+
for (const entry of check.files) {
|
|
289
|
+
const dest = sourceInfo.isDirectory() ? path.join(check.target, ...entry.rel.split('/')) : check.target;
|
|
290
|
+
ignored = await gitIgnored(cwd, dest) && ignored;
|
|
291
|
+
}
|
|
292
|
+
if (ignored !== check.ignored)
|
|
293
|
+
throw new Error('Git ignore status changed. Review again.');
|
|
294
|
+
if (!ignored && check.bytes > 100 * MB)
|
|
295
|
+
throw new Error('Over 100 MB cannot be copied into a folder included in Git. Choose an ignored folder.');
|
|
296
|
+
const isPublic = declaredPublic || (await suggestFromRemote(cwd)).state === 'public';
|
|
297
|
+
if (isPublic !== check.publicRepository)
|
|
298
|
+
throw new Error('Repository visibility changed. Review again.');
|
|
299
|
+
if (await fs.realpath(path.dirname(check.target)) !== path.dirname(check.target))
|
|
300
|
+
throw new Error('Destination folder changed.');
|
|
301
|
+
if (sourceInfo.isDirectory()) {
|
|
302
|
+
await fs.mkdir(check.target);
|
|
303
|
+
published = true;
|
|
304
|
+
}
|
|
305
|
+
for (const rel of check.directories)
|
|
306
|
+
await fs.mkdir(path.join(check.target, ...rel.split('/')));
|
|
307
|
+
for (let i = 0; i < check.files.length; i++) {
|
|
308
|
+
const entry = check.files[i];
|
|
309
|
+
const outputPath = sourceInfo.isDirectory() ? path.join(check.target, ...entry.rel.split('/')) : check.target;
|
|
310
|
+
await beforePublish?.(i);
|
|
311
|
+
if (await fs.realpath(path.dirname(outputPath)) !== path.dirname(outputPath))
|
|
312
|
+
throw new Error('Destination folder changed.');
|
|
313
|
+
const output = await fs.open(outputPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
314
|
+
published = true;
|
|
315
|
+
try {
|
|
316
|
+
const opened = await output.stat();
|
|
317
|
+
const target = await fs.lstat(outputPath);
|
|
318
|
+
if (!opened.isFile() || target.isSymbolicLink() || opened.dev !== target.dev || opened.ino !== target.ino || await fs.realpath(outputPath) !== outputPath)
|
|
319
|
+
throw new Error('Destination folder changed.');
|
|
320
|
+
const input = await fs.open(path.join(temp, String(i)), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
321
|
+
try {
|
|
322
|
+
for await (const chunk of createReadStream('', { fd: input.fd, autoClose: false, emitClose: false }))
|
|
323
|
+
await output.writeFile(chunk);
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
await input.close();
|
|
327
|
+
}
|
|
328
|
+
await output.sync();
|
|
329
|
+
}
|
|
330
|
+
finally {
|
|
331
|
+
await output.close();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return check;
|
|
335
|
+
}
|
|
336
|
+
catch (err) {
|
|
337
|
+
const detail = err instanceof Error ? err.message : 'Copy failed.';
|
|
338
|
+
throw new Error(published ? `${detail} Some copied files may remain; the original stays in Arco.` : detail);
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
await fs.rm(temp, { recursive: true, force: true });
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// Append one literal root-relative rule. Never replace an edited ignore file.
|
|
345
|
+
export async function ignoreCopyDestination(cwd, target) {
|
|
346
|
+
const project = await fs.realpath(safeDirectory(cwd));
|
|
347
|
+
if (!isPathWithin(project, target) || target === project)
|
|
348
|
+
throw new Error('Choose a destination inside this project.');
|
|
349
|
+
try {
|
|
350
|
+
await gitCall(project, ['rev-parse', '--is-inside-work-tree']);
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
throw new Error('This project is not a Git repository.');
|
|
354
|
+
}
|
|
355
|
+
const rel = path.relative(project, target).split(path.sep).join('/');
|
|
356
|
+
if (/[\r\n\0]/.test(rel))
|
|
357
|
+
throw new Error('This filename cannot be written to .gitignore.');
|
|
358
|
+
const rule = '/' + rel.replace(/([\\*?\[\] ])/g, '\\$1');
|
|
359
|
+
const ignore = path.join(project, '.gitignore');
|
|
360
|
+
const flags = constants.O_WRONLY | constants.O_APPEND | constants.O_NOFOLLOW;
|
|
361
|
+
let handle;
|
|
362
|
+
try {
|
|
363
|
+
handle = await fs.open(ignore, flags);
|
|
364
|
+
}
|
|
365
|
+
catch (e) {
|
|
366
|
+
if (e.code !== 'ENOENT')
|
|
367
|
+
throw e;
|
|
368
|
+
handle = await fs.open(ignore, flags | constants.O_CREAT | constants.O_EXCL, 0o600);
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
const opened = await handle.stat();
|
|
372
|
+
const current = await fs.lstat(ignore);
|
|
373
|
+
if (!opened.isFile() || current.isSymbolicLink() || opened.dev !== current.dev || opened.ino !== current.ino || opened.size > MiB)
|
|
374
|
+
throw new Error('The project ignore file cannot be edited.');
|
|
375
|
+
let prefix = '';
|
|
376
|
+
if (opened.size) {
|
|
377
|
+
const reader = await fs.open(ignore, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
378
|
+
try {
|
|
379
|
+
const last = Buffer.alloc(1);
|
|
380
|
+
await reader.read(last, 0, 1, opened.size - 1);
|
|
381
|
+
if (last[0] !== 10)
|
|
382
|
+
prefix = '\n';
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
await reader.close();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const content = Buffer.from(`${prefix}${rule}\n`);
|
|
389
|
+
const result = await handle.write(content);
|
|
390
|
+
if (result.bytesWritten !== content.length)
|
|
391
|
+
throw new Error('The ignore rule was only partially written. Review .gitignore.');
|
|
392
|
+
await handle.sync();
|
|
393
|
+
}
|
|
394
|
+
finally {
|
|
395
|
+
await handle.close();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
//# sourceMappingURL=artifactCopy.js.map
|
|
@@ -35,7 +35,7 @@ const RENAME_RETRY_CODES = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
|
35
35
|
const RENAME_RETRY_LIMIT_MS = 5_000;
|
|
36
36
|
const isWindows = process.platform === 'win32';
|
|
37
37
|
const retryable = (e) => isWindows && RENAME_RETRY_CODES.has(e?.code ?? '');
|
|
38
|
-
async function renameWithRetry(from, to) {
|
|
38
|
+
export async function renameWithRetry(from, to) {
|
|
39
39
|
const started = Date.now();
|
|
40
40
|
for (let delay = 5;; delay = Math.min(delay * 2, 100)) {
|
|
41
41
|
try {
|
|
@@ -28,7 +28,7 @@ interface WorkflowInfo {
|
|
|
28
28
|
name: string;
|
|
29
29
|
incognito: boolean;
|
|
30
30
|
}
|
|
31
|
-
export declare function raise(kind: AttentionKind, workflowId: string, info: WorkflowInfo, text?: string): void;
|
|
31
|
+
export declare function raise(kind: AttentionKind, workflowId: string, info: WorkflowInfo, text?: string, longEnough?: boolean): void;
|
|
32
32
|
/** Feed every workflow-scoped server message through here. Cheap for messages it ignores. */
|
|
33
33
|
export declare function observeAttention(workflowId: string, message: ServerMessage, info: WorkflowInfo): void;
|
|
34
34
|
export {};
|
package/server/dist/attention.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Attention alerts: a turn finished, failed, or is waiting on the operator.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// Desktop and phone alerts are opt-in; quiet in-app notices are on by default.
|
|
4
4
|
// The server watches workflow messages, applies the preferences, sends the
|
|
5
5
|
// phone message through ntfy itself (no hub and no client needed) and tells
|
|
6
6
|
// connected browsers with an `attention_event` so each can decide whether to
|
|
@@ -13,7 +13,7 @@ import { arcoHome } from './arcoHome.js';
|
|
|
13
13
|
import { broadcastToClients } from './notifications.js';
|
|
14
14
|
import * as clusterStore from './clusterStore.js';
|
|
15
15
|
import { isClusterDirector } from '@arco/shared';
|
|
16
|
-
//
|
|
16
|
+
// Desktop and phone finished alerts require a longer turn.
|
|
17
17
|
export const MIN_FINISHED_TURN_MS = 15_000;
|
|
18
18
|
const TEXT_MAX = 200;
|
|
19
19
|
let channelsPath = join(arcoHome(), 'notification-channels.json');
|
|
@@ -114,15 +114,12 @@ function shouldRaise(kind, workflowId) {
|
|
|
114
114
|
return true;
|
|
115
115
|
return isClusterDirector(clusterStore.getMemberRole(clusterId, workflowId));
|
|
116
116
|
}
|
|
117
|
-
export function raise(kind, workflowId, info, text) {
|
|
117
|
+
export function raise(kind, workflowId, info, text, longEnough = true) {
|
|
118
118
|
if (info.incognito)
|
|
119
119
|
return;
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
return;
|
|
124
|
-
if (!shouldRaise(kind, workflowId))
|
|
125
|
-
return;
|
|
120
|
+
const externalEligible = longEnough && shouldRaise(kind, workflowId);
|
|
121
|
+
const wantDesktop = channels.desktop[kind] && externalEligible;
|
|
122
|
+
const target = channels.phone[kind] && externalEligible ? resolvePhoneTarget() : null;
|
|
126
123
|
// One alert per workflow and kind per few seconds, whatever produced it.
|
|
127
124
|
const key = `${workflowId}:${kind}`;
|
|
128
125
|
const now = Date.now();
|
|
@@ -130,8 +127,8 @@ export function raise(kind, workflowId, info, text) {
|
|
|
130
127
|
return;
|
|
131
128
|
lastAlertAt.set(key, now);
|
|
132
129
|
const name = ascii(info.name || workflowId.slice(0, 8), 60);
|
|
133
|
-
|
|
134
|
-
broadcastToClients({ type: 'attention_event', id: `at_${now.toString(36)}_${(idCounter++).toString(36)}`, kind, workflowId, workflowName: name });
|
|
130
|
+
{
|
|
131
|
+
broadcastToClients({ type: 'attention_event', id: `at_${now.toString(36)}_${(idCounter++).toString(36)}`, kind, workflowId, workflowName: name, desktopEligible: wantDesktop });
|
|
135
132
|
}
|
|
136
133
|
if (target) {
|
|
137
134
|
const body = channels.phoneText && text ? ascii(text, TEXT_MAX) : `Open Arco to see it.`;
|
|
@@ -157,8 +154,8 @@ export function observeAttention(workflowId, message, info) {
|
|
|
157
154
|
turnStarts.delete(workflowId);
|
|
158
155
|
const text = lastText.get(workflowId);
|
|
159
156
|
lastText.delete(workflowId);
|
|
160
|
-
if (start !== undefined
|
|
161
|
-
raise('finished', workflowId, info, text ? text.slice(0, TEXT_MAX) : undefined);
|
|
157
|
+
if (start !== undefined)
|
|
158
|
+
raise('finished', workflowId, info, text ? text.slice(0, TEXT_MAX) : undefined, Date.now() - start >= MIN_FINISHED_TURN_MS);
|
|
162
159
|
break;
|
|
163
160
|
}
|
|
164
161
|
case 'operator_question':
|
package/server/dist/catchUp.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface CatchUpEvent {
|
|
|
9
9
|
task?: {
|
|
10
10
|
title?: unknown;
|
|
11
11
|
status?: unknown;
|
|
12
|
+
release?: unknown;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
export interface CatchUpSource {
|
|
@@ -18,6 +19,7 @@ export interface CatchUpSource {
|
|
|
18
19
|
truncated?: boolean;
|
|
19
20
|
unavailable?: boolean;
|
|
20
21
|
}
|
|
22
|
+
export declare function boardMovement(sources: CatchUpSource[], from: number, to: number): string | null;
|
|
21
23
|
/** When no visit marker exists: empty tab, or from = tab start / last 24 hours. */
|
|
22
24
|
export declare function resolveCatchUpWindow(sources: CatchUpSource[], end: number): {
|
|
23
25
|
empty: true;
|
package/server/dist/catchUp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { lstat,
|
|
2
|
-
import { join, relative, isAbsolute, sep } from 'node:path';
|
|
1
|
+
import { lstat, realpath } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, relative, isAbsolute, sep } from 'node:path';
|
|
3
3
|
import { flushWorkflowBuffer } from './workflowStore.js';
|
|
4
|
+
import { readLogTail } from './eventLog.js';
|
|
4
5
|
const MAX_TAIL_BYTES = 1024 * 1024;
|
|
5
6
|
const MAX_FACTS = 32;
|
|
6
7
|
const TEXT_LIMIT = 350;
|
|
@@ -17,11 +18,35 @@ function catchUpValue(e) {
|
|
|
17
18
|
if (e.type === 'task_ledger_event') {
|
|
18
19
|
return {
|
|
19
20
|
kind: 'Board',
|
|
20
|
-
value: `${String(e.op ?? 'changed')}: ${typeof e.task?.title === 'string' ? e.task.title : 'task'}${typeof e.task?.status === 'string' ? ` (${e.task.status})` : ''}`,
|
|
21
|
+
value: `${String(e.op ?? 'changed')}: ${typeof e.task?.title === 'string' ? e.task.title : 'task'}${typeof e.task?.status === 'string' ? ` (${e.task.status})` : ''}${typeof e.task?.release === 'string' && e.task.release ? ` [release ${e.task.release.slice(0, 24)}]` : ''}`,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
26
|
+
// Counts the board changes inside (from, to] by the status they left a task in
|
|
27
|
+
// and, if labeled, by release. Deterministic; null when the board did not move.
|
|
28
|
+
export function boardMovement(sources, from, to) {
|
|
29
|
+
const byStatus = new Map();
|
|
30
|
+
const byRelease = new Map();
|
|
31
|
+
let changes = 0;
|
|
32
|
+
for (const source of sources) {
|
|
33
|
+
for (const e of source.events) {
|
|
34
|
+
if (e.type !== 'task_ledger_event' || typeof e.ts !== 'number' || e.ts <= from || e.ts > to)
|
|
35
|
+
continue;
|
|
36
|
+
changes++;
|
|
37
|
+
const status = typeof e.task?.status === 'string' ? e.task.status : 'changed';
|
|
38
|
+
byStatus.set(status, (byStatus.get(status) ?? 0) + 1);
|
|
39
|
+
if (typeof e.task?.release === 'string' && e.task.release)
|
|
40
|
+
byRelease.set(e.task.release.slice(0, 24), (byRelease.get(e.task.release.slice(0, 24)) ?? 0) + 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (changes === 0)
|
|
44
|
+
return null;
|
|
45
|
+
const parts = [`${changes} board change${changes === 1 ? '' : 's'}`, [...byStatus].map(([s, n]) => `${n} ${s}`).join(', ')];
|
|
46
|
+
if (byRelease.size)
|
|
47
|
+
parts.push(`by release: ${[...byRelease].map(([r, n]) => `${r} ${n}`).join(', ')}`);
|
|
48
|
+
return parts.join('; ');
|
|
49
|
+
}
|
|
25
50
|
/** When no visit marker exists: empty tab, or from = tab start / last 24 hours. */
|
|
26
51
|
export function resolveCatchUpWindow(sources, end) {
|
|
27
52
|
let earliest = null;
|
|
@@ -74,6 +99,11 @@ export function collectCatchUpFacts(sources, from, to) {
|
|
|
74
99
|
truncated = true;
|
|
75
100
|
return { label: `${new Date(row.ts).toISOString()} ${row.label} ${row.kind}`, value: row.value.slice(0, TEXT_LIMIT) };
|
|
76
101
|
});
|
|
102
|
+
// One line on how the board moved in the range: changes by resulting status,
|
|
103
|
+
// and by release label when any task carries one.
|
|
104
|
+
const movement = boardMovement(sources, from, to);
|
|
105
|
+
if (movement)
|
|
106
|
+
facts.push({ label: 'Board movement in this range', value: movement });
|
|
77
107
|
// A member that is not loaded or is incognito is skipped, and said so.
|
|
78
108
|
for (const source of sources)
|
|
79
109
|
if (source.unavailable)
|
|
@@ -84,7 +114,6 @@ export async function readCatchUpEvents(cwd, id) {
|
|
|
84
114
|
if (!/^[a-zA-Z0-9-]{1,64}$/.test(id))
|
|
85
115
|
throw new Error('Invalid workflow.');
|
|
86
116
|
await flushWorkflowBuffer(cwd, id);
|
|
87
|
-
let file;
|
|
88
117
|
const eventPath = join(cwd, '.arco', 'workflows', id, 'events.jsonl');
|
|
89
118
|
try {
|
|
90
119
|
const stat = await lstat(eventPath);
|
|
@@ -94,32 +123,26 @@ export async function readCatchUpEvents(cwd, id) {
|
|
|
94
123
|
const rel = relative(root, resolved);
|
|
95
124
|
if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel))
|
|
96
125
|
throw new Error('Workflow activity escapes the project.');
|
|
97
|
-
file = await open(eventPath, 'r');
|
|
98
126
|
}
|
|
99
127
|
catch (error) {
|
|
100
128
|
if (error.code === 'ENOENT')
|
|
101
129
|
return { events: [], truncated: false };
|
|
102
130
|
throw error;
|
|
103
131
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
events.push(value);
|
|
116
|
-
}
|
|
117
|
-
catch { /* partial or invalid record */ }
|
|
132
|
+
// The live tail, plus the newest sealed segments when it is short (P7.3).
|
|
133
|
+
const tail = await readLogTail(dirname(eventPath), MAX_TAIL_BYTES);
|
|
134
|
+
const lines = tail.text.split('\n');
|
|
135
|
+
if (tail.truncated)
|
|
136
|
+
lines.shift();
|
|
137
|
+
const events = [];
|
|
138
|
+
for (const line of lines) {
|
|
139
|
+
try {
|
|
140
|
+
const value = JSON.parse(line);
|
|
141
|
+
if (value && typeof value === 'object')
|
|
142
|
+
events.push(value);
|
|
118
143
|
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
await file.close();
|
|
144
|
+
catch { /* partial or invalid record */ }
|
|
123
145
|
}
|
|
146
|
+
return { events, truncated: tail.truncated };
|
|
124
147
|
}
|
|
125
148
|
//# sourceMappingURL=catchUp.js.map
|
|
@@ -156,6 +156,7 @@ export declare function peerTaskCreate(ctx: PeerOpsContext, args: {
|
|
|
156
156
|
reviewRequired?: boolean;
|
|
157
157
|
goalMode?: boolean;
|
|
158
158
|
goalMaxTurns?: number;
|
|
159
|
+
release?: string;
|
|
159
160
|
status?: LedgerTaskStatus;
|
|
160
161
|
}, broadcastCluster: (msg: ServerMessage) => void): Promise<PeerTaskCreateOk | PeerTaskRejection>;
|
|
161
162
|
export declare function peerTaskClaim(ctx: PeerOpsContext, args: {
|
|
@@ -173,6 +174,7 @@ export declare function peerTaskUpdate(ctx: PeerOpsContext, args: {
|
|
|
173
174
|
id: string;
|
|
174
175
|
status?: LedgerTaskStatus;
|
|
175
176
|
notes?: string;
|
|
177
|
+
release?: string;
|
|
176
178
|
signoff?: {
|
|
177
179
|
state?: string;
|
|
178
180
|
summary?: string;
|
|
@@ -688,6 +688,7 @@ export async function peerTaskCreate(ctx, args, broadcastCluster) {
|
|
|
688
688
|
reviewRequired: args.reviewRequired,
|
|
689
689
|
goalMode: args.goalMode,
|
|
690
690
|
goalMaxTurns: args.goalMaxTurns,
|
|
691
|
+
release: args.release,
|
|
691
692
|
createdBy: ctx.workflowId,
|
|
692
693
|
});
|
|
693
694
|
if (assignee) {
|
|
@@ -823,6 +824,7 @@ export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
|
823
824
|
const applied = taskLedger.applyUpdate(tasks, args.id, {
|
|
824
825
|
...(args.status ? { status: args.status } : {}),
|
|
825
826
|
...(typeof args.notes === 'string' ? { notes: args.notes } : {}),
|
|
827
|
+
...(typeof args.release === 'string' ? { release: args.release } : {}),
|
|
826
828
|
...(signoffPatch !== undefined ? { signoff: signoffPatch } : {}),
|
|
827
829
|
});
|
|
828
830
|
if (!applied) {
|