spawnfile 0.1.32 → 0.1.34
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 +1 -1
- package/dist/auth/trainingAuth.d.ts +2 -5
- package/dist/cli/devCommands.d.ts +1 -1
- package/dist/cli/devCommands.js +0 -66
- package/dist/cli/runCli.d.ts +1 -4
- package/dist/cli/runCli.js +2 -2
- package/dist/cli/trainCommand.js +9 -15
- package/dist/cli/trainingBooted.d.ts +7 -0
- package/dist/cli/trainingBooted.js +41 -0
- package/dist/cli/trainingExecution.d.ts +4 -7
- package/dist/cli/trainingExecution.js +4 -32
- package/dist/compiler/containerArtifacts.js +0 -5
- package/dist/compiler/containerBackedMountRender.js +5 -1
- package/dist/compiler/containerDaimonBrokerRender.d.ts +5 -50
- package/dist/compiler/containerDaimonBrokerRender.js +7 -88
- package/dist/compiler/containerDaimonGatewayRender.d.ts +50 -0
- package/dist/compiler/containerDaimonGatewayRender.js +157 -0
- package/dist/compiler/containerDaimonGrokWorkerProvisioning.d.ts +2 -10
- package/dist/compiler/containerDaimonGrokWorkerProvisioning.js +13 -25
- package/dist/compiler/containerDaimonGrokWorkerRender.d.ts +11 -49
- package/dist/compiler/containerDaimonGrokWorkerRender.js +15 -39
- package/dist/compiler/containerDaimonStartupSupervision.d.ts +8 -0
- package/dist/compiler/containerDaimonStartupSupervision.js +39 -0
- package/dist/compiler/containerDaimonUidEntrypointRender.d.ts +1 -2
- package/dist/compiler/containerDaimonUidEntrypointRender.js +26 -46
- package/dist/compiler/containerRuntimeReadinessRender.js +1 -1
- package/dist/compiler/memoryArtifacts.js +0 -1
- package/dist/compiler/moltnetArtifacts.js +1 -17
- package/dist/compiler/moltnetClientConfig.js +1 -1
- package/dist/compiler/moltnetRuntimeConfig.js +0 -10
- package/dist/compiler/runProject.d.ts +1 -0
- package/dist/compiler/runProject.js +9 -3
- package/dist/compiler/runProjectAuth.js +2 -17
- package/dist/compiler/training/contract.d.ts +0 -2
- package/dist/compiler/training/contract.js +0 -2
- package/dist/compiler/training/execution.d.ts +1 -128
- package/dist/compiler/training/execution.js +7 -68
- package/dist/compiler/training/index.d.ts +0 -8
- package/dist/compiler/training/index.js +0 -7
- package/dist/compiler/training/output.d.ts +1 -0
- package/dist/compiler/training/output.js +1 -1
- package/dist/compiler/training/trial/boot.d.ts +53 -0
- package/dist/compiler/training/trial/boot.js +147 -0
- package/dist/compiler/training/trial/docker.d.ts +8 -0
- package/dist/compiler/training/trial/docker.js +22 -0
- package/dist/compiler/training/trial/gateway.d.ts +42 -0
- package/dist/compiler/training/trial/gateway.js +98 -0
- package/dist/compiler/training/trial/index.d.ts +4 -0
- package/dist/compiler/training/trial/index.js +4 -0
- package/dist/compiler/training/trial/launcher.d.ts +32 -0
- package/dist/compiler/training/trial/launcher.js +49 -0
- package/dist/compiler/training/trial/project.d.ts +11 -0
- package/dist/compiler/training/trial/project.js +31 -0
- package/dist/compiler/upReceipt.d.ts +2 -17
- package/dist/compiler/upReceipt.js +2 -17
- package/dist/deployment/artifactsExportPlan.js +2 -18
- package/dist/deployment/privateArtifactsExport.js +1 -1
- package/dist/dev/docker.d.ts +0 -5
- package/dist/dev/docker.js +0 -46
- package/dist/dev/index.d.ts +0 -1
- package/dist/dev/index.js +0 -1
- package/dist/dev/project.d.ts +0 -16
- package/dist/dev/project.js +1 -128
- package/dist/distribution/distributionReportSchema.js +1 -1
- package/dist/distribution/imageRuntimeAuth.js +3 -2
- package/dist/release/drainControl.d.ts +5 -19
- package/dist/release/drainControl.js +12 -67
- package/dist/report/types.d.ts +3 -6
- package/dist/runtime/common.d.ts +1 -1
- package/dist/runtime/common.js +1 -1
- package/dist/runtime/container.d.ts +2 -2
- package/dist/runtime/container.js +1 -39
- package/dist/runtime/daimon/config.js +6 -12
- package/dist/runtime/daimon/contractManifest.js +0 -1
- package/dist/runtime/daimon/contractManifestSchema.js +0 -1
- package/dist/runtime/daimon/control.d.ts +31 -0
- package/dist/runtime/daimon/control.js +83 -0
- package/dist/runtime/daimon/engineDescriptorSchema.js +0 -1
- package/dist/runtime/daimon/engineDescriptors.generated.d.ts +1 -1
- package/dist/runtime/daimon/engineDescriptors.generated.js +1 -2
- package/dist/runtime/daimon/engines.js +0 -1
- package/dist/runtime/daimon/gateway.d.ts +62 -0
- package/dist/runtime/daimon/gateway.js +77 -0
- package/dist/runtime/daimon/grokWorkerContract.d.ts +0 -5
- package/dist/runtime/daimon/grokWorkerContract.js +1 -13
- package/dist/runtime/daimon/index.d.ts +2 -0
- package/dist/runtime/daimon/index.js +2 -1
- package/dist/runtime/daimon/memory.js +1 -1
- package/dist/runtime/daimon/packageName.js +0 -1
- package/dist/runtime/daimon/runAuth.js +7 -4
- package/dist/runtime/daimon/runtimeIdentity.d.ts +2 -0
- package/dist/runtime/daimon/runtimeIdentity.js +2 -0
- package/dist/runtime/daimon/subscriptionRealms.d.ts +9 -3
- package/dist/runtime/daimon/subscriptionRealms.js +22 -13
- package/dist/runtime/daimon/testHelpers.d.ts +2 -0
- package/dist/runtime/{pi → daimon}/testHelpers.js +3 -3
- package/dist/runtime/daimon/training/booted/adapter.d.ts +46 -0
- package/dist/runtime/daimon/training/booted/adapter.js +59 -0
- package/dist/runtime/daimon/training/booted/adapter.js.map +1 -0
- package/dist/runtime/daimon/training/booted/index.d.ts +2 -0
- package/dist/runtime/daimon/training/booted/index.js +2 -0
- package/dist/runtime/daimon/training/booted/index.js.map +1 -0
- package/dist/runtime/daimon/training/index.d.ts +5 -0
- package/dist/runtime/daimon/training/index.js +8 -4
- package/dist/runtime/daimon/training/index.js.map +1 -1
- package/dist/runtime/daimon/training/providers/codex-subscription/index.js.map +1 -0
- package/dist/runtime/daimon/training/providers/codex-subscription/protocol.js.map +1 -0
- package/dist/runtime/daimon/training/providers/codex-subscription/provider.js.map +1 -0
- package/dist/runtime/daimon/training/providers/codex-subscription/strict-schema.js.map +1 -0
- package/dist/runtime/daimon/training/providers/grok-subscription/cli.d.ts +1 -3
- package/dist/runtime/daimon/training/providers/grok-subscription/cli.js +5 -5
- package/dist/runtime/daimon/training/providers/grok-subscription/cli.js.map +1 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/index.d.ts +1 -2
- package/dist/runtime/daimon/training/providers/grok-subscription/index.js +0 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/index.js.map +1 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/protocol.d.ts +5 -17
- package/dist/runtime/daimon/training/providers/grok-subscription/protocol.js +18 -31
- package/dist/runtime/daimon/training/providers/grok-subscription/protocol.js.map +1 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/provider.js +1 -2
- package/dist/runtime/daimon/training/providers/grok-subscription/provider.js.map +1 -1
- package/dist/runtime/daimon/wakeMoments.js +0 -1
- package/dist/runtime/install.js +0 -21
- package/dist/runtime/registry.js +0 -2
- package/dist/runtime/trainingGraderProviders.js +1 -1
- package/dist/runtime/trainingProviders.d.ts +1 -2
- package/dist/runtime/trainingProviders.js +9 -19
- package/dist/runtime/trainingSubjects.d.ts +0 -121
- package/dist/runtime/trainingSubjects.js +2 -13
- package/dist/runtime/types.d.ts +1 -8
- package/dist/shared/errors.js +0 -1
- package/dist/status/lifecycleProbes.js +3 -6
- package/dist/status/moltnetWiringProbes.js +1 -17
- package/dist/training/subjects/index.d.ts +0 -1
- package/dist/training/subjects/index.js +0 -1
- package/dist/training/subjects/index.js.map +1 -1
- package/examples/README.md +0 -1
- package/examples/daimon-org/agents/mapper/Spawnfile +4 -1
- package/examples/daimon-org/teams/review/agents/reviewer/Spawnfile +4 -1
- package/examples/jungian-daimon-org/teams/luna/agents/animus/Spawnfile +5 -8
- package/examples/jungian-daimon-org/teams/luna/agents/representative/Spawnfile +1 -1
- package/examples/jungian-daimon-org/teams/luna/agents/shadow/Spawnfile +5 -8
- package/examples/jungian-daimon-org/teams/selene/agents/animus/Spawnfile +5 -8
- package/examples/jungian-daimon-org/teams/selene/agents/representative/Spawnfile +5 -8
- package/examples/jungian-daimon-org/teams/selene/agents/shadow/Spawnfile +1 -1
- package/examples/mixed-runtime-org/agents/localist/Spawnfile +7 -7
- package/package.json +4 -13
- package/runtimes.yaml +5 -15
- package/dist/compiler/containerDaimonGrokTaskClock.d.ts +0 -5
- package/dist/compiler/containerDaimonGrokTaskClock.js +0 -29
- package/dist/compiler/daimonTelemetryArtifacts.d.ts +0 -22
- package/dist/compiler/daimonTelemetryArtifacts.js +0 -56
- package/dist/compiler/training/broker/clockProbe.d.ts +0 -6
- package/dist/compiler/training/broker/clockProbe.js +0 -27
- package/dist/compiler/training/broker/declaration.d.ts +0 -54
- package/dist/compiler/training/broker/declaration.js +0 -70
- package/dist/compiler/training/broker/entrypoint.d.ts +0 -39
- package/dist/compiler/training/broker/entrypoint.js +0 -124
- package/dist/compiler/training/broker/evaluatorSecrets.d.ts +0 -2
- package/dist/compiler/training/broker/evaluatorSecrets.js +0 -62
- package/dist/compiler/training/broker/index.d.ts +0 -12
- package/dist/compiler/training/broker/index.js +0 -12
- package/dist/compiler/training/broker/main.d.ts +0 -2
- package/dist/compiler/training/broker/main.js +0 -14
- package/dist/compiler/training/broker/paths.d.ts +0 -236
- package/dist/compiler/training/broker/paths.js +0 -249
- package/dist/compiler/training/broker/processes.d.ts +0 -51
- package/dist/compiler/training/broker/processes.js +0 -102
- package/dist/compiler/training/broker/projection.d.ts +0 -61
- package/dist/compiler/training/broker/projection.js +0 -109
- package/dist/compiler/training/broker/provisioning.d.ts +0 -78
- package/dist/compiler/training/broker/provisioning.js +0 -231
- package/dist/compiler/training/broker/receipt.d.ts +0 -77
- package/dist/compiler/training/broker/receipt.js +0 -110
- package/dist/compiler/training/broker/recycleClient.d.ts +0 -33
- package/dist/compiler/training/broker/recycleClient.js +0 -112
- package/dist/compiler/training/broker/registration.d.ts +0 -46
- package/dist/compiler/training/broker/registration.js +0 -113
- package/dist/compiler/training/broker/reset.d.ts +0 -9
- package/dist/compiler/training/broker/reset.js +0 -71
- package/dist/compiler/training/broker/rootScript.d.ts +0 -32
- package/dist/compiler/training/broker/rootScript.js +0 -33
- package/dist/compiler/training/broker/runtime.d.ts +0 -22
- package/dist/compiler/training/broker/runtime.js +0 -128
- package/dist/compiler/training/broker/seccompRoutes.d.ts +0 -31
- package/dist/compiler/training/broker/seccompRoutes.js +0 -36
- package/dist/compiler/training/broker/supervisor.d.ts +0 -108
- package/dist/compiler/training/broker/supervisor.js +0 -172
- package/dist/compiler/training/broker/taskClock.d.ts +0 -5
- package/dist/compiler/training/broker/taskClock.js +0 -41
- package/dist/compiler/training/container/contract.d.ts +0 -54
- package/dist/compiler/training/container/contract.js +0 -52
- package/dist/compiler/training/container/evaluators.d.ts +0 -48
- package/dist/compiler/training/container/evaluators.js +0 -50
- package/dist/compiler/training/container/grokWriteback.d.ts +0 -8
- package/dist/compiler/training/container/grokWriteback.js +0 -26
- package/dist/compiler/training/container/index.d.ts +0 -5
- package/dist/compiler/training/container/index.js +0 -3
- package/dist/compiler/training/container/launch.d.ts +0 -21
- package/dist/compiler/training/container/launch.js +0 -280
- package/dist/compiler/training/container/nativeSlots.d.ts +0 -14
- package/dist/compiler/training/container/nativeSlots.js +0 -13
- package/dist/compiler/training/container/outputCopy.d.ts +0 -2
- package/dist/compiler/training/container/outputCopy.js +0 -72
- package/dist/compiler/training/container/outputVolume.d.ts +0 -28
- package/dist/compiler/training/container/outputVolume.js +0 -185
- package/dist/compiler/training/container/prepare.d.ts +0 -10
- package/dist/compiler/training/container/prepare.js +0 -125
- package/dist/compiler/training/container/process.d.ts +0 -14
- package/dist/compiler/training/container/process.js +0 -70
- package/dist/compiler/training/container/security.d.ts +0 -38
- package/dist/compiler/training/container/security.js +0 -68
- package/dist/compiler/training/container/subjectIsolation.d.ts +0 -5
- package/dist/compiler/training/container/subjectIsolation.js +0 -16
- package/dist/compiler/training/preparation/assets/Dockerfile +0 -100
- package/dist/compiler/training/preparation/assets/package-lock.json +0 -5483
- package/dist/compiler/training/preparation/broker.d.ts +0 -30
- package/dist/compiler/training/preparation/broker.js +0 -68
- package/dist/compiler/training/preparation/contextModes.d.ts +0 -12
- package/dist/compiler/training/preparation/contextModes.js +0 -38
- package/dist/compiler/training/preparation/contract.d.ts +0 -203
- package/dist/compiler/training/preparation/contract.js +0 -114
- package/dist/compiler/training/preparation/copyAssets.d.ts +0 -1
- package/dist/compiler/training/preparation/copyAssets.js +0 -8
- package/dist/compiler/training/preparation/daimonParent.d.ts +0 -42
- package/dist/compiler/training/preparation/daimonParent.js +0 -114
- package/dist/compiler/training/preparation/files.d.ts +0 -29
- package/dist/compiler/training/preparation/files.js +0 -146
- package/dist/compiler/training/preparation/image.d.ts +0 -28
- package/dist/compiler/training/preparation/image.js +0 -105
- package/dist/compiler/training/preparation/index.d.ts +0 -3
- package/dist/compiler/training/preparation/index.js +0 -2
- package/dist/compiler/training/preparation/inputs.d.ts +0 -24
- package/dist/compiler/training/preparation/inputs.js +0 -101
- package/dist/compiler/training/preparation/prepare.d.ts +0 -38
- package/dist/compiler/training/preparation/prepare.js +0 -224
- package/dist/compiler/training/preparation/scratch.d.ts +0 -8
- package/dist/compiler/training/preparation/scratch.js +0 -114
- package/dist/compiler/training/repair/compatibility.d.ts +0 -11
- package/dist/compiler/training/repair/compatibility.js +0 -45
- package/dist/compiler/training/repair/contract.d.ts +0 -832
- package/dist/compiler/training/repair/contract.js +0 -34
- package/dist/compiler/training/repair/index.d.ts +0 -3
- package/dist/compiler/training/repair/index.js +0 -3
- package/dist/compiler/training/repair/prepare.d.ts +0 -378
- package/dist/compiler/training/repair/prepare.js +0 -84
- package/dist/compiler/training/repair/witness.d.ts +0 -348
- package/dist/compiler/training/repair/witness.js +0 -62
- package/dist/compiler/training/subjectDeclaration.d.ts +0 -26
- package/dist/compiler/training/subjectDeclaration.js +0 -54
- package/dist/compiler/training/subjectLease.d.ts +0 -115
- package/dist/compiler/training/subjectLease.js +0 -179
- package/dist/dev/activity.d.ts +0 -14
- package/dist/dev/activity.js +0 -48
- package/dist/runtime/codex-exec/training/adapter.d.ts +0 -13
- package/dist/runtime/codex-exec/training/adapter.js +0 -101
- package/dist/runtime/codex-exec/training/adapter.js.map +0 -1
- package/dist/runtime/codex-exec/training/environment.d.ts +0 -3
- package/dist/runtime/codex-exec/training/environment.js +0 -26
- package/dist/runtime/codex-exec/training/environment.js.map +0 -1
- package/dist/runtime/codex-exec/training/index.d.ts +0 -2
- package/dist/runtime/codex-exec/training/index.js +0 -3
- package/dist/runtime/codex-exec/training/index.js.map +0 -1
- package/dist/runtime/codex-exec/training/protocol.d.ts +0 -15
- package/dist/runtime/codex-exec/training/protocol.js +0 -102
- package/dist/runtime/codex-exec/training/protocol.js.map +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/index.js.map +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/protocol.js.map +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/provider.js.map +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/strict-schema.js.map +0 -1
- package/dist/runtime/daimon/contractManifest.js.map +0 -1
- package/dist/runtime/daimon/contractManifestSchema.js.map +0 -1
- package/dist/runtime/daimon/engineDescriptorSchema.js.map +0 -1
- package/dist/runtime/daimon/engineDescriptors.generated.js.map +0 -1
- package/dist/runtime/daimon/engines.js.map +0 -1
- package/dist/runtime/daimon/index.js.map +0 -1
- package/dist/runtime/daimon/packageName.js.map +0 -1
- package/dist/runtime/daimon/training/legacy/adapter.d.ts +0 -11
- package/dist/runtime/daimon/training/legacy/adapter.js +0 -175
- package/dist/runtime/daimon/training/legacy/adapter.js.map +0 -1
- package/dist/runtime/daimon/training/legacy/index.d.ts +0 -2
- package/dist/runtime/daimon/training/legacy/index.js +0 -3
- package/dist/runtime/daimon/training/legacy/index.js.map +0 -1
- package/dist/runtime/daimon/training/legacy/public.d.ts +0 -49
- package/dist/runtime/daimon/training/legacy/public.js +0 -16
- package/dist/runtime/daimon/training/legacy/public.js.map +0 -1
- package/dist/runtime/daimon/training/native/adapter.d.ts +0 -18
- package/dist/runtime/daimon/training/native/adapter.js +0 -252
- package/dist/runtime/daimon/training/native/adapter.js.map +0 -1
- package/dist/runtime/daimon/training/native/admission.d.ts +0 -7
- package/dist/runtime/daimon/training/native/admission.js +0 -52
- package/dist/runtime/daimon/training/native/admission.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/arguments.d.ts +0 -16
- package/dist/runtime/daimon/training/native/child/arguments.js +0 -70
- package/dist/runtime/daimon/training/native/child/arguments.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/deferred-trial.d.ts +0 -24
- package/dist/runtime/daimon/training/native/child/deferred-trial.js +0 -63
- package/dist/runtime/daimon/training/native/child/deferred-trial.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/diagnostics.d.ts +0 -58
- package/dist/runtime/daimon/training/native/child/diagnostics.js +0 -215
- package/dist/runtime/daimon/training/native/child/diagnostics.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/fixture.d.ts +0 -16
- package/dist/runtime/daimon/training/native/child/fixture.js +0 -159
- package/dist/runtime/daimon/training/native/child/fixture.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/grok.d.ts +0 -14
- package/dist/runtime/daimon/training/native/child/grok.js +0 -47
- package/dist/runtime/daimon/training/native/child/grok.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/index.d.ts +0 -7
- package/dist/runtime/daimon/training/native/child/index.js +0 -5
- package/dist/runtime/daimon/training/native/child/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/lifecycle.d.ts +0 -40
- package/dist/runtime/daimon/training/native/child/lifecycle.js +0 -400
- package/dist/runtime/daimon/training/native/child/lifecycle.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/probe.d.ts +0 -2
- package/dist/runtime/daimon/training/native/child/probe.js +0 -11
- package/dist/runtime/daimon/training/native/child/probe.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/sandbox.d.ts +0 -4
- package/dist/runtime/daimon/training/native/child/sandbox.js +0 -76
- package/dist/runtime/daimon/training/native/child/sandbox.js.map +0 -1
- package/dist/runtime/daimon/training/native/child/types.d.ts +0 -15
- package/dist/runtime/daimon/training/native/child/types.js +0 -2
- package/dist/runtime/daimon/training/native/child/types.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/docker.d.ts +0 -29
- package/dist/runtime/daimon/training/native/container/docker.js +0 -105
- package/dist/runtime/daimon/training/native/container/docker.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/grok-slot.d.ts +0 -22
- package/dist/runtime/daimon/training/native/container/grok-slot.js +0 -38
- package/dist/runtime/daimon/training/native/container/grok-slot.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/index.d.ts +0 -6
- package/dist/runtime/daimon/training/native/container/index.js +0 -6
- package/dist/runtime/daimon/training/native/container/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/lifecycle.d.ts +0 -8
- package/dist/runtime/daimon/training/native/container/lifecycle.js +0 -111
- package/dist/runtime/daimon/training/native/container/lifecycle.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/manifest.d.ts +0 -17
- package/dist/runtime/daimon/training/native/container/manifest.js +0 -164
- package/dist/runtime/daimon/training/native/container/manifest.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/native-preflight.d.ts +0 -8
- package/dist/runtime/daimon/training/native/container/native-preflight.js +0 -40
- package/dist/runtime/daimon/training/native/container/native-preflight.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/preflight.d.ts +0 -15
- package/dist/runtime/daimon/training/native/container/preflight.js +0 -79
- package/dist/runtime/daimon/training/native/container/preflight.js.map +0 -1
- package/dist/runtime/daimon/training/native/container/slot.d.ts +0 -4
- package/dist/runtime/daimon/training/native/container/slot.js +0 -58
- package/dist/runtime/daimon/training/native/container/slot.js.map +0 -1
- package/dist/runtime/daimon/training/native/external.d.ts +0 -37
- package/dist/runtime/daimon/training/native/external.js +0 -75
- package/dist/runtime/daimon/training/native/external.js.map +0 -1
- package/dist/runtime/daimon/training/native/grants/authority.d.ts +0 -36
- package/dist/runtime/daimon/training/native/grants/authority.js +0 -49
- package/dist/runtime/daimon/training/native/grants/authority.js.map +0 -1
- package/dist/runtime/daimon/training/native/grants/index.d.ts +0 -2
- package/dist/runtime/daimon/training/native/grants/index.js +0 -3
- package/dist/runtime/daimon/training/native/grants/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/grants/pins.d.ts +0 -30
- package/dist/runtime/daimon/training/native/grants/pins.js +0 -20
- package/dist/runtime/daimon/training/native/grants/pins.js.map +0 -1
- package/dist/runtime/daimon/training/native/grants/test-socket.d.ts +0 -6
- package/dist/runtime/daimon/training/native/grants/test-socket.js +0 -35
- package/dist/runtime/daimon/training/native/grants/test-socket.js.map +0 -1
- package/dist/runtime/daimon/training/native/grok-fixtures.d.ts +0 -34
- package/dist/runtime/daimon/training/native/grok-fixtures.js +0 -179
- package/dist/runtime/daimon/training/native/grok-fixtures.js.map +0 -1
- package/dist/runtime/daimon/training/native/index.d.ts +0 -38
- package/dist/runtime/daimon/training/native/index.js +0 -27
- package/dist/runtime/daimon/training/native/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/live-checkout.d.ts +0 -2
- package/dist/runtime/daimon/training/native/live-checkout.js +0 -15
- package/dist/runtime/daimon/training/native/live-checkout.js.map +0 -1
- package/dist/runtime/daimon/training/native/observations.d.ts +0 -51
- package/dist/runtime/daimon/training/native/observations.js +0 -217
- package/dist/runtime/daimon/training/native/observations.js.map +0 -1
- package/dist/runtime/daimon/training/native/outcome.d.ts +0 -13
- package/dist/runtime/daimon/training/native/outcome.js +0 -37
- package/dist/runtime/daimon/training/native/outcome.js.map +0 -1
- package/dist/runtime/daimon/training/native/preparation/engine-config.d.ts +0 -21
- package/dist/runtime/daimon/training/native/preparation/engine-config.js +0 -30
- package/dist/runtime/daimon/training/native/preparation/engine-config.js.map +0 -1
- package/dist/runtime/daimon/training/native/preparation/fixtures.d.ts +0 -17
- package/dist/runtime/daimon/training/native/preparation/fixtures.js +0 -52
- package/dist/runtime/daimon/training/native/preparation/fixtures.js.map +0 -1
- package/dist/runtime/daimon/training/native/preparation/index.d.ts +0 -7
- package/dist/runtime/daimon/training/native/preparation/index.js +0 -5
- package/dist/runtime/daimon/training/native/preparation/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/preparation/layout.d.ts +0 -66
- package/dist/runtime/daimon/training/native/preparation/layout.js +0 -87
- package/dist/runtime/daimon/training/native/preparation/layout.js.map +0 -1
- package/dist/runtime/daimon/training/native/preparation/subject.d.ts +0 -14
- package/dist/runtime/daimon/training/native/preparation/subject.js +0 -67
- package/dist/runtime/daimon/training/native/preparation/subject.js.map +0 -1
- package/dist/runtime/daimon/training/native/preparation/types.d.ts +0 -69
- package/dist/runtime/daimon/training/native/preparation/types.js +0 -2
- package/dist/runtime/daimon/training/native/preparation/types.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/artifacts.d.ts +0 -25
- package/dist/runtime/daimon/training/native/receipt/artifacts.js +0 -32
- package/dist/runtime/daimon/training/native/receipt/artifacts.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/grok-clocked-pins.d.ts +0 -129
- package/dist/runtime/daimon/training/native/receipt/grok-clocked-pins.js +0 -45
- package/dist/runtime/daimon/training/native/receipt/grok-clocked-pins.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/grok.d.ts +0 -246
- package/dist/runtime/daimon/training/native/receipt/grok.js +0 -195
- package/dist/runtime/daimon/training/native/receipt/grok.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/index.d.ts +0 -11
- package/dist/runtime/daimon/training/native/receipt/index.js +0 -8
- package/dist/runtime/daimon/training/native/receipt/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/paths.d.ts +0 -3
- package/dist/runtime/daimon/training/native/receipt/paths.js +0 -18
- package/dist/runtime/daimon/training/native/receipt/paths.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/sandbox.d.ts +0 -42
- package/dist/runtime/daimon/training/native/receipt/sandbox.js +0 -35
- package/dist/runtime/daimon/training/native/receipt/sandbox.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/schema.d.ts +0 -490
- package/dist/runtime/daimon/training/native/receipt/schema.js +0 -138
- package/dist/runtime/daimon/training/native/receipt/schema.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/subscription.d.ts +0 -13
- package/dist/runtime/daimon/training/native/receipt/subscription.js +0 -13
- package/dist/runtime/daimon/training/native/receipt/subscription.js.map +0 -1
- package/dist/runtime/daimon/training/native/receipt/task-clock.d.ts +0 -19
- package/dist/runtime/daimon/training/native/receipt/task-clock.js +0 -49
- package/dist/runtime/daimon/training/native/receipt/task-clock.js.map +0 -1
- package/dist/runtime/daimon/training/native/sealed-usage.d.ts +0 -218
- package/dist/runtime/daimon/training/native/sealed-usage.js +0 -261
- package/dist/runtime/daimon/training/native/sealed-usage.js.map +0 -1
- package/dist/runtime/daimon/training/native/test-fixtures.d.ts +0 -27
- package/dist/runtime/daimon/training/native/test-fixtures.js +0 -162
- package/dist/runtime/daimon/training/native/test-fixtures.js.map +0 -1
- package/dist/runtime/daimon/training/native/transcript.d.ts +0 -96
- package/dist/runtime/daimon/training/native/transcript.js +0 -239
- package/dist/runtime/daimon/training/native/transcript.js.map +0 -1
- package/dist/runtime/daimon/training/native/transport/delivery.d.ts +0 -27
- package/dist/runtime/daimon/training/native/transport/delivery.js +0 -98
- package/dist/runtime/daimon/training/native/transport/delivery.js.map +0 -1
- package/dist/runtime/daimon/training/native/transport/http.d.ts +0 -3
- package/dist/runtime/daimon/training/native/transport/http.js +0 -81
- package/dist/runtime/daimon/training/native/transport/http.js.map +0 -1
- package/dist/runtime/daimon/training/native/transport/index.d.ts +0 -4
- package/dist/runtime/daimon/training/native/transport/index.js +0 -3
- package/dist/runtime/daimon/training/native/transport/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/transport/types.d.ts +0 -15
- package/dist/runtime/daimon/training/native/transport/types.js +0 -2
- package/dist/runtime/daimon/training/native/transport/types.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/cli.d.ts +0 -1
- package/dist/runtime/daimon/training/native/worker/cli.js +0 -17
- package/dist/runtime/daimon/training/native/worker/cli.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/control.d.ts +0 -20
- package/dist/runtime/daimon/training/native/worker/control.js +0 -266
- package/dist/runtime/daimon/training/native/worker/control.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/deliveries.d.ts +0 -38
- package/dist/runtime/daimon/training/native/worker/deliveries.js +0 -91
- package/dist/runtime/daimon/training/native/worker/deliveries.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/evidence/collect.d.ts +0 -54
- package/dist/runtime/daimon/training/native/worker/evidence/collect.js +0 -278
- package/dist/runtime/daimon/training/native/worker/evidence/collect.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/evidence/execution.d.ts +0 -102
- package/dist/runtime/daimon/training/native/worker/evidence/execution.js +0 -191
- package/dist/runtime/daimon/training/native/worker/evidence/execution.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/evidence/index.d.ts +0 -3
- package/dist/runtime/daimon/training/native/worker/evidence/index.js +0 -4
- package/dist/runtime/daimon/training/native/worker/evidence/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/evidence/io.d.ts +0 -20
- package/dist/runtime/daimon/training/native/worker/evidence/io.js +0 -130
- package/dist/runtime/daimon/training/native/worker/evidence/io.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/evidence/seal.d.ts +0 -3
- package/dist/runtime/daimon/training/native/worker/evidence/seal.js +0 -67
- package/dist/runtime/daimon/training/native/worker/evidence/seal.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/index.d.ts +0 -11
- package/dist/runtime/daimon/training/native/worker/index.js +0 -8
- package/dist/runtime/daimon/training/native/worker/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/profile.d.ts +0 -23
- package/dist/runtime/daimon/training/native/worker/profile.js +0 -149
- package/dist/runtime/daimon/training/native/worker/profile.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/public.d.ts +0 -53
- package/dist/runtime/daimon/training/native/worker/public.js +0 -22
- package/dist/runtime/daimon/training/native/worker/public.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/sandbox.d.ts +0 -4
- package/dist/runtime/daimon/training/native/worker/sandbox.js +0 -54
- package/dist/runtime/daimon/training/native/worker/sandbox.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/server.d.ts +0 -4
- package/dist/runtime/daimon/training/native/worker/server.js +0 -102
- package/dist/runtime/daimon/training/native/worker/server.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/types.d.ts +0 -318
- package/dist/runtime/daimon/training/native/worker/types.js +0 -2
- package/dist/runtime/daimon/training/native/worker/types.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/wake-delivery/index.d.ts +0 -4
- package/dist/runtime/daimon/training/native/worker/wake-delivery/index.js +0 -4
- package/dist/runtime/daimon/training/native/worker/wake-delivery/index.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/wake-delivery/source.d.ts +0 -3
- package/dist/runtime/daimon/training/native/worker/wake-delivery/source.js +0 -16
- package/dist/runtime/daimon/training/native/worker/wake-delivery/source.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/wake-delivery/terminal.d.ts +0 -4
- package/dist/runtime/daimon/training/native/worker/wake-delivery/terminal.js +0 -52
- package/dist/runtime/daimon/training/native/worker/wake-delivery/terminal.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/wake-delivery/transport.d.ts +0 -21
- package/dist/runtime/daimon/training/native/worker/wake-delivery/transport.js +0 -198
- package/dist/runtime/daimon/training/native/worker/wake-delivery/transport.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/wake-delivery/types.d.ts +0 -91
- package/dist/runtime/daimon/training/native/worker/wake-delivery/types.js +0 -2
- package/dist/runtime/daimon/training/native/worker/wake-delivery/types.js.map +0 -1
- package/dist/runtime/daimon/training/native/worker/worker.d.ts +0 -1
- package/dist/runtime/daimon/training/native/worker/worker.js +0 -105
- package/dist/runtime/daimon/training/native/worker/worker.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/broker.d.ts +0 -20
- package/dist/runtime/daimon/training/providers/grok-broker/broker.js +0 -55
- package/dist/runtime/daimon/training/providers/grok-broker/broker.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/grant-fixtures.d.ts +0 -15
- package/dist/runtime/daimon/training/providers/grok-broker/grant-fixtures.js +0 -29
- package/dist/runtime/daimon/training/providers/grok-broker/grant-fixtures.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/grant-home.d.ts +0 -16
- package/dist/runtime/daimon/training/providers/grok-broker/grant-home.js +0 -60
- package/dist/runtime/daimon/training/providers/grok-broker/grant-home.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/grant-pool.d.ts +0 -81
- package/dist/runtime/daimon/training/providers/grok-broker/grant-pool.js +0 -221
- package/dist/runtime/daimon/training/providers/grok-broker/grant-pool.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/grant-releases.d.ts +0 -31
- package/dist/runtime/daimon/training/providers/grok-broker/grant-releases.js +0 -78
- package/dist/runtime/daimon/training/providers/grok-broker/grant-releases.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/grants.d.ts +0 -63
- package/dist/runtime/daimon/training/providers/grok-broker/grants.js +0 -20
- package/dist/runtime/daimon/training/providers/grok-broker/grants.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-broker/index.d.ts +0 -3
- package/dist/runtime/daimon/training/providers/grok-broker/index.js +0 -4
- package/dist/runtime/daimon/training/providers/grok-broker/index.js.map +0 -1
- package/dist/runtime/daimon/training/public.d.ts +0 -6
- package/dist/runtime/daimon/training/public.js +0 -5
- package/dist/runtime/daimon/training/public.js.map +0 -1
- package/dist/runtime/daimon/training/services/account-lease.d.ts +0 -7
- package/dist/runtime/daimon/training/services/account-lease.js +0 -76
- package/dist/runtime/daimon/training/services/account-lease.js.map +0 -1
- package/dist/runtime/daimon/training/services/freshness.d.ts +0 -15
- package/dist/runtime/daimon/training/services/freshness.js +0 -19
- package/dist/runtime/daimon/training/services/freshness.js.map +0 -1
- package/dist/runtime/daimon/training/services/index.d.ts +0 -4
- package/dist/runtime/daimon/training/services/index.js +0 -4
- package/dist/runtime/daimon/training/services/index.js.map +0 -1
- package/dist/runtime/daimon/training/services/slot-freshness.d.ts +0 -34
- package/dist/runtime/daimon/training/services/slot-freshness.js +0 -178
- package/dist/runtime/daimon/training/services/slot-freshness.js.map +0 -1
- package/dist/runtime/daimon/wakeMoments.js.map +0 -1
- package/dist/runtime/pi/adapter.d.ts +0 -3
- package/dist/runtime/pi/adapter.js +0 -230
- package/dist/runtime/pi/appActivitySource.d.ts +0 -1
- package/dist/runtime/pi/appActivitySource.js +0 -199
- package/dist/runtime/pi/appAgentConfig.d.ts +0 -11
- package/dist/runtime/pi/appAgentConfig.js +0 -264
- package/dist/runtime/pi/appCliEnginesSource.d.ts +0 -1
- package/dist/runtime/pi/appCliEnginesSource.js +0 -183
- package/dist/runtime/pi/appCliSource.d.ts +0 -1
- package/dist/runtime/pi/appCliSource.js +0 -353
- package/dist/runtime/pi/appControlSource.d.ts +0 -1
- package/dist/runtime/pi/appControlSource.js +0 -390
- package/dist/runtime/pi/appControlWakeIdentitySource.d.ts +0 -1
- package/dist/runtime/pi/appControlWakeIdentitySource.js +0 -19
- package/dist/runtime/pi/appCoreSource.d.ts +0 -4
- package/dist/runtime/pi/appCoreSource.js +0 -244
- package/dist/runtime/pi/appPreludeSource.d.ts +0 -1
- package/dist/runtime/pi/appPreludeSource.js +0 -192
- package/dist/runtime/pi/appScheduleSource.d.ts +0 -1
- package/dist/runtime/pi/appScheduleSource.js +0 -84
- package/dist/runtime/pi/appScriptedEngine.d.ts +0 -31
- package/dist/runtime/pi/appScriptedEngine.js +0 -42
- package/dist/runtime/pi/appSource.d.ts +0 -4
- package/dist/runtime/pi/appSource.js +0 -12
- package/dist/runtime/pi/appTemplate.d.ts +0 -14
- package/dist/runtime/pi/appTemplate.js +0 -28
- package/dist/runtime/pi/appTemplateTypes.d.ts +0 -64
- package/dist/runtime/pi/appTemplateTypes.js +0 -18
- package/dist/runtime/pi/appWakeContextSource.d.ts +0 -1
- package/dist/runtime/pi/appWakeContextSource.js +0 -398
- package/dist/runtime/pi/containerTargets.d.ts +0 -4
- package/dist/runtime/pi/containerTargets.js +0 -63
- package/dist/runtime/pi/runAuth.d.ts +0 -2
- package/dist/runtime/pi/runAuth.js +0 -185
- package/dist/runtime/pi/testHelpers.d.ts +0 -2
- package/dist/shared/errors.js.map +0 -1
- package/dist/training/subjects/environment.d.ts +0 -2
- package/dist/training/subjects/environment.js +0 -14
- package/dist/training/subjects/environment.js.map +0 -1
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/index.d.ts +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/index.js +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/protocol.d.ts +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/protocol.js +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/provider.d.ts +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/provider.js +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/strict-schema.d.ts +0 -0
- /package/dist/runtime/{codex-exec → daimon}/training/providers/codex-subscription/strict-schema.js +0 -0
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { lstat, readdir } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { redactNativeDiagnostic } from './child/index.js';
|
|
5
|
-
import { readPrivateFile } from './receipt/index.js';
|
|
6
|
-
/**
|
|
7
|
-
* Recovers what the engine was actually asked, and what it actually answered.
|
|
8
|
-
*
|
|
9
|
-
* Daimon reduces both to a digest and a character count before either leaves
|
|
10
|
-
* its runtime, which is enough to detect a change and not enough to diagnose
|
|
11
|
-
* one: a turn that files nothing looks identical to a turn that was never asked
|
|
12
|
-
* to. The Grok CLI writes its own transcript inside the Daimon-owned
|
|
13
|
-
* `$GROK_HOME`, the same runtime home this adapter already reads tool receipts
|
|
14
|
-
* and closed traces from, so the text is recoverable as observed evidence
|
|
15
|
-
* rather than reconstructed from the adapter's side of the wake.
|
|
16
|
-
*
|
|
17
|
-
* This capture is operator-only. Every trial observation persists at `raw`
|
|
18
|
-
* visibility, which no viewer, optimizer or evaluator projection can read, and
|
|
19
|
-
* it is published as a `diagnostic` so it never becomes `snapshot.output`, a
|
|
20
|
-
* captured tool call, or any judge's input. Nothing here changes what a trial
|
|
21
|
-
* evaluates.
|
|
22
|
-
*/
|
|
23
|
-
export const NATIVE_TRANSCRIPT_SCHEMA = 'spawnfile.training.daimon-native.transcript.v1';
|
|
24
|
-
/** Sessions scanned under one engine home; an isolated trial closes exactly one execution. */
|
|
25
|
-
const maximumSessions = 8;
|
|
26
|
-
/** One session's transcript; larger than this is not a turn, it is a defect. */
|
|
27
|
-
const maximumTranscriptBytes = 8 * 1024 * 1024;
|
|
28
|
-
/** Published text bound. A transcript is for reading a turn, not for archiving a corpus. */
|
|
29
|
-
const publishedChars = 32_768;
|
|
30
|
-
/** `sessions/<percent-encoded-cwd>/<session-id>/chat_history.jsonl`. */
|
|
31
|
-
const transcriptName = 'chat_history.jsonl';
|
|
32
|
-
const sessionId = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;
|
|
33
|
-
const userQuery = /<user_query>\n?([\s\S]*?)\n?<\/user_query>/u;
|
|
34
|
-
const digest = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
|
|
35
|
-
/**
|
|
36
|
-
* Publishes a transcript field, or refuses to.
|
|
37
|
-
*
|
|
38
|
-
* The digest and the character count are identities, never secrets, so they
|
|
39
|
-
* publish unconditionally — they are what Daimon's trace can be checked
|
|
40
|
-
* against. The text itself publishes only when the shared native redactor finds
|
|
41
|
-
* nothing credential-shaped left in it; otherwise the named detectors say why
|
|
42
|
-
* the bytes were withheld, which is the difference between "the reply could not
|
|
43
|
-
* be published" and "there was no reply".
|
|
44
|
-
*/
|
|
45
|
-
export function transcriptText(value) {
|
|
46
|
-
const truncated = value.length > publishedChars;
|
|
47
|
-
const candidate = truncated ? value.slice(0, publishedChars) : value;
|
|
48
|
-
// Declared secrets belong to the child lifecycle that owns the token and the
|
|
49
|
-
// process environment. With none to substitute, the detectors decide alone,
|
|
50
|
-
// which withholds more text than it would otherwise, never less.
|
|
51
|
-
const redacted = redactNativeDiagnostic(candidate, []);
|
|
52
|
-
return {
|
|
53
|
-
chars: value.length,
|
|
54
|
-
sha256: digest(value),
|
|
55
|
-
...(redacted.clean ? { text: redacted.text } : {}),
|
|
56
|
-
truncated,
|
|
57
|
-
redaction: redacted.clean ? 'applied' : 'withheld',
|
|
58
|
-
...(redacted.clean ? {} : { detectors: redacted.detectors }),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const asRecord = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
62
|
-
/** A CLI message body is a string, or the text parts of a content array. */
|
|
63
|
-
function messageText(content) {
|
|
64
|
-
if (typeof content === 'string')
|
|
65
|
-
return content;
|
|
66
|
-
if (!Array.isArray(content))
|
|
67
|
-
return '';
|
|
68
|
-
return content
|
|
69
|
-
.map(part => {
|
|
70
|
-
const row = asRecord(part);
|
|
71
|
-
return row && row.type === 'text' && typeof row.text === 'string' ? row.text : '';
|
|
72
|
-
})
|
|
73
|
-
.filter(Boolean)
|
|
74
|
-
.join('\n');
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* The wake text and the final reply in one session transcript.
|
|
78
|
-
*
|
|
79
|
-
* The CLI prepends its own user rows (environment, skills, reminders) before the
|
|
80
|
-
* wake, and wraps the wake itself in `<user_query>`. The last wrapped row is
|
|
81
|
-
* therefore the delivered prompt; a transcript with no wrapper at all reports
|
|
82
|
-
* the last user row as `bare` rather than silently presenting a CLI preamble as
|
|
83
|
-
* the assignment.
|
|
84
|
-
*/
|
|
85
|
-
export function parseGrokTranscript(id, lines) {
|
|
86
|
-
const users = [];
|
|
87
|
-
let reply;
|
|
88
|
-
let rows = 0;
|
|
89
|
-
for (const line of lines) {
|
|
90
|
-
if (!line.trim())
|
|
91
|
-
continue;
|
|
92
|
-
let value;
|
|
93
|
-
try {
|
|
94
|
-
value = JSON.parse(line);
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const row = asRecord(value);
|
|
100
|
-
if (!row)
|
|
101
|
-
continue;
|
|
102
|
-
rows++;
|
|
103
|
-
if (row.type === 'user') {
|
|
104
|
-
const text = messageText(row.content);
|
|
105
|
-
if (text)
|
|
106
|
-
users.push(text);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (row.type !== 'assistant')
|
|
110
|
-
continue;
|
|
111
|
-
// An assistant message that carries tool calls is work in progress, not the
|
|
112
|
-
// turn's answer. Treating one as the reply would report a turn that ended
|
|
113
|
-
// mid-tool-call as if it had answered.
|
|
114
|
-
const calls = Array.isArray(row.tool_calls) ? row.tool_calls.length : 0;
|
|
115
|
-
const text = messageText(row.content);
|
|
116
|
-
reply = calls > 0 || !text.trim() ? undefined : text;
|
|
117
|
-
}
|
|
118
|
-
const wrapped = users.filter(text => userQuery.test(text));
|
|
119
|
-
const last = wrapped.at(-1);
|
|
120
|
-
const bare = users.at(-1);
|
|
121
|
-
const prompt = last !== undefined ? userQuery.exec(last)[1] : bare;
|
|
122
|
-
return {
|
|
123
|
-
sessionId: id,
|
|
124
|
-
rows,
|
|
125
|
-
...(prompt === undefined ? {} : { prompt: transcriptText(prompt) }),
|
|
126
|
-
promptEnvelope: last !== undefined ? 'user_query' : bare === undefined ? 'absent' : 'bare',
|
|
127
|
-
...(reply === undefined ? {} : { reply: transcriptText(reply) }),
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
async function entries(directory) {
|
|
131
|
-
try {
|
|
132
|
-
const info = await lstat(directory);
|
|
133
|
-
if (!info.isDirectory() || info.isSymbolicLink())
|
|
134
|
-
throw new Error('Native transcript directory must be real');
|
|
135
|
-
return await readdir(directory);
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
if (error.code === 'ENOENT')
|
|
139
|
-
return [];
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/** Every `sessions/<cwd>/<session>/chat_history.jsonl` under one engine home, in stable order. */
|
|
144
|
-
async function transcriptFiles(engineHome) {
|
|
145
|
-
const root = join(engineHome, 'sessions');
|
|
146
|
-
const found = [];
|
|
147
|
-
for (const workspace of (await entries(root)).sort()) {
|
|
148
|
-
const directory = join(root, workspace);
|
|
149
|
-
let info;
|
|
150
|
-
try {
|
|
151
|
-
info = await lstat(directory);
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (!info.isDirectory() || info.isSymbolicLink())
|
|
157
|
-
continue;
|
|
158
|
-
for (const session of (await entries(directory)).sort()) {
|
|
159
|
-
if (!sessionId.test(session))
|
|
160
|
-
continue;
|
|
161
|
-
const file = join(directory, session, transcriptName);
|
|
162
|
-
try {
|
|
163
|
-
const entry = await lstat(file);
|
|
164
|
-
if (!entry.isFile() || entry.isSymbolicLink())
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (found.length >= maximumSessions)
|
|
171
|
-
throw new Error('Native engine transcript count exceeds the isolated trial bound');
|
|
172
|
-
found.push({ id: session, file });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return found;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Which captured session is the turn Daimon closed.
|
|
179
|
-
*
|
|
180
|
-
* The digest is the only authority: one session whose prompt hashes to what the
|
|
181
|
-
* trace recorded IS that turn. Failing that, a single captured session in an
|
|
182
|
-
* isolated trial is it by construction. Anything else selects nothing rather
|
|
183
|
-
* than guessing, and every session still publishes.
|
|
184
|
-
*/
|
|
185
|
-
export function selectTranscriptSession(sessions, promptSha256) {
|
|
186
|
-
if (promptSha256 !== undefined) {
|
|
187
|
-
const matched = sessions.filter(session => session.prompt?.sha256 === promptSha256);
|
|
188
|
-
if (matched.length === 1)
|
|
189
|
-
return matched[0];
|
|
190
|
-
}
|
|
191
|
-
return sessions.length === 1 ? sessions[0] : undefined;
|
|
192
|
-
}
|
|
193
|
-
const traceNumber = (value) => Number.isSafeInteger(value) && Number(value) >= 0 ? Number(value) : undefined;
|
|
194
|
-
const traceDigest = (value) => typeof value === 'string' && /^[a-f0-9]{64}$/u.test(value) ? value : undefined;
|
|
195
|
-
/** Daimon's `daimon.turn_trace.v1` reduction of the same turn, read structurally. */
|
|
196
|
-
export function traceReduction(trace) {
|
|
197
|
-
if (!trace)
|
|
198
|
-
return undefined;
|
|
199
|
-
const prompt = asRecord(trace.prompt);
|
|
200
|
-
const reply = asRecord(trace.reply);
|
|
201
|
-
return {
|
|
202
|
-
turnId: trace.turn_id,
|
|
203
|
-
...(traceDigest(prompt?.sha256) === undefined ? {} : { promptSha256: traceDigest(prompt?.sha256) }),
|
|
204
|
-
...(traceNumber(prompt?.chars) === undefined ? {} : { promptChars: traceNumber(prompt?.chars) }),
|
|
205
|
-
...(traceNumber(reply?.output_chars) === undefined ? {} : { replyChars: traceNumber(reply?.output_chars) }),
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
const compare = (observed, recorded) => observed === undefined || recorded === undefined ? 'unknown' : observed === recorded ? 'match' : 'differs';
|
|
209
|
-
/**
|
|
210
|
-
* Reads the engine's own transcript out of the Daimon-owned engine home.
|
|
211
|
-
*
|
|
212
|
-
* Returns `undefined` when there is nothing to publish, so a Codex trial and a
|
|
213
|
-
* turn whose runtime home was already recycled both stay silent rather than
|
|
214
|
-
* publishing an empty capture that reads like evidence.
|
|
215
|
-
*/
|
|
216
|
-
export async function readNativeTranscript(runtimeHome, trace) {
|
|
217
|
-
const files = await transcriptFiles(join(runtimeHome, '.grok'));
|
|
218
|
-
if (!files.length)
|
|
219
|
-
return undefined;
|
|
220
|
-
const sessions = [];
|
|
221
|
-
for (const { id, file } of files) {
|
|
222
|
-
const source = await readPrivateFile(file, maximumTranscriptBytes);
|
|
223
|
-
sessions.push(parseGrokTranscript(id, source.split('\n')));
|
|
224
|
-
}
|
|
225
|
-
const reduction = traceReduction(trace);
|
|
226
|
-
const selected = selectTranscriptSession(sessions, reduction?.promptSha256);
|
|
227
|
-
return {
|
|
228
|
-
schema: NATIVE_TRANSCRIPT_SCHEMA,
|
|
229
|
-
engine: 'grok',
|
|
230
|
-
sessions,
|
|
231
|
-
...(selected ? { selected: selected.sessionId } : {}),
|
|
232
|
-
...(reduction ? { trace: reduction } : {}),
|
|
233
|
-
agreement: {
|
|
234
|
-
promptSha256: compare(selected?.prompt?.sha256, reduction?.promptSha256),
|
|
235
|
-
replyChars: compare(selected?.reply?.chars, reduction?.replyChars),
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
//# sourceMappingURL=transcript.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../../../../src/runtime/daimon/training/native/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAyB,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GA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S,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,SAAS,EAAE;YACT,YAAY,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC;YACxE,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC;SACnE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { VerifiedNativeLaunch } from '../receipt/index.js';
|
|
2
|
-
import { type TransportDeliverySource, type TerminalEvidence } from '../worker/index.js';
|
|
3
|
-
import type { NativeWorkerRequest } from './types.js';
|
|
4
|
-
/** The provider reserves a source first; publication happens only after the worker arms it. */
|
|
5
|
-
export interface PreparedTransportDelivery {
|
|
6
|
-
source: TransportDeliverySource;
|
|
7
|
-
publish(signal: AbortSignal): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export interface NativeTransportDelivery {
|
|
10
|
-
prepare(context: {
|
|
11
|
-
trialId: string;
|
|
12
|
-
turnId: string;
|
|
13
|
-
text: string;
|
|
14
|
-
launch: VerifiedNativeLaunch;
|
|
15
|
-
executionId: string;
|
|
16
|
-
}, signal: AbortSignal): Promise<PreparedTransportDelivery>;
|
|
17
|
-
}
|
|
18
|
-
export declare function verifyPreparedTransport(value: PreparedTransportDelivery, exact?: boolean): void;
|
|
19
|
-
/** Provider callbacks may not extend the trial's real deadline or outlive cancellation. */
|
|
20
|
-
export declare function boundedTransportCall<T>(callback: (signal: AbortSignal) => Promise<T>, deadline: number, signal: AbortSignal): Promise<T>;
|
|
21
|
-
/** A transport receipt binds to its actual delivery, never a synthetic trial/wake key. */
|
|
22
|
-
export declare function transportTerminalBinding(value: TerminalEvidence, source: TransportDeliverySource | undefined): 'bound' | 'incomplete' | 'conflict';
|
|
23
|
-
/** Start observation, prove the matching run is armed, then let the provider publish. */
|
|
24
|
-
export declare function requestTransportDelivery(request: NativeWorkerRequest, body: {
|
|
25
|
-
wakeId: string;
|
|
26
|
-
source: TransportDeliverySource;
|
|
27
|
-
}, delivery: PreparedTransportDelivery, deadline: number, signal: AbortSignal): Promise<TerminalEvidence>;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { setTimeout as pause } from 'node:timers/promises';
|
|
2
|
-
import { matchTransportSource, parseTransportSource } from '../worker/index.js';
|
|
3
|
-
export function verifyPreparedTransport(value, exact = false) {
|
|
4
|
-
if (!value || Object.keys(value).sort().join(',') !== 'publish,source' || typeof value.publish !== 'function') {
|
|
5
|
-
throw new Error('Invalid prepared transport delivery');
|
|
6
|
-
}
|
|
7
|
-
const source = parseTransportSource(value.source);
|
|
8
|
-
if (exact && !('deliveryId' in source))
|
|
9
|
-
throw new Error('Transport continuation requires an exact delivery ID');
|
|
10
|
-
}
|
|
11
|
-
/** Provider callbacks may not extend the trial's real deadline or outlive cancellation. */
|
|
12
|
-
export async function boundedTransportCall(callback, deadline, signal) {
|
|
13
|
-
if (signal.aborted)
|
|
14
|
-
throw new Error('Transport delivery cancelled');
|
|
15
|
-
const remaining = deadline - Date.now();
|
|
16
|
-
if (remaining <= 0)
|
|
17
|
-
throw new Error('Native trial deadline exceeded awaiting transport delivery');
|
|
18
|
-
const controller = new AbortController();
|
|
19
|
-
let timer;
|
|
20
|
-
let abort;
|
|
21
|
-
const interrupted = new Promise((_resolve, reject) => {
|
|
22
|
-
abort = () => { controller.abort(); reject(new Error('Transport delivery cancelled')); };
|
|
23
|
-
signal.addEventListener('abort', abort, { once: true });
|
|
24
|
-
timer = setTimeout(() => { controller.abort(); reject(new Error('Native trial deadline exceeded awaiting transport delivery')); }, remaining);
|
|
25
|
-
});
|
|
26
|
-
try {
|
|
27
|
-
const value = await Promise.race([callback(controller.signal), interrupted]);
|
|
28
|
-
if (signal.aborted)
|
|
29
|
-
throw new Error('Transport delivery cancelled');
|
|
30
|
-
if (Date.now() >= deadline)
|
|
31
|
-
throw new Error('Native trial deadline exceeded awaiting transport delivery');
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
clearTimeout(timer);
|
|
36
|
-
signal.removeEventListener('abort', abort);
|
|
37
|
-
controller.abort();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function sameSource(left, right) {
|
|
41
|
-
return !!left && left.kind === right.kind && ('deliveryId' in left
|
|
42
|
-
? 'deliveryId' in right && left.deliveryId === right.deliveryId
|
|
43
|
-
: 'deliveryIdPrefix' in right && left.deliveryIdPrefix === right.deliveryIdPrefix);
|
|
44
|
-
}
|
|
45
|
-
/** A transport receipt binds to its actual delivery, never a synthetic trial/wake key. */
|
|
46
|
-
export function transportTerminalBinding(value, source) {
|
|
47
|
-
const transport = value.transport;
|
|
48
|
-
const incomplete = () => value.status === 'failed' && !value.blocked ? 'incomplete' : 'conflict';
|
|
49
|
-
if (!source || !transport || !sameSource(transport.source, source))
|
|
50
|
-
return 'conflict';
|
|
51
|
-
if (transport.deliveryId === undefined)
|
|
52
|
-
return value.receipt || value.executionId || transport.acceptanceId || transport.batch ? 'conflict' : incomplete();
|
|
53
|
-
if (!matchTransportSource(source, transport.deliveryId) || value.receipt &&
|
|
54
|
-
(value.receipt.delivery_id !== transport.deliveryId || value.receipt.agent_id !== value.agentId ||
|
|
55
|
-
transport.acceptanceId !== undefined && value.receipt.acceptance_id !== transport.acceptanceId ||
|
|
56
|
-
value.executionId !== undefined && value.receipt.execution_id !== undefined && value.receipt.execution_id !== value.executionId))
|
|
57
|
-
return 'conflict';
|
|
58
|
-
if (transport.batch && (!transport.batch.deliveryIds.includes(transport.deliveryId) ||
|
|
59
|
-
value.executionId !== undefined && transport.batch.executionId !== value.executionId))
|
|
60
|
-
return 'conflict';
|
|
61
|
-
return value.receipt && transport.acceptanceId && value.executionId && transport.batch ? 'bound' : incomplete();
|
|
62
|
-
}
|
|
63
|
-
/** Start observation, prove the matching run is armed, then let the provider publish. */
|
|
64
|
-
export async function requestTransportDelivery(request, body, delivery, deadline, signal) {
|
|
65
|
-
if (Date.now() >= deadline)
|
|
66
|
-
throw new Error('Native trial deadline exceeded awaiting transport delivery');
|
|
67
|
-
// Publication keeps the work deadline. Terminal transport gets shutdown/report
|
|
68
|
-
// grace, while the worker's completion evidence still has to predate the deadline.
|
|
69
|
-
return boundedTransportCall(async (bound) => {
|
|
70
|
-
let settled = false;
|
|
71
|
-
const terminal = request('/trial/run', body, Math.max(1, deadline - Date.now()) + 8000, bound)
|
|
72
|
-
.finally(() => { settled = true; });
|
|
73
|
-
let publishing = false;
|
|
74
|
-
const publish = boundedTransportCall(async (publication) => {
|
|
75
|
-
for (;;) {
|
|
76
|
-
const status = await request('/trial/run', undefined, Math.max(1, deadline - Date.now()), publication);
|
|
77
|
-
if (settled)
|
|
78
|
-
return;
|
|
79
|
-
if (['waiting', 'observing'].includes(status.state) && status.wakeId === body.wakeId && status.source && sameSource(status.source, body.source))
|
|
80
|
-
break;
|
|
81
|
-
await pause(20, undefined, { signal: publication });
|
|
82
|
-
}
|
|
83
|
-
publication.throwIfAborted();
|
|
84
|
-
publishing = true;
|
|
85
|
-
await delivery.publish(publication);
|
|
86
|
-
}, deadline, bound);
|
|
87
|
-
// A rejected run never publishes; a provider failure aborts the owned request.
|
|
88
|
-
await Promise.race([publish, terminal]);
|
|
89
|
-
if (publishing)
|
|
90
|
-
await publish;
|
|
91
|
-
const evidence = await terminal;
|
|
92
|
-
if (evidence.status === 'completed' && !(Date.parse(evidence.completedAt) < deadline)) {
|
|
93
|
-
throw new Error('Native trial deadline exceeded in terminal completion evidence');
|
|
94
|
-
}
|
|
95
|
-
return evidence;
|
|
96
|
-
}, deadline + 8000, signal);
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=delivery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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G,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;gBAC5E,IAAI,OAAO;oBAAE,OAAO;gBACpB,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;oBAAE,MAAM;gBACvJ,MAAM,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;YACtD,CAAC;YACD,WAAW,CAAC,cAAc,EAAE,CAAC;YAC7B,UAAU,GAAG,IAAI,CAAC;YAClB,MAAM,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpB,+EAA+E;QAC/E,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QACxC,IAAI,UAAU;YAAE,MAAM,OAAO,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC;QAChC,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;YACtF,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,EAAE,QAAQ,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { NativeWorkerRequest } from './types.js';
|
|
2
|
-
/** Fixed caller-authorized endpoint. No ambient credentials, URL credentials or redirects. */
|
|
3
|
-
export declare function createNativeHttpClient(endpoint: string, token: string, delivery?: 'direct' | 'transport'): NativeWorkerRequest;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { fetch, getGlobalDispatcher } from 'undici';
|
|
2
|
-
const responseLimit = 16_777_216;
|
|
3
|
-
/**
|
|
4
|
-
* A worker holding a socket open is working, not broken: the request's own
|
|
5
|
-
* deadline is the only authority on how long that may last. undici's ambient
|
|
6
|
-
* header and body timeouts (300 seconds by default) are shorter than a
|
|
7
|
-
* legitimate trial turn and would tear down a healthy worker as a transport
|
|
8
|
-
* failure, so every request carries its own, derived from that deadline and
|
|
9
|
-
* deliberately later than it. An over-deadline worker then expires through the
|
|
10
|
-
* abort signal and is reported as cancelled or expired, while a dead socket
|
|
11
|
-
* still surfaces as a transport failure. undici's timers are accurate to within
|
|
12
|
-
* 500ms, well inside this grace.
|
|
13
|
-
*/
|
|
14
|
-
const dispatcherGraceMs = 30_000;
|
|
15
|
-
/** Fixed caller-authorized endpoint. No ambient credentials, URL credentials or redirects. */
|
|
16
|
-
export function createNativeHttpClient(endpoint, token, delivery = 'direct') {
|
|
17
|
-
const url = new URL(endpoint);
|
|
18
|
-
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== '/') {
|
|
19
|
-
throw new Error('Native worker endpoint must be an HTTP origin without credentials, path or query');
|
|
20
|
-
}
|
|
21
|
-
if (!/^[\x21-\x7e]{16,4096}$/u.test(token))
|
|
22
|
-
throw new Error('Native worker authentication token is invalid');
|
|
23
|
-
return async (path, body, timeoutMs = 5000, signal) => {
|
|
24
|
-
if (!['/trial/health', '/trial/run', '/trial/stop', '/v2/activity'].includes(path) ||
|
|
25
|
-
(['/trial/health', '/v2/activity'].includes(path) ? body !== undefined
|
|
26
|
-
: body === undefined && !(path === '/trial/run' && delivery === 'transport')))
|
|
27
|
-
throw new Error('Unsupported native worker request');
|
|
28
|
-
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 86_408_000)
|
|
29
|
-
throw new Error('Invalid native worker request deadline');
|
|
30
|
-
const payload = body === undefined ? undefined : JSON.stringify(body);
|
|
31
|
-
if (payload !== undefined && Buffer.byteLength(payload) > 32768)
|
|
32
|
-
throw new Error('Native worker request exceeds its byte bound');
|
|
33
|
-
const deadline = AbortSignal.timeout(timeoutMs);
|
|
34
|
-
const combined = signal ? AbortSignal.any([signal, deadline]) : deadline;
|
|
35
|
-
combined.throwIfAborted();
|
|
36
|
-
// Composing the process dispatcher binds both timeouts per request without owning a connection pool to close or leak.
|
|
37
|
-
const bound = timeoutMs + dispatcherGraceMs;
|
|
38
|
-
const dispatcher = getGlobalDispatcher().compose(dispatch => (options, handler) => dispatch({ ...options, headersTimeout: bound, bodyTimeout: bound }, handler));
|
|
39
|
-
let response;
|
|
40
|
-
try {
|
|
41
|
-
response = await fetch(new URL(path, url), { method: payload === undefined ? 'GET' : 'POST', redirect: 'error',
|
|
42
|
-
headers: { authorization: `Bearer ${token}`, ...(payload === undefined ? {} : { 'content-type': 'application/json' }) },
|
|
43
|
-
body: payload, signal: combined, dispatcher });
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
throw new Error(combined.aborted ? 'Native worker request cancelled or expired' : 'Native worker transport failed');
|
|
47
|
-
}
|
|
48
|
-
if (!response.ok) {
|
|
49
|
-
await response.body?.cancel();
|
|
50
|
-
throw new Error(`Native worker HTTP status ${response.status}`);
|
|
51
|
-
}
|
|
52
|
-
if (response.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase() !== 'application/json' || !response.body) {
|
|
53
|
-
await response.body?.cancel();
|
|
54
|
-
throw new Error('Native worker response is not JSON');
|
|
55
|
-
}
|
|
56
|
-
const reader = response.body.getReader();
|
|
57
|
-
const chunks = [];
|
|
58
|
-
let bytes = 0;
|
|
59
|
-
try {
|
|
60
|
-
for (;;) {
|
|
61
|
-
const next = await reader.read();
|
|
62
|
-
if (next.done)
|
|
63
|
-
break;
|
|
64
|
-
bytes += next.value.length;
|
|
65
|
-
if (bytes > responseLimit)
|
|
66
|
-
throw new Error('Native worker response exceeds its byte bound');
|
|
67
|
-
chunks.push(next.value);
|
|
68
|
-
}
|
|
69
|
-
combined.throwIfAborted();
|
|
70
|
-
return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)));
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
await reader.cancel().catch(() => undefined);
|
|
74
|
-
throw new Error(combined.aborted ? 'Native worker response cancelled or expired' : 'Native worker response is malformed or exceeds its bound');
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
reader.releaseLock();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=http.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../../../src/runtime/daimon/training/native/transport/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGpD,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC;;;;;;;;;;GAUG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,8FAA8F;AAC9F,MAAM,UAAU,sBAAsB,CAAC,QAAgB,EAAE,KAAa,EAAE,WAAmC,QAAQ;IACjH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;QAClI,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC;IACD,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,CA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J,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { createNativeHttpClient } from './http.js';
|
|
2
|
-
export type { NativeExecutionHandle, NativeWorkerPath, NativeWorkerRequest } from './types.js';
|
|
3
|
-
export { boundedTransportCall, requestTransportDelivery, transportTerminalBinding, verifyPreparedTransport } from './delivery.js';
|
|
4
|
-
export type { NativeTransportDelivery, PreparedTransportDelivery } from './delivery.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/runtime/daimon/training/native/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { StopReceipt, SubjectStartupDiagnostic } from '../../../../../training/index.js';
|
|
2
|
-
export type NativeWorkerPath = '/trial/health' | '/trial/run' | '/trial/stop' | '/v2/activity';
|
|
3
|
-
export type NativeWorkerRequest = <T>(path: NativeWorkerPath, body?: unknown, timeoutMs?: number, signal?: AbortSignal) => Promise<T>;
|
|
4
|
-
export interface NativeExecutionHandle {
|
|
5
|
-
name: string;
|
|
6
|
-
request: NativeWorkerRequest;
|
|
7
|
-
stop(reason: string): Promise<StopReceipt>;
|
|
8
|
-
/**
|
|
9
|
-
* The redacted account of a worker that stopped answering, available once
|
|
10
|
-
* `stop` has settled and only when the closure was not confirmed. A confirmed
|
|
11
|
-
* closure needs no explanation; an unconfirmed one is the case where nothing
|
|
12
|
-
* else says why. Absent for transports that own no child process.
|
|
13
|
-
*/
|
|
14
|
-
diagnostic?(): SubjectStartupDiagnostic | undefined;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/runtime/daimon/training/native/transport/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function nativeWorkerMain(args: string[]): Promise<number>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { runDaimonNativeWorker } from './worker.js';
|
|
3
|
-
export async function nativeWorkerMain(args) {
|
|
4
|
-
try {
|
|
5
|
-
await runDaimonNativeWorker(args);
|
|
6
|
-
return 0;
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
process.stderr.write(`${JSON.stringify({ schema: 'spawnfile.training.daimon-native.start-failed.v1',
|
|
10
|
-
error: error instanceof Error ? error.message : 'Native startup failed' })}\n`);
|
|
11
|
-
return 1;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
15
|
-
void nativeWorkerMain(process.argv.slice(2)).then(code => { process.exitCode = code; });
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../../../src/runtime/daimon/training/native/worker/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAc;IACnD,IAAI,CAAC;QAAC,MAAM,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAAC,OAAO,CAAC,CAAC;IAAC,CAAC;IACpD,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,kDAAkD;YACjG,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,IAAI,CAAC,CAAC;QAClF,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/E,KAAK,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { describeNativeFailure, admittedExecutions, validateNativeFrame, executionClosed, claimedExecution, disposedWakeExecution, AMBIGUOUS_NATIVE_EXECUTION, AMBIGUOUS_WAKE_EXECUTION } from './evidence/index.js';
|
|
2
|
-
import { type DeliveryControls } from './deliveries.js';
|
|
3
|
-
import { type NativeLaunch, type NativeTaskClockEvidence } from '../receipt/index.js';
|
|
4
|
-
import { createTransportDelivery, type TransportDeliverySource } from './wake-delivery/index.js';
|
|
5
|
-
import type { NativeConfig, NativeHost, TerminalEvidence, WorkerOptions } from './types.js';
|
|
6
|
-
export interface NativeStopEvidence {
|
|
7
|
-
schema: 'spawnfile.training.daimon-native.stop.v1';
|
|
8
|
-
state: 'acknowledged' | 'unknown';
|
|
9
|
-
quiescence: 'unknown';
|
|
10
|
-
containmentVerification: 'parent-container-owner';
|
|
11
|
-
native?: unknown;
|
|
12
|
-
error?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface WorkerController {
|
|
15
|
-
host: NativeHost;
|
|
16
|
-
transport?: ReturnType<typeof createTransportDelivery>;
|
|
17
|
-
run(wakeId: string, text: string, controls?: DeliveryControls, source?: TransportDeliverySource): Promise<TerminalEvidence>;
|
|
18
|
-
stop(): Promise<NativeStopEvidence>;
|
|
19
|
-
}
|
|
20
|
-
export declare function createWorkerController(host: NativeHost, config: NativeConfig, options: WorkerOptions, token: string, launch?: NativeLaunch, taskClock?: NativeTaskClockEvidence): WorkerController;
|