arco-workbench 0.2.4 → 0.2.6
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/THIRD_PARTY_NOTICES +2 -2
- package/client/dist/assets/{PhosphorBackdrop-CHXVFLGT.js → PhosphorBackdrop-YsHTmZJh.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-Bhs4I9jA.js → ThemedBackgroundShaderImpl-BEjpgoBW.js} +1 -1
- package/client/dist/assets/{XtermView-CdfurwFx.js → XtermView-wh7jNKvk.js} +1 -1
- package/client/dist/assets/{galleryEditor-DYjZZ4cf.js → galleryEditor-CaOS2mmM.js} +1 -1
- package/client/dist/assets/{index-BjDmFvqG.js → index-j68SfA-l.js} +271 -271
- package/client/dist/index.html +1 -1
- package/client/src/App.tsx +2 -2
- package/client/src/components/AuthReloginNotice.tsx +7 -6
- package/client/src/components/ChatMessage.tsx +41 -29
- package/client/src/components/ChatPanel.tsx +17 -4
- package/client/src/components/ClaudeNativeAccountPicker.tsx +32 -0
- package/client/src/components/ClaudeNativeAuthRow.tsx +71 -19
- package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +11 -281
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +1 -1
- package/client/src/components/ClusterRightPanel/FreshMemberForm.tsx +315 -0
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +17 -7
- package/client/src/components/ClusterRightPanel/index.tsx +1 -1
- package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +6 -4
- package/client/src/components/ClusterTab.tsx +2 -2
- package/client/src/components/Connections/Connections.tsx +5 -9
- package/client/src/components/Connections/model.ts +3 -1
- package/client/src/components/FileViewerModal.tsx +54 -17
- package/client/src/components/GitHubPanel/index.tsx +9 -5
- package/client/src/components/HandoffDialog.tsx +5 -3
- package/client/src/components/MobileShell.tsx +1 -33
- package/client/src/components/OperatorQuestionNotice.tsx +5 -4
- package/client/src/components/ProvidersPopover.tsx +6 -2
- package/client/src/components/RightPanel/ActivityTab.tsx +2 -1
- package/client/src/components/RightPanel/ConfigTab.tsx +23 -5
- package/client/src/components/RightPanel/OutputsPanel.tsx +21 -9
- package/client/src/components/RightPanel/outputsReconcile.ts +31 -0
- package/client/src/components/SettingsPanel.tsx +7 -10
- package/client/src/components/SpawnDialog.tsx +14 -3
- package/client/src/components/TabBar.tsx +2 -2
- package/client/src/components/TabContextMenu.tsx +73 -133
- package/client/src/components/TerminalInput.tsx +4 -3
- package/client/src/components/TranscriptWorkerDialog.tsx +14 -4
- package/client/src/components/UpdateAction.tsx +30 -7
- package/client/src/components/UsageBar.tsx +37 -18
- package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +29 -3
- package/client/src/components/WorkflowCreator/index.tsx +29 -15
- package/client/src/components/WorkflowView.tsx +1 -1
- package/client/src/components/providerIndicator.ts +7 -3
- package/client/src/components/settings/GitHubAuthRow.tsx +34 -0
- package/client/src/explorer/ArtifactsLens.tsx +17 -8
- package/client/src/explorer/ExplorerApp.tsx +3 -3
- package/client/src/explorer/types.ts +3 -1
- package/client/src/help/content/cluster.tsx +10 -4
- package/client/src/help/content/composer.tsx +3 -2
- package/client/src/help/content/header.tsx +11 -4
- package/client/src/help/content/misc.tsx +7 -5
- package/client/src/help/content/rightPanel.tsx +8 -4
- package/client/src/help/content/settings.tsx +15 -4
- package/client/src/help/content/tabbar.tsx +1 -1
- package/client/src/help/manualSections/actions.tsx +5 -1
- package/client/src/help/manualSections/clusters.tsx +20 -14
- package/client/src/help/manualSections/configuration.tsx +6 -4
- package/client/src/help/manualSections/gettingStarted.tsx +4 -2
- package/client/src/help/manualSections/maintenance.tsx +31 -0
- package/client/src/help/manualSections/powerFeatures.tsx +1 -0
- package/client/src/help/manualSections/providers.tsx +11 -4
- package/client/src/help/manualSections/workspace.tsx +3 -3
- package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
- package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
- package/client/src/hooks/useWebSocket.ts +4 -2
- package/client/src/layout/layoutRange.ts +4 -5
- package/client/src/questions/waitingQuestion.ts +2 -0
- package/client/src/stores/appStore.ts +5 -1
- package/client/src/stores/appStore.types.ts +2 -0
- package/client/src/stores/replayContext.ts +20 -0
- package/client/src/utils/chatFileLinks.ts +34 -3
- package/client/src/utils/claudeAuth.ts +9 -1
- package/client/src/ws/handleServerMessage.ts +11 -3
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/BACKUP.md +1 -1
- package/docs/CLIENT.md +10 -5
- package/docs/EXTENDING.md +1 -1
- package/docs/FEATURES.md +3 -3
- package/docs/GETTING_STARTED.md +5 -4
- package/docs/GIT_WORKBENCH.md +8 -0
- package/docs/GLOSSARY.md +2 -2
- package/docs/GOTCHAS.md +4 -4
- package/docs/HTTP_API.md +54 -23
- package/docs/OPERATIONS.md +17 -1
- package/docs/OPERATOR_ACTIONS.md +2 -2
- package/docs/OUTPUTS.md +48 -6
- package/docs/PERSISTENCE.md +1 -1
- package/docs/PRIMITIVES.md +4 -2
- package/docs/PROTOCOL_CLUSTER.md +12 -6
- package/docs/PROTOCOL_PRIMITIVES.md +1 -1
- package/docs/PROVIDERS.md +46 -9
- package/docs/RESEARCH.md +1 -1
- package/docs/SETTINGS.md +9 -4
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
- package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
- package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
- package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/services.mjs +20 -1
- package/scripts/packaging/update.mjs +37 -2
- package/server/dist/attention.d.ts +6 -0
- package/server/dist/attention.js +6 -0
- package/server/dist/auth.d.ts +5 -0
- package/server/dist/auth.js +31 -20
- package/server/dist/clusterAutoTurn.d.ts +5 -1
- package/server/dist/clusterAutoTurn.js +31 -9
- package/server/dist/clusterPresets.js +3 -3
- package/server/dist/effortValidation.d.ts +2 -2
- package/server/dist/effortValidation.js +4 -4
- package/server/dist/explorerArtifacts.d.ts +1 -0
- package/server/dist/explorerArtifacts.js +12 -1
- package/server/dist/geminiMembers.d.ts +7 -1
- package/server/dist/geminiMembers.js +28 -14
- package/server/dist/http/conversationFiles.d.ts +36 -0
- package/server/dist/http/conversationFiles.js +222 -0
- package/server/dist/http/fileBytes.d.ts +3 -0
- package/server/dist/http/fileBytes.js +33 -0
- package/server/dist/http/fileContentRoute.d.ts +2 -0
- package/server/dist/http/fileContentRoute.js +139 -0
- package/server/dist/http/fileRead.d.ts +54 -2
- package/server/dist/http/fileRead.js +31 -24
- package/server/dist/http/outputRoutes.js +14 -21
- package/server/dist/http/readConfinement.d.ts +0 -11
- package/server/dist/http/readConfinement.js +4 -30
- package/server/dist/http/router.js +40 -66
- package/server/dist/index.js +26 -12
- package/server/dist/management/initHubLink.js +1 -1
- package/server/dist/outputs.js +8 -0
- package/server/dist/primitives/exportContext.d.ts +2 -0
- package/server/dist/primitives/exportContext.js +13 -2
- package/server/dist/primitives/runCompare.d.ts +7 -1
- package/server/dist/primitives/runCompare.js +44 -20
- package/server/dist/project/taskLedger.js +46 -34
- package/server/dist/providerAccounts.d.ts +4 -0
- package/server/dist/providerAccounts.js +20 -1
- package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
- package/server/dist/providers/antigravity/artifacts.js +140 -0
- package/server/dist/providers/antigravity/index.js +85 -7
- package/server/dist/providers/antigravity/questions.d.ts +2 -0
- package/server/dist/providers/antigravity/questions.js +58 -0
- package/server/dist/providers/claude-native/auth.d.ts +9 -8
- package/server/dist/providers/claude-native/auth.js +50 -58
- package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
- package/server/dist/providers/claude-native/authStatus.js +9 -7
- package/server/dist/providers/claude-native/catalog.d.ts +6 -5
- package/server/dist/providers/claude-native/catalog.js +50 -39
- package/server/dist/providers/claude-native/oauth.d.ts +10 -9
- package/server/dist/providers/claude-native/oauth.js +120 -96
- package/server/dist/providers/claude-native/worker.d.ts +1 -0
- package/server/dist/providers/claude-native/worker.js +38 -23
- package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
- package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
- package/server/dist/server/broadcast.js +6 -0
- package/server/dist/settings.d.ts +1 -0
- package/server/dist/settings.js +39 -7
- package/server/dist/skills.js +1 -1
- package/server/dist/smartPickupAdapters.d.ts +1 -0
- package/server/dist/smartPickupAdapters.js +2 -2
- package/server/dist/smartPickupObserver.js +8 -5
- package/server/dist/thirdPartySkills.js +11 -5
- package/server/dist/usage.d.ts +1 -1
- package/server/dist/usage.js +39 -27
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/processKill.js +37 -24
- package/server/dist/workflowMeta.js +2 -2
- package/server/dist/ws/clusterHandlers.d.ts +2 -2
- package/server/dist/ws/clusterHandlers.js +127 -113
- package/server/dist/ws/clusterMembers.d.ts +1 -1
- package/server/dist/ws/clusterMembers.js +34 -4
- package/server/dist/ws/compactHandlers.js +30 -14
- package/server/dist/ws/compareHandlers.js +53 -21
- package/server/dist/ws/gateHandlers.js +2 -0
- package/server/dist/ws/genesisHandlers.js +5 -3
- package/server/dist/ws/handoffHandlers.d.ts +1 -1
- package/server/dist/ws/handoffHandlers.js +115 -39
- package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
- package/server/dist/ws/turnEngine.js +33 -18
- package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
- package/server/dist/ws/updatePrimaryConfig.js +236 -133
- package/server/dist/ws/workflowHandlers.js +21 -4
- package/server/package.json +1 -1
- package/server/src/attention.ts +7 -0
- package/server/src/auth.ts +33 -20
- package/server/src/clusterAutoTurn.ts +31 -11
- package/server/src/clusterPresets.ts +2 -2
- package/server/src/effortValidation.ts +4 -4
- package/server/src/explorerArtifacts.ts +12 -1
- package/server/src/geminiMembers.ts +26 -15
- package/server/src/http/conversationFiles.ts +231 -0
- package/server/src/http/fileBytes.ts +34 -0
- package/server/src/http/fileContentRoute.ts +123 -0
- package/server/src/http/fileRead.ts +30 -25
- package/server/src/http/outputRoutes.ts +13 -13
- package/server/src/http/readConfinement.ts +3 -30
- package/server/src/http/router.ts +38 -62
- package/server/src/index.ts +27 -18
- package/server/src/management/initHubLink.ts +1 -1
- package/server/src/outputs.ts +8 -0
- package/server/src/primitives/exportContext.ts +14 -2
- package/server/src/primitives/runCompare.ts +73 -46
- package/server/src/project/taskLedger.ts +47 -30
- package/server/src/providerAccounts.ts +20 -1
- package/server/src/providers/antigravity/artifacts.ts +121 -0
- package/server/src/providers/antigravity/index.ts +64 -6
- package/server/src/providers/antigravity/questions.ts +52 -0
- package/server/src/providers/claude-native/auth.ts +45 -60
- package/server/src/providers/claude-native/authStatus.ts +9 -8
- package/server/src/providers/claude-native/catalog.ts +52 -35
- package/server/src/providers/claude-native/oauth.ts +101 -77
- package/server/src/providers/claude-native/worker.ts +38 -22
- package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
- package/server/src/server/broadcast.ts +4 -0
- package/server/src/settings.ts +36 -8
- package/server/src/skills.ts +1 -1
- package/server/src/smartPickupAdapters.ts +3 -2
- package/server/src/smartPickupObserver.ts +8 -5
- package/server/src/thirdPartySkills.ts +11 -5
- package/server/src/usage.ts +30 -22
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/processKill.ts +37 -23
- package/server/src/workflowMeta.ts +2 -2
- package/server/src/ws/clusterHandlers.ts +107 -104
- package/server/src/ws/clusterMembers.ts +25 -6
- package/server/src/ws/compactHandlers.ts +29 -15
- package/server/src/ws/compareHandlers.ts +59 -25
- package/server/src/ws/gateHandlers.ts +2 -0
- package/server/src/ws/genesisHandlers.ts +5 -4
- package/server/src/ws/handoffHandlers.ts +105 -37
- package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
- package/server/src/ws/turnEngine.ts +32 -17
- package/server/src/ws/updatePrimaryConfig.ts +230 -132
- package/server/src/ws/workflowHandlers.ts +20 -4
- package/shared/dist/protocol/clusters.d.ts +15 -3
- package/shared/dist/protocol/clusters.js +1 -1
- package/shared/dist/protocol/models.d.ts +6 -1
- package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
- package/shared/dist/protocol/settings.d.ts +3 -0
- package/shared/dist/protocol/settings.js +5 -0
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/dist/protocol/workflows.js +0 -2
- package/shared/src/protocol/clusters.ts +23 -5
- package/shared/src/protocol/compare.ts +2 -2
- package/shared/src/protocol/models.ts +8 -4
- package/shared/src/protocol/operatorQuestions.ts +2 -1
- package/shared/src/protocol/settings.ts +8 -1
- package/shared/src/protocol/workflows.ts +1 -1
|
@@ -7,6 +7,7 @@ import { stopTurnSizes } from '../storageTurnWatch.js';
|
|
|
7
7
|
import { noteSmartPickupStop } from '../smartPickupObserver.js';
|
|
8
8
|
import { isKnownProvider } from '../providers/index.js';
|
|
9
9
|
import { publishWorkerActivity } from './turnEngine.js';
|
|
10
|
+
import { isUpdatingNativeAccount } from './updatePrimaryConfig.js';
|
|
10
11
|
import { clearPrivateWatches } from '../voice/watches.js';
|
|
11
12
|
// server/src/ws/workflowHandlers.ts — workflow-lifecycle WS handler region
|
|
12
13
|
// extracted from index.ts (docs/ARCHITECTURE.md). Behavior-
|
|
@@ -44,7 +45,7 @@ import { getRecallIndex } from '../recall/index.js';
|
|
|
44
45
|
import { promises as fsPromises } from 'fs';
|
|
45
46
|
import path from 'path';
|
|
46
47
|
import { artifactsDir } from '../workers/limits.js';
|
|
47
|
-
import { resolveProviderAccount } from '../providerAccounts.js';
|
|
48
|
+
import { requireClaudeNativeAccount, resolveProviderAccount } from '../providerAccounts.js';
|
|
48
49
|
import { destroySandbox } from '../providers/claude-native/sandboxStore.js';
|
|
49
50
|
import { disposeProviderResources } from '../providers/index.js';
|
|
50
51
|
import { cancelClaudeNativeCompaction } from '../providers/claude-native/index.js';
|
|
@@ -111,7 +112,7 @@ export async function handleCreateWorkflow(ws, session, config, options) {
|
|
|
111
112
|
primaryEffort: saved.primaryEffort,
|
|
112
113
|
...(saved.primaryProvider === 'antigravity-cli' ? { skipPermissions: saved.antigravitySkipPermissions === true } : {}),
|
|
113
114
|
autoCompaction: resolveAutoCompactionPolicy(saved.autoCompaction, undefined) ?? (saved.efficiencyAutoCompact === 'conservative' ? { enabled: true, thresholdPercent: 80 } : saved.efficiencyAutoCompact === 'aggressive' ? { enabled: true, thresholdPercent: 70 } : undefined),
|
|
114
|
-
|
|
115
|
+
providerAccountRef: saved.providerAccountRef,
|
|
115
116
|
...(saved.claudeTransport
|
|
116
117
|
? { claudeTransport: saved.claudeTransport }
|
|
117
118
|
: saved.primaryProvider === 'claude' && !hasClaudeCliSession
|
|
@@ -152,11 +153,11 @@ export async function handleCreateWorkflow(ws, session, config, options) {
|
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
154
155
|
if (!config.resumeWorkflowId && config.primaryEffort !== undefined &&
|
|
155
|
-
!allowedWorkflowEfforts(provider, config.primaryModel).includes(config.primaryEffort)) {
|
|
156
|
+
!allowedWorkflowEfforts(provider, config.primaryModel, config.providerAccountRef).includes(config.primaryEffort)) {
|
|
156
157
|
send(ws, { type: 'error', message: 'The selected effort is not supported by this provider and model.' });
|
|
157
158
|
return;
|
|
158
159
|
}
|
|
159
|
-
config.primaryEffort = normalizedWorkflowEffort(provider, config.primaryModel, config.primaryEffort);
|
|
160
|
+
config.primaryEffort = normalizedWorkflowEffort(provider, config.primaryModel, config.primaryEffort, config.providerAccountRef);
|
|
160
161
|
const primary = derivePrimaryConfig(config);
|
|
161
162
|
const manager = new WorkerManager();
|
|
162
163
|
// docs/PROVIDERS.md - fact-force defaults OFF for new tabs.
|
|
@@ -278,6 +279,18 @@ export async function handleCreateWorkflow(ws, session, config, options) {
|
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
}
|
|
282
|
+
if (!resumed && (config.primaryProvider ?? 'claude') === 'claude' && config.providerAccountRef !== undefined) {
|
|
283
|
+
try {
|
|
284
|
+
await requireClaudeNativeAccount(config.providerAccountRef);
|
|
285
|
+
if (config.claudeTransport === 'cli' || config.ultracode)
|
|
286
|
+
throw new Error('Select Claude Native to use a Native account.');
|
|
287
|
+
config.claudeTransport = 'native';
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
send(ws, { type: 'error', message: err instanceof Error ? err.message : 'Claude Native account unavailable.' });
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
281
294
|
// docs/ARCHITECTURE.md - from-nothing Genesis. A workflow created with a
|
|
282
295
|
// genesis seed and no working directory runs the staged conversation in a
|
|
283
296
|
// hidden scratch dir until `genesis_scaffold` creates the real project and
|
|
@@ -776,6 +789,10 @@ export function handleCancel(ws, workflowId) {
|
|
|
776
789
|
send(ws, { type: 'error', message: 'Workflow storage is moving. Wait for the scaffold to finish before stopping this conversation.' });
|
|
777
790
|
return;
|
|
778
791
|
}
|
|
792
|
+
if (isUpdatingNativeAccount(wf)) {
|
|
793
|
+
send(ws, { type: 'error', message: 'Wait for the account change to finish before stopping this conversation.' });
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
779
796
|
// Smart: Automatic leaves the mail this member has now alone after STOP.
|
|
780
797
|
void noteSmartPickupStop(workflowId).catch(() => undefined);
|
|
781
798
|
wf.manager.killAll();
|
package/server/package.json
CHANGED
package/server/src/attention.ts
CHANGED
|
@@ -40,6 +40,13 @@ function firstSighting(id: string): boolean {
|
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* A question or gate Arco announced before a restart and shows again now. It is
|
|
45
|
+
* marked seen so the restored card does not raise a second desktop or phone
|
|
46
|
+
* alert (the BELL entry and the phone message went out the first time).
|
|
47
|
+
*/
|
|
48
|
+
export function acknowledgeSighting(id: string): void { firstSighting(id); }
|
|
49
|
+
|
|
43
50
|
export async function loadChannels(): Promise<NotificationChannels> {
|
|
44
51
|
try {
|
|
45
52
|
const parsed = JSON.parse(await readFile(channelsPath, 'utf-8'));
|
package/server/src/auth.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readSettings } from './settings.js';
|
|
1
2
|
import { antigravityStatus } from './providers/antigravity/status.js';
|
|
2
3
|
import { authLoginInstructions } from './authLoginInstructions.js';
|
|
3
4
|
import { execFile } from 'child_process';
|
|
@@ -30,8 +31,10 @@ const CURSOR_KEYRING_UNREACHABLE = 'Cursor keeps its sign-in in the desktop keyr
|
|
|
30
31
|
export interface AuthStatus {
|
|
31
32
|
loggedIn: boolean;
|
|
32
33
|
native?: ClaudeNativeAuthStatus;
|
|
34
|
+
nativeAccounts?: Record<string, ClaudeNativeAuthStatus>;
|
|
33
35
|
cli?: ClaudeCliAuthStatus;
|
|
34
36
|
probeFailed?: boolean;
|
|
37
|
+
githubState?: 'missing' | 'signed-out' | 'probe-failed';
|
|
35
38
|
email?: string;
|
|
36
39
|
subscriptionType?: string;
|
|
37
40
|
orgName?: string;
|
|
@@ -125,10 +128,15 @@ async function probeClaudeAuthStatus(): Promise<AuthStatus | null> {
|
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
export async function getClaudeAuthStatus(): Promise<AuthStatus> {
|
|
128
|
-
const [status, native] = await Promise.all([
|
|
131
|
+
const [status, native, settings] = await Promise.all([
|
|
129
132
|
probeClaudeAuthStatus().then(async result => result ?? await probeClaudeAuthStatus()),
|
|
130
133
|
getClaudeNativeAuthStatus(),
|
|
134
|
+
readSettings(),
|
|
131
135
|
]);
|
|
136
|
+
const legacyIds = new Set(settings.providerAccounts?.claude?.map(profile => profile.id));
|
|
137
|
+
const nativeAccounts = Object.fromEntries(await Promise.all((settings.providerAccounts?.claudeNative ?? [])
|
|
138
|
+
.filter(profile => !legacyIds.has(profile.id))
|
|
139
|
+
.map(async profile => [profile.id, await getClaudeNativeAuthStatus(profile.id)] as const)));
|
|
132
140
|
const binding = await getCliUsageBinding();
|
|
133
141
|
const cli: ClaudeCliAuthStatus = status
|
|
134
142
|
? { ...status, binding, checkedAt: Date.now() }
|
|
@@ -136,10 +144,10 @@ export async function getClaudeAuthStatus(): Promise<AuthStatus> {
|
|
|
136
144
|
cli.binding = binding;
|
|
137
145
|
cli.bindingCheckedAt = Date.now();
|
|
138
146
|
if (status) lastClaudeStatus = cli;
|
|
139
|
-
const nativeAvailable = native.credentialsPresent &&
|
|
147
|
+
const nativeAvailable = [native, ...Object.values(nativeAccounts)].some(account => account.credentialsPresent && account.state !== 'needs-attention');
|
|
140
148
|
const probeFailed = (cli.probeFailed && !nativeAvailable) || (native.probeFailed && !cli.loggedIn);
|
|
141
149
|
return {
|
|
142
|
-
native, cli,
|
|
150
|
+
native, cli, ...(Object.keys(nativeAccounts).length ? { nativeAccounts } : {}),
|
|
143
151
|
email: cli.email, subscriptionType: cli.subscriptionType, orgName: cli.orgName, apiProvider: cli.apiProvider,
|
|
144
152
|
loggedIn: cli.loggedIn || nativeAvailable,
|
|
145
153
|
probeFailed: probeFailed || undefined,
|
|
@@ -147,29 +155,34 @@ export async function getClaudeAuthStatus(): Promise<AuthStatus> {
|
|
|
147
155
|
};
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
// Human-readable gh status has appeared on either stream in supported versions.
|
|
159
|
+
// Never turn an unrecognized error or output into a signed-out verdict.
|
|
160
|
+
export function githubStatusFromProbe(stdout: string, stderr: string, failure?: { code?: unknown }): AuthStatus {
|
|
161
|
+
if (failure?.code === 'ENOENT') return { loggedIn: false, githubState: 'missing', error: 'GitHub CLI was not found. Install gh in the Arco server environment, then check again.' };
|
|
162
|
+
const output = `${stdout}\n${stderr}`;
|
|
163
|
+
if (!failure) {
|
|
164
|
+
const account = output.match(/Logged in to \S+ (?:account|as) (\S+)/)?.[1];
|
|
165
|
+
if (account) {
|
|
166
|
+
const scopes = output.match(/Token scopes: (.+)/)?.[1];
|
|
167
|
+
return { loggedIn: true, email: account, apiProvider: 'github-cli', subscriptionType: scopes ? `gh (${scopes.replace(/'/g, '')})` : 'gh' };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (/You are not logged into any (?:GitHub hosts|accounts)/i.test(output) || /Failed to log in to \S+ (?:account|using token)/i.test(output) && /token .* invalid/i.test(output)) {
|
|
171
|
+
return { loggedIn: false, githubState: 'signed-out', error: 'GitHub CLI is not signed in. Sign in, then check again.' };
|
|
172
|
+
}
|
|
173
|
+
return { loggedIn: false, githubState: 'probe-failed', probeFailed: true, error: 'GitHub CLI status could not be checked. Run gh auth status in the Arco server environment, then check again.' };
|
|
174
|
+
}
|
|
175
|
+
|
|
154
176
|
async function getGithubAuthStatus(): Promise<AuthStatus> {
|
|
155
177
|
try {
|
|
156
|
-
const { stdout } = await execFileAsync('gh', ['auth', 'status', '--active'], {
|
|
178
|
+
const { stdout, stderr } = await execFileAsync('gh', ['auth', 'status', '--active'], {
|
|
157
179
|
maxBuffer: 256 * 1024,
|
|
158
180
|
timeout: 10_000,
|
|
159
181
|
});
|
|
160
|
-
|
|
161
|
-
const scopes = stdout.match(/Token scopes: (.+)/)?.[1];
|
|
162
|
-
return {
|
|
163
|
-
loggedIn: Boolean(account),
|
|
164
|
-
email: account,
|
|
165
|
-
apiProvider: 'github-cli',
|
|
166
|
-
subscriptionType: scopes ? `gh (${scopes.replace(/'/g, '')})` : 'gh',
|
|
167
|
-
};
|
|
182
|
+
return githubStatusFromProbe(stdout, stderr);
|
|
168
183
|
} catch (err) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
error: err instanceof Error && 'stderr' in err ? String((err as { stderr: string }).stderr).slice(0, 200) : 'gh auth status failed',
|
|
172
|
-
};
|
|
184
|
+
const failure = err as { code?: unknown; stdout?: string; stderr?: string };
|
|
185
|
+
return githubStatusFromProbe(failure.stdout ?? '', failure.stderr ?? '', failure);
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
188
|
|
|
@@ -45,7 +45,7 @@ import { join } from 'node:path';
|
|
|
45
45
|
import * as clusterStore from './clusterStore.js';
|
|
46
46
|
import * as clusterMailbox from './clusterMailbox.js';
|
|
47
47
|
import type { ServerMessage } from '@arco/shared';
|
|
48
|
-
import { isGeminiMember } from './geminiMembers.js';
|
|
48
|
+
import { geminiPickupAllowed, isGeminiMember } from './geminiMembers.js';
|
|
49
49
|
|
|
50
50
|
export const GEMINI_AUTO_PICKUP_SKIP = 'Skipped a Gemini member: its mail waits for your NUDGE.';
|
|
51
51
|
export const GEMINI_MAIL_SKIP = 'Mail from a Gemini member waits for your NUDGE.';
|
|
@@ -109,6 +109,21 @@ const ruleGuard = new RulePickupGuard(
|
|
|
109
109
|
(cluster, content) => { atomicWriteFileSync(join(clusterStore.clusterDir(cluster), 'rule-pickup-ledger.json'), content, { mode: 0o600 }); },
|
|
110
110
|
);
|
|
111
111
|
const pendingChecks = new Set<string>();
|
|
112
|
+
// Members whose last turn ended in a terminal request_too_large. Automatic
|
|
113
|
+
// pickup stops waking them (their mail stays unread) until a turn succeeds or
|
|
114
|
+
// the member is dropped; a wake only adds to a history that is already too big.
|
|
115
|
+
const tooLargeMembers = new Set<string>();
|
|
116
|
+
export const MEMBER_BLOCKED_NOTICE = 'Its conversation is too large for the provider. Hand off or replace this member, then NUDGE it; its mail is kept.';
|
|
117
|
+
// Provider rejections that repeat for as long as the stored conversation stays
|
|
118
|
+
// the same size: Anthropic's request_too_large (413), its total-text-bytes
|
|
119
|
+
// limit (400 invalid_request_error), and context-window overflows.
|
|
120
|
+
const OVERSIZE_ERROR = /request_too_large|too many total text bytes|prompt is too long|context[ _]length|exceeds? the (?:maximum )?context/i;
|
|
121
|
+
export function isOversizeError(error: string): boolean { return OVERSIZE_ERROR.test(error); }
|
|
122
|
+
export function noteTurnOutcome(workflowId: string, error?: string | null): void {
|
|
123
|
+
if (error && isOversizeError(error)) tooLargeMembers.add(workflowId);
|
|
124
|
+
else if (!error) tooLargeMembers.delete(workflowId);
|
|
125
|
+
}
|
|
126
|
+
export function isMemberBlocked(workflowId: string): boolean { return tooLargeMembers.has(workflowId); }
|
|
112
127
|
export function resumeRulePickup(clusterId: string): void { ruleGuard.resume(clusterId); }
|
|
113
128
|
export function resetRulePickup(clusterId: string): void { ruleGuard.reset(clusterId); }
|
|
114
129
|
export function interruptRulePickup(clusterId: string, member?: string): void { if (clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) { try { ruleGuard.interrupt(clusterId, member); } catch (error) { console.error('[arco] Rule-based pickup ledger unavailable:', error); } } }
|
|
@@ -211,7 +226,7 @@ export async function pickupWaitingMail(clusterId: string, liveMembers = resolve
|
|
|
211
226
|
if (!isBusyFn || !clusterStore.isAutoPickupWaking(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || !liveMembers) return;
|
|
212
227
|
for (const m of liveMembers) {
|
|
213
228
|
if (m.busy) {
|
|
214
|
-
if (dispatchBusyReminderFn) await remindBusyMember(clusterId,m.workflowId,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
|
|
229
|
+
if (!isGeminiMember(m.workflowId) && dispatchBusyReminderFn) await remindBusyMember(clusterId,m.workflowId,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
|
|
215
230
|
continue;
|
|
216
231
|
}
|
|
217
232
|
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) continue;
|
|
@@ -274,6 +289,7 @@ export function clearAutoTurnDepth(workflowId: string): void {
|
|
|
274
289
|
export function dropMember(workflowId: string): void {
|
|
275
290
|
memberState.delete(workflowId);
|
|
276
291
|
pendingDepth.delete(workflowId);
|
|
292
|
+
tooLargeMembers.delete(workflowId);
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
// Chain depth the resume sweeps use for a member's pending mail.
|
|
@@ -314,7 +330,7 @@ function emitSkip(
|
|
|
314
330
|
recipientWfid: string,
|
|
315
331
|
senderWfid: string,
|
|
316
332
|
chainDepth: number,
|
|
317
|
-
reason: 'rate_capped' | 'depth_capped' | 'cooldown' | 'recipient_busy' | 'disabled' | 'ack_only' | 'budget_paused' | 'member_capped' | 'pair_paused' | 'operator_send_only' | 'gemini_mail',
|
|
333
|
+
reason: 'rate_capped' | 'depth_capped' | 'cooldown' | 'recipient_busy' | 'disabled' | 'ack_only' | 'budget_paused' | 'member_capped' | 'pair_paused' | 'operator_send_only' | 'gemini_mail' | 'member_blocked',
|
|
318
334
|
now: number,
|
|
319
335
|
notice?: string,
|
|
320
336
|
): void {
|
|
@@ -351,17 +367,15 @@ export function onPeerMessageSent(opts: {
|
|
|
351
367
|
recipientWfid: string;
|
|
352
368
|
incomingChainDepth: number;
|
|
353
369
|
}): void {
|
|
354
|
-
// docs/PROTOCOL_CLUSTER.md "Gemini members": mail to or from a Gemini
|
|
355
|
-
// member waits for the operator's NUDGE on the recipient; no automatic
|
|
356
|
-
// wake or busy reminder.
|
|
357
370
|
const geminiRecipient = isGeminiMember(opts.recipientWfid);
|
|
358
|
-
|
|
371
|
+
const recipientHeld = geminiRecipient && !geminiPickupAllowed(opts.recipientWfid);
|
|
372
|
+
if (recipientHeld || isGeminiMember(opts.senderWfid)) {
|
|
359
373
|
if (clusterStore.isAutoTurnOnMailboxEnabled(opts.clusterId) && !clusterStore.isAutoPickupPaused(opts.clusterId)) {
|
|
360
|
-
emitSkip(opts.clusterId, opts.recipientWfid, opts.senderWfid, opts.incomingChainDepth,
|
|
374
|
+
emitSkip(opts.clusterId, opts.recipientWfid, opts.senderWfid, opts.incomingChainDepth, recipientHeld ? 'operator_send_only' : 'gemini_mail', Date.now(), recipientHeld ? GEMINI_AUTO_PICKUP_SKIP : GEMINI_MAIL_SKIP);
|
|
361
375
|
}
|
|
362
376
|
return;
|
|
363
377
|
}
|
|
364
|
-
if (isBusyFn && dispatchBusyReminderFn) void remindBusyMember(opts.clusterId,opts.recipientWfid,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
|
|
378
|
+
if (!geminiRecipient && isBusyFn && dispatchBusyReminderFn) void remindBusyMember(opts.clusterId,opts.recipientWfid,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
|
|
365
379
|
if (!clusterStore.isAutoTurnOnMailboxEnabled(opts.clusterId)) return;
|
|
366
380
|
if (opts.incomingChainDepth > pendingChainDepth(opts.recipientWfid)) pendingDepth.set(opts.recipientWfid, opts.incomingChainDepth);
|
|
367
381
|
if (clusterStore.isAutoPickupPaused(opts.clusterId)) return;
|
|
@@ -387,11 +401,16 @@ function fireRulePickup(opts: { clusterId: string; senderWfid: string; recipient
|
|
|
387
401
|
const { clusterId, senderWfid, recipientWfid, incomingChainDepth } = opts;
|
|
388
402
|
const now = Date.now();
|
|
389
403
|
|
|
390
|
-
if (isGeminiMember(recipientWfid)) {
|
|
404
|
+
if (isGeminiMember(recipientWfid) && !geminiPickupAllowed(recipientWfid)) {
|
|
391
405
|
emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, 'operator_send_only', now, GEMINI_AUTO_PICKUP_SKIP);
|
|
392
406
|
return;
|
|
393
407
|
}
|
|
394
408
|
|
|
409
|
+
if (isMemberBlocked(recipientWfid)) {
|
|
410
|
+
emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, 'member_blocked', now, MEMBER_BLOCKED_NOTICE);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
395
414
|
// Guard 0: cluster toggle armed. Most clusters won't have this on; the
|
|
396
415
|
// gate is the first check so the hot path is one map lookup when off.
|
|
397
416
|
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId)) return;
|
|
@@ -497,7 +516,8 @@ export function smartChainDepthLimit(configured: number): number {
|
|
|
497
516
|
return process.env.ARCO_CLUSTER_AUTO_TURN_MAX_CHAIN_DEPTH ? AUTO_TURN_MAX_CHAIN_DEPTH : configured;
|
|
498
517
|
}
|
|
499
518
|
|
|
500
|
-
export function sharedGuardProblem(clusterId: string, recipientWfid: string, incomingChainDepth: number, now = Date.now(), depthLimit = AUTO_TURN_MAX_CHAIN_DEPTH): 'depth_capped' | 'cooldown' | 'rate_capped' | null {
|
|
519
|
+
export function sharedGuardProblem(clusterId: string, recipientWfid: string, incomingChainDepth: number, now = Date.now(), depthLimit = AUTO_TURN_MAX_CHAIN_DEPTH): 'depth_capped' | 'cooldown' | 'rate_capped' | 'member_blocked' | null {
|
|
520
|
+
if (isMemberBlocked(recipientWfid)) return 'member_blocked';
|
|
501
521
|
if (incomingChainDepth >= depthLimit) return 'depth_capped';
|
|
502
522
|
const ms = getMemberState(recipientWfid);
|
|
503
523
|
if (ms.lastFiredAt !== undefined && now - ms.lastFiredAt < AUTO_TURN_COOLDOWN_MS) return 'cooldown';
|
|
@@ -112,7 +112,7 @@ function normalizeMember(raw: unknown, idx: number): ClusterPresetMember {
|
|
|
112
112
|
}
|
|
113
113
|
const out: ClusterPresetMember = { provider, model };
|
|
114
114
|
if (typeof r.effort === 'string' && r.effort.trim().length > 0) out.effort = r.effort.trim();
|
|
115
|
-
if (provider === 'codex' && typeof r.providerAccountRef === 'string' && r.providerAccountRef.trim().length > 0) {
|
|
115
|
+
if ((provider === 'codex' || provider === 'claude') && typeof r.providerAccountRef === 'string' && r.providerAccountRef.trim().length > 0) {
|
|
116
116
|
out.providerAccountRef = r.providerAccountRef.trim();
|
|
117
117
|
}
|
|
118
118
|
if (typeof r.role === 'string') {
|
|
@@ -164,8 +164,8 @@ function normalizeMember(raw: unknown, idx: number): ClusterPresetMember {
|
|
|
164
164
|
}
|
|
165
165
|
if (out.accessMode === 'isolated') {
|
|
166
166
|
if (r.webAccess === false) out.webAccess = false;
|
|
167
|
-
if (provider === 'claude' && (r.claudeTransport === 'native' || r.claudeTransport === 'cli')) out.claudeTransport = r.claudeTransport;
|
|
168
167
|
}
|
|
168
|
+
if (provider === 'claude' && (r.claudeTransport === 'native' || r.claudeTransport === 'cli')) out.claudeTransport = r.claudeTransport;
|
|
169
169
|
// Research panels keep each researcher's ADVANCED limits (docs/RESEARCH.md).
|
|
170
170
|
if (out.accessMode === 'researcher') {
|
|
171
171
|
if (r.webAccess === false) out.webAccess = false;
|
|
@@ -3,10 +3,10 @@ import { getCachedClaudeModelEfforts } from './providers/claude-native/catalog.j
|
|
|
3
3
|
import { getCachedCodexModelCapabilities } from './providers/codex-appserver/catalog.js';
|
|
4
4
|
|
|
5
5
|
// Follow the model catalog and the same static overrides as the picker.
|
|
6
|
-
export function allowedWorkflowEfforts(provider: ProviderName | undefined, model: string): EffortLevel[] {
|
|
6
|
+
export function allowedWorkflowEfforts(provider: ProviderName | undefined, model: string, providerAccountRef?: string): EffortLevel[] {
|
|
7
7
|
if (!provider || provider === 'claude') {
|
|
8
8
|
const known = CLAUDE_MODEL_EFFORTS[model];
|
|
9
|
-
const live = getCachedClaudeModelEfforts(model);
|
|
9
|
+
const live = getCachedClaudeModelEfforts(model, providerAccountRef);
|
|
10
10
|
if (live?.length) return known ? CLAUDE_EFFORTS.filter((level) => known.includes(level) || live.includes(level)) : live;
|
|
11
11
|
return known ?? CLAUDE_EFFORTS;
|
|
12
12
|
}
|
|
@@ -20,8 +20,8 @@ export function allowedWorkflowEfforts(provider: ProviderName | undefined, model
|
|
|
20
20
|
return Object.keys(EFFORT_RANK) as EffortLevel[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function normalizedWorkflowEffort(provider: ProviderName | undefined, model: string, effort: unknown): EffortLevel {
|
|
24
|
-
const levels = allowedWorkflowEfforts(provider, model);
|
|
23
|
+
export function normalizedWorkflowEffort(provider: ProviderName | undefined, model: string, effort: unknown, providerAccountRef?: string): EffortLevel {
|
|
24
|
+
const levels = allowedWorkflowEfforts(provider, model, providerAccountRef);
|
|
25
25
|
if (typeof effort === 'string' && levels.includes(effort as EffortLevel)) return effort as EffortLevel;
|
|
26
26
|
if (typeof effort === 'string' && Object.hasOwn(EFFORT_RANK, effort)) {
|
|
27
27
|
const rank = EFFORT_RANK[effort as EffortLevel];
|
|
@@ -18,10 +18,12 @@ import { constants } from 'fs';
|
|
|
18
18
|
import { lstat, open, readFile, readdir, realpath, stat } from 'fs/promises';
|
|
19
19
|
import { basename, join, resolve, sep } from 'path';
|
|
20
20
|
import { homedir } from 'os';
|
|
21
|
+
import { listGeminiArtifacts } from './providers/antigravity/artifacts.js';
|
|
21
22
|
import { arcoHome } from './arcoHome.js';
|
|
22
23
|
import { assertSafePath, confinedPath } from './fileAccessPolicy.js';
|
|
23
24
|
|
|
24
25
|
export interface ArtifactEntry {
|
|
26
|
+
id?: string; // registered Gemini output, opened by workflow and id
|
|
25
27
|
path: string; // absolute, realpath-resolved, ⊆ $HOME
|
|
26
28
|
name: string; // basename
|
|
27
29
|
size: number; // bytes
|
|
@@ -134,8 +136,17 @@ async function collectForCwd(cwd: string): Promise<ArtifactEntry[]> {
|
|
|
134
136
|
const wfid = wf.name;
|
|
135
137
|
const files: string[] = [];
|
|
136
138
|
await walkArtifactFiles(join(workflowsDir, wfid, 'artifacts'), 0, files);
|
|
137
|
-
|
|
139
|
+
let gemini = await listGeminiArtifacts(cwd, wfid);
|
|
140
|
+
if (gemini.length) {
|
|
141
|
+
const { outputContext } = await import('./outputs.js');
|
|
142
|
+
const ctx = await outputContext(cwd, wfid).catch(() => null);
|
|
143
|
+
if (!ctx || await realpath(ctx.cwd) !== cwd) gemini = [];
|
|
144
|
+
}
|
|
145
|
+
if (files.length + gemini.length === 0) continue; // empty artifact dir → skipped (the ~90%)
|
|
138
146
|
const meta = await readWorkflowMeta(cwd, wfid);
|
|
147
|
+
for (const file of gemini) {
|
|
148
|
+
results.push({ ...file, workflowId: wfid, ...meta, project, cwd });
|
|
149
|
+
}
|
|
139
150
|
for (const f of files) {
|
|
140
151
|
const rp = await realpathWithinHome(f);
|
|
141
152
|
if (!rp) continue; // escaped $HOME or vanished — drop
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// typed in its composer. Mail to it waits in its mailbox, where the operator
|
|
4
|
-
// may read, edit or cancel it before pressing NUDGE; the member then reads it
|
|
5
|
-
// with peer_read like any other member. Each operator action gets a
|
|
6
|
-
// single-use ticket bound to the member and the exact text, and
|
|
7
|
-
// handleUserMessage (ws/turnEngine.ts) starts a Gemini member turn only with
|
|
8
|
-
// a valid ticket, checked again when a queued message is taken. Automatic
|
|
9
|
-
// turns (AUTO-PICKUP, Smart pickup, busy reminders, task dispatch,
|
|
10
|
-
// broadcasts, CONTINUE DIRECTOR, timers, retries) carry no ticket and never
|
|
11
|
-
// start one.
|
|
12
|
-
|
|
1
|
+
// Gemini member turns require a single-use ticket for the exact input.
|
|
2
|
+
// Operator input, previewed replacement history and an admitted AUTO-PICKUP wake can obtain one.
|
|
13
3
|
import { createHash, randomUUID } from 'node:crypto';
|
|
14
4
|
import { buildMessageGuardPolicy } from '@arco/shared';
|
|
15
5
|
import * as clusterStore from './clusterStore.js';
|
|
@@ -25,13 +15,22 @@ import { listSkills, buildSkillsManifest } from './skills.js';
|
|
|
25
15
|
import { gateProjectResources } from './projectTrust.js';
|
|
26
16
|
|
|
27
17
|
export const GEMINI_PROVIDER = 'antigravity-cli';
|
|
28
|
-
export const GEMINI_OPERATOR_ONLY_REFUSAL =
|
|
18
|
+
export const GEMINI_OPERATOR_ONLY_REFUSAL = "Use NUDGE or the member's composer to start a Gemini turn, or enable AUTO-PICKUP for eligible cluster mail.";
|
|
29
19
|
|
|
30
20
|
export function isGeminiMember(workflowId: string): boolean {
|
|
31
21
|
return workflows.get(workflowId)?.config.primaryProvider === GEMINI_PROVIDER
|
|
32
22
|
&& clusterStore.getClusterIdForWorkflow(workflowId) !== undefined;
|
|
33
23
|
}
|
|
34
24
|
|
|
25
|
+
// Research has a separate mailbox and wake policy. Ordinary pickup cannot
|
|
26
|
+
// cross into it or into a member with an isolated access mode.
|
|
27
|
+
export function geminiPickupAllowed(workflowId: string): boolean {
|
|
28
|
+
const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
29
|
+
if (!clusterId || !isGeminiMember(workflowId)) return false;
|
|
30
|
+
const cluster = clusterStore.getClusterCached(clusterId);
|
|
31
|
+
return !!cluster && !cluster.research && clusterStore.getMemberAccessMode(clusterId, workflowId) === 'standard';
|
|
32
|
+
}
|
|
33
|
+
|
|
35
34
|
// A queued message may wait behind a long turn; six hours bounds memory
|
|
36
35
|
// without expiring an operator message that is still waiting its turn.
|
|
37
36
|
const TICKET_TTL_MS = 6 * 60 * 60 * 1000;
|
|
@@ -45,8 +44,7 @@ function prune(now: number): void {
|
|
|
45
44
|
for (const [id, t] of tickets) if (t.expiresAt <= now) tickets.delete(id);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
//
|
|
49
|
-
// message) for a Gemini member.
|
|
47
|
+
// Issued by the server for Gemini operator input, previewed replacement history or an eligible AUTO-PICKUP wake.
|
|
50
48
|
export function issueGeminiSend(workflowId: string, content: string, now = Date.now()): string {
|
|
51
49
|
prune(now);
|
|
52
50
|
const id = randomUUID();
|
|
@@ -114,3 +112,16 @@ export async function geminiNudgeText(workflowId: string, nudge: string): Promis
|
|
|
114
112
|
}
|
|
115
113
|
return [instructions, skills, reminder, nudge].filter(part => part.trim()).join('\n\n---\n\n');
|
|
116
114
|
}
|
|
115
|
+
|
|
116
|
+
export async function prepareGeminiPickup(workflowId: string, prompt: string, mode: 'rule' | 'smart-auto') {
|
|
117
|
+
const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
118
|
+
if (!clusterId) return undefined;
|
|
119
|
+
const isCurrent = () => geminiPickupAllowed(workflowId)
|
|
120
|
+
&& clusterStore.getClusterIdForWorkflow(workflowId) === clusterId
|
|
121
|
+
&& clusterStore.getAutoPickupMode(clusterId) === mode
|
|
122
|
+
&& !clusterStore.isAutoPickupPaused(clusterId);
|
|
123
|
+
if (!isCurrent()) return undefined;
|
|
124
|
+
const content = await geminiNudgeText(workflowId, prompt);
|
|
125
|
+
if (!isCurrent()) return undefined;
|
|
126
|
+
return { content, ticket: issueGeminiSend(workflowId, content), isCurrent };
|
|
127
|
+
}
|