@open-mercato/enterprise 0.10.1-develop.8278.1.f7f8e5ab1a → 0.10.1-develop.8287.1.7313a0fe67
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/agent_orchestrator/acl.js +9 -0
- package/dist/modules/agent_orchestrator/acl.js.map +2 -2
- package/dist/modules/agent_orchestrator/ai-tools.js +37 -19
- package/dist/modules/agent_orchestrator/ai-tools.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/agent-api/agents/[id]/run/route.js +185 -0
- package/dist/modules/agent_orchestrator/api/agent-api/agents/[id]/run/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/agents/[id]/files/route.js +2 -1
- package/dist/modules/agent_orchestrator/api/agents/[id]/files/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/agents/[id]/principal/sync/route.js +110 -0
- package/dist/modules/agent_orchestrator/api/agents/[id]/principal/sync/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/agents/[id]/route.js +43 -3
- package/dist/modules/agent_orchestrator/api/agents/[id]/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/agents/[id]/run/route.js +45 -142
- package/dist/modules/agent_orchestrator/api/agents/[id]/run/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/agents/route.js +56 -2
- package/dist/modules/agent_orchestrator/api/agents/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/audit/by-instigator/[humanUserId]/route.js +47 -7
- package/dist/modules/agent_orchestrator/api/audit/by-instigator/[humanUserId]/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/context-bundles/route.js +1 -1
- package/dist/modules/agent_orchestrator/api/context-bundles/route.js.map +1 -1
- package/dist/modules/agent_orchestrator/api/eval-assertions/preview/route.js +14 -8
- package/dist/modules/agent_orchestrator/api/eval-assertions/preview/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/eval-assertions/route.js +46 -5
- package/dist/modules/agent_orchestrator/api/eval-assertions/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/eval-runs/[id]/report/route.js +91 -0
- package/dist/modules/agent_orchestrator/api/eval-runs/[id]/report/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/eval-runs/[id]/route.js +3 -2
- package/dist/modules/agent_orchestrator/api/eval-runs/[id]/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/eval-runs/compare/route.js +58 -0
- package/dist/modules/agent_orchestrator/api/eval-runs/compare/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/eval-runs/route.js +34 -14
- package/dist/modules/agent_orchestrator/api/eval-runs/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/eval-runs/trend/route.js +50 -0
- package/dist/modules/agent_orchestrator/api/eval-runs/trend/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/eval-scorers/route.js +12 -6
- package/dist/modules/agent_orchestrator/api/eval-scorers/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/eval-sets/[version]/export/route.js +132 -0
- package/dist/modules/agent_orchestrator/api/eval-sets/[version]/export/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/eval-sets/import/route.js +162 -0
- package/dist/modules/agent_orchestrator/api/eval-sets/import/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/guardrail-checks/route.js +5 -2
- package/dist/modules/agent_orchestrator/api/guardrail-checks/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/identity/agent/auth/route.js +1 -1
- package/dist/modules/agent_orchestrator/api/identity/agent/auth/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/identity/token/route.js +1 -1
- package/dist/modules/agent_orchestrator/api/identity/token/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/otel-export/settings/route.js +199 -0
- package/dist/modules/agent_orchestrator/api/otel-export/settings/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/otel-export/test/route.js +113 -0
- package/dist/modules/agent_orchestrator/api/otel-export/test/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/proposals/[id]/dispose/route.js +2 -1
- package/dist/modules/agent_orchestrator/api/proposals/[id]/dispose/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/runs/[id]/actions/route.js +164 -0
- package/dist/modules/agent_orchestrator/api/runs/[id]/actions/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/runs/[id]/artifact/route.js +92 -4
- package/dist/modules/agent_orchestrator/api/runs/[id]/artifact/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/runs/[id]/artifacts/route.js +11 -2
- package/dist/modules/agent_orchestrator/api/runs/[id]/artifacts/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/runs/[id]/compare/route.js +206 -0
- package/dist/modules/agent_orchestrator/api/runs/[id]/compare/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/api/runs/[id]/rerun/route.js +64 -8
- package/dist/modules/agent_orchestrator/api/runs/[id]/rerun/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/runs/[id]/route.js +8 -2
- package/dist/modules/agent_orchestrator/api/runs/[id]/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/runs/route.js +19 -3
- package/dist/modules/agent_orchestrator/api/runs/route.js.map +2 -2
- package/dist/modules/agent_orchestrator/api/trace-capture/settings/route.js +145 -0
- package/dist/modules/agent_orchestrator/api/trace-capture/settings/route.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/AgentAccessSection.js +110 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/AgentAccessSection.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/AgentIntegrityRulesSection.js +31 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/AgentIntegrityRulesSection.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/AssertionFormDrawer.js +9 -5
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/AssertionFormDrawer.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/ConfigurationTab.js +6 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/ConfigurationTab.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/EvalCaseDrawer.js +11 -7
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/EvalCaseDrawer.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/EvalRegressionSection.js +186 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/EvalRegressionSection.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/EvaluationTab.js +5 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/EvaluationTab.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/FilesTab.js +1 -1
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/FilesTab.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/RunEvaluationDrawer.js +91 -15
- package/dist/modules/agent_orchestrator/backend/agents/[id]/components/RunEvaluationDrawer.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/agents/[id]/page.js +23 -4
- package/dist/modules/agent_orchestrator/backend/agents/[id]/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/audit/by-instigator/[humanUserId]/page.js +17 -1
- package/dist/modules/agent_orchestrator/backend/audit/by-instigator/[humanUserId]/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/caseload/page.js +2 -0
- package/dist/modules/agent_orchestrator/backend/caseload/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/eval-cases/[id]/page.js +11 -7
- package/dist/modules/agent_orchestrator/backend/eval-cases/[id]/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/eval-runs/[id]/page.js +148 -8
- package/dist/modules/agent_orchestrator/backend/eval-runs/[id]/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/eval-runs/compare/page.js +260 -0
- package/dist/modules/agent_orchestrator/backend/eval-runs/compare/page.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/eval-runs/compare/page.meta.js +19 -0
- package/dist/modules/agent_orchestrator/backend/eval-runs/compare/page.meta.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/playground/page.js +57 -8
- package/dist/modules/agent_orchestrator/backend/playground/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/settings/otel-export/page.js +569 -0
- package/dist/modules/agent_orchestrator/backend/settings/otel-export/page.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/settings/otel-export/page.meta.js +26 -0
- package/dist/modules/agent_orchestrator/backend/settings/otel-export/page.meta.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/settings/trace-capture/page.js +423 -0
- package/dist/modules/agent_orchestrator/backend/settings/trace-capture/page.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/settings/trace-capture/page.meta.js +27 -0
- package/dist/modules/agent_orchestrator/backend/settings/trace-capture/page.meta.js.map +7 -0
- package/dist/modules/agent_orchestrator/backend/traces/[id]/page.js +52 -147
- package/dist/modules/agent_orchestrator/backend/traces/[id]/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/backend/traces/page.js +10 -3
- package/dist/modules/agent_orchestrator/backend/traces/page.js.map +2 -2
- package/dist/modules/agent_orchestrator/cli.js +596 -11
- package/dist/modules/agent_orchestrator/cli.js.map +2 -2
- package/dist/modules/agent_orchestrator/commands/dispose.js +2 -1
- package/dist/modules/agent_orchestrator/commands/dispose.js.map +2 -2
- package/dist/modules/agent_orchestrator/commands/evalRuns.js +132 -13
- package/dist/modules/agent_orchestrator/commands/evalRuns.js.map +2 -2
- package/dist/modules/agent_orchestrator/commands/evalSets.js +419 -0
- package/dist/modules/agent_orchestrator/commands/evalSets.js.map +7 -0
- package/dist/modules/agent_orchestrator/commands/index.js +3 -0
- package/dist/modules/agent_orchestrator/commands/index.js.map +2 -2
- package/dist/modules/agent_orchestrator/commands/otelExport.js +191 -0
- package/dist/modules/agent_orchestrator/commands/otelExport.js.map +7 -0
- package/dist/modules/agent_orchestrator/commands/runs.js +5 -2
- package/dist/modules/agent_orchestrator/commands/runs.js.map +2 -2
- package/dist/modules/agent_orchestrator/commands/trace.js +4 -2
- package/dist/modules/agent_orchestrator/commands/trace.js.map +2 -2
- package/dist/modules/agent_orchestrator/commands/traceCapture.js +139 -0
- package/dist/modules/agent_orchestrator/commands/traceCapture.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/ProposalCard.js +2 -0
- package/dist/modules/agent_orchestrator/components/ProposalCard.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/ProposalFacts.js +3 -2
- package/dist/modules/agent_orchestrator/components/ProposalFacts.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/ProposalOptionList.js +7 -1
- package/dist/modules/agent_orchestrator/components/ProposalOptionList.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/RunManifestCard.js +183 -0
- package/dist/modules/agent_orchestrator/components/RunManifestCard.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/SystemHealthTile.js +21 -16
- package/dist/modules/agent_orchestrator/components/SystemHealthTile.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/evalRegression.js +70 -0
- package/dist/modules/agent_orchestrator/components/evalRegression.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/evalRunTypes.js +9 -0
- package/dist/modules/agent_orchestrator/components/evalRunTypes.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/guardrailEvidence.js +48 -0
- package/dist/modules/agent_orchestrator/components/guardrailEvidence.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/health/SystemHealthPanel.js +14 -8
- package/dist/modules/agent_orchestrator/components/health/SystemHealthPanel.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/health/vocabulary.js +8 -0
- package/dist/modules/agent_orchestrator/components/health/vocabulary.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/otelExportErrorMessage.js +62 -0
- package/dist/modules/agent_orchestrator/components/otelExportErrorMessage.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/playgroundCallSettings.js +36 -0
- package/dist/modules/agent_orchestrator/components/playgroundCallSettings.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/playgroundRunError.js +4 -1
- package/dist/modules/agent_orchestrator/components/playgroundRunError.js.map +2 -2
- package/dist/modules/agent_orchestrator/components/trace/GuardrailsCard.js +176 -0
- package/dist/modules/agent_orchestrator/components/trace/GuardrailsCard.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/InspectorCard.js +23 -0
- package/dist/modules/agent_orchestrator/components/trace/InspectorCard.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/LlmStepMetadataCard.js +151 -0
- package/dist/modules/agent_orchestrator/components/trace/LlmStepMetadataCard.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/LlmStepPanels.js +291 -0
- package/dist/modules/agent_orchestrator/components/trace/LlmStepPanels.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/OffloadStatusNote.js +23 -0
- package/dist/modules/agent_orchestrator/components/trace/OffloadStatusNote.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/OtelTraceLink.js +41 -0
- package/dist/modules/agent_orchestrator/components/trace/OtelTraceLink.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/RunActionsCard.js +91 -0
- package/dist/modules/agent_orchestrator/components/trace/RunActionsCard.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/RunCompareDialog.js +314 -0
- package/dist/modules/agent_orchestrator/components/trace/RunCompareDialog.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/RunCopyMenu.js +91 -0
- package/dist/modules/agent_orchestrator/components/trace/RunCopyMenu.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/RunFilesCard.js +81 -0
- package/dist/modules/agent_orchestrator/components/trace/RunFilesCard.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/llmStepContent.js +134 -0
- package/dist/modules/agent_orchestrator/components/trace/llmStepContent.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/llmStepRows.js +89 -0
- package/dist/modules/agent_orchestrator/components/trace/llmStepRows.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/runCompareView.js +171 -0
- package/dist/modules/agent_orchestrator/components/trace/runCompareView.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/trace/structuralDiff.js +88 -0
- package/dist/modules/agent_orchestrator/components/trace/structuralDiff.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/tracesUrlFilters.js +13 -0
- package/dist/modules/agent_orchestrator/components/tracesUrlFilters.js.map +7 -0
- package/dist/modules/agent_orchestrator/components/types.js +75 -6
- package/dist/modules/agent_orchestrator/components/types.js.map +2 -2
- package/dist/modules/agent_orchestrator/data/enrichers.js +42 -0
- package/dist/modules/agent_orchestrator/data/enrichers.js.map +7 -0
- package/dist/modules/agent_orchestrator/data/entities.js.map +2 -2
- package/dist/modules/agent_orchestrator/data/validators.js +544 -11
- package/dist/modules/agent_orchestrator/data/validators.js.map +2 -2
- package/dist/modules/agent_orchestrator/di.js +18 -0
- package/dist/modules/agent_orchestrator/di.js.map +2 -2
- package/dist/modules/agent_orchestrator/events.js +1 -0
- package/dist/modules/agent_orchestrator/events.js.map +2 -2
- package/dist/modules/agent_orchestrator/generated/file-agents.generated.js.map +2 -2
- package/dist/modules/agent_orchestrator/i18n/de.json +467 -0
- package/dist/modules/agent_orchestrator/i18n/en.json +467 -0
- package/dist/modules/agent_orchestrator/i18n/es.json +467 -0
- package/dist/modules/agent_orchestrator/i18n/ko.json +467 -0
- package/dist/modules/agent_orchestrator/i18n/pl.json +467 -0
- package/dist/modules/agent_orchestrator/index.js +31 -2
- package/dist/modules/agent_orchestrator/index.js.map +2 -2
- package/dist/modules/agent_orchestrator/integration.js +57 -0
- package/dist/modules/agent_orchestrator/integration.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/access/agentInvokeAccess.js +99 -0
- package/dist/modules/agent_orchestrator/lib/access/agentInvokeAccess.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/access/invokeDenial.js +44 -0
- package/dist/modules/agent_orchestrator/lib/access/invokeDenial.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/context/contextResolver.js +83 -8
- package/dist/modules/agent_orchestrator/lib/context/contextResolver.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/context/packer.js +2 -1
- package/dist/modules/agent_orchestrator/lib/context/packer.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/context/registry.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/context/retrievalSource.js +1 -0
- package/dist/modules/agent_orchestrator/lib/context/retrievalSource.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/crudCache.js +9 -1
- package/dist/modules/agent_orchestrator/lib/crudCache.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/disposition/dispositionService.js +22 -4
- package/dist/modules/agent_orchestrator/lib/disposition/dispositionService.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/disposition/proposalAuditCorrelation.js +17 -0
- package/dist/modules/agent_orchestrator/lib/disposition/proposalAuditCorrelation.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/canonicalInputKey.js +6 -3
- package/dist/modules/agent_orchestrator/lib/eval/canonicalInputKey.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/evalGate.js +14 -5
- package/dist/modules/agent_orchestrator/lib/eval/evalGate.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/evalReplayService.js +415 -83
- package/dist/modules/agent_orchestrator/lib/eval/evalReplayService.js.map +3 -3
- package/dist/modules/agent_orchestrator/lib/eval/evalRunSettings.js +127 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalRunSettings.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalRuntimeService.js +4 -2
- package/dist/modules/agent_orchestrator/lib/eval/evalRuntimeService.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/evalSetAccess.js +20 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetAccess.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetFile.js +448 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetFile.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetFileIo.js +83 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetFileIo.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetYaml.js +147 -0
- package/dist/modules/agent_orchestrator/lib/eval/evalSetYaml.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/fixtureFileRead.js +23 -0
- package/dist/modules/agent_orchestrator/lib/eval/fixtureFileRead.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/llmJudge.js +42 -18
- package/dist/modules/agent_orchestrator/lib/eval/llmJudge.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/manifest.js +418 -0
- package/dist/modules/agent_orchestrator/lib/eval/manifest.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/manifestCache.js +51 -0
- package/dist/modules/agent_orchestrator/lib/eval/manifestCache.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/modelFixtures.js +113 -0
- package/dist/modules/agent_orchestrator/lib/eval/modelFixtures.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/modelReplay.js +180 -0
- package/dist/modules/agent_orchestrator/lib/eval/modelReplay.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/projectRunView.js +21 -2
- package/dist/modules/agent_orchestrator/lib/eval/projectRunView.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/registry/agent.js +109 -2
- package/dist/modules/agent_orchestrator/lib/eval/registry/agent.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/registry/index.js.map +1 -1
- package/dist/modules/agent_orchestrator/lib/eval/registry/judge.js +14 -4
- package/dist/modules/agent_orchestrator/lib/eval/registry/judge.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/regression/buildEvalTrend.js +111 -0
- package/dist/modules/agent_orchestrator/lib/eval/regression/buildEvalTrend.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/regression/compareSuiteRuns.js +228 -0
- package/dist/modules/agent_orchestrator/lib/eval/regression/compareSuiteRuns.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/regression/suiteAgentVersions.js +18 -0
- package/dist/modules/agent_orchestrator/lib/eval/regression/suiteAgentVersions.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/buildEvalReport.js +319 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/buildEvalReport.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/errorReport.js +74 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/errorReport.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/flaky.js +44 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/flaky.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/renderJunit.js +210 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/renderJunit.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/renderMarkdown.js +341 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/renderMarkdown.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/reportEnvironment.js +96 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/reportEnvironment.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/reportSchema.js +177 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/reportSchema.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/suiteAggregation.js +71 -0
- package/dist/modules/agent_orchestrator/lib/eval/report/suiteAggregation.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/rubrics/builtins.js +71 -0
- package/dist/modules/agent_orchestrator/lib/eval/rubrics/builtins.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/rubrics/index.js +132 -0
- package/dist/modules/agent_orchestrator/lib/eval/rubrics/index.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/scorers.js +2 -1
- package/dist/modules/agent_orchestrator/lib/eval/scorers.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/eval/toolFixtures.js +322 -0
- package/dist/modules/agent_orchestrator/lib/eval/toolFixtures.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/toolMocks.js +155 -0
- package/dist/modules/agent_orchestrator/lib/eval/toolMocks.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/eval/types.js +3 -1
- package/dist/modules/agent_orchestrator/lib/eval/types.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/guardrails/groundingSets.js +3 -3
- package/dist/modules/agent_orchestrator/lib/guardrails/groundingSets.js.map +1 -1
- package/dist/modules/agent_orchestrator/lib/guardrails/guardrailService.js +26 -2
- package/dist/modules/agent_orchestrator/lib/guardrails/guardrailService.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/declaration.js +160 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/declaration.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/integritySets.js +95 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/integritySets.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/normalize.js +212 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/normalize.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/paths.js +226 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/paths.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/pipeline.js +198 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/pipeline.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/reviewRequestedEvent.js +46 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/reviewRequestedEvent.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/reviewRequestedRuns.js +25 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/reviewRequestedRuns.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/ruleList.js +17 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/ruleList.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/abstainOrReview.js +182 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/abstainOrReview.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/custom.js +137 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/custom.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/evidenceQuote.js +134 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/evidenceQuote.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/referenceExists.js +156 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/referenceExists.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/toolConsulted.js +151 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/rules/toolConsulted.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/summary.js +98 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/summary.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/types.js +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/types.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/untrustedInput.js +68 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/integrity/untrustedInput.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/syncGroundingSets.js +3 -0
- package/dist/modules/agent_orchestrator/lib/guardrails/syncGroundingSets.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/identity/actionAgentAttribution.js +110 -0
- package/dist/modules/agent_orchestrator/lib/identity/actionAgentAttribution.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/agentNoBypassSubscriber.js +96 -2
- package/dist/modules/agent_orchestrator/lib/identity/agentNoBypassSubscriber.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/identity/agentPrincipalService.js +54 -126
- package/dist/modules/agent_orchestrator/lib/identity/agentPrincipalService.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/identity/agentPrincipalSummary.js +61 -0
- package/dist/modules/agent_orchestrator/lib/identity/agentPrincipalSummary.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/agentTokenService.js +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/agentTokenService.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/identity/agentWriteScope.js +27 -3
- package/dist/modules/agent_orchestrator/lib/identity/agentWriteScope.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/identity/auditEntryLinks.js +55 -0
- package/dist/modules/agent_orchestrator/lib/identity/auditEntryLinks.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/principalDeniedTools.js +45 -0
- package/dist/modules/agent_orchestrator/lib/identity/principalDeniedTools.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/principalSyncCommand.js +96 -0
- package/dist/modules/agent_orchestrator/lib/identity/principalSyncCommand.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/resolveEffectiveToolAcl.js +66 -0
- package/dist/modules/agent_orchestrator/lib/identity/resolveEffectiveToolAcl.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/resolveRunAsForAgent.js +69 -0
- package/dist/modules/agent_orchestrator/lib/identity/resolveRunAsForAgent.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/runActionCorrelation.js +40 -0
- package/dist/modules/agent_orchestrator/lib/identity/runActionCorrelation.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/syncAgentPrincipals.js +185 -0
- package/dist/modules/agent_orchestrator/lib/identity/syncAgentPrincipals.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/identity/toolAclGrantIntersection.js +8 -0
- package/dist/modules/agent_orchestrator/lib/identity/toolAclGrantIntersection.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/queue.js +4 -0
- package/dist/modules/agent_orchestrator/lib/queue.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/activeAgent.js +26 -0
- package/dist/modules/agent_orchestrator/lib/runtime/activeAgent.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/agentResultPayload.js +9 -0
- package/dist/modules/agent_orchestrator/lib/runtime/agentResultPayload.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/agentRunHttp.js +231 -0
- package/dist/modules/agent_orchestrator/lib/runtime/agentRunHttp.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/agentRunSessionStore.js +3 -2
- package/dist/modules/agent_orchestrator/lib/runtime/agentRunSessionStore.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/agentRuntime.js +22 -6
- package/dist/modules/agent_orchestrator/lib/runtime/agentRuntime.js.map +3 -3
- package/dist/modules/agent_orchestrator/lib/runtime/aiAgentRunDispatcher.js +113 -0
- package/dist/modules/agent_orchestrator/lib/runtime/aiAgentRunDispatcher.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/artifactCollector.js +79 -16
- package/dist/modules/agent_orchestrator/lib/runtime/artifactCollector.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/artifactFileStore.js +27 -13
- package/dist/modules/agent_orchestrator/lib/runtime/artifactFileStore.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/errors.js +58 -1
- package/dist/modules/agent_orchestrator/lib/runtime/errors.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/integrityRunSupport.js +51 -0
- package/dist/modules/agent_orchestrator/lib/runtime/integrityRunSupport.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/invokeAgentForWorkflow.js +62 -17
- package/dist/modules/agent_orchestrator/lib/runtime/invokeAgentForWorkflow.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/mcpToolObservationBinder.js +124 -0
- package/dist/modules/agent_orchestrator/lib/runtime/mcpToolObservationBinder.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/modelPricing.js +33 -11
- package/dist/modules/agent_orchestrator/lib/runtime/modelPricing.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/nativeAgentRunner.js +329 -88
- package/dist/modules/agent_orchestrator/lib/runtime/nativeAgentRunner.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/nativeContentOffload.js +104 -0
- package/dist/modules/agent_orchestrator/lib/runtime/nativeContentOffload.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/nativeModelCallRecorder.js +136 -0
- package/dist/modules/agent_orchestrator/lib/runtime/nativeModelCallRecorder.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/nativeTraceCapture.js +220 -18
- package/dist/modules/agent_orchestrator/lib/runtime/nativeTraceCapture.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/openCodeAgentRunner.js +323 -18
- package/dist/modules/agent_orchestrator/lib/runtime/openCodeAgentRunner.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/openCodeMessageTrace.js +261 -0
- package/dist/modules/agent_orchestrator/lib/runtime/openCodeMessageTrace.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/runtime/persistence.js +27 -2
- package/dist/modules/agent_orchestrator/lib/runtime/persistence.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/runContext.js +17 -2
- package/dist/modules/agent_orchestrator/lib/runtime/runContext.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/runtime/structuredOutputFailure.js +52 -0
- package/dist/modules/agent_orchestrator/lib/runtime/structuredOutputFailure.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/sdk/agentDefinitionSource.js +8 -0
- package/dist/modules/agent_orchestrator/lib/sdk/agentDefinitionSource.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/sdk/agentMarkdown.js +2 -1
- package/dist/modules/agent_orchestrator/lib/sdk/agentMarkdown.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/sdk/defineAgent.js +143 -9
- package/dist/modules/agent_orchestrator/lib/sdk/defineAgent.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/sdk/defineFileAgent.js +4 -1
- package/dist/modules/agent_orchestrator/lib/sdk/defineFileAgent.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/sdk/fileAgentGovernance.js +41 -0
- package/dist/modules/agent_orchestrator/lib/sdk/fileAgentGovernance.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/sdk/fileAgentNative.js +168 -0
- package/dist/modules/agent_orchestrator/lib/sdk/fileAgentNative.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/sdk/integrityCheckers.js +29 -0
- package/dist/modules/agent_orchestrator/lib/sdk/integrityCheckers.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/sdk/strictOutcomeSchema.js +41 -0
- package/dist/modules/agent_orchestrator/lib/sdk/strictOutcomeSchema.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/systemHealth.js +30 -0
- package/dist/modules/agent_orchestrator/lib/systemHealth.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/trace/artifactCaptureStatus.js +44 -0
- package/dist/modules/agent_orchestrator/lib/trace/artifactCaptureStatus.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/artifactStore.js +68 -20
- package/dist/modules/agent_orchestrator/lib/trace/artifactStore.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/trace/capturePolicy.js +157 -0
- package/dist/modules/agent_orchestrator/lib/trace/capturePolicy.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/captureSettingsForm.js +149 -0
- package/dist/modules/agent_orchestrator/lib/trace/captureSettingsForm.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentArtifactAccess.js +97 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentArtifactAccess.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentCapture.js +273 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentCapture.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentRetention.js +190 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentRetention.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentRetentionSchedule.js +53 -0
- package/dist/modules/agent_orchestrator/lib/trace/contentRetentionSchedule.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/definitionHash.js +63 -0
- package/dist/modules/agent_orchestrator/lib/trace/definitionHash.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/genAiAttributes.js +340 -0
- package/dist/modules/agent_orchestrator/lib/trace/genAiAttributes.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/ingestContentCapture.js +29 -0
- package/dist/modules/agent_orchestrator/lib/trace/ingestContentCapture.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/ingestLlmAttributes.js +233 -0
- package/dist/modules/agent_orchestrator/lib/trace/ingestLlmAttributes.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportBackfill.js +160 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportBackfill.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportDestination.js +104 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportDestination.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportHealth.js +77 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportHealth.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportIntegration.js +74 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportIntegration.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportIntegrationIds.js +15 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportIntegrationIds.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportJob.js +296 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportJob.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportSettings.js +280 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportSettings.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportSettingsForm.js +144 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/exportSettingsForm.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/finishedProcessExport.js +30 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/finishedProcessExport.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/genAiContent.js +316 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/genAiContent.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/ids.js +65 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/ids.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/loadRunExportBundle.js +297 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/loadRunExportBundle.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/loadRunExportContent.js +183 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/loadRunExportContent.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/mapAgentRunToOtlp.js +457 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/mapAgentRunToOtlp.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otelAttributes.js +108 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otelAttributes.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpErrorCodes.js +10 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpErrorCodes.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpHttpClient.js +171 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpHttpClient.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpJson.js +166 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpJson.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpProto.js +184 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpProto.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpRequestBody.js +15 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/otlpRequestBody.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/sendTestSpan.js +57 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/sendTestSpan.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/tenantEndpoint.js +31 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/tenantEndpoint.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/traceLink.js +56 -0
- package/dist/modules/agent_orchestrator/lib/trace/otel/traceLink.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/redactStrings.js +175 -0
- package/dist/modules/agent_orchestrator/lib/trace/redactStrings.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/runCompare.js +215 -0
- package/dist/modules/agent_orchestrator/lib/trace/runCompare.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/runManifest.js +135 -0
- package/dist/modules/agent_orchestrator/lib/trace/runManifest.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/runManifestEntry.js +136 -0
- package/dist/modules/agent_orchestrator/lib/trace/runManifestEntry.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/runManifestView.js +55 -0
- package/dist/modules/agent_orchestrator/lib/trace/runManifestView.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/sealArtifactPayload.js +19 -0
- package/dist/modules/agent_orchestrator/lib/trace/sealArtifactPayload.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/toolObservation.js +159 -0
- package/dist/modules/agent_orchestrator/lib/trace/toolObservation.js.map +7 -0
- package/dist/modules/agent_orchestrator/lib/trace/traceIngestionService.js +92 -6
- package/dist/modules/agent_orchestrator/lib/trace/traceIngestionService.js.map +2 -2
- package/dist/modules/agent_orchestrator/lib/webSearch/tools.js +2 -7
- package/dist/modules/agent_orchestrator/lib/webSearch/tools.js.map +2 -2
- package/dist/modules/agent_orchestrator/notifications.js +16 -0
- package/dist/modules/agent_orchestrator/notifications.js.map +2 -2
- package/dist/modules/agent_orchestrator/setup.js +67 -8
- package/dist/modules/agent_orchestrator/setup.js.map +2 -2
- package/dist/modules/agent_orchestrator/subscribers/otel-export-run-completed.js +17 -0
- package/dist/modules/agent_orchestrator/subscribers/otel-export-run-completed.js.map +7 -0
- package/dist/modules/agent_orchestrator/subscribers/otel-export-run-ingested.js +17 -0
- package/dist/modules/agent_orchestrator/subscribers/otel-export-run-ingested.js.map +7 -0
- package/dist/modules/agent_orchestrator/subscribers/process-workflow-cancelled.js +4 -1
- package/dist/modules/agent_orchestrator/subscribers/process-workflow-cancelled.js.map +2 -2
- package/dist/modules/agent_orchestrator/subscribers/process-workflow-completed.js +4 -1
- package/dist/modules/agent_orchestrator/subscribers/process-workflow-completed.js.map +2 -2
- package/dist/modules/agent_orchestrator/subscribers/process-workflow-failed.js +4 -1
- package/dist/modules/agent_orchestrator/subscribers/process-workflow-failed.js.map +2 -2
- package/dist/modules/agent_orchestrator/subscribers/run-review-requested-notification.js +102 -0
- package/dist/modules/agent_orchestrator/subscribers/run-review-requested-notification.js.map +7 -0
- package/dist/modules/agent_orchestrator/widgets/injection/audit-proposal-link/widget.js +35 -0
- package/dist/modules/agent_orchestrator/widgets/injection/audit-proposal-link/widget.js.map +7 -0
- package/dist/modules/agent_orchestrator/widgets/injection/audit-run-link/widget.js +27 -0
- package/dist/modules/agent_orchestrator/widgets/injection/audit-run-link/widget.js.map +7 -0
- package/dist/modules/agent_orchestrator/widgets/injection-table.js +11 -0
- package/dist/modules/agent_orchestrator/widgets/injection-table.js.map +2 -2
- package/dist/modules/agent_orchestrator/workers/otel-export.js +24 -0
- package/dist/modules/agent_orchestrator/workers/otel-export.js.map +7 -0
- package/dist/modules/agent_orchestrator/workers/trace-content-retention.js +38 -0
- package/dist/modules/agent_orchestrator/workers/trace-content-retention.js.map +7 -0
- package/jest.config.cjs +1 -0
- package/package.json +11 -10
- package/src/modules/agent_orchestrator/.ai/skills/om-create-opencode-agent/SKILL.md +11 -0
- package/src/modules/agent_orchestrator/AGENTS.md +54 -9
- package/src/modules/agent_orchestrator/acl.ts +9 -0
- package/src/modules/agent_orchestrator/ai-tools.ts +48 -31
- package/src/modules/agent_orchestrator/api/agent-api/agents/[id]/run/route.ts +217 -0
- package/src/modules/agent_orchestrator/api/agents/[id]/files/route.ts +4 -3
- package/src/modules/agent_orchestrator/api/agents/[id]/principal/sync/route.ts +125 -0
- package/src/modules/agent_orchestrator/api/agents/[id]/route.ts +51 -2
- package/src/modules/agent_orchestrator/api/agents/[id]/run/route.ts +49 -212
- package/src/modules/agent_orchestrator/api/agents/route.ts +78 -17
- package/src/modules/agent_orchestrator/api/audit/by-instigator/[humanUserId]/route.ts +50 -4
- package/src/modules/agent_orchestrator/api/context-bundles/route.ts +1 -1
- package/src/modules/agent_orchestrator/api/eval-assertions/preview/route.ts +16 -8
- package/src/modules/agent_orchestrator/api/eval-assertions/route.ts +55 -5
- package/src/modules/agent_orchestrator/api/eval-runs/[id]/report/route.ts +107 -0
- package/src/modules/agent_orchestrator/api/eval-runs/[id]/route.ts +3 -2
- package/src/modules/agent_orchestrator/api/eval-runs/compare/route.ts +67 -0
- package/src/modules/agent_orchestrator/api/eval-runs/route.ts +33 -13
- package/src/modules/agent_orchestrator/api/eval-runs/trend/route.ts +58 -0
- package/src/modules/agent_orchestrator/api/eval-scorers/route.ts +21 -6
- package/src/modules/agent_orchestrator/api/eval-sets/[version]/export/route.ts +149 -0
- package/src/modules/agent_orchestrator/api/eval-sets/import/route.ts +186 -0
- package/src/modules/agent_orchestrator/api/guardrail-checks/route.ts +4 -1
- package/src/modules/agent_orchestrator/api/identity/agent/auth/route.ts +1 -1
- package/src/modules/agent_orchestrator/api/identity/token/route.ts +1 -1
- package/src/modules/agent_orchestrator/api/otel-export/settings/route.ts +239 -0
- package/src/modules/agent_orchestrator/api/otel-export/test/route.ts +129 -0
- package/src/modules/agent_orchestrator/api/proposals/[id]/dispose/route.ts +1 -0
- package/src/modules/agent_orchestrator/api/runs/[id]/actions/route.ts +212 -0
- package/src/modules/agent_orchestrator/api/runs/[id]/artifact/route.ts +133 -5
- package/src/modules/agent_orchestrator/api/runs/[id]/artifacts/route.ts +11 -2
- package/src/modules/agent_orchestrator/api/runs/[id]/compare/route.ts +270 -0
- package/src/modules/agent_orchestrator/api/runs/[id]/rerun/route.ts +64 -5
- package/src/modules/agent_orchestrator/api/runs/[id]/route.ts +7 -1
- package/src/modules/agent_orchestrator/api/runs/route.ts +23 -3
- package/src/modules/agent_orchestrator/api/trace-capture/settings/route.ts +172 -0
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/AgentAccessSection.tsx +156 -0
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/AgentIntegrityRulesSection.tsx +46 -0
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/AssertionFormDrawer.tsx +15 -6
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/ConfigurationTab.tsx +10 -3
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/EvalCaseDrawer.tsx +14 -12
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/EvalRegressionSection.tsx +261 -0
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/EvaluationTab.tsx +9 -1
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/FilesTab.tsx +5 -1
- package/src/modules/agent_orchestrator/backend/agents/[id]/components/RunEvaluationDrawer.tsx +116 -14
- package/src/modules/agent_orchestrator/backend/agents/[id]/page.tsx +26 -8
- package/src/modules/agent_orchestrator/backend/audit/by-instigator/[humanUserId]/page.tsx +37 -0
- package/src/modules/agent_orchestrator/backend/caseload/page.tsx +2 -0
- package/src/modules/agent_orchestrator/backend/eval-cases/[id]/page.tsx +14 -12
- package/src/modules/agent_orchestrator/backend/eval-runs/[id]/page.tsx +194 -17
- package/src/modules/agent_orchestrator/backend/eval-runs/compare/page.meta.ts +15 -0
- package/src/modules/agent_orchestrator/backend/eval-runs/compare/page.tsx +388 -0
- package/src/modules/agent_orchestrator/backend/playground/page.tsx +77 -6
- package/src/modules/agent_orchestrator/backend/settings/otel-export/page.meta.ts +24 -0
- package/src/modules/agent_orchestrator/backend/settings/otel-export/page.tsx +752 -0
- package/src/modules/agent_orchestrator/backend/settings/trace-capture/page.meta.ts +25 -0
- package/src/modules/agent_orchestrator/backend/settings/trace-capture/page.tsx +558 -0
- package/src/modules/agent_orchestrator/backend/traces/[id]/page.tsx +45 -204
- package/src/modules/agent_orchestrator/backend/traces/page.tsx +11 -4
- package/src/modules/agent_orchestrator/cli.ts +733 -14
- package/src/modules/agent_orchestrator/commands/dispose.ts +2 -1
- package/src/modules/agent_orchestrator/commands/evalRuns.ts +159 -15
- package/src/modules/agent_orchestrator/commands/evalSets.ts +538 -0
- package/src/modules/agent_orchestrator/commands/index.ts +3 -0
- package/src/modules/agent_orchestrator/commands/otelExport.ts +281 -0
- package/src/modules/agent_orchestrator/commands/runs.ts +3 -0
- package/src/modules/agent_orchestrator/commands/trace.ts +4 -2
- package/src/modules/agent_orchestrator/commands/traceCapture.ts +201 -0
- package/src/modules/agent_orchestrator/components/ProposalCard.tsx +2 -0
- package/src/modules/agent_orchestrator/components/ProposalFacts.tsx +5 -2
- package/src/modules/agent_orchestrator/components/ProposalOptionList.tsx +16 -1
- package/src/modules/agent_orchestrator/components/RunManifestCard.tsx +240 -0
- package/src/modules/agent_orchestrator/components/SystemHealthTile.tsx +22 -16
- package/src/modules/agent_orchestrator/components/evalRegression.tsx +80 -0
- package/src/modules/agent_orchestrator/components/evalRunTypes.ts +14 -0
- package/src/modules/agent_orchestrator/components/guardrailEvidence.ts +76 -0
- package/src/modules/agent_orchestrator/components/health/SystemHealthPanel.tsx +18 -9
- package/src/modules/agent_orchestrator/components/health/vocabulary.ts +9 -1
- package/src/modules/agent_orchestrator/components/otelExportErrorMessage.ts +67 -0
- package/src/modules/agent_orchestrator/components/playgroundCallSettings.ts +61 -0
- package/src/modules/agent_orchestrator/components/playgroundRunError.ts +3 -0
- package/src/modules/agent_orchestrator/components/trace/GuardrailsCard.tsx +258 -0
- package/src/modules/agent_orchestrator/components/trace/InspectorCard.tsx +32 -0
- package/src/modules/agent_orchestrator/components/trace/LlmStepMetadataCard.tsx +227 -0
- package/src/modules/agent_orchestrator/components/trace/LlmStepPanels.tsx +402 -0
- package/src/modules/agent_orchestrator/components/trace/OffloadStatusNote.tsx +34 -0
- package/src/modules/agent_orchestrator/components/trace/OtelTraceLink.tsx +51 -0
- package/src/modules/agent_orchestrator/components/trace/RunActionsCard.tsx +137 -0
- package/src/modules/agent_orchestrator/components/trace/RunCompareDialog.tsx +437 -0
- package/src/modules/agent_orchestrator/components/trace/RunCopyMenu.tsx +103 -0
- package/src/modules/agent_orchestrator/components/trace/RunFilesCard.tsx +120 -0
- package/src/modules/agent_orchestrator/components/trace/llmStepContent.ts +194 -0
- package/src/modules/agent_orchestrator/components/trace/llmStepRows.ts +119 -0
- package/src/modules/agent_orchestrator/components/trace/runCompareView.ts +224 -0
- package/src/modules/agent_orchestrator/components/trace/structuralDiff.ts +107 -0
- package/src/modules/agent_orchestrator/components/tracesUrlFilters.ts +22 -0
- package/src/modules/agent_orchestrator/components/types.ts +144 -3
- package/src/modules/agent_orchestrator/data/enrichers.ts +65 -0
- package/src/modules/agent_orchestrator/data/entities.ts +9 -4
- package/src/modules/agent_orchestrator/data/validators.ts +756 -9
- package/src/modules/agent_orchestrator/di.ts +18 -0
- package/src/modules/agent_orchestrator/events.ts +1 -0
- package/src/modules/agent_orchestrator/generated/file-agents.generated.ts +22 -3
- package/src/modules/agent_orchestrator/i18n/de.json +467 -0
- package/src/modules/agent_orchestrator/i18n/en.json +467 -0
- package/src/modules/agent_orchestrator/i18n/es.json +467 -0
- package/src/modules/agent_orchestrator/i18n/ko.json +467 -0
- package/src/modules/agent_orchestrator/i18n/pl.json +467 -0
- package/src/modules/agent_orchestrator/index.ts +25 -1
- package/src/modules/agent_orchestrator/integration.ts +53 -0
- package/src/modules/agent_orchestrator/lib/access/agentInvokeAccess.ts +154 -0
- package/src/modules/agent_orchestrator/lib/access/invokeDenial.ts +62 -0
- package/src/modules/agent_orchestrator/lib/context/contextResolver.ts +126 -9
- package/src/modules/agent_orchestrator/lib/context/packer.ts +1 -0
- package/src/modules/agent_orchestrator/lib/context/registry.ts +2 -0
- package/src/modules/agent_orchestrator/lib/context/retrievalSource.ts +1 -1
- package/src/modules/agent_orchestrator/lib/crudCache.ts +18 -1
- package/src/modules/agent_orchestrator/lib/disposition/dispositionService.ts +27 -3
- package/src/modules/agent_orchestrator/lib/disposition/proposalAuditCorrelation.ts +29 -0
- package/src/modules/agent_orchestrator/lib/eval/canonicalInputKey.ts +5 -2
- package/src/modules/agent_orchestrator/lib/eval/evalGate.ts +49 -9
- package/src/modules/agent_orchestrator/lib/eval/evalReplayService.ts +592 -111
- package/src/modules/agent_orchestrator/lib/eval/evalRunSettings.ts +178 -0
- package/src/modules/agent_orchestrator/lib/eval/evalRuntimeService.ts +4 -1
- package/src/modules/agent_orchestrator/lib/eval/evalSetAccess.ts +28 -0
- package/src/modules/agent_orchestrator/lib/eval/evalSetFile.ts +526 -0
- package/src/modules/agent_orchestrator/lib/eval/evalSetFileIo.ts +120 -0
- package/src/modules/agent_orchestrator/lib/eval/evalSetYaml.ts +172 -0
- package/src/modules/agent_orchestrator/lib/eval/fixtureFileRead.ts +20 -0
- package/src/modules/agent_orchestrator/lib/eval/llmJudge.ts +79 -17
- package/src/modules/agent_orchestrator/lib/eval/manifest.ts +538 -0
- package/src/modules/agent_orchestrator/lib/eval/manifestCache.ts +69 -0
- package/src/modules/agent_orchestrator/lib/eval/modelFixtures.ts +129 -0
- package/src/modules/agent_orchestrator/lib/eval/modelReplay.ts +177 -0
- package/src/modules/agent_orchestrator/lib/eval/projectRunView.ts +31 -2
- package/src/modules/agent_orchestrator/lib/eval/registry/agent.ts +130 -2
- package/src/modules/agent_orchestrator/lib/eval/registry/index.ts +1 -1
- package/src/modules/agent_orchestrator/lib/eval/registry/judge.ts +16 -3
- package/src/modules/agent_orchestrator/lib/eval/regression/buildEvalTrend.ts +191 -0
- package/src/modules/agent_orchestrator/lib/eval/regression/compareSuiteRuns.ts +339 -0
- package/src/modules/agent_orchestrator/lib/eval/regression/suiteAgentVersions.ts +57 -0
- package/src/modules/agent_orchestrator/lib/eval/report/buildEvalReport.ts +408 -0
- package/src/modules/agent_orchestrator/lib/eval/report/errorReport.ts +91 -0
- package/src/modules/agent_orchestrator/lib/eval/report/flaky.ts +69 -0
- package/src/modules/agent_orchestrator/lib/eval/report/renderJunit.ts +246 -0
- package/src/modules/agent_orchestrator/lib/eval/report/renderMarkdown.ts +385 -0
- package/src/modules/agent_orchestrator/lib/eval/report/reportEnvironment.ts +132 -0
- package/src/modules/agent_orchestrator/lib/eval/report/reportSchema.ts +188 -0
- package/src/modules/agent_orchestrator/lib/eval/report/suiteAggregation.ts +97 -0
- package/src/modules/agent_orchestrator/lib/eval/rubrics/builtins.ts +86 -0
- package/src/modules/agent_orchestrator/lib/eval/rubrics/index.ts +180 -0
- package/src/modules/agent_orchestrator/lib/eval/scorers.ts +1 -0
- package/src/modules/agent_orchestrator/lib/eval/toolFixtures.ts +433 -0
- package/src/modules/agent_orchestrator/lib/eval/toolMocks.ts +251 -0
- package/src/modules/agent_orchestrator/lib/eval/types.ts +14 -1
- package/src/modules/agent_orchestrator/lib/guardrails/groundingSets.ts +3 -3
- package/src/modules/agent_orchestrator/lib/guardrails/guardrailService.ts +38 -2
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/declaration.ts +226 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/integritySets.ts +136 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/normalize.ts +269 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/paths.ts +294 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/pipeline.ts +280 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/reviewRequestedEvent.ts +69 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/reviewRequestedRuns.ts +92 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/ruleList.ts +24 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/rules/abstainOrReview.ts +218 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/rules/custom.ts +176 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/rules/evidenceQuote.ts +165 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/rules/referenceExists.ts +221 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/rules/toolConsulted.ts +219 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/summary.ts +142 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/types.ts +78 -0
- package/src/modules/agent_orchestrator/lib/guardrails/integrity/untrustedInput.ts +94 -0
- package/src/modules/agent_orchestrator/lib/guardrails/syncGroundingSets.ts +5 -1
- package/src/modules/agent_orchestrator/lib/identity/actionAgentAttribution.ts +190 -0
- package/src/modules/agent_orchestrator/lib/identity/agentNoBypassSubscriber.ts +144 -4
- package/src/modules/agent_orchestrator/lib/identity/agentPrincipalService.ts +81 -171
- package/src/modules/agent_orchestrator/lib/identity/agentPrincipalSummary.ts +91 -0
- package/src/modules/agent_orchestrator/lib/identity/agentTokenService.ts +8 -0
- package/src/modules/agent_orchestrator/lib/identity/agentWriteScope.ts +49 -2
- package/src/modules/agent_orchestrator/lib/identity/auditEntryLinks.ts +73 -0
- package/src/modules/agent_orchestrator/lib/identity/principalDeniedTools.ts +71 -0
- package/src/modules/agent_orchestrator/lib/identity/principalSyncCommand.ts +166 -0
- package/src/modules/agent_orchestrator/lib/identity/resolveEffectiveToolAcl.ts +106 -0
- package/src/modules/agent_orchestrator/lib/identity/resolveRunAsForAgent.ts +110 -0
- package/src/modules/agent_orchestrator/lib/identity/runActionCorrelation.ts +32 -0
- package/src/modules/agent_orchestrator/lib/identity/syncAgentPrincipals.ts +267 -0
- package/src/modules/agent_orchestrator/lib/identity/toolAclGrantIntersection.ts +14 -0
- package/src/modules/agent_orchestrator/lib/queue.ts +19 -0
- package/src/modules/agent_orchestrator/lib/runtime/activeAgent.ts +39 -0
- package/src/modules/agent_orchestrator/lib/runtime/agentResultPayload.ts +14 -0
- package/src/modules/agent_orchestrator/lib/runtime/agentRunHttp.ts +348 -0
- package/src/modules/agent_orchestrator/lib/runtime/agentRunSessionStore.ts +3 -2
- package/src/modules/agent_orchestrator/lib/runtime/agentRuntime.ts +20 -6
- package/src/modules/agent_orchestrator/lib/runtime/aiAgentRunDispatcher.ts +159 -0
- package/src/modules/agent_orchestrator/lib/runtime/artifactCollector.ts +94 -15
- package/src/modules/agent_orchestrator/lib/runtime/artifactFileStore.ts +54 -24
- package/src/modules/agent_orchestrator/lib/runtime/errors.ts +93 -1
- package/src/modules/agent_orchestrator/lib/runtime/integrityRunSupport.ts +75 -0
- package/src/modules/agent_orchestrator/lib/runtime/invokeAgentForWorkflow.ts +99 -16
- package/src/modules/agent_orchestrator/lib/runtime/mcpToolObservationBinder.ts +172 -0
- package/src/modules/agent_orchestrator/lib/runtime/modelPricing.ts +49 -11
- package/src/modules/agent_orchestrator/lib/runtime/nativeAgentRunner.ts +397 -112
- package/src/modules/agent_orchestrator/lib/runtime/nativeContentOffload.ts +170 -0
- package/src/modules/agent_orchestrator/lib/runtime/nativeModelCallRecorder.ts +221 -0
- package/src/modules/agent_orchestrator/lib/runtime/nativeTraceCapture.ts +309 -24
- package/src/modules/agent_orchestrator/lib/runtime/openCodeAgentRunner.ts +406 -15
- package/src/modules/agent_orchestrator/lib/runtime/openCodeMessageTrace.ts +375 -0
- package/src/modules/agent_orchestrator/lib/runtime/persistence.ts +79 -2
- package/src/modules/agent_orchestrator/lib/runtime/runContext.ts +44 -2
- package/src/modules/agent_orchestrator/lib/runtime/structuredOutputFailure.ts +81 -0
- package/src/modules/agent_orchestrator/lib/sdk/agentDefinitionSource.ts +13 -0
- package/src/modules/agent_orchestrator/lib/sdk/agentMarkdown.ts +6 -2
- package/src/modules/agent_orchestrator/lib/sdk/defineAgent.ts +307 -34
- package/src/modules/agent_orchestrator/lib/sdk/defineFileAgent.ts +3 -0
- package/src/modules/agent_orchestrator/lib/sdk/fileAgentGovernance.ts +79 -0
- package/src/modules/agent_orchestrator/lib/sdk/fileAgentNative.ts +248 -0
- package/src/modules/agent_orchestrator/lib/sdk/integrityCheckers.ts +74 -0
- package/src/modules/agent_orchestrator/lib/sdk/strictOutcomeSchema.ts +66 -0
- package/src/modules/agent_orchestrator/lib/systemHealth.ts +52 -1
- package/src/modules/agent_orchestrator/lib/trace/artifactCaptureStatus.ts +61 -0
- package/src/modules/agent_orchestrator/lib/trace/artifactStore.ts +139 -33
- package/src/modules/agent_orchestrator/lib/trace/capturePolicy.ts +251 -0
- package/src/modules/agent_orchestrator/lib/trace/captureSettingsForm.ts +216 -0
- package/src/modules/agent_orchestrator/lib/trace/contentArtifactAccess.ts +172 -0
- package/src/modules/agent_orchestrator/lib/trace/contentCapture.ts +419 -0
- package/src/modules/agent_orchestrator/lib/trace/contentRetention.ts +295 -0
- package/src/modules/agent_orchestrator/lib/trace/contentRetentionSchedule.ts +105 -0
- package/src/modules/agent_orchestrator/lib/trace/definitionHash.ts +94 -0
- package/src/modules/agent_orchestrator/lib/trace/genAiAttributes.ts +420 -0
- package/src/modules/agent_orchestrator/lib/trace/ingestContentCapture.ts +45 -0
- package/src/modules/agent_orchestrator/lib/trace/ingestLlmAttributes.ts +311 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportBackfill.ts +254 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportDestination.ts +201 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportHealth.ts +114 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportIntegration.ts +112 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportIntegrationIds.ts +10 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportJob.ts +470 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportSettings.ts +390 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/exportSettingsForm.ts +221 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/finishedProcessExport.ts +41 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/genAiContent.ts +400 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/ids.ts +72 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/loadRunExportBundle.ts +457 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/loadRunExportContent.ts +260 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/mapAgentRunToOtlp.ts +556 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/otelAttributes.ts +104 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/otlpErrorCodes.ts +6 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/otlpHttpClient.ts +233 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/otlpJson.ts +310 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/otlpProto.ts +218 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/otlpRequestBody.ts +25 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/sendTestSpan.ts +85 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/tenantEndpoint.ts +60 -0
- package/src/modules/agent_orchestrator/lib/trace/otel/traceLink.ts +88 -0
- package/src/modules/agent_orchestrator/lib/trace/redactStrings.ts +197 -0
- package/src/modules/agent_orchestrator/lib/trace/runCompare.ts +280 -0
- package/src/modules/agent_orchestrator/lib/trace/runManifest.ts +251 -0
- package/src/modules/agent_orchestrator/lib/trace/runManifestEntry.ts +164 -0
- package/src/modules/agent_orchestrator/lib/trace/runManifestView.ts +69 -0
- package/src/modules/agent_orchestrator/lib/trace/sealArtifactPayload.ts +46 -0
- package/src/modules/agent_orchestrator/lib/trace/toolObservation.ts +206 -0
- package/src/modules/agent_orchestrator/lib/trace/traceIngestionService.ts +156 -9
- package/src/modules/agent_orchestrator/lib/webSearch/tools.ts +2 -9
- package/src/modules/agent_orchestrator/migrations/adopt-squash.mjs +25 -1
- package/src/modules/agent_orchestrator/notifications.ts +22 -0
- package/src/modules/agent_orchestrator/setup.ts +83 -35
- package/src/modules/agent_orchestrator/subscribers/otel-export-run-completed.ts +17 -0
- package/src/modules/agent_orchestrator/subscribers/otel-export-run-ingested.ts +17 -0
- package/src/modules/agent_orchestrator/subscribers/process-workflow-cancelled.ts +4 -1
- package/src/modules/agent_orchestrator/subscribers/process-workflow-completed.ts +4 -1
- package/src/modules/agent_orchestrator/subscribers/process-workflow-failed.ts +4 -1
- package/src/modules/agent_orchestrator/subscribers/run-review-requested-notification.ts +146 -0
- package/src/modules/agent_orchestrator/widgets/injection/audit-proposal-link/widget.ts +42 -0
- package/src/modules/agent_orchestrator/widgets/injection/audit-run-link/widget.ts +31 -0
- package/src/modules/agent_orchestrator/widgets/injection-table.ts +11 -0
- package/src/modules/agent_orchestrator/workers/otel-export.ts +29 -0
- package/src/modules/agent_orchestrator/workers/trace-content-retention.ts +49 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[build:enterprise] found
|
|
1
|
+
[build:enterprise] found 927 entry points
|
|
2
2
|
[build:enterprise] built successfully
|
|
@@ -31,6 +31,15 @@ const features = [
|
|
|
31
31
|
module: "agent_orchestrator",
|
|
32
32
|
dependsOn: ["agent_orchestrator.trace.view"]
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
// Gates reading captured prompt and response content in traces and changing
|
|
36
|
+
// the trace capture policy. Default-OFF: held by admin/superadmin through
|
|
37
|
+
// the module wildcard, deliberately NOT in any narrower defaultRoleFeatures.
|
|
38
|
+
id: "agent_orchestrator.trace.view_content",
|
|
39
|
+
title: "View captured agent trace content and manage trace capture",
|
|
40
|
+
module: "agent_orchestrator",
|
|
41
|
+
dependsOn: ["agent_orchestrator.trace.view"]
|
|
42
|
+
},
|
|
34
43
|
{
|
|
35
44
|
id: "agent_orchestrator.eval.manage",
|
|
36
45
|
title: "Manage evaluation cases and assertions",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/agent_orchestrator/acl.ts"],
|
|
4
|
-
"sourcesContent": ["// Area 01 owns `agents.view` / `agents.run`. Area 03 owns `proposals.view` /\n// `proposals.dispose`. `workflows.author` is declared by area 02 \u2014 see\n// mvp/00-overview.md \u00A7ACL features.\nexport const features = [\n { id: 'agent_orchestrator.agents.view', title: 'View agents and runs', module: 'agent_orchestrator' },\n {\n // The Playground gate. Deliberately SEPARATE from `processes.run`: running\n // one agent directly is a development, eval and diagnostics capability, and\n // granting it is not the same decision as letting someone start durable\n // business work.\n id: 'agent_orchestrator.agents.run',\n title: 'Run agents directly (Playground, evals, diagnostics)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.agents.view'],\n },\n {\n id: 'agent_orchestrator.agents.manage',\n title: 'Manage agent presentation settings',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.agents.view'],\n },\n { id: 'agent_orchestrator.proposals.view', title: 'View proposals', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.proposals.dispose',\n title: 'Dispose proposals (approve/edit/reject)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.proposals.view'],\n },\n // Trace + eval overlay.\n { id: 'agent_orchestrator.trace.view', title: 'View agent run traces', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.trace.correct',\n title: 'Record agent corrections',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.trace.view'],\n },\n {\n id: 'agent_orchestrator.eval.manage',\n title: 'Manage evaluation cases and assertions',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.trace.view'],\n },\n {\n // Separate from eval.manage: authoring an assertion is cheap, but TRIGGERING a\n // run performs real inference against a real model and costs real money.\n id: 'agent_orchestrator.eval.run',\n title: 'Run agent evaluations',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.eval.manage'],\n },\n {\n id: 'agent_orchestrator.eval.export',\n title: 'Export the agent eval-case set',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.eval.manage'],\n },\n // Runtime guardrails overlay.\n { id: 'agent_orchestrator.guardrail.read', title: 'View guardrail checks', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.guardrail.manage',\n title: 'Manage guardrail sets',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.guardrail.read'],\n },\n // Context overlay \u2014 read the assembled context bundles (trace \"context assembled\" panel).\n { id: 'agent_orchestrator.context.read', title: 'View agent context bundles', module: 'agent_orchestrator' },\n // Identity overlay (Wave 4) \u2014 provision/manage agent principals and their scoped roles.\n { id: 'agent_orchestrator.identity.read', title: 'View agent principals', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.identity.manage',\n title: 'Manage agent principals (provision agent users + scoped roles)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.identity.read'],\n },\n // External-agent OAuth (Wave 4 Phase 3) \u2014 mint client-credentials tokens and\n // create/revoke delegation grants for external (`oauth_client`) principals.\n {\n id: 'agent_orchestrator.identity.tokens',\n title: 'Manage external agent tokens and delegation grants',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.identity.manage'],\n },\n // Processes (triggered process model spec, 2026-08-11). ONE `view` feature\n // covers both surfaces the model has: the running-process projection\n // (`/backend/processes`) and the definitions that can start one\n // (`/backend/processes/definitions`). The retired `tasks.view` merged into\n // this id rather than adding a fourth feature for a distinction nobody makes.\n // Consequence recorded in the spec: `dependsOn` proposals.view is inherited by\n // definition authors, who did not transitively read proposals before.\n {\n id: 'agent_orchestrator.processes.view',\n title: 'View agent processes, process definitions and run history',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.proposals.view'],\n },\n {\n id: 'agent_orchestrator.processes.manage',\n title: 'Create and configure process definitions',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.processes.view'],\n },\n {\n id: 'agent_orchestrator.processes.run',\n title: 'Start a process run',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.processes.view'],\n },\n // Web egress overlay (spec 2026-07-11-agent-web-search-tool) \u2014 gates the\n // read-only `web_search`/`web_fetch` MCP tools. Default-OFF: intentionally NOT\n // added to the narrower `defaultRoleFeatures` in setup.ts, so an agent must be\n // explicitly authorized for network egress. `dependsOn` agents.run because the\n // tools are only reachable inside an agent run.\n {\n id: 'agent_orchestrator.web_search',\n title: 'Use agent web search',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.agents.run'],\n },\n // Split from `web_search` so a tenant can be granted discovery without the\n // ability to retrieve an arbitrary URL, which is the higher-risk half. Additive:\n // `web_fetch` requires BOTH features, so every existing grant of `web_search`\n // keeps working for search and only loses fetch until this is granted too.\n {\n id: 'agent_orchestrator.web_fetch',\n title: 'Use agent web fetch (retrieve an arbitrary URL)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.web_search'],\n },\n]\n\nexport default features\n"],
|
|
5
|
-
"mappings": "AAGO,MAAM,WAAW;AAAA,EACtB,EAAE,IAAI,kCAAkC,OAAO,wBAAwB,QAAQ,qBAAqB;AAAA,EACpG;AAAA;AAAA;AAAA;AAAA;AAAA,IAKE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,gCAAgC;AAAA,EAC9C;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IAC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,WAAW,CAAC,oCAAoC;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,mCAAmC;AAAA,EACjD;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,mCAAmC;AAAA,EACjD;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,mCAAmC;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,+BAA+B;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,+BAA+B;AAAA,EAC7C;AACF;AAEA,IAAO,cAAQ;",
|
|
4
|
+
"sourcesContent": ["// Area 01 owns `agents.view` / `agents.run`. Area 03 owns `proposals.view` /\n// `proposals.dispose`. `workflows.author` is declared by area 02 \u2014 see\n// mvp/00-overview.md \u00A7ACL features.\nexport const features = [\n { id: 'agent_orchestrator.agents.view', title: 'View agents and runs', module: 'agent_orchestrator' },\n {\n // The Playground gate. Deliberately SEPARATE from `processes.run`: running\n // one agent directly is a development, eval and diagnostics capability, and\n // granting it is not the same decision as letting someone start durable\n // business work.\n id: 'agent_orchestrator.agents.run',\n title: 'Run agents directly (Playground, evals, diagnostics)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.agents.view'],\n },\n {\n id: 'agent_orchestrator.agents.manage',\n title: 'Manage agent presentation settings',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.agents.view'],\n },\n { id: 'agent_orchestrator.proposals.view', title: 'View proposals', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.proposals.dispose',\n title: 'Dispose proposals (approve/edit/reject)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.proposals.view'],\n },\n // Trace + eval overlay.\n { id: 'agent_orchestrator.trace.view', title: 'View agent run traces', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.trace.correct',\n title: 'Record agent corrections',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.trace.view'],\n },\n {\n // Gates reading captured prompt and response content in traces and changing\n // the trace capture policy. Default-OFF: held by admin/superadmin through\n // the module wildcard, deliberately NOT in any narrower defaultRoleFeatures.\n id: 'agent_orchestrator.trace.view_content',\n title: 'View captured agent trace content and manage trace capture',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.trace.view'],\n },\n {\n id: 'agent_orchestrator.eval.manage',\n title: 'Manage evaluation cases and assertions',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.trace.view'],\n },\n {\n // Separate from eval.manage: authoring an assertion is cheap, but TRIGGERING a\n // run performs real inference against a real model and costs real money.\n id: 'agent_orchestrator.eval.run',\n title: 'Run agent evaluations',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.eval.manage'],\n },\n {\n id: 'agent_orchestrator.eval.export',\n title: 'Export the agent eval-case set',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.eval.manage'],\n },\n // Runtime guardrails overlay.\n { id: 'agent_orchestrator.guardrail.read', title: 'View guardrail checks', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.guardrail.manage',\n title: 'Manage guardrail sets',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.guardrail.read'],\n },\n // Context overlay \u2014 read the assembled context bundles (trace \"context assembled\" panel).\n { id: 'agent_orchestrator.context.read', title: 'View agent context bundles', module: 'agent_orchestrator' },\n // Identity overlay (Wave 4) \u2014 provision/manage agent principals and their scoped roles.\n { id: 'agent_orchestrator.identity.read', title: 'View agent principals', module: 'agent_orchestrator' },\n {\n id: 'agent_orchestrator.identity.manage',\n title: 'Manage agent principals (provision agent users + scoped roles)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.identity.read'],\n },\n // External-agent OAuth (Wave 4 Phase 3) \u2014 mint client-credentials tokens and\n // create/revoke delegation grants for external (`oauth_client`) principals.\n {\n id: 'agent_orchestrator.identity.tokens',\n title: 'Manage external agent tokens and delegation grants',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.identity.manage'],\n },\n // Processes (triggered process model spec, 2026-08-11). ONE `view` feature\n // covers both surfaces the model has: the running-process projection\n // (`/backend/processes`) and the definitions that can start one\n // (`/backend/processes/definitions`). The retired `tasks.view` merged into\n // this id rather than adding a fourth feature for a distinction nobody makes.\n // Consequence recorded in the spec: `dependsOn` proposals.view is inherited by\n // definition authors, who did not transitively read proposals before.\n {\n id: 'agent_orchestrator.processes.view',\n title: 'View agent processes, process definitions and run history',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.proposals.view'],\n },\n {\n id: 'agent_orchestrator.processes.manage',\n title: 'Create and configure process definitions',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.processes.view'],\n },\n {\n id: 'agent_orchestrator.processes.run',\n title: 'Start a process run',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.processes.view'],\n },\n // Web egress overlay (spec 2026-07-11-agent-web-search-tool) \u2014 gates the\n // read-only `web_search`/`web_fetch` MCP tools. Default-OFF: intentionally NOT\n // added to the narrower `defaultRoleFeatures` in setup.ts, so an agent must be\n // explicitly authorized for network egress. `dependsOn` agents.run because the\n // tools are only reachable inside an agent run.\n {\n id: 'agent_orchestrator.web_search',\n title: 'Use agent web search',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.agents.run'],\n },\n // Split from `web_search` so a tenant can be granted discovery without the\n // ability to retrieve an arbitrary URL, which is the higher-risk half. Additive:\n // `web_fetch` requires BOTH features, so every existing grant of `web_search`\n // keeps working for search and only loses fetch until this is granted too.\n {\n id: 'agent_orchestrator.web_fetch',\n title: 'Use agent web fetch (retrieve an arbitrary URL)',\n module: 'agent_orchestrator',\n dependsOn: ['agent_orchestrator.web_search'],\n },\n]\n\nexport default features\n"],
|
|
5
|
+
"mappings": "AAGO,MAAM,WAAW;AAAA,EACtB,EAAE,IAAI,kCAAkC,OAAO,wBAAwB,QAAQ,qBAAqB;AAAA,EACpG;AAAA;AAAA;AAAA;AAAA;AAAA,IAKE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,gCAAgC;AAAA,EAC9C;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,gCAAgC;AAAA,EAC9C;AAAA,EACA,EAAE,IAAI,qCAAqC,OAAO,kBAAkB,QAAQ,qBAAqB;AAAA,EACjG;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,mCAAmC;AAAA,EACjD;AAAA;AAAA,EAEA,EAAE,IAAI,iCAAiC,OAAO,yBAAyB,QAAQ,qBAAqB;AAAA,EACpG;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,+BAA+B;AAAA,EAC7C;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,IAIE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,+BAA+B;AAAA,EAC7C;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,+BAA+B;AAAA,EAC7C;AAAA,EACA;AAAA;AAAA;AAAA,IAGE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW,CAAC,gCAAgC;AAAA,EAC9C;AAAA,EAC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AQ;AAAA,IACR,WAAW,CAAC,+BAA+B;AAAA,EAC7C;AACF;AAEA,IAAO,cAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,11 +2,21 @@ import { z } from "zod";
|
|
|
2
2
|
import { DELEGATE_TOOL_ID, getAgentEntry, ensureAgentsLoaded } from "./lib/sdk/defineAgent.js";
|
|
3
3
|
import { getAgentSkill, getAgentSkillScript } from "./lib/runtime/fileAgentSkills.js";
|
|
4
4
|
import { runSandboxedScript } from "./lib/runtime/sandboxedScript.js";
|
|
5
|
-
import { getCurrentRunId, getCurrentRunSource } from "./lib/runtime/runContext.js";
|
|
5
|
+
import { getCurrentRunId, getCurrentRunInvoker, getCurrentRunSource } from "./lib/runtime/runContext.js";
|
|
6
|
+
import { resolveActiveAgentId } from "./lib/runtime/activeAgent.js";
|
|
7
|
+
import {
|
|
8
|
+
AGENT_INVOKE_DENIED_CODE,
|
|
9
|
+
AGENT_PRINCIPAL_MISSING_CODE,
|
|
10
|
+
isAgentInvokeDeniedError,
|
|
11
|
+
isAgentPrincipalMissingError
|
|
12
|
+
} from "./lib/runtime/errors.js";
|
|
13
|
+
import { agentResultPayload } from "./lib/runtime/agentResultPayload.js";
|
|
6
14
|
import { webSearchTool, webFetchTool } from "./lib/webSearch/tools.js";
|
|
7
15
|
const SUBMIT_OUTCOME_TOOL_ID = "agent_orchestrator.submit_outcome";
|
|
8
16
|
const LOAD_SKILL_TOOL_ID = "agent_orchestrator.load_skill";
|
|
9
17
|
const RUN_SKILL_SCRIPT_TOOL_ID = "agent_orchestrator.run_skill_script";
|
|
18
|
+
const DELEGATE_NO_ACTIVE_RUN_CODE = "no_active_run";
|
|
19
|
+
const DELEGATE_SUB_AGENT_NOT_ALLOWED_CODE = "sub_agent_not_allowed";
|
|
10
20
|
const delegateInput = z.object({
|
|
11
21
|
agentId: z.string().min(1).describe("Id of the sub-agent to run (must be a researcher agent)."),
|
|
12
22
|
input: z.unknown().describe("Input payload passed to the sub-agent (shape is sub-agent specific).")
|
|
@@ -33,7 +43,7 @@ async function resolveParentRunIdFromSession(ctx) {
|
|
|
33
43
|
const delegateAgentTool = {
|
|
34
44
|
name: DELEGATE_TOOL_ID,
|
|
35
45
|
displayName: "Delegate to sub-agent",
|
|
36
|
-
description: "Run another agent as a read-only sub-agent and return its result. Only researcher, non-delegating
|
|
46
|
+
description: "Run another agent as a read-only sub-agent and return its result. Only the current agent declared sub-agents (researcher, non-delegating) may be targeted. Call multiple times in one step to fan out in parallel.",
|
|
37
47
|
inputSchema: delegateInput,
|
|
38
48
|
requiredFeatures: ["agent_orchestrator.agents.run"],
|
|
39
49
|
isMutation: false,
|
|
@@ -43,7 +53,15 @@ const delegateAgentTool = {
|
|
|
43
53
|
if (!ctx.tenantId || !ctx.organizationId || !ctx.userId) {
|
|
44
54
|
return { ok: false, agentId, error: "missing tenant/org/user scope" };
|
|
45
55
|
}
|
|
56
|
+
const parentAgentId = await resolveActiveAgentId(ctx.container, ctx.sessionId);
|
|
57
|
+
if (!parentAgentId) {
|
|
58
|
+
return { ok: false, agentId, error: DELEGATE_NO_ACTIVE_RUN_CODE };
|
|
59
|
+
}
|
|
46
60
|
await ensureAgentsLoaded();
|
|
61
|
+
const parentEntry = getAgentEntry(parentAgentId);
|
|
62
|
+
if (!parentEntry || !parentEntry.subAgents.includes(agentId)) {
|
|
63
|
+
return { ok: false, agentId, error: DELEGATE_SUB_AGENT_NOT_ALLOWED_CODE };
|
|
64
|
+
}
|
|
47
65
|
const entry = getAgentEntry(agentId);
|
|
48
66
|
if (!entry) {
|
|
49
67
|
return { ok: false, agentId, error: `unknown sub-agent "${agentId}"` };
|
|
@@ -58,6 +76,7 @@ const delegateAgentTool = {
|
|
|
58
76
|
const agentRuntime = ctx.container.resolve("agentRuntime");
|
|
59
77
|
const parentRunId = getCurrentRunId() ?? await resolveParentRunIdFromSession(ctx);
|
|
60
78
|
const delegatedSource = getCurrentRunSource();
|
|
79
|
+
const parentInvoker = getCurrentRunInvoker();
|
|
61
80
|
const result = await agentRuntime.run(agentId, input, {
|
|
62
81
|
tenantId: ctx.tenantId,
|
|
63
82
|
organizationId: ctx.organizationId,
|
|
@@ -69,11 +88,18 @@ const delegateAgentTool = {
|
|
|
69
88
|
...parentRunId ? { parentRunId } : {},
|
|
70
89
|
// Inherit the parent's origin so an eval replay's sub-agent runs are not
|
|
71
90
|
// counted as production traffic in the agent's metric rollups.
|
|
72
|
-
...delegatedSource ? { source: delegatedSource } : {}
|
|
91
|
+
...delegatedSource ? { source: delegatedSource } : {},
|
|
92
|
+
...parentInvoker ? { invoker: parentInvoker } : {},
|
|
93
|
+
entryPoint: "delegate"
|
|
73
94
|
});
|
|
74
|
-
|
|
75
|
-
return { ok: true, agentId, data };
|
|
95
|
+
return { ok: true, agentId, data: agentResultPayload(result) };
|
|
76
96
|
} catch (err) {
|
|
97
|
+
if (isAgentInvokeDeniedError(err)) {
|
|
98
|
+
return { ok: false, agentId, error: AGENT_INVOKE_DENIED_CODE };
|
|
99
|
+
}
|
|
100
|
+
if (isAgentPrincipalMissingError(err)) {
|
|
101
|
+
return { ok: false, agentId, error: AGENT_PRINCIPAL_MISSING_CODE };
|
|
102
|
+
}
|
|
77
103
|
const message = err instanceof Error ? err.message : String(err);
|
|
78
104
|
return { ok: false, agentId, error: message };
|
|
79
105
|
}
|
|
@@ -162,14 +188,9 @@ const loadSkillTool = {
|
|
|
162
188
|
tags: ["read", "agent_orchestrator"],
|
|
163
189
|
async handler(rawInput, ctx) {
|
|
164
190
|
const { skillId } = loadSkillInput.parse(rawInput);
|
|
165
|
-
const
|
|
166
|
-
if (!sessionToken) {
|
|
167
|
-
return { ok: false, code: "no_active_run", error: "no run session in context" };
|
|
168
|
-
}
|
|
169
|
-
const store = ctx.container.resolve("agentRunSessionStore");
|
|
170
|
-
const agentId = await store.resolveActiveAgentId(sessionToken);
|
|
191
|
+
const agentId = await resolveActiveAgentId(ctx.container, ctx.sessionId);
|
|
171
192
|
if (!agentId) {
|
|
172
|
-
return { ok: false, code: "no_active_run", error: "no active run for this
|
|
193
|
+
return { ok: false, code: "no_active_run", error: "no active run for this call" };
|
|
173
194
|
}
|
|
174
195
|
await ensureAgentsLoaded();
|
|
175
196
|
const skill = getAgentSkill(agentId, skillId);
|
|
@@ -203,14 +224,9 @@ const runSkillScriptTool = {
|
|
|
203
224
|
tags: ["read", "agent_orchestrator"],
|
|
204
225
|
async handler(rawInput, ctx) {
|
|
205
226
|
const { skillId, scriptName, args } = runSkillScriptInput.parse(rawInput);
|
|
206
|
-
const
|
|
207
|
-
if (!sessionToken) {
|
|
208
|
-
return { ok: false, code: "no_active_run", error: "no run session in context" };
|
|
209
|
-
}
|
|
210
|
-
const store = ctx.container.resolve("agentRunSessionStore");
|
|
211
|
-
const agentId = await store.resolveActiveAgentId(sessionToken);
|
|
227
|
+
const agentId = await resolveActiveAgentId(ctx.container, ctx.sessionId);
|
|
212
228
|
if (!agentId) {
|
|
213
|
-
return { ok: false, code: "no_active_run", error: "no active run for this
|
|
229
|
+
return { ok: false, code: "no_active_run", error: "no active run for this call" };
|
|
214
230
|
}
|
|
215
231
|
await ensureAgentsLoaded();
|
|
216
232
|
if (!getAgentSkill(agentId, skillId)) {
|
|
@@ -245,6 +261,8 @@ const aiTools = [
|
|
|
245
261
|
];
|
|
246
262
|
var ai_tools_default = aiTools;
|
|
247
263
|
export {
|
|
264
|
+
DELEGATE_NO_ACTIVE_RUN_CODE,
|
|
265
|
+
DELEGATE_SUB_AGENT_NOT_ALLOWED_CODE,
|
|
248
266
|
LOAD_SKILL_TOOL_ID,
|
|
249
267
|
RUN_SKILL_SCRIPT_TOOL_ID,
|
|
250
268
|
SUBMIT_OUTCOME_TOOL_ID,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/agent_orchestrator/ai-tools.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod'\nimport { defineAiTool } from '@open-mercato/ai-assistant/modules/ai_assistant/lib/ai-tool-definition'\nimport type { AiToolDefinition, McpToolContext } from '@open-mercato/ai-assistant/modules/ai_assistant/lib/types'\nimport { DELEGATE_TOOL_ID, getAgentEntry, ensureAgentsLoaded } from './lib/sdk/defineAgent'\nimport type { AgentRuntimeService } from './lib/runtime/agentRuntime'\nimport type { AgentRunSessionStore } from './lib/runtime/agentRunSessionStore'\nimport { getAgentSkill, getAgentSkillScript } from './lib/runtime/fileAgentSkills'\nimport { runSandboxedScript } from './lib/runtime/sandboxedScript'\nimport { getCurrentRunId, getCurrentRunSource } from './lib/runtime/runContext'\nimport { webSearchTool, webFetchTool } from './lib/webSearch/tools'\n\n/** Tool id of the OUTCOME-submission tool an OpenCode file-agent finishes with. */\nexport const SUBMIT_OUTCOME_TOOL_ID = 'agent_orchestrator.submit_outcome'\n\n/** Tool id of the skill progressive-disclosure fallback (native skills preferred). */\nexport const LOAD_SKILL_TOOL_ID = 'agent_orchestrator.load_skill'\n\n/** Tool id of the sandboxed skill-script / local-tool runner (Phase 5). */\nexport const RUN_SKILL_SCRIPT_TOOL_ID = 'agent_orchestrator.run_skill_script'\n\nconst delegateInput = z.object({\n agentId: z.string().min(1).describe('Id of the sub-agent to run (must be a researcher agent).'),\n input: z.unknown().describe('Input payload passed to the sub-agent (shape is sub-agent specific).'),\n})\n\n/** Default wall-clock budget for a delegated sub-agent run (ms) \u2014 deliberately far\n * below the top-level `OM_OPENCODE_RUN_TIMEOUT_MS` so a hung sub-agent tool (e.g. a\n * wedged web_search navigation) fails fast and returns an error to the orchestrator\n * instead of blocking it for the full top-level deadline. */\nconst DEFAULT_DELEGATE_RUN_TIMEOUT_MS = 3 * 60_000\n\n/** Resolve the delegated-run wall-clock budget from `OM_AGENT_DELEGATE_RUN_TIMEOUT_MS`,\n * falling back to {@link DEFAULT_DELEGATE_RUN_TIMEOUT_MS}. A non-positive/NaN override is ignored. */\nfunction resolveDelegateRunTimeoutMs(): number {\n const raw = process.env.OM_AGENT_DELEGATE_RUN_TIMEOUT_MS\n if (raw != null && raw !== '') {\n const parsed = Number(raw)\n if (Number.isFinite(parsed) && parsed > 0) return parsed\n }\n return DEFAULT_DELEGATE_RUN_TIMEOUT_MS\n}\n\n/**\n * Resolve the parent run id from the caller's run session when the in-process\n * run context is absent. On the OpenCode path this tool runs in the separate\n * `mcp:serve-http` process where `getCurrentRunId()` is always undefined, so the\n * nested-run `parent_run_id` trace link would be lost. Mirrors how\n * `submit_outcome` (this file) and `lib/webSearch/guardrails.ts` resolve the run\n * from the session token via `agentRunSessionStore`. Never throws \u2014 a missing\n * session or an unresolvable store yields `undefined` (a top-level nested run).\n */\nasync function resolveParentRunIdFromSession(ctx: McpToolContext): Promise<string | undefined> {\n const sessionToken = ctx.sessionId\n if (!sessionToken) return undefined\n try {\n const store = ctx.container.resolve('agentRunSessionStore') as AgentRunSessionStore\n return (await store.resolveActiveRunId(sessionToken)) ?? undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * Sub-agent-as-tool: lets a parent agent run another agent as a read-only\n * sub-agent and fan several out in parallel (the model emits multiple calls in\n * one step; the SDK runs them concurrently). Propose-only is preserved:\n *\n * - the tool is `isMutation: false` \u2014 never gated, never a write;\n * - the target MUST be an `researcher` agent (sub-agents inform; only the\n * parent proposes), so no nested proposals are created;\n * - the target may NOT itself delegate (no `subAgents`), which caps tree depth\n * at one and prevents cycles;\n * - the sub-agent runs under the SAME caller scope/ACL \u2014 never escalated.\n *\n * Errors are returned as data (`{ ok: false }`) so one failed sub-task never\n * crashes the parent loop.\n */\nconst delegateAgentTool: AiToolDefinition = {\n name: DELEGATE_TOOL_ID,\n displayName: 'Delegate to sub-agent',\n description:\n 'Run another agent as a read-only sub-agent and return its result. Only researcher, non-delegating agents may be targeted. Call multiple times in one step to fan out in parallel.',\n inputSchema: delegateInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { agentId, input } = delegateInput.parse(rawInput)\n if (!ctx.tenantId || !ctx.organizationId || !ctx.userId) {\n return { ok: false as const, agentId, error: 'missing tenant/org/user scope' }\n }\n\n await ensureAgentsLoaded()\n const entry = getAgentEntry(agentId)\n if (!entry) {\n return { ok: false as const, agentId, error: `unknown sub-agent \"${agentId}\"` }\n }\n if (entry.resultKind !== 'research') {\n return { ok: false as const, agentId, error: 'only research sub-agents may be delegated to' }\n }\n if (entry.subAgents.length > 0) {\n return { ok: false as const, agentId, error: 'sub-agents may not delegate further (depth capped at 1)' }\n }\n\n try {\n const agentRuntime = ctx.container.resolve('agentRuntime') as AgentRuntimeService\n // The parent run is the in-process run currently executing (bound via the\n // run-context AsyncLocalStorage); pass its id so the nested sub-agent run\n // records `parent_run_id` for traceability (Phase 4). On the OpenCode path\n // this tool runs in the separate mcp:serve-http process where that async\n // context is never set \u2014 fall back to the cross-process correlation store,\n // resolving the parent run from THIS run's session token. Undefined when\n // neither resolves (the nested run is then a top-level run).\n const parentRunId = getCurrentRunId() ?? (await resolveParentRunIdFromSession(ctx))\n const delegatedSource = getCurrentRunSource()\n const result = await agentRuntime.run(agentId, input, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n userId: ctx.userId,\n // Bound the delegated run well below the top-level budget so a hung\n // sub-agent tool (e.g. a wedged web_search navigation) fails fast and\n // returns an error to the orchestrator instead of blocking it for an hour.\n runTimeoutMs: resolveDelegateRunTimeoutMs(),\n ...(parentRunId ? { parentRunId } : {}),\n // Inherit the parent's origin so an eval replay's sub-agent runs are not\n // counted as production traffic in the agent's metric rollups.\n ...(delegatedSource ? { source: delegatedSource } : {}),\n })\n // Whatever the sub-agent produced, handed back verbatim under its own key:\n // the orchestrator reads a finding, an intent and a file list differently,\n // and flattening them here would make them indistinguishable.\n const data =\n result.kind === 'research'\n ? result.data\n : result.kind === 'proposal'\n ? result.proposal\n : { artifacts: result.artifacts, summary: result.summary }\n return { ok: true as const, agentId, data }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n return { ok: false as const, agentId, error: message }\n }\n },\n}\n\nconst submitOutcomeInput = z.object({\n outcome: z\n .unknown()\n .describe(\n 'The structured result, matching the active agent OUTCOME contract. The active agent and its schema are resolved server-side from the run session \u2014 never trusted from this call.',\n ),\n // File plane (#12): ADVISORY captions for files the agent wrote into the sandbox\n // `out/` dir. Additive + optional (existing single-`outcome` callers stay valid).\n // The collector is FILESYSTEM-authoritative: it captures whatever is on disk and\n // uses these only to attach a caption (matched by relative path) \u2014 it never\n // trusts this list to invent, hide, or rename a file.\n artifacts: z\n .array(\n z.object({\n path: z.string().max(255).describe('Path of the produced file, relative to the sandbox out/ dir.'),\n caption: z.string().max(500).optional().describe('Short human description of the file.'),\n }),\n )\n .max(20)\n .optional()\n .describe('Optional captions for files written to the sandbox out/ directory.'),\n})\n\n/**\n * Terminal tool an OpenCode file-agent calls to deliver its structured result.\n *\n * The active agent id is resolved from the cross-process correlation store keyed\n * by THIS run's session token (`ctx.sessionId`, which the MCP HTTP server sets to\n * the session token the runner minted) \u2014 NOT trusted from the model. The store is\n * DB-backed because the runner and this tool run in different processes. The\n * agent's compiled OUTCOME schema is read from the registry; the submitted\n * `outcome` is validated against it:\n *\n * - valid \u2192 written to the store; the polling runner reads it back. `{ ok: true }`.\n * - invalid \u2192 `{ ok: false, code: 'outcome_invalid', errors }` so OpenCode/the\n * agent can correct and retry (NOT thrown). A non-JSON string is the\n * same: parsed first, then validated.\n * - missing/stale correlation (no run for this session, or already completed)\n * \u2192 `{ ok: false, code: 'no_active_run' }`.\n *\n * Propose-only: `isMutation: false` \u2014 the only state this ever produces is the\n * AgentRun/AgentProposal the runner persists from the captured outcome.\n */\nconst submitOutcomeTool: AiToolDefinition = {\n name: SUBMIT_OUTCOME_TOOL_ID,\n displayName: 'Submit agent outcome',\n description:\n 'Finish the current agent run by submitting its structured outcome (as the `outcome` argument object). The server validates it against the agent OUTCOME contract; on failure it returns the validation errors so you can correct and resubmit.',\n inputSchema: submitOutcomeInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { outcome } = submitOutcomeInput.parse(rawInput)\n const sessionToken = ctx.sessionId\n if (!sessionToken) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no run session in context' }\n }\n const store = ctx.container.resolve('agentRunSessionStore') as AgentRunSessionStore\n const agentId = await store.resolveActiveAgentId(sessionToken)\n if (!agentId) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no active run for this session' }\n }\n await ensureAgentsLoaded()\n const entry = getAgentEntry(agentId)\n if (!entry) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'active agent is no longer registered' }\n }\n // Models sometimes pass the outcome as a JSON STRING \u2014 parse it before validating.\n let outcomeValue = outcome\n if (typeof outcomeValue === 'string') {\n try {\n outcomeValue = JSON.parse(outcomeValue)\n } catch {\n return {\n ok: false as const,\n code: 'outcome_invalid' as const,\n errors: [{ path: '', message: 'outcome must be a JSON object, not an unparseable string' }],\n }\n }\n }\n const parsed = entry.schema.safeParse(outcomeValue)\n if (!parsed.success) {\n return {\n ok: false as const,\n code: 'outcome_invalid' as const,\n errors: parsed.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n })),\n }\n }\n const completion = await store.completeOutcome(sessionToken, parsed.data)\n if (completion !== 'completed') {\n // not_found (run gone) or already_completed \u2192 nothing more to capture.\n return { ok: false as const, code: 'no_active_run' as const, error: `run ${completion}` }\n }\n return { ok: true as const }\n },\n}\n\nconst loadSkillInput = z.object({\n skillId: z\n .string()\n .min(1)\n .describe('Id of the skill to load. Must be one of the active agent allowed skills.'),\n})\n\n/**\n * Progressive-disclosure FALLBACK for agent-local skills. Native OpenCode skills\n * (generated `SKILL.md` files) are the primary path; this MCP tool returns a\n * skill's full content on demand AND carries TEMPLATE.md/examples that native\n * skills may not bundle.\n *\n * The allowed skill set is the ACTIVE agent's skills \u2014 resolved from the per-run\n * correlation store keyed by THIS run's session token (`ctx.sessionId`) \u2014 NEVER\n * trusted from the model. Outcomes:\n *\n * - missing/stale correlation (no run for this session) \u2192 `{ ok:false, code:'no_active_run' }`.\n * - skillId not registered for the active agent \u2192 `{ ok:false, code:'skill_not_allowed' }`.\n * - otherwise \u2192 `{ ok:true, instructions, template?, examples }`.\n *\n * Propose-only: `isMutation:false` \u2014 it only reads skill content.\n */\nconst loadSkillTool: AiToolDefinition = {\n name: LOAD_SKILL_TOOL_ID,\n displayName: 'Load agent skill',\n description:\n 'Load the full instructions (and optional template + examples) of one of the current agent skills, by skill id.',\n inputSchema: loadSkillInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { skillId } = loadSkillInput.parse(rawInput)\n const sessionToken = ctx.sessionId\n if (!sessionToken) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no run session in context' }\n }\n const store = ctx.container.resolve('agentRunSessionStore') as AgentRunSessionStore\n const agentId = await store.resolveActiveAgentId(sessionToken)\n if (!agentId) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no active run for this session' }\n }\n // Populate the file-agent skill registry before resolving \u2014 on a fresh\n // process this tool can be the first agent_orchestrator call, so the\n // registry would otherwise be empty and reject a valid skill.\n await ensureAgentsLoaded()\n const skill = getAgentSkill(agentId, skillId)\n if (!skill) {\n return {\n ok: false as const,\n code: 'skill_not_allowed' as const,\n error: `skill \"${skillId}\" is not available to the active agent`,\n }\n }\n return {\n ok: true as const,\n instructions: skill.instructions,\n ...(skill.template != null ? { template: skill.template } : {}),\n examples: skill.examples,\n }\n },\n}\n\nconst runSkillScriptInput = z.object({\n skillId: z\n .string()\n .min(1)\n .describe('Id of the skill the script belongs to (one of the current agent skills).'),\n scriptName: z\n .string()\n .min(1)\n .describe('Script basename without extension (e.g. `scripts/score.ts` \u2192 \"score\").'),\n args: z.unknown().optional().describe('Arguments passed to the script `run(args)` function.'),\n})\n\n/**\n * Run one of the active agent's sandboxed helper scripts (Phase 5) \u2014 a skill\n * `scripts/<name>.ts` or a local tool file (carried under the synthetic\n * `__agent_tools__` skill id) \u2014 and return its value.\n *\n * The active agent + its allowed skill/script set are resolved server-side from\n * the per-run correlation store (`ctx.sessionId`) \u2014 NEVER trusted from the model.\n * The script source runs in the Code Mode `isolated-vm` sandbox: no fs/net/\n * imports, a hard 30s cap, and per-call ACL via `requiredFeatures` + the session\n * token. A script is a pure function of its `args`, so this stays propose-only \u2014\n * it can compute, not mutate. Errors are returned as data, never thrown.\n */\nconst runSkillScriptTool: AiToolDefinition = {\n name: RUN_SKILL_SCRIPT_TOOL_ID,\n displayName: 'Run agent skill script',\n description:\n 'Run one of the current agent sandboxed helper scripts by skill id + script name and return its result. Scripts are pure functions of their args (no fs/net/side effects) executed in a sandbox.',\n inputSchema: runSkillScriptInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { skillId, scriptName, args } = runSkillScriptInput.parse(rawInput)\n const sessionToken = ctx.sessionId\n if (!sessionToken) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no run session in context' }\n }\n const store = ctx.container.resolve('agentRunSessionStore') as AgentRunSessionStore\n const agentId = await store.resolveActiveAgentId(sessionToken)\n if (!agentId) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no active run for this session' }\n }\n // Populate the file-agent skill registry before resolving \u2014 on a fresh\n // process this tool can be the first agent_orchestrator call, so the\n // registry would otherwise be empty and reject a valid skill/script.\n await ensureAgentsLoaded()\n if (!getAgentSkill(agentId, skillId)) {\n return {\n ok: false as const,\n code: 'skill_not_allowed' as const,\n error: `skill \"${skillId}\" is not available to the active agent`,\n }\n }\n const script = getAgentSkillScript(agentId, skillId, scriptName)\n if (!script) {\n return {\n ok: false as const,\n code: 'script_not_found' as const,\n error: `script \"${scriptName}\" not found in skill \"${skillId}\"`,\n }\n }\n const outcome = await runSandboxedScript({ source: script.source, args })\n if (!outcome.ok) {\n return { ok: false as const, code: outcome.code, error: outcome.error }\n }\n return { ok: true as const, result: outcome.result }\n },\n}\n\nexport const aiTools: AiToolDefinition[] = [\n delegateAgentTool,\n submitOutcomeTool,\n loadSkillTool,\n runSkillScriptTool,\n webSearchTool,\n webFetchTool,\n]\n\nexport default aiTools\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAGlB,SAAS,kBAAkB,eAAe,0BAA0B;AAGpE,SAAS,eAAe,2BAA2B;AACnD,SAAS,0BAA0B;AACnC,SAAS,iBAAiB,2BAA2B;
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport { defineAiTool } from '@open-mercato/ai-assistant/modules/ai_assistant/lib/ai-tool-definition'\nimport type { AiToolDefinition, McpToolContext } from '@open-mercato/ai-assistant/modules/ai_assistant/lib/types'\nimport { DELEGATE_TOOL_ID, getAgentEntry, ensureAgentsLoaded } from './lib/sdk/defineAgent'\nimport type { AgentRuntimeService } from './lib/runtime/agentRuntime'\nimport type { AgentRunSessionStore } from './lib/runtime/agentRunSessionStore'\nimport { getAgentSkill, getAgentSkillScript } from './lib/runtime/fileAgentSkills'\nimport { runSandboxedScript } from './lib/runtime/sandboxedScript'\nimport { getCurrentRunId, getCurrentRunInvoker, getCurrentRunSource } from './lib/runtime/runContext'\nimport { resolveActiveAgentId } from './lib/runtime/activeAgent'\nimport {\n AGENT_INVOKE_DENIED_CODE,\n AGENT_PRINCIPAL_MISSING_CODE,\n isAgentInvokeDeniedError,\n isAgentPrincipalMissingError,\n} from './lib/runtime/errors'\nimport { agentResultPayload } from './lib/runtime/agentResultPayload'\nimport { webSearchTool, webFetchTool } from './lib/webSearch/tools'\n\n/** Tool id of the OUTCOME-submission tool an OpenCode file-agent finishes with. */\nexport const SUBMIT_OUTCOME_TOOL_ID = 'agent_orchestrator.submit_outcome'\n\n/** Tool id of the skill progressive-disclosure fallback (native skills preferred). */\nexport const LOAD_SKILL_TOOL_ID = 'agent_orchestrator.load_skill'\n\n/** Tool id of the sandboxed skill-script / local-tool runner (Phase 5). */\nexport const RUN_SKILL_SCRIPT_TOOL_ID = 'agent_orchestrator.run_skill_script'\n\n/** `delegate_agent` refusal: the call belongs to no active agent run. */\nexport const DELEGATE_NO_ACTIVE_RUN_CODE = 'no_active_run'\n\n/** `delegate_agent` refusal: the target is not a declared sub-agent of the calling agent. */\nexport const DELEGATE_SUB_AGENT_NOT_ALLOWED_CODE = 'sub_agent_not_allowed'\n\nconst delegateInput = z.object({\n agentId: z.string().min(1).describe('Id of the sub-agent to run (must be a researcher agent).'),\n input: z.unknown().describe('Input payload passed to the sub-agent (shape is sub-agent specific).'),\n})\n\n/** Default wall-clock budget for a delegated sub-agent run (ms) \u2014 deliberately far\n * below the top-level `OM_OPENCODE_RUN_TIMEOUT_MS` so a hung sub-agent tool (e.g. a\n * wedged web_search navigation) fails fast and returns an error to the orchestrator\n * instead of blocking it for the full top-level deadline. */\nconst DEFAULT_DELEGATE_RUN_TIMEOUT_MS = 3 * 60_000\n\n/** Resolve the delegated-run wall-clock budget from `OM_AGENT_DELEGATE_RUN_TIMEOUT_MS`,\n * falling back to {@link DEFAULT_DELEGATE_RUN_TIMEOUT_MS}. A non-positive/NaN override is ignored. */\nfunction resolveDelegateRunTimeoutMs(): number {\n const raw = process.env.OM_AGENT_DELEGATE_RUN_TIMEOUT_MS\n if (raw != null && raw !== '') {\n const parsed = Number(raw)\n if (Number.isFinite(parsed) && parsed > 0) return parsed\n }\n return DEFAULT_DELEGATE_RUN_TIMEOUT_MS\n}\n\n/**\n * Resolve the parent run id from the caller's run session when the in-process\n * run context is absent. On the OpenCode path this tool runs in the separate\n * `mcp:serve-http` process where `getCurrentRunId()` is always undefined, so the\n * nested-run `parent_run_id` trace link would be lost. Mirrors how\n * `submit_outcome` (this file) and `lib/webSearch/guardrails.ts` resolve the run\n * from the session token via `agentRunSessionStore`. Never throws \u2014 a missing\n * session or an unresolvable store yields `undefined` (a top-level nested run).\n */\nasync function resolveParentRunIdFromSession(ctx: McpToolContext): Promise<string | undefined> {\n const sessionToken = ctx.sessionId\n if (!sessionToken) return undefined\n try {\n const store = ctx.container.resolve('agentRunSessionStore') as AgentRunSessionStore\n return (await store.resolveActiveRunId(sessionToken)) ?? undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * Sub-agent-as-tool: lets a parent agent run another agent as a read-only\n * sub-agent and fan several out in parallel (the model emits multiple calls in\n * one step; the SDK runs them concurrently). Propose-only is preserved:\n *\n * - the tool is `isMutation: false` \u2014 never gated, never a write;\n * - the target MUST be one of the `subAgents` declared by the calling agent,\n * which is resolved server-side (`resolveActiveAgentId`) and never taken from\n * the model; a call with no resolvable parent run is refused (fail closed);\n * - the target MUST be an `researcher` agent (sub-agents inform; only the\n * parent proposes), so no nested proposals are created;\n * - the target may NOT itself delegate (no `subAgents`), which caps tree depth\n * at one and prevents cycles;\n * - the sub-agent runs under the SAME caller scope/ACL \u2014 never escalated.\n *\n * Errors are returned as data (`{ ok: false }`) so one failed sub-task never\n * crashes the parent loop.\n */\nconst delegateAgentTool: AiToolDefinition = {\n name: DELEGATE_TOOL_ID,\n displayName: 'Delegate to sub-agent',\n description:\n 'Run another agent as a read-only sub-agent and return its result. Only the current agent declared sub-agents (researcher, non-delegating) may be targeted. Call multiple times in one step to fan out in parallel.',\n inputSchema: delegateInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { agentId, input } = delegateInput.parse(rawInput)\n if (!ctx.tenantId || !ctx.organizationId || !ctx.userId) {\n return { ok: false as const, agentId, error: 'missing tenant/org/user scope' }\n }\n\n const parentAgentId = await resolveActiveAgentId(ctx.container, ctx.sessionId)\n if (!parentAgentId) {\n return { ok: false as const, agentId, error: DELEGATE_NO_ACTIVE_RUN_CODE }\n }\n await ensureAgentsLoaded()\n const parentEntry = getAgentEntry(parentAgentId)\n if (!parentEntry || !parentEntry.subAgents.includes(agentId)) {\n return { ok: false as const, agentId, error: DELEGATE_SUB_AGENT_NOT_ALLOWED_CODE }\n }\n const entry = getAgentEntry(agentId)\n if (!entry) {\n return { ok: false as const, agentId, error: `unknown sub-agent \"${agentId}\"` }\n }\n if (entry.resultKind !== 'research') {\n return { ok: false as const, agentId, error: 'only research sub-agents may be delegated to' }\n }\n if (entry.subAgents.length > 0) {\n return { ok: false as const, agentId, error: 'sub-agents may not delegate further (depth capped at 1)' }\n }\n\n try {\n const agentRuntime = ctx.container.resolve('agentRuntime') as AgentRuntimeService\n // The parent run is the in-process run currently executing (bound via the\n // run-context AsyncLocalStorage); pass its id so the nested sub-agent run\n // records `parent_run_id` for traceability (Phase 4). On the OpenCode path\n // this tool runs in the separate mcp:serve-http process where that async\n // context is never set \u2014 fall back to the cross-process correlation store,\n // resolving the parent run from THIS run's session token. Undefined when\n // neither resolves (the nested run is then a top-level run).\n const parentRunId = getCurrentRunId() ?? (await resolveParentRunIdFromSession(ctx))\n const delegatedSource = getCurrentRunSource()\n const parentInvoker = getCurrentRunInvoker()\n const result = await agentRuntime.run(agentId, input, {\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n userId: ctx.userId,\n // Bound the delegated run well below the top-level budget so a hung\n // sub-agent tool (e.g. a wedged web_search navigation) fails fast and\n // returns an error to the orchestrator instead of blocking it for an hour.\n runTimeoutMs: resolveDelegateRunTimeoutMs(),\n ...(parentRunId ? { parentRunId } : {}),\n // Inherit the parent's origin so an eval replay's sub-agent runs are not\n // counted as production traffic in the agent's metric rollups.\n ...(delegatedSource ? { source: delegatedSource } : {}),\n ...(parentInvoker ? { invoker: parentInvoker } : {}),\n entryPoint: 'delegate',\n })\n return { ok: true as const, agentId, data: agentResultPayload(result) }\n } catch (err) {\n if (isAgentInvokeDeniedError(err)) {\n return { ok: false as const, agentId, error: AGENT_INVOKE_DENIED_CODE }\n }\n if (isAgentPrincipalMissingError(err)) {\n return { ok: false as const, agentId, error: AGENT_PRINCIPAL_MISSING_CODE }\n }\n const message = err instanceof Error ? err.message : String(err)\n return { ok: false as const, agentId, error: message }\n }\n },\n}\n\nconst submitOutcomeInput = z.object({\n outcome: z\n .unknown()\n .describe(\n 'The structured result, matching the active agent OUTCOME contract. The active agent and its schema are resolved server-side from the run session \u2014 never trusted from this call.',\n ),\n // File plane (#12): ADVISORY captions for files the agent wrote into the sandbox\n // `out/` dir. Additive + optional (existing single-`outcome` callers stay valid).\n // The collector is FILESYSTEM-authoritative: it captures whatever is on disk and\n // uses these only to attach a caption (matched by relative path) \u2014 it never\n // trusts this list to invent, hide, or rename a file.\n artifacts: z\n .array(\n z.object({\n path: z.string().max(255).describe('Path of the produced file, relative to the sandbox out/ dir.'),\n caption: z.string().max(500).optional().describe('Short human description of the file.'),\n }),\n )\n .max(20)\n .optional()\n .describe('Optional captions for files written to the sandbox out/ directory.'),\n})\n\n/**\n * Terminal tool an OpenCode file-agent calls to deliver its structured result.\n *\n * The active agent id is resolved from the cross-process correlation store keyed\n * by THIS run's session token (`ctx.sessionId`, which the MCP HTTP server sets to\n * the session token the runner minted) \u2014 NOT trusted from the model. The store is\n * DB-backed because the runner and this tool run in different processes. The\n * agent's compiled OUTCOME schema is read from the registry; the submitted\n * `outcome` is validated against it:\n *\n * - valid \u2192 written to the store; the polling runner reads it back. `{ ok: true }`.\n * - invalid \u2192 `{ ok: false, code: 'outcome_invalid', errors }` so OpenCode/the\n * agent can correct and retry (NOT thrown). A non-JSON string is the\n * same: parsed first, then validated.\n * - missing/stale correlation (no run for this session, or already completed)\n * \u2192 `{ ok: false, code: 'no_active_run' }`.\n *\n * Propose-only: `isMutation: false` \u2014 the only state this ever produces is the\n * AgentRun/AgentProposal the runner persists from the captured outcome.\n */\nconst submitOutcomeTool: AiToolDefinition = {\n name: SUBMIT_OUTCOME_TOOL_ID,\n displayName: 'Submit agent outcome',\n description:\n 'Finish the current agent run by submitting its structured outcome (as the `outcome` argument object). The server validates it against the agent OUTCOME contract; on failure it returns the validation errors so you can correct and resubmit.',\n inputSchema: submitOutcomeInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { outcome } = submitOutcomeInput.parse(rawInput)\n const sessionToken = ctx.sessionId\n if (!sessionToken) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no run session in context' }\n }\n const store = ctx.container.resolve('agentRunSessionStore') as AgentRunSessionStore\n const agentId = await store.resolveActiveAgentId(sessionToken)\n if (!agentId) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no active run for this session' }\n }\n await ensureAgentsLoaded()\n const entry = getAgentEntry(agentId)\n if (!entry) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'active agent is no longer registered' }\n }\n // Models sometimes pass the outcome as a JSON STRING \u2014 parse it before validating.\n let outcomeValue = outcome\n if (typeof outcomeValue === 'string') {\n try {\n outcomeValue = JSON.parse(outcomeValue)\n } catch {\n return {\n ok: false as const,\n code: 'outcome_invalid' as const,\n errors: [{ path: '', message: 'outcome must be a JSON object, not an unparseable string' }],\n }\n }\n }\n const parsed = entry.schema.safeParse(outcomeValue)\n if (!parsed.success) {\n return {\n ok: false as const,\n code: 'outcome_invalid' as const,\n errors: parsed.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n })),\n }\n }\n const completion = await store.completeOutcome(sessionToken, parsed.data)\n if (completion !== 'completed') {\n // not_found (run gone) or already_completed \u2192 nothing more to capture.\n return { ok: false as const, code: 'no_active_run' as const, error: `run ${completion}` }\n }\n return { ok: true as const }\n },\n}\n\nconst loadSkillInput = z.object({\n skillId: z\n .string()\n .min(1)\n .describe('Id of the skill to load. Must be one of the active agent allowed skills.'),\n})\n\n/**\n * Progressive-disclosure FALLBACK for agent-local skills. Native OpenCode skills\n * (generated `SKILL.md` files) are the primary path; this MCP tool returns a\n * skill's full content on demand AND carries TEMPLATE.md/examples that native\n * skills may not bundle.\n *\n * The allowed skill set is the ACTIVE agent's skills \u2014 resolved server-side from\n * the native run context, or on the OpenCode path from the per-run correlation\n * store keyed by THIS run's session token (`ctx.sessionId`) \u2014 NEVER trusted from\n * the model. Outcomes:\n *\n * - missing/stale correlation (no run for this session) \u2192 `{ ok:false, code:'no_active_run' }`.\n * - skillId not registered for the active agent \u2192 `{ ok:false, code:'skill_not_allowed' }`.\n * - otherwise \u2192 `{ ok:true, instructions, template?, examples }`.\n *\n * Propose-only: `isMutation:false` \u2014 it only reads skill content.\n */\nconst loadSkillTool: AiToolDefinition = {\n name: LOAD_SKILL_TOOL_ID,\n displayName: 'Load agent skill',\n description:\n 'Load the full instructions (and optional template + examples) of one of the current agent skills, by skill id.',\n inputSchema: loadSkillInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { skillId } = loadSkillInput.parse(rawInput)\n const agentId = await resolveActiveAgentId(ctx.container, ctx.sessionId)\n if (!agentId) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no active run for this call' }\n }\n // Populate the file-agent skill registry before resolving \u2014 on a fresh\n // process this tool can be the first agent_orchestrator call, so the\n // registry would otherwise be empty and reject a valid skill.\n await ensureAgentsLoaded()\n const skill = getAgentSkill(agentId, skillId)\n if (!skill) {\n return {\n ok: false as const,\n code: 'skill_not_allowed' as const,\n error: `skill \"${skillId}\" is not available to the active agent`,\n }\n }\n return {\n ok: true as const,\n instructions: skill.instructions,\n ...(skill.template != null ? { template: skill.template } : {}),\n examples: skill.examples,\n }\n },\n}\n\nconst runSkillScriptInput = z.object({\n skillId: z\n .string()\n .min(1)\n .describe('Id of the skill the script belongs to (one of the current agent skills).'),\n scriptName: z\n .string()\n .min(1)\n .describe('Script basename without extension (e.g. `scripts/score.ts` \u2192 \"score\").'),\n args: z.unknown().optional().describe('Arguments passed to the script `run(args)` function.'),\n})\n\n/**\n * Run one of the active agent's sandboxed helper scripts (Phase 5) \u2014 a skill\n * `scripts/<name>.ts` or a local tool file (carried under the synthetic\n * `__agent_tools__` skill id) \u2014 and return its value.\n *\n * The active agent + its allowed skill/script set are resolved server-side (the\n * native run context, or the OpenCode run's correlation store keyed by\n * `ctx.sessionId`) \u2014 NEVER trusted from the model.\n * The script source runs in the Code Mode `isolated-vm` sandbox: no fs/net/\n * imports, a hard 30s cap, and per-call ACL via `requiredFeatures` + the session\n * token. A script is a pure function of its `args`, so this stays propose-only \u2014\n * it can compute, not mutate. Errors are returned as data, never thrown.\n */\nconst runSkillScriptTool: AiToolDefinition = {\n name: RUN_SKILL_SCRIPT_TOOL_ID,\n displayName: 'Run agent skill script',\n description:\n 'Run one of the current agent sandboxed helper scripts by skill id + script name and return its result. Scripts are pure functions of their args (no fs/net/side effects) executed in a sandbox.',\n inputSchema: runSkillScriptInput,\n requiredFeatures: ['agent_orchestrator.agents.run'],\n isMutation: false,\n tags: ['read', 'agent_orchestrator'],\n async handler(rawInput, ctx) {\n const { skillId, scriptName, args } = runSkillScriptInput.parse(rawInput)\n const agentId = await resolveActiveAgentId(ctx.container, ctx.sessionId)\n if (!agentId) {\n return { ok: false as const, code: 'no_active_run' as const, error: 'no active run for this call' }\n }\n // Populate the file-agent skill registry before resolving \u2014 on a fresh\n // process this tool can be the first agent_orchestrator call, so the\n // registry would otherwise be empty and reject a valid skill/script.\n await ensureAgentsLoaded()\n if (!getAgentSkill(agentId, skillId)) {\n return {\n ok: false as const,\n code: 'skill_not_allowed' as const,\n error: `skill \"${skillId}\" is not available to the active agent`,\n }\n }\n const script = getAgentSkillScript(agentId, skillId, scriptName)\n if (!script) {\n return {\n ok: false as const,\n code: 'script_not_found' as const,\n error: `script \"${scriptName}\" not found in skill \"${skillId}\"`,\n }\n }\n const outcome = await runSandboxedScript({ source: script.source, args })\n if (!outcome.ok) {\n return { ok: false as const, code: outcome.code, error: outcome.error }\n }\n return { ok: true as const, result: outcome.result }\n },\n}\n\nexport const aiTools: AiToolDefinition[] = [\n delegateAgentTool,\n submitOutcomeTool,\n loadSkillTool,\n runSkillSc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AAa;AAAA,EACb,aACE;AAAA,EACF,aAAa;AAAA,EACb,kBAAkB,CAAC,+BAA+B;AAAA,EAClD,YAAY;AAAA,EACZ,MAAM,CAAC,QAAQ,oBAAoB;AAAA,EACnC,MAAM,QAAQ,UAAU,KAAK;AAC3B,UAAM,EAAE,SAAS,YAAY,KAAK,IAAI,oBAAoB,MAAM,QAAQ;AACxE,UAAM,UAAU,MAAM,qBAAqB,IAAI,WAAW,IAAI,SAAS;AACvE,QAAI,CAAC,SAAS;AACZ,aAAO,EAAE,IAAI,OAAgB,MAAM,iBAA0B,OAAO,8BAA8B;AAAA,IACpG;AAIA,UAAM,mBAAmB;AACzB,QAAI,CAAC,cAAc,SAAS,OAAO,GAAG;AACpC,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,OAAO,UAAU,OAAO;AAAA,MAC1B;AAAA,IACF;AACA,UAAM,SAAS,oBAAoB,SAAS,SAAS,UAAU;AAC/D,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,OAAO,WAAW,UAAU,yBAAyB,OAAO;AAAA,MAC9D;AAAA,IACF;AACA,UAAM,UAAU,MAAM,mBAAmB,EAAE,QAAQ,OAAO,QAAQ,KAAK,CAAC;AACxE,QAAI,CAAC,QAAQ,IAAI;AACf,aAAO,EAAE,IAAI,OAAgB,MAAM,QAAQ,MAAM,OAAO,QAAQ,MAAM;AAAA,IACxE;AACA,WAAO,EAAE,IAAI,MAAe,QAAQ,QAAQ,OAAO;AAAA,EACrD;AACF;AAEO,MAAM,UAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
4
|
+
import { readJsonSafe } from "@open-mercato/shared/lib/http/readJsonSafe";
|
|
5
|
+
import { parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
|
|
6
|
+
import { readEndpointRateLimitConfig } from "@open-mercato/shared/lib/ratelimit/config";
|
|
7
|
+
import { rateLimitErrorSchema } from "@open-mercato/shared/lib/ratelimit/helpers";
|
|
8
|
+
import { validateCrudMutationGuard, runCrudMutationGuardAfterSuccess } from "@open-mercato/shared/lib/crud/mutation-guard";
|
|
9
|
+
import { resolveCorrelationId, CORRELATION_ID_HEADER } from "@open-mercato/ai-assistant/modules/ai_assistant/lib/mcp-audit";
|
|
10
|
+
import { agentRunRequestSchema } from "../../../../../data/validators.js";
|
|
11
|
+
import { invokeDeniedBody, invokeDeniedErrorSchema } from "../../../../../lib/access/invokeDenial.js";
|
|
12
|
+
import { enforcePublicEndpointRateLimit } from "../../../../../lib/guardrails/publicEndpointRateLimit.js";
|
|
13
|
+
import { verifyAgentToken } from "../../../../../lib/identity/agentTokenService.js";
|
|
14
|
+
import {
|
|
15
|
+
agentRunErrorResponse,
|
|
16
|
+
agentRunErrorSchema,
|
|
17
|
+
agentRunSuccessResponse,
|
|
18
|
+
agentRunSuccessResponseSchema,
|
|
19
|
+
createRunIdObserver,
|
|
20
|
+
callSettingsUnsupportedErrorSchema,
|
|
21
|
+
guardrailBlockedErrorSchema,
|
|
22
|
+
modelUnavailableErrorSchema,
|
|
23
|
+
parseAgentRunRequest,
|
|
24
|
+
unclassifiedErrorSchema,
|
|
25
|
+
outcomeSchemaRejectedErrorSchema
|
|
26
|
+
} from "../../../../../lib/runtime/agentRunHttp.js";
|
|
27
|
+
const metadata = {
|
|
28
|
+
POST: { requireAuth: false }
|
|
29
|
+
};
|
|
30
|
+
const AGENT_API_ENABLED_ENV = "OM_AGENT_API_ENABLED";
|
|
31
|
+
const AGENT_API_RUN_SCOPE = "agent_orchestrator.agents.run";
|
|
32
|
+
const agentApiRunRateLimitConfig = readEndpointRateLimitConfig("AGENT_ORCH_AGENT_API_RUN", {
|
|
33
|
+
points: 30,
|
|
34
|
+
duration: 60,
|
|
35
|
+
blockDuration: 60,
|
|
36
|
+
keyPrefix: "agent_orchestrator:agent_api_run"
|
|
37
|
+
});
|
|
38
|
+
const unauthorizedErrorSchema = z.object({ error: z.literal("unauthorized") });
|
|
39
|
+
function isAgentApiEnabled() {
|
|
40
|
+
return parseBooleanWithDefault(process.env[AGENT_API_ENABLED_ENV], false);
|
|
41
|
+
}
|
|
42
|
+
function readBearerToken(req) {
|
|
43
|
+
const header = req.headers.get("authorization");
|
|
44
|
+
if (!header) return null;
|
|
45
|
+
const match = /^Bearer\s+(\S+)\s*$/i.exec(header);
|
|
46
|
+
return match ? match[1] : null;
|
|
47
|
+
}
|
|
48
|
+
function grantsAgentRun(scopes, agentId) {
|
|
49
|
+
return scopes.includes(AGENT_API_RUN_SCOPE) || scopes.includes(`agent:${agentId}`);
|
|
50
|
+
}
|
|
51
|
+
function unauthorized() {
|
|
52
|
+
return NextResponse.json({ error: "unauthorized" }, { status: 401 });
|
|
53
|
+
}
|
|
54
|
+
async function POST(req, ctx) {
|
|
55
|
+
if (!isAgentApiEnabled()) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
|
56
|
+
const container = await createRequestContainer();
|
|
57
|
+
const rateLimited = await enforcePublicEndpointRateLimit(container, req, agentApiRunRateLimitConfig);
|
|
58
|
+
if (rateLimited) return rateLimited;
|
|
59
|
+
const token = readBearerToken(req);
|
|
60
|
+
if (!token) return unauthorized();
|
|
61
|
+
const verified = await verifyAgentToken(container, token);
|
|
62
|
+
if (!verified) return unauthorized();
|
|
63
|
+
const { id } = await ctx.params;
|
|
64
|
+
if (!grantsAgentRun(verified.scopes, id)) {
|
|
65
|
+
return NextResponse.json(invokeDeniedBody({ agentId: id }), { status: 403 });
|
|
66
|
+
}
|
|
67
|
+
const body = await readJsonSafe(req, {});
|
|
68
|
+
const parsed = parseAgentRunRequest(body);
|
|
69
|
+
if (!parsed.ok) return parsed.response;
|
|
70
|
+
const { claims } = verified;
|
|
71
|
+
const tenantId = claims.tenantId;
|
|
72
|
+
const organizationId = claims.organizationId;
|
|
73
|
+
const guardResult = await validateCrudMutationGuard(container, {
|
|
74
|
+
tenantId,
|
|
75
|
+
organizationId,
|
|
76
|
+
userId: claims.sub,
|
|
77
|
+
resourceKind: "agent_orchestrator.agent_run",
|
|
78
|
+
resourceId: id,
|
|
79
|
+
operation: "custom",
|
|
80
|
+
requestMethod: "POST",
|
|
81
|
+
requestHeaders: req.headers
|
|
82
|
+
});
|
|
83
|
+
if (guardResult && !guardResult.ok) {
|
|
84
|
+
return NextResponse.json(guardResult.body, { status: guardResult.status });
|
|
85
|
+
}
|
|
86
|
+
const runIdObserver = createRunIdObserver();
|
|
87
|
+
const runCtx = {
|
|
88
|
+
tenantId,
|
|
89
|
+
organizationId,
|
|
90
|
+
userId: claims.sub,
|
|
91
|
+
invoker: {
|
|
92
|
+
kind: "agent_token",
|
|
93
|
+
agentUserId: claims.sub,
|
|
94
|
+
onBehalfOfUserId: claims.obo ?? null,
|
|
95
|
+
grantId: claims.grantId
|
|
96
|
+
},
|
|
97
|
+
runAs: { agentUserId: claims.sub, onBehalfOfUserId: claims.obo ?? null },
|
|
98
|
+
entryPoint: "agent_api",
|
|
99
|
+
correlationId: resolveCorrelationId(req.headers.get(CORRELATION_ID_HEADER)),
|
|
100
|
+
onRunPersisted: runIdObserver.onRunPersisted,
|
|
101
|
+
...parsed.callSettings ? { callSettings: parsed.callSettings } : {}
|
|
102
|
+
};
|
|
103
|
+
let result;
|
|
104
|
+
try {
|
|
105
|
+
const agentRuntime = container.resolve("agentRuntime");
|
|
106
|
+
result = await agentRuntime.run(id, parsed.input, runCtx);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
return agentRunErrorResponse(err, id, runIdObserver.runId(), { exposeReason: false });
|
|
109
|
+
}
|
|
110
|
+
if (guardResult?.shouldRunAfterSuccess) {
|
|
111
|
+
await runCrudMutationGuardAfterSuccess(container, {
|
|
112
|
+
tenantId,
|
|
113
|
+
organizationId,
|
|
114
|
+
userId: claims.sub,
|
|
115
|
+
resourceKind: "agent_orchestrator.agent_run",
|
|
116
|
+
resourceId: id,
|
|
117
|
+
operation: "custom",
|
|
118
|
+
requestMethod: "POST",
|
|
119
|
+
requestHeaders: req.headers,
|
|
120
|
+
metadata: guardResult.metadata
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return agentRunSuccessResponse(container, result, runIdObserver.runId(), { tenantId, organizationId });
|
|
124
|
+
}
|
|
125
|
+
const openApi = {
|
|
126
|
+
tag: "Agent Orchestrator",
|
|
127
|
+
summary: "Run an agent with an agent token",
|
|
128
|
+
methods: {
|
|
129
|
+
POST: {
|
|
130
|
+
summary: "Run one agent as an external agent principal",
|
|
131
|
+
description: "The agent-token door. Disabled (404) unless OM_AGENT_API_ENABLED is on. Accepts only `Authorization: Bearer <agent access token>` minted by POST /identity/token; the delegation grant is re-checked on every request, so a revoked grant fails on the next call. The token scope must contain `agent_orchestrator.agents.run` or `agent:<id>`, and the target agent's required features are checked against the agent principal's role. Tenant and organization come from the token, never the request. The run executes as the agent principal on behalf of the delegating human. Request, response and run error contract match POST /agents/{id}/run.",
|
|
132
|
+
requestBody: {
|
|
133
|
+
contentType: "application/json",
|
|
134
|
+
schema: agentRunRequestSchema,
|
|
135
|
+
description: "Agent input payload (shape is agent-specific) plus optional `callSettings`, with the same limits as POST /agents/{id}/run."
|
|
136
|
+
},
|
|
137
|
+
responses: [
|
|
138
|
+
{
|
|
139
|
+
status: 200,
|
|
140
|
+
description: "Typed AgentResult + { runId, proposalId, integrity }",
|
|
141
|
+
schema: agentRunSuccessResponseSchema
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
errors: [
|
|
145
|
+
{
|
|
146
|
+
status: 401,
|
|
147
|
+
description: "Missing, invalid, expired or revoked agent token (minimal body, no detail)",
|
|
148
|
+
schema: unauthorizedErrorSchema
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
status: 403,
|
|
152
|
+
description: 'The token scope does not cover this agent, or the agent principal may not invoke it (`code: "agent_invoke_denied"`; required features are never echoed)',
|
|
153
|
+
schema: z.union([agentRunErrorSchema, invokeDeniedErrorSchema])
|
|
154
|
+
},
|
|
155
|
+
{ status: 404, description: "The agent API is disabled, or the agent id is unknown", schema: agentRunErrorSchema },
|
|
156
|
+
{
|
|
157
|
+
status: 422,
|
|
158
|
+
description: 'Invalid input or `callSettings`, invalid model output, run wall-clock timeout, `callSettings` the agent\'s runtime cannot apply (`code: "agent_call_settings_unsupported"`), or a runtime guardrail block (`code: "guardrail_blocked"`, with `kind`/`phase`/`guardrailSetVersion` and the blocking integrity `ruleId` or null)',
|
|
159
|
+
schema: z.union([agentRunErrorSchema, guardrailBlockedErrorSchema, callSettingsUnsupportedErrorSchema])
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
status: 429,
|
|
163
|
+
description: "Too many requests from this client IP, or agent run capacity exhausted; includes Retry-After",
|
|
164
|
+
schema: z.union([rateLimitErrorSchema, agentRunErrorSchema])
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
status: 500,
|
|
168
|
+
description: 'The run failed for a reason this route does not classify (`code: "agent_run_failed"`), or the LLM provider rejected the agent output schema (`code: "outcome_schema_rejected"`)',
|
|
169
|
+
schema: z.union([unclassifiedErrorSchema, outcomeSchemaRejectedErrorSchema])
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
status: 503,
|
|
173
|
+
description: "No usable LLM provider, or the rate limiter is unavailable",
|
|
174
|
+
schema: z.union([modelUnavailableErrorSchema, rateLimitErrorSchema])
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
export {
|
|
181
|
+
POST,
|
|
182
|
+
metadata,
|
|
183
|
+
openApi
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../src/modules/agent_orchestrator/api/agent-api/agents/%5Bid%5D/run/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'\nimport { parseBooleanWithDefault } from '@open-mercato/shared/lib/boolean'\nimport { readEndpointRateLimitConfig } from '@open-mercato/shared/lib/ratelimit/config'\nimport { rateLimitErrorSchema } from '@open-mercato/shared/lib/ratelimit/helpers'\nimport { validateCrudMutationGuard, runCrudMutationGuardAfterSuccess } from '@open-mercato/shared/lib/crud/mutation-guard'\nimport { resolveCorrelationId, CORRELATION_ID_HEADER } from '@open-mercato/ai-assistant/modules/ai_assistant/lib/mcp-audit'\nimport { agentRunRequestSchema } from '../../../../../data/validators'\nimport type { AgentRunCtx, AgentRuntimeService } from '../../../../../lib/runtime/agentRuntime'\nimport { invokeDeniedBody, invokeDeniedErrorSchema } from '../../../../../lib/access/invokeDenial'\nimport { enforcePublicEndpointRateLimit } from '../../../../../lib/guardrails/publicEndpointRateLimit'\nimport { verifyAgentToken } from '../../../../../lib/identity/agentTokenService'\nimport {\n agentRunErrorResponse,\n agentRunErrorSchema,\n agentRunSuccessResponse,\n agentRunSuccessResponseSchema,\n createRunIdObserver,\n callSettingsUnsupportedErrorSchema,\n guardrailBlockedErrorSchema,\n modelUnavailableErrorSchema,\n parseAgentRunRequest,\n unclassifiedErrorSchema,\n outcomeSchemaRejectedErrorSchema,\n} from '../../../../../lib/runtime/agentRunHttp'\n\n/**\n * The agent-token door (agent invocation access spec \u00A7E): an EXTERNAL agent runs\n * one agent with its own `aud=agent` Bearer token instead of a staff session, so\n * it sets `requireAuth: false`. The route is invisible (404) unless\n * `OM_AGENT_API_ENABLED` is on. Rate-limited per client IP BEFORE token\n * verification, which re-loads the delegation grant on every request (immediate\n * revocation). Any token failure is one minimal 401. The run executes with the\n * token principal as invoker and `runAs`, so the target agent's\n * `requiredFeatures` are checked against the principal's role by the runtime.\n */\nexport const metadata = {\n POST: { requireAuth: false },\n}\n\nconst AGENT_API_ENABLED_ENV = 'OM_AGENT_API_ENABLED'\nconst AGENT_API_RUN_SCOPE = 'agent_orchestrator.agents.run'\n\nconst agentApiRunRateLimitConfig = readEndpointRateLimitConfig('AGENT_ORCH_AGENT_API_RUN', {\n points: 30,\n duration: 60,\n blockDuration: 60,\n keyPrefix: 'agent_orchestrator:agent_api_run',\n})\n\nconst unauthorizedErrorSchema = z.object({ error: z.literal('unauthorized') })\n\nfunction isAgentApiEnabled(): boolean {\n return parseBooleanWithDefault(process.env[AGENT_API_ENABLED_ENV], false)\n}\n\nfunction readBearerToken(req: Request): string | null {\n const header = req.headers.get('authorization')\n if (!header) return null\n const match = /^Bearer\\s+(\\S+)\\s*$/i.exec(header)\n return match ? match[1] : null\n}\n\nfunction grantsAgentRun(scopes: string[], agentId: string): boolean {\n return scopes.includes(AGENT_API_RUN_SCOPE) || scopes.includes(`agent:${agentId}`)\n}\n\nfunction unauthorized(): NextResponse {\n return NextResponse.json({ error: 'unauthorized' }, { status: 401 })\n}\n\ntype RouteContext = { params: Promise<{ id: string }> }\n\nexport async function POST(req: Request, ctx: RouteContext) {\n if (!isAgentApiEnabled()) return NextResponse.json({ error: 'Not found' }, { status: 404 })\n\n const container = await createRequestContainer()\n const rateLimited = await enforcePublicEndpointRateLimit(container, req, agentApiRunRateLimitConfig)\n if (rateLimited) return rateLimited\n\n const token = readBearerToken(req)\n if (!token) return unauthorized()\n const verified = await verifyAgentToken(container, token)\n if (!verified) return unauthorized()\n\n const { id } = await ctx.params\n if (!grantsAgentRun(verified.scopes, id)) {\n return NextResponse.json(invokeDeniedBody({ agentId: id }), { status: 403 })\n }\n\n const body = await readJsonSafe(req, {})\n const parsed = parseAgentRunRequest(body)\n if (!parsed.ok) return parsed.response\n\n const { claims } = verified\n const tenantId = claims.tenantId\n const organizationId = claims.organizationId\n\n const guardResult = await validateCrudMutationGuard(container, {\n tenantId,\n organizationId,\n userId: claims.sub,\n resourceKind: 'agent_orchestrator.agent_run',\n resourceId: id,\n operation: 'custom',\n requestMethod: 'POST',\n requestHeaders: req.headers,\n })\n if (guardResult && !guardResult.ok) {\n return NextResponse.json(guardResult.body, { status: guardResult.status })\n }\n\n const runIdObserver = createRunIdObserver()\n const runCtx: AgentRunCtx = {\n tenantId,\n organizationId,\n userId: claims.sub,\n invoker: {\n kind: 'agent_token',\n agentUserId: claims.sub,\n onBehalfOfUserId: claims.obo ?? null,\n grantId: claims.grantId,\n },\n runAs: { agentUserId: claims.sub, onBehalfOfUserId: claims.obo ?? null },\n entryPoint: 'agent_api',\n correlationId: resolveCorrelationId(req.headers.get(CORRELATION_ID_HEADER)),\n onRunPersisted: runIdObserver.onRunPersisted,\n ...(parsed.callSettings ? { callSettings: parsed.callSettings } : {}),\n }\n\n let result: unknown\n try {\n const agentRuntime = container.resolve('agentRuntime') as AgentRuntimeService\n result = await agentRuntime.run(id, parsed.input, runCtx)\n } catch (err) {\n return agentRunErrorResponse(err, id, runIdObserver.runId(), { exposeReason: false })\n }\n\n if (guardResult?.shouldRunAfterSuccess) {\n await runCrudMutationGuardAfterSuccess(container, {\n tenantId,\n organizationId,\n userId: claims.sub,\n resourceKind: 'agent_orchestrator.agent_run',\n resourceId: id,\n operation: 'custom',\n requestMethod: 'POST',\n requestHeaders: req.headers,\n metadata: guardResult.metadata,\n })\n }\n\n return agentRunSuccessResponse(container, result, runIdObserver.runId(), { tenantId, organizationId })\n}\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Agent Orchestrator',\n summary: 'Run an agent with an agent token',\n methods: {\n POST: {\n summary: 'Run one agent as an external agent principal',\n description:\n 'The agent-token door. Disabled (404) unless OM_AGENT_API_ENABLED is on. Accepts only `Authorization: Bearer <agent access token>` minted by POST /identity/token; the delegation grant is re-checked on every request, so a revoked grant fails on the next call. The token scope must contain `agent_orchestrator.agents.run` or `agent:<id>`, and the target agent\\'s required features are checked against the agent principal\\'s role. Tenant and organization come from the token, never the request. The run executes as the agent principal on behalf of the delegating human. Request, response and run error contract match POST /agents/{id}/run.',\n requestBody: {\n contentType: 'application/json',\n schema: agentRunRequestSchema,\n description: 'Agent input payload (shape is agent-specific) plus optional `callSettings`, with the same limits as POST /agents/{id}/run.',\n },\n responses: [\n {\n status: 200,\n description: 'Typed AgentResult + { runId, proposalId, integrity }',\n schema: agentRunSuccessResponseSchema,\n },\n ],\n errors: [\n {\n status: 401,\n description: 'Missing, invalid, expired or revoked agent token (minimal body, no detail)',\n schema: unauthorizedErrorSchema,\n },\n {\n status: 403,\n description:\n 'The token scope does not cover this agent, or the agent principal may not invoke it (`code: \"agent_invoke_denied\"`; required features are never echoed)',\n schema: z.union([agentRunErrorSchema, invokeDeniedErrorSchema]),\n },\n { status: 404, description: 'The agent API is disabled, or the agent id is unknown', schema: agentRunErrorSchema },\n {\n status: 422,\n description:\n 'Invalid input or `callSettings`, invalid model output, run wall-clock timeout, `callSettings` the agent\\'s runtime cannot apply (`code: \"agent_call_settings_unsupported\"`), or a runtime guardrail block (`code: \"guardrail_blocked\"`, with `kind`/`phase`/`guardrailSetVersion` and the blocking integrity `ruleId` or null)',\n schema: z.union([agentRunErrorSchema, guardrailBlockedErrorSchema, callSettingsUnsupportedErrorSchema]),\n },\n {\n status: 429,\n description: 'Too many requests from this client IP, or agent run capacity exhausted; includes Retry-After',\n schema: z.union([rateLimitErrorSchema, agentRunErrorSchema]),\n },\n {\n status: 500,\n description:\n 'The run failed for a reason this route does not classify (`code: \"agent_run_failed\"`), or the LLM provider rejected the agent output schema (`code: \"outcome_schema_rejected\"`)',\n schema: z.union([unclassifiedErrorSchema, outcomeSchemaRejectedErrorSchema]),\n },\n {\n status: 503,\n description: 'No usable LLM provider, or the r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AA,UACR,aAAa;AAAA,UACb,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,MACA,QAAQ;AAAA,QACN;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,QAAQ;AAAA,QACV;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,aACE;AAAA,UACF,QAAQ,EAAE,MAAM,CAAC,qBAAqB,uBAAuB,CAAC;AAAA,QAChE;AAAA,QACA,EAAE,QAAQ,KAAK,aAAa,yDAAyD,QAAQ,oBAAoB;AAAA,QACjH;AAAA,UACE,QAAQ;AAAA,UACR,aACE;AAAA,UACF,QAAQ,EAAE,MAAM,CAAC,qBAAqB,6BAA6B,kCAAkC,CAAC;AAAA,QACxG;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,QAAQ,EAAE,MAAM,CAAC,sBAAsB,mBAAmB,CAAC;AAAA,QAC7D;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,aACE;AAAA,UACF,QAAQ,EAAE,MAAM,CAAC,yBAAyB,gCAAgC,CAAC;AAAA,QAC7E;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,QAAQ,EAAE,MAAM,CAAC,6BAA6B,oBAAoB,CAAC;AAAA,QACrE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getAuthFromRequest } from "@open-mercato/shared/lib/auth/server";
|
|
4
4
|
import { getAgentEntry, ensureAgentsLoaded } from "../../../../lib/sdk/defineAgent.js";
|
|
5
|
+
import { resolveAgentDefinitionSource } from "../../../../lib/sdk/agentDefinitionSource.js";
|
|
5
6
|
const metadata = {
|
|
6
7
|
GET: { requireAuth: true, requireFeatures: ["agent_orchestrator.agents.view"] }
|
|
7
8
|
};
|
|
@@ -34,7 +35,7 @@ async function GET(req, ctx) {
|
|
|
34
35
|
await ensureAgentsLoaded();
|
|
35
36
|
const entry = getAgentEntry(id);
|
|
36
37
|
if (!entry) return NextResponse.json({ error: "Agent not found" }, { status: 404 });
|
|
37
|
-
if (entry
|
|
38
|
+
if (resolveAgentDefinitionSource(entry) !== "file" || !entry.sourceFiles) {
|
|
38
39
|
return NextResponse.json({ error: "Agent has no source files" }, { status: 404 });
|
|
39
40
|
}
|
|
40
41
|
return NextResponse.json({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/agent_orchestrator/api/agents/%5Bid%5D/files/route.ts"],
|
|
4
|
-
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { getAgentEntry, ensureAgentsLoaded } from '../../../../lib/sdk/defineAgent'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['agent_orchestrator.agents.view'] },\n}\n\nconst sourceFileSchema = z.object({\n path: z.string(),\n content: z.string(),\n tokens: z.number(),\n inContext: z.boolean(),\n})\n\nconst tokenizedFileSchema = z.object({ path: z.string(), tokens: z.number() })\nconst tokenUsageSchema = z.object({\n total: z.number(),\n self: z.number(),\n agent: z.number(),\n outcome: z.number(),\n skills: z.array(z.object({ id: z.string(), tokens: z.number(), files: z.array(tokenizedFileSchema) })),\n tools: z.array(z.object({ name: z.string(), path: z.string(), tokens: z.number() })),\n subAgents: z.array(z.object({ id: z.string(), tokens: z.number() })),\n})\n\nconst filesResponseSchema = z.object({\n agentId: z.string(),\n files: z.array(sourceFileSchema),\n tokenUsage: tokenUsageSchema.nullable(),\n})\n\nconst errorSchema = z.object({ error: z.string() })\n\ntype RouteContext = { params: Promise<{ id: string }> }\n\nexport async function GET(req: Request, ctx: RouteContext) {\n const auth = await getAuthFromRequest(req)\n if (!auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n const { id } = await ctx.params\n await ensureAgentsLoaded()\n const entry = getAgentEntry(id)\n if (!entry) return NextResponse.json({ error: 'Agent not found' }, { status: 404 })\n // The Files tab is a read-only view of a file-defined
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,eAAe,0BAA0B;
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { getAgentEntry, ensureAgentsLoaded } from '../../../../lib/sdk/defineAgent'\nimport { resolveAgentDefinitionSource } from '../../../../lib/sdk/agentDefinitionSource'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['agent_orchestrator.agents.view'] },\n}\n\nconst sourceFileSchema = z.object({\n path: z.string(),\n content: z.string(),\n tokens: z.number(),\n inContext: z.boolean(),\n})\n\nconst tokenizedFileSchema = z.object({ path: z.string(), tokens: z.number() })\nconst tokenUsageSchema = z.object({\n total: z.number(),\n self: z.number(),\n agent: z.number(),\n outcome: z.number(),\n skills: z.array(z.object({ id: z.string(), tokens: z.number(), files: z.array(tokenizedFileSchema) })),\n tools: z.array(z.object({ name: z.string(), path: z.string(), tokens: z.number() })),\n subAgents: z.array(z.object({ id: z.string(), tokens: z.number() })),\n})\n\nconst filesResponseSchema = z.object({\n agentId: z.string(),\n files: z.array(sourceFileSchema),\n tokenUsage: tokenUsageSchema.nullable(),\n})\n\nconst errorSchema = z.object({ error: z.string() })\n\ntype RouteContext = { params: Promise<{ id: string }> }\n\nexport async function GET(req: Request, ctx: RouteContext) {\n const auth = await getAuthFromRequest(req)\n if (!auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n const { id } = await ctx.params\n await ensureAgentsLoaded()\n const entry = getAgentEntry(id)\n if (!entry) return NextResponse.json({ error: 'Agent not found' }, { status: 404 })\n // The Files tab is a read-only view of a file-defined agent's source, whatever\n // runtime it executes on. Code agents have no baked files \u2192 404 so the UI never\n // renders the tab for them.\n if (resolveAgentDefinitionSource(entry) !== 'file' || !entry.sourceFiles) {\n return NextResponse.json({ error: 'Agent has no source files' }, { status: 404 })\n }\n return NextResponse.json({\n agentId: entry.id,\n files: entry.sourceFiles,\n tokenUsage: entry.tokenUsage ?? null,\n })\n}\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Agent Orchestrator',\n summary: 'Get an agent definition files',\n methods: {\n GET: {\n summary: \"Read a file-defined agent's raw definition files\",\n description:\n \"Returns the baked raw content and o200k_base token count of every construction file (AGENT.md, OUTCOME.md, skills, tools, sub-agents) of a file-defined (OpenCode) agent, for the read-only Files tab. 404 for native agents. Gated by agent_orchestrator.agents.view.\",\n responses: [\n { status: 200, description: 'Agent source files', schema: filesResponseSchema },\n ],\n errors: [\n { status: 401, description: 'Unauthorized', schema: errorSchema },\n { status: 403, description: 'Missing agent_orchestrator.agents.view', schema: errorSchema },\n { status: 404, description: 'Unknown agent id or native agent (no files)', schema: errorSchema },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,eAAe,0BAA0B;AAClD,SAAS,oCAAoC;AAEtC,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,gCAAgC,EAAE;AAChF;AAEA,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,OAAO;AAAA,EACf,SAAS,EAAE,OAAO;AAAA,EAClB,QAAQ,EAAE,OAAO;AAAA,EACjB,WAAW,EAAE,QAAQ;AACvB,CAAC;AAED,MAAM,sBAAsB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,CAAC;A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