@nodetool-ai/execution 0.8.1
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/README.md +129 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/app-debug/app-spec.d.ts +94 -0
- package/dist/app-debug/app-spec.d.ts.map +1 -0
- package/dist/app-debug/app-spec.js +710 -0
- package/dist/app-debug/app-spec.js.map +1 -0
- package/dist/app-debug/application-target.d.ts +53 -0
- package/dist/app-debug/application-target.d.ts.map +1 -0
- package/dist/app-debug/application-target.js +126 -0
- package/dist/app-debug/application-target.js.map +1 -0
- package/dist/app-debug/bundle-target.d.ts +21 -0
- package/dist/app-debug/bundle-target.d.ts.map +1 -0
- package/dist/app-debug/bundle-target.js +51 -0
- package/dist/app-debug/bundle-target.js.map +1 -0
- package/dist/app-debug/graph-shape.d.ts +14 -0
- package/dist/app-debug/graph-shape.d.ts.map +1 -0
- package/dist/app-debug/graph-shape.js +23 -0
- package/dist/app-debug/graph-shape.js.map +1 -0
- package/dist/app-debug/index.d.ts +26 -0
- package/dist/app-debug/index.d.ts.map +1 -0
- package/dist/app-debug/index.js +19 -0
- package/dist/app-debug/index.js.map +1 -0
- package/dist/app-debug/markdown.d.ts +6 -0
- package/dist/app-debug/markdown.d.ts.map +1 -0
- package/dist/app-debug/markdown.js +133 -0
- package/dist/app-debug/markdown.js.map +1 -0
- package/dist/app-debug/runtime.d.ts +267 -0
- package/dist/app-debug/runtime.d.ts.map +1 -0
- package/dist/app-debug/runtime.js +633 -0
- package/dist/app-debug/runtime.js.map +1 -0
- package/dist/app-debug/script-operation.d.ts +58 -0
- package/dist/app-debug/script-operation.d.ts.map +1 -0
- package/dist/app-debug/script-operation.js +44 -0
- package/dist/app-debug/script-operation.js.map +1 -0
- package/dist/app-debug/simulate.d.ts +85 -0
- package/dist/app-debug/simulate.d.ts.map +1 -0
- package/dist/app-debug/simulate.js +991 -0
- package/dist/app-debug/simulate.js.map +1 -0
- package/dist/app-debug/summarize.d.ts +64 -0
- package/dist/app-debug/summarize.d.ts.map +1 -0
- package/dist/app-debug/summarize.js +65 -0
- package/dist/app-debug/summarize.js.map +1 -0
- package/dist/app-debug/types.d.ts +343 -0
- package/dist/app-debug/types.d.ts.map +1 -0
- package/dist/app-debug/types.js +2 -0
- package/dist/app-debug/types.js.map +1 -0
- package/dist/cost-ledger.d.ts +147 -0
- package/dist/cost-ledger.d.ts.map +1 -0
- package/dist/cost-ledger.js +288 -0
- package/dist/cost-ledger.js.map +1 -0
- package/dist/debug/collector.d.ts +28 -0
- package/dist/debug/collector.d.ts.map +1 -0
- package/dist/debug/collector.js +284 -0
- package/dist/debug/collector.js.map +1 -0
- package/dist/debug/index.d.ts +15 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +16 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/types.d.ts +179 -0
- package/dist/debug/types.d.ts.map +1 -0
- package/dist/debug/types.js +11 -0
- package/dist/debug/types.js.map +1 -0
- package/dist/debug/verdict.d.ts +27 -0
- package/dist/debug/verdict.d.ts.map +1 -0
- package/dist/debug/verdict.js +51 -0
- package/dist/debug/verdict.js.map +1 -0
- package/dist/executor-resolver.d.ts +13 -0
- package/dist/executor-resolver.d.ts.map +1 -0
- package/dist/executor-resolver.js +13 -0
- package/dist/executor-resolver.js.map +1 -0
- package/dist/fal-output-decoder.d.ts +36 -0
- package/dist/fal-output-decoder.d.ts.map +1 -0
- package/dist/fal-output-decoder.js +129 -0
- package/dist/fal-output-decoder.js.map +1 -0
- package/dist/generation-lifecycle.d.ts +54 -0
- package/dist/generation-lifecycle.d.ts.map +1 -0
- package/dist/generation-lifecycle.js +431 -0
- package/dist/generation-lifecycle.js.map +1 -0
- package/dist/generation-recovery-worker.d.ts +100 -0
- package/dist/generation-recovery-worker.d.ts.map +1 -0
- package/dist/generation-recovery-worker.js +995 -0
- package/dist/generation-recovery-worker.js.map +1 -0
- package/dist/generation-tracker.d.ts +83 -0
- package/dist/generation-tracker.d.ts.map +1 -0
- package/dist/generation-tracker.js +436 -0
- package/dist/generation-tracker.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/js-script-debug/index.d.ts +13 -0
- package/dist/js-script-debug/index.d.ts.map +1 -0
- package/dist/js-script-debug/index.js +12 -0
- package/dist/js-script-debug/index.js.map +1 -0
- package/dist/js-script-debug/markdown.d.ts +6 -0
- package/dist/js-script-debug/markdown.d.ts.map +1 -0
- package/dist/js-script-debug/markdown.js +62 -0
- package/dist/js-script-debug/markdown.js.map +1 -0
- package/dist/js-script-debug/outputs.d.ts +20 -0
- package/dist/js-script-debug/outputs.d.ts.map +1 -0
- package/dist/js-script-debug/outputs.js +30 -0
- package/dist/js-script-debug/outputs.js.map +1 -0
- package/dist/js-script-debug/report.d.ts +15 -0
- package/dist/js-script-debug/report.d.ts.map +1 -0
- package/dist/js-script-debug/report.js +90 -0
- package/dist/js-script-debug/report.js.map +1 -0
- package/dist/js-script-debug/types.d.ts +63 -0
- package/dist/js-script-debug/types.d.ts.map +1 -0
- package/dist/js-script-debug/types.js +10 -0
- package/dist/js-script-debug/types.js.map +1 -0
- package/dist/js-script-debug/validate.d.ts +38 -0
- package/dist/js-script-debug/validate.d.ts.map +1 -0
- package/dist/js-script-debug/validate.js +137 -0
- package/dist/js-script-debug/validate.js.map +1 -0
- package/dist/message-stream.d.ts +33 -0
- package/dist/message-stream.d.ts.map +1 -0
- package/dist/message-stream.js +58 -0
- package/dist/message-stream.js.map +1 -0
- package/dist/normalize-graph.d.ts +13 -0
- package/dist/normalize-graph.d.ts.map +1 -0
- package/dist/normalize-graph.js +63 -0
- package/dist/normalize-graph.js.map +1 -0
- package/dist/output-names.d.ts +13 -0
- package/dist/output-names.d.ts.map +1 -0
- package/dist/output-names.js +13 -0
- package/dist/output-names.js.map +1 -0
- package/dist/predicates.d.ts +6 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +6 -0
- package/dist/predicates.js.map +1 -0
- package/dist/preflight.d.ts +87 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +139 -0
- package/dist/preflight.js.map +1 -0
- package/dist/provider-secret-key.d.ts +3 -0
- package/dist/provider-secret-key.d.ts.map +1 -0
- package/dist/provider-secret-key.js +7 -0
- package/dist/provider-secret-key.js.map +1 -0
- package/dist/service/app-debug-service.d.ts +78 -0
- package/dist/service/app-debug-service.d.ts.map +1 -0
- package/dist/service/app-debug-service.js +201 -0
- package/dist/service/app-debug-service.js.map +1 -0
- package/dist/service/app-run-server.d.ts +28 -0
- package/dist/service/app-run-server.d.ts.map +1 -0
- package/dist/service/app-run-server.js +104 -0
- package/dist/service/app-run-server.js.map +1 -0
- package/dist/service/debug-sessions.d.ts +158 -0
- package/dist/service/debug-sessions.d.ts.map +1 -0
- package/dist/service/debug-sessions.js +358 -0
- package/dist/service/debug-sessions.js.map +1 -0
- package/dist/service/index.d.ts +22 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +17 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/job-progress.d.ts +40 -0
- package/dist/service/job-progress.d.ts.map +1 -0
- package/dist/service/job-progress.js +53 -0
- package/dist/service/job-progress.js.map +1 -0
- package/dist/service/workflow-run.d.ts +279 -0
- package/dist/service/workflow-run.d.ts.map +1 -0
- package/dist/service/workflow-run.js +598 -0
- package/dist/service/workflow-run.js.map +1 -0
- package/dist/service/workflow-workspace.d.ts +89 -0
- package/dist/service/workflow-workspace.d.ts.map +1 -0
- package/dist/service/workflow-workspace.js +160 -0
- package/dist/service/workflow-workspace.js.map +1 -0
- package/dist/session.d.ts +62 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +353 -0
- package/dist/session.js.map +1 -0
- package/dist/sketch-debug/index.d.ts +11 -0
- package/dist/sketch-debug/index.d.ts.map +1 -0
- package/dist/sketch-debug/index.js +10 -0
- package/dist/sketch-debug/index.js.map +1 -0
- package/dist/sketch-debug/markdown.d.ts +6 -0
- package/dist/sketch-debug/markdown.d.ts.map +1 -0
- package/dist/sketch-debug/markdown.js +93 -0
- package/dist/sketch-debug/markdown.js.map +1 -0
- package/dist/sketch-debug/report.d.ts +15 -0
- package/dist/sketch-debug/report.d.ts.map +1 -0
- package/dist/sketch-debug/report.js +98 -0
- package/dist/sketch-debug/report.js.map +1 -0
- package/dist/sketch-debug/types.d.ts +62 -0
- package/dist/sketch-debug/types.d.ts.map +1 -0
- package/dist/sketch-debug/types.js +10 -0
- package/dist/sketch-debug/types.js.map +1 -0
- package/dist/sketch-debug/validate.d.ts +14 -0
- package/dist/sketch-debug/validate.d.ts.map +1 -0
- package/dist/sketch-debug/validate.js +478 -0
- package/dist/sketch-debug/validate.js.map +1 -0
- package/dist/supervisor.d.ts +45 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +97 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/timeline-debug/index.d.ts +11 -0
- package/dist/timeline-debug/index.d.ts.map +1 -0
- package/dist/timeline-debug/index.js +10 -0
- package/dist/timeline-debug/index.js.map +1 -0
- package/dist/timeline-debug/legibility.d.ts +23 -0
- package/dist/timeline-debug/legibility.d.ts.map +1 -0
- package/dist/timeline-debug/legibility.js +240 -0
- package/dist/timeline-debug/legibility.js.map +1 -0
- package/dist/timeline-debug/markdown.d.ts +6 -0
- package/dist/timeline-debug/markdown.d.ts.map +1 -0
- package/dist/timeline-debug/markdown.js +103 -0
- package/dist/timeline-debug/markdown.js.map +1 -0
- package/dist/timeline-debug/motion.d.ts +20 -0
- package/dist/timeline-debug/motion.d.ts.map +1 -0
- package/dist/timeline-debug/motion.js +362 -0
- package/dist/timeline-debug/motion.js.map +1 -0
- package/dist/timeline-debug/report.d.ts +16 -0
- package/dist/timeline-debug/report.d.ts.map +1 -0
- package/dist/timeline-debug/report.js +100 -0
- package/dist/timeline-debug/report.js.map +1 -0
- package/dist/timeline-debug/showcase.d.ts +7 -0
- package/dist/timeline-debug/showcase.d.ts.map +1 -0
- package/dist/timeline-debug/showcase.js +347 -0
- package/dist/timeline-debug/showcase.js.map +1 -0
- package/dist/timeline-debug/types.d.ts +64 -0
- package/dist/timeline-debug/types.d.ts.map +1 -0
- package/dist/timeline-debug/types.js +10 -0
- package/dist/timeline-debug/types.js.map +1 -0
- package/dist/timeline-debug/validate.d.ts +24 -0
- package/dist/timeline-debug/validate.d.ts.map +1 -0
- package/dist/timeline-debug/validate.js +1432 -0
- package/dist/timeline-debug/validate.js.map +1 -0
- package/dist/types.d.ts +211 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +103 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/execution – Public API
|
|
3
|
+
*/
|
|
4
|
+
export { ExecutionSession } from "./session.js";
|
|
5
|
+
export { DurableGenerationLifecycle, createDurableGenerationLifecycle, createFalGenerationLifecycleHooks } from "./generation-lifecycle.js";
|
|
6
|
+
export { DurableGenerationRecoveryWorker } from "./generation-recovery-worker.js";
|
|
7
|
+
export { decodeFalOutputs, deterministicFalStorageKey, type FalOutputDescriptor } from "./fal-output-decoder.js";
|
|
8
|
+
export type { DurableGenerationRecoveryOptions, DurableRecoveryProvider, DurableRecoveryRunResult, DurableRecoverySubmission } from "./generation-recovery-worker.js";
|
|
9
|
+
export type { DurableGenerationAcceptance, GenerationLeaseWindow, FalGenerationLifecycleHooksOptions } from "./generation-lifecycle.js";
|
|
10
|
+
export { normalizeGraph, toRawGraphInput } from "./normalize-graph.js";
|
|
11
|
+
export { assertPreflight, collectPreflightIssues, ExecutionPreflightError, formatPreflightDetail, isExecutionPreflightError, modelSelectionErrors, providerConfigurationChecker, unconfiguredProviderErrors, RUNTIME_CATALOGS } from "./preflight.js";
|
|
12
|
+
export type { CredentialResolver, ExecutionPreflightIssue, PreflightIssueKind, PreflightOptions, ProviderConfigurationChecker, RunModelCatalogs } from "./preflight.js";
|
|
13
|
+
export { DEFAULT_MESSAGE_BUFFER_LIMIT } from "./message-stream.js";
|
|
14
|
+
export { attachRunCostLedger, isUnitBilledCapability, nodeTypeLookup, priceGeneration, recordFromMessage, recordGenerationSpend, recordNodeProviderCost } from "./cost-ledger.js";
|
|
15
|
+
export type { CostLedgerSource, RunCostLedgerHandle, GenerationSpend, NodeCostSpend, PricedGeneration, RunCostLedgerOptions } from "./cost-ledger.js";
|
|
16
|
+
export { createTrackerState, drainReconcileQueue, generationsForNode, linkGenerationAssets, reconcileGeneration, reconcileRow, resetGenerationTrackerState, startGenerationReconcileWorker, sweepInterruptedGenerations, trackPredictionMessage } from "./generation-tracker.js";
|
|
17
|
+
export type { GenerationTrackerState, ReconcileOutcome, ReconcileSecretResolver } from "./generation-tracker.js";
|
|
18
|
+
export { INTERVENTION_MARK, formatInterventionLine, formatSupervisedSummary, summarizeInterventions } from "./supervisor.js";
|
|
19
|
+
export type { SupervisedRunSummary } from "./supervisor.js";
|
|
20
|
+
export type { BridgeFactory, Edge, ExecutionLimits, ExecutionSessionOptions, JobPersistenceHook, NodeDescriptor, ProcessingMessage, RawGraphInput, RunResult, SupervisorHandle } from "./types.js";
|
|
21
|
+
export type { NodeTypeResolver, ResolvedNodeType } from "@nodetool-ai/kernel";
|
|
22
|
+
export { collectExecutionSummary, previewValue } from "./debug/collector.js";
|
|
23
|
+
export { buildRunVerdict, collectInterventionWarnings, collectRunIssues, describeErrors } from "./debug/verdict.js";
|
|
24
|
+
export type { DebugError, DebugGraph, DebugTargetInfo, DebugVerdict, EdgeDebug, ExecutionSummary, LlmCallDebug, LogEntry, NodeDebug, NodeOutput, RunVerdict, ServerRunReport, TraceSummary } from "./debug/types.js";
|
|
25
|
+
export { simulateApp, defaultInteractions } from "./app-debug/index.js";
|
|
26
|
+
export type { AppServerRunInput, AppServerRunOutcome, AppSimulationDeps } from "./app-debug/simulate.js";
|
|
27
|
+
export type * from "./app-debug/types.js";
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,gCAAgC,EAChC,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,kCAAkC,EACnC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb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
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/execution – Public API
|
|
3
|
+
*/
|
|
4
|
+
export { ExecutionSession } from "./session.js";
|
|
5
|
+
export { DurableGenerationLifecycle, createDurableGenerationLifecycle, createFalGenerationLifecycleHooks } from "./generation-lifecycle.js";
|
|
6
|
+
export { DurableGenerationRecoveryWorker } from "./generation-recovery-worker.js";
|
|
7
|
+
export { decodeFalOutputs, deterministicFalStorageKey } from "./fal-output-decoder.js";
|
|
8
|
+
export { normalizeGraph, toRawGraphInput } from "./normalize-graph.js";
|
|
9
|
+
export { assertPreflight, collectPreflightIssues, ExecutionPreflightError, formatPreflightDetail, isExecutionPreflightError, modelSelectionErrors, providerConfigurationChecker, unconfiguredProviderErrors, RUNTIME_CATALOGS } from "./preflight.js";
|
|
10
|
+
export { DEFAULT_MESSAGE_BUFFER_LIMIT } from "./message-stream.js";
|
|
11
|
+
export { attachRunCostLedger, isUnitBilledCapability, nodeTypeLookup, priceGeneration, recordFromMessage, recordGenerationSpend, recordNodeProviderCost } from "./cost-ledger.js";
|
|
12
|
+
export { createTrackerState, drainReconcileQueue, generationsForNode, linkGenerationAssets, reconcileGeneration, reconcileRow, resetGenerationTrackerState, startGenerationReconcileWorker, sweepInterruptedGenerations, trackPredictionMessage } from "./generation-tracker.js";
|
|
13
|
+
export { INTERVENTION_MARK, formatInterventionLine, formatSupervisedSummary, summarizeInterventions } from "./supervisor.js";
|
|
14
|
+
// Debug surface: one execution-summary vocabulary + triage for every host that
|
|
15
|
+
// reports on a run (CLI harness, HTTP debug endpoint, agent tools).
|
|
16
|
+
export { collectExecutionSummary, previewValue } from "./debug/collector.js";
|
|
17
|
+
export { buildRunVerdict, collectInterventionWarnings, collectRunIssues, describeErrors } from "./debug/verdict.js";
|
|
18
|
+
// App-debug surface: one headless simulation of a mini app for every host that
|
|
19
|
+
// reports on one (CLI `app debug`, the agent build loop, the server).
|
|
20
|
+
export { simulateApp, defaultInteractions } from "./app-debug/index.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAE3B,MAAM,yBAAyB,CAAC;AAYjC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAgBzB,+EAA+E;AAC/E,oEAAoE;AACpE,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAiB5B,+EAA+E;AAC/E,sEAAsE;AACtE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nodetool-ai/execution/js-script-debug` — JS script validation + debug
|
|
3
|
+
* report.
|
|
4
|
+
*
|
|
5
|
+
* Pure core: no DB, no sandbox, no browser. Hosts (the CLI `jsscript` command,
|
|
6
|
+
* the `validate_js_script` capability) resolve the target and write the bundle.
|
|
7
|
+
*/
|
|
8
|
+
export type { JsScriptDebugIssue, JsScriptValidation, JsScriptInteractionRecord, JsScriptDebugTarget, JsScriptDocumentMeta, JsScriptDebugReport } from "./types.js";
|
|
9
|
+
export { validateJsScriptDoc, type JsScriptValidationOptions } from "./validate.js";
|
|
10
|
+
export { missingDeclaredJsScriptOutputs, emptyDeclaredJsScriptOutputsError } from "./outputs.js";
|
|
11
|
+
export { buildJsScriptDebugReport, type JsScriptDebugReportInput } from "./report.js";
|
|
12
|
+
export { renderJsScriptReportMarkdown } from "./markdown.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/js-script-debug/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nodetool-ai/execution/js-script-debug` — JS script validation + debug
|
|
3
|
+
* report.
|
|
4
|
+
*
|
|
5
|
+
* Pure core: no DB, no sandbox, no browser. Hosts (the CLI `jsscript` command,
|
|
6
|
+
* the `validate_js_script` capability) resolve the target and write the bundle.
|
|
7
|
+
*/
|
|
8
|
+
export { validateJsScriptDoc } from "./validate.js";
|
|
9
|
+
export { missingDeclaredJsScriptOutputs, emptyDeclaredJsScriptOutputsError } from "./outputs.js";
|
|
10
|
+
export { buildJsScriptDebugReport } from "./report.js";
|
|
11
|
+
export { renderJsScriptReportMarkdown } from "./markdown.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/js-script-debug/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,EACL,mBAAmB,EAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EAClC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EAEzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a `JsScriptDebugReport` as human-readable Markdown for the bundle.
|
|
3
|
+
*/
|
|
4
|
+
import type { JsScriptDebugReport } from "./types.js";
|
|
5
|
+
export declare function renderJsScriptReportMarkdown(report: JsScriptDebugReport): string;
|
|
6
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/js-script-debug/markdown.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAsB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA+B1E,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,mBAAmB,GAC1B,MAAM,CAsDR"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isString } from "../predicates.js";
|
|
2
|
+
const short = (value, max = 120) => {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return "—";
|
|
5
|
+
let s;
|
|
6
|
+
try {
|
|
7
|
+
s = isString(value) ? value : JSON.stringify(value);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
s = String(value);
|
|
11
|
+
}
|
|
12
|
+
s = (s ?? "null").replace(/\s+/g, " ");
|
|
13
|
+
return s.length > max ? `${s.slice(0, max)}…` : s;
|
|
14
|
+
};
|
|
15
|
+
function issueTable(title, issues, lines) {
|
|
16
|
+
if (issues.length === 0)
|
|
17
|
+
return;
|
|
18
|
+
lines.push("", `## ${title}`, "");
|
|
19
|
+
lines.push("| Severity | Code | Where | Message |");
|
|
20
|
+
lines.push("| --- | --- | --- | --- |");
|
|
21
|
+
for (const issue of issues) {
|
|
22
|
+
lines.push(`| ${issue.severity} | \`${issue.code}\` | ${issue.path ? `\`${issue.path}\`` : "—"} | ${short(issue.message, 300)} |`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function renderJsScriptReportMarkdown(report) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
const title = report.target.name ?? report.target.ref;
|
|
28
|
+
lines.push(`# JS script debug: ${title}`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
lines.push(`${report.verdict.ok ? "✅" : "❌"} ${report.verdict.headline}`);
|
|
31
|
+
lines.push("");
|
|
32
|
+
lines.push(`Target: \`${report.target.ref}\` (${report.target.kind})`);
|
|
33
|
+
lines.push(`Document: ${report.meta.inputCount} input(s), ${report.meta.outputCount} output(s), ` +
|
|
34
|
+
`${report.meta.packageCount} package(s), ${report.meta.secretCount} secret(s), ` +
|
|
35
|
+
`${report.meta.testCount} test(s) · timeout ${report.meta.timeoutSeconds}s · ` +
|
|
36
|
+
`${report.meta.codeLength} chars of code`);
|
|
37
|
+
if (report.verdict.issues.length > 0) {
|
|
38
|
+
lines.push("", "## Issues", "");
|
|
39
|
+
for (const issue of report.verdict.issues)
|
|
40
|
+
lines.push(`- ${issue}`);
|
|
41
|
+
}
|
|
42
|
+
issueTable("Validation", [...report.validation.errors, ...report.validation.warnings], lines);
|
|
43
|
+
if (report.interactions.length > 0) {
|
|
44
|
+
lines.push("", "## Interactions", "");
|
|
45
|
+
lines.push("| Tool | OK | Input | Error |");
|
|
46
|
+
lines.push("| --- | --- | --- | --- |");
|
|
47
|
+
for (const step of report.interactions) {
|
|
48
|
+
lines.push(`| \`${step.tool}\` | ${step.ok ? "✅" : "❌"} | ${short(step.input)} | ${step.error ? short(step.error, 200) : "—"} |`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (report.finalValidation) {
|
|
52
|
+
issueTable("Validation after edits", [...report.finalValidation.errors, ...report.finalValidation.warnings], lines);
|
|
53
|
+
}
|
|
54
|
+
if (report.notSimulated.length > 0) {
|
|
55
|
+
lines.push("", "## Not simulated", "");
|
|
56
|
+
for (const entry of report.notSimulated)
|
|
57
|
+
lines.push(`- ${entry}`);
|
|
58
|
+
}
|
|
59
|
+
lines.push("");
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/js-script-debug/markdown.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,GAAG,GAAG,GAAG,EAAU,EAAE;IAClD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACpC,IAAI,CAAS,CAAC;IACd,IAAI,CAAC;QACH,CAAC,GAAG,Q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
|
|
1
|
+
/**
|
|
2
|
+
* Runtime contract for a JS-script run: a document that declares output
|
|
3
|
+
* ports cannot succeed with an empty output bag.
|
|
4
|
+
*
|
|
5
|
+
* Shared by the HTTP run route and the eval headless bridge so both
|
|
6
|
+
* surfaces fail the same `{ok: true, outputs: {}}` hole.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Declared output names that a successful run left out of the bag.
|
|
10
|
+
*
|
|
11
|
+
* Returns every declared name only when none of them appear — the empty-bag
|
|
12
|
+
* false success. If any declared name is present, returns [] and leaves a
|
|
13
|
+
* partial bag to other checks. No declared ports is never a miss.
|
|
14
|
+
*/
|
|
15
|
+
export declare function missingDeclaredJsScriptOutputs(declared: readonly {
|
|
16
|
+
name: string;
|
|
17
|
+
}[], outputs: Record<string, unknown> | undefined): string[];
|
|
18
|
+
/** Error text when {@link missingDeclaredJsScriptOutputs} is non-empty. */
|
|
19
|
+
export declare function emptyDeclaredJsScriptOutputsError(missing: readonly string[]): string;
|
|
20
|
+
//# sourceMappingURL=outputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../../src/js-script-debug/outputs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,MAAM,EAAE,CAMV;AAED,2EAA2E;AAC3E,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CAMR"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime contract for a JS-script run: a document that declares output
|
|
3
|
+
* ports cannot succeed with an empty output bag.
|
|
4
|
+
*
|
|
5
|
+
* Shared by the HTTP run route and the eval headless bridge so both
|
|
6
|
+
* surfaces fail the same `{ok: true, outputs: {}}` hole.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Declared output names that a successful run left out of the bag.
|
|
10
|
+
*
|
|
11
|
+
* Returns every declared name only when none of them appear — the empty-bag
|
|
12
|
+
* false success. If any declared name is present, returns [] and leaves a
|
|
13
|
+
* partial bag to other checks. No declared ports is never a miss.
|
|
14
|
+
*/
|
|
15
|
+
export function missingDeclaredJsScriptOutputs(declared, outputs) {
|
|
16
|
+
if (declared.length === 0)
|
|
17
|
+
return [];
|
|
18
|
+
const bag = outputs ?? {};
|
|
19
|
+
const missing = declared.map((port) => port.name).filter((name) => !(name in bag));
|
|
20
|
+
if (missing.length !== declared.length)
|
|
21
|
+
return [];
|
|
22
|
+
return missing;
|
|
23
|
+
}
|
|
24
|
+
/** Error text when {@link missingDeclaredJsScriptOutputs} is non-empty. */
|
|
25
|
+
export function emptyDeclaredJsScriptOutputsError(missing) {
|
|
26
|
+
return (`The run produced none of the declared outputs: ${missing.join(", ")}. ` +
|
|
27
|
+
"Leave values with `await output(name, value)` or `await emit(name, value)` — " +
|
|
28
|
+
"an empty output bag is not success.");
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=outputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outputs.js","sourceRoot":"","sources":["../../src/js-script-debug/outputs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAAqC,EACrC,OAA4C;IAE5C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,GAAG,GAAG,OAAO,IAAI,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IACnF,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAClD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,iCAAiC,CAC/C,OAA0B;IAE1B,OAAO,CACL,kDAAkD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QACxE,+EAA+E;QAC/E,qCAAqC,CACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JsScriptDebugReport, JsScriptDebugTarget, JsScriptInteractionRecord } from "./types.js";
|
|
2
|
+
import { type JsScriptValidationOptions } from "./validate.js";
|
|
3
|
+
export interface JsScriptDebugReportInput {
|
|
4
|
+
target: JsScriptDebugTarget;
|
|
5
|
+
/** The document as loaded — untrusted, validated here. */
|
|
6
|
+
document: unknown;
|
|
7
|
+
options?: JsScriptValidationOptions;
|
|
8
|
+
interactions?: JsScriptInteractionRecord[];
|
|
9
|
+
/** Bridge snapshot after the scripted session. */
|
|
10
|
+
finalState?: unknown;
|
|
11
|
+
/** The document the session left behind, validated as a second pass. */
|
|
12
|
+
finalDocument?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildJsScriptDebugReport(input: JsScriptDebugReportInput): Promise<JsScriptDebugReport>;
|
|
15
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/js-script-debug/report.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,mBAAmB,EACnB,mBAAmB,EAEnB,yBAAyB,EAE1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,eAAe,CAAC;AAwFvB,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,mBAAmB,CAAC,CA2B9B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assembles a `JsScriptDebugReport` from a document, an optional scripted edit
|
|
3
|
+
* session, and the document that session left behind.
|
|
4
|
+
*
|
|
5
|
+
* Pure: the host resolves the target (file, id) and writes the bundle; this
|
|
6
|
+
* decides what the run means.
|
|
7
|
+
*/
|
|
8
|
+
import { JS_SCRIPT_DEFAULT_TIMEOUT_SECONDS } from "@nodetool-ai/protocol/api-schemas/js-scripts.js";
|
|
9
|
+
import { validateJsScriptDoc } from "./validate.js";
|
|
10
|
+
import { isFiniteNumber, isString } from "../predicates.js";
|
|
11
|
+
/**
|
|
12
|
+
* What a headless JS-script run cannot answer. Fixed, because the boundary is
|
|
13
|
+
* a property of the harness, not of the document it was pointed at.
|
|
14
|
+
*/
|
|
15
|
+
const NOT_SIMULATED = [
|
|
16
|
+
"The editor — Monaco, the assistant panel, the ports/packages/secrets controls, and the run console render nothing headlessly.",
|
|
17
|
+
"Version history — a debug session never snapshots or restores; use `jsscript versions` for that.",
|
|
18
|
+
"Persistence — a scripted session edits an in-memory document and is never saved back onto the row.",
|
|
19
|
+
"Secret values — a run reads only the secrets the document declares, and the store is per-install."
|
|
20
|
+
];
|
|
21
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
+
const count = (value) => Array.isArray(value) ? value.length : 0;
|
|
23
|
+
function describeDocument(document) {
|
|
24
|
+
const record = isRecord(document) ? document : {};
|
|
25
|
+
const timeout = record.timeoutSeconds;
|
|
26
|
+
return {
|
|
27
|
+
inputCount: count(record.inputs),
|
|
28
|
+
outputCount: count(record.outputs),
|
|
29
|
+
packageCount: count(record.packages),
|
|
30
|
+
secretCount: count(record.secrets),
|
|
31
|
+
testCount: count(record.tests),
|
|
32
|
+
timeoutSeconds: isFiniteNumber(timeout)
|
|
33
|
+
? timeout
|
|
34
|
+
: JS_SCRIPT_DEFAULT_TIMEOUT_SECONDS,
|
|
35
|
+
codeLength: isString(record.code) ? record.code.length : 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const describe = (issue) => issue.path
|
|
39
|
+
? `[${issue.code}] ${issue.path}: ${issue.message}`
|
|
40
|
+
: `[${issue.code}] ${issue.message}`;
|
|
41
|
+
function buildVerdict(validation, interactions, finalValidation) {
|
|
42
|
+
const failedSteps = interactions.filter((step) => !step.ok);
|
|
43
|
+
const issues = [
|
|
44
|
+
...validation.errors.map(describe),
|
|
45
|
+
...failedSteps.map((step) => `Interaction \`${step.tool}\` failed${step.error ? `: ${step.error}` : ""}`),
|
|
46
|
+
...(finalValidation?.errors ?? []).map((issue) => `After edits — ${describe(issue)}`)
|
|
47
|
+
];
|
|
48
|
+
const warnings = [
|
|
49
|
+
...validation.warnings.map(describe),
|
|
50
|
+
...(finalValidation?.warnings ?? []).map((issue) => `After edits — ${describe(issue)}`)
|
|
51
|
+
];
|
|
52
|
+
const ok = issues.length === 0;
|
|
53
|
+
const headline = ok
|
|
54
|
+
? `Script is sound — ${interactions.length} interaction(s) ran clean` +
|
|
55
|
+
(warnings.length > 0 ? `, ${warnings.length} warning(s)` : "") +
|
|
56
|
+
"."
|
|
57
|
+
: `Script has ${issues.length} problem(s)` +
|
|
58
|
+
(failedSteps.length > 0
|
|
59
|
+
? `, ${failedSteps.length} failed interaction(s)`
|
|
60
|
+
: "") +
|
|
61
|
+
(warnings.length > 0 ? `, ${warnings.length} warning(s)` : "") +
|
|
62
|
+
` — ${issues[0]}`;
|
|
63
|
+
return warnings.length > 0
|
|
64
|
+
? { ok, headline, issues, warnings }
|
|
65
|
+
: { ok, headline, issues };
|
|
66
|
+
}
|
|
67
|
+
export async function buildJsScriptDebugReport(input) {
|
|
68
|
+
const options = input.options ?? {};
|
|
69
|
+
const validation = await validateJsScriptDoc(input.document, options);
|
|
70
|
+
const finalValidation = input.finalDocument === undefined
|
|
71
|
+
? undefined
|
|
72
|
+
: await validateJsScriptDoc(input.finalDocument, options);
|
|
73
|
+
const interactions = input.interactions ?? [];
|
|
74
|
+
const report = {
|
|
75
|
+
target: input.target,
|
|
76
|
+
meta: describeDocument(input.finalDocument ?? input.document),
|
|
77
|
+
validation,
|
|
78
|
+
interactions,
|
|
79
|
+
notSimulated: [...NOT_SIMULATED],
|
|
80
|
+
verdict: buildVerdict(validation, interactions, finalValidation)
|
|
81
|
+
};
|
|
82
|
+
if (input.finalState !== undefined) {
|
|
83
|
+
report.finalState = input.finalState;
|
|
84
|
+
}
|
|
85
|
+
if (finalValidation) {
|
|
86
|
+
report.finalValidation = finalValidation;
|
|
87
|
+
}
|
|
88
|
+
return report;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/js-script-debug/report.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAC;AAUpG,OAAO,EACL,mBAAmB,EAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAK1B;;;GAGG;AACH,MAAM,aAAa,GAA0B;IAC3C,+HAA+H;IAC/H,kGAAkG;IAClG,oGAAoG;IACpG,mGAAmG;CACpG,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAA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G,KAAK,CAAC,UAAU,CAAC;IACvC,CAAC;IACD,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS script debug vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* One report shape for "is this script document sound, and what did a scripted
|
|
5
|
+
* edit session leave behind" — shared by the CLI `jsscript validate` /
|
|
6
|
+
* `jsscript debug` commands and the `validate_js_script` capability, the same
|
|
7
|
+
* way `../sketch-debug/types.ts` is shared by the sketch surfaces.
|
|
8
|
+
*/
|
|
9
|
+
import type { DebugVerdict } from "../debug/types.js";
|
|
10
|
+
/** One finding against a JS script document. */
|
|
11
|
+
export interface JsScriptDebugIssue {
|
|
12
|
+
severity: "error" | "warning";
|
|
13
|
+
/** Stable machine code, e.g. `js_script_duplicate_port`, `code_syntax`. */
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
/** JSON path of the offending field, for schema findings. */
|
|
17
|
+
path?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface JsScriptValidation {
|
|
20
|
+
/** True when there are no errors. Warnings do not clear `ok`. */
|
|
21
|
+
ok: boolean;
|
|
22
|
+
errors: JsScriptDebugIssue[];
|
|
23
|
+
warnings: JsScriptDebugIssue[];
|
|
24
|
+
}
|
|
25
|
+
/** One executed step of a `--interact` script. */
|
|
26
|
+
export interface JsScriptInteractionRecord {
|
|
27
|
+
/** Tool name as invoked (canonical `ui_jsscript_*` form). */
|
|
28
|
+
tool: string;
|
|
29
|
+
input: unknown;
|
|
30
|
+
ok: boolean;
|
|
31
|
+
result?: unknown;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface JsScriptDebugTarget {
|
|
35
|
+
kind: "file" | "id";
|
|
36
|
+
ref: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface JsScriptDocumentMeta {
|
|
40
|
+
inputCount: number;
|
|
41
|
+
outputCount: number;
|
|
42
|
+
packageCount: number;
|
|
43
|
+
secretCount: number;
|
|
44
|
+
testCount: number;
|
|
45
|
+
timeoutSeconds: number;
|
|
46
|
+
codeLength: number;
|
|
47
|
+
}
|
|
48
|
+
export interface JsScriptDebugReport {
|
|
49
|
+
target: JsScriptDebugTarget;
|
|
50
|
+
meta: JsScriptDocumentMeta;
|
|
51
|
+
/** Static validation of the input document. */
|
|
52
|
+
validation: JsScriptValidation;
|
|
53
|
+
/** Scripted edit session, when one ran. */
|
|
54
|
+
interactions: JsScriptInteractionRecord[];
|
|
55
|
+
/** Bridge snapshot after the script. */
|
|
56
|
+
finalState?: unknown;
|
|
57
|
+
/** Validation of the document the session left behind. */
|
|
58
|
+
finalValidation?: JsScriptValidation;
|
|
59
|
+
/** What a headless run cannot answer. */
|
|
60
|
+
notSimulated: string[];
|
|
61
|
+
verdict: DebugVerdict;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/js-script-debug/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED,kDAAkD;AAClD,MAAM,WAAW,yBAAyB;IACxC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,2CAA2C;IAC3C,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC,yCAAyC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC;CACvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS script debug vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* One report shape for "is this script document sound, and what did a scripted
|
|
5
|
+
* edit session leave behind" — shared by the CLI `jsscript validate` /
|
|
6
|
+
* `jsscript debug` commands and the `validate_js_script` capability, the same
|
|
7
|
+
* way `../sketch-debug/types.ts` is shared by the sketch surfaces.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/js-script-debug/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The static check behind `nodetool jsscript validate` and the
|
|
3
|
+
* `validate_js_script` capability.
|
|
4
|
+
*
|
|
5
|
+
* Two layers, neither forked:
|
|
6
|
+
*
|
|
7
|
+
* - the document's shape and internal consistency come from
|
|
8
|
+
* `validateJsScriptDocument` in `@nodetool-ai/protocol` — the same function
|
|
9
|
+
* the model's `beforeSave` and the tRPC router run;
|
|
10
|
+
* - the body analysis comes from `validateCodeNodeBody` in
|
|
11
|
+
* `@nodetool-ai/node-sdk` — the same function `validateGraph` runs over a
|
|
12
|
+
* Code node, given the document's declared ports. A script has no packages
|
|
13
|
+
* setting: every installed pack and every platform module resolves by import.
|
|
14
|
+
*
|
|
15
|
+
* On top of both, two rules only a script has: outputs that leave through
|
|
16
|
+
* `return` instead of `emit`/`output` are an error (a script is a new surface,
|
|
17
|
+
* so there is no legacy contract to support), and a declared secret the
|
|
18
|
+
* install does not carry is a warning. Secrets are passed in rather than read
|
|
19
|
+
* here, so a file target stays database-free.
|
|
20
|
+
*/
|
|
21
|
+
import type { SandboxModuleCatalog } from "@nodetool-ai/runtime";
|
|
22
|
+
import type { JsScriptValidation } from "./types.js";
|
|
23
|
+
export interface JsScriptValidationOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Secret names this install carries. A declared secret missing from the list
|
|
26
|
+
* is a warning. Omit to skip the check — the store is per-install, and a file
|
|
27
|
+
* target has no database to read it from.
|
|
28
|
+
*/
|
|
29
|
+
knownSecrets?: readonly string[];
|
|
30
|
+
/** The installed sandbox catalog, when the caller has one. */
|
|
31
|
+
sandboxModuleCatalog?: SandboxModuleCatalog | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check a JS script document without running it. Returns findings rather than
|
|
35
|
+
* throwing: every caller renders them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateJsScriptDoc(document: unknown, options?: JsScriptValidationOptions): Promise<JsScriptValidation>;
|
|
38
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/js-script-debug/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,8DAA8D;IAC9D,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD;AAsED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,OAAO,EACjB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,kBAAkB,CAAC,CAgE7B"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The static check behind `nodetool jsscript validate` and the
|
|
3
|
+
* `validate_js_script` capability.
|
|
4
|
+
*
|
|
5
|
+
* Two layers, neither forked:
|
|
6
|
+
*
|
|
7
|
+
* - the document's shape and internal consistency come from
|
|
8
|
+
* `validateJsScriptDocument` in `@nodetool-ai/protocol` — the same function
|
|
9
|
+
* the model's `beforeSave` and the tRPC router run;
|
|
10
|
+
* - the body analysis comes from `validateCodeNodeBody` in
|
|
11
|
+
* `@nodetool-ai/node-sdk` — the same function `validateGraph` runs over a
|
|
12
|
+
* Code node, given the document's declared ports. A script has no packages
|
|
13
|
+
* setting: every installed pack and every platform module resolves by import.
|
|
14
|
+
*
|
|
15
|
+
* On top of both, two rules only a script has: outputs that leave through
|
|
16
|
+
* `return` instead of `emit`/`output` are an error (a script is a new surface,
|
|
17
|
+
* so there is no legacy contract to support), and a declared secret the
|
|
18
|
+
* install does not carry is a warning. Secrets are passed in rather than read
|
|
19
|
+
* here, so a file target stays database-free.
|
|
20
|
+
*/
|
|
21
|
+
import { jsScriptDocument, validateJsScriptDocument } from "@nodetool-ai/protocol/api-schemas/js-scripts.js";
|
|
22
|
+
function split(issues) {
|
|
23
|
+
const errors = issues.filter((issue) => issue.severity === "error");
|
|
24
|
+
const warnings = issues.filter((issue) => issue.severity === "warning");
|
|
25
|
+
return { ok: errors.length === 0, errors, warnings };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A body still on the return contract: it declares outputs and calls neither
|
|
29
|
+
* `emit` nor `output`, so nothing ever reaches a handle.
|
|
30
|
+
*/
|
|
31
|
+
function legacyContractIssue(doc, usesEmitOutputContract) {
|
|
32
|
+
const code = doc.code.trim();
|
|
33
|
+
if (code === "" || doc.outputs.length === 0)
|
|
34
|
+
return null;
|
|
35
|
+
if (usesEmitOutputContract(doc.code))
|
|
36
|
+
return null;
|
|
37
|
+
return {
|
|
38
|
+
severity: "error",
|
|
39
|
+
code: "js_script_legacy_contract",
|
|
40
|
+
message: "The body declares outputs but calls neither emit() nor output(). A " +
|
|
41
|
+
"script has no return contract: stream a value with " +
|
|
42
|
+
"`await emit(name, value)` and set a final one with " +
|
|
43
|
+
"`await output(name, value)`."
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Where the saved cases and the body disagree about how inputs arrive.
|
|
48
|
+
*
|
|
49
|
+
* A case stages items for a body that never calls `stream`: nothing pulls them,
|
|
50
|
+
* so the case tests less than it looks like it does. A streaming body whose
|
|
51
|
+
* cases stage nothing: every `stream` completes immediately, so the case proves
|
|
52
|
+
* only that the body survives an empty inbox.
|
|
53
|
+
*/
|
|
54
|
+
function testStreamIssues(doc, streaming) {
|
|
55
|
+
const staged = doc.tests.filter((testCase) => Object.keys(testCase.inputStreams ?? {}).length > 0);
|
|
56
|
+
if (!streaming) {
|
|
57
|
+
return staged.map((testCase) => ({
|
|
58
|
+
severity: "warning",
|
|
59
|
+
code: "js_script_test_streams_unused",
|
|
60
|
+
message: `test "${testCase.name}" stages input streams, but the body never ` +
|
|
61
|
+
"calls stream() — the staged items are never read. Read them with " +
|
|
62
|
+
"`for await (const item of stream(name))`, or move them to `inputs`."
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
if (doc.tests.length > 0 && staged.length === 0) {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
severity: "warning",
|
|
69
|
+
code: "js_script_tests_no_streams",
|
|
70
|
+
message: "The body reads its inputs with stream(), but no saved test stages " +
|
|
71
|
+
"any items — every stream ends immediately. Give a case " +
|
|
72
|
+
"`inputStreams` so the cases exercise what the body does."
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check a JS script document without running it. Returns findings rather than
|
|
80
|
+
* throwing: every caller renders them.
|
|
81
|
+
*/
|
|
82
|
+
export async function validateJsScriptDoc(document, options = {}) {
|
|
83
|
+
const shapeIssues = validateJsScriptDocument(document).map((issue) => ({
|
|
84
|
+
severity: issue.severity,
|
|
85
|
+
code: issue.code,
|
|
86
|
+
message: issue.message
|
|
87
|
+
}));
|
|
88
|
+
const parsed = jsScriptDocument.safeParse(document);
|
|
89
|
+
if (!parsed.success) {
|
|
90
|
+
// The document does not even parse, so there is nothing to analyze; the
|
|
91
|
+
// schema findings are the whole answer.
|
|
92
|
+
return split(shapeIssues);
|
|
93
|
+
}
|
|
94
|
+
const doc = parsed.data;
|
|
95
|
+
const { validateCodeNodeBody, usesEmitOutputContract, usesStreamInputContract } = await import("@nodetool-ai/node-sdk");
|
|
96
|
+
// A script has no node-configured property values: every declared input is
|
|
97
|
+
// fed by the caller, which is what the graph calls a connected handle. Saying
|
|
98
|
+
// so is what makes the streaming rules right here — `stream("x")` on a
|
|
99
|
+
// declared input never warns "nothing feeds it", and reading a declared input
|
|
100
|
+
// through `inputs.x` in a streaming body is the error it is in a graph.
|
|
101
|
+
const inputNames = doc.inputs.map((port) => port.name);
|
|
102
|
+
const bodyIssues = validateCodeNodeBody({
|
|
103
|
+
code: doc.code,
|
|
104
|
+
availableInputs: inputNames,
|
|
105
|
+
connectedInputs: inputNames,
|
|
106
|
+
declaredOutputs: doc.outputs.map((port) => port.name),
|
|
107
|
+
sandboxModuleCatalog: options.sandboxModuleCatalog ?? null
|
|
108
|
+
}).map((issue) => ({
|
|
109
|
+
severity: issue.severity,
|
|
110
|
+
code: issue.code,
|
|
111
|
+
message: issue.message
|
|
112
|
+
}));
|
|
113
|
+
const issues = [...shapeIssues, ...bodyIssues];
|
|
114
|
+
const streaming = usesStreamInputContract(doc.code);
|
|
115
|
+
// A streaming body on the return contract is already an error from the body
|
|
116
|
+
// check (`code_stream_return_contract`), which says the same thing.
|
|
117
|
+
const legacy = streaming
|
|
118
|
+
? null
|
|
119
|
+
: legacyContractIssue(doc, usesEmitOutputContract);
|
|
120
|
+
if (legacy)
|
|
121
|
+
issues.push(legacy);
|
|
122
|
+
issues.push(...testStreamIssues(doc, streaming));
|
|
123
|
+
if (options.knownSecrets !== undefined) {
|
|
124
|
+
const known = new Set(options.knownSecrets);
|
|
125
|
+
for (const name of doc.secrets) {
|
|
126
|
+
if (name.trim() !== "" && !known.has(name)) {
|
|
127
|
+
issues.push({
|
|
128
|
+
severity: "warning",
|
|
129
|
+
code: "js_script_secret_missing",
|
|
130
|
+
message: `Declared secret "${name}" is not in this install's secret store.`
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return split(issues);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=validate.js.map
|