@tonyclaw/agent-inspector 3.1.32 → 4.0.2
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +241 -120
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-oXUk3MBR.mjs → router-BBY_zWRK.mjs} +91 -3
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-BtfPSpkV.js → CompareDrawer-rtNElN-B.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D9DPPQ3n.js → InspectorPet-QaAiuF3d.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-Buu8vkCK.js → ProxyViewerContainer-6twNZHwl.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-BER-QzpD.js → ReplayDialog-B7KlziO2.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-C8Zwxrr7.js → RequestAnatomy-2XVFBrW4.js} +1 -1
- package/.output/ui/assets/{ResponseView-DDpKdYk6.js → ResponseView-BULgzLVB.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-sMPGG7Sw.js → StreamingChunkSequence-DSkvkbns.js} +1 -1
- package/.output/ui/assets/{_sessionId-e4IheHnP.js → _sessionId-D2dmJi3G.js} +1 -1
- package/.output/ui/assets/{_sessionId-C5Uv72Fx.js → _sessionId-DcS0s1Mr.js} +1 -1
- package/.output/ui/assets/{index-B__qT0Yd.js → index-B0TN1KKO.js} +2 -2
- package/.output/ui/assets/{index-Be3bTCzi.js → index-Bva1zHEs.js} +1 -1
- package/.output/ui/assets/{index-C9q__p8J.js → index-BzBExOxu.js} +1 -1
- package/.output/ui/assets/{index-CtB0deSZ.js → index-k6sRQz55.js} +1 -1
- package/.output/ui/assets/{json-viewer-Db0AFp-7.js → json-viewer-CWM4tY-j.js} +1 -1
- package/.output/ui/assets/{jszip.min-DkY0Ym_q.js → jszip.min-BkWvRFlo.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +8 -13
- package/src/assets/IDE/claudecode-color.svg +0 -1
- package/src/assets/IDE/codex-color.svg +0 -1
- package/src/assets/IDE/opencode.svg +0 -1
- package/src/assets/IDE/xiaomimimo.svg +0 -1
- package/src/assets/favicon.svg +0 -21
- package/src/assets/logos/alibaba.svg +0 -1
- package/src/assets/logos/anthropic.svg +0 -1
- package/src/assets/logos/claude-code.svg +0 -4
- package/src/assets/logos/deepseek.svg +0 -1
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +0 -1
- package/src/assets/logos/opencode.svg +0 -4
- package/src/assets/logos/qwen.webp +0 -0
- package/src/assets/logos/zhipuai.svg +0 -219
- package/src/backend/router.tsx +0 -36
- package/src/backend/routes/$.ts +0 -26
- package/src/backend/routes/__root.ts +0 -4
- package/src/backend/routes/api/-instances.ts +0 -7
- package/src/backend/routes/api/alerts.summary.ts +0 -28
- package/src/backend/routes/api/alerts.ts +0 -70
- package/src/backend/routes/api/config.paths.ts +0 -14
- package/src/backend/routes/api/config.ts +0 -73
- package/src/backend/routes/api/ecosystem.packages.$packageId.help.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.install.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.runner-presets.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.upgrade.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.ts +0 -21
- package/src/backend/routes/api/ecosystem.recipes.$recipeId.run.ts +0 -11
- package/src/backend/routes/api/ecosystem.tasks.$taskId.ts +0 -16
- package/src/backend/routes/api/ecosystem.tasks.ts +0 -12
- package/src/backend/routes/api/groups.$groupId.evidence.ts +0 -55
- package/src/backend/routes/api/groups.$groupId.sessions.ts +0 -50
- package/src/backend/routes/api/groups.$groupId.ts +0 -93
- package/src/backend/routes/api/groups.ts +0 -79
- package/src/backend/routes/api/health.ts +0 -22
- package/src/backend/routes/api/instances.$name.connection.ts +0 -12
- package/src/backend/routes/api/instances.$name.restart.ts +0 -23
- package/src/backend/routes/api/instances.$name.start.ts +0 -18
- package/src/backend/routes/api/instances.$name.stop.ts +0 -23
- package/src/backend/routes/api/instances.$name.ts +0 -12
- package/src/backend/routes/api/instances.ts +0 -16
- package/src/backend/routes/api/knowledge.candidates.$candidateId.promote.ts +0 -32
- package/src/backend/routes/api/knowledge.candidates.$candidateId.ts +0 -50
- package/src/backend/routes/api/knowledge.candidates.ts +0 -10
- package/src/backend/routes/api/knowledge.project-context.ts +0 -29
- package/src/backend/routes/api/knowledge.search.ts +0 -62
- package/src/backend/routes/api/knowledge.sessions.$sessionId.candidates.ts +0 -26
- package/src/backend/routes/api/logs.$id.body.ts +0 -58
- package/src/backend/routes/api/logs.$id.chunks.ts +0 -37
- package/src/backend/routes/api/logs.$id.replay.ts +0 -297
- package/src/backend/routes/api/logs.$id.ts +0 -23
- package/src/backend/routes/api/logs.import.ts +0 -39
- package/src/backend/routes/api/logs.stream.ts +0 -174
- package/src/backend/routes/api/logs.ts +0 -214
- package/src/backend/routes/api/mcp.ts +0 -25
- package/src/backend/routes/api/models.ts +0 -10
- package/src/backend/routes/api/pi-agent.ts +0 -29
- package/src/backend/routes/api/providers.$providerId.model-metadata.ts +0 -173
- package/src/backend/routes/api/providers.$providerId.test.log.ts +0 -342
- package/src/backend/routes/api/providers.$providerId.ts +0 -111
- package/src/backend/routes/api/providers.export.ts +0 -44
- package/src/backend/routes/api/providers.import.ts +0 -81
- package/src/backend/routes/api/providers.scan.ts +0 -28
- package/src/backend/routes/api/providers.ts +0 -102
- package/src/backend/routes/api/runs.$runId.evidence.ts +0 -55
- package/src/backend/routes/api/runs.$runId.ts +0 -50
- package/src/backend/routes/api/runs.ts +0 -62
- package/src/backend/routes/api/runtime.ts +0 -46
- package/src/backend/routes/api/sessions.ts +0 -51
- package/src/backend/routes/api/storage.ts +0 -56
- package/src/backend/routes/livez.ts +0 -13
- package/src/backend/routes/metrics.ts +0 -14
- package/src/backend/routes/proxy/$.ts +0 -15
- package/src/backend/routes/readyz.ts +0 -18
- package/src/backend/start.ts +0 -10
- package/src/cli/alias.ts +0 -431
- package/src/cli/detect-tools.ts +0 -123
- package/src/cli/doctor.ts +0 -836
- package/src/cli/instance.ts +0 -1071
- package/src/cli/instanceApi.ts +0 -213
- package/src/cli/instanceArgs.ts +0 -301
- package/src/cli/instanceControl.ts +0 -191
- package/src/cli/instanceModel.ts +0 -276
- package/src/cli/instanceRegistry.ts +0 -731
- package/src/cli/networkHints.ts +0 -170
- package/src/cli/onboard.ts +0 -1668
- package/src/cli/onboardTarget.ts +0 -228
- package/src/cli/rustBackendPackage.ts +0 -458
- package/src/cli/startupOutput.ts +0 -16
- package/src/cli/templates/codex-skill-onboard.ts +0 -320
- package/src/cli/templates/command-onboard.ts +0 -25
- package/src/cli/templates/skill-onboard.ts +0 -625
- package/src/cli.ts +0 -1397
- package/src/components/OnboardingBanner.tsx +0 -115
- package/src/components/ProxyViewer.tsx +0 -2259
- package/src/components/ProxyViewerContainer.tsx +0 -1076
- package/src/components/alerts/AlertsDialog.tsx +0 -615
- package/src/components/clients/ClientLogo.tsx +0 -175
- package/src/components/ecosystem/AgentLabDialog.tsx +0 -947
- package/src/components/errors/SafeErrorBoundary.tsx +0 -201
- package/src/components/groups/GroupsDialog.tsx +0 -1304
- package/src/components/inspector-pet/InspectorPet.tsx +0 -398
- package/src/components/inspector-pet/InspectorPetCrab3D.tsx +0 -455
- package/src/components/inspector-pet/inspectorPetLogic.ts +0 -272
- package/src/components/pi-agent/PiAgentPanel.tsx +0 -446
- package/src/components/pi-agent/piAgentChatLogic.ts +0 -273
- package/src/components/providers/ImportWizardDialog.tsx +0 -281
- package/src/components/providers/ProviderCard.tsx +0 -347
- package/src/components/providers/ProviderForm.tsx +0 -1183
- package/src/components/providers/ProviderLogo.tsx +0 -122
- package/src/components/providers/ProviderTestResultsView.tsx +0 -734
- package/src/components/providers/ProvidersPanel.tsx +0 -714
- package/src/components/providers/SettingsDialog.tsx +0 -1042
- package/src/components/providers/providerFormCapabilities.ts +0 -36
- package/src/components/proxy-viewer/AgentTraceSummary.tsx +0 -902
- package/src/components/proxy-viewer/AnswerMarkdown.tsx +0 -51
- package/src/components/proxy-viewer/ApplicationBar.tsx +0 -123
- package/src/components/proxy-viewer/CompareDrawer.tsx +0 -984
- package/src/components/proxy-viewer/ConversationGroup.tsx +0 -208
- package/src/components/proxy-viewer/ConversationGroupList.tsx +0 -652
- package/src/components/proxy-viewer/ConversationHeader.tsx +0 -429
- package/src/components/proxy-viewer/LiveConnectionStatus.tsx +0 -186
- package/src/components/proxy-viewer/LogEntry.tsx +0 -1419
- package/src/components/proxy-viewer/LogEntryHeader.tsx +0 -596
- package/src/components/proxy-viewer/ProviderLogoStack.tsx +0 -57
- package/src/components/proxy-viewer/RawExportWarning.tsx +0 -77
- package/src/components/proxy-viewer/ReplayDialog.tsx +0 -636
- package/src/components/proxy-viewer/RequestToolsPanel.tsx +0 -299
- package/src/components/proxy-viewer/ResponseView.tsx +0 -202
- package/src/components/proxy-viewer/SessionLoadProgressBar.tsx +0 -61
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +0 -265
- package/src/components/proxy-viewer/ThreadConnector.tsx +0 -165
- package/src/components/proxy-viewer/ToolTraceEvents.tsx +0 -64
- package/src/components/proxy-viewer/TurnGroup.tsx +0 -383
- package/src/components/proxy-viewer/TurnGroupList.tsx +0 -156
- package/src/components/proxy-viewer/accessibility.ts +0 -8
- package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +0 -887
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +0 -222
- package/src/components/proxy-viewer/anatomy/contextIntelligence.ts +0 -737
- package/src/components/proxy-viewer/anatomy/sessionContextSummary.ts +0 -268
- package/src/components/proxy-viewer/anatomy/tokenEstimate.ts +0 -53
- package/src/components/proxy-viewer/anatomy/types.ts +0 -41
- package/src/components/proxy-viewer/anatomy/useAnatomyJump.ts +0 -114
- package/src/components/proxy-viewer/bodyHydration.ts +0 -123
- package/src/components/proxy-viewer/cacheTrend.ts +0 -50
- package/src/components/proxy-viewer/diff/DiffView.tsx +0 -321
- package/src/components/proxy-viewer/diff/computeDiff.ts +0 -178
- package/src/components/proxy-viewer/diff/index.ts +0 -3
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +0 -194
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +0 -81
- package/src/components/proxy-viewer/formats/anthropic/thinkingExtract.ts +0 -21
- package/src/components/proxy-viewer/formats/index.tsx +0 -47
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +0 -442
- package/src/components/proxy-viewer/index.ts +0 -9
- package/src/components/proxy-viewer/lazy.ts +0 -41
- package/src/components/proxy-viewer/liveConnectionState.ts +0 -158
- package/src/components/proxy-viewer/log-formats/anthropic.ts +0 -191
- package/src/components/proxy-viewer/log-formats/index.ts +0 -23
- package/src/components/proxy-viewer/log-formats/openai.ts +0 -256
- package/src/components/proxy-viewer/log-formats/types.ts +0 -40
- package/src/components/proxy-viewer/log-formats/unknown.ts +0 -18
- package/src/components/proxy-viewer/logEntryVisibility.ts +0 -73
- package/src/components/proxy-viewer/logFocus.ts +0 -54
- package/src/components/proxy-viewer/proxyViewerContainerLogic.ts +0 -124
- package/src/components/proxy-viewer/proxyViewerLogic.ts +0 -488
- package/src/components/proxy-viewer/replayComparison.ts +0 -131
- package/src/components/proxy-viewer/requestDiff.ts +0 -277
- package/src/components/proxy-viewer/requestTools.ts +0 -220
- package/src/components/proxy-viewer/useCopyFeedback.ts +0 -38
- package/src/components/proxy-viewer/useKeyboardNavigation.ts +0 -232
- package/src/components/proxy-viewer/viewerState.ts +0 -176
- package/src/components/ui/badge.tsx +0 -47
- package/src/components/ui/button.tsx +0 -47
- package/src/components/ui/collapsible.tsx +0 -21
- package/src/components/ui/confirm-dialog.tsx +0 -51
- package/src/components/ui/crab-logo.tsx +0 -45
- package/src/components/ui/crab-variants.tsx +0 -467
- package/src/components/ui/dialog.tsx +0 -130
- package/src/components/ui/icon-trigger.ts +0 -2
- package/src/components/ui/json-viewer-bulk.ts +0 -132
- package/src/components/ui/json-viewer.tsx +0 -508
- package/src/components/ui/scroll-area.tsx +0 -54
- package/src/components/ui/select.tsx +0 -178
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/tabs.tsx +0 -88
- package/src/components/ui/tooltip.tsx +0 -51
- package/src/components/ui/transient-toast.tsx +0 -105
- package/src/contracts/anthropic.ts +0 -230
- package/src/contracts/index.ts +0 -59
- package/src/contracts/json.ts +0 -37
- package/src/contracts/log.ts +0 -139
- package/src/contracts/openai.ts +0 -267
- package/src/index.css +0 -11
- package/src/knowledge/candidateStore.ts +0 -94
- package/src/knowledge/distiller.ts +0 -98
- package/src/knowledge/openclawClient.ts +0 -161
- package/src/knowledge/openclawGatewayClient.ts +0 -249
- package/src/knowledge/openclawMarkdown.ts +0 -146
- package/src/knowledge/redactor.ts +0 -80
- package/src/knowledge/types.ts +0 -83
- package/src/lib/alertContract.ts +0 -76
- package/src/lib/apiClient.ts +0 -166
- package/src/lib/apiFormat.ts +0 -29
- package/src/lib/backendImplementation.ts +0 -16
- package/src/lib/basePath.ts +0 -107
- package/src/lib/browserRuntimeContract.ts +0 -124
- package/src/lib/browserRuntimeResolver.ts +0 -333
- package/src/lib/chunkLoadRecovery.ts +0 -83
- package/src/lib/claudeCodeStrip.ts +0 -98
- package/src/lib/clipboard.ts +0 -67
- package/src/lib/codingAgentEndpoints.ts +0 -54
- package/src/lib/ecosystemContract.ts +0 -130
- package/src/lib/export-logs.ts +0 -287
- package/src/lib/groupContract.ts +0 -166
- package/src/lib/instanceContract.ts +0 -239
- package/src/lib/jsonFile.ts +0 -46
- package/src/lib/logImportContract.ts +0 -12
- package/src/lib/managedInstance.ts +0 -112
- package/src/lib/mask.ts +0 -4
- package/src/lib/objectUtils.ts +0 -22
- package/src/lib/piAgentContract.ts +0 -102
- package/src/lib/providerContract.ts +0 -125
- package/src/lib/providerImportContract.ts +0 -27
- package/src/lib/providerModelMetadata.ts +0 -458
- package/src/lib/providerTestContract.ts +0 -170
- package/src/lib/providerTestPrompt.ts +0 -100
- package/src/lib/publicBasePathContext.ts +0 -137
- package/src/lib/resourceLimits.ts +0 -345
- package/src/lib/runContract.ts +0 -164
- package/src/lib/runtimeConfig.ts +0 -43
- package/src/lib/safeDiagnostic.ts +0 -38
- package/src/lib/safeFetch.ts +0 -508
- package/src/lib/serverPort.ts +0 -47
- package/src/lib/sessionInfoContract.ts +0 -78
- package/src/lib/sessionUrl.ts +0 -46
- package/src/lib/ssrfGuard.ts +0 -133
- package/src/lib/stopReason.ts +0 -130
- package/src/lib/themeMode.ts +0 -41
- package/src/lib/timeDisplay.ts +0 -22
- package/src/lib/toolTrace.ts +0 -290
- package/src/lib/uiScale.ts +0 -117
- package/src/lib/unknown.ts +0 -27
- package/src/lib/upstreamUrl.ts +0 -150
- package/src/lib/useAlerts.ts +0 -82
- package/src/lib/useGroupEvidence.ts +0 -37
- package/src/lib/useGroups.ts +0 -32
- package/src/lib/useOnboarding.ts +0 -93
- package/src/lib/useProviders.ts +0 -30
- package/src/lib/useStripConfig.ts +0 -154
- package/src/lib/useThemeMode.ts +0 -40
- package/src/lib/useUiScale.ts +0 -52
- package/src/lib/utils.ts +0 -78
- package/src/mcp/currentContext.ts +0 -65
- package/src/mcp/instanceHandlers.ts +0 -151
- package/src/mcp/loopback.ts +0 -88
- package/src/mcp/mode.ts +0 -75
- package/src/mcp/previewExtractor.ts +0 -233
- package/src/mcp/server.ts +0 -2274
- package/src/mcp/toolHandlers.ts +0 -1533
- package/src/proxy/alerts.ts +0 -664
- package/src/proxy/chunkStorage.ts +0 -123
- package/src/proxy/config.ts +0 -218
- package/src/proxy/constants.ts +0 -66
- package/src/proxy/dataDir.ts +0 -147
- package/src/proxy/ecosystemExecutionConfirmation.ts +0 -114
- package/src/proxy/ecosystemExecutionRoute.ts +0 -116
- package/src/proxy/ecosystemRegistry.ts +0 -296
- package/src/proxy/ecosystemTasks.ts +0 -415
- package/src/proxy/evidenceAnalysis.ts +0 -526
- package/src/proxy/evidenceExporter.ts +0 -235
- package/src/proxy/formats/anthropic/anthropicProvider.ts +0 -75
- package/src/proxy/formats/anthropic/handler.ts +0 -75
- package/src/proxy/formats/anthropic/index.ts +0 -13
- package/src/proxy/formats/anthropic/register.ts +0 -4
- package/src/proxy/formats/anthropic/schemas.ts +0 -6
- package/src/proxy/formats/anthropic/stream.ts +0 -205
- package/src/proxy/formats/handler.ts +0 -46
- package/src/proxy/formats/index.ts +0 -13
- package/src/proxy/formats/jsonSchema.ts +0 -2
- package/src/proxy/formats/openai/alibabaProvider.ts +0 -34
- package/src/proxy/formats/openai/codexMetadata.ts +0 -61
- package/src/proxy/formats/openai/handler.ts +0 -133
- package/src/proxy/formats/openai/index.ts +0 -33
- package/src/proxy/formats/openai/provider.ts +0 -50
- package/src/proxy/formats/openai/register.ts +0 -4
- package/src/proxy/formats/openai/schemas.ts +0 -25
- package/src/proxy/formats/openai/stream.ts +0 -600
- package/src/proxy/formats/openai/zhipuProvider.ts +0 -31
- package/src/proxy/formats/providerAdapter.ts +0 -50
- package/src/proxy/formats/providerRegistry.ts +0 -51
- package/src/proxy/formats/providers/index.ts +0 -3
- package/src/proxy/formats/registry.ts +0 -65
- package/src/proxy/groupEvidenceExporter.ts +0 -371
- package/src/proxy/groupStore.ts +0 -336
- package/src/proxy/handler.ts +0 -729
- package/src/proxy/identityProxy.ts +0 -1842
- package/src/proxy/jsonlRecovery.ts +0 -554
- package/src/proxy/logBodyChunks.ts +0 -91
- package/src/proxy/logFinalizer.ts +0 -777
- package/src/proxy/logFinalizer.worker.ts +0 -24
- package/src/proxy/logImportUpload.ts +0 -128
- package/src/proxy/logImporter.ts +0 -813
- package/src/proxy/logIndex.ts +0 -663
- package/src/proxy/logSearch.ts +0 -122
- package/src/proxy/logger.ts +0 -537
- package/src/proxy/openaiOrphanToolStrip.ts +0 -142
- package/src/proxy/platformCommands.ts +0 -253
- package/src/proxy/privateDataPath.ts +0 -419
- package/src/proxy/providerImporters.ts +0 -578
- package/src/proxy/providerScanStore.ts +0 -87
- package/src/proxy/providerSecretStore.ts +0 -216
- package/src/proxy/providers.ts +0 -998
- package/src/proxy/rawStreamCapture.ts +0 -342
- package/src/proxy/runFailures.ts +0 -94
- package/src/proxy/runStore.ts +0 -214
- package/src/proxy/runtimeAdmission.ts +0 -55
- package/src/proxy/runtimeHealth.ts +0 -221
- package/src/proxy/runtimeMetrics.ts +0 -149
- package/src/proxy/runtimeShutdown.ts +0 -157
- package/src/proxy/schemas.ts +0 -112
- package/src/proxy/sessionArchive.ts +0 -479
- package/src/proxy/sessionInfo.ts +0 -266
- package/src/proxy/sessionProcess.ts +0 -194
- package/src/proxy/sessionRuntime.ts +0 -121
- package/src/proxy/sessionSupervisor.ts +0 -305
- package/src/proxy/sessionWorkerEntry.ts +0 -26
- package/src/proxy/shutdownCoordinator.ts +0 -90
- package/src/proxy/socketTracker.ts +0 -639
- package/src/proxy/sqliteLogIndex.ts +0 -733
- package/src/proxy/storageLifecycle.ts +0 -432
- package/src/proxy/store.ts +0 -1773
- package/src/proxy/streamTiming.ts +0 -31
- package/src/proxy/toolSchemaWarnings.ts +0 -529
- package/src/proxy/uiAssetServer.ts +0 -106
- package/src/proxy/upstream.ts +0 -127
- package/src/services/alerts.ts +0 -12
- package/src/services/groups.ts +0 -119
- package/src/services/piAgent.ts +0 -421
- package/src/services/piAgentRetrieval.ts +0 -1180
- package/src/services/result.ts +0 -17
- package/src/services/runs.ts +0 -76
- package/src/ui/bootstrap.ts +0 -167
- package/src/ui/index.html +0 -38
- package/src/ui/logsStreamClient.ts +0 -20
- package/src/ui/main.tsx +0 -13
- package/src/ui/public/runtime-config.js +0 -2
- package/src/ui/router.tsx +0 -13
- package/src/ui/routes/__root.tsx +0 -69
- package/src/ui/routes/index.tsx +0 -35
- package/src/ui/routes/session/$sessionId.tsx +0 -50
- package/src/ui/runtimeDiscovery.ts +0 -50
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { Buffer } from "node:buffer";
|
|
2
|
-
import { spawn, type ChildProcess } from "node:child_process";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
import type {
|
|
5
|
-
EcosystemExecutionPlan,
|
|
6
|
-
EcosystemTask,
|
|
7
|
-
EcosystemTaskAction,
|
|
8
|
-
EcosystemTaskStatus,
|
|
9
|
-
} from "../lib/ecosystemContract";
|
|
10
|
-
import { findEcosystemPackage, findEcosystemRecipe } from "./ecosystemRegistry";
|
|
11
|
-
import {
|
|
12
|
-
npmCommand,
|
|
13
|
-
npmSpawnCommand,
|
|
14
|
-
signalProcessTree,
|
|
15
|
-
type CommandSpec,
|
|
16
|
-
} from "./platformCommands";
|
|
17
|
-
import { DEFAULT_RUNTIME_BUDGET_POLICY } from "../lib/resourceLimits";
|
|
18
|
-
|
|
19
|
-
const MAX_TASKS = 50;
|
|
20
|
-
const OUTPUT_LIMIT = 40_000;
|
|
21
|
-
const INSTALL_TIMEOUT_MS = 120_000;
|
|
22
|
-
const HELP_TIMEOUT_MS = 30_000;
|
|
23
|
-
const RECIPE_TIMEOUT_MS = 90_000;
|
|
24
|
-
const SHUTDOWN_GRACE_MS = 2_000;
|
|
25
|
-
|
|
26
|
-
const tasks = new Map<string, EcosystemTask>();
|
|
27
|
-
type ActiveTask = {
|
|
28
|
-
child: ChildProcess;
|
|
29
|
-
closed: Promise<void>;
|
|
30
|
-
resolveClosed: () => void;
|
|
31
|
-
timeout: ReturnType<typeof setTimeout>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const activeTasks = new Map<string, ActiveTask>();
|
|
35
|
-
let acceptingTasks = true;
|
|
36
|
-
let shutdownForceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
37
|
-
|
|
38
|
-
function activeTaskLimit(): number {
|
|
39
|
-
const configured = Number(process.env["ECOSYSTEM_TASK_ACTIVE_LIMIT"]);
|
|
40
|
-
if (Number.isSafeInteger(configured) && configured > 0) return configured;
|
|
41
|
-
return DEFAULT_RUNTIME_BUDGET_POLICY.queues.backgroundWorkers;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function nowIso(): string {
|
|
45
|
-
return new Date().toISOString();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function trimOutput(output: string): string {
|
|
49
|
-
if (output.length <= OUTPUT_LIMIT) return output;
|
|
50
|
-
return output.slice(output.length - OUTPUT_LIMIT);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function appendTaskOutput(task: EcosystemTask, chunk: string): void {
|
|
54
|
-
task.output = trimOutput(`${task.output}${chunk}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function rememberTask(task: EcosystemTask): void {
|
|
58
|
-
tasks.set(task.id, task);
|
|
59
|
-
while (tasks.size > MAX_TASKS) {
|
|
60
|
-
const oldest = tasks.keys().next().value;
|
|
61
|
-
if (typeof oldest !== "string") return;
|
|
62
|
-
tasks.delete(oldest);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function packageActionArgs(action: EcosystemTaskAction, npmName: string): string[] {
|
|
67
|
-
switch (action) {
|
|
68
|
-
case "install":
|
|
69
|
-
case "upgrade":
|
|
70
|
-
return ["install", "-g", npmName];
|
|
71
|
-
case "help":
|
|
72
|
-
return ["exec", "--yes", npmName, "--", "--help"];
|
|
73
|
-
case "runner-presets":
|
|
74
|
-
return ["exec", "--yes", "@tonyclaw/eval-harness", "--", "runner-presets"];
|
|
75
|
-
case "recipe":
|
|
76
|
-
return ["exec", "--yes", npmName, "--", "--help"];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function recipeActionArgs(recipeId: string): string[] | null {
|
|
81
|
-
const execPrefix = ["exec", "--yes", "@tonyclaw/eval-harness", "--"];
|
|
82
|
-
switch (recipeId) {
|
|
83
|
-
case "inspector-mcp-smoke":
|
|
84
|
-
return [...execPrefix, "check-inspector-mcp"];
|
|
85
|
-
case "session-evidence-smoke":
|
|
86
|
-
return [
|
|
87
|
-
...execPrefix,
|
|
88
|
-
"inspector-smoke",
|
|
89
|
-
"--title",
|
|
90
|
-
"TonyClaw Lab smoke",
|
|
91
|
-
"--latest-log-limit",
|
|
92
|
-
"5",
|
|
93
|
-
];
|
|
94
|
-
case "runner-presets-json":
|
|
95
|
-
return [...execPrefix, "runner-presets", "--format", "json"];
|
|
96
|
-
case "local-smoke-batch":
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function packageActionTimeout(action: EcosystemTaskAction): number {
|
|
104
|
-
switch (action) {
|
|
105
|
-
case "install":
|
|
106
|
-
case "upgrade":
|
|
107
|
-
return INSTALL_TIMEOUT_MS;
|
|
108
|
-
case "help":
|
|
109
|
-
case "runner-presets":
|
|
110
|
-
return HELP_TIMEOUT_MS;
|
|
111
|
-
case "recipe":
|
|
112
|
-
return RECIPE_TIMEOUT_MS;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function taskCommand(args: readonly string[]): string {
|
|
117
|
-
return `${npmCommand()} ${args.join(" ")}`;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function getEcosystemPackageExecutionPlan(
|
|
121
|
-
packageId: string,
|
|
122
|
-
action: EcosystemTaskAction,
|
|
123
|
-
): EcosystemExecutionPlan | null {
|
|
124
|
-
if (action === "recipe") return null;
|
|
125
|
-
const definition =
|
|
126
|
-
action === "runner-presets"
|
|
127
|
-
? findEcosystemPackage("eval-harness")
|
|
128
|
-
: findEcosystemPackage(packageId);
|
|
129
|
-
if (definition === null) return null;
|
|
130
|
-
if (action === "runner-presets" && packageId !== "eval-harness") return null;
|
|
131
|
-
|
|
132
|
-
const args = packageActionArgs(action, definition.npmName);
|
|
133
|
-
const mutatesGlobalPackages = action === "install" || action === "upgrade";
|
|
134
|
-
return {
|
|
135
|
-
action,
|
|
136
|
-
targetId: definition.id,
|
|
137
|
-
targetName: definition.name,
|
|
138
|
-
command: taskCommand(args),
|
|
139
|
-
source: `npm registry: ${definition.npmName}`,
|
|
140
|
-
timeoutMs: packageActionTimeout(action),
|
|
141
|
-
scope: mutatesGlobalPackages
|
|
142
|
-
? "Global npm package installation"
|
|
143
|
-
: "Ephemeral npm exec process in the Inspector service account",
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function getEcosystemRecipeExecutionPlan(recipeId: string): EcosystemExecutionPlan | null {
|
|
148
|
-
const recipe = findEcosystemRecipe(recipeId);
|
|
149
|
-
if (recipe === null || !recipe.runnable) return null;
|
|
150
|
-
const definition = findEcosystemPackage(recipe.packageId);
|
|
151
|
-
if (definition === null) return null;
|
|
152
|
-
const args = recipeActionArgs(recipe.id);
|
|
153
|
-
if (args === null) return null;
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
action: "recipe",
|
|
157
|
-
targetId: recipe.id,
|
|
158
|
-
targetName: recipe.title,
|
|
159
|
-
command: taskCommand(args),
|
|
160
|
-
source: `Built-in allowlisted recipe using ${definition.npmName}`,
|
|
161
|
-
timeoutMs: RECIPE_TIMEOUT_MS,
|
|
162
|
-
scope: "Ephemeral npm exec process in the Inspector service account",
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function completeTask(
|
|
167
|
-
task: EcosystemTask,
|
|
168
|
-
status: Exclude<EcosystemTaskStatus, "queued" | "running">,
|
|
169
|
-
exitCode: number | null,
|
|
170
|
-
error: string | null,
|
|
171
|
-
): void {
|
|
172
|
-
task.status = status;
|
|
173
|
-
task.exitCode = exitCode;
|
|
174
|
-
task.error = error;
|
|
175
|
-
task.finishedAt = nowIso();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function finishActiveTask(taskId: string): void {
|
|
179
|
-
const active = activeTasks.get(taskId);
|
|
180
|
-
if (active === undefined) return;
|
|
181
|
-
clearTimeout(active.timeout);
|
|
182
|
-
activeTasks.delete(taskId);
|
|
183
|
-
active.resolveClosed();
|
|
184
|
-
if (activeTasks.size === 0 && shutdownForceTimer !== null) {
|
|
185
|
-
clearTimeout(shutdownForceTimer);
|
|
186
|
-
shutdownForceTimer = null;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function failTaskForShutdown(task: EcosystemTask): void {
|
|
191
|
-
if (task.status !== "running" && task.status !== "queued") return;
|
|
192
|
-
const error = "Runtime shutdown terminated the ecosystem command";
|
|
193
|
-
appendTaskOutput(task, `\n${error}.\n`);
|
|
194
|
-
completeTask(task, "failed", null, error);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function forceActiveTaskTrees(): void {
|
|
198
|
-
for (const [taskId, active] of activeTasks) {
|
|
199
|
-
const pid = active.child.pid;
|
|
200
|
-
if (pid === undefined) continue;
|
|
201
|
-
signalProcessTree(pid, "SIGKILL");
|
|
202
|
-
if (process.platform === "win32") {
|
|
203
|
-
const task = tasks.get(taskId);
|
|
204
|
-
if (task !== undefined) failTaskForShutdown(task);
|
|
205
|
-
finishActiveTask(taskId);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function launchTask(task: EcosystemTask, spawnCommand: CommandSpec, timeoutMs: number): void {
|
|
211
|
-
const child = spawn(spawnCommand.command, spawnCommand.args, {
|
|
212
|
-
detached: process.platform !== "win32",
|
|
213
|
-
windowsHide: true,
|
|
214
|
-
shell: false,
|
|
215
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
216
|
-
});
|
|
217
|
-
let resolveClosed = (): void => {};
|
|
218
|
-
const closed = new Promise<void>((resolve) => {
|
|
219
|
-
resolveClosed = resolve;
|
|
220
|
-
});
|
|
221
|
-
const timeout = setTimeout(() => {
|
|
222
|
-
const pid = child.pid;
|
|
223
|
-
if (pid !== undefined) signalProcessTree(pid, "SIGKILL");
|
|
224
|
-
appendTaskOutput(task, `\nTimed out after ${String(timeoutMs / 1000)}s.\n`);
|
|
225
|
-
}, timeoutMs);
|
|
226
|
-
activeTasks.set(task.id, { child, closed, resolveClosed, timeout });
|
|
227
|
-
|
|
228
|
-
task.status = "running";
|
|
229
|
-
task.startedAt = nowIso();
|
|
230
|
-
appendTaskOutput(task, `$ ${task.command}\n`);
|
|
231
|
-
|
|
232
|
-
child.stdout?.on("data", (chunk: Buffer) => {
|
|
233
|
-
appendTaskOutput(task, chunk.toString("utf8"));
|
|
234
|
-
});
|
|
235
|
-
child.stderr?.on("data", (chunk: Buffer) => {
|
|
236
|
-
appendTaskOutput(task, chunk.toString("utf8"));
|
|
237
|
-
});
|
|
238
|
-
child.on("error", (error) => {
|
|
239
|
-
appendTaskOutput(task, `\n${error.message}\n`);
|
|
240
|
-
if (task.status !== "failed") completeTask(task, "failed", null, error.message);
|
|
241
|
-
finishActiveTask(task.id);
|
|
242
|
-
});
|
|
243
|
-
child.on("close", (code) => {
|
|
244
|
-
if (task.status !== "failed") {
|
|
245
|
-
if (code === 0) {
|
|
246
|
-
completeTask(task, "succeeded", code, null);
|
|
247
|
-
} else {
|
|
248
|
-
completeTask(task, "failed", code, `Command exited with code ${String(code ?? "unknown")}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
finishActiveTask(task.id);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export function getEcosystemTask(taskId: string): EcosystemTask | null {
|
|
256
|
-
return tasks.get(taskId) ?? null;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export function listEcosystemTasks(): EcosystemTask[] {
|
|
260
|
-
return [...tasks.values()].sort((left, right) => right.createdAt.localeCompare(left.createdAt));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export function startEcosystemTask(
|
|
264
|
-
packageId: string,
|
|
265
|
-
action: EcosystemTaskAction,
|
|
266
|
-
): EcosystemTask | null {
|
|
267
|
-
if (!acceptingTasks) return null;
|
|
268
|
-
if (activeTasks.size >= activeTaskLimit()) return null;
|
|
269
|
-
if (action === "recipe") return null;
|
|
270
|
-
const definition =
|
|
271
|
-
action === "runner-presets"
|
|
272
|
-
? findEcosystemPackage("eval-harness")
|
|
273
|
-
: findEcosystemPackage(packageId);
|
|
274
|
-
if (definition === null) return null;
|
|
275
|
-
if (action === "runner-presets" && packageId !== "eval-harness") return null;
|
|
276
|
-
|
|
277
|
-
const args = packageActionArgs(action, definition.npmName);
|
|
278
|
-
const task: EcosystemTask = {
|
|
279
|
-
id: randomUUID(),
|
|
280
|
-
packageId: definition.id,
|
|
281
|
-
npmName: definition.npmName,
|
|
282
|
-
recipeId: null,
|
|
283
|
-
action,
|
|
284
|
-
status: "queued",
|
|
285
|
-
command: taskCommand(args),
|
|
286
|
-
output: "",
|
|
287
|
-
createdAt: nowIso(),
|
|
288
|
-
startedAt: null,
|
|
289
|
-
finishedAt: null,
|
|
290
|
-
exitCode: null,
|
|
291
|
-
error: null,
|
|
292
|
-
};
|
|
293
|
-
rememberTask(task);
|
|
294
|
-
|
|
295
|
-
launchTask(task, npmSpawnCommand(args), packageActionTimeout(action));
|
|
296
|
-
|
|
297
|
-
return task;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export function startEcosystemRecipeTask(recipeId: string): EcosystemTask | null {
|
|
301
|
-
if (!acceptingTasks) return null;
|
|
302
|
-
if (activeTasks.size >= activeTaskLimit()) return null;
|
|
303
|
-
const recipe = findEcosystemRecipe(recipeId);
|
|
304
|
-
if (recipe === null) return null;
|
|
305
|
-
if (!recipe.runnable) return null;
|
|
306
|
-
const definition = findEcosystemPackage(recipe.packageId);
|
|
307
|
-
if (definition === null) return null;
|
|
308
|
-
const args = recipeActionArgs(recipe.id);
|
|
309
|
-
if (args === null) return null;
|
|
310
|
-
|
|
311
|
-
const task: EcosystemTask = {
|
|
312
|
-
id: randomUUID(),
|
|
313
|
-
packageId: definition.id,
|
|
314
|
-
npmName: definition.npmName,
|
|
315
|
-
recipeId: recipe.id,
|
|
316
|
-
action: "recipe",
|
|
317
|
-
status: "queued",
|
|
318
|
-
command: taskCommand(args),
|
|
319
|
-
output: "",
|
|
320
|
-
createdAt: nowIso(),
|
|
321
|
-
startedAt: null,
|
|
322
|
-
finishedAt: null,
|
|
323
|
-
exitCode: null,
|
|
324
|
-
error: null,
|
|
325
|
-
};
|
|
326
|
-
rememberTask(task);
|
|
327
|
-
|
|
328
|
-
launchTask(task, npmSpawnCommand(args), RECIPE_TIMEOUT_MS);
|
|
329
|
-
|
|
330
|
-
return task;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/** Stop admitting commands and begin terminating every tracked child process tree. */
|
|
334
|
-
export function beginEcosystemTaskShutdown(): void {
|
|
335
|
-
acceptingTasks = false;
|
|
336
|
-
for (const [taskId, active] of activeTasks) {
|
|
337
|
-
const task = tasks.get(taskId);
|
|
338
|
-
if (task !== undefined) failTaskForShutdown(task);
|
|
339
|
-
clearTimeout(active.timeout);
|
|
340
|
-
const pid = active.child.pid;
|
|
341
|
-
if (pid !== undefined) {
|
|
342
|
-
signalProcessTree(pid, process.platform === "win32" ? "SIGKILL" : "SIGTERM");
|
|
343
|
-
if (process.platform === "win32") finishActiveTask(taskId);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
if (activeTasks.size > 0 && shutdownForceTimer === null) {
|
|
347
|
-
shutdownForceTimer = setTimeout(() => {
|
|
348
|
-
shutdownForceTimer = null;
|
|
349
|
-
forceActiveTaskTrees();
|
|
350
|
-
}, SHUTDOWN_GRACE_MS);
|
|
351
|
-
shutdownForceTimer.unref();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/** Wait until children signalled by beginEcosystemTaskShutdown have closed. */
|
|
356
|
-
export async function waitForEcosystemTasksToClose(): Promise<void> {
|
|
357
|
-
await Promise.all([...activeTasks.values()].map(async (active) => await active.closed));
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/** Immediate deadline fallback used by the runtime shutdown coordinator. */
|
|
361
|
-
export function forceCloseEcosystemTasks(): void {
|
|
362
|
-
acceptingTasks = false;
|
|
363
|
-
if (shutdownForceTimer !== null) {
|
|
364
|
-
clearTimeout(shutdownForceTimer);
|
|
365
|
-
shutdownForceTimer = null;
|
|
366
|
-
}
|
|
367
|
-
for (const taskId of activeTasks.keys()) {
|
|
368
|
-
const task = tasks.get(taskId);
|
|
369
|
-
if (task !== undefined) failTaskForShutdown(task);
|
|
370
|
-
}
|
|
371
|
-
forceActiveTaskTrees();
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
export function _startEcosystemTaskForTests(
|
|
375
|
-
spawnCommand: CommandSpec,
|
|
376
|
-
timeoutMs = RECIPE_TIMEOUT_MS,
|
|
377
|
-
): EcosystemTask | null {
|
|
378
|
-
if (!acceptingTasks) return null;
|
|
379
|
-
if (activeTasks.size >= activeTaskLimit()) return null;
|
|
380
|
-
const task: EcosystemTask = {
|
|
381
|
-
id: randomUUID(),
|
|
382
|
-
packageId: "test-package",
|
|
383
|
-
npmName: "test-package",
|
|
384
|
-
recipeId: null,
|
|
385
|
-
action: "help",
|
|
386
|
-
status: "queued",
|
|
387
|
-
command: `${spawnCommand.command} ${spawnCommand.args.join(" ")}`,
|
|
388
|
-
output: "",
|
|
389
|
-
createdAt: nowIso(),
|
|
390
|
-
startedAt: null,
|
|
391
|
-
finishedAt: null,
|
|
392
|
-
exitCode: null,
|
|
393
|
-
error: null,
|
|
394
|
-
};
|
|
395
|
-
rememberTask(task);
|
|
396
|
-
launchTask(task, spawnCommand, timeoutMs);
|
|
397
|
-
return task;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
export function _resetEcosystemTasksForTests(): void {
|
|
401
|
-
forceCloseEcosystemTasks();
|
|
402
|
-
tasks.clear();
|
|
403
|
-
activeTasks.clear();
|
|
404
|
-
acceptingTasks = true;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
export function _getEcosystemTaskAdmissionHealthForTests(): {
|
|
408
|
-
activeTasks: number;
|
|
409
|
-
activeTaskLimit: number;
|
|
410
|
-
} {
|
|
411
|
-
return {
|
|
412
|
-
activeTasks: activeTasks.size,
|
|
413
|
-
activeTaskLimit: activeTaskLimit(),
|
|
414
|
-
};
|
|
415
|
-
}
|