@tonyclaw/agent-inspector 4.0.1 → 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 +192 -109
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-CTHqmroT.mjs → router-BBY_zWRK.mjs} +91 -3
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-L3n4J-Or.js → CompareDrawer-rtNElN-B.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D5o_3OZS.js → InspectorPet-QaAiuF3d.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-Ocagx75S.js → ProxyViewerContainer-6twNZHwl.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-Bk7x1h-y.js → ReplayDialog-B7KlziO2.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-U4lzL7Sc.js → RequestAnatomy-2XVFBrW4.js} +1 -1
- package/.output/ui/assets/{ResponseView-LOWfvBLK.js → ResponseView-BULgzLVB.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DPfsrrXQ.js → StreamingChunkSequence-DSkvkbns.js} +1 -1
- package/.output/ui/assets/{_sessionId-OdX2Jvt1.js → _sessionId-D2dmJi3G.js} +1 -1
- package/.output/ui/assets/{_sessionId-0MlWS-CO.js → _sessionId-DcS0s1Mr.js} +1 -1
- package/.output/ui/assets/{index-Du4qNOOt.js → index-B0TN1KKO.js} +2 -2
- package/.output/ui/assets/{index-gvFj_9K6.js → index-Bva1zHEs.js} +1 -1
- package/.output/ui/assets/{index-Ea-c8hPg.js → index-BzBExOxu.js} +1 -1
- package/.output/ui/assets/{index-zVVS53Hd.js → index-k6sRQz55.js} +1 -1
- package/.output/ui/assets/{json-viewer-C1WAMzg3.js → json-viewer-CWM4tY-j.js} +1 -1
- package/.output/ui/assets/{jszip.min-B8AKu2zm.js → jszip.min-BkWvRFlo.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +5 -10
- 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 -1433
- 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 -258
- 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,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenAI Chat Completions format guard: orphan `tool` messages.
|
|
3
|
-
*
|
|
4
|
-
* The OpenAI Chat Completions spec requires every message with
|
|
5
|
-
* `role: "tool"` to reference a `tool_call_id` that appears in a preceding
|
|
6
|
-
* `assistant` message's `tool_calls` array. When this invariant is broken
|
|
7
|
-
* (typically by a buggy client that records a tool result without the
|
|
8
|
-
* matching assistant tool_call), the upstream rejects the request with a
|
|
9
|
-
* 400 like:
|
|
10
|
-
*
|
|
11
|
-
* {"type":"error","error":{"type":"bad_request_error",
|
|
12
|
-
* "message":"invalid params, tool result's tool id(call_xxx) not found"}}
|
|
13
|
-
*
|
|
14
|
-
* This module finds such orphan tool messages and returns a rewritten body
|
|
15
|
-
* with them removed so the proxy can forward a valid request. The original
|
|
16
|
-
* body is preserved by the caller for the captured log, so the inspector UI
|
|
17
|
-
* still shows the broken request the client actually sent.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const ROLE_ASSISTANT = "assistant";
|
|
21
|
-
const ROLE_TOOL = "tool";
|
|
22
|
-
|
|
23
|
-
export type OrphanToolStripResult = {
|
|
24
|
-
/** The new request body. Equal to input (by reference) when no change was made. */
|
|
25
|
-
body: string;
|
|
26
|
-
/** Number of orphan tool messages removed. */
|
|
27
|
-
removed: number;
|
|
28
|
-
/**
|
|
29
|
-
* The `tool_call_id` values of the removed messages, in document order.
|
|
30
|
-
* `null` is used when a tool message had no `tool_call_id` at all.
|
|
31
|
-
*/
|
|
32
|
-
orphanIds: Array<string | null>;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
import { safeGetOwnProperty, isPlainRecord } from "../lib/objectUtils";
|
|
36
|
-
|
|
37
|
-
function isObjectWithMessages(value: unknown): value is { messages: unknown[] } {
|
|
38
|
-
if (!isPlainRecord(value)) return false;
|
|
39
|
-
if (!Object.prototype.hasOwnProperty.call(value, "messages")) return false;
|
|
40
|
-
const messages = safeGetOwnProperty(value, "messages");
|
|
41
|
-
return Array.isArray(messages);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Collects the set of tool_call ids from an assistant message's `tool_calls`
|
|
46
|
-
* array. Tolerant of malformed entries: anything without a string `id` is
|
|
47
|
-
* skipped silently (those ids cannot be referenced by a tool message anyway).
|
|
48
|
-
*/
|
|
49
|
-
function collectAssistantToolCallIds(message: unknown, into: Set<string>): void {
|
|
50
|
-
if (!isPlainRecord(message)) return;
|
|
51
|
-
const toolCalls = safeGetOwnProperty(message, "tool_calls");
|
|
52
|
-
if (!Array.isArray(toolCalls)) return;
|
|
53
|
-
for (const tc of toolCalls) {
|
|
54
|
-
if (!isPlainRecord(tc)) continue;
|
|
55
|
-
const id = safeGetOwnProperty(tc, "id");
|
|
56
|
-
if (typeof id === "string" && id.length > 0) {
|
|
57
|
-
into.add(id);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Returns the indices of `tool`-role messages whose `tool_call_id` does not
|
|
64
|
-
* appear in any *preceding* assistant message's `tool_calls`. A tool message
|
|
65
|
-
* with no `tool_call_id` at all is also considered orphan.
|
|
66
|
-
*
|
|
67
|
-
* Pure, exported for unit tests. Used by `stripOpenAIOrphanToolMessages`.
|
|
68
|
-
*/
|
|
69
|
-
export function findOrphanToolMessageIndices(messages: readonly unknown[]): {
|
|
70
|
-
indices: number[];
|
|
71
|
-
orphanIds: Array<string | null>;
|
|
72
|
-
} {
|
|
73
|
-
const knownToolCallIds = new Set<string>();
|
|
74
|
-
const indices: number[] = [];
|
|
75
|
-
const orphanIds: Array<string | null> = [];
|
|
76
|
-
|
|
77
|
-
for (let i = 0; i < messages.length; i++) {
|
|
78
|
-
const msg = messages[i];
|
|
79
|
-
if (!isPlainRecord(msg)) continue;
|
|
80
|
-
|
|
81
|
-
const role = safeGetOwnProperty(msg, "role");
|
|
82
|
-
|
|
83
|
-
if (role === ROLE_ASSISTANT) {
|
|
84
|
-
collectAssistantToolCallIds(msg, knownToolCallIds);
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (role === ROLE_TOOL) {
|
|
89
|
-
const id = safeGetOwnProperty(msg, "tool_call_id");
|
|
90
|
-
if (typeof id !== "string" || id.length === 0) {
|
|
91
|
-
indices.push(i);
|
|
92
|
-
orphanIds.push(null);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
if (!knownToolCallIds.has(id)) {
|
|
96
|
-
indices.push(i);
|
|
97
|
-
orphanIds.push(id);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return { indices, orphanIds };
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Inspects an OpenAI-format request body and, if its `messages` array
|
|
107
|
-
* contains one or more orphan `tool` messages (see `findOrphanToolMessageIndices`),
|
|
108
|
-
* returns a new body with those messages removed. The original string is
|
|
109
|
-
* returned unchanged (by reference equality) when no edit is needed so the
|
|
110
|
-
* caller can skip a re-serialization.
|
|
111
|
-
*
|
|
112
|
-
* Tolerant of bodies that are not valid JSON, not OpenAI-format, or that
|
|
113
|
-
* have no `messages` array — all such inputs are returned unchanged.
|
|
114
|
-
*/
|
|
115
|
-
export function stripOpenAIOrphanToolMessages(rawBody: string): OrphanToolStripResult {
|
|
116
|
-
let parsed: unknown;
|
|
117
|
-
try {
|
|
118
|
-
parsed = JSON.parse(rawBody);
|
|
119
|
-
} catch {
|
|
120
|
-
return { body: rawBody, removed: 0, orphanIds: [] };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (!isObjectWithMessages(parsed)) {
|
|
124
|
-
return { body: rawBody, removed: 0, orphanIds: [] };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const messages = parsed.messages;
|
|
128
|
-
const { indices, orphanIds } = findOrphanToolMessageIndices(messages);
|
|
129
|
-
|
|
130
|
-
if (indices.length === 0) {
|
|
131
|
-
return { body: rawBody, removed: 0, orphanIds: [] };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const dropSet = new Set(indices);
|
|
135
|
-
const kept: unknown[] = [];
|
|
136
|
-
for (let i = 0; i < messages.length; i++) {
|
|
137
|
-
if (!dropSet.has(i)) kept.push(messages[i]);
|
|
138
|
-
}
|
|
139
|
-
parsed.messages = kept;
|
|
140
|
-
|
|
141
|
-
return { body: JSON.stringify(parsed), removed: indices.length, orphanIds };
|
|
142
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { statSync } from "node:fs";
|
|
2
|
-
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { delimiter, isAbsolute, join } from "node:path";
|
|
4
|
-
|
|
5
|
-
export type PlatformName = typeof process.platform;
|
|
6
|
-
type PathEnv = Record<string, string | undefined>;
|
|
7
|
-
|
|
8
|
-
export type CommandSpec = {
|
|
9
|
-
command: string;
|
|
10
|
-
args: string[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function platformCommand(
|
|
14
|
-
command: string,
|
|
15
|
-
args: readonly string[],
|
|
16
|
-
platform: PlatformName = process.platform,
|
|
17
|
-
): CommandSpec {
|
|
18
|
-
if (platform !== "win32") return { command, args: [...args] };
|
|
19
|
-
return { command: "cmd.exe", args: ["/d", "/s", "/c", command, ...args] };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function npmCommand(platform: PlatformName = process.platform): string {
|
|
23
|
-
return platform === "win32" ? "npm.cmd" : "npm";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function npmSpawnCommand(
|
|
27
|
-
args: readonly string[],
|
|
28
|
-
platform: PlatformName = process.platform,
|
|
29
|
-
): CommandSpec {
|
|
30
|
-
return platformCommand(npmCommand(platform), args, platform);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function pathEntries(envPath: string | undefined): string[] {
|
|
34
|
-
if (envPath === undefined || envPath.length === 0) return [];
|
|
35
|
-
return envPath.split(delimiter).filter((entry) => entry.length > 0);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function windowsExecutableExtensions(envPathExt: string | undefined): string[] {
|
|
39
|
-
const defaults = [".COM", ".EXE", ".BAT", ".CMD"];
|
|
40
|
-
if (envPathExt === undefined || envPathExt.trim().length === 0) return defaults;
|
|
41
|
-
const parsed = envPathExt
|
|
42
|
-
.split(";")
|
|
43
|
-
.map((entry) => entry.trim())
|
|
44
|
-
.filter((entry) => entry.length > 0);
|
|
45
|
-
return parsed.length > 0 ? parsed : defaults;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function isExecutableCandidate(path: string, platform: PlatformName): boolean {
|
|
49
|
-
try {
|
|
50
|
-
const stat = statSync(path);
|
|
51
|
-
if (!stat.isFile()) return false;
|
|
52
|
-
if (platform === "win32" || process.platform === "win32") return true;
|
|
53
|
-
return (stat.mode & 0o111) !== 0;
|
|
54
|
-
} catch {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function executableCandidates(bin: string, platform: PlatformName, env: PathEnv): string[] {
|
|
60
|
-
if (isAbsolute(bin)) return [bin];
|
|
61
|
-
const entries = pathEntries(env["PATH"] ?? env["Path"] ?? env["path"]);
|
|
62
|
-
if (platform !== "win32") return entries.map((entry) => join(entry, bin));
|
|
63
|
-
|
|
64
|
-
const hasExtension = /\.[^\\/]+$/.test(bin);
|
|
65
|
-
const extensions = hasExtension ? [""] : windowsExecutableExtensions(env["PATHEXT"]);
|
|
66
|
-
const candidates: string[] = [];
|
|
67
|
-
for (const entry of entries) {
|
|
68
|
-
for (const extension of extensions) {
|
|
69
|
-
candidates.push(join(entry, `${bin}${extension.toLowerCase()}`));
|
|
70
|
-
candidates.push(join(entry, `${bin}${extension.toUpperCase()}`));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return candidates;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function resolveExecutableOnPath(
|
|
77
|
-
bin: string,
|
|
78
|
-
platform: PlatformName = process.platform,
|
|
79
|
-
env: PathEnv = process.env,
|
|
80
|
-
): string | null {
|
|
81
|
-
if (bin.trim().length === 0) return null;
|
|
82
|
-
for (const candidate of executableCandidates(bin, platform, env)) {
|
|
83
|
-
if (isExecutableCandidate(candidate, platform)) return candidate;
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function openUrlCommand(
|
|
89
|
-
targetUrl: string,
|
|
90
|
-
platform: PlatformName = process.platform,
|
|
91
|
-
): CommandSpec | null {
|
|
92
|
-
switch (platform) {
|
|
93
|
-
case "darwin":
|
|
94
|
-
return { command: "open", args: [targetUrl] };
|
|
95
|
-
case "linux":
|
|
96
|
-
case "freebsd":
|
|
97
|
-
case "openbsd":
|
|
98
|
-
case "netbsd":
|
|
99
|
-
return { command: "xdg-open", args: [targetUrl] };
|
|
100
|
-
case "win32":
|
|
101
|
-
return { command: "cmd.exe", args: ["/d", "/s", "/c", "start", "", targetUrl] };
|
|
102
|
-
case "aix":
|
|
103
|
-
case "android":
|
|
104
|
-
case "cygwin":
|
|
105
|
-
case "haiku":
|
|
106
|
-
case "sunos":
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function parseWindowsNetstatPids(output: string, targetPort: number): number[] {
|
|
114
|
-
const pids = new Set<number>();
|
|
115
|
-
const targetToken = `:${targetPort}`;
|
|
116
|
-
for (const line of output.split(/\r?\n/)) {
|
|
117
|
-
const parts = line.trim().split(/\s+/);
|
|
118
|
-
if (parts.length < 5) continue;
|
|
119
|
-
const localAddress = parts[1] ?? "";
|
|
120
|
-
const pidStr = parts[4] ?? "";
|
|
121
|
-
if (!localAddress.endsWith(targetToken)) continue;
|
|
122
|
-
const pid = Number.parseInt(pidStr, 10);
|
|
123
|
-
if (Number.isInteger(pid) && pid > 0) pids.add(pid);
|
|
124
|
-
}
|
|
125
|
-
return [...pids];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function parseUnixLsofPids(output: string): number[] {
|
|
129
|
-
const pids = new Set<number>();
|
|
130
|
-
for (const line of output.split(/\r?\n/)) {
|
|
131
|
-
const pid = Number.parseInt(line.trim(), 10);
|
|
132
|
-
if (Number.isInteger(pid) && pid > 0) pids.add(pid);
|
|
133
|
-
}
|
|
134
|
-
return [...pids];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function parseUnixSsPids(output: string): number[] {
|
|
138
|
-
const pids = new Set<number>();
|
|
139
|
-
for (const match of output.matchAll(/pid=(\d+)/g)) {
|
|
140
|
-
const pid = Number.parseInt(match[1] ?? "", 10);
|
|
141
|
-
if (Number.isInteger(pid) && pid > 0) pids.add(pid);
|
|
142
|
-
}
|
|
143
|
-
return [...pids];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function findPidsByPort(
|
|
147
|
-
targetPort: number,
|
|
148
|
-
platform: PlatformName = process.platform,
|
|
149
|
-
): number[] {
|
|
150
|
-
if (!Number.isInteger(targetPort) || targetPort <= 0 || targetPort > 65_535) return [];
|
|
151
|
-
try {
|
|
152
|
-
if (platform === "win32") {
|
|
153
|
-
const output = execFileSync("netstat.exe", ["-ano", "-p", "TCP"], {
|
|
154
|
-
encoding: "utf8",
|
|
155
|
-
timeout: 5000,
|
|
156
|
-
windowsHide: true,
|
|
157
|
-
});
|
|
158
|
-
return parseWindowsNetstatPids(output, targetPort);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
const output = execFileSync("lsof", [`-ti:${String(targetPort)}`], {
|
|
163
|
-
encoding: "utf8",
|
|
164
|
-
timeout: 5000,
|
|
165
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
166
|
-
});
|
|
167
|
-
const pids = parseUnixLsofPids(output);
|
|
168
|
-
if (pids.length > 0) return pids;
|
|
169
|
-
} catch {
|
|
170
|
-
// Fall back to ss below.
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const output = execFileSync("ss", ["-tanp"], {
|
|
174
|
-
encoding: "utf8",
|
|
175
|
-
timeout: 5000,
|
|
176
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
177
|
-
});
|
|
178
|
-
return parseUnixSsPids(
|
|
179
|
-
output
|
|
180
|
-
.split(/\r?\n/)
|
|
181
|
-
.filter((line) => line.includes(`:${String(targetPort)}`))
|
|
182
|
-
.join("\n"),
|
|
183
|
-
);
|
|
184
|
-
} catch {
|
|
185
|
-
return [];
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function killPid(pid: number, platform: PlatformName = process.platform): boolean {
|
|
190
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
191
|
-
try {
|
|
192
|
-
if (platform === "win32") {
|
|
193
|
-
try {
|
|
194
|
-
execFileSync("taskkill.exe", ["/PID", String(pid), "/T", "/F"], {
|
|
195
|
-
encoding: "utf8",
|
|
196
|
-
timeout: 5000,
|
|
197
|
-
windowsHide: true,
|
|
198
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
199
|
-
});
|
|
200
|
-
return true;
|
|
201
|
-
} catch {
|
|
202
|
-
process.kill(pid, "SIGKILL");
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
process.kill(pid, "SIGKILL");
|
|
207
|
-
return true;
|
|
208
|
-
} catch {
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export type ProcessTreeSignal = "SIGTERM" | "SIGKILL";
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Signal a child process and every descendant created in its process tree.
|
|
217
|
-
*
|
|
218
|
-
* Unix callers must spawn the root with `detached: true`, which makes its PID the process-group
|
|
219
|
-
* ID. Windows has no equivalent portable Node signal, so taskkill owns descendant traversal.
|
|
220
|
-
*/
|
|
221
|
-
export function signalProcessTree(
|
|
222
|
-
pid: number,
|
|
223
|
-
signal: ProcessTreeSignal,
|
|
224
|
-
platform: PlatformName = process.platform,
|
|
225
|
-
): boolean {
|
|
226
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
227
|
-
try {
|
|
228
|
-
if (platform === "win32") {
|
|
229
|
-
const args = ["/PID", String(pid), "/T"];
|
|
230
|
-
if (signal === "SIGKILL") args.push("/F");
|
|
231
|
-
execFileSync("taskkill.exe", args, {
|
|
232
|
-
encoding: "utf8",
|
|
233
|
-
timeout: 5000,
|
|
234
|
-
windowsHide: true,
|
|
235
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
236
|
-
});
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
process.kill(-pid, signal);
|
|
240
|
-
return true;
|
|
241
|
-
} catch {
|
|
242
|
-
// Killing only the Windows root would orphan descendants and could make the runtime report a
|
|
243
|
-
// false clean shutdown. Let the caller retry taskkill with /F instead.
|
|
244
|
-
if (platform === "win32") return false;
|
|
245
|
-
try {
|
|
246
|
-
process.kill(pid, signal);
|
|
247
|
-
return true;
|
|
248
|
-
} catch {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export const platformCommandParsersForTests = {
|
|
255
|
-
parseUnixLsofPids,
|
|
256
|
-
parseUnixSsPids,
|
|
257
|
-
parseWindowsNetstatPids,
|
|
258
|
-
};
|