@agimon-ai/po-core 0.0.0-alpha.104 → 0.0.0-alpha.105

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.
Files changed (86) hide show
  1. package/dist/apiContracts.d.mts +95 -7
  2. package/dist/apiContracts.d.mts.map +1 -1
  3. package/dist/headlessSessionHost.d.mts +1 -1
  4. package/dist/nodePlatform.cjs +4 -1
  5. package/dist/nodePlatform.cjs.map +1 -1
  6. package/dist/nodePlatform.d.mts +3 -0
  7. package/dist/nodePlatform.d.mts.map +1 -1
  8. package/dist/nodePlatform.mjs +4 -1
  9. package/dist/nodePlatform.mjs.map +1 -1
  10. package/dist/packageApiServer.cjs +1 -0
  11. package/dist/packageApiServer.cjs.map +1 -1
  12. package/dist/packageApiServer.d.mts +1 -0
  13. package/dist/packageApiServer.d.mts.map +1 -1
  14. package/dist/packageApiServer.mjs +1 -0
  15. package/dist/packageApiServer.mjs.map +1 -1
  16. package/dist/serverPlugin.cjs +6 -0
  17. package/dist/serverPlugin.d.mts +5 -2
  18. package/dist/serverPlugin.mjs +4 -1
  19. package/dist/src/schemas/approval.cjs +4 -1
  20. package/dist/src/schemas/approval.cjs.map +1 -1
  21. package/dist/src/schemas/approval.d.mts.map +1 -1
  22. package/dist/src/schemas/approval.mjs +4 -1
  23. package/dist/src/schemas/approval.mjs.map +1 -1
  24. package/dist/src/schemas/brain.cjs +43 -0
  25. package/dist/src/schemas/brain.cjs.map +1 -0
  26. package/dist/src/schemas/brain.d.mts +105 -0
  27. package/dist/src/schemas/brain.d.mts.map +1 -0
  28. package/dist/src/schemas/brain.mjs +43 -0
  29. package/dist/src/schemas/brain.mjs.map +1 -0
  30. package/dist/src/schemas/codemode.cjs +4 -1
  31. package/dist/src/schemas/codemode.cjs.map +1 -1
  32. package/dist/src/schemas/codemode.d.mts.map +1 -1
  33. package/dist/src/schemas/codemode.mjs +4 -1
  34. package/dist/src/schemas/codemode.mjs.map +1 -1
  35. package/dist/src/schemas/globalServices.cjs.map +1 -1
  36. package/dist/src/schemas/globalServices.d.mts +2 -2
  37. package/dist/src/schemas/globalServices.d.mts.map +1 -1
  38. package/dist/src/schemas/globalServices.mjs.map +1 -1
  39. package/dist/src/schemas/headless.d.mts +1 -1
  40. package/dist/src/schemas/hostServiceContracts.cjs +34 -0
  41. package/dist/src/schemas/hostServiceContracts.cjs.map +1 -0
  42. package/dist/src/schemas/hostServiceContracts.d.mts +23 -0
  43. package/dist/src/schemas/hostServiceContracts.d.mts.map +1 -0
  44. package/dist/src/schemas/hostServiceContracts.mjs +34 -0
  45. package/dist/src/schemas/hostServiceContracts.mjs.map +1 -0
  46. package/dist/src/schemas/packageApi.cjs.map +1 -1
  47. package/dist/src/schemas/packageApi.d.mts +3 -0
  48. package/dist/src/schemas/packageApi.d.mts.map +1 -1
  49. package/dist/src/schemas/packageApi.mjs.map +1 -1
  50. package/dist/src/schemas/serverBundle.d.mts +5 -0
  51. package/dist/src/schemas/serverBundle.d.mts.map +1 -1
  52. package/dist/src/schemas/serverScope.cjs +18 -1
  53. package/dist/src/schemas/serverScope.cjs.map +1 -1
  54. package/dist/src/schemas/serverScope.d.mts +11 -0
  55. package/dist/src/schemas/serverScope.d.mts.map +1 -1
  56. package/dist/src/schemas/serverScope.mjs +18 -2
  57. package/dist/src/schemas/serverScope.mjs.map +1 -1
  58. package/dist/src/server/serverScope.cjs +188 -9
  59. package/dist/src/server/serverScope.cjs.map +1 -1
  60. package/dist/src/server/serverScope.d.mts +8 -3
  61. package/dist/src/server/serverScope.d.mts.map +1 -1
  62. package/dist/src/server/serverScope.mjs +189 -10
  63. package/dist/src/server/serverScope.mjs.map +1 -1
  64. package/dist/src/services/globalServices/index.cjs +12 -3
  65. package/dist/src/services/globalServices/index.cjs.map +1 -1
  66. package/dist/src/services/globalServices/index.d.mts +2 -2
  67. package/dist/src/services/globalServices/index.d.mts.map +1 -1
  68. package/dist/src/services/globalServices/index.mjs +12 -3
  69. package/dist/src/services/globalServices/index.mjs.map +1 -1
  70. package/dist/src/systems/main/types/headlessHost.d.mts +1 -1
  71. package/dist/src/web/hostSlots.cjs +117 -0
  72. package/dist/src/web/hostSlots.cjs.map +1 -0
  73. package/dist/src/web/hostSlots.d.mts +109 -0
  74. package/dist/src/web/hostSlots.d.mts.map +1 -0
  75. package/dist/src/web/hostSlots.mjs +114 -0
  76. package/dist/src/web/hostSlots.mjs.map +1 -0
  77. package/dist/src/web/types/webPlugin.d.mts +4 -0
  78. package/dist/src/web/types/webPlugin.d.mts.map +1 -1
  79. package/dist/web.cjs +5 -0
  80. package/dist/web.d.mts +3 -1
  81. package/dist/web.mjs +2 -1
  82. package/dist/webCompositions.cjs.map +1 -1
  83. package/dist/webCompositions.d.mts +6 -0
  84. package/dist/webCompositions.d.mts.map +1 -1
  85. package/dist/webCompositions.mjs.map +1 -1
  86. package/package.json +4 -4
@@ -8,11 +8,104 @@ import { SqliteDatabase } from "@earendil-works/pi-durable/storage/sqlite";
8
8
  import "@agimon-ai/po-web-security/deviceProof";
9
9
  import { Schema } from "@earendil-works/pi-schema";
10
10
  import "@earendil-works/chord/context";
11
+ //#region src/schemas/serverBundle.d.ts
12
+ /** Every occurrence that can activate a package in this repository. */
13
+ interface PoServerBundleOwner {
14
+ readonly majorMode: string;
15
+ readonly layer: string;
16
+ }
17
+ interface PoServerBundleEntry {
18
+ readonly packageName: string;
19
+ /** Host-admitted distribution catalog origin, never inferred from a local path. */
20
+ readonly origin?: 'po' | 'personal' | 'unknown';
21
+ /** Validated additive client metadata, retained without importing browser code. */
22
+ readonly webMetadata?: PoWebBrainMetadata;
23
+ /** Parsed at package load. Missing or malformed contracts cannot authorize federation. */
24
+ readonly apiContract?: PoApiContract;
25
+ /** The declared package-relative source entry, retained for attribution. */
26
+ readonly entry: string;
27
+ /** Absolute path of the package's built module; the live loader imports it from its content URL. */
28
+ readonly module: string;
29
+ readonly scopes: readonly PoApiScope[];
30
+ readonly owners: readonly PoServerBundleOwner[];
31
+ readonly required: boolean;
32
+ }
33
+ //#endregion
34
+ //#region src/schemas/brain.d.ts
35
+ /** Detached descriptions only. No service values, fibers, paths or callbacks cross this boundary. */
36
+ interface BrainScope {
37
+ id: string;
38
+ level: PoApiScope;
39
+ }
40
+ interface BrainOwner {
41
+ kind: 'host' | 'package' | 'unknown';
42
+ packageName: string | null;
43
+ origin: NonNullable<PoServerBundleEntry['origin']>;
44
+ }
45
+ interface BrainService {
46
+ id: string;
47
+ name: string;
48
+ scope: BrainScope;
49
+ visibleFrom: BrainScope;
50
+ owner: BrainOwner;
51
+ public: boolean;
52
+ description: string | null;
53
+ }
54
+ interface BrainConsumer {
55
+ id: string;
56
+ name: string;
57
+ scope: BrainScope;
58
+ owner: BrainOwner;
59
+ }
60
+ /** Declared injections only, never inferred from ctx.get or requirePo helpers. */
61
+ interface BrainEdge {
62
+ consumer: string;
63
+ service: string | null;
64
+ name: string;
65
+ status: 'resolved' | 'waiting';
66
+ }
67
+ interface BrainPackage {
68
+ scope: BrainScope;
69
+ owner: BrainOwner;
70
+ web: PoWebBrainMetadata | null;
71
+ }
72
+ interface BrainServicesSnapshot {
73
+ scope: BrainScope;
74
+ scopes: BrainScope[];
75
+ packages: BrainPackage[];
76
+ /** Exact published browser mounts, when the host supplied every scope's inventory. */
77
+ clientPackages?: BrainPackage[];
78
+ services: BrainService[];
79
+ consumers: BrainConsumer[];
80
+ edges: BrainEdge[];
81
+ diagnostics: string[];
82
+ }
83
+ /** Additive manifest metadata. Older manifests omit this block rather than claiming no slots. */
84
+ interface PoWebBrainMetadata {
85
+ version: 1;
86
+ slots: {
87
+ name: string;
88
+ scope: PoApiScope;
89
+ description?: string;
90
+ parent?: string;
91
+ kind: 'data' | 'component';
92
+ }[];
93
+ fills: {
94
+ id: string;
95
+ slot: string | null;
96
+ scope: PoApiScope;
97
+ placement: 'verified' | 'unverified';
98
+ }[];
99
+ diagnostics: string[];
100
+ }
101
+ //#endregion
11
102
  //#region src/schemas/serverScope.d.ts
12
103
  /** An abstract service: the name every level resolves and the level that provides it. */
13
104
  interface PoServiceContract<T> {
14
105
  readonly name: string;
15
106
  readonly scope: PoApiScope;
107
+ /** What this service offers an author. Built public contracts require a nonblank description. */
108
+ readonly description?: string;
16
109
  /** Type carrier only; never set at runtime. */
17
110
  readonly _type?: T;
18
111
  }
@@ -34,6 +127,8 @@ interface PoServerPluginShare<TRoots> {
34
127
  /** What a plugin sees of the scope it is installed into. */
35
128
  interface PoServerScopeService {
36
129
  readonly level: PoApiScope;
130
+ /** Detached current scope and ancestry only, without reading service values. */
131
+ snapshot(): BrainServicesSnapshot;
37
132
  /**
38
133
  * Bind the concrete value of a contract owned by this level, visible here and in every descendant.
39
134
  * Settles once every descendant publishes it. The binding unwinds with the calling fiber; the
@@ -753,13 +848,6 @@ declare module '@deepseek-ai/cordis' {
753
848
  }
754
849
  }
755
850
  //#endregion
756
- //#region src/schemas/serverBundle.d.ts
757
- /** Every occurrence that can activate a package in this repository. */
758
- interface PoServerBundleOwner {
759
- readonly majorMode: string;
760
- readonly layer: string;
761
- }
762
- //#endregion
763
851
  //#region src/schemas/apiContracts.d.ts
764
852
  export declare const PO_API_CONTRACT_VERSION = 1;
765
853
  export declare const PO_API_CONTRACT_FILE = "contracts.json";
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":["_0","_0","_0","IoContext","_0","_$__hubChannel0.PoHubSessionUsage","_0","_$__protocolContracts0.ChordMethods"],"sources":["../src/schemas/serverScope.ts","../src/schemas/approvalPrompt.ts","../src/schemas/approval.ts","../src/schemas/backgroundWork.ts","../src/schemas/platform.ts","../src/schemas/workflow.ts","../src/schemas/hubChannel.ts","../src/schemas/packageApi.ts","../src/schemas/serverBundle.ts","../src/schemas/apiContracts.ts","../src/services/apiContracts/index.ts","../src/schemas/builtinApiContracts.ts","../src/schemas/httpApiContracts.ts","../src/schemas/protocolContracts.ts","../src/schemas/sessionProtocol.ts","../src/schemas/sessionApiContracts.ts","../src/schemas/transportApiContracts.ts"],"mappings":";;;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A;;qBAqCjB,wBAAsB,KAAA,QAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAwBtB,wBAAsB,KAAA,QAAA,KAAA"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":["_0","_0","_0","IoContext","_0","_$__hubChannel0.PoHubSessionUsage","_0","_$__protocolContracts0.ChordMethods"],"sources":["../src/schemas/serverBundle.ts","../src/schemas/brain.ts","../src/schemas/serverScope.ts","../src/schemas/approvalPrompt.ts","../src/schemas/approval.ts","../src/schemas/backgroundWork.ts","../src/schemas/platform.ts","../src/schemas/workflow.ts","../src/schemas/hubChannel.ts","../src/schemas/packageApi.ts","../src/schemas/apiContracts.ts","../src/services/apiContracts/index.ts","../src/schemas/builtinApiContracts.ts","../src/schemas/httpApiContracts.ts","../src/schemas/protocolContracts.ts","../src/schemas/sessionProtocol.ts","../src/schemas/sessionApiContracts.ts","../src/schemas/transportApiContracts.ts"],"mappings":";;;;;;;;;;;;UAKiB;WACN;WACA;;UAGM;WACN;;WAEA;;WAEA,cAAc;;WAEd,cAAc;;WAEd;;WAEA;WACA,iBAAiB;WACjB,iBAAiB;WACjB;;;;;UCpBM;EACf;EACA,OAAO;;UAGQ;EACf;EACA;EACA,QAAQ,YAAY;;UAGL;EACf;EACA;EACA,OAAO;EACP,aAAa;EACb,OAAO;EACP;EACA;;UAGe;EACf;EACA;EACA,OAAO;EACP,OAAO;;;UAIQ;EACf;EACA;EACA;EACA;;UAGe;EACf,OAAO;EACP,OAAO;EACP,KAAK;;UAGU;EACf,OAAO;EACP,QAAQ;EACR,UAAU;;EAEV,iBAAiB;EACjB,UAAU;EACV,WAAW;EACX,OAAO;EACP;;;UA+Be;EACf;EACA;IACE;IACA,OAAO;IACP;IACA;IACA;;EAEF;IACE;IACA;IACA,OAAO;IACP;;EAEF;;;;;UCnFe,kBAAkB;WACxB;WACA,OAAO;;WAEP;;WAEA,QAAQ;;;KAeP;;UAoBK,sBAAsB;WA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;;;;;;;;qBAwBtB,wBAAsB,KAAA,QAAA,KAAA"}
@@ -2,11 +2,11 @@ import { PoPlatform } from "./src/schemas/platform.mjs";
2
2
  import { PoWorkflowContextService } from "./src/schemas/workflow.mjs";
3
3
  import { PoHubSessionExecutionState, PoSessionContext } from "./src/schemas/hubChannel.mjs";
4
4
  import { PoNativeComposition, PoWebComposition } from "./src/schemas/packageApi.mjs";
5
+ import { PoServerBundleEntry } from "./src/schemas/serverBundle.mjs";
5
6
  import { DirectHarnessRuntime } from "./src/types/server/directHarnessRuntime.mjs";
6
7
  import { PoChildThread } from "./src/systems/child/types/childSession.mjs";
7
8
  import { ContextProjectionInput } from "./contextProjection.mjs";
8
9
  import { SessionToolSurface } from "./src/types/server/sessionToolSurface.mjs";
9
- import { PoServerBundleEntry } from "./src/schemas/serverBundle.mjs";
10
10
  import { PoHeadlessRefreshAxis, PoHeadlessSelection } from "./src/schemas/headless.mjs";
11
11
  import { PoServerProviderOverride } from "./src/schemas/serverPlugin.mjs";
12
12
  import "./headless.mjs";
@@ -97,7 +97,10 @@ function createNodePlatform(options = {}) {
97
97
  abiVersion: 1,
98
98
  homeDirectory: options.homeDirectory ?? node_os.default.homedir(),
99
99
  temporaryDirectory: process.platform === "darwin" || process.platform === "linux" ? options.temporaryDirectory ?? node_os.default.tmpdir() : void 0,
100
- env: (cwd) => new _earendil_works_pi_durable_env_node.NodeExecutionEnv({ cwd }),
100
+ env: (cwd) => new _earendil_works_pi_durable_env_node.NodeExecutionEnv({
101
+ cwd,
102
+ watch: options.watch
103
+ }),
101
104
  sqlite: {
102
105
  abiVersion: 1,
103
106
  open: openNodeSqliteDatabase
@@ -1 +1 @@
1
- {"version":3,"file":"nodePlatform.cjs","names":["openDatabase","createHistoryOwnership","openSqliteSessionStorage","openReadOnlyDurableStorage","sqliteSessionFile","path","DURABLE_DIRECTORY","fs","os","NodeExecutionEnv"],"sources":["../src/services/nodePlatform/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { NodeExecutionEnv } from '@earendil-works/pi-durable/env/node';\nimport { openNodeSqliteDatabase as openDatabase } from '@earendil-works/pi-durable/storage/sqlite/node';\n\nimport type { PoPlatform, PoSessionStorageService, PoStoredSession } from '../../schemas/platform';\nimport { DURABLE_DIRECTORY } from '../durableSession';\nimport { createHistoryOwnership } from '../historyOwnership';\nimport type { HistoryOwnership } from '../historyOwnership/type';\nimport { openReadOnlyDurableStorage, openSqliteSessionStorage, sqliteSessionFile } from '../sqliteSessionStorage';\n\nconst SQLITE_BUSY = 5;\nconst SQLITE_OPEN_TIMEOUT_MS = 5_000;\nconst SQLITE_OPEN_RETRY_MS = 10;\n\n/** Concurrent WAL initialization can return SQLITE_BUSY without waiting for SQLite's busy timeout. */\nexport async function openNodeSqliteDatabase(file: string) {\n const deadline = Date.now() + SQLITE_OPEN_TIMEOUT_MS;\n for (;;) {\n try {\n return await openDatabase(file, { busyTimeoutMs: Math.max(0, deadline - Date.now()) });\n } catch (error) {\n if (!(error instanceof Error) || !('errcode' in error) || error.errcode !== SQLITE_BUSY || Date.now() >= deadline)\n throw error;\n await new Promise((resolve) => setTimeout(resolve, SQLITE_OPEN_RETRY_MS));\n }\n }\n}\n\nexport interface NodePlatformOptions {\n /** Defaults to the user's home directory. */\n readonly homeDirectory?: string;\n /** Host-admitted override; defaults to this Node host's OS temporary directory. */\n readonly temporaryDirectory?: string;\n /** Where the launching entry keeps agent sessions. Without it `sessions` refuses every call. */\n readonly sessionsRoot?: string;\n /** Shared ownership for every session this platform opens; created on first open when absent. */\n readonly historyOwnership?: HistoryOwnership;\n}\n\n/** One lock-owned durable-v1 SQLite file per agent session. */\nfunction createNodeSessions(options: NodePlatformOptions): PoSessionStorageService {\n let historyOwnership = options.historyOwnership;\n const root = () => {\n if (options.sessionsRoot === undefined) throw new Error('This Node platform was given no sessions root.');\n return options.sessionsRoot;\n };\n return {\n abiVersion: 1,\n async open(request, context) {\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n const opened = await openSqliteSessionStorage({ ...request, sessionsRoot: root(), historyOwnership }, context);\n return {\n storage: opened.storage,\n assertWritable: () => opened.historyLease.assertQuiescent(),\n async release(releaseContext) {\n // The lease outlives a failed close so no second writer opens a file still being written.\n await opened.session.close(releaseContext);\n await opened.historyLease.release();\n },\n };\n },\n openReadOnly: async (sessionId) => openReadOnlyDurableStorage(sqliteSessionFile(root(), sessionId)),\n async list() {\n const directory = path.join(root(), DURABLE_DIRECTORY);\n const files = await fs.readdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const stored: PoStoredSession[] = [];\n for (const file of files) {\n if (!/^[a-zA-Z0-9_-]+\\.sqlite$/u.test(file)) continue;\n const { mtimeMs } = await fs.stat(path.join(directory, file));\n stored.push({ sessionId: path.basename(file, '.sqlite'), updatedAt: mtimeMs });\n }\n return stored;\n },\n async remove(sessionId) {\n const file = sqliteSessionFile(root(), sessionId);\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n let lease: Awaited<ReturnType<HistoryOwnership['acquire']>>;\n try {\n lease = await historyOwnership.acquire(file);\n } catch (error) {\n const cause = error instanceof Error ? (error.cause as NodeJS.ErrnoException | undefined) : undefined;\n if (cause?.code === 'EEXIST') return 'busy';\n throw error;\n }\n try {\n for (const suffix of ['', '-wal', '-shm']) await fs.rm(`${file}${suffix}`, { force: true });\n } finally {\n // Releasing removes the lock file, so a removed session leaves no lock behind.\n await lease.release();\n }\n return 'removed';\n },\n };\n}\n\n/** The Node host: local files and shell, `node:sqlite` files, and lock-owned durable-v1 sessions. */\nexport function createNodePlatform(options: NodePlatformOptions = {}): PoPlatform {\n return {\n abiVersion: 1,\n homeDirectory: options.homeDirectory ?? os.homedir(),\n // Secure session-file protection and viewing currently require POSIX ownership semantics.\n temporaryDirectory:\n process.platform === 'darwin' || process.platform === 'linux'\n ? (options.temporaryDirectory ?? os.tmpdir())\n : undefined,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AAA;EACN,MAAM,QAAQ,IAAIC,oCAAAA,iBAAiB,EAAE,IAAI,CAAC;EAC1C,QAAQ;GAAE,YAAY;GAAG,MAAM;EAAuB;EACtD,UAAU,mBAAmB,OAAO;CACtC;AACF"}
1
+ {"version":3,"file":"nodePlatform.cjs","names":["openDatabase","createHistoryOwnership","openSqliteSessionStorage","openReadOnlyDurableStorage","sqliteSessionFile","path","DURABLE_DIRECTORY","fs","os","NodeExecutionEnv"],"sources":["../src/services/nodePlatform/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { NodeExecutionEnv, type NodeWatchOptions } from '@earendil-works/pi-durable/env/node';\nimport { openNodeSqliteDatabase as openDatabase } from '@earendil-works/pi-durable/storage/sqlite/node';\n\nimport type { PoPlatform, PoSessionStorageService, PoStoredSession } from '../../schemas/platform';\nimport { DURABLE_DIRECTORY } from '../durableSession';\nimport { createHistoryOwnership } from '../historyOwnership';\nimport type { HistoryOwnership } from '../historyOwnership/type';\nimport { openReadOnlyDurableStorage, openSqliteSessionStorage, sqliteSessionFile } from '../sqliteSessionStorage';\n\nconst SQLITE_BUSY = 5;\nconst SQLITE_OPEN_TIMEOUT_MS = 5_000;\nconst SQLITE_OPEN_RETRY_MS = 10;\n\n/** Concurrent WAL initialization can return SQLITE_BUSY without waiting for SQLite's busy timeout. */\nexport async function openNodeSqliteDatabase(file: string) {\n const deadline = Date.now() + SQLITE_OPEN_TIMEOUT_MS;\n for (;;) {\n try {\n return await openDatabase(file, { busyTimeoutMs: Math.max(0, deadline - Date.now()) });\n } catch (error) {\n if (!(error instanceof Error) || !('errcode' in error) || error.errcode !== SQLITE_BUSY || Date.now() >= deadline)\n throw error;\n await new Promise((resolve) => setTimeout(resolve, SQLITE_OPEN_RETRY_MS));\n }\n }\n}\n\nexport interface NodePlatformOptions {\n /** Defaults to the user's home directory. */\n readonly homeDirectory?: string;\n /** Host-admitted override; defaults to this Node host's OS temporary directory. */\n readonly temporaryDirectory?: string;\n /** Where the launching entry keeps agent sessions. Without it `sessions` refuses every call. */\n readonly sessionsRoot?: string;\n /** Shared ownership for every session this platform opens; created on first open when absent. */\n readonly historyOwnership?: HistoryOwnership;\n /** Host-selected watcher settings; omission retains the upstream defaults. */\n readonly watch?: NodeWatchOptions;\n}\n\n/** One lock-owned durable-v1 SQLite file per agent session. */\nfunction createNodeSessions(options: NodePlatformOptions): PoSessionStorageService {\n let historyOwnership = options.historyOwnership;\n const root = () => {\n if (options.sessionsRoot === undefined) throw new Error('This Node platform was given no sessions root.');\n return options.sessionsRoot;\n };\n return {\n abiVersion: 1,\n async open(request, context) {\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n const opened = await openSqliteSessionStorage({ ...request, sessionsRoot: root(), historyOwnership }, context);\n return {\n storage: opened.storage,\n assertWritable: () => opened.historyLease.assertQuiescent(),\n async release(releaseContext) {\n // The lease outlives a failed close so no second writer opens a file still being written.\n await opened.session.close(releaseContext);\n await opened.historyLease.release();\n },\n };\n },\n openReadOnly: async (sessionId) => openReadOnlyDurableStorage(sqliteSessionFile(root(), sessionId)),\n async list() {\n const directory = path.join(root(), DURABLE_DIRECTORY);\n const files = await fs.readdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const stored: PoStoredSession[] = [];\n for (const file of files) {\n if (!/^[a-zA-Z0-9_-]+\\.sqlite$/u.test(file)) continue;\n const { mtimeMs } = await fs.stat(path.join(directory, file));\n stored.push({ sessionId: path.basename(file, '.sqlite'), updatedAt: mtimeMs });\n }\n return stored;\n },\n async remove(sessionId) {\n const file = sqliteSessionFile(root(), sessionId);\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n let lease: Awaited<ReturnType<HistoryOwnership['acquire']>>;\n try {\n lease = await historyOwnership.acquire(file);\n } catch (error) {\n const cause = error instanceof Error ? (error.cause as NodeJS.ErrnoException | undefined) : undefined;\n if (cause?.code === 'EEXIST') return 'busy';\n throw error;\n }\n try {\n for (const suffix of ['', '-wal', '-shm']) await fs.rm(`${file}${suffix}`, { force: true });\n } finally {\n // Releasing removes the lock file, so a removed session leaves no lock behind.\n await lease.release();\n }\n return 'removed';\n },\n };\n}\n\n/** The Node host: local files and shell, `node:sqlite` files, and lock-owned durable-v1 sessions. */\nexport function createNodePlatform(options: NodePlatformOptions = {}): PoPlatform {\n return {\n abiVersion: 1,\n homeDirectory: options.homeDirectory ?? os.homedir(),\n // Secure session-file protection and viewing currently require POSIX ownership semantics.\n temporaryDirectory:\n process.platform === 'darwin' || process.platform === 'linux'\n ? (options.temporaryDirectory ?? os.tmpdir())\n : undefined,\n env: (cwd) => new NodeExecutionEnv({ cwd, watch: options.watch }),\n sqlite: { abiVersion: 1, open: openNodeSqliteDatabase },\n sessions: createNodeSessions(options),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;;AAG7B,eAAsB,uBAAuB,MAAc;CACzD,MAAM,WAAW,KAAK,IAAI,IAAI;CAC9B,SACE,IAAI;EACF,OAAO,OAAA,GAAMA,+CAAAA,uBAAAA,CAAa,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,WAAW,KAAK,IAAI,CAAC,EAAE,CAAC;CACvF,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,UAAU,EAAE,aAAa,UAAU,MAAM,YAAY,eAAe,KAAK,IAAI,KAAK,UACvG,MAAM;EACR,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,oBAAoB,CAAC;CAC1E;AAEJ;;AAgBA,SAAS,mBAAmB,SAAuD;CACjF,IAAI,mBAAmB,QAAQ;CAC/B,MAAM,aAAa;EACjB,IAAI,QAAQ,iBAAiB,KAAA,GAAW,MAAM,IAAI,MAAM,gDAAgD;EACxG,OAAO,QAAQ;CACjB;CACA,OAAO;EACL,YAAY;EACZ,MAAM,KAAK,SAAS,SAAS;GAC3B,q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IACrC,MAAM;GACR;GACA,IAAI;IACF,KAAK,MAAM,UAAU;KAAC;KAAI;KAAQ;IAAM,GAAG,MAAMM,iBAAAA,QAAG,GAAG,GAAG,OAAO,UAAU,EAAE,OAAO,KAAK,CAAC;GAC5F,UAAU;IAER,MAAM,MAAM,QAAQ;GACtB;GACA,OAAO;EACT;CACF;AACF;;AAGA,SAAgB,mBAAmB,UAA+B,CAAC,GAAe;CAChF,OAAO;EACL,YAAY;EACZ,eAAe,QAAQ,iBAAiBC,QAAAA,QAAG,QAAQ;EAEnD,oBACE,QAAQ,aAAa,YAAY,QAAQ,aAAa,UACjD,QAAQ,sBAAsBA,QAAAA,QAAG,OAAO,IACzC,KAAA;EACN,MAAM,QAAQ,IAAIC,oCAAAA,iBAAiB;GAAE;GAAK,OAAO,QAAQ;EAAM,CAAC;EAChE,QAAQ;GAAE,YAAY;GAAG,MAAM;EAAuB;EACtD,UAAU,mBAAmB,OAAO;CACtC;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { PoPlatform } from "./src/schemas/platform.mjs";
2
2
  import { HistoryOwnership } from "./src/services/historyOwnership/type.mjs";
3
+ import { NodeWatchOptions } from "@earendil-works/pi-durable/env/node";
3
4
  //#region src/services/nodePlatform/index.d.ts
4
5
  /** Concurrent WAL initialization can return SQLITE_BUSY without waiting for SQLite's busy timeout. */
5
6
  export declare function openNodeSqliteDatabase(file: string): Promise<import("@earendil-works/chord/sqlite/node").NodeSqliteDatabase>;
@@ -12,6 +13,8 @@ export interface NodePlatformOptions {
12
13
  readonly sessionsRoot?: string;
13
14
  /** Shared ownership for every session this platform opens; created on first open when absent. */
14
15
  readonly historyOwnership?: HistoryOwnership;
16
+ /** Host-selected watcher settings; omission retains the upstream defaults. */
17
+ readonly watch?: NodeWatchOptions;
15
18
  }
16
19
  /** The Node host: local files and shell, `node:sqlite` files, and lock-owned durable-v1 sessions. */
17
20
  export declare function createNodePlatform(options?: NodePlatformOptions): PoPlatform;
@@ -1 +1 @@
1
- {"version":3,"file":"nodePlatform.d.mts","names":[],"sources":["../src/services/nodePlatform/index.ts"],"mappings":";;;;wBAkBsB,uBAAuB,eAAY,oDAAA;iBAaxC;;WAEN;;WAEA;;WAEA;;WAEA,mBAAmB;;;wBA+Dd,mBAAmB,UAAS,sBAA2B"}
1
+ {"version":3,"file":"nodePlatform.d.mts","names":[],"sources":["../src/services/nodePlatform/index.ts"],"mappings":";;;;;wBAkBsB,uBAAuB,eAAY,oDAAA;iBAaxC;;WAEN;;WAEA;;WAEA;;WAEA,mBAAmB;;WAEnB,QAAQ;;;wBA+DH,mBAAmB,UAAS,sBAA2B"}
@@ -92,7 +92,10 @@ function createNodePlatform(options = {}) {
92
92
  abiVersion: 1,
93
93
  homeDirectory: options.homeDirectory ?? os.homedir(),
94
94
  temporaryDirectory: process.platform === "darwin" || process.platform === "linux" ? options.temporaryDirectory ?? os.tmpdir() : void 0,
95
- env: (cwd) => new NodeExecutionEnv({ cwd }),
95
+ env: (cwd) => new NodeExecutionEnv({
96
+ cwd,
97
+ watch: options.watch
98
+ }),
96
99
  sqlite: {
97
100
  abiVersion: 1,
98
101
  open: openNodeSqliteDatabase
@@ -1 +1 @@
1
- {"version":3,"file":"nodePlatform.mjs","names":["openDatabase"],"sources":["../src/services/nodePlatform/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { NodeExecutionEnv } from '@earendil-works/pi-durable/env/node';\nimport { openNodeSqliteDatabase as openDatabase } from '@earendil-works/pi-durable/storage/sqlite/node';\n\nimport type { PoPlatform, PoSessionStorageService, PoStoredSession } from '../../schemas/platform';\nimport { DURABLE_DIRECTORY } from '../durableSession';\nimport { createHistoryOwnership } from '../historyOwnership';\nimport type { HistoryOwnership } from '../historyOwnership/type';\nimport { openReadOnlyDurableStorage, openSqliteSessionStorage, sqliteSessionFile } from '../sqliteSessionStorage';\n\nconst SQLITE_BUSY = 5;\nconst SQLITE_OPEN_TIMEOUT_MS = 5_000;\nconst SQLITE_OPEN_RETRY_MS = 10;\n\n/** Concurrent WAL initialization can return SQLITE_BUSY without waiting for SQLite's busy timeout. */\nexport async function openNodeSqliteDatabase(file: string) {\n const deadline = Date.now() + SQLITE_OPEN_TIMEOUT_MS;\n for (;;) {\n try {\n return await openDatabase(file, { busyTimeoutMs: Math.max(0, deadline - Date.now()) });\n } catch (error) {\n if (!(error instanceof Error) || !('errcode' in error) || error.errcode !== SQLITE_BUSY || Date.now() >= deadline)\n throw error;\n await new Promise((resolve) => setTimeout(resolve, SQLITE_OPEN_RETRY_MS));\n }\n }\n}\n\nexport interface NodePlatformOptions {\n /** Defaults to the user's home directory. */\n readonly homeDirectory?: string;\n /** Host-admitted override; defaults to this Node host's OS temporary directory. */\n readonly temporaryDirectory?: string;\n /** Where the launching entry keeps agent sessions. Without it `sessions` refuses every call. */\n readonly sessionsRoot?: string;\n /** Shared ownership for every session this platform opens; created on first open when absent. */\n readonly historyOwnership?: HistoryOwnership;\n}\n\n/** One lock-owned durable-v1 SQLite file per agent session. */\nfunction createNodeSessions(options: NodePlatformOptions): PoSessionStorageService {\n let historyOwnership = options.historyOwnership;\n const root = () => {\n if (options.sessionsRoot === undefined) throw new Error('This Node platform was given no sessions root.');\n return options.sessionsRoot;\n };\n return {\n abiVersion: 1,\n async open(request, context) {\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n const opened = await openSqliteSessionStorage({ ...request, sessionsRoot: root(), historyOwnership }, context);\n return {\n storage: opened.storage,\n assertWritable: () => opened.historyLease.assertQuiescent(),\n async release(releaseContext) {\n // The lease outlives a failed close so no second writer opens a file still being written.\n await opened.session.close(releaseContext);\n await opened.historyLease.release();\n },\n };\n },\n openReadOnly: async (sessionId) => openReadOnlyDurableStorage(sqliteSessionFile(root(), sessionId)),\n async list() {\n const directory = path.join(root(), DURABLE_DIRECTORY);\n const files = await fs.readdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const stored: PoStoredSession[] = [];\n for (const file of files) {\n if (!/^[a-zA-Z0-9_-]+\\.sqlite$/u.test(file)) continue;\n const { mtimeMs } = await fs.stat(path.join(directory, file));\n stored.push({ sessionId: path.basename(file, '.sqlite'), updatedAt: mtimeMs });\n }\n return stored;\n },\n async remove(sessionId) {\n const file = sqliteSessionFile(root(), sessionId);\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n let lease: Awaited<ReturnType<HistoryOwnership['acquire']>>;\n try {\n lease = await historyOwnership.acquire(file);\n } catch (error) {\n const cause = error instanceof Error ? (error.cause as NodeJS.ErrnoException | undefined) : undefined;\n if (cause?.code === 'EEXIST') return 'busy';\n throw error;\n }\n try {\n for (const suffix of ['', '-wal', '-shm']) await fs.rm(`${file}${suffix}`, { force: true });\n } finally {\n // Releasing removes the lock file, so a removed session leaves no lock behind.\n await lease.release();\n }\n return 'removed';\n },\n };\n}\n\n/** The Node host: local files and shell, `node:sqlite` files, and lock-owned durable-v1 sessions. */\nexport function createNodePlatform(options: NodePlatformOptions = {}): PoPlatform {\n return {\n abiVersion: 1,\n homeDirectory: options.homeDirectory ?? os.homedir(),\n // Secure session-file protection and viewing currently require POSIX ownership semantics.\n temporaryDirectory:\n process.platform === 'darwin' || process.platform === 'linux'\n ? (options.temporaryDirectory ?? os.tmpdir())\n : undefined,\n env: (cwd) => new NodeExecutionEnv({ cwd }),\n sqlite: { abiVersion: 1, open: openNodeSqliteDatabase },\n sessions: createNodeSessions(options),\n };\n}\n"],"mappings":";;;;;;;;;AAaA,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;;AAG7B,eAAsB,uBAAuB,MAAc;CACzD,MAAM,WAAW,KAAK,IAAI,IAAI;CAC9B,SACE,IAAI;EACF,OAAO,MAAMA,yBAAa,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,WAAW,KAAK,IAAI,CAAC,EAAE,CAAC;CACvF,SAAS,OAAO;EACd,IAAI,EAAE,iBAAi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OAAO,WAAW;GACtB,MAAM,OAAO,kBAAkB,KAAK,GAAG,SAAS;GAChD,qBAAqB,uBAAuB,EAAE,cAAc,SAAS,CAAC;GACtE,IAAI;GACJ,IAAI;IACF,QAAQ,MAAM,iBAAiB,QAAQ,IAAI;GAC7C,SAAS,OAAO;IAEd,KADc,iBAAiB,QAAS,MAAM,QAA8C,KAAA,EAAA,EACjF,SAAS,UAAU,OAAO;IACrC,MAAM;GACR;GACA,IAAI;IACF,KAAK,MAAM,UAAU;KAAC;KAAI;KAAQ;IAAM,GAAG,MAAM,GAAG,GAAG,GAAG,OAAO,UAAU,EAAE,OAAO,KAAK,CAAC;GAC5F,UAAU;IAER,MAAM,MAAM,QAAQ;GACtB;GACA,OAAO;EACT;CACF;AACF;;AAGA,SAAgB,mBAAmB,UAA+B,CAAC,GAAe;CAChF,OAAO;EACL,YAAY;EACZ,eAAe,QAAQ,iBAAiB,GAAG,QAAQ;EAEnD,oBACE,QAAQ,aAAa,YAAY,QAAQ,aAAa,UACjD,QAAQ,sBAAsB,GAAG,OAAO,IACzC,KAAA;EACN,MAAM,QAAQ,IAAI,iBAAiB,EAAE,IAAI,CAAC;EAC1C,QAAQ;GAAE,YAAY;GAAG,MAAM;EAAuB;EACtD,UAAU,mBAAmB,OAAO;CACtC;AACF"}
1
+ {"version":3,"file":"nodePlatform.mjs","names":["openDatabase"],"sources":["../src/services/nodePlatform/index.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { NodeExecutionEnv, type NodeWatchOptions } from '@earendil-works/pi-durable/env/node';\nimport { openNodeSqliteDatabase as openDatabase } from '@earendil-works/pi-durable/storage/sqlite/node';\n\nimport type { PoPlatform, PoSessionStorageService, PoStoredSession } from '../../schemas/platform';\nimport { DURABLE_DIRECTORY } from '../durableSession';\nimport { createHistoryOwnership } from '../historyOwnership';\nimport type { HistoryOwnership } from '../historyOwnership/type';\nimport { openReadOnlyDurableStorage, openSqliteSessionStorage, sqliteSessionFile } from '../sqliteSessionStorage';\n\nconst SQLITE_BUSY = 5;\nconst SQLITE_OPEN_TIMEOUT_MS = 5_000;\nconst SQLITE_OPEN_RETRY_MS = 10;\n\n/** Concurrent WAL initialization can return SQLITE_BUSY without waiting for SQLite's busy timeout. */\nexport async function openNodeSqliteDatabase(file: string) {\n const deadline = Date.now() + SQLITE_OPEN_TIMEOUT_MS;\n for (;;) {\n try {\n return await openDatabase(file, { busyTimeoutMs: Math.max(0, deadline - Date.now()) });\n } catch (error) {\n if (!(error instanceof Error) || !('errcode' in error) || error.errcode !== SQLITE_BUSY || Date.now() >= deadline)\n throw error;\n await new Promise((resolve) => setTimeout(resolve, SQLITE_OPEN_RETRY_MS));\n }\n }\n}\n\nexport interface NodePlatformOptions {\n /** Defaults to the user's home directory. */\n readonly homeDirectory?: string;\n /** Host-admitted override; defaults to this Node host's OS temporary directory. */\n readonly temporaryDirectory?: string;\n /** Where the launching entry keeps agent sessions. Without it `sessions` refuses every call. */\n readonly sessionsRoot?: string;\n /** Shared ownership for every session this platform opens; created on first open when absent. */\n readonly historyOwnership?: HistoryOwnership;\n /** Host-selected watcher settings; omission retains the upstream defaults. */\n readonly watch?: NodeWatchOptions;\n}\n\n/** One lock-owned durable-v1 SQLite file per agent session. */\nfunction createNodeSessions(options: NodePlatformOptions): PoSessionStorageService {\n let historyOwnership = options.historyOwnership;\n const root = () => {\n if (options.sessionsRoot === undefined) throw new Error('This Node platform was given no sessions root.');\n return options.sessionsRoot;\n };\n return {\n abiVersion: 1,\n async open(request, context) {\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n const opened = await openSqliteSessionStorage({ ...request, sessionsRoot: root(), historyOwnership }, context);\n return {\n storage: opened.storage,\n assertWritable: () => opened.historyLease.assertQuiescent(),\n async release(releaseContext) {\n // The lease outlives a failed close so no second writer opens a file still being written.\n await opened.session.close(releaseContext);\n await opened.historyLease.release();\n },\n };\n },\n openReadOnly: async (sessionId) => openReadOnlyDurableStorage(sqliteSessionFile(root(), sessionId)),\n async list() {\n const directory = path.join(root(), DURABLE_DIRECTORY);\n const files = await fs.readdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return [];\n throw error;\n });\n const stored: PoStoredSession[] = [];\n for (const file of files) {\n if (!/^[a-zA-Z0-9_-]+\\.sqlite$/u.test(file)) continue;\n const { mtimeMs } = await fs.stat(path.join(directory, file));\n stored.push({ sessionId: path.basename(file, '.sqlite'), updatedAt: mtimeMs });\n }\n return stored;\n },\n async remove(sessionId) {\n const file = sqliteSessionFile(root(), sessionId);\n historyOwnership ??= createHistoryOwnership({ sourceFormat: 'sqlite' });\n let lease: Awaited<ReturnType<HistoryOwnership['acquire']>>;\n try {\n lease = await historyOwnership.acquire(file);\n } catch (error) {\n const cause = error instanceof Error ? (error.cause as NodeJS.ErrnoException | undefined) : undefined;\n if (cause?.code === 'EEXIST') return 'busy';\n throw error;\n }\n try {\n for (const suffix of ['', '-wal', '-shm']) await fs.rm(`${file}${suffix}`, { force: true });\n } finally {\n // Releasing removes the lock file, so a removed session leaves no lock behind.\n await lease.release();\n }\n return 'removed';\n },\n };\n}\n\n/** The Node host: local files and shell, `node:sqlite` files, and lock-owned durable-v1 sessions. */\nexport function createNodePlatform(options: NodePlatformOptions = {}): PoPlatform {\n return {\n abiVersion: 1,\n homeDirectory: options.homeDirectory ?? os.homedir(),\n // Secure session-file protection and viewing currently require POSIX ownership semantics.\n temporaryDirectory:\n process.platform === 'darwin' || process.platform === 'linux'\n ? (options.temporaryDirectory ?? os.tmpdir())\n : undefined,\n env: (cwd) => new NodeExecutionEnv({ cwd, watch: options.watch }),\n sqlite: { abiVersion: 1, open: openNodeSqliteDatabase },\n sessions: createNodeSessions(options),\n };\n}\n"],"mappings":";;;;;;;;;AAaA,MAAM,cAAc;AACpB,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;;AAG7B,eAAsB,uBAAuB,MAAc;CACzD,MAAM,WAAW,KAAK,IAAI,IA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AAM,GAAG,KAAK,KAAK,KAAK,WAAW,IAAI,CAAC;IAC5D,OAAO,KAAK;KAAE,WAAW,KAAK,SAAS,MAAM,SAAS;KAAG,WAAW;IAAQ,CAAC;GAC/E;GACA,OAAO;EACT;EACA,MAAM,OAAO,WAAW;GACtB,MAAM,OAAO,kBAAkB,KAAK,GAAG,SAAS;GAChD,qBAAqB,uBAAuB,EAAE,cAAc,SAAS,CAAC;GACtE,IAAI;GACJ,IAAI;IACF,QAAQ,MAAM,iBAAiB,QAAQ,IAAI;GAC7C,SAAS,OAAO;IAEd,KADc,iBAAiB,QAAS,MAAM,QAA8C,KAAA,EAAA,EACjF,SAAS,UAAU,OAAO;IACrC,MAAM;GACR;GACA,IAAI;IACF,KAAK,MAAM,UAAU;KAAC;KAAI;KAAQ;IAAM,GAAG,MAAM,GAAG,GAAG,GAAG,OAAO,UAAU,EAAE,OAAO,KAAK,CAAC;GAC5F,UAAU;IAER,MAAM,MAAM,QAAQ;GACtB;GACA,OAAO;EACT;CACF;AACF;;AAGA,SAAgB,mBAAmB,UAA+B,CAAC,GAAe;CAChF,OAAO;EACL,YAAY;EACZ,eAAe,QAAQ,iBAAiB,GAAG,QAAQ;EAEnD,oBACE,QAAQ,aAAa,YAAY,QAAQ,aAAa,UACjD,QAAQ,sBAAsB,GAAG,OAAO,IACzC,KAAA;EACN,MAAM,QAAQ,IAAI,iBAAiB;GAAE;GAAK,OAAO,QAAQ;EAAM,CAAC;EAChE,QAAQ;GAAE,YAAY;GAAG,MAAM;EAAuB;EACtD,UAAU,mBAAmB,OAAO;CACtC;AACF"}
@@ -138,6 +138,7 @@ async function serveSessionApis(options) {
138
138
  sessionStorage: options.platform.sessions,
139
139
  cwd: options.cwd,
140
140
  environment: options.environment,
141
+ ...options.clientPlugins === void 0 ? {} : { clientPlugins: options.clientPlugins },
141
142
  directEvents: options.directEvents,
142
143
  ...options.computerUse === void 0 ? {} : { computerUse: options.computerUse },
143
144
  ...options.shareFile === void 0 ? {} : { shareFile: options.shareFile },
@@ -1 +1 @@
1
- {"version":3,"file":"packageApiServer.cjs","names":["SESSION_FILES_API","readAccessibleFile","prepareSessionEnvironment","createPoServerHost","createFileAccess","PO_SESSION_TEMP_DIR","path","PoServerScope","PO_FILE_ACCESS_SERVICE","PO_API_ROUTE_PREFIX","validatedTraceContext","OperationCancelledError"],"sources":["../src/server/packageApiServer.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { SESSION_FILES_API } from '../constants/sessionFiles';\nimport type { PoDirectEventBus, PoHubSessionPromptOptions, PoHubSessionService } from '../exports/hubChannel';\nimport { PO_API_ROUTE_PREFIX, type PoApi, type PoApiContext } from '../exports/packageApi';\nimport type { PoPlatform } from '../exports/platform';\nimport type { PoPluginRegistry } from '../exports/pluginProtocol';\nimport {\n createPoServerHost,\n type CreatePoServerHostOptions,\n type LoadedServerPackage,\n type PoServerPackageFailure,\n type PoServerPlugin,\n PoServerScope,\n} from '../exports/serverPlugin';\nimport {\n createFileAccess,\n PO_FILE_ACCESS_SERVICE,\n type PoFileAccess,\n readAccessibleFile,\n} from '../services/fileAccess';\nimport type { PoTraceContext } from '../services/poTelemetry';\nimport { observe, type ServerTelemetry } from '../services/serverTelemetry';\nimport { PO_SESSION_TEMP_DIR, prepareSessionEnvironment } from '../services/sessionFiles';\nimport { OperationCancelledError } from '../services/telemetry';\nimport { validatedTraceContext } from '../services/traceContext';\n\n/**\n * A body that keeps streaming well after its headers went out is worth its own span. A fast\n * one is not: the request span already carries the duration and outcome, so emitting a second\n * span per call made package API traffic 99.65% of all spans recorded in a two hour sample.\n */\nexport const COMPLETION_SPAN_MIN_DURATION_MS = 1000;\n/** A body this large is worth a span however fast it flushed: big bodies drive heap spikes. */\nexport const COMPLETION_SPAN_MIN_BYTES = 1024 * 1024;\n\n/** A coarse body class, so a size can be attributed without recording a path or file name. */\nexport function contentClass(contentType: string | null): string {\n const type = contentType?.split(';')[0]?.trim().toLowerCase() ?? '';\n if (type === '') return 'none';\n if (type.startsWith('image/')) return 'image';\n if (type.endsWith('json')) return 'json';\n if (type.startsWith('text/')) return 'text';\n return 'binary';\n}\n\nexport interface PackageApiServerOptions {\n sessionId: string;\n workspaceId?: string;\n workspaceRoot?: string;\n sessionContext?: PoApiContext['sessionContext'];\n homeDirectory?: string;\n mountChannel?: CreatePoServerHostOptions['mountChannel'];\n cwd: string;\n /** Admitted environment for APIs serving this session. */\n readonly environment: Readonly<Record<string, string | undefined>>;\n /** Lifecycle-owned direct events shared with the hub. */\n readonly directEvents: PoDirectEventBus;\n readonly computerUse?: PoApiContext['computerUse'];\n /** Bound to this session's id and cwd by the host. */\n readonly shareFile?: PoApiContext['shareFile'];\n readonly shareRegisteredFile?: PoApiContext['shareRegisteredFile'];\n readonly mediaArbitration?: PoApiContext['mediaArbitration'];\n readonly executionBudget?: PoApiContext['executionBudget'];\n readonly peerAgents?: PoApiContext['peerAgents'];\n readonly requestApi?: PoApiContext['requestApi'];\n /** Publishes this session's activity line through the hub; bound to this session only. */\n readonly publishActivity?: PoApiContext['publishActivity'];\n internalToken?: string;\n hubToken?: string;\n /** Shared exact-scope dispatch table, so session packages can mount plugin methods. */\n pluginRegistry?: PoPluginRegistry;\n sessionService?: PoHubSessionService;\n apis: readonly PoApi[];\n /** Server packages to install; each registers its own APIs through the host. */\n packages?: readonly (PoServerPlugin | LoadedServerPackage)[];\n /** Publishes the session's own services into its scope root before any package installs. */\n preparePackages?: (root: Context) => void | Promise<void>;\n /** The hub's workspace or global scope; the session's own scope opens below it and closes with it. */\n parentScope?: PoServerScope;\n /** Host capabilities for the session scope root, injected by the composition root. */\n platform: PoPlatform;\n activatePackages?: (installedPackages: readonly string[]) => Promise<void>;\n canDispatch?: () => boolean;\n telemetry?: ServerTelemetry;\n onNotice: (message: string) => void;\n}\n\nexport interface PackageApiServer {\n /** Dispatches an already-authenticated request without crossing a transport boundary. */\n readonly operation?: (basePath: string, method: string, path: string) => string | undefined;\n readonly request: (request: Request) => Promise<Response>;\n /**\n * Brings the session's installed packages up to date: changed and added `packages` install with\n * per-package rollback, and installed ones no longer `declared` are disposed. A declared package\n * whose new build failed to load is absent from `packages` but keeps its running build.\n */\n readonly reconcile?: (\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n declared: readonly string[],\n ) => Promise<PackageReconcileResult>;\n close(): Promise<void>;\n}\n\nexport interface PackageReconcileResult {\n readonly installed: readonly string[];\n readonly removed: readonly string[];\n readonly failed: readonly PoServerPackageFailure[];\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction responseWithCompletion(response: Response, complete: (bytes: number) => void): Response {\n if (response.body === null) {\n complete(0);\n return response;\n }\n const reader = response.body.getReader();\n let completed = false;\n let bytes = 0;\n const finish = (): void => {\n if (completed) return;\n completed = true;\n complete(bytes);\n };\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n finish();\n controller.close();\n } else {\n bytes += result.value.byteLength;\n controller.enqueue(result.value);\n }\n } catch (error) {\n finish();\n controller.error(error);\n }\n },\n async cancel(reason) {\n finish();\n await reader.cancel(reason);\n },\n });\n return new Response(body, response);\n}\n\n/** Reads files under the session's open folders; the hub's session `/file` route forwards here. */\nfunction sessionFilesApi(fileAccess: PoFileAccess, cwd: string): PoApi {\n return {\n basePath: SESSION_FILES_API,\n start: () => ({\n fetch: (request) => {\n if (request.method !== 'GET') return Response.json({ error: 'Method not allowed.' }, { status: 405 });\n return readAccessibleFile({\n roots: fileAccess.roots(),\n cwd,\n path: new URL(request.url).searchParams.get('path'),\n ...(request.headers.get('range') === null ? {} : { range: request.headers.get('range')! }),\n ...(request.headers.get('if-match') === null ? {} : { expectedVersion: request.headers.get('if-match')! }),\n });\n },\n close: () => undefined,\n }),\n };\n}\n/** Installs session packages and dispatches authenticated package API calls in-process. */\nexport async function serveSessionApis(options: PackageApiServerOptions): Promise<PackageApiServer> {\n if (options.environment === undefined)\n throw new Error('Session package API server requires an admitted environment.');\n if (options.directEvents === undefined) throw new Error('Session package API server requires direct events.');\n options = { ...options, environment: await prepareSessionEnvironment(options) };\n const packages = options.packages ?? [];\n // Without a level above it, a session that mounts nothing has nothing to route.\n const routesNothing = (): boolean => !options.preparePackages && options.parentScope === undefined;\n if (options.apis.length === 0 && packages.length === 0 && routesNothing()) {\n return {\n request: async () => Response.json({ error: 'No package APIs are mounted.' }, { status: 404 }),\n close: () => Promise.resolve(),\n };\n }\n\n const owningSessionService = options.sessionService;\n const communication = owningSessionService?.bindCommunication?.(options.sessionId);\n const ownedReadExecutionState = owningSessionService?.readExecutionState?.bind(owningSessionService);\n const ownedPrompt = owningSessionService?.prompt?.bind(owningSessionService);\n const ownedAbort = owningSessionService?.abort?.bind(owningSessionService);\n const ownedSteer = owningSessionService?.steer?.bind(owningSessionService);\n const ownedRelease = owningSessionService?.release?.bind(owningSessionService);\n const exposedSessionService: PoHubSessionService | undefined =\n owningSessionService === undefined\n ? undefined\n : {\n create: (request) => owningSessionService.create(request),\n close: (sessionId) => owningSessionService.close(sessionId),\n isLive: (sessionId) => owningSessionService.isLive(sessionId),\n ...(ownedReadExecutionState === undefined\n ? {}\n : {\n readExecutionState: (sessionId: string) =>\n ownedReadExecutionState(sessionId, { parentSessionId: options.sessionId }),\n }),\n // A session may drive only the children it started, never its parent or a sibling.\n ...(ownedPrompt === undefined\n ? {}\n : {\n prompt: (sessionId: string, text: string, promptOptions?: PoHubSessionPromptOptions) =>\n ownedPrompt(sessionId, text, {\n ...(promptOptions?.signal === undefined ? {} : { signal: promptOptions.signal }),\n parentSessionId: options.sessionId,\n }),\n }),\n ...(ownedAbort === undefined\n ? {}\n : {\n abort: (sessionId: string) => ownedAbort(sessionId, { parentSessionId: options.sessionId }),\n }),\n ...(ownedSteer === undefined\n ? {}\n : {\n steer: (sessionId: string, message: string) =>\n ownedSteer(sessionId, message, { parentSessionId: options.sessionId }),\n }),\n ...(ownedRelease === undefined\n ? {}\n : {\n release: (sessionId, releaseOptions) =>\n ownedRelease(sessionId, {\n ...(releaseOptions?.onlyIfIdle === undefined ? {} : { onlyIfIdle: releaseOptions.onlyIfIdle }),\n parentSessionId: options.sessionId,\n }),\n }),\n ...(owningSessionService.canCommunicate === undefined\n ? {}\n : {\n canCommunicate: (sourceSessionId: string, targetSessionId: string) =>\n owningSessionService.canCommunicate?.(sourceSessionId, targetSessionId) === true,\n }),\n };\n const context: PoApiContext = {\n scope: 'session',\n sessionId: options.sessionId,\n workspaceId: options.workspaceId,\n workspaceRoot: options.workspaceRoot,\n ...(options.sessionContext === undefined ? {} : { sessionContext: options.sessionContext }),\n homeDirectory: options.homeDirectory ?? options.platform.homeDirectory,\n sessionStorage: options.platform.sessions,\n cwd: options.cwd,\n environment: options.environment,\n directEvents: options.directEvents,\n ...(options.computerUse === undefined ? {} : { computerUse: options.computerUse }),\n ...(options.shareFile === undefined ? {} : { shareFile: options.shareFile }),\n ...(options.shareRegisteredFile === undefined ? {} : { shareRegisteredFile: options.shareRegisteredFile }),\n ...(options.mediaArbitration === undefined ? {} : { mediaArbitration: options.mediaArbitration }),\n ...(options.executionBudget === undefined ? {} : { executionBudget: options.executionBudget }),\n ...(options.peerAgents === undefined ? {} : { peerAgents: options.peerAgents }),\n ...(options.requestApi === undefined ? {} : { requestApi: options.requestApi }),\n ...(options.publishActivity === undefined ? {} : { publishActivity: options.publishActivity }),\n ...(options.internalToken === undefined ? {} : { internalToken: options.internalToken }),\n ...(options.hubToken === undefined ? {} : { hubToken: options.hubToken }),\n ...(exposedSessionService === undefined ? {} : { sessionService: exposedSessionService }),\n ...(communication === undefined ? {} : { sessionCommunication: communication }),\n onNotice: options.onNotice,\n };\n const host = createPoServerHost({\n scope: 'session',\n context,\n mountChannel: options.mountChannel,\n ...(options.pluginRegistry === undefined ? {} : { pluginRegistry: options.pluginRegistry }),\n });\n // The session's own folder, its workspace and the temp folders of every session under this Po home;\n // extensions open their own beside these.\n const fileAccess = createFileAccess();\n const tempDirectory = options.environment[PO_SESSION_TEMP_DIR];\n const sessionsTemp =\n tempDirectory !== undefined && path.basename(path.dirname(tempDirectory)) === 'sessions'\n ? path.dirname(tempDirectory)\n : tempDirectory;\n for (const directory of [options.cwd, options.workspaceRoot, sessionsTemp])\n if (directory !== undefined && path.isAbsolute(directory)) fileAccess.register(directory);\n let scope: PoServerScope | undefined;\n const installOptions = (failed?: PoServerPackageFailure[]) => ({\n onNotice: options.onNotice,\n ...(failed === undefined ? {} : { onPackageFailed: (failure: PoServerPackageFailure) => failed.push(failure) }),\n onPackageSettled: (report: { packageName: string; outcome: string; durationMs: number }) => {\n if (!options.telemetry) return;\n observe(\n options.telemetry.recordEvent('po_server.package_install', {\n 'package.name': report.packageName,\n 'package.outcome': report.outcome,\n duration_ms: report.durationMs,\n scope: 'session',\n }),\n options.onNotice,\n );\n },\n });\n try {\n // Registered first, so no package can claim the host's own base path.\n host.registerApi(sessionFilesApi(fileAccess, options.cwd));\n for (const api of options.apis) host.registerApi(api);\n // The session's own level of the server IoC tree; it closes with the hub level it opens below.\n scope = await PoServerScope.open('session', options.parentScope);\n await scope.serve({ host, platform: options.platform });\n await scope.root.plugin((root) => {\n root.provide(PO_FILE_ACCESS_SERVICE, fileAccess);\n });\n await options.preparePackages?.(scope.root);\n const installed = await scope.install(packages, installOptions());\n await options.activatePackages?.(installed);\n } catch (error) {\n await scope?.dispose();\n communication?.close();\n host.dispose();\n throw error;\n }\n if (host.mounted().length === 0 && routesNothing()) {\n await scope.dispose();\n communication?.close();\n host.dispose();\n return {\n request: async () => Response.json({ error: 'No package APIs are mounted.' }, { status: 404 }),\n close: () => Promise.resolve(),\n };\n }\n const sessionScope = scope;\n const reconcile = async (\n next: readonly (PoServerPlugin | LoadedServerPackage)[],\n declared: readonly string[],\n ): Promise<PackageReconcileResult> => {\n const failed: PoServerPackageFailure[] = [];\n const installed = await sessionScope.install(next, installOptions(failed));\n const removed = installed.filter((name) => !declared.includes(name));\n return { installed: await sessionScope.uninstall(removed), removed, failed };\n };\n\n const dispatch = async (request: Request): Promise<Response> => {\n if (options.canDispatch?.() === false)\n return Response.json({ error: 'Session selection is not ready.' }, { status: 503 });\n const url = new URL(request.url);\n if (!url.pathname.startsWith(`${PO_API_ROUTE_PREFIX}/`))\n return Response.json({ error: 'Not found.' }, { status: 404 });\n const rest = url.pathname.slice(PO_API_ROUTE_PREFIX.length + 1);\n const slash = rest.indexOf('/');\n const basePath = slash === -1 ? rest : rest.slice(0, slash);\n // The session's own API, else the nearest level above it that serves one.\n const handler = sessionScope.apiHandler(basePath);\n if (handler === undefined)\n return Response.json({ error: `No API '${basePath}' in this session.` }, { status: 404 });\n url.pathname = slash === -1 ? '/' : rest.slice(slash);\n const startedAt = performance.now();\n const parent = validatedTraceContext(request.headers.get('traceparent'));\n let childContext: PoTraceContext | undefined;\n let response: Response;\n try {\n const invoke = async (context?: PoTraceContext): Promise<Response> => {\n if (options.canDispatch?.() === false || sessionScope.apiHandler(basePath) !== handler) {\n return Response.json({ error: 'Session selection changed before dispatch.' }, { status: 503 });\n }\n childContext = context;\n const incoming = new Request(url, request);\n try {\n return await handler.fetch(incoming);\n } catch (error) {\n if (incoming.signal.aborted && (error === incoming.signal.reason || error instanceof OperationCancelledError))\n return new Response(null, { status: 499 });\n throw error;\n }\n };\n response = options.telemetry\n ? await options.telemetry.runInSpan(\n 'po_server.package_api.request',\n { api: basePath, method: request.method },\n invoke,\n parent,\n )\n : await invoke();\n } catch (error) {\n options.onNotice(`package API '${basePath}' failed on ${url.pathname} (${describeError(error)})`);\n response = Response.json({ error: `The '${basePath}' API failed.` }, { status: 500 });\n }\n // A long poll waits before its headers; only time spent after them is a slow flush.\n const headersAt = performance.now();\n return responseWithCompletion(response, (responseBytes) => {\n if (!options.telemetry) return;\n const now = performance.now();\n const durationMs = Math.round(now - startedAt);\n // Keep this span only where it says something the request span cannot: a failing status,\n // a body that took real time to flush after the headers were sent, or a large body.\n if (\n response.status < 400 &&\n now - headersAt < COMPLETION_SPAN_MIN_DURATION_MS &&\n responseBytes < COMPLETION_SPAN_MIN_BYTES\n )\n return;\n const requestBytes = Number(request.headers.get('content-length'));\n observe(\n options.telemetry.runInSpan(\n 'po_server.package_api.complete',\n {\n api: basePath,\n method: request.method,\n status_code: response.status,\n duration_ms: durationMs,\n response_bytes: responseBytes,\n response_kind: contentClass(response.headers.get('content-type')),\n ...(Number.isFinite(requestBytes) && requestBytes > 0 ? { request_bytes: requestBytes } : {}),\n },\n async () => undefined,\n childContext ?? parent,\n ),\n options.onNotice,\n );\n });\n };\n let closePromise: Promise<void> | undefined;\n\n return {\n operation: (basePath, method, path) => scope?.apiOperation(basePath, method, path),\n request: dispatch,\n reconcile,\n close: () => {\n closePromise ??= (async () => {\n await scope.dispose();\n communication?.close();\n host.dispose();\n })();\n return closePromise;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,kCAAkC;;AAE/C,MAAa,4BAA4B;;AAGzC,SAAgB,aAAa,aAAoC;CAC/D,MAAM,OAAO,aAAa,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK;CACjE,IAAI,SAAS,IAAI,OAAO;CACxB,IAAI,KAAK,WAAW,QAAQ,GAAG,OAAO;CACtC,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO;CAClC,IAAI,KAAK,WAAW,OAAO,GAAG,OAAO;CACrC,OAAO;AACT;AAkEA,SAAS,cAAc,OAAwB;CAC7C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,uBAAuB,UAAoB,UAA6C;CAC/F,IAAI,SAAS,SAAS,MAAM;EAC1B,SAAS,CAAC;EACV,OAAO;CACT;CACA,MAAM,SAAS,SAAS,KAAK,UAAU;CACvC,IAAI,YAAY;CAChB,IAAI,QAAQ;CACZ,MAAM,eAAqB;EACzB,IAAI,WAAW;EACf,YAAY;EACZ,SAAS,KAAK;CAChB;CACA,MAAM,OAAO,IAAI,e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ACA;IAAE,KAAK;IAAU,QAAQ,QAAQ;GAAO,GACxC,QACA,MACF,IACA,MAAM,OAAO;EACnB,SAAS,OAAO;GACd,QAAQ,SAAS,gBAAgB,SAAS,cAAc,IAAI,SAAS,IAAI,cAAc,KAAK,EAAE,EAAE;GAChG,WAAW,SAAS,KAAK,EAAE,OAAO,QAAQ,SAAS,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;EACtF;EAEA,MAAM,YAAY,YAAY,IAAI;EAClC,OAAO,uBAAuB,WAAW,kBAAkB;GACzD,IAAI,CAAC,QAAQ,WAAW;GACxB,MAAM,MAAM,YAAY,IAAI;GAC5B,MAAM,aAAa,KAAK,MAAM,MAAM,SAAS;GAG7C,IACE,SAAS,SAAS,OAClB,MAAM,YAAA,OACN,gBAAA,SAEA;GACF,MAAM,eAAe,OAAO,QAAQ,QAAQ,IAAI,gBAAgB,CAAC;GACjE,wBAAA,QACE,QAAQ,UAAU,UAChB,kCACA;IACE,KAAK;IACL,QAAQ,QAAQ;IAChB,aAAa,SAAS;IACtB,aAAa;IACb,gBAAgB;IAChB,eAAe,aAAa,SAAS,QAAQ,IAAI,cAAc,CAAC;IAChE,GAAI,OAAO,SAAS,YAAY,KAAK,eAAe,IAAI,EAAE,eAAe,aAAa,IAAI,CAAC;GAC7F,GACA,YAAY,KAAA,GACZ,gBAAgB,MAClB,GACA,QAAQ,QACV;EACF,CAAC;CACH;CACA,IAAI;CAEJ,OAAO;EACL,YAAY,UAAU,QAAQ,SAAS,OAAO,aAAa,UAAU,QAAQ,IAAI;EACjF,SAAS;EACT;EACA,aAAa;GACX,kBAAkB,YAAY;IAC5B,MAAM,MAAM,QAAQ;IACpB,eAAe,MAAM;IACrB,KAAK,QAAQ;GACf,EAAA,CAAG;GACH,OAAO;EACT;CACF;AACF"}
1
+ {"version":3,"file":"packageApiServer.cjs","names":["SESSION_FILES_API","readAccessibleFile","prepareSessionEnvironment","createPoServerHost","createFileAccess","PO_SESSION_TEMP_DIR","path","PoServerScope","PO_FILE_ACCESS_SERVICE","PO_API_ROUTE_PREFIX","validatedTraceContext","OperationCancelledError"],"sources":["../src/server/packageApiServer.ts"],"sourcesContent":["import path from 'node:path';\n\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { SESSION_FILES_API } from '../constants/sessionFiles';\nimport type { PoDirectEventBus, PoHubSessionPromptOptions, PoHubSessionService } from '../exports/hubChannel';\nimport { PO_API_ROUTE_PREFIX, type PoApi, type PoApiContext } from '../exports/packageApi';\nimport type { PoPlatform } from '../exports/platform';\nimport type { PoPluginRegistry } from '../exports/pluginProtocol';\nimport {\n createPoServerHost,\n type CreatePoServerHostOptions,\n type LoadedServerPackage,\n type PoServerPackageFailure,\n type PoServerPlugin,\n PoServerScope,\n} from '../exports/serverPlugin';\nimport {\n createFileAccess,\n PO_FILE_ACCESS_SERVICE,\n type PoFileAccess,\n readAccessibleFile,\n} from '../services/fileAccess';\nimport type { PoTraceContext } from '../services/poTelemetry';\nimport { observe, type ServerTelemetry } from '../services/serverTelemetry';\nimport { PO_SESSION_TEMP_DIR, prepareSessionEnvironment } from '../services/sessionFiles';\nimport { OperationCancelledError } from '../services/telemetry';\nimport { validatedTraceContext } from '../services/traceContext';\n\n/**\n * A body that keeps streaming well after its headers went out is worth its own span. A fast\n * one is not: the request span already carries the duration and outcome, so emitting a second\n * span per call made package API traffic 99.65% of all spans recorded in a two hour sample.\n */\nexport const COMPLETION_SPAN_MIN_DURATION_MS = 1000;\n/** A body this large is worth a span however fast it flushed: big bodies drive heap spikes. */\nexport const COMPLETION_SPAN_MIN_BYTES = 1024 * 1024;\n\n/** A coarse body class, so a size can be attributed without recording a path or file name. */\nexport function contentClass(contentType: string | null): string {\n const type = contentType?.split(';')[0]?.trim().toLowerCase() ?? '';\n if (type === '') return 'none';\n if (type.startsWith('image/')) return 'image';\n if (type.endsWith('json')) return 'json';\n if (type.startsWith('text/')) return 'text';\n return 'binary';\n}\n\nexport interface PackageApiServerOptions {\n sessionId: string;\n workspaceId?: string;\n workspaceRoot?: string;\n sessionContext?: PoApiContext['sessionContext'];\n clientPlugins?: PoApiContext['clientPlugins'];\n homeDirectory?: string;\n mountChannel?: CreatePoServerHostOptions['mountChannel'];\n cwd: string;\n /** Admitted environment for APIs serving this session. */\n readonly environment: Readonly<Record<string, string | undefined>>;\n /** Lifecycle-owned direct events shared with the hub. */\n readonly directEvents: PoDirectEventBus;\n readonly computerUse?: PoApiContext['computerUse'];\n /** Bound to this session's id and cwd by the host. */\n readonly shareFile?: PoApiContext['shareFile'];\n readonly shareRegisteredFile?: PoApiContext['shareRegisteredFile'];\n readonly mediaArbitration?: PoApiContext['mediaArbitration'];\n readonly executionBudget?: PoApiContext['executionBudget'];\n readonly peerAgents?: PoApiContext['peerAgents'];\n readonly requestApi?: PoApiContext['requestApi'];\n /** Publishes this session's activity line through the hub; bound to this session only. */\n readonly publishActivity?: PoApiContext['publishActivity'];\n internalToken?: string;\n hubToken?: string;\n /** Shared exact-scope dispatch table, so session packages can mount plugin methods. */\n pluginRegistry?: PoPluginRegistry;\n sessionService?: PoHubSessionService;\n apis: readonly PoApi[];\n /** Server packages to install; each registers its own APIs through the host. */\n packages?: readonly (PoServerPlugin | LoadedServerPackage)[];\n /** Publishes the session's own services into its scope root before any package installs. */\n preparePackages?: (root: Context) => void | Promise<void>;\n /** The hub's workspace or global scope; the session's own scope opens below it and closes with it. */\n parentScope?: PoServerScope;\n /** Host capabilities for the session scope root, injected by the composition root. */\n platform: PoPlatform;\n activatePackages?: (installedPackages: readonly string[]) => Promise<void>;\n canDispatch?: () => boolean;\n telemetry?: ServerTelemetry;\n onNotice: (message: string) => void;\n}\n\nexport interface PackageApiServer {\n /** Dispatches an already-authenticated request without crossing a transport boundary. */\n readonly operation?: (basePath: string, method: string, path: string) => string | undefined;\n readonly request: (request: Request) => Promise<Response>;\n /**\n * Brings the session's installed packages up to date: changed and added `packages` install with\n * per-package rollback, and installed ones no longer `declared` are disposed. A declared package\n * whose new build failed to load is absent from `packages` but keeps its running build.\n */\n readonly reconcile?: (\n packages: readonly (PoServerPlugin | LoadedServerPackage)[],\n declared: readonly string[],\n ) => Promise<PackageReconcileResult>;\n close(): Promise<void>;\n}\n\nexport interface PackageReconcileResult {\n readonly installed: readonly string[];\n readonly removed: readonly string[];\n readonly failed: readonly PoServerPackageFailure[];\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction responseWithCompletion(response: Response, complete: (bytes: number) => void): Response {\n if (response.body === null) {\n complete(0);\n return response;\n }\n const reader = response.body.getReader();\n let completed = false;\n let bytes = 0;\n const finish = (): void => {\n if (completed) return;\n completed = true;\n complete(bytes);\n };\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n finish();\n controller.close();\n } else {\n bytes += result.value.byteLength;\n controller.enqueue(result.value);\n }\n } catch (error) {\n finish();\n controller.error(error);\n }\n },\n async cancel(reason) {\n finish();\n await reader.cancel(reason);\n },\n });\n return new Response(body, response);\n}\n\n/** Reads files under the session's open folders; the hub's session `/file` route forwards here. */\nfunction sessionFilesApi(fileAccess: PoFileAccess, cwd: string): PoApi {\n return {\n basePath: SESSION_FILES_API,\n start: () => ({\n fetch: (request) => {\n if (request.method !== 'GET') return Response.json({ error: 'Method not allowed.' }, { status: 405 });\n return readAccessibleFile({\n roots: fileAccess.roots(),\n cwd,\n path: new URL(request.url).searchParams.get('path'),\n ...(request.headers.get('range') === null ? {} : { range: request.headers.get('range')! }),\n ...(request.headers.get('if-match') === null ? {} : { expectedVersion: request.headers.get('if-match')! }),\n });\n },\n close: () => undefined,\n }),\n };\n}\n/** Installs session packages and dispatches authenticated package API calls in-process. */\nexport async function serveSessionApis(options: PackageApiServerOptions): Promise<PackageApiServer> {\n if (options.environment === undefined)\n throw new Error('Session package API server requires an admitted environment.');\n if (options.directEvents === undefined) throw new Error('Session package API server requires direct events.');\n options = { ...options, environment: await prepareSessionEnvironment(options) };\n const packages = options.packages ?? [];\n // Without a level above it, a session that mounts nothing has nothing to route.\n const routesNothing = (): boolean => !options.preparePackages && options.parentScope === undefined;\n if (options.apis.length === 0 && packages.length === 0 && routesNothing()) {\n return {\n request: async () => Response.json({ error: 'No package APIs are mounted.' }, { status: 404 }),\n close: () => Promise.resolve(),\n };\n }\n\n const owningSessionService = options.sessionService;\n const communication = owningSessionService?.bindCommunication?.(options.sessionId);\n const ownedReadExecutionState = owningSessionService?.readExecutionState?.bind(owningSessionService);\n const ownedPrompt = owningSessionService?.prompt?.bind(owningSessionService);\n const ownedAbort = owningSessionService?.abort?.bind(owningSessionService);\n const ownedSteer = owningSessionService?.steer?.bind(owningSessionService);\n const ownedRelease = owningSessionService?.release?.bind(owningSessionService);\n const exposedSessionService: PoHubSessionService | undefined =\n owningSessionService === undefined\n ? undefined\n : {\n create: (request) => owningSessionService.create(request),\n close: (sessionId) => owningSessionService.close(sessionId),\n isLive: (sessionId) => owningSessionService.isLive(sessionId),\n ...(ownedReadExecutionState === undefined\n ? {}\n : {\n readExecutionState: (sessionId: string) =>\n ownedReadExecutionState(sessionId, { parentSessionId: options.sessionId }),\n }),\n // A session may drive only the children it started, never its parent or a sibling.\n ...(ownedPrompt === undefined\n ? {}\n : {\n prompt: (sessionId: string, text: string, promptOptions?: PoHubSessionPromptOptions) =>\n ownedPrompt(sessionId, text, {\n ...(promptOptions?.signal === undefined ? {} : { signal: promptOptions.signal }),\n parentSessionId: options.sessionId,\n }),\n }),\n ...(ownedAbort === undefined\n ? {}\n : {\n abort: (sessionId: string) => ownedAbort(sessionId, { parentSessionId: options.sessionId }),\n }),\n ...(ownedSteer === undefined\n ? {}\n : {\n steer: (sessionId: string, message: string) =>\n ownedSteer(sessionId, message, { parentSessionId: options.sessionId }),\n }),\n ...(ownedRelease === undefined\n ? {}\n : {\n release: (sessionId, releaseOptions) =>\n ownedRelease(sessionId, {\n ...(releaseOptions?.onlyIfIdle === undefined ? {} : { onlyIfIdle: releaseOptions.onlyIfIdle }),\n parentSessionId: options.sessionId,\n }),\n }),\n ...(owningSessionService.canCommunicate === undefined\n ? {}\n : {\n canCommunicate: (sourceSessionId: string, targetSessionId: string) =>\n owningSessionService.canCommunicate?.(sourceSessionId, targetSessionId) === true,\n }),\n };\n const context: PoApiContext = {\n scope: 'session',\n sessionId: options.sessionId,\n workspaceId: options.workspaceId,\n workspaceRoot: options.workspaceRoot,\n ...(options.sessionContext === undefined ? {} : { sessionContext: options.sessionContext }),\n homeDirectory: options.homeDirectory ?? options.platform.homeDirectory,\n sessionStorage: options.platform.sessions,\n cwd: options.cwd,\n environment: options.environment,\n ...(options.clientPlugins === undefined ? {} : { clientPlugins: options.clientPlugins }),\n directEvents: options.directEvents,\n ...(options.computerUse === undefined ? {} : { computerUse: options.computerUse }),\n ...(options.shareFile === undefined ? {} : { shareFile: options.shareFile }),\n ...(options.shareRegisteredFile === undefined ? {} : { shareRegisteredFile: options.shareRegisteredFile }),\n ...(options.mediaArbitration === undefined ? {} : { mediaArbitration: options.mediaArbitration }),\n ...(options.executionBudget === undefined ? {} : { executionBudget: options.executionBudget }),\n ...(options.peerAgents === undefined ? {} : { peerAgents: options.peerAgents }),\n ...(options.requestApi === undefined ? {} : { requestApi: options.requestApi }),\n ...(options.publishActivity === undefined ? {} : { publishActivity: options.publishActivity }),\n ...(options.internalToken === undefined ? {} : { internalToken: options.internalToken }),\n ...(options.hubToken === undefined ? {} : { hubToken: options.hubToken }),\n ...(exposedSessionService === undefined ? {} : { sessionService: exposedSessionService }),\n ...(communication === undefined ? {} : { sessionCommunication: communication }),\n onNotice: options.onNotice,\n };\n const host = createPoServerHost({\n scope: 'session',\n context,\n mountChannel: options.mountChannel,\n ...(options.pluginRegistry === undefined ? {} : { pluginRegistry: options.pluginRegistry }),\n });\n // The session's own folder, its workspace and the temp folders of every session under this Po home;\n // extensions open their own beside these.\n const fileAccess = createFileAccess();\n const tempDirectory = options.environment[PO_SESSION_TEMP_DIR];\n const sessionsTemp =\n tempDirectory !== undefined && path.basename(path.dirname(tempDirectory)) === 'sessions'\n ? path.dirname(tempDirectory)\n : tempDirectory;\n for (const directory of [options.cwd, options.workspaceRoot, sessionsTemp])\n if (directory !== undefined && path.isAbsolute(directory)) fileAccess.register(directory);\n let scope: PoServerScope | undefined;\n const installOptions = (failed?: PoServerPackageFailure[]) => ({\n onNotice: options.onNotice,\n ...(failed === undefined ? {} : { onPackageFailed: (failure: PoServerPackageFailure) => failed.push(failure) }),\n onPackageSettled: (report: { packageName: string; outcome: string; durationMs: number }) => {\n if (!options.telemetry) return;\n observe(\n options.telemetry.recordEvent('po_server.package_install', {\n 'package.name': report.packageName,\n 'package.outcome': report.outcome,\n duration_ms: report.durationMs,\n scope: 'session',\n }),\n options.onNotice,\n );\n },\n });\n try {\n // Registered first, so no package can claim the host's own base path.\n host.registerApi(sessionFilesApi(fileAccess, options.cwd));\n for (const api of options.apis) host.registerApi(api);\n // The session's own level of the server IoC tree; it closes with the hub level it opens below.\n scope = await PoServerScope.open('session', options.parentScope);\n await scope.serve({ host, platform: options.platform });\n await scope.root.plugin((root) => {\n root.provide(PO_FILE_ACCESS_SERVICE, fileAccess);\n });\n await options.preparePackages?.(scope.root);\n const installed = await scope.install(packages, installOptions());\n await options.activatePackages?.(installed);\n } catch (error) {\n await scope?.dispose();\n communication?.close();\n host.dispose();\n throw error;\n }\n if (host.mounted().length === 0 && routesNothing()) {\n await scope.dispose();\n communication?.close();\n host.dispose();\n return {\n request: async () => Response.json({ error: 'No package APIs are mounted.' }, { status: 404 }),\n close: () => Promise.resolve(),\n };\n }\n const sessionScope = scope;\n const reconcile = async (\n next: readonly (PoServerPlugin | LoadedServerPackage)[],\n declared: readonly string[],\n ): Promise<PackageReconcileResult> => {\n const failed: PoServerPackageFailure[] = [];\n const installed = await sessionScope.install(next, installOptions(failed));\n const removed = installed.filter((name) => !declared.includes(name));\n return { installed: await sessionScope.uninstall(removed), removed, failed };\n };\n\n const dispatch = async (request: Request): Promise<Response> => {\n if (options.canDispatch?.() === false)\n return Response.json({ error: 'Session selection is not ready.' }, { status: 503 });\n const url = new URL(request.url);\n if (!url.pathname.startsWith(`${PO_API_ROUTE_PREFIX}/`))\n return Response.json({ error: 'Not found.' }, { status: 404 });\n const rest = url.pathname.slice(PO_API_ROUTE_PREFIX.length + 1);\n const slash = rest.indexOf('/');\n const basePath = slash === -1 ? rest : rest.slice(0, slash);\n // The session's own API, else the nearest level above it that serves one.\n const handler = sessionScope.apiHandler(basePath);\n if (handler === undefined)\n return Response.json({ error: `No API '${basePath}' in this session.` }, { status: 404 });\n url.pathname = slash === -1 ? '/' : rest.slice(slash);\n const startedAt = performance.now();\n const parent = validatedTraceContext(request.headers.get('traceparent'));\n let childContext: PoTraceContext | undefined;\n let response: Response;\n try {\n const invoke = async (context?: PoTraceContext): Promise<Response> => {\n if (options.canDispatch?.() === false || sessionScope.apiHandler(basePath) !== handler) {\n return Response.json({ error: 'Session selection changed before dispatch.' }, { status: 503 });\n }\n childContext = context;\n const incoming = new Request(url, request);\n try {\n return await handler.fetch(incoming);\n } catch (error) {\n if (incoming.signal.aborted && (error === incoming.signal.reason || error instanceof OperationCancelledError))\n return new Response(null, { status: 499 });\n throw error;\n }\n };\n response = options.telemetry\n ? await options.telemetry.runInSpan(\n 'po_server.package_api.request',\n { api: basePath, method: request.method },\n invoke,\n parent,\n )\n : await invoke();\n } catch (error) {\n options.onNotice(`package API '${basePath}' failed on ${url.pathname} (${describeError(error)})`);\n response = Response.json({ error: `The '${basePath}' API failed.` }, { status: 500 });\n }\n // A long poll waits before its headers; only time spent after them is a slow flush.\n const headersAt = performance.now();\n return responseWithCompletion(response, (responseBytes) => {\n if (!options.telemetry) return;\n const now = performance.now();\n const durationMs = Math.round(now - startedAt);\n // Keep this span only where it says something the request span cannot: a failing status,\n // a body that took real time to flush after the headers were sent, or a large body.\n if (\n response.status < 400 &&\n now - headersAt < COMPLETION_SPAN_MIN_DURATION_MS &&\n responseBytes < COMPLETION_SPAN_MIN_BYTES\n )\n return;\n const requestBytes = Number(request.headers.get('content-length'));\n observe(\n options.telemetry.runInSpan(\n 'po_server.package_api.complete',\n {\n api: basePath,\n method: request.method,\n status_code: response.status,\n duration_ms: durationMs,\n response_bytes: responseBytes,\n response_kind: contentClass(response.headers.get('content-type')),\n ...(Number.isFinite(requestBytes) && requestBytes > 0 ? { request_bytes: requestBytes } : {}),\n },\n async () => undefined,\n childContext ?? parent,\n ),\n options.onNotice,\n );\n });\n };\n let closePromise: Promise<void> | undefined;\n\n return {\n operation: (basePath, method, path) => scope?.apiOperation(basePath, method, path),\n request: dispatch,\n reconcile,\n close: () => {\n closePromise ??= (async () => {\n await scope.dispose();\n communication?.close();\n host.dispose();\n })();\n return closePromise;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,kCAAkC;;AAE/C,MAAa,4BAA4B;;AAGzC,SAAgB,aAAa,aAAoC;CAC/D,MAAM,OAAO,aAAa,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK;CACjE,IAAI,SAAS,IAAI,OAAO;CACxB,IAAI,KAAK,WAAW,QAAQ,GAAG,OAAO;CACtC,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO;CAClC,IAAI,KAAK,WAAW,OAAO,GAAG,OAAO;CACrC,OAAO;AACT;AAmEA,SAAS,cAAc,OAAwB;CAC7C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,uBAAuB,UAAoB,UAA6C;CAC/F,IAAI,SAAS,SAAS,MAAM;EAC1B,SAAS,CAAC;EACV,OAAO;CACT;CACA,MAAM,SAAS,SAAS,KAAK,UAAU;CACvC,IAAI,YAAY;CAChB,IAAI,QAAQ;CACZ,MAAM,eAAqB;EACzB,IAAI,WAAW;EACf,YAAY;EACZ,SAAS,KAAK;CAChB;CACA,MAAM,OAAO,IAAI,eAA2B;EAC1C,MAAM,KAAK,YAAY;GACrB,IAAI;IACF,MAAM,SAAS,MAA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AAU,UACtB,iCACA;IAAE,KAAK;IAAU,QAAQ,QAAQ;GAAO,GACxC,QACA,MACF,IACA,MAAM,OAAO;EACnB,SAAS,OAAO;GACd,QAAQ,SAAS,gBAAgB,SAAS,cAAc,IAAI,SAAS,IAAI,cAAc,KAAK,EAAE,EAAE;GAChG,WAAW,SAAS,KAAK,EAAE,OAAO,QAAQ,SAAS,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;EACtF;EAEA,MAAM,YAAY,YAAY,IAAI;EAClC,OAAO,uBAAuB,WAAW,kBAAkB;GACzD,IAAI,CAAC,QAAQ,WAAW;GACxB,MAAM,MAAM,YAAY,IAAI;GAC5B,MAAM,aAAa,KAAK,MAAM,MAAM,SAAS;GAG7C,IACE,SAAS,SAAS,OAClB,MAAM,YAAA,OACN,gBAAA,SAEA;GACF,MAAM,eAAe,OAAO,QAAQ,QAAQ,IAAI,gBAAgB,CAAC;GACjE,wBAAA,QACE,QAAQ,UAAU,UAChB,kCACA;IACE,KAAK;IACL,QAAQ,QAAQ;IAChB,aAAa,SAAS;IACtB,aAAa;IACb,gBAAgB;IAChB,eAAe,aAAa,SAAS,QAAQ,IAAI,cAAc,CAAC;IAChE,GAAI,OAAO,SAAS,YAAY,KAAK,eAAe,IAAI,EAAE,eAAe,aAAa,IAAI,CAAC;GAC7F,GACA,YAAY,KAAA,GACZ,gBAAgB,MAClB,GACA,QAAQ,QACV;EACF,CAAC;CACH;CACA,IAAI;CAEJ,OAAO;EACL,YAAY,UAAU,QAAQ,SAAS,OAAO,aAAa,UAAU,QAAQ,IAAI;EACjF,SAAS;EACT;EACA,aAAa;GACX,kBAAkB,YAAY;IAC5B,MAAM,MAAM,QAAQ;IACpB,eAAe,MAAM;IACrB,KAAK,QAAQ;GACf,EAAA,CAAG;GACH,OAAO;EACT;CACF;AACF"}
@@ -29,6 +29,7 @@ export interface PackageApiServerOptions {
29
29
  workspaceId?: string;
30
30
  workspaceRoot?: string;
31
31
  sessionContext?: PoApiContext['sessionContext'];
32
+ clientPlugins?: PoApiContext['clientPlugins'];
32
33
  homeDirectory?: string;
33
34
  mountChannel?: CreatePoServerHostOptions['mountChannel'];
34
35
  cwd: string;
@@ -1 +1 @@
1
- {"version":3,"file":"packageApiServer.d.mts","names":[],"sources":["../src/server/packageApiServer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAkCa;;qBAEA;;wBAGG,aAAa;iBASZ;EACf;EACA;EACA;EACA,iBAAiB;EACjB;EACA,eAAe;EACf;;WAES,aAAa,SAAS;;WAEtB,cAAc;WACd,cAAc;;WAEd,YAAY;WACZ,sBAAsB;WACtB,mBAAmB;WACnB,kBAAkB;WAClB,aAAa;WACb,aAAa;;WAEb,kBAAkB;EAC3B;EACA;;EAEA,iBAAiB;EACjB,iBAAiB;EACjB,eAAe;;EAEf,qBAAqB,iBAAiB;;EAEtC,mBAAmB,MAAM,mBAAmB;;EAE5C,cAAc;;EAEd,UAAU;EACV,oBAAoB,yCAAyC;EAC7D;EACA,YAAY;EACZ,WAAW;;iBAGI;;WAEN,aAAa,kBAAkB,gBAAgB;WAC/C,UAAU,SAAS,YAAY,QAAQ;;;;;;WAMvC,aACP,oBAAoB,iBAAiB,wBACrC,gCACG,QAAQ;EACb,SAAS;;iBAGM;WACN;WACA;WACA,iBAAiB;;;wBAgEN,iBAAiB,SAAS,0BAA0B,QAAQ"}
1
+ {"version":3,"file":"packageApiServer.d.mts","names":[],"sources":["../src/server/packageApiServer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAkCa;;qBAEA;;wBAGG,aAAa;iBASZ;EACf;EACA;EACA;EACA,iBAAiB;EACjB,gBAAgB;EAChB;EACA,eAAe;EACf;;WAES,aAAa,SAAS;;WAEtB,cAAc;WACd,cAAc;;WAEd,YAAY;WACZ,sBAAsB;WACtB,mBAAmB;WACnB,kBAAkB;WAClB,aAAa;WACb,aAAa;;WAEb,kBAAkB;EAC3B;EACA;;EAEA,iBAAiB;EACjB,iBAAiB;EACjB,eAAe;;EAEf,qBAAqB,iBAAiB;;EAEtC,mBAAmB,MAAM,mBAAmB;;EAE5C,cAAc;;EAEd,UAAU;EACV,oBAAoB,yCAAyC;EAC7D;EACA,YAAY;EACZ,WAAW;;iBAGI;;WAEN,aAAa,kBAAkB,gBAAgB;WAC/C,UAAU,SAAS,YAAY,QAAQ;;;;;;WAMvC,aACP,oBAAoB,iBAAiB,wBACrC,gCACG,QAAQ;EACb,SAAS;;iBAGM;WACN;WACA;WACA,iBAAiB;;;wBAgEN,iBAAiB,SAAS,0BAA0B,QAAQ"}
@@ -135,6 +135,7 @@ async function serveSessionApis(options) {
135
135
  sessionStorage: options.platform.sessions,
136
136
  cwd: options.cwd,
137
137
  environment: options.environment,
138
+ ...options.clientPlugins === void 0 ? {} : { clientPlugins: options.clientPlugins },
138
139
  directEvents: options.directEvents,
139
140
  ...options.computerUse === void 0 ? {} : { computerUse: options.computerUse },
140
141
  ...options.shareFile === void 0 ? {} : { shareFile: options.shareFile },