spawnfile 0.1.33 → 0.1.35
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/audit/readAudit.d.ts +3 -3
- package/dist/auth/profileStore.d.ts +3 -1
- package/dist/auth/profileStore.js +31 -30
- package/dist/auth/trainingAuth.d.ts +2 -5
- package/dist/auth/types.d.ts +16 -0
- package/dist/cli/authCommands.d.ts +1 -1
- package/dist/cli/authCommands.js +21 -1
- package/dist/cli/devCommands.d.ts +1 -1
- package/dist/cli/devCommands.js +0 -66
- package/dist/cli/runCli.d.ts +3 -4
- package/dist/cli/runCli.js +4 -3
- package/dist/cli/trainCommand.js +9 -15
- package/dist/cli/trainingBooted.d.ts +9 -0
- package/dist/cli/trainingBooted.js +45 -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 +19 -90
- package/dist/compiler/containerDaimonGatewayRender.d.ts +50 -0
- package/dist/compiler/containerDaimonGatewayRender.js +161 -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 +29 -47
- 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 +3 -0
- package/dist/compiler/runProject.js +12 -5
- package/dist/compiler/runProjectAuth.js +6 -18
- 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/rewind/contract.d.ts +6 -6
- package/dist/compiler/training/trial/boot.d.ts +72 -0
- package/dist/compiler/training/trial/boot.js +225 -0
- package/dist/compiler/training/trial/docker.d.ts +10 -0
- package/dist/compiler/training/trial/docker.js +22 -0
- package/dist/compiler/training/trial/gateway.d.ts +47 -0
- package/dist/compiler/training/trial/gateway.js +113 -0
- package/dist/compiler/training/trial/homeLogin.d.ts +31 -0
- package/dist/compiler/training/trial/homeLogin.js +69 -0
- package/dist/compiler/training/trial/index.d.ts +8 -0
- package/dist/compiler/training/trial/index.js +8 -0
- package/dist/compiler/training/trial/judge.d.ts +15 -0
- package/dist/compiler/training/trial/judge.js +42 -0
- package/dist/compiler/training/trial/launcher.d.ts +47 -0
- package/dist/compiler/training/trial/launcher.js +193 -0
- package/dist/compiler/training/trial/login.d.ts +35 -0
- package/dist/compiler/training/trial/login.js +85 -0
- package/dist/compiler/training/trial/project.d.ts +11 -0
- package/dist/compiler/training/trial/project.js +31 -0
- package/dist/compiler/training/trial/realmTurns.d.ts +20 -0
- package/dist/compiler/training/trial/realmTurns.js +69 -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/manifest/renderSpawnfile.js +2 -1
- 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 +8 -14
- 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 +15 -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 +27 -3
- package/dist/runtime/daimon/subscriptionRealms.js +35 -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 +50 -0
- package/dist/runtime/daimon/training/booted/adapter.js +60 -0
- package/dist/runtime/daimon/training/booted/adapter.js.map +1 -0
- package/dist/runtime/daimon/training/booted/index.d.ts +4 -0
- package/dist/runtime/daimon/training/booted/index.js +3 -0
- package/dist/runtime/daimon/training/booted/index.js.map +1 -0
- package/dist/runtime/daimon/training/booted/judge.d.ts +39 -0
- package/dist/runtime/daimon/training/booted/judge.js +122 -0
- package/dist/runtime/daimon/training/booted/judge.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/wakeMoments.js +0 -1
- package/dist/runtime/install.js +0 -21
- package/dist/runtime/registry.js +0 -2
- package/dist/runtime/trainingGraderProviders.js +10 -4
- package/dist/runtime/trainingProviders.d.ts +5 -3
- package/dist/runtime/trainingProviders.js +21 -24
- 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/runtime/usageRequestLedger.d.ts +2 -0
- package/dist/runtime/usageRequestLedger.js +3 -1
- package/dist/shared/errors.js +0 -1
- package/dist/shared/trainingLegacy/trainingLegacyHashDomains.d.ts +1 -0
- package/dist/shared/trainingLegacy/trainingLegacyHashDomains.js +1 -0
- package/dist/shared/trainingLegacy/trainingLegacyHashDomains.js.map +1 -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.d.ts +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/index.js +0 -2
- package/dist/runtime/codex-exec/training/providers/codex-subscription/index.js.map +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/protocol.d.ts +0 -17
- package/dist/runtime/codex-exec/training/providers/codex-subscription/protocol.js +0 -80
- package/dist/runtime/codex-exec/training/providers/codex-subscription/protocol.js.map +0 -1
- package/dist/runtime/codex-exec/training/providers/codex-subscription/provider.d.ts +0 -12
- package/dist/runtime/codex-exec/training/providers/codex-subscription/provider.js +0 -125
- 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.d.ts +0 -6
- package/dist/runtime/codex-exec/training/providers/codex-subscription/strict-schema.js +0 -219
- 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/providers/grok-subscription/cli.d.ts +0 -21
- package/dist/runtime/daimon/training/providers/grok-subscription/cli.js +0 -81
- package/dist/runtime/daimon/training/providers/grok-subscription/cli.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/index.d.ts +0 -4
- package/dist/runtime/daimon/training/providers/grok-subscription/index.js +0 -5
- package/dist/runtime/daimon/training/providers/grok-subscription/index.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/protocol.d.ts +0 -26
- package/dist/runtime/daimon/training/providers/grok-subscription/protocol.js +0 -102
- package/dist/runtime/daimon/training/providers/grok-subscription/protocol.js.map +0 -1
- package/dist/runtime/daimon/training/providers/grok-subscription/provider.d.ts +0 -9
- package/dist/runtime/daimon/training/providers/grok-subscription/provider.js +0 -38
- package/dist/runtime/daimon/training/providers/grok-subscription/provider.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
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { compatibleWireLiteral } from '../../../../training/index.js';
|
|
2
|
-
import { randomBytes, randomUUID } from 'node:crypto';
|
|
3
|
-
import { constants } from 'node:fs';
|
|
4
|
-
import { lstat, open, readFile, rename, unlink } from 'node:fs/promises';
|
|
5
|
-
import { dirname, isAbsolute } from 'node:path';
|
|
6
|
-
import { setTimeout as pause } from 'node:timers/promises';
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
const schema = 'spawnfile.training.daimon-native.grok-slot-freshness.v1';
|
|
9
|
-
const nonce = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
10
|
-
const stateSchema = z.strictObject({ schema: compatibleWireLiteral(schema),
|
|
11
|
-
slots: z.record(z.string().regex(/^(?:0|[1-9][0-9]{0,15})$/u), z.strictObject({ lastGeneration: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER), pendingNonce: nonce.optional() })) });
|
|
12
|
-
const lockSchema = z.strictObject({ pid: z.number().int().positive(), token: z.string().min(1) });
|
|
13
|
-
/** Compare-and-swap guard: a write may never lower any slot's generation floor already on disk. */
|
|
14
|
-
export function assertNoFloorRollback(disk, next) {
|
|
15
|
-
for (const [slot, entry] of Object.entries(disk.slots)) {
|
|
16
|
-
if ((next.slots[slot]?.lastGeneration ?? -1) < entry.lastGeneration)
|
|
17
|
-
throw new Error('Grok slot freshness state refuses to lower a generation floor');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const noFollowRead = constants.O_RDONLY | constants.O_NOFOLLOW;
|
|
21
|
-
const exclusiveCreate = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW;
|
|
22
|
-
const alive = (pid) => {
|
|
23
|
-
try {
|
|
24
|
-
process.kill(pid, 0);
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
return error.code === 'EPERM';
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Every operation re-reads the file under an exclusive O_EXCL lockfile shared by all
|
|
33
|
-
* store instances and processes, then compare-and-swaps: no slot's generation floor on
|
|
34
|
-
* disk is ever lowered. A lock whose owner process is gone (same PID namespace) is
|
|
35
|
-
* reclaimed; a live owner is waited for until the lock deadline.
|
|
36
|
-
*/
|
|
37
|
-
export function createGrokSlotFreshnessStore(file, options = {}) {
|
|
38
|
-
if (!isAbsolute(file))
|
|
39
|
-
throw new Error('Grok slot freshness state requires an absolute experiment-state path');
|
|
40
|
-
const lockTimeoutMs = options.lockTimeoutMs ?? 10_000;
|
|
41
|
-
const lockFile = `${file}.lock`;
|
|
42
|
-
const key = (slot) => {
|
|
43
|
-
if (!Number.isSafeInteger(slot) || slot < 0)
|
|
44
|
-
throw new Error('Invalid Grok broker slot');
|
|
45
|
-
return String(slot);
|
|
46
|
-
};
|
|
47
|
-
const refuseLink = async (path) => {
|
|
48
|
-
try {
|
|
49
|
-
const entry = await lstat(path);
|
|
50
|
-
if (!entry.isFile() || entry.isSymbolicLink() || entry.nlink !== 1)
|
|
51
|
-
throw new Error('Grok slot freshness state must be a private regular file, never a symlink');
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
if (error.code === 'ENOENT')
|
|
56
|
-
return false;
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const load = async () => {
|
|
61
|
-
if (!await refuseLink(file))
|
|
62
|
-
return { schema, slots: {} };
|
|
63
|
-
const handle = await open(file, noFollowRead);
|
|
64
|
-
try {
|
|
65
|
-
return stateSchema.parse(JSON.parse(await handle.readFile('utf8')));
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
await handle.close();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const save = async (state) => {
|
|
72
|
-
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
73
|
-
const handle = await open(temporary, exclusiveCreate, 0o600);
|
|
74
|
-
try {
|
|
75
|
-
await handle.writeFile(`${JSON.stringify(state)}\n`);
|
|
76
|
-
await handle.sync();
|
|
77
|
-
}
|
|
78
|
-
finally {
|
|
79
|
-
await handle.close();
|
|
80
|
-
}
|
|
81
|
-
await refuseLink(file);
|
|
82
|
-
await rename(temporary, file);
|
|
83
|
-
const directory = await open(dirname(file), 'r');
|
|
84
|
-
try {
|
|
85
|
-
await directory.sync();
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
await directory.close();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const acquire = async () => {
|
|
92
|
-
const token = randomUUID();
|
|
93
|
-
const deadline = Date.now() + lockTimeoutMs;
|
|
94
|
-
for (let delay = 5;; delay = Math.min(delay * 2, 100)) {
|
|
95
|
-
try {
|
|
96
|
-
const handle = await open(lockFile, exclusiveCreate, 0o600);
|
|
97
|
-
try {
|
|
98
|
-
await handle.writeFile(JSON.stringify({ pid: process.pid, token }));
|
|
99
|
-
await handle.sync();
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
await handle.close();
|
|
103
|
-
}
|
|
104
|
-
return token;
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
if (error.code !== 'EEXIST')
|
|
108
|
-
throw error;
|
|
109
|
-
}
|
|
110
|
-
let owner;
|
|
111
|
-
try {
|
|
112
|
-
owner = lockSchema.parse(JSON.parse(await readFile(lockFile, 'utf8')));
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
owner = undefined;
|
|
116
|
-
}
|
|
117
|
-
if (owner && !alive(owner.pid)) {
|
|
118
|
-
// Reclaim only the exact dead owner's lock: move it aside, then confirm it is still that owner.
|
|
119
|
-
const aside = `${lockFile}.${randomUUID()}.stale`;
|
|
120
|
-
try {
|
|
121
|
-
await rename(lockFile, aside);
|
|
122
|
-
const moved = lockSchema.safeParse(JSON.parse(await readFile(aside, 'utf8')));
|
|
123
|
-
if (moved.success && moved.data.token === owner.token) {
|
|
124
|
-
await unlink(aside);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
await rename(aside, lockFile);
|
|
128
|
-
}
|
|
129
|
-
catch { /* another reclaimer won; retry acquisition */ }
|
|
130
|
-
}
|
|
131
|
-
if (Date.now() >= deadline)
|
|
132
|
-
throw new Error('Grok slot freshness state lock is held by another live evaluator');
|
|
133
|
-
await pause(delay);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const release = async (token) => {
|
|
137
|
-
const held = lockSchema.safeParse(JSON.parse(await readFile(lockFile, 'utf8')));
|
|
138
|
-
if (held.success && held.data.token === token)
|
|
139
|
-
await unlink(lockFile);
|
|
140
|
-
};
|
|
141
|
-
const transaction = async (mutate) => {
|
|
142
|
-
const token = await acquire();
|
|
143
|
-
try {
|
|
144
|
-
const disk = await load();
|
|
145
|
-
const next = structuredClone(disk);
|
|
146
|
-
const result = mutate(next);
|
|
147
|
-
assertNoFloorRollback(disk, next);
|
|
148
|
-
await save(next);
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
await release(token);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
return {
|
|
156
|
-
request: async (slot) => {
|
|
157
|
-
const id = key(slot);
|
|
158
|
-
return transaction(state => {
|
|
159
|
-
const entry = state.slots[id] ?? { lastGeneration: 0 };
|
|
160
|
-
const expectedNonce = randomBytes(32).toString('hex');
|
|
161
|
-
state.slots[id] = { lastGeneration: entry.lastGeneration, pendingNonce: expectedNonce };
|
|
162
|
-
return { expectedNonce, minGeneration: entry.lastGeneration + 1 };
|
|
163
|
-
});
|
|
164
|
-
},
|
|
165
|
-
accept: async (slot, receipt) => {
|
|
166
|
-
const id = key(slot);
|
|
167
|
-
await transaction(state => {
|
|
168
|
-
const entry = state.slots[id];
|
|
169
|
-
if (!entry?.pendingNonce || entry.pendingNonce !== receipt.nonce)
|
|
170
|
-
throw new Error('Grok slot preflight receipt is stale: nonce');
|
|
171
|
-
if (!Number.isSafeInteger(receipt.generation) || receipt.generation <= entry.lastGeneration)
|
|
172
|
-
throw new Error('Grok slot preflight receipt is stale: generation');
|
|
173
|
-
state.slots[id] = { lastGeneration: receipt.generation };
|
|
174
|
-
});
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
//# sourceMappingURL=slot-freshness.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slot-freshness.js","sourceRoot":"","sources":["../../../../../src/runtime/daimon/training/services/slot-freshness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,GAAG,yDAAyD,CAAC;AACzE,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,CAAC,CAAC,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AAG,CAAC,IAAK,KAAiC,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC"}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { readUtf8File, resolveProjectPath } from "../../filesystem/index.js";
|
|
2
|
-
import { SpawnfileError } from "../../shared/index.js";
|
|
3
|
-
import { CLI_ENGINE_SKILL_BASE_DIRECTORIES, createAgentCapabilities, createDiagnostic, createDocumentFiles, createSkillFiles } from "../common.js";
|
|
4
|
-
import { resolveScriptedEngineCommandOption, resolveScriptedEngineStagedPath } from "./appScriptedEngine.js";
|
|
5
|
-
import { isPiEveryScheduleValue, PI_BUILTIN_TOOLS, PI_ENGINE_KINDS, PI_PACKAGE_NAME, PI_PACKAGE_VERSION, PI_THINKING_FORMATS, PI_THINKING_LEVELS } from "./appTemplate.js";
|
|
6
|
-
import { createPiContainerTargets, PI_CONFIG_FILE, PI_CONTROL_PORT, } from "./containerTargets.js";
|
|
7
|
-
import { preparePiRuntimeAuth } from "./runAuth.js";
|
|
8
|
-
/**
|
|
9
|
-
* Stages a `scripted`-engine's `engine_command` script into this agent's
|
|
10
|
-
* emitted workspace files, the same way `createDocumentFiles`/
|
|
11
|
-
* `createSkillFiles` stage docs/skills: read once at compile time (relative
|
|
12
|
-
* to the declaring manifest, via `resolveProjectPath(node.sourcePath ?? node.source, ...)`,
|
|
13
|
-
* mirroring `surfaces.ts`'s `loadResolvedDocuments`) and emitted as a
|
|
14
|
-
* `workspace/...` file, which `createContainerTargets` below relocates to
|
|
15
|
-
* `workspace/agents/<slug>/...` (`moveWorkspaceFileToAgentWorkspace`) just
|
|
16
|
-
* like every other per-agent workspace file. Returns `[]` for every engine
|
|
17
|
-
* other than `scripted` (and defensively for a `scripted` engine missing
|
|
18
|
-
* `engine_command`, though `validateRuntimeOptions` below already rejects
|
|
19
|
-
* that before `compileAgent` ever runs).
|
|
20
|
-
*/
|
|
21
|
-
const createScriptedEngineFiles = async (node) => {
|
|
22
|
-
const option = resolveScriptedEngineCommandOption(node);
|
|
23
|
-
const stagedPath = resolveScriptedEngineStagedPath(node);
|
|
24
|
-
if (!option || !stagedPath) {
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
const sourcePath = resolveProjectPath(node.sourcePath ?? node.source, option);
|
|
28
|
-
const content = await readUtf8File(sourcePath);
|
|
29
|
-
return [
|
|
30
|
-
{
|
|
31
|
-
content,
|
|
32
|
-
mode: 0o755,
|
|
33
|
-
path: `workspace/${stagedPath}`
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
};
|
|
37
|
-
const scheduleOutcomeFor = (node) => {
|
|
38
|
-
if (!node.schedule) {
|
|
39
|
-
return {};
|
|
40
|
-
}
|
|
41
|
-
if (node.schedule.kind === "every" || node.schedule.kind === "disabled") {
|
|
42
|
-
return {
|
|
43
|
-
message: "Pi generated runtime app owns this schedule",
|
|
44
|
-
outcome: "supported"
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
message: "Pi generated runtime app supports every schedules in Spawnfile v0.1",
|
|
49
|
-
outcome: "degraded"
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
const createScheduleDiagnostics = (node) => node.schedule?.kind === "cron"
|
|
53
|
-
? [
|
|
54
|
-
createDiagnostic("warn", "Pi generated runtime app supports every schedules in Spawnfile v0.1; cron schedules are degraded")
|
|
55
|
-
]
|
|
56
|
-
: [];
|
|
57
|
-
const createMemoryConsolidationDiagnostics = (node) => (node.memoryAccess ?? []).flatMap((access) => access.bank.consolidation.mode === "scheduled" &&
|
|
58
|
-
access.bank.consolidation.schedule &&
|
|
59
|
-
!isPiEveryScheduleValue(access.bank.consolidation.schedule)
|
|
60
|
-
? [
|
|
61
|
-
createDiagnostic("warn", `Pi generated runtime app supports every memory consolidation schedules in Spawnfile v0.1; memory bank ${access.bank.id} consolidation is degraded`)
|
|
62
|
-
]
|
|
63
|
-
: []);
|
|
64
|
-
const moltnetCapabilityOptions = (node) => node.surfaces?.moltnet
|
|
65
|
-
? {
|
|
66
|
-
moltnetMessage: "Pi generated runtime app exposes a control endpoint for Moltnet bridge wake delivery",
|
|
67
|
-
moltnetOutcome: "supported"
|
|
68
|
-
}
|
|
69
|
-
: {};
|
|
70
|
-
const assertSupportedPiSurfaces = (surfaces) => {
|
|
71
|
-
if (!surfaces) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const unsupported = [
|
|
75
|
-
surfaces.discord ? "discord" : null,
|
|
76
|
-
surfaces.http ? "http" : null,
|
|
77
|
-
surfaces.slack ? "slack" : null,
|
|
78
|
-
surfaces.telegram ? "telegram" : null,
|
|
79
|
-
surfaces.webhook ? "webhook" : null,
|
|
80
|
-
surfaces.whatsapp ? "whatsapp" : null
|
|
81
|
-
].filter((surface) => surface !== null);
|
|
82
|
-
if (unsupported.length > 0) {
|
|
83
|
-
throw new SpawnfileError("validation_error", `Pi runtime only supports Moltnet surfaces in Spawnfile v0.1; unsupported surfaces: ${unsupported.join(", ")}`);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
export const piAdapter = {
|
|
87
|
-
assertSupportedModelTarget(target) {
|
|
88
|
-
if (target.reasoningEffort !== undefined) {
|
|
89
|
-
throw new SpawnfileError("validation_error", "Pi runtime does not support reasoning_effort; only Daimon Codex and Grok engines support it");
|
|
90
|
-
}
|
|
91
|
-
if (target.endpoint) {
|
|
92
|
-
if (target.provider !== "custom" && target.provider !== "local") {
|
|
93
|
-
throw new SpawnfileError("validation_error", "Pi runtime only supports endpoints on custom or local model providers");
|
|
94
|
-
}
|
|
95
|
-
if (target.auth.method === "none" || target.auth.method === "api_key") {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
throw new SpawnfileError("validation_error", `Pi runtime endpoint models only support none or api_key auth, got ${target.auth.method}`);
|
|
99
|
-
}
|
|
100
|
-
if (target.provider === "openai") {
|
|
101
|
-
if (target.auth.method === "api_key" || target.auth.method === "codex") {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (target.provider === "anthropic" && target.auth.method === "api_key") {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (target.provider === "anthropic" && target.auth.method === "claude-code") {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
throw new SpawnfileError("validation_error", `Pi runtime does not support model auth method ${target.auth.method} for provider ${target.provider}`);
|
|
112
|
-
},
|
|
113
|
-
assertSupportedSurfaces(surfaces) {
|
|
114
|
-
assertSupportedPiSurfaces(surfaces);
|
|
115
|
-
},
|
|
116
|
-
container: {
|
|
117
|
-
configFileName: PI_CONFIG_FILE,
|
|
118
|
-
configPathEnv: "SPAWNFILE_PI_CONFIG",
|
|
119
|
-
homeEnv: "SPAWNFILE_PI_HOME",
|
|
120
|
-
instancePaths: {
|
|
121
|
-
configPathTemplate: "<instance-root>/pi/<config-file>",
|
|
122
|
-
homePathTemplate: "<instance-root>/home",
|
|
123
|
-
sourceWorkspacePathTemplate: "<instance-root>/workspace/agents/<source-slug>",
|
|
124
|
-
workspacePathTemplate: "<instance-root>/workspace"
|
|
125
|
-
},
|
|
126
|
-
port: PI_CONTROL_PORT,
|
|
127
|
-
portEnv: "SPAWNFILE_PI_CONTROL_PORT",
|
|
128
|
-
globalNpmPackages: ["@anthropic-ai/claude-code", "@openai/codex@0.142.3"],
|
|
129
|
-
postRootfsCommands: [
|
|
130
|
-
"curl -fsSL https://x.ai/cli/install.sh | GROK_BIN_DIR=/usr/local/bin bash",
|
|
131
|
-
"if [ -L /usr/local/bin/grok ]; then cp -L /usr/local/bin/grok /usr/local/bin/grok.real && mv /usr/local/bin/grok.real /usr/local/bin/grok && chmod 0755 /usr/local/bin/grok && ln -sf /usr/local/bin/grok /usr/local/bin/agent; fi",
|
|
132
|
-
"curl -fsSL https://antigravity.google/cli/install.sh | bash -s -- --dir /usr/local/bin"
|
|
133
|
-
],
|
|
134
|
-
standaloneBaseImage: "node:24-bookworm-slim",
|
|
135
|
-
startCommand: ["node", "<runtime-root>/app.mjs", "<config-path>"],
|
|
136
|
-
systemDeps: ["bash", "ca-certificates", "curl", "git", "procps", "tar"]
|
|
137
|
-
},
|
|
138
|
-
systemInstructionSurface: {
|
|
139
|
-
placement: "append_pointer",
|
|
140
|
-
resolvePath() {
|
|
141
|
-
return "workspace/AGENTS.md";
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
async compileAgent(node) {
|
|
145
|
-
const scheduleOutcome = scheduleOutcomeFor(node);
|
|
146
|
-
return {
|
|
147
|
-
capabilities: createAgentCapabilities(node, {
|
|
148
|
-
memoryMessage: "Daimon exposes Mneme memory through generated runtime turns",
|
|
149
|
-
memoryOutcome: "supported",
|
|
150
|
-
...moltnetCapabilityOptions(node),
|
|
151
|
-
mcpOutcome: node.mcpServers.length > 0 ? "degraded" : "supported",
|
|
152
|
-
sandboxOutcome: node.execution?.sandbox ? "degraded" : "supported",
|
|
153
|
-
scheduleMessage: scheduleOutcome.message,
|
|
154
|
-
scheduleOutcome: scheduleOutcome.outcome,
|
|
155
|
-
subagentOutcome: node.subagents.length > 0 ? "degraded" : "supported"
|
|
156
|
-
}),
|
|
157
|
-
diagnostics: [
|
|
158
|
-
...createScheduleDiagnostics(node),
|
|
159
|
-
...createMemoryConsolidationDiagnostics(node),
|
|
160
|
-
...(node.execution?.sandbox
|
|
161
|
-
? [createDiagnostic("warn", "Pi runtime relies on container and workspace isolation; Pi itself is not a sandbox engine")]
|
|
162
|
-
: []),
|
|
163
|
-
...(node.mcpServers.length > 0
|
|
164
|
-
? [createDiagnostic("warn", "Pi runtime does not lower MCP server declarations in Spawnfile v0.1")]
|
|
165
|
-
: []),
|
|
166
|
-
...(node.subagents.length > 0
|
|
167
|
-
? [createDiagnostic("warn", "Pi runtime groups compiled agents but does not preserve native parent-owned subagent semantics in v0.1")]
|
|
168
|
-
: [])
|
|
169
|
-
],
|
|
170
|
-
files: [
|
|
171
|
-
...createDocumentFiles("workspace", node.docs),
|
|
172
|
-
...createSkillFiles(CLI_ENGINE_SKILL_BASE_DIRECTORIES, node.skills),
|
|
173
|
-
...(await createScriptedEngineFiles(node))
|
|
174
|
-
]
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
async createContainerTargets(inputs) {
|
|
178
|
-
return createPiContainerTargets(inputs);
|
|
179
|
-
},
|
|
180
|
-
name: "pi",
|
|
181
|
-
prepareRuntimeAuth: preparePiRuntimeAuth,
|
|
182
|
-
validateRuntimeOptions(options) {
|
|
183
|
-
const diagnostics = [];
|
|
184
|
-
if (options.engine !== undefined &&
|
|
185
|
-
(typeof options.engine !== "string" ||
|
|
186
|
-
!PI_ENGINE_KINDS.includes(options.engine))) {
|
|
187
|
-
diagnostics.push(createDiagnostic("error", `Pi runtime option engine must be one of ${PI_ENGINE_KINDS.join(", ")}`));
|
|
188
|
-
}
|
|
189
|
-
if (options.engine === "scripted" &&
|
|
190
|
-
(typeof options.engine_command !== "string" || options.engine_command.trim().length === 0)) {
|
|
191
|
-
diagnostics.push(createDiagnostic("error", "Pi runtime option engine_command is required (a fixture-relative script path) when engine is scripted"));
|
|
192
|
-
}
|
|
193
|
-
if (options.thinking !== undefined &&
|
|
194
|
-
(typeof options.thinking !== "string" ||
|
|
195
|
-
!PI_THINKING_LEVELS.includes(options.thinking))) {
|
|
196
|
-
diagnostics.push(createDiagnostic("error", `Pi runtime option thinking must be one of ${PI_THINKING_LEVELS.join(", ")}`));
|
|
197
|
-
}
|
|
198
|
-
if (options.thinking_format !== undefined &&
|
|
199
|
-
(typeof options.thinking_format !== "string" ||
|
|
200
|
-
!PI_THINKING_FORMATS.includes(options.thinking_format))) {
|
|
201
|
-
diagnostics.push(createDiagnostic("error", `Pi runtime option thinking_format must be one of ${PI_THINKING_FORMATS.join(", ")}`));
|
|
202
|
-
}
|
|
203
|
-
if (options.tools !== undefined &&
|
|
204
|
-
(!Array.isArray(options.tools)
|
|
205
|
-
|| options.tools.some((item) => typeof item !== "string"
|
|
206
|
-
|| !PI_BUILTIN_TOOLS.includes(item))
|
|
207
|
-
|| new Set(options.tools).size !== options.tools.length)) {
|
|
208
|
-
diagnostics.push(createDiagnostic("error", `Pi runtime option tools must contain unique values from ${PI_BUILTIN_TOOLS.join(", ")}`));
|
|
209
|
-
}
|
|
210
|
-
if (options.raw_training_capture_turns !== undefined
|
|
211
|
-
&& (!Number.isSafeInteger(options.raw_training_capture_turns)
|
|
212
|
-
|| typeof options.raw_training_capture_turns !== "number"
|
|
213
|
-
|| options.raw_training_capture_turns < 1
|
|
214
|
-
|| options.raw_training_capture_turns > 100_000)) {
|
|
215
|
-
diagnostics.push(createDiagnostic("error", "Pi runtime option raw_training_capture_turns must be an integer between 1 and 100000"));
|
|
216
|
-
}
|
|
217
|
-
const unsupported = Object.keys(options).filter((key) => key !== "restrict_to_workspace"
|
|
218
|
-
&& key !== "engine"
|
|
219
|
-
&& key !== "engine_command"
|
|
220
|
-
&& key !== "thinking"
|
|
221
|
-
&& key !== "thinking_format"
|
|
222
|
-
&& key !== "tools"
|
|
223
|
-
&& key !== "raw_training_capture_turns");
|
|
224
|
-
for (const key of unsupported) {
|
|
225
|
-
diagnostics.push(createDiagnostic("warn", `Pi runtime option ${key} is not used yet`));
|
|
226
|
-
}
|
|
227
|
-
return diagnostics;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
export const PI_RUNTIME_PACKAGE = `${PI_PACKAGE_NAME}@${PI_PACKAGE_VERSION}`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const renderPiActivitySource: () => string;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
export const renderPiActivitySource = () => String.raw `
|
|
2
|
-
const maxActivityEvents = 500;
|
|
3
|
-
|
|
4
|
-
const createActivityBroker = (options = {}) => {
|
|
5
|
-
let sequence = 0;
|
|
6
|
-
const events = [];
|
|
7
|
-
const clients = new Set();
|
|
8
|
-
|
|
9
|
-
const normalizeFilter = (value) => typeof value === "string" && value.trim().length > 0
|
|
10
|
-
? value.trim()
|
|
11
|
-
: "";
|
|
12
|
-
const matchesFilter = (event, filter) => {
|
|
13
|
-
const normalized = normalizeFilter(filter);
|
|
14
|
-
return normalized === "" ||
|
|
15
|
-
event.agent_id === normalized ||
|
|
16
|
-
event.agent_slug === normalized ||
|
|
17
|
-
event.agent_name === normalized ||
|
|
18
|
-
event.agent_id === "agent:" + normalized;
|
|
19
|
-
};
|
|
20
|
-
const parseTail = (value) => {
|
|
21
|
-
const parsed = Number(value);
|
|
22
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : maxActivityEvents;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const publish = (event) => {
|
|
26
|
-
const full = {
|
|
27
|
-
version: "spawnfile.activity.v1",
|
|
28
|
-
sequence: ++sequence,
|
|
29
|
-
created_at: new Date().toISOString(),
|
|
30
|
-
...event
|
|
31
|
-
};
|
|
32
|
-
events.push(full);
|
|
33
|
-
if (events.length > maxActivityEvents) {
|
|
34
|
-
events.splice(0, events.length - maxActivityEvents);
|
|
35
|
-
}
|
|
36
|
-
if (typeof options.logPath === "string" && options.logPath.length > 0) {
|
|
37
|
-
appendFileSync(options.logPath, JSON.stringify(full) + "\n", "utf8");
|
|
38
|
-
}
|
|
39
|
-
const frame = "data: " + JSON.stringify(full) + "\n\n";
|
|
40
|
-
for (const client of [...clients]) {
|
|
41
|
-
if (!matchesFilter(full, client.filter)) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
client.response.write(frame);
|
|
46
|
-
} catch {
|
|
47
|
-
clients.delete(client);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return full;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const list = (filter, tail) => {
|
|
54
|
-
const selected = events.filter((event) => matchesFilter(event, filter));
|
|
55
|
-
return selected.slice(Math.max(0, selected.length - parseTail(tail)));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const stream = (request, response, filter, tail) => {
|
|
59
|
-
response.writeHead(200, {
|
|
60
|
-
"cache-control": "no-cache",
|
|
61
|
-
"connection": "keep-alive",
|
|
62
|
-
"content-type": "text/event-stream"
|
|
63
|
-
});
|
|
64
|
-
response.write("event: ready\ndata: {\"status\":\"ok\"}\n\n");
|
|
65
|
-
for (const event of list(filter, tail)) {
|
|
66
|
-
response.write("data: " + JSON.stringify(event) + "\n\n");
|
|
67
|
-
}
|
|
68
|
-
const client = { filter: normalizeFilter(filter), response };
|
|
69
|
-
clients.add(client);
|
|
70
|
-
request.on("close", () => clients.delete(client));
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return { list, publish, stream };
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const redactActivityText = (value) => {
|
|
77
|
-
let redacted = String(value);
|
|
78
|
-
redacted = redacted.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, "Bearer [REDACTED]");
|
|
79
|
-
redacted = redacted.replace(/\bmagt_v1_[A-Za-z0-9_-]{16,}\b/g, "[REDACTED]");
|
|
80
|
-
redacted = redacted.replace(/\b(?:sk|sk-proj)-[A-Za-z0-9_-]{20,}\b/g, "[REDACTED]");
|
|
81
|
-
redacted = redacted.replace(
|
|
82
|
-
/("([^"]*(?:api[_-]?key|authorization|credential|password|secret|session[_-]?key|token)[^"]*)"\s*:\s*")([^"]+)(")/gi,
|
|
83
|
-
"$1[REDACTED]$4"
|
|
84
|
-
);
|
|
85
|
-
redacted = redacted.replace(
|
|
86
|
-
/\b((?:api[_-]?key|authorization|credential|password|secret|session\s+key|session[_-]?key|token)\s*[:=]\s*)([^\r\n]+)/gi,
|
|
87
|
-
"$1[REDACTED]"
|
|
88
|
-
);
|
|
89
|
-
redacted = redacted.replace(/\/(?:Users|home|private|tmp|var|opt|run)\/[^\s"']+/g, "[path]");
|
|
90
|
-
return redacted.length > 1000 ? redacted.slice(0, 1000) + "..." : redacted;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const formatActivityError = (error) => redactActivityText(error instanceof Error ? error.message : String(error));
|
|
94
|
-
|
|
95
|
-
const traceSha256 = (value) => createHash("sha256").update(value, "utf8").digest("hex");
|
|
96
|
-
|
|
97
|
-
const sensitiveTraceKeyPattern = /(?:api[_-]?key|authorization|credential|password|secret|session[_-]?key|token)/iu;
|
|
98
|
-
|
|
99
|
-
const sanitizeTraceValue = (value, key = "") => {
|
|
100
|
-
if (value === null || value === undefined) {
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
if (sensitiveTraceKeyPattern.test(String(key))) {
|
|
104
|
-
return "[REDACTED]";
|
|
105
|
-
}
|
|
106
|
-
if (typeof value === "string") {
|
|
107
|
-
return redactActivityText(value);
|
|
108
|
-
}
|
|
109
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
110
|
-
return value;
|
|
111
|
-
}
|
|
112
|
-
if (Array.isArray(value)) {
|
|
113
|
-
return value.map((entry) => sanitizeTraceValue(entry));
|
|
114
|
-
}
|
|
115
|
-
if (typeof value === "object") {
|
|
116
|
-
const sanitized = {};
|
|
117
|
-
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
118
|
-
sanitized[entryKey] = sanitizeTraceValue(entryValue, entryKey);
|
|
119
|
-
}
|
|
120
|
-
return sanitized;
|
|
121
|
-
}
|
|
122
|
-
return redactActivityText(String(value));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const summarizeTurnPrompt = (prompt) => ({
|
|
126
|
-
chars: typeof prompt === "string" ? prompt.length : 0,
|
|
127
|
-
has_active_environment: typeof prompt === "string" && prompt.includes("Active environment context:"),
|
|
128
|
-
has_dream_mode: typeof prompt === "string" && prompt.includes("## Dream Mode"),
|
|
129
|
-
has_memory_context: typeof prompt === "string" && prompt.includes("Memory context"),
|
|
130
|
-
lines: typeof prompt === "string" && prompt.length > 0 ? prompt.split(/\r?\n/u).length : 0,
|
|
131
|
-
sha256: traceSha256(typeof prompt === "string" ? prompt : "")
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const sanitizeTraceFileId = (value) => {
|
|
135
|
-
const normalized = String(value).replace(/[^A-Za-z0-9._-]+/gu, "_").slice(0, 128);
|
|
136
|
-
return normalized.length > 0 ? normalized : "turn";
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const turnTracePath = (paths, wakeId) =>
|
|
140
|
-
path.join(paths.runtimeHomePath, "telemetry", "turns", sanitizeTraceFileId(wakeId) + ".json");
|
|
141
|
-
|
|
142
|
-
const writeTurnTrace = async (paths, record) => {
|
|
143
|
-
const telemetryPath = path.join(paths.runtimeHomePath, "telemetry");
|
|
144
|
-
const turnsPath = path.join(telemetryPath, "turns");
|
|
145
|
-
await mkdir(turnsPath, { recursive: true });
|
|
146
|
-
await writeFile(turnTracePath(paths, record.turn_id), JSON.stringify(record, null, 2) + "\n", "utf8");
|
|
147
|
-
await writeFile(path.join(telemetryPath, "turns.ndjson"), JSON.stringify(record) + "\n", { flag: "a" });
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const createGeneratedTurnTrace = (input) => ({
|
|
151
|
-
agent_id: input.config.id,
|
|
152
|
-
completed_at: new Date().toISOString(),
|
|
153
|
-
engine: {
|
|
154
|
-
auth_method: input.config.model?.auth_method ?? "unknown",
|
|
155
|
-
kind: input.engine,
|
|
156
|
-
model: input.config.model?.name ?? "unknown",
|
|
157
|
-
provider: input.config.model?.provider ?? "unknown"
|
|
158
|
-
},
|
|
159
|
-
...(input.error ? { error: { message: formatActivityError(input.error), stage: input.errorStage ?? "wake" } } : {}),
|
|
160
|
-
memory: {
|
|
161
|
-
enabled: Boolean(input.config.memory),
|
|
162
|
-
...(input.memoryPrepareMs !== undefined || input.memoryRecall ? {
|
|
163
|
-
prepare: {
|
|
164
|
-
duration_ms: input.memoryPrepareMs ?? 0,
|
|
165
|
-
...(input.memoryRecall ? { recall: input.memoryRecall } : {}),
|
|
166
|
-
status: input.memoryPrepareStatus ?? "completed"
|
|
167
|
-
}
|
|
168
|
-
} : {}),
|
|
169
|
-
...(input.memoryRecordMs !== undefined ? { record_ms: input.memoryRecordMs } : {})
|
|
170
|
-
},
|
|
171
|
-
prompt: summarizeTurnPrompt(input.prompt),
|
|
172
|
-
reply: {
|
|
173
|
-
output_chars: input.outputText.length,
|
|
174
|
-
reply_given: input.outputText.trim().length > 0
|
|
175
|
-
},
|
|
176
|
-
schema: "daimon.turn_trace.v1",
|
|
177
|
-
session: {
|
|
178
|
-
mode: input.event.kind === "dream" ? "dream" : "awake",
|
|
179
|
-
thread_id: input.event.context_id ? redactActivityText(input.event.context_id) : input.event.id
|
|
180
|
-
},
|
|
181
|
-
started_at: input.startedAt.toISOString(),
|
|
182
|
-
status: input.status,
|
|
183
|
-
timings_ms: {
|
|
184
|
-
...(input.engineMs !== undefined ? { engine_prompt: input.engineMs } : {}),
|
|
185
|
-
...(input.memoryPrepareMs !== undefined ? { memory_prepare: input.memoryPrepareMs } : {}),
|
|
186
|
-
...(input.memoryRecordMs !== undefined ? { memory_record: input.memoryRecordMs } : {}),
|
|
187
|
-
total: Date.now() - input.startedAt.getTime()
|
|
188
|
-
},
|
|
189
|
-
tools: [],
|
|
190
|
-
turn_id: input.event.id,
|
|
191
|
-
wake: {
|
|
192
|
-
...(input.event.context ? { context: sanitizeTraceValue(input.event.context) } : {}),
|
|
193
|
-
...(input.event.context_id ? { context_id: redactActivityText(input.event.context_id) } : {}),
|
|
194
|
-
event_id: input.event.id,
|
|
195
|
-
...(input.event.from ? { from: redactActivityText(input.event.from) } : {}),
|
|
196
|
-
kind: input.event.kind
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ResolvedAgentNode } from "../../compiler/types.js";
|
|
2
|
-
import type { SimfileWorldBindingV1 } from "../../compiler/worldBindings.js";
|
|
3
|
-
import { PI_THINKING_FORMATS, type PiGeneratedAgent } from "./appTemplateTypes.js";
|
|
4
|
-
export declare const isPiEveryScheduleValue: (value: string) => boolean;
|
|
5
|
-
export declare const resolvePiEngine: (node: ResolvedAgentNode) => PiGeneratedAgent["engine"];
|
|
6
|
-
export declare const resolvePiThinkingLevel: (node: ResolvedAgentNode) => PiGeneratedAgent["thinking_level"] | undefined;
|
|
7
|
-
export declare const resolvePiTools: (node: ResolvedAgentNode) => string[];
|
|
8
|
-
export declare const resolvePiThinkingFormat: (node: ResolvedAgentNode) => (typeof PI_THINKING_FORMATS)[number] | undefined;
|
|
9
|
-
export declare const resolvePiRawTrainingCapture: (node: ResolvedAgentNode) => PiGeneratedAgent["raw_training_capture"] | undefined;
|
|
10
|
-
export declare const renderPiModelsConfig: (nodes: ResolvedAgentNode[]) => string;
|
|
11
|
-
export declare const createPiAgentConfig: (node: ResolvedAgentNode, slug: string, id: string, worldBinding?: SimfileWorldBindingV1) => PiGeneratedAgent;
|