@noopolis/daimon 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/contracts/attentionContract.d.ts +25 -0
- package/dist/contracts/attentionContract.d.ts.map +1 -1
- package/dist/contracts/attentionContract.js +8 -1
- package/dist/contracts/grokBrokerTaskClock.d.ts +18 -0
- package/dist/contracts/grokBrokerTaskClock.d.ts.map +1 -0
- package/dist/contracts/grokBrokerTaskClock.js +16 -0
- package/dist/contracts/organizationRuntimeContract.d.ts +76 -0
- package/dist/contracts/organizationRuntimeContract.d.ts.map +1 -1
- package/dist/contracts/organizationRuntimeContract.js +2 -0
- package/dist/contracts/runtimeContractManifest.d.ts +222 -15
- package/dist/contracts/runtimeContractManifest.d.ts.map +1 -1
- package/dist/contracts/runtimeContractManifest.js +35 -10
- package/dist/contracts/shellEnvironmentPolicy.d.ts +3 -0
- package/dist/contracts/shellEnvironmentPolicy.d.ts.map +1 -0
- package/dist/contracts/shellEnvironmentPolicy.js +5 -0
- package/dist/contracts/wakeMomentContract.d.ts +61 -0
- package/dist/contracts/wakeMomentContract.d.ts.map +1 -0
- package/dist/contracts/wakeMomentContract.js +27 -0
- package/dist/core/types.d.ts +2 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.d.ts +1 -0
- package/dist/examples/jungianPlayAgent.d.ts.map +1 -1
- package/dist/examples/jungianPlayAgent.js +6 -2
- package/dist/observability/causalEvents.d.ts +3 -3
- package/dist/observability/causalEvents.d.ts.map +1 -1
- package/dist/observability/causalEvents.js +4 -4
- package/dist/pi/cliEngineSpawn.d.ts +2 -2
- package/dist/pi/cliEngineSpawn.d.ts.map +1 -1
- package/dist/pi/cliEngineSpawn.js +7 -2
- package/dist/pi/cliEnvironment.d.ts.map +1 -1
- package/dist/pi/cliEnvironment.js +2 -0
- package/dist/pi/cliMcpRegistration.d.ts +1 -1
- package/dist/pi/cliMcpRegistration.d.ts.map +1 -1
- package/dist/pi/cliMcpRegistration.js +1 -1
- package/dist/pi/cliSession.d.ts +2 -0
- package/dist/pi/cliSession.d.ts.map +1 -1
- package/dist/pi/cliSession.js +3 -80
- package/dist/pi/cliSessionMcp.d.ts +9 -0
- package/dist/pi/cliSessionMcp.d.ts.map +1 -0
- package/dist/pi/cliSessionMcp.js +80 -0
- package/dist/pi/engineTaskClock.d.ts +9 -0
- package/dist/pi/engineTaskClock.d.ts.map +1 -0
- package/dist/pi/engineTaskClock.js +28 -0
- package/dist/pi/grokHomeMcpRegistration.d.ts.map +1 -1
- package/dist/pi/grokHomeMcpRegistration.js +2 -1
- package/dist/pi/grokSandbox.js +1 -1
- package/dist/pi/memoryClock.d.ts +25 -0
- package/dist/pi/memoryClock.d.ts.map +1 -0
- package/dist/pi/memoryClock.js +18 -0
- package/dist/pi/piAgentHandle.d.ts +3 -1
- package/dist/pi/piAgentHandle.d.ts.map +1 -1
- package/dist/pi/piAgentHandle.js +5 -2
- package/dist/pi/piHarness.d.ts +8 -2
- package/dist/pi/piHarness.d.ts.map +1 -1
- package/dist/pi/piHarness.js +28 -12
- package/dist/pi/taskClockProcess.d.ts +6 -0
- package/dist/pi/taskClockProcess.d.ts.map +1 -0
- package/dist/pi/taskClockProcess.js +8 -0
- package/dist/pi/turnCausal.d.ts +4 -2
- package/dist/pi/turnCausal.d.ts.map +1 -1
- package/dist/pi/turnCausal.js +4 -4
- package/dist/pi/wakeAcceptance.d.ts +1 -1
- package/dist/pi/wakeAcceptance.d.ts.map +1 -1
- package/dist/pi/wakeAcceptance.js +2 -2
- package/dist/runtime/agentSkillsDirectory.d.ts +25 -0
- package/dist/runtime/agentSkillsDirectory.d.ts.map +1 -0
- package/dist/runtime/agentSkillsDirectory.js +101 -0
- package/dist/runtime/agySubscriptionBootstrap.js +1 -1
- package/dist/runtime/agySubscriptionRealm.js +1 -1
- package/dist/runtime/attention.d.ts +5 -0
- package/dist/runtime/attention.d.ts.map +1 -1
- package/dist/runtime/attention.js +14 -1
- package/dist/runtime/attentionDispatcher.d.ts +14 -2
- package/dist/runtime/attentionDispatcher.d.ts.map +1 -1
- package/dist/runtime/attentionDispatcher.js +127 -33
- package/dist/runtime/cli.js +5 -0
- package/dist/runtime/contract-manifest.json +1 -1
- package/dist/runtime/contract-manifest.sha256 +1 -1
- package/dist/runtime/engineBrokerCapabilities.d.ts +10 -0
- package/dist/runtime/engineBrokerCapabilities.d.ts.map +1 -1
- package/dist/runtime/engineBrokerCapabilities.js +10 -0
- package/dist/runtime/engineBrokerControlClient.d.ts +12 -1
- package/dist/runtime/engineBrokerControlClient.d.ts.map +1 -1
- package/dist/runtime/engineBrokerControlClient.js +139 -43
- package/dist/runtime/engineBrokerCredentialJournal.d.ts +2 -0
- package/dist/runtime/engineBrokerCredentialJournal.d.ts.map +1 -1
- package/dist/runtime/engineBrokerCredentialJournal.js +9 -0
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts +3 -2
- package/dist/runtime/engineBrokerInferenceProtocol.d.ts.map +1 -1
- package/dist/runtime/engineBrokerInferenceProtocol.js +4 -4
- package/dist/runtime/engineBrokerMcpCallLog.d.ts +11 -0
- package/dist/runtime/engineBrokerMcpCallLog.d.ts.map +1 -1
- package/dist/runtime/engineBrokerMcpCallLog.js +13 -1
- package/dist/runtime/engineBrokerMcpFacade.d.ts +5 -2
- package/dist/runtime/engineBrokerMcpFacade.d.ts.map +1 -1
- package/dist/runtime/engineBrokerMcpFacade.js +5 -2
- package/dist/runtime/engineBrokerNativeClient.js +2 -2
- package/dist/runtime/engineBrokerProtocol.d.ts +42 -10
- package/dist/runtime/engineBrokerProtocol.d.ts.map +1 -1
- package/dist/runtime/engineBrokerProtocol.js +97 -14
- package/dist/runtime/engineBrokerSealLedger.d.ts.map +1 -1
- package/dist/runtime/engineBrokerSealLedger.js +9 -0
- package/dist/runtime/engineBrokerService.d.ts +8 -2
- package/dist/runtime/engineBrokerService.d.ts.map +1 -1
- package/dist/runtime/engineBrokerService.js +95 -37
- package/dist/runtime/engineBrokerServiceCli.js +1 -1
- package/dist/runtime/engineBrokerServiceConfig.d.ts +15 -2
- package/dist/runtime/engineBrokerServiceConfig.d.ts.map +1 -1
- package/dist/runtime/engineBrokerServiceConfig.js +53 -11
- package/dist/runtime/engineBrokerTurnRegistry.d.ts +1 -1
- package/dist/runtime/engineBrokerTurnRegistry.d.ts.map +1 -1
- package/dist/runtime/engineBrokerTurnRegistry.js +7 -6
- package/dist/runtime/engineDispatcher.d.ts +2 -0
- package/dist/runtime/engineDispatcher.d.ts.map +1 -1
- package/dist/runtime/engineDispatcher.js +14 -2
- package/dist/runtime/engineReadiness.js +1 -1
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts +1 -0
- package/dist/runtime/grokBrokerCredentialAuthority.d.ts.map +1 -1
- package/dist/runtime/grokBrokerCredentialAuthority.js +48 -22
- package/dist/runtime/grokBrokerCredentialReader.d.ts +1 -0
- package/dist/runtime/grokBrokerCredentialReader.d.ts.map +1 -1
- package/dist/runtime/grokBrokerCredentialReader.js +2 -1
- package/dist/runtime/grokBrokerProjection.d.ts +26 -2
- package/dist/runtime/grokBrokerProjection.d.ts.map +1 -1
- package/dist/runtime/grokBrokerProjection.js +18 -7
- package/dist/runtime/grokBrokerProviderClock.d.ts +26 -0
- package/dist/runtime/grokBrokerProviderClock.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProviderClock.js +133 -0
- package/dist/runtime/grokBrokerProxy.d.ts +17 -3
- package/dist/runtime/grokBrokerProxy.d.ts.map +1 -1
- package/dist/runtime/grokBrokerProxy.js +73 -9
- package/dist/runtime/grokBrokerProxyJson.d.ts +10 -0
- package/dist/runtime/grokBrokerProxyJson.d.ts.map +1 -0
- package/dist/runtime/grokBrokerProxyJson.js +31 -0
- package/dist/runtime/grokBrokerProxyRequest.d.ts.map +1 -1
- package/dist/runtime/grokBrokerProxyRequest.js +17 -6
- package/dist/runtime/grokBrokerRealmLease.js +1 -1
- package/dist/runtime/grokBrokerRefresh.js +1 -1
- package/dist/runtime/grokBrokerRunBudget.d.ts +20 -0
- package/dist/runtime/grokBrokerRunBudget.d.ts.map +1 -0
- package/dist/runtime/grokBrokerRunBudget.js +85 -0
- package/dist/runtime/grokBrokerSlot.d.ts +6 -0
- package/dist/runtime/grokBrokerSlot.d.ts.map +1 -0
- package/dist/runtime/grokBrokerSlot.js +21 -0
- package/dist/runtime/grokBrokerTaskClock.d.ts +32 -0
- package/dist/runtime/grokBrokerTaskClock.d.ts.map +1 -0
- package/dist/runtime/grokBrokerTaskClock.js +120 -0
- package/dist/runtime/grokBrokerTurnMeter.d.ts +55 -3
- package/dist/runtime/grokBrokerTurnMeter.d.ts.map +1 -1
- package/dist/runtime/grokBrokerTurnMeter.js +90 -4
- package/dist/runtime/grokBrokerWorkerConfig.d.ts +5 -2
- package/dist/runtime/grokBrokerWorkerConfig.d.ts.map +1 -1
- package/dist/runtime/grokBrokerWorkerConfig.js +22 -3
- package/dist/runtime/grokEngineBroker.d.ts +43 -3
- package/dist/runtime/grokEngineBroker.d.ts.map +1 -1
- package/dist/runtime/grokEngineBroker.js +159 -71
- package/dist/runtime/grokEngineBrokerTurn.d.ts +32 -8
- package/dist/runtime/grokEngineBrokerTurn.d.ts.map +1 -1
- package/dist/runtime/grokEngineBrokerTurn.js +204 -21
- package/dist/runtime/grokEngineBrokerTurnEnd.d.ts +88 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.d.ts.map +1 -0
- package/dist/runtime/grokEngineBrokerTurnEnd.js +148 -0
- package/dist/runtime/grokInferenceProxy.d.ts.map +1 -1
- package/dist/runtime/grokInferenceProxy.js +3 -0
- package/dist/runtime/grokSubscriptionRealm.js +1 -1
- package/dist/runtime/grokWorkerAttestation.d.ts +12 -5
- package/dist/runtime/grokWorkerAttestation.d.ts.map +1 -1
- package/dist/runtime/grokWorkerAttestation.js +5 -3
- package/dist/runtime/grokWorkerHomeAttestation.d.ts +51 -5
- package/dist/runtime/grokWorkerHomeAttestation.d.ts.map +1 -1
- package/dist/runtime/grokWorkerHomeAttestation.js +103 -8
- package/dist/runtime/grokWorkerSkills.d.ts +86 -0
- package/dist/runtime/grokWorkerSkills.d.ts.map +1 -0
- package/dist/runtime/grokWorkerSkills.js +135 -0
- package/dist/runtime/index.d.ts +10 -2
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +8 -1
- package/dist/runtime/native/daimon-engine-broker +0 -0
- package/dist/runtime/organizationRuntime.d.ts +3 -0
- package/dist/runtime/organizationRuntime.d.ts.map +1 -1
- package/dist/runtime/organizationRuntimeAdmission.d.ts +6 -0
- package/dist/runtime/organizationRuntimeAdmission.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeAdmission.js +22 -0
- package/dist/runtime/organizationRuntimeControl.d.ts +9 -0
- package/dist/runtime/organizationRuntimeControl.d.ts.map +1 -1
- package/dist/runtime/organizationRuntimeControl.js +72 -24
- package/dist/runtime/organizationRuntimeHost.d.ts.map +1 -1
- package/dist/runtime/organizationRuntimeHost.js +13 -4
- package/dist/runtime/organizationRuntimeParsing.d.ts.map +1 -1
- package/dist/runtime/organizationRuntimeParsing.js +4 -1
- package/dist/runtime/organizationRuntimeReadiness.d.ts.map +1 -1
- package/dist/runtime/organizationRuntimeReadiness.js +8 -0
- package/dist/runtime/organizationRuntimeRecording.d.ts +7 -0
- package/dist/runtime/organizationRuntimeRecording.d.ts.map +1 -0
- package/dist/runtime/organizationRuntimeRecording.js +58 -0
- package/dist/runtime/physicalReadiness.d.ts +12 -0
- package/dist/runtime/physicalReadiness.d.ts.map +1 -1
- package/dist/runtime/physicalReadiness.js +43 -9
- package/dist/runtime/productionAgentTools.d.ts.map +1 -1
- package/dist/runtime/productionAgentTools.js +13 -5
- package/dist/runtime/relocateRuntimeConfig.d.ts +14 -0
- package/dist/runtime/relocateRuntimeConfig.d.ts.map +1 -0
- package/dist/runtime/relocateRuntimeConfig.js +38 -0
- package/dist/runtime/schedule.d.ts.map +1 -1
- package/dist/runtime/schedule.js +12 -7
- package/dist/runtime/storeCoordination.d.ts +10 -0
- package/dist/runtime/storeCoordination.d.ts.map +1 -1
- package/dist/runtime/storeCoordination.js +23 -0
- package/dist/runtime/taskClock.d.ts +42 -0
- package/dist/runtime/taskClock.d.ts.map +1 -0
- package/dist/runtime/taskClock.js +102 -0
- package/dist/runtime/taskClockProcess.d.ts +17 -0
- package/dist/runtime/taskClockProcess.d.ts.map +1 -0
- package/dist/runtime/taskClockProcess.js +58 -0
- package/dist/runtime/turnRequestLedger.d.ts +0 -5
- package/dist/runtime/turnRequestLedger.d.ts.map +1 -1
- package/dist/runtime/turnRequestLedger.js +23 -21
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts +34 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceClaimDiagnostics.js +79 -0
- package/dist/runtime/wakeAcceptanceIndex.d.ts +55 -0
- package/dist/runtime/wakeAcceptanceIndex.d.ts.map +1 -0
- package/dist/runtime/wakeAcceptanceIndex.js +158 -0
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts +9 -1
- package/dist/runtime/wakeAcceptanceProcessIdentity.d.ts.map +1 -1
- package/dist/runtime/wakeAcceptanceProcessIdentity.js +5 -1
- package/dist/runtime/wakeAcceptanceRecord.d.ts +2 -0
- package/dist/runtime/wakeAcceptanceRecord.d.ts.map +1 -1
- package/dist/runtime/wakeAcceptanceRecord.js +4 -2
- package/dist/runtime/wakeAcceptanceRetention.d.ts +25 -1
- package/dist/runtime/wakeAcceptanceRetention.d.ts.map +1 -1
- package/dist/runtime/wakeAcceptanceRetention.js +28 -2
- package/dist/runtime/wakeAcceptanceStore.d.ts +8 -8
- package/dist/runtime/wakeAcceptanceStore.d.ts.map +1 -1
- package/dist/runtime/wakeAcceptanceStore.js +66 -63
- package/dist/runtime/wakeFuse.d.ts +58 -3
- package/dist/runtime/wakeFuse.d.ts.map +1 -1
- package/dist/runtime/wakeFuse.js +106 -7
- package/dist/runtime/wakeMomentFs.d.ts +27 -0
- package/dist/runtime/wakeMomentFs.d.ts.map +1 -0
- package/dist/runtime/wakeMomentFs.js +223 -0
- package/dist/runtime/wakeMomentHistory.d.ts +26 -0
- package/dist/runtime/wakeMomentHistory.d.ts.map +1 -0
- package/dist/runtime/wakeMomentHistory.js +109 -0
- package/dist/runtime/wakeMomentIo.d.ts +22 -0
- package/dist/runtime/wakeMomentIo.d.ts.map +1 -0
- package/dist/runtime/wakeMomentIo.js +114 -0
- package/dist/runtime/wakeMomentRecorder.d.ts +33 -0
- package/dist/runtime/wakeMomentRecorder.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRecorder.js +81 -0
- package/dist/runtime/wakeMomentRetention.d.ts +7 -0
- package/dist/runtime/wakeMomentRetention.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRetention.js +143 -0
- package/dist/runtime/wakeMomentRows.d.ts +8 -0
- package/dist/runtime/wakeMomentRows.d.ts.map +1 -0
- package/dist/runtime/wakeMomentRows.js +66 -0
- package/dist/runtime/wakeMomentSnapshot.d.ts +56 -0
- package/dist/runtime/wakeMomentSnapshot.d.ts.map +1 -0
- package/dist/runtime/wakeMomentSnapshot.js +248 -0
- package/package.json +4 -4
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { createServer } from "node:http";
|
|
3
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
|
+
import { createPiToolMcpServer } from "../mcp/toolServer.js";
|
|
5
|
+
export const startMcp = async (tools, maxToolTurns, wakeDeadline, onToolsMounted, onStarted) => {
|
|
6
|
+
onToolsMounted?.(tools);
|
|
7
|
+
const mcpServer = createPiToolMcpServer(tools, { maxToolTurns, wakeDeadline });
|
|
8
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID() });
|
|
9
|
+
const httpServer = createServer((request, response) => {
|
|
10
|
+
void transport.handleRequest(request, response);
|
|
11
|
+
});
|
|
12
|
+
let lifecycle = "starting";
|
|
13
|
+
let cancelled = false;
|
|
14
|
+
let endpoint = "";
|
|
15
|
+
let closePromise;
|
|
16
|
+
let settleStartup;
|
|
17
|
+
const startupSettled = new Promise((resolve) => { settleStartup = resolve; });
|
|
18
|
+
const close = () => closePromise ??= (async () => {
|
|
19
|
+
cancelled = true;
|
|
20
|
+
if (lifecycle !== "closed")
|
|
21
|
+
lifecycle = "closing";
|
|
22
|
+
// `listen()` begins synchronously but its callback is pending. Waiting for
|
|
23
|
+
// startup prevents dispose from returning while that callback can still bind.
|
|
24
|
+
await startupSettled;
|
|
25
|
+
await transport.close().catch(() => undefined);
|
|
26
|
+
await mcpServer.close().catch(() => undefined);
|
|
27
|
+
// `close` only stops accepting and then waits for every open connection,
|
|
28
|
+
// including the ones the transport has no record of and so cannot end (a
|
|
29
|
+
// socket opened before `initialize`, or a client pool's idle keep-alive
|
|
30
|
+
// socket, which relaying a turn through the broker MCP facade leaves
|
|
31
|
+
// behind). That wait is unbounded and sits on the wake's own completion
|
|
32
|
+
// path: measured, one such connection parked a finished broker turn with
|
|
33
|
+
// its result in hand and published nothing. By here this one wake's engine
|
|
34
|
+
// has returned, failed or been cancelled, so anything still connected is a
|
|
35
|
+
// leftover — see `AGENTS.md`, and the facade, which bounds itself the same
|
|
36
|
+
// way.
|
|
37
|
+
if (httpServer.listening)
|
|
38
|
+
await new Promise((resolve) => { httpServer.close(() => resolve()); httpServer.closeAllConnections(); });
|
|
39
|
+
lifecycle = "closed";
|
|
40
|
+
})();
|
|
41
|
+
const mount = { get endpoint() { return endpoint; }, close };
|
|
42
|
+
onStarted(mount);
|
|
43
|
+
let startupError;
|
|
44
|
+
try {
|
|
45
|
+
if (cancelled)
|
|
46
|
+
throw new Error("MCP startup was cancelled");
|
|
47
|
+
await mcpServer.connect(transport);
|
|
48
|
+
if (cancelled)
|
|
49
|
+
throw new Error("MCP startup was cancelled");
|
|
50
|
+
await new Promise((resolve, reject) => {
|
|
51
|
+
const onError = (error) => reject(error);
|
|
52
|
+
httpServer.once("error", onError);
|
|
53
|
+
httpServer.listen(0, "127.0.0.1", () => {
|
|
54
|
+
httpServer.off("error", onError);
|
|
55
|
+
// A disposer can run from a Server.prototype.listen interceptor before
|
|
56
|
+
// this callback. Never publish the server as live in that interleaving.
|
|
57
|
+
if (!cancelled)
|
|
58
|
+
lifecycle = "listening";
|
|
59
|
+
resolve();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
if (cancelled)
|
|
63
|
+
throw new Error("MCP startup was cancelled");
|
|
64
|
+
const address = httpServer.address();
|
|
65
|
+
if (address === null || typeof address === "string") {
|
|
66
|
+
throw new Error("MCP server did not receive an ephemeral port");
|
|
67
|
+
}
|
|
68
|
+
endpoint = `http://127.0.0.1:${address.port}/mcp`;
|
|
69
|
+
return mount;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
startupError = error;
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
settleStartup();
|
|
77
|
+
if (cancelled || startupError !== undefined)
|
|
78
|
+
await close();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Explicit set is scoped by the engines to shell/tool children, never provider traffic.
|
|
2
|
+
* Pin an empty allowlist so ambient include filters cannot discard the clock values.
|
|
3
|
+
* Sources/versions and the broker contract and AGY gap are recorded in docs/runtime.md.
|
|
4
|
+
*/
|
|
5
|
+
export declare function codexTaskClockArgs(): string[];
|
|
6
|
+
export declare function grokTaskClockConfig(): string;
|
|
7
|
+
/** Operational diagnostic only. Brokered Grok reports from its attested per-turn boundary. */
|
|
8
|
+
export declare function reportEngineTaskClockGap(engine: "codex" | "grok" | "agy"): void;
|
|
9
|
+
//# sourceMappingURL=engineTaskClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineTaskClock.d.ts","sourceRoot":"","sources":["../../src/pi/engineTaskClock.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAI7C;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAG5C;AAMD,8FAA8F;AAC9F,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAK/E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readTaskClock, taskClockChildEnvironment } from "../runtime/taskClock.js";
|
|
2
|
+
import { shellEnvironmentPolicyEntries } from "../contracts/shellEnvironmentPolicy.js";
|
|
3
|
+
/** Explicit set is scoped by the engines to shell/tool children, never provider traffic.
|
|
4
|
+
* Pin an empty allowlist so ambient include filters cannot discard the clock values.
|
|
5
|
+
* Sources/versions and the broker contract and AGY gap are recorded in docs/runtime.md.
|
|
6
|
+
*/
|
|
7
|
+
export function codexTaskClockArgs() {
|
|
8
|
+
const env = taskClockChildEnvironment();
|
|
9
|
+
if (Object.keys(env).length === 0)
|
|
10
|
+
return [];
|
|
11
|
+
return ["-c", `shell_environment_policy=${shellPolicy(env)}`];
|
|
12
|
+
}
|
|
13
|
+
export function grokTaskClockConfig() {
|
|
14
|
+
const env = taskClockChildEnvironment();
|
|
15
|
+
return Object.keys(env).length === 0 ? "" : `shell_environment_policy = ${shellPolicy(env)}\n`;
|
|
16
|
+
}
|
|
17
|
+
function shellPolicy(env) {
|
|
18
|
+
return `{${shellEnvironmentPolicyEntries(env).join(",")}}`;
|
|
19
|
+
}
|
|
20
|
+
/** Operational diagnostic only. Brokered Grok reports from its attested per-turn boundary. */
|
|
21
|
+
export function reportEngineTaskClockGap(engine) {
|
|
22
|
+
if (readTaskClock() === undefined)
|
|
23
|
+
return;
|
|
24
|
+
const gap = engine === "agy" ? "no supported tool-only environment setting"
|
|
25
|
+
: undefined; // Brokered Grok reports after config attestation, from its per-turn processClock field.
|
|
26
|
+
if (gap)
|
|
27
|
+
console.warn(`daimon: task clock coverage gap engine=${engine}: ${gap}; native tools remain on real time; wake allowed`);
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grokHomeMcpRegistration.d.ts","sourceRoot":"","sources":["../../src/pi/grokHomeMcpRegistration.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"grokHomeMcpRegistration.d.ts","sourceRoot":"","sources":["../../src/pi/grokHomeMcpRegistration.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAE,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAepL"}
|
|
@@ -3,6 +3,7 @@ import { constants } from "node:fs";
|
|
|
3
3
|
import { lstat, mkdir, open, rename, unlink } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { renderGrokLeanBaseConfig } from "../runtime/grokBrokerWorkerConfig.js";
|
|
6
|
+
import { grokTaskClockConfig } from "./engineTaskClock.js";
|
|
6
7
|
/**
|
|
7
8
|
* Per-wake MCP registration for the direct (non-broker) Grok CLI path.
|
|
8
9
|
*
|
|
@@ -25,7 +26,7 @@ export async function registerGrokHomeMcpServer(input) {
|
|
|
25
26
|
if (!/^http:\/\/127\.0\.0\.1:\d{1,5}\/[A-Za-z0-9/_-]*$/u.test(input.endpoint))
|
|
26
27
|
throw new Error("Grok MCP endpoint must be a loopback http URL");
|
|
27
28
|
await input.verify?.();
|
|
28
|
-
await writeConfig(home, `${renderGrokLeanBaseConfig()}[mcp_servers.daimon]\nurl = ${JSON.stringify(input.endpoint)}\n`);
|
|
29
|
+
await writeConfig(home, `${grokTaskClockConfig()}${renderGrokLeanBaseConfig()}[mcp_servers.daimon]\nurl = ${JSON.stringify(input.endpoint)}\n`);
|
|
29
30
|
let closePromise;
|
|
30
31
|
return {
|
|
31
32
|
close: () => closePromise ??= (async () => {
|
package/dist/pi/grokSandbox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { spawn } from "
|
|
2
|
+
import { spawnRealTime as spawn } from "../runtime/taskClockProcess.js";
|
|
3
3
|
import { constants } from "node:fs";
|
|
4
4
|
import { lstat, mkdir, open, realpath, rename, unlink } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as mneme from "@noopolis/mneme";
|
|
2
|
+
import { type TaskClock } from "../runtime/taskClock.js";
|
|
3
|
+
type MnemeClockModule = {
|
|
4
|
+
readonly createOffsetClock?: unknown;
|
|
5
|
+
};
|
|
6
|
+
type MemoryConfig = Parameters<typeof mneme.createMemoryRuntime>[0];
|
|
7
|
+
type MemoryModule = MnemeClockModule & {
|
|
8
|
+
createMemoryRuntime(config: MemoryConfig & {
|
|
9
|
+
clock?: () => number;
|
|
10
|
+
}): ReturnType<typeof mneme.createMemoryRuntime>;
|
|
11
|
+
};
|
|
12
|
+
/** Keep construction and capability detection together while the published types catch up. */
|
|
13
|
+
export declare function createClockedMemoryRuntime(config: MemoryConfig, clock?: Readonly<{
|
|
14
|
+
raw: string;
|
|
15
|
+
origin: string;
|
|
16
|
+
anchorEpochMs: number;
|
|
17
|
+
at(realEpochMs: number): number;
|
|
18
|
+
now(): number;
|
|
19
|
+
}> | undefined, moduleRoot?: MemoryModule): mneme.MemoryRuntime;
|
|
20
|
+
/** The root export is Mneme's capability signal, including across older published versions. */
|
|
21
|
+
export declare function memoryClockOptions(clock?: TaskClock | undefined, moduleRoot?: MnemeClockModule): {
|
|
22
|
+
clock?: () => number;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=memoryClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoryClock.d.ts","sourceRoot":"","sources":["../../src/pi/memoryClock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAExE,KAAK,gBAAgB,GAAG;IAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjE,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,KAAK,YAAY,GAAG,gBAAgB,GAAG;IAAE,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,MAAM,CAAA;KAAE,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,mBAAmB,CAAC,CAAA;CAAE,CAAC;AAE9J,8FAA8F;AAC9F,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK;;;;;;cAAkB,EAAE,UAAU,GAAE,YAAoB,uBAEzH;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAChC,KAAK,GAAE,SAAS,GAAG,SAA2B,EAC9C,UAAU,GAAE,gBAA4C,GACvD;IAAE,KAAK,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,CAQ1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as mneme from "@noopolis/mneme";
|
|
2
|
+
import { readTaskClock } from "../runtime/taskClock.js";
|
|
3
|
+
/** Keep construction and capability detection together while the published types catch up. */
|
|
4
|
+
export function createClockedMemoryRuntime(config, clock = readTaskClock(), moduleRoot = mneme) {
|
|
5
|
+
return moduleRoot.createMemoryRuntime({ ...config, ...memoryClockOptions(clock, moduleRoot) });
|
|
6
|
+
}
|
|
7
|
+
/** The root export is Mneme's capability signal, including across older published versions. */
|
|
8
|
+
export function memoryClockOptions(clock = readTaskClock(), moduleRoot = mneme) {
|
|
9
|
+
if (clock === undefined)
|
|
10
|
+
return {};
|
|
11
|
+
if (typeof moduleRoot.createOffsetClock !== "function") {
|
|
12
|
+
throw new Error("NOOPOLIS_TASK_CLOCK requires @noopolis/mneme with the root createOffsetClock export and createMemoryRuntime({ clock }) support");
|
|
13
|
+
}
|
|
14
|
+
const memoryClock = moduleRoot.createOffsetClock({ origin: clock.origin, anchorMs: clock.anchorEpochMs });
|
|
15
|
+
if (typeof memoryClock !== "function")
|
|
16
|
+
throw new Error("@noopolis/mneme createOffsetClock must return an epoch-ms clock function");
|
|
17
|
+
return { clock: memoryClock };
|
|
18
|
+
}
|
|
@@ -6,7 +6,7 @@ import { persistPiTurnTrace, type PiTurnTraceModel } from "./turnTrace.js";
|
|
|
6
6
|
import { type PiRawTrainingCaptureOptions, type PiRawTrainingCaptureRef } from "./rawTrainingCapture.js";
|
|
7
7
|
import { type PiWorldToolContextRef } from "./worldNudge.js";
|
|
8
8
|
import { type PiWorldTrajectoryIdentity } from "./worldTrajectory.js";
|
|
9
|
-
import {
|
|
9
|
+
import type { PiNativeSessionCreator, PiSession, PiSessionCreator, PiSessionLike, PiWakeEnvironmentContextRef } from "./piAgentWakeSupport.js";
|
|
10
10
|
import { type MemoryRuntime } from "@noopolis/mneme";
|
|
11
11
|
export type { PiSession, PiSessionLike, PiSessionCreator, PiNativeSessionCreator } from "./piAgentWakeSupport.js";
|
|
12
12
|
export type WakeAcceptanceInput = {
|
|
@@ -14,6 +14,7 @@ export type WakeAcceptanceInput = {
|
|
|
14
14
|
completeTurn?: typeof stampTurnOutputCompleted;
|
|
15
15
|
traceTurn?: typeof persistPiTurnTrace;
|
|
16
16
|
createWakeAcceptance?: (runtimeHomePath: string, agentId: string) => WakeAcceptanceStoreLike;
|
|
17
|
+
causalRunId?: string;
|
|
17
18
|
};
|
|
18
19
|
export declare class PiAgentHandle implements AgentHandle {
|
|
19
20
|
readonly id: string;
|
|
@@ -36,6 +37,7 @@ export declare class PiAgentHandle implements AgentHandle {
|
|
|
36
37
|
private readonly stampTurnInputSubmitted;
|
|
37
38
|
private readonly stampTurnOutputCompleted;
|
|
38
39
|
private readonly persistTrace;
|
|
40
|
+
private readonly causalRunId?;
|
|
39
41
|
constructor(id: string, session: PiSession, createSession: PiNativeSessionCreator, runtimeHomePath: string, traceModel: PiTurnTraceModel, memory?: MemoryRuntime, memoryToolContext?: PiMemoryToolContextRef, dependencies?: WakeAcceptanceInput, worldToolContext?: PiWorldToolContextRef, rawTrainingCaptureRef?: PiRawTrainingCaptureRef, rawTrainingCaptureOptions?: PiRawTrainingCaptureOptions, worldTrajectoryIdentity?: PiWorldTrajectoryIdentity, rawTrainingCaptureSession?: PiSession, wakeEnvironmentContext?: PiWakeEnvironmentContextRef);
|
|
40
42
|
constructor(id: string, session: PiSessionLike, createSession: PiSessionCreator, runtimeHomePath: string, traceModel: PiTurnTraceModel, memory?: MemoryRuntime, memoryToolContext?: PiMemoryToolContextRef, dependencies?: WakeAcceptanceInput, worldToolContext?: PiWorldToolContextRef, rawTrainingCaptureRef?: never, rawTrainingCaptureOptions?: never, worldTrajectoryIdentity?: PiWorldTrajectoryIdentity, rawTrainingCaptureSession?: never, wakeEnvironmentContext?: PiWakeEnvironmentContextRef);
|
|
41
43
|
wake(event: WakeEvent): Promise<WakeResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piAgentHandle.d.ts","sourceRoot":"","sources":["../../src/pi/piAgentHandle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAoC,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,EAC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
32
32
|
persistTrace;
|
|
33
|
+
causalRunId;
|
|
33
34
|
constructor(id, session, createSession, runtimeHomePath, traceModel, memory, memoryToolContext, dependencies = {}, worldToolContext, rawTrainingCaptureRef, rawTrainingCaptureOptions, worldTrajectoryIdentity, piSessionForRawCapture, wakeEnvironmentContext) {
|
|
34
35
|
this.id = id;
|
|
35
36
|
this.session = session;
|
|
@@ -47,8 +48,8 @@ export class PiAgentHandle {
|
|
|
47
48
|
this.stampTurnInputSubmitted = dependencies.runWake ?? stampTurnInputSubmitted;
|
|
48
49
|
this.stampTurnOutputCompleted = dependencies.completeTurn ?? stampTurnOutputCompleted;
|
|
49
50
|
this.persistTrace = dependencies.traceTurn ?? persistPiTurnTrace;
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
this.causalRunId = dependencies.causalRunId;
|
|
52
|
+
const wakeAcceptance = dependencies.createWakeAcceptance?.(runtimeHomePath, id) ?? new WakeAcceptanceStore(runtimeHomePath, id, undefined, this.causalRunId);
|
|
52
53
|
this.wakeDeliveryQueue = new PiWakeDeliveryQueue(id, wakeAcceptance);
|
|
53
54
|
}
|
|
54
55
|
async wake(event) {
|
|
@@ -163,6 +164,7 @@ export class PiAgentHandle {
|
|
|
163
164
|
}
|
|
164
165
|
stage = "causal_input";
|
|
165
166
|
const turnInput = await this.stampTurnInputSubmitted({
|
|
167
|
+
runId: this.causalRunId,
|
|
166
168
|
agentId: this.id,
|
|
167
169
|
event,
|
|
168
170
|
prepared,
|
|
@@ -182,6 +184,7 @@ export class PiAgentHandle {
|
|
|
182
184
|
const outputText = chunks.join("\n").trim();
|
|
183
185
|
stage = "causal_output";
|
|
184
186
|
await this.stampTurnOutputCompleted({
|
|
187
|
+
runId: this.causalRunId,
|
|
185
188
|
agentId: this.id,
|
|
186
189
|
causeEventId: turnInput.event_id,
|
|
187
190
|
outputText,
|
package/dist/pi/piHarness.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createAgentSession, type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
2
|
+
import type { MemoryAuthorityConfig } from "@noopolis/mneme";
|
|
3
3
|
import type { AgentHandle, AgentHarnessAdapter, AgentStartInput, HarnessModelSpec } from "../core/types.js";
|
|
4
4
|
import { type PiSessionLike } from "./piAgentHandle.js";
|
|
5
5
|
import { type PiWakeEnvironmentContextRef } from "./piAgentWakeSupport.js";
|
|
6
6
|
import { type PiWorldBinding } from "./worldTools.js";
|
|
7
|
+
import { type TaskClockProcessProbe } from "./taskClockProcess.js";
|
|
7
8
|
import { type PiRawTrainingCaptureOptions } from "./rawTrainingCapture.js";
|
|
8
9
|
type HarnessMemoryEmbeddingProvider = {
|
|
9
10
|
dimensions?: number;
|
|
@@ -52,10 +53,15 @@ export type PiSessionFactory = (input: PiSessionFactoryInput) => Promise<{
|
|
|
52
53
|
}>;
|
|
53
54
|
export declare class PiHarnessAdapter implements AgentHarnessAdapter {
|
|
54
55
|
private readonly options;
|
|
56
|
+
private readonly taskClockProbe?;
|
|
57
|
+
static readonly capabilities: Readonly<{
|
|
58
|
+
causalRunId: true;
|
|
59
|
+
memoryCausalRunId: false;
|
|
60
|
+
}>;
|
|
55
61
|
private readonly authStorage;
|
|
56
62
|
private readonly modelRegistry;
|
|
57
63
|
private readonly sessionFactory;
|
|
58
|
-
constructor(options: PiHarnessOptions);
|
|
64
|
+
constructor(options: PiHarnessOptions, /** @internal */ taskClockProbe?: TaskClockProcessProbe | undefined);
|
|
59
65
|
startAgent(input: AgentStartInput): Promise<AgentHandle>;
|
|
60
66
|
}
|
|
61
67
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piHarness.d.ts","sourceRoot":"","sources":["../../src/pi/piHarness.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,kBAAkB,EAIlB,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAuB,
|
|
1
|
+
{"version":3,"file":"piHarness.d.ts","sourceRoot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AAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmB;gBAErB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,CAAkB,cAAc,CAAC,EAAE,qBAAqB,YAAA;IAM1H,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA0K/D"}
|
package/dist/pi/piHarness.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AuthStorage, createBashTool, createAgentSession, SessionManager, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveRunId } from "../observability/causalEvents.js";
|
|
5
5
|
import { resolvePiHarnessModel } from "./modelConfig.js";
|
|
6
6
|
import { createPiModelRegistry } from "./modelRegistry.js";
|
|
7
7
|
import { createPiMemoryTools, piMemoryToolNames } from "./memoryTools.js";
|
|
@@ -10,20 +10,35 @@ import { PiAgentHandle } from "./piAgentHandle.js";
|
|
|
10
10
|
import { DAIMON_WAKE_ID_ENV } from "./cliEnvironment.js";
|
|
11
11
|
import { createPiWorldTools, piWorldToolNames } from "./worldTools.js";
|
|
12
12
|
import { ensureRuntimeHome, ensureRuntimeHomeDirectory } from "../runtime/runtimeHomeLayout.js";
|
|
13
|
+
import { readyTaskClockEnvironment } from "../runtime/taskClockProcess.js";
|
|
14
|
+
import { readTaskClock, taskClockChildEnvironment, taskClockProcessEnvironment } from "../runtime/taskClock.js";
|
|
15
|
+
import { createClockedMemoryRuntime, memoryClockOptions } from "./memoryClock.js";
|
|
16
|
+
import { verifyTaskClockProcess } from "./taskClockProcess.js";
|
|
13
17
|
import { bindPiRawTrainingCapture, validatePiRawTrainingCaptureOptions } from "./rawTrainingCapture.js";
|
|
14
18
|
export class PiHarnessAdapter {
|
|
15
19
|
options;
|
|
20
|
+
taskClockProbe;
|
|
21
|
+
static capabilities = Object.freeze({ causalRunId: true, memoryCausalRunId: false });
|
|
16
22
|
authStorage;
|
|
17
23
|
modelRegistry;
|
|
18
24
|
sessionFactory;
|
|
19
|
-
constructor(options) {
|
|
25
|
+
constructor(options, /** @internal */ taskClockProbe) {
|
|
20
26
|
this.options = options;
|
|
27
|
+
this.taskClockProbe = taskClockProbe;
|
|
21
28
|
this.authStorage = AuthStorage.create(options.authPath);
|
|
22
29
|
this.modelRegistry = createPiModelRegistry(this.authStorage, options);
|
|
23
30
|
this.sessionFactory = options.sessionFactory ?? createAgentSession;
|
|
24
31
|
}
|
|
25
32
|
async startAgent(input) {
|
|
33
|
+
const taskClock = readTaskClock();
|
|
34
|
+
if (this.options.memory !== undefined)
|
|
35
|
+
memoryClockOptions(taskClock);
|
|
36
|
+
if (input.causalRunId !== undefined && this.options.memory !== undefined) {
|
|
37
|
+
throw new Error("Per-agent causalRunId requires a memory runtime with explicit causal context; configured memory is currently unsupported");
|
|
38
|
+
}
|
|
39
|
+
const causalRunId = input.causalRunId === undefined ? undefined : resolveRunId(undefined, input.causalRunId);
|
|
26
40
|
validatePiRawTrainingCaptureOptions(this.options.rawTrainingCapture);
|
|
41
|
+
await verifyTaskClockProcess(input.runtimeHomePath, taskClock, this.taskClockProbe);
|
|
27
42
|
await ensureRuntimeHome(input.runtimeHomePath);
|
|
28
43
|
await Promise.all([".config", ".local/share", ".local/state", ".cache", ".tmp", "tool-state"]
|
|
29
44
|
.map((relative) => ensureRuntimeHomeDirectory(input.runtimeHomePath, relative)));
|
|
@@ -42,14 +57,14 @@ export class PiHarnessAdapter {
|
|
|
42
57
|
}
|
|
43
58
|
const memory = this.options.memory === undefined
|
|
44
59
|
? undefined
|
|
45
|
-
:
|
|
60
|
+
: createClockedMemoryRuntime({
|
|
46
61
|
agentId: input.id,
|
|
47
62
|
authority: this.options.memory.authority,
|
|
48
63
|
embeddingProvider: this.options.memory.embeddingProvider,
|
|
49
64
|
runtimeHomePath: memoryRuntimeHomePath,
|
|
50
65
|
source: this.options.memory.source,
|
|
51
66
|
tokenBudget: this.options.memory.tokenBudget
|
|
52
|
-
});
|
|
67
|
+
}, taskClock);
|
|
53
68
|
const memoryToolContext = memory === undefined ? undefined : {};
|
|
54
69
|
const worldToolContext = this.options.world === undefined ? undefined : {};
|
|
55
70
|
const rawTrainingCaptureRef = this.options.rawTrainingCapture === undefined ? undefined : {};
|
|
@@ -80,9 +95,9 @@ export class PiHarnessAdapter {
|
|
|
80
95
|
...(this.options.world === undefined ? [] : [this.options.world.tokenEnv])
|
|
81
96
|
])];
|
|
82
97
|
const requestedTools = this.options.toolNames ?? input.tools;
|
|
83
|
-
const protectedBash = protectedNames.length === 0 || requestedTools?.includes("bash") === false
|
|
98
|
+
const protectedBash = (protectedNames.length === 0 && taskClock === undefined) || requestedTools?.includes("bash") === false
|
|
84
99
|
? []
|
|
85
|
-
: [createProtectedBashTool(input.workspacePath, input.runtimeHomePath, protectedNames, wakeEnvironmentContext)];
|
|
100
|
+
: [createProtectedBashTool(input.workspacePath, input.runtimeHomePath, protectedNames, wakeEnvironmentContext, taskClockChildEnvironment({}, taskClock))];
|
|
86
101
|
const toolNames = [
|
|
87
102
|
...(requestedTools ?? ["read", "write", "edit", "bash", "grep", "find", "ls"]),
|
|
88
103
|
...piMemoryToolNames(memoryTools),
|
|
@@ -126,7 +141,7 @@ export class PiHarnessAdapter {
|
|
|
126
141
|
authMethod: modelSpec.auth?.method ?? "none",
|
|
127
142
|
model: resolvedModel.name,
|
|
128
143
|
provider: resolvedModel.provider
|
|
129
|
-
}, memory, memoryToolContext, {}, worldToolContext, rawTrainingCaptureRef, this.options.rawTrainingCapture, worldToolContext === undefined
|
|
144
|
+
}, memory, memoryToolContext, { causalRunId }, worldToolContext, rawTrainingCaptureRef, this.options.rawTrainingCapture, worldToolContext === undefined
|
|
130
145
|
? undefined
|
|
131
146
|
: { instructions: input.instructions, thinkingLevel: this.options.thinkingLevel ?? "off" }, session, wakeEnvironmentContext);
|
|
132
147
|
}
|
|
@@ -139,7 +154,7 @@ export class PiHarnessAdapter {
|
|
|
139
154
|
authMethod: modelSpec.auth?.method ?? "none",
|
|
140
155
|
model: resolvedModel.name,
|
|
141
156
|
provider: resolvedModel.provider
|
|
142
|
-
}, memory, memoryToolContext, {}, worldToolContext, undefined, undefined, worldToolContext === undefined
|
|
157
|
+
}, memory, memoryToolContext, { causalRunId }, worldToolContext, undefined, undefined, worldToolContext === undefined
|
|
143
158
|
? undefined
|
|
144
159
|
: {
|
|
145
160
|
instructions: input.instructions,
|
|
@@ -147,22 +162,23 @@ export class PiHarnessAdapter {
|
|
|
147
162
|
}, undefined, wakeEnvironmentContext);
|
|
148
163
|
}
|
|
149
164
|
}
|
|
150
|
-
function createProtectedBashTool(workspacePath, runtimeHomePath, protectedNames, wakeEnvironmentContext) {
|
|
165
|
+
function createProtectedBashTool(workspacePath, runtimeHomePath, protectedNames, wakeEnvironmentContext, clockEnvironment) {
|
|
151
166
|
const bash = createBashTool(workspacePath, {
|
|
152
167
|
spawnHook: (context) => ({
|
|
153
168
|
...context,
|
|
154
|
-
env: {
|
|
155
|
-
...Object.fromEntries(Object.entries(context.env).filter(([name]) => !protectedNames.includes(name))),
|
|
169
|
+
env: readyTaskClockEnvironment({
|
|
170
|
+
...Object.fromEntries(Object.entries(taskClockProcessEnvironment(context.env, clockEnvironment)).filter(([name]) => !protectedNames.includes(name))),
|
|
156
171
|
HOME: runtimeHomePath,
|
|
157
172
|
XDG_CONFIG_HOME: `${runtimeHomePath}/.config`,
|
|
158
173
|
XDG_DATA_HOME: `${runtimeHomePath}/.local/share`,
|
|
159
174
|
XDG_STATE_HOME: `${runtimeHomePath}/.local/state`,
|
|
160
175
|
XDG_CACHE_HOME: `${runtimeHomePath}/.cache`,
|
|
161
176
|
TMPDIR: `${runtimeHomePath}/.tmp`,
|
|
177
|
+
...clockEnvironment,
|
|
162
178
|
...(wakeEnvironmentContext.current === undefined
|
|
163
179
|
? {}
|
|
164
180
|
: { [DAIMON_WAKE_ID_ENV]: wakeEnvironmentContext.current })
|
|
165
|
-
}
|
|
181
|
+
})
|
|
166
182
|
})
|
|
167
183
|
});
|
|
168
184
|
return {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type TaskClock } from "../runtime/taskClock.js";
|
|
2
|
+
import { type TaskClockProcessProbe } from "../runtime/taskClockProcess.js";
|
|
3
|
+
export type { TaskClockProcessProbe } from "../runtime/taskClockProcess.js";
|
|
4
|
+
/** Eager Pi readiness uses the same gate as every later child launch. */
|
|
5
|
+
export declare function verifyTaskClockProcess(runtimeHomePath: string, clock?: TaskClock | undefined, probe?: TaskClockProcessProbe): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=taskClockProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskClockProcess.d.ts","sourceRoot":"","sources":["../../src/pi/taskClockProcess.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvG,YAAY,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,yEAAyE;AACzE,wBAAsB,sBAAsB,CAC1C,eAAe,EAAE,MAAM,EAAE,KAAK,GAAE,SAAS,GAAG,SAA2B,EAAE,KAAK,CAAC,EAAE,qBAAqB,GACrG,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { cliChildEnvironment } from "./cliEnvironment.js";
|
|
2
|
+
import { readTaskClock } from "../runtime/taskClock.js";
|
|
3
|
+
import { readyTaskClockEnvironment } from "../runtime/taskClockProcess.js";
|
|
4
|
+
/** Eager Pi readiness uses the same gate as every later child launch. */
|
|
5
|
+
export async function verifyTaskClockProcess(runtimeHomePath, clock = readTaskClock(), probe) {
|
|
6
|
+
if (clock !== undefined)
|
|
7
|
+
readyTaskClockEnvironment(cliChildEnvironment([], runtimeHomePath), clock, probe);
|
|
8
|
+
}
|
package/dist/pi/turnCausal.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface StampTurnInputSubmittedInput {
|
|
|
15
15
|
prepared?: MemoryPrepareTurnResult;
|
|
16
16
|
promptText: string;
|
|
17
17
|
runtimeHomePath: string;
|
|
18
|
+
runId?: string;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Stamps `turn.input.submitted` for one Pi turn, wiring piHarness's own
|
|
@@ -51,8 +52,8 @@ export interface StampTurnInputSubmittedInput {
|
|
|
51
52
|
* the actual `event_id`s of the `memory.recalled` events it appended for
|
|
52
53
|
* this turn, so this cause link is id-joined the same way the moltnet
|
|
53
54
|
* link above is.
|
|
54
|
-
* - `run_id`
|
|
55
|
-
* from `event` or model output.
|
|
55
|
+
* - `run_id` comes from trusted per-instance host context, with the historical
|
|
56
|
+
* environment fallback. Never from `event` or model output.
|
|
56
57
|
*/
|
|
57
58
|
export declare const stampTurnInputSubmitted: (input: StampTurnInputSubmittedInput) => Promise<CausalEvent<TurnInputSubmittedPayload>>;
|
|
58
59
|
export interface StampTurnOutputCompletedInput {
|
|
@@ -61,6 +62,7 @@ export interface StampTurnOutputCompletedInput {
|
|
|
61
62
|
outputText: string;
|
|
62
63
|
runtimeHomePath: string;
|
|
63
64
|
turnId: string;
|
|
65
|
+
runId?: string;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* Stamps `turn.output.completed` once a Pi turn finishes successfully,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnCausal.d.ts","sourceRoot":"","sources":["../../src/pi/turnCausal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAKL,KAAK,WAAW,EACh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B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,6BAA6B,KACnC,OAAO,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAS9C,CAAC"}
|
package/dist/pi/turnCausal.js
CHANGED
|
@@ -43,8 +43,8 @@ export const agentPrincipalId = (agentId) => `agent:${agentId}`;
|
|
|
43
43
|
* the actual `event_id`s of the `memory.recalled` events it appended for
|
|
44
44
|
* this turn, so this cause link is id-joined the same way the moltnet
|
|
45
45
|
* link above is.
|
|
46
|
-
* - `run_id`
|
|
47
|
-
* from `event` or model output.
|
|
46
|
+
* - `run_id` comes from trusted per-instance host context, with the historical
|
|
47
|
+
* environment fallback. Never from `event` or model output.
|
|
48
48
|
*/
|
|
49
49
|
export const stampTurnInputSubmitted = (input) => emitTurnInputSubmitted({
|
|
50
50
|
agentId: input.agentId,
|
|
@@ -53,7 +53,7 @@ export const stampTurnInputSubmitted = (input) => emitTurnInputSubmitted({
|
|
|
53
53
|
inputMessageIds: [input.event.id],
|
|
54
54
|
principalId: agentPrincipalId(input.agentId),
|
|
55
55
|
promptSha256: summarizePrompt(input.promptText).sha256,
|
|
56
|
-
runId: resolveRunId(),
|
|
56
|
+
runId: resolveRunId(undefined, input.runId),
|
|
57
57
|
runtimeHomePath: input.runtimeHomePath,
|
|
58
58
|
turnId: input.event.id
|
|
59
59
|
});
|
|
@@ -69,7 +69,7 @@ export const stampTurnOutputCompleted = (input) => emitTurnOutputCompleted({
|
|
|
69
69
|
causeEventIds: [input.causeEventId],
|
|
70
70
|
outputSha256: sha256Hex(input.outputText),
|
|
71
71
|
principalId: agentPrincipalId(input.agentId),
|
|
72
|
-
runId: resolveRunId(),
|
|
72
|
+
runId: resolveRunId(undefined, input.runId),
|
|
73
73
|
runtimeHomePath: input.runtimeHomePath,
|
|
74
74
|
turnId: input.turnId
|
|
75
75
|
});
|
|
@@ -24,7 +24,7 @@ export declare class WakeAcceptanceStore {
|
|
|
24
24
|
private readonly fs;
|
|
25
25
|
readonly runId: string;
|
|
26
26
|
private readonly capabilities;
|
|
27
|
-
constructor(runtimeHomePath: string, agentId: string, fs?: WakeAcceptanceFs);
|
|
27
|
+
constructor(runtimeHomePath: string, agentId: string, fs?: WakeAcceptanceFs, causalRunId?: string);
|
|
28
28
|
getAcceptanceFilePath(): string;
|
|
29
29
|
candidateFromDelivery(event: WakeEvent): WakeAcceptanceAttempt;
|
|
30
30
|
candidateFromEvent(event: WakeEvent): WakeAcceptanceAttempt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakeAcceptance.d.ts","sourceRoot":"","sources":["../../src/pi/wakeAcceptance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAEL,KAAK,qBAAqB,EAG1B,KAAK,wBAAwB,EAQ9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAMzD,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,wBAAwB,CAAA;CAAE,CAAC;AAE1D,QAAA,MAAM,gBAAgB,eAAuC,CAAC;AAE9D,MAAM,WAAW,wBAAwB;IACvC,CAAC,gBAAgB,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAC7C;AAWD,MAAM,WAAW,uBAAuB;IACtC,qBAAqB,CAAC,KAAK,EAAE,SAAS,GAAG,qBAAqB,CAAC;IAC/D,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC1D,YAAY,CAAC,UAAU,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtF,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AAuB,EACvB,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAC"}
|
|
@@ -11,11 +11,11 @@ export class WakeAcceptanceStore {
|
|
|
11
11
|
fs;
|
|
12
12
|
runId;
|
|
13
13
|
capabilities = new WeakMap();
|
|
14
|
-
constructor(runtimeHomePath, agentId, fs = new WakeAcceptanceFs(runtimeHomePath)) {
|
|
14
|
+
constructor(runtimeHomePath, agentId, fs = new WakeAcceptanceFs(runtimeHomePath), causalRunId) {
|
|
15
15
|
this.runtimeHomePath = runtimeHomePath;
|
|
16
16
|
this.agentId = agentId;
|
|
17
17
|
this.fs = fs;
|
|
18
|
-
this.runId = resolveRunId();
|
|
18
|
+
this.runId = resolveRunId(undefined, causalRunId);
|
|
19
19
|
}
|
|
20
20
|
getAcceptanceFilePath() {
|
|
21
21
|
return this.fs.stateFilePath;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AgentSkill } from "./grokWorkerSkills.js";
|
|
2
|
+
/**
|
|
3
|
+
* What every entry of a skills tree must satisfy beyond being a plain,
|
|
4
|
+
* non-symlink directory or regular file. Attesting a root-provisioned
|
|
5
|
+
* `$GROK_HOME/skills` sets both; reading a compiled workspace leaves them unset.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentSkillsTreePolicy = Readonly<{
|
|
8
|
+
ownerUid?: number;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Reads a skills tree — `<root>/<name>/SKILL.md` plus any supporting files —
|
|
13
|
+
* into the engine-neutral {@link AgentSkill} input, or `undefined` when `root`
|
|
14
|
+
* does not exist.
|
|
15
|
+
*
|
|
16
|
+
* It is the same reader for both ends of the Grok skills path: provisioning
|
|
17
|
+
* reads the compiled workspace's `.agents/skills` (the tree Codex reads in
|
|
18
|
+
* place), and the broker re-reads the rendered `$GROK_HOME/skills` before every
|
|
19
|
+
* turn under a root-owned, read-only policy. Symlinks, special files, hard
|
|
20
|
+
* links (read-only policy), non-UTF-8 content and anything past the
|
|
21
|
+
* {@link AGENT_SKILLS_BOUNDS} are refused rather than skipped, because a
|
|
22
|
+
* skipped entry would make the attested digest describe less than Grok loads.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readAgentSkillsDirectory(root: string, policy?: AgentSkillsTreePolicy): Promise<readonly AgentSkill[] | undefined>;
|
|
25
|
+
//# sourceMappingURL=agentSkillsDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentSkillsDirectory.d.ts","sourceRoot":"","sources":["../../src/runtime/agentSkillsDirectory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyC,KAAK,UAAU,EAAuB,MAAM,uBAAuB,CAAC;AAEpH;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAKxF;;;;;;;;;;;;GAYG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,GAAG,SAAS,CAAC,CAqC3I"}
|