@agimon-ai/po-author 0.0.0-alpha.32 → 0.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ node_path = require_structuredDocuments.__toESM(node_path, 1);
12
12
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
13
13
  let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
14
14
  let hono = require("hono");
15
+ let node_fs = require("node:fs");
15
16
  let node_fs_promises = require("node:fs/promises");
16
17
  node_fs_promises = require_structuredDocuments.__toESM(node_fs_promises, 1);
17
18
  let _agimon_ai_po_artifact_artifactFiles = require("@agimon-ai/po-artifact/artifactFiles");
@@ -82,13 +83,13 @@ function inside(root, candidate) {
82
83
  * may read. It is named either `artifact:<relative>` or by the absolute path the
83
84
  * agent's prompt gives; po-artifact's guarded open does the containment checks.
84
85
  */
85
- async function resolveArtifact(requestedPath, sessionId) {
86
+ async function resolveArtifact(requestedPath, sessionId, environment) {
86
87
  const prefixed = requestedPath.startsWith(require_structuredDocuments.AUTHOR_ARTIFACT_PREFIX);
87
- if (sessionId === void 0) {
88
+ if (sessionId === void 0 || environment === void 0) {
88
89
  if (prefixed) throw new require_structuredDocuments.DocumentRequestError("Artifacts need a session.", 400);
89
90
  return;
90
91
  }
91
- const root = (0, _agimon_ai_po_artifact_artifactFiles.artifactRoot)(sessionId, process.env);
92
+ const root = (0, _agimon_ai_po_artifact_artifactFiles.artifactRoot)(sessionId, environment);
92
93
  if (prefixed) return {
93
94
  root,
94
95
  relative: requestedPath.slice(require_structuredDocuments.AUTHOR_ARTIFACT_PREFIX.length)
@@ -101,9 +102,9 @@ async function resolveArtifact(requestedPath, sessionId) {
101
102
  relative: node_path.default.relative(base, requestedPath).split(node_path.default.sep).join("/")
102
103
  };
103
104
  }
104
- async function resolveDocument(cwd, requestedPath, sessionId) {
105
+ async function resolveDocument(cwd, requestedPath, sessionId, environment) {
105
106
  if (typeof requestedPath !== "string" || requestedPath.length === 0 || requestedPath.includes("\0")) throw new Error("A relative document path is required.");
106
- const artifact = await resolveArtifact(requestedPath, sessionId);
107
+ const artifact = await resolveArtifact(requestedPath, sessionId, environment);
107
108
  if (artifact !== void 0) {
108
109
  const realRoot = await node_fs_promises.default.realpath(artifact.root).catch(() => artifact.root);
109
110
  return {
@@ -121,6 +122,7 @@ async function resolveDocument(cwd, requestedPath, sessionId) {
121
122
  if (realCandidate !== root && !realCandidate.startsWith(`${root}${node_path.default.sep}`)) throw new require_structuredDocuments.DocumentRequestError("Document path is outside the working directory.", 403);
122
123
  return {
123
124
  kind: "workspace",
125
+ root,
124
126
  path: node_path.default.relative(root, realCandidate).split(node_path.default.sep).join("/"),
125
127
  realPath: realCandidate
126
128
  };
@@ -142,16 +144,27 @@ async function readArtifact(root, relative) {
142
144
  }
143
145
  async function readSource(source) {
144
146
  if (source.kind === "artifact") return await readArtifact(source.root, source.relative);
145
- if ((await node_fs_promises.default.stat(source.realPath)).size > 26214400) throw require_structuredDocuments.documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);
146
- return await node_fs_promises.default.readFile(source.realPath);
147
+ if (process.platform !== "darwin" && process.platform !== "linux") throw new require_structuredDocuments.DocumentRequestError("Secure document reads require macOS or Linux.", 403);
148
+ const noFollow = process.platform === "darwin" ? 536870912 : node_fs.constants.O_NOFOLLOW;
149
+ const handle = await node_fs_promises.default.open(source.realPath, node_fs.constants.O_RDONLY | node_fs.constants.O_NONBLOCK | noFollow);
150
+ try {
151
+ const stat = await handle.stat();
152
+ const current = await node_fs_promises.default.lstat(source.realPath);
153
+ const realPath = await node_fs_promises.default.realpath(process.platform === "linux" ? `/proc/self/fd/${handle.fd}` : source.realPath);
154
+ if (!stat.isFile() || !current.isFile() || stat.dev !== current.dev || stat.ino !== current.ino || !inside(source.root, realPath)) throw new require_structuredDocuments.DocumentRequestError("The document changed or is outside the working directory.", 403);
155
+ if (stat.size > 26214400) throw require_structuredDocuments.documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);
156
+ return await (0, _agimon_ai_po_artifact_artifactFiles.readArtifactBytes)(handle, stat.size);
157
+ } finally {
158
+ await handle.close();
159
+ }
147
160
  }
148
- async function readDocument(cwd, requestedPath, sessionId) {
149
- return await readSource(await resolveDocument(cwd, requestedPath, sessionId));
161
+ async function readDocument(cwd, requestedPath, sessionId, environment) {
162
+ return await readSource(await resolveDocument(cwd, requestedPath, sessionId, environment));
150
163
  }
151
164
  //#endregion
152
165
  //#region src/services/authorCanvasRegistry/index.ts
153
166
  const MAX_CANVASES = 32;
154
- function createAuthorCanvasRegistry(cwd, createBridge, sessionId) {
167
+ function createAuthorCanvasRegistry(cwd, createBridge, sessionId, environment) {
155
168
  const byAlias = /* @__PURE__ */ new Map();
156
169
  const byPath = /* @__PURE__ */ new Map();
157
170
  const select = (alias) => {
@@ -191,7 +204,7 @@ function createAuthorCanvasRegistry(cwd, createBridge, sessionId) {
191
204
  async open(requestedPath, signal, requestedAlias) {
192
205
  signal?.throwIfAborted();
193
206
  if (requestedAlias !== void 0 && !require_structuredDocuments.AUTHOR_ALIAS_PATTERN.test(requestedAlias)) throw new require_structuredDocuments.AuthorBridgeError("Invalid Author canvas alias.", 400);
194
- const source = await resolveDocument(cwd, requestedPath, sessionId);
207
+ const source = await resolveDocument(cwd, requestedPath, sessionId, environment);
195
208
  const bytes = await readSource(source);
196
209
  signal?.throwIfAborted();
197
210
  const { realPath, path: canonicalPath } = source;
@@ -517,7 +530,7 @@ function createAuthorDocumentApi(options = {}) {
517
530
  try {
518
531
  const body = await bodyOf(context.req.raw);
519
532
  if (body.format === void 0 && options.open !== void 0) return context.json(await options.open(body.path, context.req.raw.signal, body.alias));
520
- const bytes = await readDocument(cwd, body.path, options.sessionId);
533
+ const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);
521
534
  if (body.format === void 0) return context.json({
522
535
  path: body.path,
523
536
  byteLength: bytes.byteLength
@@ -530,7 +543,7 @@ function createAuthorDocumentApi(options = {}) {
530
543
  app.post(apiRoutes_default.documentsPreflight.path, async (context) => {
531
544
  try {
532
545
  const body = await bodyOf(context.req.raw);
533
- const bytes = await readDocument(cwd, body.path, options.sessionId);
546
+ const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);
534
547
  return context.json(await require_structuredDocuments.preflightStructuredDocument(requestFormat(body.format), bytes, requestOperations(body.operations), body.csvDialect));
535
548
  } catch (error) {
536
549
  return errorResponse(context, error);
@@ -540,7 +553,7 @@ function createAuthorDocumentApi(options = {}) {
540
553
  try {
541
554
  const body = await bodyOf(context.req.raw);
542
555
  if (typeof body.preflightDigest !== "string") throw new Error("A preflight report digest is required.");
543
- const bytes = await readDocument(cwd, body.path, options.sessionId);
556
+ const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);
544
557
  const serialized = await require_structuredDocuments.serializeStructuredDocument(requestFormat(body.format), bytes, requestOperations(body.operations), body.preflightDigest, body.csvDialect);
545
558
  return context.json({
546
559
  bytes: Buffer.from(serialized.bytes).toString("base64"),
@@ -571,7 +584,7 @@ const createBridge = () => require_structuredDocuments.createAuthorBridgeState({
571
584
  });
572
585
  function createAuthorApi(options = {}) {
573
586
  const app = new hono.Hono();
574
- const registry = options.registry ?? createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId);
587
+ const registry = options.registry ?? createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId, options.environment);
575
588
  app.get(apiRoutes_default.state.path, (context) => context.json({
576
589
  sessionId: options.sessionId ?? null,
577
590
  ...(options.readState ?? inactiveState)()
@@ -580,6 +593,7 @@ function createAuthorApi(options = {}) {
580
593
  app.route("/", createAuthorDocumentApi({
581
594
  ...options.cwd === void 0 ? {} : { cwd: options.cwd },
582
595
  ...options.sessionId === void 0 ? {} : { sessionId: options.sessionId },
596
+ ...options.environment === void 0 ? {} : { environment: options.environment },
583
597
  open: (path, signal, alias) => registry.open(path, signal, alias)
584
598
  }));
585
599
  return app;
@@ -588,10 +602,11 @@ const api = {
588
602
  basePath: API_BASE_PATH,
589
603
  start(context) {
590
604
  if (context.cwd === void 0) throw new Error("Author requires the session working directory.");
591
- const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId);
605
+ const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId, context.environment);
592
606
  const app = createAuthorApi({
593
607
  ...context.sessionId === void 0 ? {} : { sessionId: context.sessionId },
594
608
  cwd: context.cwd,
609
+ ...context.environment === void 0 ? {} : { environment: context.environment },
595
610
  registry
596
611
  });
597
612
  return {
@@ -601,8 +616,8 @@ const api = {
601
616
  }
602
617
  };
603
618
  /** The session API and tools share the same browser ownership and pending requests. */
604
- function createAuthorSessionApi(cwd, sessionId) {
605
- const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId);
619
+ function createAuthorSessionApi(cwd, sessionId, environment) {
620
+ const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId, environment);
606
621
  return {
607
622
  catalog: {
608
623
  open: (path, signal, alias) => registry.open(path, signal, alias),
@@ -618,6 +633,7 @@ function createAuthorSessionApi(cwd, sessionId) {
618
633
  const app = createAuthorApi({
619
634
  cwd,
620
635
  sessionId,
636
+ environment,
621
637
  registry
622
638
  });
623
639
  return {
@@ -630,8 +646,10 @@ function createAuthorSessionApi(cwd, sessionId) {
630
646
  }
631
647
  //#endregion
632
648
  //#region src/extensions/workspaces/sessions/(backend)/root.server.ts
633
- var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ agent, signal }) => {
634
- const session = agent ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId) : void 0;
649
+ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ agent, host, signal }) => {
650
+ const environment = host.context.environment;
651
+ if (agent && environment === void 0) throw new Error("Author requires an admitted session environment.");
652
+ const session = agent && environment ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId, environment) : void 0;
635
653
  const isActive = () => (agent?.context.selection.state?.["minor-mode"] ?? []).includes(require_structuredDocuments.authorMinorMode.descriptor.id);
636
654
  const mode = agent ? require_structuredDocuments.authorMinorMode.createOwner({
637
655
  isActive,
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["parseDescribeAuthorToolsInput","parseUseAuthorToolInput","path","AUTHOR_ARTIFACT_PREFIX","DocumentRequestError","artifactRoot","fs","openArtifact","ArtifactAccessError","documentTooLarge","readArtifactBytes","AUTHOR_ALIAS_PATTERN","AuthorBridgeError","path","defineApiRoutes","apiResponse","AuthorBridgeError","Hono","routes","parseUseAuthorToolInput","DocumentRequestError","Hono","routes","parseStructuredDocument","preflightStructuredDocument","serializeStructuredDocument","createAuthorBridgeState","randomUUID","Hono","routes","defineRoot","authorMinorMode","createAuthorCatalog","PO_CODEMODE_SERVICE","readPoCodemode","serverMinorModes","routes","AUTHOR_ALIAS_PATTERN","defineChannel","defineServerMethod","authorBridgeMethod","defineMethod","defineRoute","defineRoutedCommand","createAuthorCommand","defineHook","AUTHOR_GUIDANCE","defineResource","packageResourcePath","readPackageResource","defineResource","packageResourcePath","readPackageResource","defineTool","createAuthorTools","AUTHOR_TOOL_WHEN","defineTool","createAuthorTools","AUTHOR_TOOL_WHEN","defineTool","createAuthorTools","AUTHOR_TOOL_WHEN","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","channelAuthorWebmcp","methodBridge","composeRootHooks","apiRoute","commandAuthor","hookBeforeAgentStart","resourceCodemodeHowToAuthor","resourcePoUseAuthor","toolDescribeAuthorTools","toolOpenAuthoringFile","toolUseAuthorTools"],"sources":["../../src/services/webmcpNamespace/index.ts","../../src/services/structuredDocuments/document.ts","../../src/services/authorCanvasRegistry/index.ts","../../src/types/apiRoutes.ts","../../src/types/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorBridgeApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorDocumentApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/types/webAuthor.ts","../../src/services/webAuthorChannel/index.ts","../../src/extensions/(backend)/channel/author-webmcp.server.ts","../../src/services/authorBridgeMethod/index.ts","../../src/extensions/(backend)/method/bridge.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/author.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server.ts","../../generated/server.ts"],"sourcesContent":["import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\n\nimport { parseDescribeAuthorToolsInput, parseUseAuthorToolInput } from '../../schemas/authorTools';\nimport type { AuthorCatalog } from '../authorCatalog/type';\n\n// ponytail: typed per-canvas members need a synchronous catalog reader and a shared schema converter in po-core.\nconst DECLARATIONS = `interface AuthorViewportCatalogSnapshot {\n catalogToken: string;\n tools: { name: string; label: string; description: string; inputSchema: Readonly<Record<string, unknown>> }[];\n canvases?: { alias: string; path: string; status: 'opening' | 'ready' | 'unavailable' }[];\n alias?: string;\n path?: string;\n status?: 'opening' | 'ready' | 'unavailable';\n nextStep?: string;\n}\ndeclare const webmcp: {\n /** Ready canvases, or one canvas's tools and its catalog token. */\n describe(input?: { alias?: string }): Promise<AuthorViewportCatalogSnapshot>;\n /** Call one tool with an explicit current token. Await same-canvas calls sequentially. */\n call(input: { alias?: string; catalogToken: string; name: string; arguments: Record<string, unknown> }): Promise<unknown>;\n};`;\n\nfunction copy<T>(value: T): T {\n return value === undefined ? value : JSON.parse(JSON.stringify(value));\n}\n\nexport function createWebmcpNamespace(\n catalog: AuthorCatalog,\n sessionId: string,\n assertAvailable: () => void,\n): PoCodemodeNamespace {\n return {\n name: 'webmcp',\n summary:\n 'Author canvas WebMCP: describe catalogs, then call one tool with its explicit token. Await same-canvas calls sequentially; structured errors remain data.',\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== sessionId) throw new Error('Author WebMCP namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n run.signal.throwIfAborted();\n if (disposed) throw new Error('Author WebMCP run is disposed.');\n assertAvailable();\n };\n const members: Record<string, unknown> = Object.create(null);\n members.describe = async (input?: unknown) => {\n check();\n const { alias } = parseDescribeAuthorToolsInput(copy(input === undefined ? {} : input));\n const result = await catalog.describe(run.signal, alias);\n check();\n return copy(result);\n };\n members.call = async (input: unknown) => {\n check();\n const parsed = parseUseAuthorToolInput(copy(input));\n const result = await catalog.execute(parsed, run.signal);\n check();\n return copy(result.result);\n };\n return members;\n },\n };\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n ArtifactAccessError,\n artifactRoot,\n openArtifact,\n readArtifactBytes,\n} from '@agimon-ai/po-artifact/artifactFiles';\n\nimport { AUTHOR_ARTIFACT_PREFIX } from '../../constants/author';\nimport { DocumentRequestError, documentTooLarge } from './common';\n\nexport const AUTHOR_DOCUMENT_MAX_BYTES = 25 * 1024 * 1024;\n\n/**\n * Where a requested document lives. `path` is the canonical form clients use;\n * `realPath` identifies the file so two spellings share one canvas.\n */\nexport type AuthorDocumentSource =\n | { kind: 'workspace'; path: string; realPath: string }\n | { kind: 'artifact'; path: string; realPath: string; root: string; relative: string };\n\nfunction inside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);\n}\n\n/**\n * The session artifact folder is the one place outside the working tree Author\n * may read. It is named either `artifact:<relative>` or by the absolute path the\n * agent's prompt gives; po-artifact's guarded open does the containment checks.\n */\nasync function resolveArtifact(requestedPath: string, sessionId: string | undefined) {\n const prefixed = requestedPath.startsWith(AUTHOR_ARTIFACT_PREFIX);\n if (sessionId === undefined) {\n if (prefixed) throw new DocumentRequestError('Artifacts need a session.', 400);\n return undefined;\n }\n const root = artifactRoot(sessionId, process.env);\n if (prefixed) return { root, relative: requestedPath.slice(AUTHOR_ARTIFACT_PREFIX.length) };\n if (!path.isAbsolute(requestedPath)) return undefined;\n const realRoot = await fs.realpath(root).catch(() => root);\n const base = [root, realRoot].find((candidate) => inside(candidate, requestedPath));\n if (base === undefined) return undefined;\n return { root, relative: path.relative(base, requestedPath).split(path.sep).join('/') };\n}\n\nexport async function resolveDocument(\n cwd: string,\n requestedPath: unknown,\n sessionId?: string,\n): Promise<AuthorDocumentSource> {\n if (typeof requestedPath !== 'string' || requestedPath.length === 0 || requestedPath.includes('\\0'))\n throw new Error('A relative document path is required.');\n const artifact = await resolveArtifact(requestedPath, sessionId);\n if (artifact !== undefined) {\n const realRoot = await fs.realpath(artifact.root).catch(() => artifact.root);\n return {\n kind: 'artifact',\n path: `${AUTHOR_ARTIFACT_PREFIX}${artifact.relative}`,\n realPath: path.join(realRoot, artifact.relative),\n ...artifact,\n };\n }\n if (path.isAbsolute(requestedPath))\n throw new Error('A relative document path, or a file in the session artifact folder, is required.');\n const root = await fs.realpath(cwd);\n const candidate = path.resolve(root, requestedPath);\n if (candidate !== root && !candidate.startsWith(`${root}${path.sep}`))\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n const realCandidate = await fs.realpath(candidate);\n if (realCandidate !== root && !realCandidate.startsWith(`${root}${path.sep}`)) {\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n }\n return {\n kind: 'workspace',\n path: path.relative(root, realCandidate).split(path.sep).join('/'),\n realPath: realCandidate,\n };\n}\n\nasync function readArtifact(root: string, relative: string): Promise<Uint8Array> {\n let file: Awaited<ReturnType<typeof openArtifact>>;\n try {\n file = await openArtifact(root, relative);\n } catch (error) {\n if (error instanceof ArtifactAccessError) throw new DocumentRequestError(error.message, error.status);\n throw error;\n }\n try {\n if (file.stat.size > AUTHOR_DOCUMENT_MAX_BYTES)\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n return await readArtifactBytes(file.handle, file.stat.size);\n } finally {\n await file.handle.close();\n }\n}\n\nexport async function readSource(source: AuthorDocumentSource): Promise<Uint8Array> {\n if (source.kind === 'artifact') return await readArtifact(source.root, source.relative);\n const stat = await fs.stat(source.realPath);\n if (stat.size > AUTHOR_DOCUMENT_MAX_BYTES) {\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n }\n return await fs.readFile(source.realPath);\n}\n\nexport async function readDocument(cwd: string, requestedPath: unknown, sessionId?: string): Promise<Uint8Array> {\n return await readSource(await resolveDocument(cwd, requestedPath, sessionId));\n}\n","import path from 'node:path';\n\nimport { AuthorBridgeError, type AuthorBridgeState } from '../../models/authorBridgeState';\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport type {\n AuthorCanvasView,\n AuthorOpenFileResult,\n AuthorViewportCatalogSnapshot,\n UseAuthorToolInput,\n} from '../../types/author';\nimport { readSource, resolveDocument } from '../structuredDocuments/document';\n\ninterface Canvas {\n alias: string;\n path: string;\n realPath: string;\n bridge: AuthorBridgeState;\n closed: boolean;\n readyOnce: boolean;\n}\n\nconst MAX_CANVASES = 32;\n\nexport function createAuthorCanvasRegistry(\n cwd: string,\n createBridge: () => AuthorBridgeState,\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string,\n) {\n const byAlias = new Map<string, Canvas>();\n const byPath = new Map<string, Canvas>();\n\n const select = (alias?: string): Canvas => {\n if (alias !== undefined) {\n if (!AUTHOR_ALIAS_PATTERN.test(alias)) throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const canvas = byAlias.get(alias);\n if (canvas === undefined)\n throw new AuthorBridgeError(\n `Unknown Author canvas '${alias}'. Call describe_author_tools({}) for available aliases.`,\n 404,\n );\n return canvas;\n }\n const canvases = [...byAlias.values()].filter((canvas) => !canvas.closed);\n if (canvases.length !== 1)\n throw new AuthorBridgeError('Specify a canvas alias. Call describe_author_tools({}) to list canvases.', 409);\n return canvases[0]!;\n };\n\n const view = (canvas: Canvas): AuthorCanvasView => {\n if (canvas.closed) return { alias: canvas.alias, path: canvas.path, status: 'unavailable' };\n try {\n canvas.bridge.describe();\n canvas.readyOnce = true;\n return { alias: canvas.alias, path: canvas.path, status: 'ready' };\n } catch {\n return { alias: canvas.alias, path: canvas.path, status: canvas.readyOnce ? 'unavailable' : 'opening' };\n }\n };\n\n return {\n async open(requestedPath: string, signal?: AbortSignal, requestedAlias?: string): Promise<AuthorOpenFileResult> {\n signal?.throwIfAborted();\n if (requestedAlias !== undefined && !AUTHOR_ALIAS_PATTERN.test(requestedAlias))\n throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const source = await resolveDocument(cwd, requestedPath, sessionId);\n const bytes = await readSource(source);\n signal?.throwIfAborted();\n const { realPath, path: canonicalPath } = source;\n const occupied = requestedAlias === undefined ? undefined : byAlias.get(requestedAlias);\n if (occupied !== undefined && occupied.realPath !== realPath)\n throw new AuthorBridgeError(`Author canvas alias '${requestedAlias}' already names ${occupied.path}.`, 409);\n const existing = byPath.get(realPath);\n if (existing !== undefined) {\n if (existing.closed) existing.readyOnce = false;\n existing.closed = false;\n return {\n path: existing.path,\n byteLength: bytes.byteLength,\n alias: existing.alias,\n status: view(existing).status,\n reused: true,\n };\n }\n if (byAlias.size >= MAX_CANVASES) {\n const reusable = [...byAlias.values()].find((canvas) => canvas.closed);\n if (reusable === undefined) throw new AuthorBridgeError('Too many Author canvases in this conversation.', 409);\n reusable.bridge.close();\n byAlias.delete(reusable.alias);\n byPath.delete(reusable.realPath);\n }\n const base =\n path\n .basename(realPath)\n .replace(/\\.[^.]*$/u, '')\n .toLowerCase()\n .replace(/[^a-z0-9_-]+/gu, '-')\n .replace(/^[^a-z]+/u, 'canvas-')\n .slice(0, 48) || 'canvas';\n let alias = requestedAlias ?? base;\n for (let suffix = 2; byAlias.has(alias); suffix++) alias = `${base.slice(0, 56)}-${suffix}`;\n const canvas: Canvas = {\n alias,\n path: canonicalPath,\n realPath,\n bridge: createBridge(),\n closed: false,\n readyOnce: false,\n };\n byAlias.set(alias, canvas);\n byPath.set(realPath, canvas);\n return { path: canonicalPath, byteLength: bytes.byteLength, alias, status: 'opening', reused: false };\n },\n describe(alias?: string): AuthorViewportCatalogSnapshot {\n const canvases = [...byAlias.values()].map(view);\n const target =\n alias === undefined && canvases.filter((canvas) => canvas.status !== 'unavailable').length !== 1\n ? undefined\n : select(alias);\n if (target === undefined) {\n return {\n catalogToken: '',\n tools: [],\n canvases,\n nextStep: 'Open a file with open_authoring_file, then describe_author_tools({\"alias\":\"canvas-name\"}).',\n };\n }\n const status = view(target).status;\n const base = { alias: target.alias, path: target.path, status, canvases };\n if (status !== 'ready') {\n return {\n ...base,\n catalogToken: '',\n tools: [],\n nextStep:\n status === 'opening'\n ? `Wait for ${target.alias} to be ready, then call describe_author_tools({\"alias\":\"${target.alias}\"}).`\n : `Reopen ${target.path} with open_authoring_file({\"path\":\"${target.path}\",\"alias\":\"${target.alias}\"}).`,\n };\n }\n return { ...base, ...target.bridge.describe() };\n },\n invoke(input: UseAuthorToolInput, signal?: AbortSignal) {\n const target = select(input.alias);\n if (target.closed) throw new AuthorBridgeError(`Canvas '${target.alias}' is closed. Reopen its file.`, 503);\n return target.bridge.invoke(input, signal).then((result) => ({ ...result, alias: target.alias }));\n },\n bridge(alias: string): AuthorBridgeState {\n const canvas = select(alias);\n if (canvas.closed) throw new AuthorBridgeError(`Canvas '${alias}' is closed. Reopen its file.`, 503);\n return canvas.bridge;\n },\n close(alias: string): void {\n const canvas = select(alias);\n canvas.closed = true;\n canvas.bridge.close();\n canvas.bridge = createBridge();\n },\n dispose(): void {\n for (const canvas of byAlias.values()) canvas.bridge.close();\n byAlias.clear();\n byPath.clear();\n },\n };\n}\n\nexport type AuthorCanvasRegistry = ReturnType<typeof createAuthorCanvasRegistry>;\n","import { apiResponse, defineApiRoutes } from '@agimon-ai/po-core/web';\n\nimport type { AuthorOpenFileResult } from './author';\nimport type { AuthorSessionView } from './authorApi';\nimport type { DocumentPreflightReport, ParsedStructuredDocument } from './structuredDocuments';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path. The build reads both off\n * `src/extensions/workspaces/sessions/(backend)/api/author/`, so the mount is\n * stated once, by the folder that creates it. The browser used to restate it:\n * `authorStateUrl` built one URL from `API_BASE_PATH` and the document helper\n * two files away spelled `author` out again as a literal, so the two could\n * disagree and nothing would say so.\n *\n * The order below is the order the three Hono apps register in: `/state` in\n * `authorApi`, the eight bridge routes in `authorBridgeApi`, the three document\n * routes in `authorDocumentApi`. A reviewer can read the two side by side.\n *\n * Response types are named only where a caller reads the body. The bridge\n * routes are called by the hub's author channel over `requestSessionApi`, which\n * has its own message vocabulary and never sees this client.\n */\nexport default defineApiRoutes({\n state: {\n method: 'GET',\n path: '/state',\n response: apiResponse<AuthorSessionView>(),\n },\n bridgeRegister: {\n method: 'POST',\n path: '/bridge/register',\n },\n bridgeCatalog: {\n method: 'POST',\n path: '/bridge/catalog',\n },\n /** Long-polls for the next capability request, so it settles when one arrives. */\n bridgeNext: {\n method: 'POST',\n path: '/bridge/next',\n },\n bridgeResult: {\n method: 'POST',\n path: '/bridge/result',\n },\n bridgeCancelled: {\n method: 'POST',\n path: '/bridge/cancelled',\n },\n bridgeDisconnect: {\n method: 'POST',\n path: '/bridge/disconnect',\n },\n bridgeClose: {\n method: 'POST',\n path: '/bridge/close',\n },\n bridgeDescribe: {\n method: 'GET',\n path: '/bridge/describe',\n query: ['alias'],\n },\n bridgeInvoke: {\n method: 'POST',\n path: '/bridge/invoke',\n },\n /**\n * Parses one structured document.\n *\n * Answers a byte-length summary instead when the request names no format,\n * which is the agent-side tool path; the page always names one.\n */\n documentsOpen: {\n method: 'POST',\n path: '/documents/open',\n query: ['session'],\n response: apiResponse<ParsedStructuredDocument | AuthorOpenFileResult>(),\n },\n documentsPreflight: {\n method: 'POST',\n path: '/documents/preflight',\n query: ['session'],\n response: apiResponse<DocumentPreflightReport>(),\n },\n documentsSerialize: {\n method: 'POST',\n path: '/documents/serialize',\n query: ['session'],\n response: apiResponse<{ bytes: string; encoding: string }>(),\n },\n /**\n * The host's own bytes route, not this package's.\n *\n * `host: true` hangs it off the session root rather than under `/plugins`,\n * which is how the cockpit already serves it. Author reads a document's\n * bytes and its digest through it, and writes the edited bytes back to the\n * same path, so both stay raw transfers rather than calls: the body is the\n * file and the digest travels in a header.\n */\n file: {\n method: 'GET',\n path: '/file',\n query: ['path'],\n host: true,\n },\n});\n","import type { AuthorModeActivation } from './author';\n\n/**\n * The wire vocabulary this package's API shares with whatever calls it.\n *\n * Paths live in `./apiRoutes`, which the Hono apps register from and the\n * generated client addresses, so neither half can move alone. What stays here\n * is the mount segment the server registers under and the shape the state\n * route answers with.\n */\n\n/** Where a host mounts this package's API; the segment after /api/plugins/. */\nexport const API_BASE_PATH = 'author';\n\n/** Query parameter naming the session a document request belongs to. */\nexport const SESSION_QUERY_PARAM = 'session';\n\nexport interface AuthorSessionView {\n sessionId: string | null;\n activation: AuthorModeActivation;\n capabilityCount: number;\n}\n","import { Hono } from 'hono';\n\nimport { AuthorBridgeError } from '../../../../../../../models/authorBridgeState';\nimport { parseUseAuthorToolInput } from '../../../../../../../schemas/authorTools';\nimport type { AuthorCanvasRegistry } from '../../../../../../../services/authorCanvasRegistry';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorViewportCapabilityDescriptor } from '../../../../../../../types/author';\n\nfunction record(value: unknown): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new AuthorBridgeError('Invalid request.', 400);\n return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, key: string): string {\n const result = record(value)[key];\n if (typeof result !== 'string' || result === '') throw new AuthorBridgeError(`Invalid ${key}.`, 400);\n return result;\n}\n\nfunction generation(value: unknown): number {\n const result = record(value).generation;\n if (!Number.isSafeInteger(result) || (result as number) < 0) throw new AuthorBridgeError('Invalid generation.', 400);\n return result as number;\n}\n\nasync function body(request: Request): Promise<Record<string, unknown>> {\n return record(await request.json());\n}\n\nexport function createAuthorBridgeApi(registry: AuthorCanvasRegistry): Hono {\n const app = new Hono();\n app.onError((error, context) =>\n context.json(\n { error: error instanceof Error ? error.message : String(error) },\n error instanceof AuthorBridgeError ? error.status : 500,\n ),\n );\n app.post(routes.bridgeRegister.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({ ...registry.bridge(alias).register(text(value, 'bindingId'), generation(value)), alias });\n });\n app.post(routes.bridgeCatalog.path, async (context) => {\n const value = await body(context.req.raw);\n const tools = value.tools;\n if (!Array.isArray(tools)) throw new AuthorBridgeError('Invalid Author catalog.', 400);\n const alias = text(value, 'alias');\n return context.json({\n ...registry\n .bridge(alias)\n .catalog(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n tools as AuthorViewportCapabilityDescriptor[],\n ),\n alias,\n });\n });\n app.post(routes.bridgeNext.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({\n ...(await registry\n .bridge(alias)\n .next(text(value, 'bindingId'), generation(value), text(value, 'ownerToken'), context.req.raw.signal)),\n alias,\n });\n });\n app.post(routes.bridgeResult.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .result(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n value.result,\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeCancelled.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .cancelled(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeDisconnect.path, async (context) => {\n const value = await body(context.req.raw);\n registry.bridge(text(value, 'alias')).disconnect(text(value, 'bindingId'), generation(value));\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeClose.path, async (context) => {\n const value = await body(context.req.raw);\n registry.close(text(value, 'alias'));\n return context.json({ accepted: true });\n });\n app.get(routes.bridgeDescribe.path, (context) => context.json(registry.describe(context.req.query('alias'))));\n app.post(routes.bridgeInvoke.path, async (context) => {\n const value = parseUseAuthorToolInput(await context.req.raw.json());\n return context.json(await registry.invoke(value, context.req.raw.signal));\n });\n return app;\n}\n","import { Hono } from 'hono';\n\nimport {\n parseStructuredDocument,\n preflightStructuredDocument,\n serializeStructuredDocument,\n} from '../../../../../../../services/structuredDocuments';\nimport { DocumentRequestError } from '../../../../../../../services/structuredDocuments/common';\nimport { readDocument } from '../../../../../../../services/structuredDocuments/document';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorOpenFileResult } from '../../../../../../../types/author';\nimport type {\n CsvDialect,\n DocumentOperation,\n StructuredDocumentFormat,\n} from '../../../../../../../types/structuredDocuments';\n\nexport { AUTHOR_DOCUMENT_MAX_BYTES } from '../../../../../../../services/structuredDocuments/document';\n\ninterface DocumentRequest {\n path?: unknown;\n alias?: unknown;\n format?: unknown;\n operations?: unknown;\n preflightDigest?: unknown;\n csvDialect?: unknown;\n}\n\nexport interface AuthorDocumentApiOptions {\n cwd?: string;\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string;\n open?: (path: string, signal?: AbortSignal, alias?: string) => Promise<AuthorOpenFileResult>;\n}\n\nconst FORMATS = new Set<StructuredDocumentFormat>(['markdown-slides', 'csv', 'pptx', 'xlsx']);\n\nfunction errorResponse(\n context: { json: (value: unknown, status: 400 | 403 | 404 | 413 | 422 | 500) => Response },\n error: unknown,\n): Response {\n const message = error instanceof Error ? error.message : 'Document operation failed.';\n // A refusal names its own status; anything else is a request the document cannot satisfy.\n return context.json({ error: message }, error instanceof DocumentRequestError ? error.status : 422);\n}\n\nfunction requestFormat(value: unknown): StructuredDocumentFormat {\n if (typeof value !== 'string' || !FORMATS.has(value as StructuredDocumentFormat))\n throw new Error('A supported format is required.');\n return value as StructuredDocumentFormat;\n}\n\nfunction requestOperations(value: unknown): DocumentOperation[] {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > 100_000) throw new Error('A bounded operations array is required.');\n return value.map((operation) => {\n if (\n typeof operation !== 'object' ||\n operation === null ||\n typeof (operation as Record<string, unknown>).fragmentId !== 'string' ||\n typeof (operation as Record<string, unknown>).replacement !== 'string'\n ) {\n throw new Error('Each operation requires string fragmentId and replacement fields.');\n }\n return operation as DocumentOperation;\n });\n}\n\nasync function bodyOf(request: Request): Promise<DocumentRequest> {\n const body = (await request.json()) as unknown;\n if (typeof body !== 'object' || body === null || Array.isArray(body)) throw new Error('A JSON object is required.');\n return body as DocumentRequest;\n}\n\nexport function createAuthorDocumentApi(options: AuthorDocumentApiOptions = {}): Hono {\n const app = new Hono();\n const cwd = options.cwd ?? process.cwd();\n\n app.post(routes.documentsOpen.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (body.format === undefined && options.open !== undefined) {\n return context.json(\n await options.open(body.path as string, context.req.raw.signal, body.alias as string | undefined),\n );\n }\n const bytes = await readDocument(cwd, body.path, options.sessionId);\n if (body.format === undefined) {\n return context.json({ path: body.path as string, byteLength: bytes.byteLength } satisfies AuthorOpenFileResult);\n }\n return context.json(\n await parseStructuredDocument(requestFormat(body.format), bytes, body.csvDialect as Partial<CsvDialect>),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsPreflight.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n const bytes = await readDocument(cwd, body.path, options.sessionId);\n return context.json(\n await preflightStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.csvDialect as Partial<CsvDialect>,\n ),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsSerialize.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (typeof body.preflightDigest !== 'string') throw new Error('A preflight report digest is required.');\n const bytes = await readDocument(cwd, body.path, options.sessionId);\n const serialized = await serializeStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.preflightDigest,\n body.csvDialect as Partial<CsvDialect>,\n );\n return context.json({\n bytes: Buffer.from(serialized.bytes).toString('base64'),\n encoding: 'base64',\n manifest: serialized.manifest,\n operationLog: serialized.operationLog,\n });\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n return app;\n}\n","import { randomUUID } from 'node:crypto';\n\nimport type { PoApi, PoApiContext, PoApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { Hono } from 'hono';\n\nimport { createAuthorBridgeState, type AuthorBridgeState } from '../../../../../../../models/authorBridgeState';\nimport {\n createAuthorCanvasRegistry,\n type AuthorCanvasRegistry,\n} from '../../../../../../../services/authorCanvasRegistry';\nimport type { AuthorCatalog } from '../../../../../../../services/authorCatalog/type';\nimport routes from '../../../../../../../types/apiRoutes';\nimport { API_BASE_PATH, type AuthorSessionView } from '../../../../../../../types/authorApi';\nimport { createAuthorBridgeApi } from './authorBridgeApi';\nimport { createAuthorDocumentApi } from './authorDocumentApi';\n\nexport interface AuthorApiOptions {\n sessionId?: string;\n cwd?: string;\n readState?: () => Omit<AuthorSessionView, 'sessionId'>;\n registry?: AuthorCanvasRegistry;\n}\n\nconst inactiveState = (): Omit<AuthorSessionView, 'sessionId'> => ({ activation: 'inactive', capabilityCount: 0 });\nconst createBridge = (): AuthorBridgeState =>\n createAuthorBridgeState({\n now: Date.now,\n issueToken: randomUUID,\n scheduleTimeout(callback, delayMs) {\n const timer = setTimeout(callback, delayMs);\n timer.unref?.();\n return () => clearTimeout(timer);\n },\n });\n\nexport function createAuthorApi(options: AuthorApiOptions = {}): Hono {\n const app = new Hono();\n const registry =\n options.registry ?? createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId);\n app.get(routes.state.path, (context) =>\n context.json({\n sessionId: options.sessionId ?? null,\n ...(options.readState ?? inactiveState)(),\n } satisfies AuthorSessionView),\n );\n app.route('/', createAuthorBridgeApi(registry));\n app.route(\n '/',\n createAuthorDocumentApi({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.sessionId === undefined ? {} : { sessionId: options.sessionId }),\n open: (path, signal, alias) => registry.open(path, signal, alias),\n }),\n );\n return app;\n}\n\nexport const api: PoApi = {\n basePath: API_BASE_PATH,\n start(context: PoApiContext): PoApiHandler {\n // One server hosts many sessions, so its own directory is never a session's project.\n if (context.cwd === undefined) throw new Error('Author requires the session working directory.');\n const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId);\n const app = createAuthorApi({\n ...(context.sessionId === undefined ? {} : { sessionId: context.sessionId }),\n cwd: context.cwd,\n registry,\n });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n};\n\n/** The session API and tools share the same browser ownership and pending requests. */\nexport function createAuthorSessionApi(cwd: string, sessionId: string): { api: PoApi; catalog: AuthorCatalog } {\n const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId);\n return {\n catalog: {\n open: (path, signal, alias) => registry.open(path, signal, alias),\n async describe(signal, alias) {\n signal?.throwIfAborted();\n return registry.describe(alias);\n },\n execute: (input, signal) => registry.invoke(input, signal),\n },\n api: {\n basePath: API_BASE_PATH,\n start() {\n const app = createAuthorApi({ cwd, sessionId, registry });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\nimport { serverMinorModes } from '@agimon-ai/po-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { authorMinorMode } from '../../../../models/authorMode';\nimport { createAuthorCatalog } from '../../../../services/authorCatalog';\nimport { createWebmcpNamespace } from '../../../../services/webmcpNamespace';\nimport { api, createAuthorSessionApi } from './api/author/_lib/authorApi';\n\nexport default defineRoot(({ agent, signal }: PoServerPluginContext) => {\n const session = agent ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId) : undefined;\n const isActive = () => (agent?.context.selection.state?.['minor-mode'] ?? []).includes(authorMinorMode.descriptor.id);\n const mode = agent\n ? authorMinorMode.createOwner({\n isActive,\n detail: () => 'document authoring available',\n async setActive(enabled) {\n const modes = (agent.context.selection.state?.['minor-mode'] ?? []).filter(\n (id) => id !== authorMinorMode.descriptor.id,\n );\n await agent.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, authorMinorMode.descriptor.id] : modes,\n });\n },\n })\n : undefined;\n let disposed = false;\n const catalog = createAuthorCatalog(session?.catalog);\n const assertAvailable = () => {\n signal.throwIfAborted();\n if (disposed) throw new Error('Author session is disposed.');\n if (!isActive()) throw new Error('Author mode is not active.');\n };\n const mountNamespace = (context: Context) => {\n if (!agent) return;\n const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAvailable);\n context.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const registration = readPoCodemode(scoped)?.register('@agimon-ai/po-author', namespace);\n return () => registration?.dispose();\n });\n };\n return {\n onDispose: () => {\n disposed = true;\n },\n value: {\n api: session?.api ?? api,\n catalog,\n // Registration is gated by AUTHOR_TOOL_WHEN; this re-checks a call already in flight when the mode turns off.\n assertAvailable,\n service: undefined,\n },\n services: [...(mode ? [serverMinorModes([mode])] : []), mountNamespace],\n };\n});\n","import type { AuthorViewportCapabilityDescriptor } from './author';\n\nexport const authorChannelType = 'author_webmcp';\n\nexport interface AuthorRegisterMessage {\n alias: string;\n kind: 'register';\n generation: number;\n}\n\nexport interface AuthorReleaseMessage {\n alias: string;\n kind: 'release';\n generation: number;\n}\nexport interface AuthorCatalogMessage {\n alias: string;\n kind: 'catalog';\n generation: number;\n ownerToken: string;\n tools: AuthorViewportCapabilityDescriptor[];\n}\n\nexport interface AuthorResultMessage {\n alias: string;\n kind: 'result';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n result: unknown;\n}\n\nexport interface AuthorCancelledMessage {\n alias: string;\n kind: 'cancelled';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport type AuthorBrowserMessage =\n | AuthorRegisterMessage\n | AuthorReleaseMessage\n | AuthorCatalogMessage\n | AuthorResultMessage\n | AuthorCancelledMessage;\n\nexport interface AuthorAcceptedMessage {\n alias?: string;\n kind: 'accepted';\n generation: number;\n ownerToken: string;\n catalogToken?: string;\n leaseMs: number;\n}\n\nexport interface AuthorRequestMessage {\n alias?: string;\n kind: 'request';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n name: string;\n arguments: Record<string, unknown>;\n}\n\nexport interface AuthorCancelMessage {\n alias?: string;\n kind: 'cancel';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport interface AuthorRejectedMessage {\n alias?: string;\n kind: 'rejected';\n reason: string;\n}\n\nexport type AuthorHubMessage =\n | AuthorAcceptedMessage\n | AuthorRequestMessage\n | AuthorCancelMessage\n | AuthorRejectedMessage;\n\nexport interface AuthorWebView {\n activation: 'inactive' | 'active';\n capabilityCount: number;\n}\n","import type {\n PoHubChannelConnection,\n PoHubChannelHost,\n PoHubChannelSource,\n PoHubSessionScope,\n PoHubChannel,\n} from '@agimon-ai/po-core/hubChannel';\n\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport routes from '../../types/apiRoutes';\nimport { API_BASE_PATH } from '../../types/authorApi';\nimport { authorChannelType, type AuthorBrowserMessage, type AuthorHubMessage } from '../../types/webAuthor';\n\n/**\n * Which route carries each message the browser sends.\n *\n * The paths come from the package's one route table, so the hub cannot address\n * a bridge route the session no longer serves. `release` is absent because it\n * is answered by the disconnect route rather than one of its own.\n */\nconst BRIDGE_ROUTE: Readonly<Record<Exclude<AuthorBrowserMessage['kind'], 'release'>, string>> = {\n register: routes.bridgeRegister.path,\n catalog: routes.bridgeCatalog.path,\n result: routes.bridgeResult.path,\n cancelled: routes.bridgeCancelled.path,\n};\n\ninterface Binding {\n alias: string;\n scope: PoHubSessionScope;\n connectionId: string;\n generation: number;\n ownerToken: string;\n poll?: AbortController;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction browserMessage(value: unknown): AuthorBrowserMessage | undefined {\n if (\n !isRecord(value) ||\n typeof value.kind !== 'string' ||\n typeof value.alias !== 'string' ||\n !AUTHOR_ALIAS_PATTERN.test(value.alias)\n )\n return undefined;\n if (!['register', 'release', 'catalog', 'result', 'cancelled'].includes(value.kind)) return undefined;\n return value as unknown as AuthorBrowserMessage;\n}\n\nasync function responsePayload(response: Response): Promise<AuthorHubMessage> {\n const value = (await response.json()) as unknown;\n if (response.ok) return value as AuthorHubMessage;\n const reason =\n isRecord(value) && typeof value.error === 'string' ? value.error : `Author bridge HTTP ${response.status}`;\n return { kind: 'rejected', reason };\n}\n\nexport function createAuthorChannel(): PoHubChannel {\n const bindings = new Map<string, Binding>();\n let host: PoHubChannelHost | undefined;\n let closed = false;\n const keyOf = (sessionId: string, connectionId: string, alias: string): string =>\n `${sessionId}\\0${connectionId}\\0${alias}`;\n const send = async (scope: PoHubSessionScope, path: string, value: Record<string, unknown>, signal?: AbortSignal) =>\n await host!.requestSessionApi(scope, {\n basePath: API_BASE_PATH,\n path,\n method: 'POST',\n body: JSON.stringify(value),\n ...(signal === undefined ? {} : { signal }),\n });\n const publish = (binding: Binding, payload: AuthorHubMessage): boolean =>\n host?.publishToConnection?.(binding.connectionId, binding.scope.sessionId, { ...payload, alias: binding.alias }) ??\n false;\n\n const poll = async (binding: Binding): Promise<void> => {\n binding.poll?.abort();\n const controller = new AbortController();\n binding.poll = controller;\n while (!closed && bindings.get(keyOf(binding.scope.sessionId, binding.connectionId, binding.alias)) === binding) {\n try {\n const response = await send(\n binding.scope,\n routes.bridgeNext.path,\n {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n ownerToken: binding.ownerToken,\n },\n controller.signal,\n );\n const payload = await responsePayload(response);\n if (controller.signal.aborted) break;\n if (!publish(binding, payload) || payload.kind === 'rejected') break;\n } catch (error) {\n if (!controller.signal.aborted) host?.onNotice(error instanceof Error ? error.message : String(error));\n break;\n }\n }\n if (binding.poll === controller) binding.poll = undefined;\n };\n\n const channel: PoHubChannel = {\n frameType: authorChannelType,\n lifecycle: 'hub',\n receiveWithoutSubscription: true,\n start(channelHost) {\n host = channelHost;\n const source: PoHubChannelSource = {\n payloadFor: () => undefined,\n sessionRemoved(sessionId) {\n for (const [key, binding] of bindings) {\n if (binding.scope.sessionId !== sessionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n close() {\n closed = true;\n for (const binding of bindings.values()) {\n binding.poll?.abort();\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n bindings.clear();\n },\n };\n return source;\n },\n receive(scope, payload, connection) {\n const message = browserMessage(payload);\n if (message === undefined || host === undefined || closed) return;\n void (async () => {\n const key = keyOf(scope.sessionId, connection.connectionId, message.alias);\n const previous = bindings.get(key);\n if (message.kind === 'release') {\n if (previous === undefined || previous.generation !== message.generation) return;\n previous.poll?.abort();\n bindings.delete(key);\n await send(scope, routes.bridgeDisconnect.path, {\n alias: message.alias,\n bindingId: connection.connectionId,\n generation: message.generation,\n });\n return;\n }\n const route = BRIDGE_ROUTE[message.kind];\n const response = await send(scope, route, { ...message, bindingId: connection.connectionId });\n const reply = await responsePayload(response);\n if (reply.kind === 'accepted') {\n const current = bindings.get(key);\n if (current?.generation === reply.generation && current.ownerToken === reply.ownerToken) {\n publish(current, reply);\n if (current.poll === undefined) void poll(current);\n return;\n }\n const binding: Binding = {\n alias: message.alias,\n scope,\n connectionId: connection.connectionId,\n generation: reply.generation,\n ownerToken: reply.ownerToken,\n };\n current?.poll?.abort();\n bindings.set(key, binding);\n publish(binding, reply);\n void poll(binding);\n } else if (reply.kind === 'rejected') {\n if (previous !== undefined) publish(previous, reply);\n else\n host?.publishToConnection?.(connection.connectionId, scope.sessionId, { ...reply, alias: message.alias });\n }\n })().catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n },\n disconnected(connection: PoHubChannelConnection) {\n for (const [key, binding] of bindings) {\n if (binding.connectionId !== connection.connectionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n };\n return channel;\n}\n","import { defineChannel } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorChannel } from '../../../services/webAuthorChannel';\n\nexport default defineChannel(createAuthorChannel);\n","import { defineServerMethod, type PoServerHostService } from '@agimon-ai/po-core/serverPlugin';\n\nimport { authorBridgeMethod } from '../../schemas/authorFacade';\nimport { authorChannelType } from '../../types/webAuthor';\n\nexport function createAuthorBridgeMethod(scope: 'global' | 'workspace', host: PoServerHostService) {\n return defineServerMethod(authorBridgeMethod(scope), ({ sessionId, message }, caller) => {\n if (!caller.connectionId) throw new Error('Author bridge requires an authenticated browser connection.');\n if (!host.context.receiveChannel?.(sessionId, authorChannelType, message, caller.connectionId))\n throw new Error('Author bridge session is outside this mount.');\n return {};\n });\n}\n","import { defineMethod } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createAuthorBridgeMethod } from '../../../services/authorBridgeMethod';\n\nexport default defineMethod(({ host }: PoServerPluginContext) =>\n host.scope === 'session'\n ? { register: () => ({ dispose: () => undefined }) }\n : createAuthorBridgeMethod(host.scope, host),\n);\n","import { defineRoute, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\ntype AuthorServerScope = Awaited<ReturnType<typeof import('../../root.server').default>>['value'];\n\nexport default defineRoute((context: WithRoot<PoServerPluginContext, AuthorServerScope>) => context.root.api);\n","import { defineCommand as defineRoutedCommand, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorCommand } from '../../../../../services/authorCommand';\nimport type { AuthorExtensionService } from '../../../../../types/extension';\n\nexport default defineRoutedCommand((context: WithRoot<unknown, { readonly service?: AuthorExtensionService }>) =>\n createAuthorCommand(context.root.service),\n);\n","import { defineHook } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_GUIDANCE } from '../../../../../constants/author';\n\nexport default defineHook<'before_agent_start'>({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor', mode: 'author' } },\n event: 'before_agent_start',\n handle(event) {\n const systemPrompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${systemPrompt}\\n\\n${AUTHOR_GUIDANCE}`.trim() };\n },\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nconst skillFile = 'src/prompts/codemode-how-to-author/SKILL.md';\n\nexport default defineResource({\n name: 'codemode-how-to-author',\n description:\n 'Call Author canvas capabilities through the webmcp namespace in code mode. Use for canvas discovery, capability calls, and their catalog tokens from exec.',\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, skillFile),\n read: () => readPackageResource(import.meta.url, skillFile),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor' as const, mode: 'author' } },\n name: 'po-use-author',\n description: 'Use the Author workflow for focused document review, canvas steering, and bounded authoring.',\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n});\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[1]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[0]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[2]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelAuthorWebmcp from '../src/extensions/(backend)/channel/author-webmcp.server';\nimport methodBridge from '../src/extensions/(backend)/method/bridge.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/author/route.server';\nimport commandAuthor from '../src/extensions/workspaces/sessions/(backend)/command/author.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport resourceCodemodeHowToAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server';\nimport resourcePoUseAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server';\nimport toolDescribeAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server';\nimport toolOpenAuthoringFile from '../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server';\nimport toolUseAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-author',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n global: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return [() => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n workspace: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get commands(): PoServerSessionPlugin['commands'] { return [via({ name: 'author' }, at(commandAuthor, contextSession))]; },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToAuthor, contextSession), at(resourcePoUseAuthor, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [via({ name: 'describe_author_tools' }, at(toolDescribeAuthorTools, contextSession)), via({ name: 'open_authoring_file' }, at(toolOpenAuthoringFile, contextSession)), via({ name: 'use_author_tools' }, at(toolUseAuthorTools, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,MAAM,eAAe;;;;;;;;;;;;;;;AAgBrB,SAAS,KAAQ,OAAa;CAC5B,OAAO,UAAU,KAAA,IAAY,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACvE;AAEA,SAAgB,sBACd,SACA,WACA,iBACqB;CACrB,OAAO;EACL,MAAM;EACN,SACE;EACF,cAAc;EACd,KAAK,KAAK;GACR,IAAI,IAAI,cAAc,WAAW,MAAM,IAAI,MAAM,qDAAqD;GACtG,IAAI,WAAW;GACf,IAAI,gBAAgB;IAClB,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AAGC,mCAAsB,cAAc,CAAC,CAAC;GAAG;GACvI,IAAI,UAA4C;IAAE,OAAO,CAAC,GAAGJ,uBAAc,OAAO,CAAC;GAAG;GACtF,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGK,uCAA6B,cAAc,GAAG,GAAGC,8BAAqB,cAAc,CAAC;GAAG;GACzJ,IAAI,QAAwC;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,wBAAwB,GAAG,GAAGC,sCAAyB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,sBAAsB,GAAG,GAAGC,oCAAuB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,iCAAoB,cAAc,CAAC;IAAC;GAAG;GACxS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.cjs","names":["parseDescribeAuthorToolsInput","parseUseAuthorToolInput","path","AUTHOR_ARTIFACT_PREFIX","DocumentRequestError","artifactRoot","fs","openArtifact","ArtifactAccessError","documentTooLarge","readArtifactBytes","constants","AUTHOR_ALIAS_PATTERN","AuthorBridgeError","path","defineApiRoutes","apiResponse","AuthorBridgeError","Hono","routes","parseUseAuthorToolInput","DocumentRequestError","Hono","routes","parseStructuredDocument","preflightStructuredDocument","serializeStructuredDocument","createAuthorBridgeState","randomUUID","Hono","routes","defineRoot","authorMinorMode","createAuthorCatalog","PO_CODEMODE_SERVICE","readPoCodemode","serverMinorModes","routes","AUTHOR_ALIAS_PATTERN","defineChannel","defineServerMethod","authorBridgeMethod","defineMethod","defineRoute","defineRoutedCommand","createAuthorCommand","defineHook","AUTHOR_GUIDANCE","defineResource","packageResourcePath","readPackageResource","defineResource","packageResourcePath","readPackageResource","defineTool","createAuthorTools","AUTHOR_TOOL_WHEN","defineTool","createAuthorTools","AUTHOR_TOOL_WHEN","defineTool","createAuthorTools","AUTHOR_TOOL_WHEN","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootInjects","channelAuthorWebmcp","methodBridge","composeRootHooks","apiRoute","commandAuthor","hookBeforeAgentStart","resourceCodemodeHowToAuthor","resourcePoUseAuthor","toolDescribeAuthorTools","toolOpenAuthoringFile","toolUseAuthorTools"],"sources":["../../src/services/webmcpNamespace/index.ts","../../src/services/structuredDocuments/document.ts","../../src/services/authorCanvasRegistry/index.ts","../../src/types/apiRoutes.ts","../../src/types/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorBridgeApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorDocumentApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/types/webAuthor.ts","../../src/services/webAuthorChannel/index.ts","../../src/extensions/(backend)/channel/author-webmcp.server.ts","../../src/services/authorBridgeMethod/index.ts","../../src/extensions/(backend)/method/bridge.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/author.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server.ts","../../generated/server.ts"],"sourcesContent":["import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\n\nimport { parseDescribeAuthorToolsInput, parseUseAuthorToolInput } from '../../schemas/authorTools';\nimport type { AuthorCatalog } from '../authorCatalog/type';\n\n// ponytail: typed per-canvas members need a synchronous catalog reader and a shared schema converter in po-core.\nconst DECLARATIONS = `interface AuthorViewportCatalogSnapshot {\n catalogToken: string;\n tools: { name: string; label: string; description: string; inputSchema: Readonly<Record<string, unknown>> }[];\n canvases?: { alias: string; path: string; status: 'opening' | 'ready' | 'unavailable' }[];\n alias?: string;\n path?: string;\n status?: 'opening' | 'ready' | 'unavailable';\n nextStep?: string;\n}\ndeclare const webmcp: {\n /** Ready canvases, or one canvas's tools and its catalog token. */\n describe(input?: { alias?: string }): Promise<AuthorViewportCatalogSnapshot>;\n /** Call one tool with an explicit current token. Await same-canvas calls sequentially. */\n call(input: { alias?: string; catalogToken: string; name: string; arguments: Record<string, unknown> }): Promise<unknown>;\n};`;\n\nfunction copy<T>(value: T): T {\n return value === undefined ? value : JSON.parse(JSON.stringify(value));\n}\n\nexport function createWebmcpNamespace(\n catalog: AuthorCatalog,\n sessionId: string,\n assertAvailable: () => void,\n): PoCodemodeNamespace {\n return {\n name: 'webmcp',\n summary:\n 'Author canvas WebMCP: describe catalogs, then call one tool with its explicit token. Await same-canvas calls sequentially; structured errors remain data.',\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== sessionId) throw new Error('Author WebMCP namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n run.signal.throwIfAborted();\n if (disposed) throw new Error('Author WebMCP run is disposed.');\n assertAvailable();\n };\n const members: Record<string, unknown> = Object.create(null);\n members.describe = async (input?: unknown) => {\n check();\n const { alias } = parseDescribeAuthorToolsInput(copy(input === undefined ? {} : input));\n const result = await catalog.describe(run.signal, alias);\n check();\n return copy(result);\n };\n members.call = async (input: unknown) => {\n check();\n const parsed = parseUseAuthorToolInput(copy(input));\n const result = await catalog.execute(parsed, run.signal);\n check();\n return copy(result.result);\n };\n return members;\n },\n };\n}\n","import { constants } from 'node:fs';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n ArtifactAccessError,\n artifactRoot,\n openArtifact,\n readArtifactBytes,\n} from '@agimon-ai/po-artifact/artifactFiles';\n\nimport { AUTHOR_ARTIFACT_PREFIX } from '../../constants/author';\nimport { DocumentRequestError, documentTooLarge } from './common';\n\nexport const AUTHOR_DOCUMENT_MAX_BYTES = 25 * 1024 * 1024;\n\n/**\n * Where a requested document lives. `path` is the canonical form clients use;\n * `realPath` identifies the file so two spellings share one canvas.\n */\nexport type AuthorDocumentSource =\n | { kind: 'workspace'; path: string; realPath: string; root: string }\n | { kind: 'artifact'; path: string; realPath: string; root: string; relative: string };\n\nfunction inside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);\n}\n\n/**\n * The session artifact folder is the one place outside the working tree Author\n * may read. It is named either `artifact:<relative>` or by the absolute path the\n * agent's prompt gives; po-artifact's guarded open does the containment checks.\n */\nasync function resolveArtifact(\n requestedPath: string,\n sessionId: string | undefined,\n environment: Readonly<Record<string, string | undefined>> | undefined,\n) {\n const prefixed = requestedPath.startsWith(AUTHOR_ARTIFACT_PREFIX);\n if (sessionId === undefined || environment === undefined) {\n if (prefixed) throw new DocumentRequestError('Artifacts need a session.', 400);\n return undefined;\n }\n const root = artifactRoot(sessionId, environment);\n if (prefixed) return { root, relative: requestedPath.slice(AUTHOR_ARTIFACT_PREFIX.length) };\n if (!path.isAbsolute(requestedPath)) return undefined;\n const realRoot = await fs.realpath(root).catch(() => root);\n const base = [root, realRoot].find((candidate) => inside(candidate, requestedPath));\n if (base === undefined) return undefined;\n return { root, relative: path.relative(base, requestedPath).split(path.sep).join('/') };\n}\n\nexport async function resolveDocument(\n cwd: string,\n requestedPath: unknown,\n sessionId?: string,\n environment?: Readonly<Record<string, string | undefined>>,\n): Promise<AuthorDocumentSource> {\n if (typeof requestedPath !== 'string' || requestedPath.length === 0 || requestedPath.includes('\\0'))\n throw new Error('A relative document path is required.');\n const artifact = await resolveArtifact(requestedPath, sessionId, environment);\n if (artifact !== undefined) {\n const realRoot = await fs.realpath(artifact.root).catch(() => artifact.root);\n return {\n kind: 'artifact',\n path: `${AUTHOR_ARTIFACT_PREFIX}${artifact.relative}`,\n realPath: path.join(realRoot, artifact.relative),\n ...artifact,\n };\n }\n if (path.isAbsolute(requestedPath))\n throw new Error('A relative document path, or a file in the session artifact folder, is required.');\n const root = await fs.realpath(cwd);\n const candidate = path.resolve(root, requestedPath);\n if (candidate !== root && !candidate.startsWith(`${root}${path.sep}`))\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n const realCandidate = await fs.realpath(candidate);\n if (realCandidate !== root && !realCandidate.startsWith(`${root}${path.sep}`)) {\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n }\n return {\n kind: 'workspace',\n root,\n path: path.relative(root, realCandidate).split(path.sep).join('/'),\n realPath: realCandidate,\n };\n}\n\nasync function readArtifact(root: string, relative: string): Promise<Uint8Array> {\n let file: Awaited<ReturnType<typeof openArtifact>>;\n try {\n file = await openArtifact(root, relative);\n } catch (error) {\n if (error instanceof ArtifactAccessError) throw new DocumentRequestError(error.message, error.status);\n throw error;\n }\n try {\n if (file.stat.size > AUTHOR_DOCUMENT_MAX_BYTES)\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n return await readArtifactBytes(file.handle, file.stat.size);\n } finally {\n await file.handle.close();\n }\n}\n\nexport async function readSource(source: AuthorDocumentSource): Promise<Uint8Array> {\n if (source.kind === 'artifact') return await readArtifact(source.root, source.relative);\n if (process.platform !== 'darwin' && process.platform !== 'linux')\n throw new DocumentRequestError('Secure document reads require macOS or Linux.', 403);\n // Darwin O_NOFOLLOW_ANY atomically rejects symlinks in every component.\n // Linux validates the opened descriptor's actual path, not a mutable path lookup.\n const noFollow = process.platform === 'darwin' ? 0x20000000 : constants.O_NOFOLLOW;\n const handle = await fs.open(source.realPath, constants.O_RDONLY | constants.O_NONBLOCK | noFollow);\n try {\n const stat = await handle.stat();\n const current = await fs.lstat(source.realPath);\n const realPath = await fs.realpath(process.platform === 'linux' ? `/proc/self/fd/${handle.fd}` : source.realPath);\n if (\n !stat.isFile() ||\n !current.isFile() ||\n stat.dev !== current.dev ||\n stat.ino !== current.ino ||\n !inside(source.root, realPath)\n )\n throw new DocumentRequestError('The document changed or is outside the working directory.', 403);\n if (stat.size > AUTHOR_DOCUMENT_MAX_BYTES)\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n return await readArtifactBytes(handle, stat.size);\n } finally {\n await handle.close();\n }\n}\n\nexport async function readDocument(\n cwd: string,\n requestedPath: unknown,\n sessionId?: string,\n environment?: Readonly<Record<string, string | undefined>>,\n): Promise<Uint8Array> {\n return await readSource(await resolveDocument(cwd, requestedPath, sessionId, environment));\n}\n","import path from 'node:path';\n\nimport { AuthorBridgeError, type AuthorBridgeState } from '../../models/authorBridgeState';\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport type {\n AuthorCanvasView,\n AuthorOpenFileResult,\n AuthorViewportCatalogSnapshot,\n UseAuthorToolInput,\n} from '../../types/author';\nimport { readSource, resolveDocument } from '../structuredDocuments/document';\n\ninterface Canvas {\n alias: string;\n path: string;\n realPath: string;\n bridge: AuthorBridgeState;\n closed: boolean;\n readyOnce: boolean;\n}\n\nconst MAX_CANVASES = 32;\n\nexport function createAuthorCanvasRegistry(\n cwd: string,\n createBridge: () => AuthorBridgeState,\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string,\n environment?: Readonly<Record<string, string | undefined>>,\n) {\n const byAlias = new Map<string, Canvas>();\n const byPath = new Map<string, Canvas>();\n\n const select = (alias?: string): Canvas => {\n if (alias !== undefined) {\n if (!AUTHOR_ALIAS_PATTERN.test(alias)) throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const canvas = byAlias.get(alias);\n if (canvas === undefined)\n throw new AuthorBridgeError(\n `Unknown Author canvas '${alias}'. Call describe_author_tools({}) for available aliases.`,\n 404,\n );\n return canvas;\n }\n const canvases = [...byAlias.values()].filter((canvas) => !canvas.closed);\n if (canvases.length !== 1)\n throw new AuthorBridgeError('Specify a canvas alias. Call describe_author_tools({}) to list canvases.', 409);\n return canvases[0]!;\n };\n\n const view = (canvas: Canvas): AuthorCanvasView => {\n if (canvas.closed) return { alias: canvas.alias, path: canvas.path, status: 'unavailable' };\n try {\n canvas.bridge.describe();\n canvas.readyOnce = true;\n return { alias: canvas.alias, path: canvas.path, status: 'ready' };\n } catch {\n return { alias: canvas.alias, path: canvas.path, status: canvas.readyOnce ? 'unavailable' : 'opening' };\n }\n };\n\n return {\n async open(requestedPath: string, signal?: AbortSignal, requestedAlias?: string): Promise<AuthorOpenFileResult> {\n signal?.throwIfAborted();\n if (requestedAlias !== undefined && !AUTHOR_ALIAS_PATTERN.test(requestedAlias))\n throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const source = await resolveDocument(cwd, requestedPath, sessionId, environment);\n const bytes = await readSource(source);\n signal?.throwIfAborted();\n const { realPath, path: canonicalPath } = source;\n const occupied = requestedAlias === undefined ? undefined : byAlias.get(requestedAlias);\n if (occupied !== undefined && occupied.realPath !== realPath)\n throw new AuthorBridgeError(`Author canvas alias '${requestedAlias}' already names ${occupied.path}.`, 409);\n const existing = byPath.get(realPath);\n if (existing !== undefined) {\n if (existing.closed) existing.readyOnce = false;\n existing.closed = false;\n return {\n path: existing.path,\n byteLength: bytes.byteLength,\n alias: existing.alias,\n status: view(existing).status,\n reused: true,\n };\n }\n if (byAlias.size >= MAX_CANVASES) {\n const reusable = [...byAlias.values()].find((canvas) => canvas.closed);\n if (reusable === undefined) throw new AuthorBridgeError('Too many Author canvases in this conversation.', 409);\n reusable.bridge.close();\n byAlias.delete(reusable.alias);\n byPath.delete(reusable.realPath);\n }\n const base =\n path\n .basename(realPath)\n .replace(/\\.[^.]*$/u, '')\n .toLowerCase()\n .replace(/[^a-z0-9_-]+/gu, '-')\n .replace(/^[^a-z]+/u, 'canvas-')\n .slice(0, 48) || 'canvas';\n let alias = requestedAlias ?? base;\n for (let suffix = 2; byAlias.has(alias); suffix++) alias = `${base.slice(0, 56)}-${suffix}`;\n const canvas: Canvas = {\n alias,\n path: canonicalPath,\n realPath,\n bridge: createBridge(),\n closed: false,\n readyOnce: false,\n };\n byAlias.set(alias, canvas);\n byPath.set(realPath, canvas);\n return { path: canonicalPath, byteLength: bytes.byteLength, alias, status: 'opening', reused: false };\n },\n describe(alias?: string): AuthorViewportCatalogSnapshot {\n const canvases = [...byAlias.values()].map(view);\n const target =\n alias === undefined && canvases.filter((canvas) => canvas.status !== 'unavailable').length !== 1\n ? undefined\n : select(alias);\n if (target === undefined) {\n return {\n catalogToken: '',\n tools: [],\n canvases,\n nextStep: 'Open a file with open_authoring_file, then describe_author_tools({\"alias\":\"canvas-name\"}).',\n };\n }\n const status = view(target).status;\n const base = { alias: target.alias, path: target.path, status, canvases };\n if (status !== 'ready') {\n return {\n ...base,\n catalogToken: '',\n tools: [],\n nextStep:\n status === 'opening'\n ? `Wait for ${target.alias} to be ready, then call describe_author_tools({\"alias\":\"${target.alias}\"}).`\n : `Reopen ${target.path} with open_authoring_file({\"path\":\"${target.path}\",\"alias\":\"${target.alias}\"}).`,\n };\n }\n return { ...base, ...target.bridge.describe() };\n },\n invoke(input: UseAuthorToolInput, signal?: AbortSignal) {\n const target = select(input.alias);\n if (target.closed) throw new AuthorBridgeError(`Canvas '${target.alias}' is closed. Reopen its file.`, 503);\n return target.bridge.invoke(input, signal).then((result) => ({ ...result, alias: target.alias }));\n },\n bridge(alias: string): AuthorBridgeState {\n const canvas = select(alias);\n if (canvas.closed) throw new AuthorBridgeError(`Canvas '${alias}' is closed. Reopen its file.`, 503);\n return canvas.bridge;\n },\n close(alias: string): void {\n const canvas = select(alias);\n canvas.closed = true;\n canvas.bridge.close();\n canvas.bridge = createBridge();\n },\n dispose(): void {\n for (const canvas of byAlias.values()) canvas.bridge.close();\n byAlias.clear();\n byPath.clear();\n },\n };\n}\n\nexport type AuthorCanvasRegistry = ReturnType<typeof createAuthorCanvasRegistry>;\n","import { apiResponse, defineApiRoutes } from '@agimon-ai/po-core/web';\n\nimport type { AuthorOpenFileResult } from './author';\nimport type { AuthorSessionView } from './authorApi';\nimport type { DocumentPreflightReport, ParsedStructuredDocument } from './structuredDocuments';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path. The build reads both off\n * `src/extensions/workspaces/sessions/(backend)/api/author/`, so the mount is\n * stated once, by the folder that creates it. The browser used to restate it:\n * `authorStateUrl` built one URL from `API_BASE_PATH` and the document helper\n * two files away spelled `author` out again as a literal, so the two could\n * disagree and nothing would say so.\n *\n * The order below is the order the three Hono apps register in: `/state` in\n * `authorApi`, the eight bridge routes in `authorBridgeApi`, the three document\n * routes in `authorDocumentApi`. A reviewer can read the two side by side.\n *\n * Response types are named only where a caller reads the body. The bridge\n * routes are called by the hub's author channel over `requestSessionApi`, which\n * has its own message vocabulary and never sees this client.\n */\nexport default defineApiRoutes({\n state: {\n method: 'GET',\n path: '/state',\n response: apiResponse<AuthorSessionView>(),\n },\n bridgeRegister: {\n method: 'POST',\n path: '/bridge/register',\n },\n bridgeCatalog: {\n method: 'POST',\n path: '/bridge/catalog',\n },\n /** Long-polls for the next capability request, so it settles when one arrives. */\n bridgeNext: {\n method: 'POST',\n path: '/bridge/next',\n },\n bridgeResult: {\n method: 'POST',\n path: '/bridge/result',\n },\n bridgeCancelled: {\n method: 'POST',\n path: '/bridge/cancelled',\n },\n bridgeDisconnect: {\n method: 'POST',\n path: '/bridge/disconnect',\n },\n bridgeClose: {\n method: 'POST',\n path: '/bridge/close',\n },\n bridgeDescribe: {\n method: 'GET',\n path: '/bridge/describe',\n query: ['alias'],\n },\n bridgeInvoke: {\n method: 'POST',\n path: '/bridge/invoke',\n },\n /**\n * Parses one structured document.\n *\n * Answers a byte-length summary instead when the request names no format,\n * which is the agent-side tool path; the page always names one.\n */\n documentsOpen: {\n method: 'POST',\n path: '/documents/open',\n query: ['session'],\n response: apiResponse<ParsedStructuredDocument | AuthorOpenFileResult>(),\n },\n documentsPreflight: {\n method: 'POST',\n path: '/documents/preflight',\n query: ['session'],\n response: apiResponse<DocumentPreflightReport>(),\n },\n documentsSerialize: {\n method: 'POST',\n path: '/documents/serialize',\n query: ['session'],\n response: apiResponse<{ bytes: string; encoding: string }>(),\n },\n /**\n * The host's own bytes route, not this package's.\n *\n * `host: true` hangs it off the session root rather than under `/plugins`,\n * which is how the cockpit already serves it. Author reads a document's\n * bytes and its digest through it, and writes the edited bytes back to the\n * same path, so both stay raw transfers rather than calls: the body is the\n * file and the digest travels in a header.\n */\n file: {\n method: 'GET',\n path: '/file',\n query: ['path'],\n host: true,\n },\n});\n","import type { AuthorModeActivation } from './author';\n\n/**\n * The wire vocabulary this package's API shares with whatever calls it.\n *\n * Paths live in `./apiRoutes`, which the Hono apps register from and the\n * generated client addresses, so neither half can move alone. What stays here\n * is the mount segment the server registers under and the shape the state\n * route answers with.\n */\n\n/** Where a host mounts this package's API; the segment after /api/plugins/. */\nexport const API_BASE_PATH = 'author';\n\n/** Query parameter naming the session a document request belongs to. */\nexport const SESSION_QUERY_PARAM = 'session';\n\nexport interface AuthorSessionView {\n sessionId: string | null;\n activation: AuthorModeActivation;\n capabilityCount: number;\n}\n","import { Hono } from 'hono';\n\nimport { AuthorBridgeError } from '../../../../../../../models/authorBridgeState';\nimport { parseUseAuthorToolInput } from '../../../../../../../schemas/authorTools';\nimport type { AuthorCanvasRegistry } from '../../../../../../../services/authorCanvasRegistry';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorViewportCapabilityDescriptor } from '../../../../../../../types/author';\n\nfunction record(value: unknown): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new AuthorBridgeError('Invalid request.', 400);\n return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, key: string): string {\n const result = record(value)[key];\n if (typeof result !== 'string' || result === '') throw new AuthorBridgeError(`Invalid ${key}.`, 400);\n return result;\n}\n\nfunction generation(value: unknown): number {\n const result = record(value).generation;\n if (!Number.isSafeInteger(result) || (result as number) < 0) throw new AuthorBridgeError('Invalid generation.', 400);\n return result as number;\n}\n\nasync function body(request: Request): Promise<Record<string, unknown>> {\n return record(await request.json());\n}\n\nexport function createAuthorBridgeApi(registry: AuthorCanvasRegistry): Hono {\n const app = new Hono();\n app.onError((error, context) =>\n context.json(\n { error: error instanceof Error ? error.message : String(error) },\n error instanceof AuthorBridgeError ? error.status : 500,\n ),\n );\n app.post(routes.bridgeRegister.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({ ...registry.bridge(alias).register(text(value, 'bindingId'), generation(value)), alias });\n });\n app.post(routes.bridgeCatalog.path, async (context) => {\n const value = await body(context.req.raw);\n const tools = value.tools;\n if (!Array.isArray(tools)) throw new AuthorBridgeError('Invalid Author catalog.', 400);\n const alias = text(value, 'alias');\n return context.json({\n ...registry\n .bridge(alias)\n .catalog(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n tools as AuthorViewportCapabilityDescriptor[],\n ),\n alias,\n });\n });\n app.post(routes.bridgeNext.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({\n ...(await registry\n .bridge(alias)\n .next(text(value, 'bindingId'), generation(value), text(value, 'ownerToken'), context.req.raw.signal)),\n alias,\n });\n });\n app.post(routes.bridgeResult.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .result(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n value.result,\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeCancelled.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .cancelled(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeDisconnect.path, async (context) => {\n const value = await body(context.req.raw);\n registry.bridge(text(value, 'alias')).disconnect(text(value, 'bindingId'), generation(value));\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeClose.path, async (context) => {\n const value = await body(context.req.raw);\n registry.close(text(value, 'alias'));\n return context.json({ accepted: true });\n });\n app.get(routes.bridgeDescribe.path, (context) => context.json(registry.describe(context.req.query('alias'))));\n app.post(routes.bridgeInvoke.path, async (context) => {\n const value = parseUseAuthorToolInput(await context.req.raw.json());\n return context.json(await registry.invoke(value, context.req.raw.signal));\n });\n return app;\n}\n","import { Hono } from 'hono';\n\nimport {\n parseStructuredDocument,\n preflightStructuredDocument,\n serializeStructuredDocument,\n} from '../../../../../../../services/structuredDocuments';\nimport { DocumentRequestError } from '../../../../../../../services/structuredDocuments/common';\nimport { readDocument } from '../../../../../../../services/structuredDocuments/document';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorOpenFileResult } from '../../../../../../../types/author';\nimport type {\n CsvDialect,\n DocumentOperation,\n StructuredDocumentFormat,\n} from '../../../../../../../types/structuredDocuments';\n\nexport { AUTHOR_DOCUMENT_MAX_BYTES } from '../../../../../../../services/structuredDocuments/document';\n\ninterface DocumentRequest {\n path?: unknown;\n alias?: unknown;\n format?: unknown;\n operations?: unknown;\n preflightDigest?: unknown;\n csvDialect?: unknown;\n}\n\nexport interface AuthorDocumentApiOptions {\n cwd?: string;\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n open?: (path: string, signal?: AbortSignal, alias?: string) => Promise<AuthorOpenFileResult>;\n}\n\nconst FORMATS = new Set<StructuredDocumentFormat>(['markdown-slides', 'csv', 'pptx', 'xlsx']);\n\nfunction errorResponse(\n context: { json: (value: unknown, status: 400 | 403 | 404 | 413 | 422 | 500) => Response },\n error: unknown,\n): Response {\n const message = error instanceof Error ? error.message : 'Document operation failed.';\n // A refusal names its own status; anything else is a request the document cannot satisfy.\n return context.json({ error: message }, error instanceof DocumentRequestError ? error.status : 422);\n}\n\nfunction requestFormat(value: unknown): StructuredDocumentFormat {\n if (typeof value !== 'string' || !FORMATS.has(value as StructuredDocumentFormat))\n throw new Error('A supported format is required.');\n return value as StructuredDocumentFormat;\n}\n\nfunction requestOperations(value: unknown): DocumentOperation[] {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > 100_000) throw new Error('A bounded operations array is required.');\n return value.map((operation) => {\n if (\n typeof operation !== 'object' ||\n operation === null ||\n typeof (operation as Record<string, unknown>).fragmentId !== 'string' ||\n typeof (operation as Record<string, unknown>).replacement !== 'string'\n ) {\n throw new Error('Each operation requires string fragmentId and replacement fields.');\n }\n return operation as DocumentOperation;\n });\n}\n\nasync function bodyOf(request: Request): Promise<DocumentRequest> {\n const body = (await request.json()) as unknown;\n if (typeof body !== 'object' || body === null || Array.isArray(body)) throw new Error('A JSON object is required.');\n return body as DocumentRequest;\n}\n\nexport function createAuthorDocumentApi(options: AuthorDocumentApiOptions = {}): Hono {\n const app = new Hono();\n const cwd = options.cwd ?? process.cwd();\n\n app.post(routes.documentsOpen.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (body.format === undefined && options.open !== undefined) {\n return context.json(\n await options.open(body.path as string, context.req.raw.signal, body.alias as string | undefined),\n );\n }\n const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);\n if (body.format === undefined) {\n return context.json({ path: body.path as string, byteLength: bytes.byteLength } satisfies AuthorOpenFileResult);\n }\n return context.json(\n await parseStructuredDocument(requestFormat(body.format), bytes, body.csvDialect as Partial<CsvDialect>),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsPreflight.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);\n return context.json(\n await preflightStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.csvDialect as Partial<CsvDialect>,\n ),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsSerialize.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (typeof body.preflightDigest !== 'string') throw new Error('A preflight report digest is required.');\n const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);\n const serialized = await serializeStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.preflightDigest,\n body.csvDialect as Partial<CsvDialect>,\n );\n return context.json({\n bytes: Buffer.from(serialized.bytes).toString('base64'),\n encoding: 'base64',\n manifest: serialized.manifest,\n operationLog: serialized.operationLog,\n });\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n return app;\n}\n","import { randomUUID } from 'node:crypto';\n\nimport type { PoApi, PoApiContext, PoApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { Hono } from 'hono';\n\nimport { createAuthorBridgeState, type AuthorBridgeState } from '../../../../../../../models/authorBridgeState';\nimport {\n createAuthorCanvasRegistry,\n type AuthorCanvasRegistry,\n} from '../../../../../../../services/authorCanvasRegistry';\nimport type { AuthorCatalog } from '../../../../../../../services/authorCatalog/type';\nimport routes from '../../../../../../../types/apiRoutes';\nimport { API_BASE_PATH, type AuthorSessionView } from '../../../../../../../types/authorApi';\nimport { createAuthorBridgeApi } from './authorBridgeApi';\nimport { createAuthorDocumentApi } from './authorDocumentApi';\n\nexport interface AuthorApiOptions {\n sessionId?: string;\n cwd?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n readState?: () => Omit<AuthorSessionView, 'sessionId'>;\n registry?: AuthorCanvasRegistry;\n}\n\nconst inactiveState = (): Omit<AuthorSessionView, 'sessionId'> => ({ activation: 'inactive', capabilityCount: 0 });\nconst createBridge = (): AuthorBridgeState =>\n createAuthorBridgeState({\n now: Date.now,\n issueToken: randomUUID,\n scheduleTimeout(callback, delayMs) {\n const timer = setTimeout(callback, delayMs);\n timer.unref?.();\n return () => clearTimeout(timer);\n },\n });\n\nexport function createAuthorApi(options: AuthorApiOptions = {}): Hono {\n const app = new Hono();\n const registry =\n options.registry ??\n createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId, options.environment);\n app.get(routes.state.path, (context) =>\n context.json({\n sessionId: options.sessionId ?? null,\n ...(options.readState ?? inactiveState)(),\n } satisfies AuthorSessionView),\n );\n app.route('/', createAuthorBridgeApi(registry));\n app.route(\n '/',\n createAuthorDocumentApi({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.sessionId === undefined ? {} : { sessionId: options.sessionId }),\n ...(options.environment === undefined ? {} : { environment: options.environment }),\n open: (path, signal, alias) => registry.open(path, signal, alias),\n }),\n );\n return app;\n}\n\nexport const api: PoApi = {\n basePath: API_BASE_PATH,\n start(context: PoApiContext): PoApiHandler {\n // One server hosts many sessions, so its own directory is never a session's project.\n if (context.cwd === undefined) throw new Error('Author requires the session working directory.');\n const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId, context.environment);\n const app = createAuthorApi({\n ...(context.sessionId === undefined ? {} : { sessionId: context.sessionId }),\n cwd: context.cwd,\n ...(context.environment === undefined ? {} : { environment: context.environment }),\n registry,\n });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n};\n\n/** The session API and tools share the same browser ownership and pending requests. */\nexport function createAuthorSessionApi(\n cwd: string,\n sessionId: string,\n environment: Readonly<Record<string, string | undefined>>,\n): { api: PoApi; catalog: AuthorCatalog } {\n const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId, environment);\n return {\n catalog: {\n open: (path, signal, alias) => registry.open(path, signal, alias),\n async describe(signal, alias) {\n signal?.throwIfAborted();\n return registry.describe(alias);\n },\n execute: (input, signal) => registry.invoke(input, signal),\n },\n api: {\n basePath: API_BASE_PATH,\n start() {\n const app = createAuthorApi({ cwd, sessionId, environment, registry });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\nimport { serverMinorModes } from '@agimon-ai/po-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { authorMinorMode } from '../../../../models/authorMode';\nimport { createAuthorCatalog } from '../../../../services/authorCatalog';\nimport { createWebmcpNamespace } from '../../../../services/webmcpNamespace';\nimport { api, createAuthorSessionApi } from './api/author/_lib/authorApi';\n\nexport default defineRoot(({ agent, host, signal }: PoServerPluginContext) => {\n const environment = host.context.environment;\n if (agent && environment === undefined) throw new Error('Author requires an admitted session environment.');\n const session =\n agent && environment ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId, environment) : undefined;\n const isActive = () => (agent?.context.selection.state?.['minor-mode'] ?? []).includes(authorMinorMode.descriptor.id);\n const mode = agent\n ? authorMinorMode.createOwner({\n isActive,\n detail: () => 'document authoring available',\n async setActive(enabled) {\n const modes = (agent.context.selection.state?.['minor-mode'] ?? []).filter(\n (id) => id !== authorMinorMode.descriptor.id,\n );\n await agent.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, authorMinorMode.descriptor.id] : modes,\n });\n },\n })\n : undefined;\n let disposed = false;\n const catalog = createAuthorCatalog(session?.catalog);\n const assertAvailable = () => {\n signal.throwIfAborted();\n if (disposed) throw new Error('Author session is disposed.');\n if (!isActive()) throw new Error('Author mode is not active.');\n };\n const mountNamespace = (context: Context) => {\n if (!agent) return;\n const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAvailable);\n context.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const registration = readPoCodemode(scoped)?.register('@agimon-ai/po-author', namespace);\n return () => registration?.dispose();\n });\n };\n return {\n onDispose: () => {\n disposed = true;\n },\n value: {\n api: session?.api ?? api,\n catalog,\n // Registration is gated by AUTHOR_TOOL_WHEN; this re-checks a call already in flight when the mode turns off.\n assertAvailable,\n service: undefined,\n },\n services: [...(mode ? [serverMinorModes([mode])] : []), mountNamespace],\n };\n});\n","import type { AuthorViewportCapabilityDescriptor } from './author';\n\nexport const authorChannelType = 'author_webmcp';\n\nexport interface AuthorRegisterMessage {\n alias: string;\n kind: 'register';\n generation: number;\n}\n\nexport interface AuthorReleaseMessage {\n alias: string;\n kind: 'release';\n generation: number;\n}\nexport interface AuthorCatalogMessage {\n alias: string;\n kind: 'catalog';\n generation: number;\n ownerToken: string;\n tools: AuthorViewportCapabilityDescriptor[];\n}\n\nexport interface AuthorResultMessage {\n alias: string;\n kind: 'result';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n result: unknown;\n}\n\nexport interface AuthorCancelledMessage {\n alias: string;\n kind: 'cancelled';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport type AuthorBrowserMessage =\n | AuthorRegisterMessage\n | AuthorReleaseMessage\n | AuthorCatalogMessage\n | AuthorResultMessage\n | AuthorCancelledMessage;\n\nexport interface AuthorAcceptedMessage {\n alias?: string;\n kind: 'accepted';\n generation: number;\n ownerToken: string;\n catalogToken?: string;\n leaseMs: number;\n}\n\nexport interface AuthorRequestMessage {\n alias?: string;\n kind: 'request';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n name: string;\n arguments: Record<string, unknown>;\n}\n\nexport interface AuthorCancelMessage {\n alias?: string;\n kind: 'cancel';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport interface AuthorRejectedMessage {\n alias?: string;\n kind: 'rejected';\n reason: string;\n}\n\nexport type AuthorHubMessage =\n | AuthorAcceptedMessage\n | AuthorRequestMessage\n | AuthorCancelMessage\n | AuthorRejectedMessage;\n\nexport interface AuthorWebView {\n activation: 'inactive' | 'active';\n capabilityCount: number;\n}\n","import type {\n PoHubChannelConnection,\n PoHubChannelHost,\n PoHubChannelSource,\n PoHubSessionScope,\n PoHubChannel,\n} from '@agimon-ai/po-core/hubChannel';\n\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport routes from '../../types/apiRoutes';\nimport { API_BASE_PATH } from '../../types/authorApi';\nimport { authorChannelType, type AuthorBrowserMessage, type AuthorHubMessage } from '../../types/webAuthor';\n\n/**\n * Which route carries each message the browser sends.\n *\n * The paths come from the package's one route table, so the hub cannot address\n * a bridge route the session no longer serves. `release` is absent because it\n * is answered by the disconnect route rather than one of its own.\n */\nconst BRIDGE_ROUTE: Readonly<Record<Exclude<AuthorBrowserMessage['kind'], 'release'>, string>> = {\n register: routes.bridgeRegister.path,\n catalog: routes.bridgeCatalog.path,\n result: routes.bridgeResult.path,\n cancelled: routes.bridgeCancelled.path,\n};\n\ninterface Binding {\n alias: string;\n scope: PoHubSessionScope;\n connectionId: string;\n generation: number;\n ownerToken: string;\n poll?: AbortController;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction browserMessage(value: unknown): AuthorBrowserMessage | undefined {\n if (\n !isRecord(value) ||\n typeof value.kind !== 'string' ||\n typeof value.alias !== 'string' ||\n !AUTHOR_ALIAS_PATTERN.test(value.alias)\n )\n return undefined;\n if (!['register', 'release', 'catalog', 'result', 'cancelled'].includes(value.kind)) return undefined;\n return value as unknown as AuthorBrowserMessage;\n}\n\nasync function responsePayload(response: Response): Promise<AuthorHubMessage> {\n const value = (await response.json()) as unknown;\n if (response.ok) return value as AuthorHubMessage;\n const reason =\n isRecord(value) && typeof value.error === 'string' ? value.error : `Author bridge HTTP ${response.status}`;\n return { kind: 'rejected', reason };\n}\n\nexport function createAuthorChannel(): PoHubChannel {\n const bindings = new Map<string, Binding>();\n let host: PoHubChannelHost | undefined;\n let closed = false;\n const keyOf = (sessionId: string, connectionId: string, alias: string): string =>\n `${sessionId}\\0${connectionId}\\0${alias}`;\n const send = async (scope: PoHubSessionScope, path: string, value: Record<string, unknown>, signal?: AbortSignal) =>\n await host!.requestSessionApi(scope, {\n basePath: API_BASE_PATH,\n path,\n method: 'POST',\n body: JSON.stringify(value),\n ...(signal === undefined ? {} : { signal }),\n });\n const publish = (binding: Binding, payload: AuthorHubMessage): boolean =>\n host?.publishToConnection?.(binding.connectionId, binding.scope.sessionId, { ...payload, alias: binding.alias }) ??\n false;\n\n const poll = async (binding: Binding): Promise<void> => {\n binding.poll?.abort();\n const controller = new AbortController();\n binding.poll = controller;\n while (!closed && bindings.get(keyOf(binding.scope.sessionId, binding.connectionId, binding.alias)) === binding) {\n try {\n const response = await send(\n binding.scope,\n routes.bridgeNext.path,\n {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n ownerToken: binding.ownerToken,\n },\n controller.signal,\n );\n const payload = await responsePayload(response);\n if (controller.signal.aborted) break;\n if (!publish(binding, payload) || payload.kind === 'rejected') break;\n } catch (error) {\n if (!controller.signal.aborted) host?.onNotice(error instanceof Error ? error.message : String(error));\n break;\n }\n }\n if (binding.poll === controller) binding.poll = undefined;\n };\n\n const channel: PoHubChannel = {\n frameType: authorChannelType,\n lifecycle: 'hub',\n receiveWithoutSubscription: true,\n start(channelHost) {\n host = channelHost;\n const source: PoHubChannelSource = {\n payloadFor: () => undefined,\n sessionRemoved(sessionId) {\n for (const [key, binding] of bindings) {\n if (binding.scope.sessionId !== sessionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n close() {\n closed = true;\n for (const binding of bindings.values()) {\n binding.poll?.abort();\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n bindings.clear();\n },\n };\n return source;\n },\n receive(scope, payload, connection) {\n const message = browserMessage(payload);\n if (message === undefined || host === undefined || closed) return;\n void (async () => {\n const key = keyOf(scope.sessionId, connection.connectionId, message.alias);\n const previous = bindings.get(key);\n if (message.kind === 'release') {\n if (previous === undefined || previous.generation !== message.generation) return;\n previous.poll?.abort();\n bindings.delete(key);\n await send(scope, routes.bridgeDisconnect.path, {\n alias: message.alias,\n bindingId: connection.connectionId,\n generation: message.generation,\n });\n return;\n }\n const route = BRIDGE_ROUTE[message.kind];\n const response = await send(scope, route, { ...message, bindingId: connection.connectionId });\n const reply = await responsePayload(response);\n if (reply.kind === 'accepted') {\n const current = bindings.get(key);\n if (current?.generation === reply.generation && current.ownerToken === reply.ownerToken) {\n publish(current, reply);\n if (current.poll === undefined) void poll(current);\n return;\n }\n const binding: Binding = {\n alias: message.alias,\n scope,\n connectionId: connection.connectionId,\n generation: reply.generation,\n ownerToken: reply.ownerToken,\n };\n current?.poll?.abort();\n bindings.set(key, binding);\n publish(binding, reply);\n void poll(binding);\n } else if (reply.kind === 'rejected') {\n if (previous !== undefined) publish(previous, reply);\n else\n host?.publishToConnection?.(connection.connectionId, scope.sessionId, { ...reply, alias: message.alias });\n }\n })().catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n },\n disconnected(connection: PoHubChannelConnection) {\n for (const [key, binding] of bindings) {\n if (binding.connectionId !== connection.connectionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n };\n return channel;\n}\n","import { defineChannel } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorChannel } from '../../../services/webAuthorChannel';\n\nexport default defineChannel(createAuthorChannel);\n","import { defineServerMethod, type PoServerHostService } from '@agimon-ai/po-core/serverPlugin';\n\nimport { authorBridgeMethod } from '../../schemas/authorFacade';\nimport { authorChannelType } from '../../types/webAuthor';\n\nexport function createAuthorBridgeMethod(scope: 'global' | 'workspace', host: PoServerHostService) {\n return defineServerMethod(authorBridgeMethod(scope), ({ sessionId, message }, caller) => {\n if (!caller.connectionId) throw new Error('Author bridge requires an authenticated browser connection.');\n if (!host.context.receiveChannel?.(sessionId, authorChannelType, message, caller.connectionId))\n throw new Error('Author bridge session is outside this mount.');\n return {};\n });\n}\n","import { defineMethod } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createAuthorBridgeMethod } from '../../../services/authorBridgeMethod';\n\nexport default defineMethod(({ host }: PoServerPluginContext) =>\n host.scope === 'session'\n ? { register: () => ({ dispose: () => undefined }) }\n : createAuthorBridgeMethod(host.scope, host),\n);\n","import { defineRoute, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\ntype AuthorServerScope = Awaited<ReturnType<typeof import('../../root.server').default>>['value'];\n\nexport default defineRoute((context: WithRoot<PoServerPluginContext, AuthorServerScope>) => context.root.api);\n","import { defineCommand as defineRoutedCommand, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorCommand } from '../../../../../services/authorCommand';\nimport type { AuthorExtensionService } from '../../../../../types/extension';\n\nexport default defineRoutedCommand((context: WithRoot<unknown, { readonly service?: AuthorExtensionService }>) =>\n createAuthorCommand(context.root.service),\n);\n","import { defineHook } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_GUIDANCE } from '../../../../../constants/author';\n\nexport default defineHook<'before_agent_start'>({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor', mode: 'author' } },\n event: 'before_agent_start',\n handle(event) {\n const systemPrompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${systemPrompt}\\n\\n${AUTHOR_GUIDANCE}`.trim() };\n },\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nconst skillFile = 'src/prompts/codemode-how-to-author/SKILL.md';\n\nexport default defineResource({\n name: 'codemode-how-to-author',\n description:\n 'Call Author canvas capabilities through the webmcp namespace in code mode. Use for canvas discovery, capability calls, and their catalog tokens from exec.',\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, skillFile),\n read: () => readPackageResource(import.meta.url, skillFile),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor' as const, mode: 'author' } },\n name: 'po-use-author',\n description: 'Use the Author workflow for focused document review, canvas steering, and bounded authoring.',\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n});\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[1]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[0]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[2]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelAuthorWebmcp from '../src/extensions/(backend)/channel/author-webmcp.server';\nimport methodBridge from '../src/extensions/(backend)/method/bridge.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/author/route.server';\nimport commandAuthor from '../src/extensions/workspaces/sessions/(backend)/command/author.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport resourceCodemodeHowToAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server';\nimport resourcePoUseAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server';\nimport toolDescribeAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server';\nimport toolOpenAuthoringFile from '../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server';\nimport toolUseAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-author',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n global: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return [() => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n workspace: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get commands(): PoServerSessionPlugin['commands'] { return [via({ name: 'author' }, at(commandAuthor, contextSession))]; },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToAuthor, contextSession), at(resourcePoUseAuthor, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [via({ name: 'describe_author_tools' }, at(toolDescribeAuthorTools, contextSession)), via({ name: 'open_authoring_file' }, at(toolOpenAuthoringFile, contextSession)), via({ name: 'use_author_tools' }, at(toolUseAuthorTools, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,MAAM,eAAe;;;;;;;;;;;;;;;AAgBrB,SAAS,KAAQ,OAAa;CAC5B,OAAO,UAAU,KAAA,IAAY,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACvE;AAEA,SAAgB,sBACd,SACA,WACA,iBACqB;CACrB,OAAO;EACL,MA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vI,IAAI,UAA4C;IAAE,OAAO,CAAC,GAAGJ,uBAAc,OAAO,CAAC;GAAG;GACtF,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGK,uCAA6B,cAAc,GAAG,GAAGC,8BAAqB,cAAc,CAAC;GAAG;GACzJ,IAAI,QAAwC;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,wBAAwB,GAAG,GAAGC,sCAAyB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,sBAAsB,GAAG,GAAGC,oCAAuB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,iCAAoB,cAAc,CAAC;IAAC;GAAG;GACxS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
@@ -7,6 +7,7 @@ import path from "node:path";
7
7
  import { composeRootHooks, composeRootInjects, defineChannel, defineCommand as defineCommand$1, defineHook, defineMethod, defineResource, defineRoot, defineRoute, defineTool as defineTool$1 } from "@agimon-ai/po-core/extensionFile";
8
8
  import { PO_CODEMODE_SERVICE, readPoCodemode } from "@agimon-ai/po-core/codemode";
9
9
  import { Hono } from "hono";
10
+ import { constants } from "node:fs";
10
11
  import fs from "node:fs/promises";
11
12
  import { ArtifactAccessError, artifactRoot, openArtifact, readArtifactBytes } from "@agimon-ai/po-artifact/artifactFiles";
12
13
  import { apiResponse, defineApiRoutes } from "@agimon-ai/po-core/web";
@@ -76,13 +77,13 @@ function inside(root, candidate) {
76
77
  * may read. It is named either `artifact:<relative>` or by the absolute path the
77
78
  * agent's prompt gives; po-artifact's guarded open does the containment checks.
78
79
  */
79
- async function resolveArtifact(requestedPath, sessionId) {
80
+ async function resolveArtifact(requestedPath, sessionId, environment) {
80
81
  const prefixed = requestedPath.startsWith(AUTHOR_ARTIFACT_PREFIX);
81
- if (sessionId === void 0) {
82
+ if (sessionId === void 0 || environment === void 0) {
82
83
  if (prefixed) throw new DocumentRequestError("Artifacts need a session.", 400);
83
84
  return;
84
85
  }
85
- const root = artifactRoot(sessionId, process.env);
86
+ const root = artifactRoot(sessionId, environment);
86
87
  if (prefixed) return {
87
88
  root,
88
89
  relative: requestedPath.slice(AUTHOR_ARTIFACT_PREFIX.length)
@@ -95,9 +96,9 @@ async function resolveArtifact(requestedPath, sessionId) {
95
96
  relative: path.relative(base, requestedPath).split(path.sep).join("/")
96
97
  };
97
98
  }
98
- async function resolveDocument(cwd, requestedPath, sessionId) {
99
+ async function resolveDocument(cwd, requestedPath, sessionId, environment) {
99
100
  if (typeof requestedPath !== "string" || requestedPath.length === 0 || requestedPath.includes("\0")) throw new Error("A relative document path is required.");
100
- const artifact = await resolveArtifact(requestedPath, sessionId);
101
+ const artifact = await resolveArtifact(requestedPath, sessionId, environment);
101
102
  if (artifact !== void 0) {
102
103
  const realRoot = await fs.realpath(artifact.root).catch(() => artifact.root);
103
104
  return {
@@ -115,6 +116,7 @@ async function resolveDocument(cwd, requestedPath, sessionId) {
115
116
  if (realCandidate !== root && !realCandidate.startsWith(`${root}${path.sep}`)) throw new DocumentRequestError("Document path is outside the working directory.", 403);
116
117
  return {
117
118
  kind: "workspace",
119
+ root,
118
120
  path: path.relative(root, realCandidate).split(path.sep).join("/"),
119
121
  realPath: realCandidate
120
122
  };
@@ -136,16 +138,27 @@ async function readArtifact(root, relative) {
136
138
  }
137
139
  async function readSource(source) {
138
140
  if (source.kind === "artifact") return await readArtifact(source.root, source.relative);
139
- if ((await fs.stat(source.realPath)).size > 26214400) throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);
140
- return await fs.readFile(source.realPath);
141
+ if (process.platform !== "darwin" && process.platform !== "linux") throw new DocumentRequestError("Secure document reads require macOS or Linux.", 403);
142
+ const noFollow = process.platform === "darwin" ? 536870912 : constants.O_NOFOLLOW;
143
+ const handle = await fs.open(source.realPath, constants.O_RDONLY | constants.O_NONBLOCK | noFollow);
144
+ try {
145
+ const stat = await handle.stat();
146
+ const current = await fs.lstat(source.realPath);
147
+ const realPath = await fs.realpath(process.platform === "linux" ? `/proc/self/fd/${handle.fd}` : source.realPath);
148
+ if (!stat.isFile() || !current.isFile() || stat.dev !== current.dev || stat.ino !== current.ino || !inside(source.root, realPath)) throw new DocumentRequestError("The document changed or is outside the working directory.", 403);
149
+ if (stat.size > 26214400) throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);
150
+ return await readArtifactBytes(handle, stat.size);
151
+ } finally {
152
+ await handle.close();
153
+ }
141
154
  }
142
- async function readDocument(cwd, requestedPath, sessionId) {
143
- return await readSource(await resolveDocument(cwd, requestedPath, sessionId));
155
+ async function readDocument(cwd, requestedPath, sessionId, environment) {
156
+ return await readSource(await resolveDocument(cwd, requestedPath, sessionId, environment));
144
157
  }
145
158
  //#endregion
146
159
  //#region src/services/authorCanvasRegistry/index.ts
147
160
  const MAX_CANVASES = 32;
148
- function createAuthorCanvasRegistry(cwd, createBridge, sessionId) {
161
+ function createAuthorCanvasRegistry(cwd, createBridge, sessionId, environment) {
149
162
  const byAlias = /* @__PURE__ */ new Map();
150
163
  const byPath = /* @__PURE__ */ new Map();
151
164
  const select = (alias) => {
@@ -185,7 +198,7 @@ function createAuthorCanvasRegistry(cwd, createBridge, sessionId) {
185
198
  async open(requestedPath, signal, requestedAlias) {
186
199
  signal?.throwIfAborted();
187
200
  if (requestedAlias !== void 0 && !AUTHOR_ALIAS_PATTERN.test(requestedAlias)) throw new AuthorBridgeError("Invalid Author canvas alias.", 400);
188
- const source = await resolveDocument(cwd, requestedPath, sessionId);
201
+ const source = await resolveDocument(cwd, requestedPath, sessionId, environment);
189
202
  const bytes = await readSource(source);
190
203
  signal?.throwIfAborted();
191
204
  const { realPath, path: canonicalPath } = source;
@@ -511,7 +524,7 @@ function createAuthorDocumentApi(options = {}) {
511
524
  try {
512
525
  const body = await bodyOf(context.req.raw);
513
526
  if (body.format === void 0 && options.open !== void 0) return context.json(await options.open(body.path, context.req.raw.signal, body.alias));
514
- const bytes = await readDocument(cwd, body.path, options.sessionId);
527
+ const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);
515
528
  if (body.format === void 0) return context.json({
516
529
  path: body.path,
517
530
  byteLength: bytes.byteLength
@@ -524,7 +537,7 @@ function createAuthorDocumentApi(options = {}) {
524
537
  app.post(apiRoutes_default.documentsPreflight.path, async (context) => {
525
538
  try {
526
539
  const body = await bodyOf(context.req.raw);
527
- const bytes = await readDocument(cwd, body.path, options.sessionId);
540
+ const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);
528
541
  return context.json(await preflightStructuredDocument(requestFormat(body.format), bytes, requestOperations(body.operations), body.csvDialect));
529
542
  } catch (error) {
530
543
  return errorResponse(context, error);
@@ -534,7 +547,7 @@ function createAuthorDocumentApi(options = {}) {
534
547
  try {
535
548
  const body = await bodyOf(context.req.raw);
536
549
  if (typeof body.preflightDigest !== "string") throw new Error("A preflight report digest is required.");
537
- const bytes = await readDocument(cwd, body.path, options.sessionId);
550
+ const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);
538
551
  const serialized = await serializeStructuredDocument(requestFormat(body.format), bytes, requestOperations(body.operations), body.preflightDigest, body.csvDialect);
539
552
  return context.json({
540
553
  bytes: Buffer.from(serialized.bytes).toString("base64"),
@@ -565,7 +578,7 @@ const createBridge = () => createAuthorBridgeState({
565
578
  });
566
579
  function createAuthorApi(options = {}) {
567
580
  const app = new Hono();
568
- const registry = options.registry ?? createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId);
581
+ const registry = options.registry ?? createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId, options.environment);
569
582
  app.get(apiRoutes_default.state.path, (context) => context.json({
570
583
  sessionId: options.sessionId ?? null,
571
584
  ...(options.readState ?? inactiveState)()
@@ -574,6 +587,7 @@ function createAuthorApi(options = {}) {
574
587
  app.route("/", createAuthorDocumentApi({
575
588
  ...options.cwd === void 0 ? {} : { cwd: options.cwd },
576
589
  ...options.sessionId === void 0 ? {} : { sessionId: options.sessionId },
590
+ ...options.environment === void 0 ? {} : { environment: options.environment },
577
591
  open: (path, signal, alias) => registry.open(path, signal, alias)
578
592
  }));
579
593
  return app;
@@ -582,10 +596,11 @@ const api = {
582
596
  basePath: API_BASE_PATH,
583
597
  start(context) {
584
598
  if (context.cwd === void 0) throw new Error("Author requires the session working directory.");
585
- const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId);
599
+ const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId, context.environment);
586
600
  const app = createAuthorApi({
587
601
  ...context.sessionId === void 0 ? {} : { sessionId: context.sessionId },
588
602
  cwd: context.cwd,
603
+ ...context.environment === void 0 ? {} : { environment: context.environment },
589
604
  registry
590
605
  });
591
606
  return {
@@ -595,8 +610,8 @@ const api = {
595
610
  }
596
611
  };
597
612
  /** The session API and tools share the same browser ownership and pending requests. */
598
- function createAuthorSessionApi(cwd, sessionId) {
599
- const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId);
613
+ function createAuthorSessionApi(cwd, sessionId, environment) {
614
+ const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId, environment);
600
615
  return {
601
616
  catalog: {
602
617
  open: (path, signal, alias) => registry.open(path, signal, alias),
@@ -612,6 +627,7 @@ function createAuthorSessionApi(cwd, sessionId) {
612
627
  const app = createAuthorApi({
613
628
  cwd,
614
629
  sessionId,
630
+ environment,
615
631
  registry
616
632
  });
617
633
  return {
@@ -624,8 +640,10 @@ function createAuthorSessionApi(cwd, sessionId) {
624
640
  }
625
641
  //#endregion
626
642
  //#region src/extensions/workspaces/sessions/(backend)/root.server.ts
627
- var root_server_default = defineRoot(({ agent, signal }) => {
628
- const session = agent ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId) : void 0;
643
+ var root_server_default = defineRoot(({ agent, host, signal }) => {
644
+ const environment = host.context.environment;
645
+ if (agent && environment === void 0) throw new Error("Author requires an admitted session environment.");
646
+ const session = agent && environment ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId, environment) : void 0;
629
647
  const isActive = () => (agent?.context.selection.state?.["minor-mode"] ?? []).includes(authorMinorMode.descriptor.id);
630
648
  const mode = agent ? authorMinorMode.createOwner({
631
649
  isActive,
@@ -1 +1 @@
1
- {"version":3,"file":"server.mjs","names":["routes","routes","routes","routes","defineRoutedCommand","defineTool","defineTool","defineTool","rootSession","channelAuthorWebmcp","methodBridge","apiRoute","commandAuthor","hookBeforeAgentStart","resourceCodemodeHowToAuthor","resourcePoUseAuthor","toolDescribeAuthorTools","toolOpenAuthoringFile","toolUseAuthorTools"],"sources":["../../src/services/webmcpNamespace/index.ts","../../src/services/structuredDocuments/document.ts","../../src/services/authorCanvasRegistry/index.ts","../../src/types/apiRoutes.ts","../../src/types/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorBridgeApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorDocumentApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/types/webAuthor.ts","../../src/services/webAuthorChannel/index.ts","../../src/extensions/(backend)/channel/author-webmcp.server.ts","../../src/services/authorBridgeMethod/index.ts","../../src/extensions/(backend)/method/bridge.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/author.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server.ts","../../generated/server.ts"],"sourcesContent":["import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\n\nimport { parseDescribeAuthorToolsInput, parseUseAuthorToolInput } from '../../schemas/authorTools';\nimport type { AuthorCatalog } from '../authorCatalog/type';\n\n// ponytail: typed per-canvas members need a synchronous catalog reader and a shared schema converter in po-core.\nconst DECLARATIONS = `interface AuthorViewportCatalogSnapshot {\n catalogToken: string;\n tools: { name: string; label: string; description: string; inputSchema: Readonly<Record<string, unknown>> }[];\n canvases?: { alias: string; path: string; status: 'opening' | 'ready' | 'unavailable' }[];\n alias?: string;\n path?: string;\n status?: 'opening' | 'ready' | 'unavailable';\n nextStep?: string;\n}\ndeclare const webmcp: {\n /** Ready canvases, or one canvas's tools and its catalog token. */\n describe(input?: { alias?: string }): Promise<AuthorViewportCatalogSnapshot>;\n /** Call one tool with an explicit current token. Await same-canvas calls sequentially. */\n call(input: { alias?: string; catalogToken: string; name: string; arguments: Record<string, unknown> }): Promise<unknown>;\n};`;\n\nfunction copy<T>(value: T): T {\n return value === undefined ? value : JSON.parse(JSON.stringify(value));\n}\n\nexport function createWebmcpNamespace(\n catalog: AuthorCatalog,\n sessionId: string,\n assertAvailable: () => void,\n): PoCodemodeNamespace {\n return {\n name: 'webmcp',\n summary:\n 'Author canvas WebMCP: describe catalogs, then call one tool with its explicit token. Await same-canvas calls sequentially; structured errors remain data.',\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== sessionId) throw new Error('Author WebMCP namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n run.signal.throwIfAborted();\n if (disposed) throw new Error('Author WebMCP run is disposed.');\n assertAvailable();\n };\n const members: Record<string, unknown> = Object.create(null);\n members.describe = async (input?: unknown) => {\n check();\n const { alias } = parseDescribeAuthorToolsInput(copy(input === undefined ? {} : input));\n const result = await catalog.describe(run.signal, alias);\n check();\n return copy(result);\n };\n members.call = async (input: unknown) => {\n check();\n const parsed = parseUseAuthorToolInput(copy(input));\n const result = await catalog.execute(parsed, run.signal);\n check();\n return copy(result.result);\n };\n return members;\n },\n };\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n ArtifactAccessError,\n artifactRoot,\n openArtifact,\n readArtifactBytes,\n} from '@agimon-ai/po-artifact/artifactFiles';\n\nimport { AUTHOR_ARTIFACT_PREFIX } from '../../constants/author';\nimport { DocumentRequestError, documentTooLarge } from './common';\n\nexport const AUTHOR_DOCUMENT_MAX_BYTES = 25 * 1024 * 1024;\n\n/**\n * Where a requested document lives. `path` is the canonical form clients use;\n * `realPath` identifies the file so two spellings share one canvas.\n */\nexport type AuthorDocumentSource =\n | { kind: 'workspace'; path: string; realPath: string }\n | { kind: 'artifact'; path: string; realPath: string; root: string; relative: string };\n\nfunction inside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);\n}\n\n/**\n * The session artifact folder is the one place outside the working tree Author\n * may read. It is named either `artifact:<relative>` or by the absolute path the\n * agent's prompt gives; po-artifact's guarded open does the containment checks.\n */\nasync function resolveArtifact(requestedPath: string, sessionId: string | undefined) {\n const prefixed = requestedPath.startsWith(AUTHOR_ARTIFACT_PREFIX);\n if (sessionId === undefined) {\n if (prefixed) throw new DocumentRequestError('Artifacts need a session.', 400);\n return undefined;\n }\n const root = artifactRoot(sessionId, process.env);\n if (prefixed) return { root, relative: requestedPath.slice(AUTHOR_ARTIFACT_PREFIX.length) };\n if (!path.isAbsolute(requestedPath)) return undefined;\n const realRoot = await fs.realpath(root).catch(() => root);\n const base = [root, realRoot].find((candidate) => inside(candidate, requestedPath));\n if (base === undefined) return undefined;\n return { root, relative: path.relative(base, requestedPath).split(path.sep).join('/') };\n}\n\nexport async function resolveDocument(\n cwd: string,\n requestedPath: unknown,\n sessionId?: string,\n): Promise<AuthorDocumentSource> {\n if (typeof requestedPath !== 'string' || requestedPath.length === 0 || requestedPath.includes('\\0'))\n throw new Error('A relative document path is required.');\n const artifact = await resolveArtifact(requestedPath, sessionId);\n if (artifact !== undefined) {\n const realRoot = await fs.realpath(artifact.root).catch(() => artifact.root);\n return {\n kind: 'artifact',\n path: `${AUTHOR_ARTIFACT_PREFIX}${artifact.relative}`,\n realPath: path.join(realRoot, artifact.relative),\n ...artifact,\n };\n }\n if (path.isAbsolute(requestedPath))\n throw new Error('A relative document path, or a file in the session artifact folder, is required.');\n const root = await fs.realpath(cwd);\n const candidate = path.resolve(root, requestedPath);\n if (candidate !== root && !candidate.startsWith(`${root}${path.sep}`))\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n const realCandidate = await fs.realpath(candidate);\n if (realCandidate !== root && !realCandidate.startsWith(`${root}${path.sep}`)) {\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n }\n return {\n kind: 'workspace',\n path: path.relative(root, realCandidate).split(path.sep).join('/'),\n realPath: realCandidate,\n };\n}\n\nasync function readArtifact(root: string, relative: string): Promise<Uint8Array> {\n let file: Awaited<ReturnType<typeof openArtifact>>;\n try {\n file = await openArtifact(root, relative);\n } catch (error) {\n if (error instanceof ArtifactAccessError) throw new DocumentRequestError(error.message, error.status);\n throw error;\n }\n try {\n if (file.stat.size > AUTHOR_DOCUMENT_MAX_BYTES)\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n return await readArtifactBytes(file.handle, file.stat.size);\n } finally {\n await file.handle.close();\n }\n}\n\nexport async function readSource(source: AuthorDocumentSource): Promise<Uint8Array> {\n if (source.kind === 'artifact') return await readArtifact(source.root, source.relative);\n const stat = await fs.stat(source.realPath);\n if (stat.size > AUTHOR_DOCUMENT_MAX_BYTES) {\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n }\n return await fs.readFile(source.realPath);\n}\n\nexport async function readDocument(cwd: string, requestedPath: unknown, sessionId?: string): Promise<Uint8Array> {\n return await readSource(await resolveDocument(cwd, requestedPath, sessionId));\n}\n","import path from 'node:path';\n\nimport { AuthorBridgeError, type AuthorBridgeState } from '../../models/authorBridgeState';\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport type {\n AuthorCanvasView,\n AuthorOpenFileResult,\n AuthorViewportCatalogSnapshot,\n UseAuthorToolInput,\n} from '../../types/author';\nimport { readSource, resolveDocument } from '../structuredDocuments/document';\n\ninterface Canvas {\n alias: string;\n path: string;\n realPath: string;\n bridge: AuthorBridgeState;\n closed: boolean;\n readyOnce: boolean;\n}\n\nconst MAX_CANVASES = 32;\n\nexport function createAuthorCanvasRegistry(\n cwd: string,\n createBridge: () => AuthorBridgeState,\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string,\n) {\n const byAlias = new Map<string, Canvas>();\n const byPath = new Map<string, Canvas>();\n\n const select = (alias?: string): Canvas => {\n if (alias !== undefined) {\n if (!AUTHOR_ALIAS_PATTERN.test(alias)) throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const canvas = byAlias.get(alias);\n if (canvas === undefined)\n throw new AuthorBridgeError(\n `Unknown Author canvas '${alias}'. Call describe_author_tools({}) for available aliases.`,\n 404,\n );\n return canvas;\n }\n const canvases = [...byAlias.values()].filter((canvas) => !canvas.closed);\n if (canvases.length !== 1)\n throw new AuthorBridgeError('Specify a canvas alias. Call describe_author_tools({}) to list canvases.', 409);\n return canvases[0]!;\n };\n\n const view = (canvas: Canvas): AuthorCanvasView => {\n if (canvas.closed) return { alias: canvas.alias, path: canvas.path, status: 'unavailable' };\n try {\n canvas.bridge.describe();\n canvas.readyOnce = true;\n return { alias: canvas.alias, path: canvas.path, status: 'ready' };\n } catch {\n return { alias: canvas.alias, path: canvas.path, status: canvas.readyOnce ? 'unavailable' : 'opening' };\n }\n };\n\n return {\n async open(requestedPath: string, signal?: AbortSignal, requestedAlias?: string): Promise<AuthorOpenFileResult> {\n signal?.throwIfAborted();\n if (requestedAlias !== undefined && !AUTHOR_ALIAS_PATTERN.test(requestedAlias))\n throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const source = await resolveDocument(cwd, requestedPath, sessionId);\n const bytes = await readSource(source);\n signal?.throwIfAborted();\n const { realPath, path: canonicalPath } = source;\n const occupied = requestedAlias === undefined ? undefined : byAlias.get(requestedAlias);\n if (occupied !== undefined && occupied.realPath !== realPath)\n throw new AuthorBridgeError(`Author canvas alias '${requestedAlias}' already names ${occupied.path}.`, 409);\n const existing = byPath.get(realPath);\n if (existing !== undefined) {\n if (existing.closed) existing.readyOnce = false;\n existing.closed = false;\n return {\n path: existing.path,\n byteLength: bytes.byteLength,\n alias: existing.alias,\n status: view(existing).status,\n reused: true,\n };\n }\n if (byAlias.size >= MAX_CANVASES) {\n const reusable = [...byAlias.values()].find((canvas) => canvas.closed);\n if (reusable === undefined) throw new AuthorBridgeError('Too many Author canvases in this conversation.', 409);\n reusable.bridge.close();\n byAlias.delete(reusable.alias);\n byPath.delete(reusable.realPath);\n }\n const base =\n path\n .basename(realPath)\n .replace(/\\.[^.]*$/u, '')\n .toLowerCase()\n .replace(/[^a-z0-9_-]+/gu, '-')\n .replace(/^[^a-z]+/u, 'canvas-')\n .slice(0, 48) || 'canvas';\n let alias = requestedAlias ?? base;\n for (let suffix = 2; byAlias.has(alias); suffix++) alias = `${base.slice(0, 56)}-${suffix}`;\n const canvas: Canvas = {\n alias,\n path: canonicalPath,\n realPath,\n bridge: createBridge(),\n closed: false,\n readyOnce: false,\n };\n byAlias.set(alias, canvas);\n byPath.set(realPath, canvas);\n return { path: canonicalPath, byteLength: bytes.byteLength, alias, status: 'opening', reused: false };\n },\n describe(alias?: string): AuthorViewportCatalogSnapshot {\n const canvases = [...byAlias.values()].map(view);\n const target =\n alias === undefined && canvases.filter((canvas) => canvas.status !== 'unavailable').length !== 1\n ? undefined\n : select(alias);\n if (target === undefined) {\n return {\n catalogToken: '',\n tools: [],\n canvases,\n nextStep: 'Open a file with open_authoring_file, then describe_author_tools({\"alias\":\"canvas-name\"}).',\n };\n }\n const status = view(target).status;\n const base = { alias: target.alias, path: target.path, status, canvases };\n if (status !== 'ready') {\n return {\n ...base,\n catalogToken: '',\n tools: [],\n nextStep:\n status === 'opening'\n ? `Wait for ${target.alias} to be ready, then call describe_author_tools({\"alias\":\"${target.alias}\"}).`\n : `Reopen ${target.path} with open_authoring_file({\"path\":\"${target.path}\",\"alias\":\"${target.alias}\"}).`,\n };\n }\n return { ...base, ...target.bridge.describe() };\n },\n invoke(input: UseAuthorToolInput, signal?: AbortSignal) {\n const target = select(input.alias);\n if (target.closed) throw new AuthorBridgeError(`Canvas '${target.alias}' is closed. Reopen its file.`, 503);\n return target.bridge.invoke(input, signal).then((result) => ({ ...result, alias: target.alias }));\n },\n bridge(alias: string): AuthorBridgeState {\n const canvas = select(alias);\n if (canvas.closed) throw new AuthorBridgeError(`Canvas '${alias}' is closed. Reopen its file.`, 503);\n return canvas.bridge;\n },\n close(alias: string): void {\n const canvas = select(alias);\n canvas.closed = true;\n canvas.bridge.close();\n canvas.bridge = createBridge();\n },\n dispose(): void {\n for (const canvas of byAlias.values()) canvas.bridge.close();\n byAlias.clear();\n byPath.clear();\n },\n };\n}\n\nexport type AuthorCanvasRegistry = ReturnType<typeof createAuthorCanvasRegistry>;\n","import { apiResponse, defineApiRoutes } from '@agimon-ai/po-core/web';\n\nimport type { AuthorOpenFileResult } from './author';\nimport type { AuthorSessionView } from './authorApi';\nimport type { DocumentPreflightReport, ParsedStructuredDocument } from './structuredDocuments';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path. The build reads both off\n * `src/extensions/workspaces/sessions/(backend)/api/author/`, so the mount is\n * stated once, by the folder that creates it. The browser used to restate it:\n * `authorStateUrl` built one URL from `API_BASE_PATH` and the document helper\n * two files away spelled `author` out again as a literal, so the two could\n * disagree and nothing would say so.\n *\n * The order below is the order the three Hono apps register in: `/state` in\n * `authorApi`, the eight bridge routes in `authorBridgeApi`, the three document\n * routes in `authorDocumentApi`. A reviewer can read the two side by side.\n *\n * Response types are named only where a caller reads the body. The bridge\n * routes are called by the hub's author channel over `requestSessionApi`, which\n * has its own message vocabulary and never sees this client.\n */\nexport default defineApiRoutes({\n state: {\n method: 'GET',\n path: '/state',\n response: apiResponse<AuthorSessionView>(),\n },\n bridgeRegister: {\n method: 'POST',\n path: '/bridge/register',\n },\n bridgeCatalog: {\n method: 'POST',\n path: '/bridge/catalog',\n },\n /** Long-polls for the next capability request, so it settles when one arrives. */\n bridgeNext: {\n method: 'POST',\n path: '/bridge/next',\n },\n bridgeResult: {\n method: 'POST',\n path: '/bridge/result',\n },\n bridgeCancelled: {\n method: 'POST',\n path: '/bridge/cancelled',\n },\n bridgeDisconnect: {\n method: 'POST',\n path: '/bridge/disconnect',\n },\n bridgeClose: {\n method: 'POST',\n path: '/bridge/close',\n },\n bridgeDescribe: {\n method: 'GET',\n path: '/bridge/describe',\n query: ['alias'],\n },\n bridgeInvoke: {\n method: 'POST',\n path: '/bridge/invoke',\n },\n /**\n * Parses one structured document.\n *\n * Answers a byte-length summary instead when the request names no format,\n * which is the agent-side tool path; the page always names one.\n */\n documentsOpen: {\n method: 'POST',\n path: '/documents/open',\n query: ['session'],\n response: apiResponse<ParsedStructuredDocument | AuthorOpenFileResult>(),\n },\n documentsPreflight: {\n method: 'POST',\n path: '/documents/preflight',\n query: ['session'],\n response: apiResponse<DocumentPreflightReport>(),\n },\n documentsSerialize: {\n method: 'POST',\n path: '/documents/serialize',\n query: ['session'],\n response: apiResponse<{ bytes: string; encoding: string }>(),\n },\n /**\n * The host's own bytes route, not this package's.\n *\n * `host: true` hangs it off the session root rather than under `/plugins`,\n * which is how the cockpit already serves it. Author reads a document's\n * bytes and its digest through it, and writes the edited bytes back to the\n * same path, so both stay raw transfers rather than calls: the body is the\n * file and the digest travels in a header.\n */\n file: {\n method: 'GET',\n path: '/file',\n query: ['path'],\n host: true,\n },\n});\n","import type { AuthorModeActivation } from './author';\n\n/**\n * The wire vocabulary this package's API shares with whatever calls it.\n *\n * Paths live in `./apiRoutes`, which the Hono apps register from and the\n * generated client addresses, so neither half can move alone. What stays here\n * is the mount segment the server registers under and the shape the state\n * route answers with.\n */\n\n/** Where a host mounts this package's API; the segment after /api/plugins/. */\nexport const API_BASE_PATH = 'author';\n\n/** Query parameter naming the session a document request belongs to. */\nexport const SESSION_QUERY_PARAM = 'session';\n\nexport interface AuthorSessionView {\n sessionId: string | null;\n activation: AuthorModeActivation;\n capabilityCount: number;\n}\n","import { Hono } from 'hono';\n\nimport { AuthorBridgeError } from '../../../../../../../models/authorBridgeState';\nimport { parseUseAuthorToolInput } from '../../../../../../../schemas/authorTools';\nimport type { AuthorCanvasRegistry } from '../../../../../../../services/authorCanvasRegistry';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorViewportCapabilityDescriptor } from '../../../../../../../types/author';\n\nfunction record(value: unknown): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new AuthorBridgeError('Invalid request.', 400);\n return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, key: string): string {\n const result = record(value)[key];\n if (typeof result !== 'string' || result === '') throw new AuthorBridgeError(`Invalid ${key}.`, 400);\n return result;\n}\n\nfunction generation(value: unknown): number {\n const result = record(value).generation;\n if (!Number.isSafeInteger(result) || (result as number) < 0) throw new AuthorBridgeError('Invalid generation.', 400);\n return result as number;\n}\n\nasync function body(request: Request): Promise<Record<string, unknown>> {\n return record(await request.json());\n}\n\nexport function createAuthorBridgeApi(registry: AuthorCanvasRegistry): Hono {\n const app = new Hono();\n app.onError((error, context) =>\n context.json(\n { error: error instanceof Error ? error.message : String(error) },\n error instanceof AuthorBridgeError ? error.status : 500,\n ),\n );\n app.post(routes.bridgeRegister.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({ ...registry.bridge(alias).register(text(value, 'bindingId'), generation(value)), alias });\n });\n app.post(routes.bridgeCatalog.path, async (context) => {\n const value = await body(context.req.raw);\n const tools = value.tools;\n if (!Array.isArray(tools)) throw new AuthorBridgeError('Invalid Author catalog.', 400);\n const alias = text(value, 'alias');\n return context.json({\n ...registry\n .bridge(alias)\n .catalog(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n tools as AuthorViewportCapabilityDescriptor[],\n ),\n alias,\n });\n });\n app.post(routes.bridgeNext.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({\n ...(await registry\n .bridge(alias)\n .next(text(value, 'bindingId'), generation(value), text(value, 'ownerToken'), context.req.raw.signal)),\n alias,\n });\n });\n app.post(routes.bridgeResult.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .result(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n value.result,\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeCancelled.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .cancelled(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeDisconnect.path, async (context) => {\n const value = await body(context.req.raw);\n registry.bridge(text(value, 'alias')).disconnect(text(value, 'bindingId'), generation(value));\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeClose.path, async (context) => {\n const value = await body(context.req.raw);\n registry.close(text(value, 'alias'));\n return context.json({ accepted: true });\n });\n app.get(routes.bridgeDescribe.path, (context) => context.json(registry.describe(context.req.query('alias'))));\n app.post(routes.bridgeInvoke.path, async (context) => {\n const value = parseUseAuthorToolInput(await context.req.raw.json());\n return context.json(await registry.invoke(value, context.req.raw.signal));\n });\n return app;\n}\n","import { Hono } from 'hono';\n\nimport {\n parseStructuredDocument,\n preflightStructuredDocument,\n serializeStructuredDocument,\n} from '../../../../../../../services/structuredDocuments';\nimport { DocumentRequestError } from '../../../../../../../services/structuredDocuments/common';\nimport { readDocument } from '../../../../../../../services/structuredDocuments/document';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorOpenFileResult } from '../../../../../../../types/author';\nimport type {\n CsvDialect,\n DocumentOperation,\n StructuredDocumentFormat,\n} from '../../../../../../../types/structuredDocuments';\n\nexport { AUTHOR_DOCUMENT_MAX_BYTES } from '../../../../../../../services/structuredDocuments/document';\n\ninterface DocumentRequest {\n path?: unknown;\n alias?: unknown;\n format?: unknown;\n operations?: unknown;\n preflightDigest?: unknown;\n csvDialect?: unknown;\n}\n\nexport interface AuthorDocumentApiOptions {\n cwd?: string;\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string;\n open?: (path: string, signal?: AbortSignal, alias?: string) => Promise<AuthorOpenFileResult>;\n}\n\nconst FORMATS = new Set<StructuredDocumentFormat>(['markdown-slides', 'csv', 'pptx', 'xlsx']);\n\nfunction errorResponse(\n context: { json: (value: unknown, status: 400 | 403 | 404 | 413 | 422 | 500) => Response },\n error: unknown,\n): Response {\n const message = error instanceof Error ? error.message : 'Document operation failed.';\n // A refusal names its own status; anything else is a request the document cannot satisfy.\n return context.json({ error: message }, error instanceof DocumentRequestError ? error.status : 422);\n}\n\nfunction requestFormat(value: unknown): StructuredDocumentFormat {\n if (typeof value !== 'string' || !FORMATS.has(value as StructuredDocumentFormat))\n throw new Error('A supported format is required.');\n return value as StructuredDocumentFormat;\n}\n\nfunction requestOperations(value: unknown): DocumentOperation[] {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > 100_000) throw new Error('A bounded operations array is required.');\n return value.map((operation) => {\n if (\n typeof operation !== 'object' ||\n operation === null ||\n typeof (operation as Record<string, unknown>).fragmentId !== 'string' ||\n typeof (operation as Record<string, unknown>).replacement !== 'string'\n ) {\n throw new Error('Each operation requires string fragmentId and replacement fields.');\n }\n return operation as DocumentOperation;\n });\n}\n\nasync function bodyOf(request: Request): Promise<DocumentRequest> {\n const body = (await request.json()) as unknown;\n if (typeof body !== 'object' || body === null || Array.isArray(body)) throw new Error('A JSON object is required.');\n return body as DocumentRequest;\n}\n\nexport function createAuthorDocumentApi(options: AuthorDocumentApiOptions = {}): Hono {\n const app = new Hono();\n const cwd = options.cwd ?? process.cwd();\n\n app.post(routes.documentsOpen.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (body.format === undefined && options.open !== undefined) {\n return context.json(\n await options.open(body.path as string, context.req.raw.signal, body.alias as string | undefined),\n );\n }\n const bytes = await readDocument(cwd, body.path, options.sessionId);\n if (body.format === undefined) {\n return context.json({ path: body.path as string, byteLength: bytes.byteLength } satisfies AuthorOpenFileResult);\n }\n return context.json(\n await parseStructuredDocument(requestFormat(body.format), bytes, body.csvDialect as Partial<CsvDialect>),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsPreflight.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n const bytes = await readDocument(cwd, body.path, options.sessionId);\n return context.json(\n await preflightStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.csvDialect as Partial<CsvDialect>,\n ),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsSerialize.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (typeof body.preflightDigest !== 'string') throw new Error('A preflight report digest is required.');\n const bytes = await readDocument(cwd, body.path, options.sessionId);\n const serialized = await serializeStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.preflightDigest,\n body.csvDialect as Partial<CsvDialect>,\n );\n return context.json({\n bytes: Buffer.from(serialized.bytes).toString('base64'),\n encoding: 'base64',\n manifest: serialized.manifest,\n operationLog: serialized.operationLog,\n });\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n return app;\n}\n","import { randomUUID } from 'node:crypto';\n\nimport type { PoApi, PoApiContext, PoApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { Hono } from 'hono';\n\nimport { createAuthorBridgeState, type AuthorBridgeState } from '../../../../../../../models/authorBridgeState';\nimport {\n createAuthorCanvasRegistry,\n type AuthorCanvasRegistry,\n} from '../../../../../../../services/authorCanvasRegistry';\nimport type { AuthorCatalog } from '../../../../../../../services/authorCatalog/type';\nimport routes from '../../../../../../../types/apiRoutes';\nimport { API_BASE_PATH, type AuthorSessionView } from '../../../../../../../types/authorApi';\nimport { createAuthorBridgeApi } from './authorBridgeApi';\nimport { createAuthorDocumentApi } from './authorDocumentApi';\n\nexport interface AuthorApiOptions {\n sessionId?: string;\n cwd?: string;\n readState?: () => Omit<AuthorSessionView, 'sessionId'>;\n registry?: AuthorCanvasRegistry;\n}\n\nconst inactiveState = (): Omit<AuthorSessionView, 'sessionId'> => ({ activation: 'inactive', capabilityCount: 0 });\nconst createBridge = (): AuthorBridgeState =>\n createAuthorBridgeState({\n now: Date.now,\n issueToken: randomUUID,\n scheduleTimeout(callback, delayMs) {\n const timer = setTimeout(callback, delayMs);\n timer.unref?.();\n return () => clearTimeout(timer);\n },\n });\n\nexport function createAuthorApi(options: AuthorApiOptions = {}): Hono {\n const app = new Hono();\n const registry =\n options.registry ?? createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId);\n app.get(routes.state.path, (context) =>\n context.json({\n sessionId: options.sessionId ?? null,\n ...(options.readState ?? inactiveState)(),\n } satisfies AuthorSessionView),\n );\n app.route('/', createAuthorBridgeApi(registry));\n app.route(\n '/',\n createAuthorDocumentApi({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.sessionId === undefined ? {} : { sessionId: options.sessionId }),\n open: (path, signal, alias) => registry.open(path, signal, alias),\n }),\n );\n return app;\n}\n\nexport const api: PoApi = {\n basePath: API_BASE_PATH,\n start(context: PoApiContext): PoApiHandler {\n // One server hosts many sessions, so its own directory is never a session's project.\n if (context.cwd === undefined) throw new Error('Author requires the session working directory.');\n const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId);\n const app = createAuthorApi({\n ...(context.sessionId === undefined ? {} : { sessionId: context.sessionId }),\n cwd: context.cwd,\n registry,\n });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n};\n\n/** The session API and tools share the same browser ownership and pending requests. */\nexport function createAuthorSessionApi(cwd: string, sessionId: string): { api: PoApi; catalog: AuthorCatalog } {\n const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId);\n return {\n catalog: {\n open: (path, signal, alias) => registry.open(path, signal, alias),\n async describe(signal, alias) {\n signal?.throwIfAborted();\n return registry.describe(alias);\n },\n execute: (input, signal) => registry.invoke(input, signal),\n },\n api: {\n basePath: API_BASE_PATH,\n start() {\n const app = createAuthorApi({ cwd, sessionId, registry });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\nimport { serverMinorModes } from '@agimon-ai/po-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { authorMinorMode } from '../../../../models/authorMode';\nimport { createAuthorCatalog } from '../../../../services/authorCatalog';\nimport { createWebmcpNamespace } from '../../../../services/webmcpNamespace';\nimport { api, createAuthorSessionApi } from './api/author/_lib/authorApi';\n\nexport default defineRoot(({ agent, signal }: PoServerPluginContext) => {\n const session = agent ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId) : undefined;\n const isActive = () => (agent?.context.selection.state?.['minor-mode'] ?? []).includes(authorMinorMode.descriptor.id);\n const mode = agent\n ? authorMinorMode.createOwner({\n isActive,\n detail: () => 'document authoring available',\n async setActive(enabled) {\n const modes = (agent.context.selection.state?.['minor-mode'] ?? []).filter(\n (id) => id !== authorMinorMode.descriptor.id,\n );\n await agent.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, authorMinorMode.descriptor.id] : modes,\n });\n },\n })\n : undefined;\n let disposed = false;\n const catalog = createAuthorCatalog(session?.catalog);\n const assertAvailable = () => {\n signal.throwIfAborted();\n if (disposed) throw new Error('Author session is disposed.');\n if (!isActive()) throw new Error('Author mode is not active.');\n };\n const mountNamespace = (context: Context) => {\n if (!agent) return;\n const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAvailable);\n context.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const registration = readPoCodemode(scoped)?.register('@agimon-ai/po-author', namespace);\n return () => registration?.dispose();\n });\n };\n return {\n onDispose: () => {\n disposed = true;\n },\n value: {\n api: session?.api ?? api,\n catalog,\n // Registration is gated by AUTHOR_TOOL_WHEN; this re-checks a call already in flight when the mode turns off.\n assertAvailable,\n service: undefined,\n },\n services: [...(mode ? [serverMinorModes([mode])] : []), mountNamespace],\n };\n});\n","import type { AuthorViewportCapabilityDescriptor } from './author';\n\nexport const authorChannelType = 'author_webmcp';\n\nexport interface AuthorRegisterMessage {\n alias: string;\n kind: 'register';\n generation: number;\n}\n\nexport interface AuthorReleaseMessage {\n alias: string;\n kind: 'release';\n generation: number;\n}\nexport interface AuthorCatalogMessage {\n alias: string;\n kind: 'catalog';\n generation: number;\n ownerToken: string;\n tools: AuthorViewportCapabilityDescriptor[];\n}\n\nexport interface AuthorResultMessage {\n alias: string;\n kind: 'result';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n result: unknown;\n}\n\nexport interface AuthorCancelledMessage {\n alias: string;\n kind: 'cancelled';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport type AuthorBrowserMessage =\n | AuthorRegisterMessage\n | AuthorReleaseMessage\n | AuthorCatalogMessage\n | AuthorResultMessage\n | AuthorCancelledMessage;\n\nexport interface AuthorAcceptedMessage {\n alias?: string;\n kind: 'accepted';\n generation: number;\n ownerToken: string;\n catalogToken?: string;\n leaseMs: number;\n}\n\nexport interface AuthorRequestMessage {\n alias?: string;\n kind: 'request';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n name: string;\n arguments: Record<string, unknown>;\n}\n\nexport interface AuthorCancelMessage {\n alias?: string;\n kind: 'cancel';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport interface AuthorRejectedMessage {\n alias?: string;\n kind: 'rejected';\n reason: string;\n}\n\nexport type AuthorHubMessage =\n | AuthorAcceptedMessage\n | AuthorRequestMessage\n | AuthorCancelMessage\n | AuthorRejectedMessage;\n\nexport interface AuthorWebView {\n activation: 'inactive' | 'active';\n capabilityCount: number;\n}\n","import type {\n PoHubChannelConnection,\n PoHubChannelHost,\n PoHubChannelSource,\n PoHubSessionScope,\n PoHubChannel,\n} from '@agimon-ai/po-core/hubChannel';\n\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport routes from '../../types/apiRoutes';\nimport { API_BASE_PATH } from '../../types/authorApi';\nimport { authorChannelType, type AuthorBrowserMessage, type AuthorHubMessage } from '../../types/webAuthor';\n\n/**\n * Which route carries each message the browser sends.\n *\n * The paths come from the package's one route table, so the hub cannot address\n * a bridge route the session no longer serves. `release` is absent because it\n * is answered by the disconnect route rather than one of its own.\n */\nconst BRIDGE_ROUTE: Readonly<Record<Exclude<AuthorBrowserMessage['kind'], 'release'>, string>> = {\n register: routes.bridgeRegister.path,\n catalog: routes.bridgeCatalog.path,\n result: routes.bridgeResult.path,\n cancelled: routes.bridgeCancelled.path,\n};\n\ninterface Binding {\n alias: string;\n scope: PoHubSessionScope;\n connectionId: string;\n generation: number;\n ownerToken: string;\n poll?: AbortController;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction browserMessage(value: unknown): AuthorBrowserMessage | undefined {\n if (\n !isRecord(value) ||\n typeof value.kind !== 'string' ||\n typeof value.alias !== 'string' ||\n !AUTHOR_ALIAS_PATTERN.test(value.alias)\n )\n return undefined;\n if (!['register', 'release', 'catalog', 'result', 'cancelled'].includes(value.kind)) return undefined;\n return value as unknown as AuthorBrowserMessage;\n}\n\nasync function responsePayload(response: Response): Promise<AuthorHubMessage> {\n const value = (await response.json()) as unknown;\n if (response.ok) return value as AuthorHubMessage;\n const reason =\n isRecord(value) && typeof value.error === 'string' ? value.error : `Author bridge HTTP ${response.status}`;\n return { kind: 'rejected', reason };\n}\n\nexport function createAuthorChannel(): PoHubChannel {\n const bindings = new Map<string, Binding>();\n let host: PoHubChannelHost | undefined;\n let closed = false;\n const keyOf = (sessionId: string, connectionId: string, alias: string): string =>\n `${sessionId}\\0${connectionId}\\0${alias}`;\n const send = async (scope: PoHubSessionScope, path: string, value: Record<string, unknown>, signal?: AbortSignal) =>\n await host!.requestSessionApi(scope, {\n basePath: API_BASE_PATH,\n path,\n method: 'POST',\n body: JSON.stringify(value),\n ...(signal === undefined ? {} : { signal }),\n });\n const publish = (binding: Binding, payload: AuthorHubMessage): boolean =>\n host?.publishToConnection?.(binding.connectionId, binding.scope.sessionId, { ...payload, alias: binding.alias }) ??\n false;\n\n const poll = async (binding: Binding): Promise<void> => {\n binding.poll?.abort();\n const controller = new AbortController();\n binding.poll = controller;\n while (!closed && bindings.get(keyOf(binding.scope.sessionId, binding.connectionId, binding.alias)) === binding) {\n try {\n const response = await send(\n binding.scope,\n routes.bridgeNext.path,\n {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n ownerToken: binding.ownerToken,\n },\n controller.signal,\n );\n const payload = await responsePayload(response);\n if (controller.signal.aborted) break;\n if (!publish(binding, payload) || payload.kind === 'rejected') break;\n } catch (error) {\n if (!controller.signal.aborted) host?.onNotice(error instanceof Error ? error.message : String(error));\n break;\n }\n }\n if (binding.poll === controller) binding.poll = undefined;\n };\n\n const channel: PoHubChannel = {\n frameType: authorChannelType,\n lifecycle: 'hub',\n receiveWithoutSubscription: true,\n start(channelHost) {\n host = channelHost;\n const source: PoHubChannelSource = {\n payloadFor: () => undefined,\n sessionRemoved(sessionId) {\n for (const [key, binding] of bindings) {\n if (binding.scope.sessionId !== sessionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n close() {\n closed = true;\n for (const binding of bindings.values()) {\n binding.poll?.abort();\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n bindings.clear();\n },\n };\n return source;\n },\n receive(scope, payload, connection) {\n const message = browserMessage(payload);\n if (message === undefined || host === undefined || closed) return;\n void (async () => {\n const key = keyOf(scope.sessionId, connection.connectionId, message.alias);\n const previous = bindings.get(key);\n if (message.kind === 'release') {\n if (previous === undefined || previous.generation !== message.generation) return;\n previous.poll?.abort();\n bindings.delete(key);\n await send(scope, routes.bridgeDisconnect.path, {\n alias: message.alias,\n bindingId: connection.connectionId,\n generation: message.generation,\n });\n return;\n }\n const route = BRIDGE_ROUTE[message.kind];\n const response = await send(scope, route, { ...message, bindingId: connection.connectionId });\n const reply = await responsePayload(response);\n if (reply.kind === 'accepted') {\n const current = bindings.get(key);\n if (current?.generation === reply.generation && current.ownerToken === reply.ownerToken) {\n publish(current, reply);\n if (current.poll === undefined) void poll(current);\n return;\n }\n const binding: Binding = {\n alias: message.alias,\n scope,\n connectionId: connection.connectionId,\n generation: reply.generation,\n ownerToken: reply.ownerToken,\n };\n current?.poll?.abort();\n bindings.set(key, binding);\n publish(binding, reply);\n void poll(binding);\n } else if (reply.kind === 'rejected') {\n if (previous !== undefined) publish(previous, reply);\n else\n host?.publishToConnection?.(connection.connectionId, scope.sessionId, { ...reply, alias: message.alias });\n }\n })().catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n },\n disconnected(connection: PoHubChannelConnection) {\n for (const [key, binding] of bindings) {\n if (binding.connectionId !== connection.connectionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n };\n return channel;\n}\n","import { defineChannel } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorChannel } from '../../../services/webAuthorChannel';\n\nexport default defineChannel(createAuthorChannel);\n","import { defineServerMethod, type PoServerHostService } from '@agimon-ai/po-core/serverPlugin';\n\nimport { authorBridgeMethod } from '../../schemas/authorFacade';\nimport { authorChannelType } from '../../types/webAuthor';\n\nexport function createAuthorBridgeMethod(scope: 'global' | 'workspace', host: PoServerHostService) {\n return defineServerMethod(authorBridgeMethod(scope), ({ sessionId, message }, caller) => {\n if (!caller.connectionId) throw new Error('Author bridge requires an authenticated browser connection.');\n if (!host.context.receiveChannel?.(sessionId, authorChannelType, message, caller.connectionId))\n throw new Error('Author bridge session is outside this mount.');\n return {};\n });\n}\n","import { defineMethod } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createAuthorBridgeMethod } from '../../../services/authorBridgeMethod';\n\nexport default defineMethod(({ host }: PoServerPluginContext) =>\n host.scope === 'session'\n ? { register: () => ({ dispose: () => undefined }) }\n : createAuthorBridgeMethod(host.scope, host),\n);\n","import { defineRoute, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\ntype AuthorServerScope = Awaited<ReturnType<typeof import('../../root.server').default>>['value'];\n\nexport default defineRoute((context: WithRoot<PoServerPluginContext, AuthorServerScope>) => context.root.api);\n","import { defineCommand as defineRoutedCommand, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorCommand } from '../../../../../services/authorCommand';\nimport type { AuthorExtensionService } from '../../../../../types/extension';\n\nexport default defineRoutedCommand((context: WithRoot<unknown, { readonly service?: AuthorExtensionService }>) =>\n createAuthorCommand(context.root.service),\n);\n","import { defineHook } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_GUIDANCE } from '../../../../../constants/author';\n\nexport default defineHook<'before_agent_start'>({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor', mode: 'author' } },\n event: 'before_agent_start',\n handle(event) {\n const systemPrompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${systemPrompt}\\n\\n${AUTHOR_GUIDANCE}`.trim() };\n },\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nconst skillFile = 'src/prompts/codemode-how-to-author/SKILL.md';\n\nexport default defineResource({\n name: 'codemode-how-to-author',\n description:\n 'Call Author canvas capabilities through the webmcp namespace in code mode. Use for canvas discovery, capability calls, and their catalog tokens from exec.',\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, skillFile),\n read: () => readPackageResource(import.meta.url, skillFile),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor' as const, mode: 'author' } },\n name: 'po-use-author',\n description: 'Use the Author workflow for focused document review, canvas steering, and bounded authoring.',\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n});\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[1]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[0]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[2]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelAuthorWebmcp from '../src/extensions/(backend)/channel/author-webmcp.server';\nimport methodBridge from '../src/extensions/(backend)/method/bridge.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/author/route.server';\nimport commandAuthor from '../src/extensions/workspaces/sessions/(backend)/command/author.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport resourceCodemodeHowToAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server';\nimport resourcePoUseAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server';\nimport toolDescribeAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server';\nimport toolOpenAuthoringFile from '../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server';\nimport toolUseAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-author',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n global: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return [() => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n workspace: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get commands(): PoServerSessionPlugin['commands'] { return [via({ name: 'author' }, at(commandAuthor, contextSession))]; },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToAuthor, contextSession), at(resourcePoUseAuthor, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [via({ name: 'describe_author_tools' }, at(toolDescribeAuthorTools, contextSession)), via({ name: 'open_authoring_file' }, at(toolOpenAuthoringFile, contextSession)), via({ name: 'use_author_tools' }, at(toolUseAuthorTools, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,eAAe;;;;;;;;;;;;;;;AAgBrB,SAAS,KAAQ,OAAa;CAC5B,OAAO,UAAU,KAAA,IAAY,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACvE;AAEA,SAAgB,sBACd,SACA,WACA,iBACqB;CACrB,OAAO;EACL,MAAM;EACN,SACE;EACF,cAAc;EACd,KAAK,KAAK;GACR,IAAI,IAAI,cAAc,WAAW,MAAM,IAAI,MAAM,qDAAqD;GACtG,IAAI,WAAW;GACf,IAAI,gBAAgB;IAClB,WAAW;GACb,CAAC;GACD,MAAM,cAAc;IAClB,IAAI,OAAO,eAAe;IAC1B,IAAI,UAAU,MAAM,IAAI,MAAM,gCAAgC;IAC9D,gBAAgB;GAClB;GACA,MAAM,UAAmC,OAAO,OAAO,IAAI;GAC3D,QAAQ,WAAW,OAAO,UAAoB;IAC5C,MAAM;IACN,MAAM,EAAE,UAAU,8BAA8B,KAAK,UAAU,KAAA,IAAY,CAAC,IAAI,KAAK,CAAC;IACtF,MAAM,SAAS,MAAM,QAAQ,SAAS,IAAI,QAAQ,KAAK;IACvD,MAAM;IACN,OAAO,KAAK,MAAM;GACpB;GACA,QAAQ,OAAO,OAAO,UAAmB;IACvC,MAAM;IACN,MAAM,SAAS,wBAAwB,KAAK,KAAK,CAAC;IAClD,MAAM,SAAS,MAAM,QAAQ,QAAQ,QAAQ,IAAI,MAAM;IACvD,MAAM;IACN,OAAO,KAAK,OAAO,MAAM;GAC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WAA8C;IAAE,OAAO,QAAQ,CAAC,QAAQ,OAAO,QAAQ,IAAI,KAAA,UAAkB,IAAI,EAAE,WAAW,gBAAgB,GAAG,GAAGF,8BAAqB,OAAO,CAAC,CAAC,CAAC;GAAG;GAC1L,IAAI,WAA8C;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,SAAS,GAAG,GAAGG,uBAAe,cAAc,CAAC,CAAC;GAAG;GACzH,IAAI,QAAwC;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,mCAAsB,cAAc,CAAC,CAAC;GAAG;GACvI,IAAI,UAA4C;IAAE,OAAO,CAAC,GAAGH,uBAAc,OAAO,CAAC;GAAG;GACtF,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGI,uCAA6B,cAAc,GAAG,GAAGC,8BAAqB,cAAc,CAAC;GAAG;GACzJ,IAAI,QAAwC;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,wBAAwB,GAAG,GAAGC,sCAAyB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,sBAAsB,GAAG,GAAGC,oCAAuB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,iCAAoB,cAAc,CAAC;IAAC;GAAG;GACxS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"server.mjs","names":["routes","routes","routes","routes","defineRoutedCommand","defineTool","defineTool","defineTool","rootSession","channelAuthorWebmcp","methodBridge","apiRoute","commandAuthor","hookBeforeAgentStart","resourceCodemodeHowToAuthor","resourcePoUseAuthor","toolDescribeAuthorTools","toolOpenAuthoringFile","toolUseAuthorTools"],"sources":["../../src/services/webmcpNamespace/index.ts","../../src/services/structuredDocuments/document.ts","../../src/services/authorCanvasRegistry/index.ts","../../src/types/apiRoutes.ts","../../src/types/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorBridgeApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorDocumentApi.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/_lib/authorApi.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/types/webAuthor.ts","../../src/services/webAuthorChannel/index.ts","../../src/extensions/(backend)/channel/author-webmcp.server.ts","../../src/services/authorBridgeMethod/index.ts","../../src/extensions/(backend)/method/bridge.server.ts","../../src/extensions/workspaces/sessions/(backend)/api/author/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/author.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server.ts","../../generated/server.ts"],"sourcesContent":["import type { PoCodemodeNamespace } from '@agimon-ai/po-core/codemode';\n\nimport { parseDescribeAuthorToolsInput, parseUseAuthorToolInput } from '../../schemas/authorTools';\nimport type { AuthorCatalog } from '../authorCatalog/type';\n\n// ponytail: typed per-canvas members need a synchronous catalog reader and a shared schema converter in po-core.\nconst DECLARATIONS = `interface AuthorViewportCatalogSnapshot {\n catalogToken: string;\n tools: { name: string; label: string; description: string; inputSchema: Readonly<Record<string, unknown>> }[];\n canvases?: { alias: string; path: string; status: 'opening' | 'ready' | 'unavailable' }[];\n alias?: string;\n path?: string;\n status?: 'opening' | 'ready' | 'unavailable';\n nextStep?: string;\n}\ndeclare const webmcp: {\n /** Ready canvases, or one canvas's tools and its catalog token. */\n describe(input?: { alias?: string }): Promise<AuthorViewportCatalogSnapshot>;\n /** Call one tool with an explicit current token. Await same-canvas calls sequentially. */\n call(input: { alias?: string; catalogToken: string; name: string; arguments: Record<string, unknown> }): Promise<unknown>;\n};`;\n\nfunction copy<T>(value: T): T {\n return value === undefined ? value : JSON.parse(JSON.stringify(value));\n}\n\nexport function createWebmcpNamespace(\n catalog: AuthorCatalog,\n sessionId: string,\n assertAvailable: () => void,\n): PoCodemodeNamespace {\n return {\n name: 'webmcp',\n summary:\n 'Author canvas WebMCP: describe catalogs, then call one tool with its explicit token. Await same-canvas calls sequentially; structured errors remain data.',\n declarations: DECLARATIONS,\n bind(run) {\n if (run.sessionId !== sessionId) throw new Error('Author WebMCP namespace belongs to another session.');\n let disposed = false;\n run.onDispose(() => {\n disposed = true;\n });\n const check = () => {\n run.signal.throwIfAborted();\n if (disposed) throw new Error('Author WebMCP run is disposed.');\n assertAvailable();\n };\n const members: Record<string, unknown> = Object.create(null);\n members.describe = async (input?: unknown) => {\n check();\n const { alias } = parseDescribeAuthorToolsInput(copy(input === undefined ? {} : input));\n const result = await catalog.describe(run.signal, alias);\n check();\n return copy(result);\n };\n members.call = async (input: unknown) => {\n check();\n const parsed = parseUseAuthorToolInput(copy(input));\n const result = await catalog.execute(parsed, run.signal);\n check();\n return copy(result.result);\n };\n return members;\n },\n };\n}\n","import { constants } from 'node:fs';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n ArtifactAccessError,\n artifactRoot,\n openArtifact,\n readArtifactBytes,\n} from '@agimon-ai/po-artifact/artifactFiles';\n\nimport { AUTHOR_ARTIFACT_PREFIX } from '../../constants/author';\nimport { DocumentRequestError, documentTooLarge } from './common';\n\nexport const AUTHOR_DOCUMENT_MAX_BYTES = 25 * 1024 * 1024;\n\n/**\n * Where a requested document lives. `path` is the canonical form clients use;\n * `realPath` identifies the file so two spellings share one canvas.\n */\nexport type AuthorDocumentSource =\n | { kind: 'workspace'; path: string; realPath: string; root: string }\n | { kind: 'artifact'; path: string; realPath: string; root: string; relative: string };\n\nfunction inside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);\n}\n\n/**\n * The session artifact folder is the one place outside the working tree Author\n * may read. It is named either `artifact:<relative>` or by the absolute path the\n * agent's prompt gives; po-artifact's guarded open does the containment checks.\n */\nasync function resolveArtifact(\n requestedPath: string,\n sessionId: string | undefined,\n environment: Readonly<Record<string, string | undefined>> | undefined,\n) {\n const prefixed = requestedPath.startsWith(AUTHOR_ARTIFACT_PREFIX);\n if (sessionId === undefined || environment === undefined) {\n if (prefixed) throw new DocumentRequestError('Artifacts need a session.', 400);\n return undefined;\n }\n const root = artifactRoot(sessionId, environment);\n if (prefixed) return { root, relative: requestedPath.slice(AUTHOR_ARTIFACT_PREFIX.length) };\n if (!path.isAbsolute(requestedPath)) return undefined;\n const realRoot = await fs.realpath(root).catch(() => root);\n const base = [root, realRoot].find((candidate) => inside(candidate, requestedPath));\n if (base === undefined) return undefined;\n return { root, relative: path.relative(base, requestedPath).split(path.sep).join('/') };\n}\n\nexport async function resolveDocument(\n cwd: string,\n requestedPath: unknown,\n sessionId?: string,\n environment?: Readonly<Record<string, string | undefined>>,\n): Promise<AuthorDocumentSource> {\n if (typeof requestedPath !== 'string' || requestedPath.length === 0 || requestedPath.includes('\\0'))\n throw new Error('A relative document path is required.');\n const artifact = await resolveArtifact(requestedPath, sessionId, environment);\n if (artifact !== undefined) {\n const realRoot = await fs.realpath(artifact.root).catch(() => artifact.root);\n return {\n kind: 'artifact',\n path: `${AUTHOR_ARTIFACT_PREFIX}${artifact.relative}`,\n realPath: path.join(realRoot, artifact.relative),\n ...artifact,\n };\n }\n if (path.isAbsolute(requestedPath))\n throw new Error('A relative document path, or a file in the session artifact folder, is required.');\n const root = await fs.realpath(cwd);\n const candidate = path.resolve(root, requestedPath);\n if (candidate !== root && !candidate.startsWith(`${root}${path.sep}`))\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n const realCandidate = await fs.realpath(candidate);\n if (realCandidate !== root && !realCandidate.startsWith(`${root}${path.sep}`)) {\n throw new DocumentRequestError('Document path is outside the working directory.', 403);\n }\n return {\n kind: 'workspace',\n root,\n path: path.relative(root, realCandidate).split(path.sep).join('/'),\n realPath: realCandidate,\n };\n}\n\nasync function readArtifact(root: string, relative: string): Promise<Uint8Array> {\n let file: Awaited<ReturnType<typeof openArtifact>>;\n try {\n file = await openArtifact(root, relative);\n } catch (error) {\n if (error instanceof ArtifactAccessError) throw new DocumentRequestError(error.message, error.status);\n throw error;\n }\n try {\n if (file.stat.size > AUTHOR_DOCUMENT_MAX_BYTES)\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n return await readArtifactBytes(file.handle, file.stat.size);\n } finally {\n await file.handle.close();\n }\n}\n\nexport async function readSource(source: AuthorDocumentSource): Promise<Uint8Array> {\n if (source.kind === 'artifact') return await readArtifact(source.root, source.relative);\n if (process.platform !== 'darwin' && process.platform !== 'linux')\n throw new DocumentRequestError('Secure document reads require macOS or Linux.', 403);\n // Darwin O_NOFOLLOW_ANY atomically rejects symlinks in every component.\n // Linux validates the opened descriptor's actual path, not a mutable path lookup.\n const noFollow = process.platform === 'darwin' ? 0x20000000 : constants.O_NOFOLLOW;\n const handle = await fs.open(source.realPath, constants.O_RDONLY | constants.O_NONBLOCK | noFollow);\n try {\n const stat = await handle.stat();\n const current = await fs.lstat(source.realPath);\n const realPath = await fs.realpath(process.platform === 'linux' ? `/proc/self/fd/${handle.fd}` : source.realPath);\n if (\n !stat.isFile() ||\n !current.isFile() ||\n stat.dev !== current.dev ||\n stat.ino !== current.ino ||\n !inside(source.root, realPath)\n )\n throw new DocumentRequestError('The document changed or is outside the working directory.', 403);\n if (stat.size > AUTHOR_DOCUMENT_MAX_BYTES)\n throw documentTooLarge(`Document exceeds the ${AUTHOR_DOCUMENT_MAX_BYTES} byte preview limit.`);\n return await readArtifactBytes(handle, stat.size);\n } finally {\n await handle.close();\n }\n}\n\nexport async function readDocument(\n cwd: string,\n requestedPath: unknown,\n sessionId?: string,\n environment?: Readonly<Record<string, string | undefined>>,\n): Promise<Uint8Array> {\n return await readSource(await resolveDocument(cwd, requestedPath, sessionId, environment));\n}\n","import path from 'node:path';\n\nimport { AuthorBridgeError, type AuthorBridgeState } from '../../models/authorBridgeState';\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport type {\n AuthorCanvasView,\n AuthorOpenFileResult,\n AuthorViewportCatalogSnapshot,\n UseAuthorToolInput,\n} from '../../types/author';\nimport { readSource, resolveDocument } from '../structuredDocuments/document';\n\ninterface Canvas {\n alias: string;\n path: string;\n realPath: string;\n bridge: AuthorBridgeState;\n closed: boolean;\n readyOnce: boolean;\n}\n\nconst MAX_CANVASES = 32;\n\nexport function createAuthorCanvasRegistry(\n cwd: string,\n createBridge: () => AuthorBridgeState,\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string,\n environment?: Readonly<Record<string, string | undefined>>,\n) {\n const byAlias = new Map<string, Canvas>();\n const byPath = new Map<string, Canvas>();\n\n const select = (alias?: string): Canvas => {\n if (alias !== undefined) {\n if (!AUTHOR_ALIAS_PATTERN.test(alias)) throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const canvas = byAlias.get(alias);\n if (canvas === undefined)\n throw new AuthorBridgeError(\n `Unknown Author canvas '${alias}'. Call describe_author_tools({}) for available aliases.`,\n 404,\n );\n return canvas;\n }\n const canvases = [...byAlias.values()].filter((canvas) => !canvas.closed);\n if (canvases.length !== 1)\n throw new AuthorBridgeError('Specify a canvas alias. Call describe_author_tools({}) to list canvases.', 409);\n return canvases[0]!;\n };\n\n const view = (canvas: Canvas): AuthorCanvasView => {\n if (canvas.closed) return { alias: canvas.alias, path: canvas.path, status: 'unavailable' };\n try {\n canvas.bridge.describe();\n canvas.readyOnce = true;\n return { alias: canvas.alias, path: canvas.path, status: 'ready' };\n } catch {\n return { alias: canvas.alias, path: canvas.path, status: canvas.readyOnce ? 'unavailable' : 'opening' };\n }\n };\n\n return {\n async open(requestedPath: string, signal?: AbortSignal, requestedAlias?: string): Promise<AuthorOpenFileResult> {\n signal?.throwIfAborted();\n if (requestedAlias !== undefined && !AUTHOR_ALIAS_PATTERN.test(requestedAlias))\n throw new AuthorBridgeError('Invalid Author canvas alias.', 400);\n const source = await resolveDocument(cwd, requestedPath, sessionId, environment);\n const bytes = await readSource(source);\n signal?.throwIfAborted();\n const { realPath, path: canonicalPath } = source;\n const occupied = requestedAlias === undefined ? undefined : byAlias.get(requestedAlias);\n if (occupied !== undefined && occupied.realPath !== realPath)\n throw new AuthorBridgeError(`Author canvas alias '${requestedAlias}' already names ${occupied.path}.`, 409);\n const existing = byPath.get(realPath);\n if (existing !== undefined) {\n if (existing.closed) existing.readyOnce = false;\n existing.closed = false;\n return {\n path: existing.path,\n byteLength: bytes.byteLength,\n alias: existing.alias,\n status: view(existing).status,\n reused: true,\n };\n }\n if (byAlias.size >= MAX_CANVASES) {\n const reusable = [...byAlias.values()].find((canvas) => canvas.closed);\n if (reusable === undefined) throw new AuthorBridgeError('Too many Author canvases in this conversation.', 409);\n reusable.bridge.close();\n byAlias.delete(reusable.alias);\n byPath.delete(reusable.realPath);\n }\n const base =\n path\n .basename(realPath)\n .replace(/\\.[^.]*$/u, '')\n .toLowerCase()\n .replace(/[^a-z0-9_-]+/gu, '-')\n .replace(/^[^a-z]+/u, 'canvas-')\n .slice(0, 48) || 'canvas';\n let alias = requestedAlias ?? base;\n for (let suffix = 2; byAlias.has(alias); suffix++) alias = `${base.slice(0, 56)}-${suffix}`;\n const canvas: Canvas = {\n alias,\n path: canonicalPath,\n realPath,\n bridge: createBridge(),\n closed: false,\n readyOnce: false,\n };\n byAlias.set(alias, canvas);\n byPath.set(realPath, canvas);\n return { path: canonicalPath, byteLength: bytes.byteLength, alias, status: 'opening', reused: false };\n },\n describe(alias?: string): AuthorViewportCatalogSnapshot {\n const canvases = [...byAlias.values()].map(view);\n const target =\n alias === undefined && canvases.filter((canvas) => canvas.status !== 'unavailable').length !== 1\n ? undefined\n : select(alias);\n if (target === undefined) {\n return {\n catalogToken: '',\n tools: [],\n canvases,\n nextStep: 'Open a file with open_authoring_file, then describe_author_tools({\"alias\":\"canvas-name\"}).',\n };\n }\n const status = view(target).status;\n const base = { alias: target.alias, path: target.path, status, canvases };\n if (status !== 'ready') {\n return {\n ...base,\n catalogToken: '',\n tools: [],\n nextStep:\n status === 'opening'\n ? `Wait for ${target.alias} to be ready, then call describe_author_tools({\"alias\":\"${target.alias}\"}).`\n : `Reopen ${target.path} with open_authoring_file({\"path\":\"${target.path}\",\"alias\":\"${target.alias}\"}).`,\n };\n }\n return { ...base, ...target.bridge.describe() };\n },\n invoke(input: UseAuthorToolInput, signal?: AbortSignal) {\n const target = select(input.alias);\n if (target.closed) throw new AuthorBridgeError(`Canvas '${target.alias}' is closed. Reopen its file.`, 503);\n return target.bridge.invoke(input, signal).then((result) => ({ ...result, alias: target.alias }));\n },\n bridge(alias: string): AuthorBridgeState {\n const canvas = select(alias);\n if (canvas.closed) throw new AuthorBridgeError(`Canvas '${alias}' is closed. Reopen its file.`, 503);\n return canvas.bridge;\n },\n close(alias: string): void {\n const canvas = select(alias);\n canvas.closed = true;\n canvas.bridge.close();\n canvas.bridge = createBridge();\n },\n dispose(): void {\n for (const canvas of byAlias.values()) canvas.bridge.close();\n byAlias.clear();\n byPath.clear();\n },\n };\n}\n\nexport type AuthorCanvasRegistry = ReturnType<typeof createAuthorCanvasRegistry>;\n","import { apiResponse, defineApiRoutes } from '@agimon-ai/po-core/web';\n\nimport type { AuthorOpenFileResult } from './author';\nimport type { AuthorSessionView } from './authorApi';\nimport type { DocumentPreflightReport, ParsedStructuredDocument } from './structuredDocuments';\n\n/**\n * This package's routes, as data.\n *\n * No scope and no base path. The build reads both off\n * `src/extensions/workspaces/sessions/(backend)/api/author/`, so the mount is\n * stated once, by the folder that creates it. The browser used to restate it:\n * `authorStateUrl` built one URL from `API_BASE_PATH` and the document helper\n * two files away spelled `author` out again as a literal, so the two could\n * disagree and nothing would say so.\n *\n * The order below is the order the three Hono apps register in: `/state` in\n * `authorApi`, the eight bridge routes in `authorBridgeApi`, the three document\n * routes in `authorDocumentApi`. A reviewer can read the two side by side.\n *\n * Response types are named only where a caller reads the body. The bridge\n * routes are called by the hub's author channel over `requestSessionApi`, which\n * has its own message vocabulary and never sees this client.\n */\nexport default defineApiRoutes({\n state: {\n method: 'GET',\n path: '/state',\n response: apiResponse<AuthorSessionView>(),\n },\n bridgeRegister: {\n method: 'POST',\n path: '/bridge/register',\n },\n bridgeCatalog: {\n method: 'POST',\n path: '/bridge/catalog',\n },\n /** Long-polls for the next capability request, so it settles when one arrives. */\n bridgeNext: {\n method: 'POST',\n path: '/bridge/next',\n },\n bridgeResult: {\n method: 'POST',\n path: '/bridge/result',\n },\n bridgeCancelled: {\n method: 'POST',\n path: '/bridge/cancelled',\n },\n bridgeDisconnect: {\n method: 'POST',\n path: '/bridge/disconnect',\n },\n bridgeClose: {\n method: 'POST',\n path: '/bridge/close',\n },\n bridgeDescribe: {\n method: 'GET',\n path: '/bridge/describe',\n query: ['alias'],\n },\n bridgeInvoke: {\n method: 'POST',\n path: '/bridge/invoke',\n },\n /**\n * Parses one structured document.\n *\n * Answers a byte-length summary instead when the request names no format,\n * which is the agent-side tool path; the page always names one.\n */\n documentsOpen: {\n method: 'POST',\n path: '/documents/open',\n query: ['session'],\n response: apiResponse<ParsedStructuredDocument | AuthorOpenFileResult>(),\n },\n documentsPreflight: {\n method: 'POST',\n path: '/documents/preflight',\n query: ['session'],\n response: apiResponse<DocumentPreflightReport>(),\n },\n documentsSerialize: {\n method: 'POST',\n path: '/documents/serialize',\n query: ['session'],\n response: apiResponse<{ bytes: string; encoding: string }>(),\n },\n /**\n * The host's own bytes route, not this package's.\n *\n * `host: true` hangs it off the session root rather than under `/plugins`,\n * which is how the cockpit already serves it. Author reads a document's\n * bytes and its digest through it, and writes the edited bytes back to the\n * same path, so both stay raw transfers rather than calls: the body is the\n * file and the digest travels in a header.\n */\n file: {\n method: 'GET',\n path: '/file',\n query: ['path'],\n host: true,\n },\n});\n","import type { AuthorModeActivation } from './author';\n\n/**\n * The wire vocabulary this package's API shares with whatever calls it.\n *\n * Paths live in `./apiRoutes`, which the Hono apps register from and the\n * generated client addresses, so neither half can move alone. What stays here\n * is the mount segment the server registers under and the shape the state\n * route answers with.\n */\n\n/** Where a host mounts this package's API; the segment after /api/plugins/. */\nexport const API_BASE_PATH = 'author';\n\n/** Query parameter naming the session a document request belongs to. */\nexport const SESSION_QUERY_PARAM = 'session';\n\nexport interface AuthorSessionView {\n sessionId: string | null;\n activation: AuthorModeActivation;\n capabilityCount: number;\n}\n","import { Hono } from 'hono';\n\nimport { AuthorBridgeError } from '../../../../../../../models/authorBridgeState';\nimport { parseUseAuthorToolInput } from '../../../../../../../schemas/authorTools';\nimport type { AuthorCanvasRegistry } from '../../../../../../../services/authorCanvasRegistry';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorViewportCapabilityDescriptor } from '../../../../../../../types/author';\n\nfunction record(value: unknown): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new AuthorBridgeError('Invalid request.', 400);\n return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, key: string): string {\n const result = record(value)[key];\n if (typeof result !== 'string' || result === '') throw new AuthorBridgeError(`Invalid ${key}.`, 400);\n return result;\n}\n\nfunction generation(value: unknown): number {\n const result = record(value).generation;\n if (!Number.isSafeInteger(result) || (result as number) < 0) throw new AuthorBridgeError('Invalid generation.', 400);\n return result as number;\n}\n\nasync function body(request: Request): Promise<Record<string, unknown>> {\n return record(await request.json());\n}\n\nexport function createAuthorBridgeApi(registry: AuthorCanvasRegistry): Hono {\n const app = new Hono();\n app.onError((error, context) =>\n context.json(\n { error: error instanceof Error ? error.message : String(error) },\n error instanceof AuthorBridgeError ? error.status : 500,\n ),\n );\n app.post(routes.bridgeRegister.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({ ...registry.bridge(alias).register(text(value, 'bindingId'), generation(value)), alias });\n });\n app.post(routes.bridgeCatalog.path, async (context) => {\n const value = await body(context.req.raw);\n const tools = value.tools;\n if (!Array.isArray(tools)) throw new AuthorBridgeError('Invalid Author catalog.', 400);\n const alias = text(value, 'alias');\n return context.json({\n ...registry\n .bridge(alias)\n .catalog(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n tools as AuthorViewportCapabilityDescriptor[],\n ),\n alias,\n });\n });\n app.post(routes.bridgeNext.path, async (context) => {\n const value = await body(context.req.raw);\n const alias = text(value, 'alias');\n return context.json({\n ...(await registry\n .bridge(alias)\n .next(text(value, 'bindingId'), generation(value), text(value, 'ownerToken'), context.req.raw.signal)),\n alias,\n });\n });\n app.post(routes.bridgeResult.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .result(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n value.result,\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeCancelled.path, async (context) => {\n const value = await body(context.req.raw);\n registry\n .bridge(text(value, 'alias'))\n .cancelled(\n text(value, 'bindingId'),\n generation(value),\n text(value, 'ownerToken'),\n text(value, 'catalogToken'),\n text(value, 'requestId'),\n );\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeDisconnect.path, async (context) => {\n const value = await body(context.req.raw);\n registry.bridge(text(value, 'alias')).disconnect(text(value, 'bindingId'), generation(value));\n return context.json({ accepted: true });\n });\n app.post(routes.bridgeClose.path, async (context) => {\n const value = await body(context.req.raw);\n registry.close(text(value, 'alias'));\n return context.json({ accepted: true });\n });\n app.get(routes.bridgeDescribe.path, (context) => context.json(registry.describe(context.req.query('alias'))));\n app.post(routes.bridgeInvoke.path, async (context) => {\n const value = parseUseAuthorToolInput(await context.req.raw.json());\n return context.json(await registry.invoke(value, context.req.raw.signal));\n });\n return app;\n}\n","import { Hono } from 'hono';\n\nimport {\n parseStructuredDocument,\n preflightStructuredDocument,\n serializeStructuredDocument,\n} from '../../../../../../../services/structuredDocuments';\nimport { DocumentRequestError } from '../../../../../../../services/structuredDocuments/common';\nimport { readDocument } from '../../../../../../../services/structuredDocuments/document';\nimport routes from '../../../../../../../types/apiRoutes';\nimport type { AuthorOpenFileResult } from '../../../../../../../types/author';\nimport type {\n CsvDialect,\n DocumentOperation,\n StructuredDocumentFormat,\n} from '../../../../../../../types/structuredDocuments';\n\nexport { AUTHOR_DOCUMENT_MAX_BYTES } from '../../../../../../../services/structuredDocuments/document';\n\ninterface DocumentRequest {\n path?: unknown;\n alias?: unknown;\n format?: unknown;\n operations?: unknown;\n preflightDigest?: unknown;\n csvDialect?: unknown;\n}\n\nexport interface AuthorDocumentApiOptions {\n cwd?: string;\n /** Admits the session's artifact folder beside the working tree. */\n sessionId?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n open?: (path: string, signal?: AbortSignal, alias?: string) => Promise<AuthorOpenFileResult>;\n}\n\nconst FORMATS = new Set<StructuredDocumentFormat>(['markdown-slides', 'csv', 'pptx', 'xlsx']);\n\nfunction errorResponse(\n context: { json: (value: unknown, status: 400 | 403 | 404 | 413 | 422 | 500) => Response },\n error: unknown,\n): Response {\n const message = error instanceof Error ? error.message : 'Document operation failed.';\n // A refusal names its own status; anything else is a request the document cannot satisfy.\n return context.json({ error: message }, error instanceof DocumentRequestError ? error.status : 422);\n}\n\nfunction requestFormat(value: unknown): StructuredDocumentFormat {\n if (typeof value !== 'string' || !FORMATS.has(value as StructuredDocumentFormat))\n throw new Error('A supported format is required.');\n return value as StructuredDocumentFormat;\n}\n\nfunction requestOperations(value: unknown): DocumentOperation[] {\n if (value === undefined) return [];\n if (!Array.isArray(value) || value.length > 100_000) throw new Error('A bounded operations array is required.');\n return value.map((operation) => {\n if (\n typeof operation !== 'object' ||\n operation === null ||\n typeof (operation as Record<string, unknown>).fragmentId !== 'string' ||\n typeof (operation as Record<string, unknown>).replacement !== 'string'\n ) {\n throw new Error('Each operation requires string fragmentId and replacement fields.');\n }\n return operation as DocumentOperation;\n });\n}\n\nasync function bodyOf(request: Request): Promise<DocumentRequest> {\n const body = (await request.json()) as unknown;\n if (typeof body !== 'object' || body === null || Array.isArray(body)) throw new Error('A JSON object is required.');\n return body as DocumentRequest;\n}\n\nexport function createAuthorDocumentApi(options: AuthorDocumentApiOptions = {}): Hono {\n const app = new Hono();\n const cwd = options.cwd ?? process.cwd();\n\n app.post(routes.documentsOpen.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (body.format === undefined && options.open !== undefined) {\n return context.json(\n await options.open(body.path as string, context.req.raw.signal, body.alias as string | undefined),\n );\n }\n const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);\n if (body.format === undefined) {\n return context.json({ path: body.path as string, byteLength: bytes.byteLength } satisfies AuthorOpenFileResult);\n }\n return context.json(\n await parseStructuredDocument(requestFormat(body.format), bytes, body.csvDialect as Partial<CsvDialect>),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsPreflight.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);\n return context.json(\n await preflightStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.csvDialect as Partial<CsvDialect>,\n ),\n );\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n\n app.post(routes.documentsSerialize.path, async (context) => {\n try {\n const body = await bodyOf(context.req.raw);\n if (typeof body.preflightDigest !== 'string') throw new Error('A preflight report digest is required.');\n const bytes = await readDocument(cwd, body.path, options.sessionId, options.environment);\n const serialized = await serializeStructuredDocument(\n requestFormat(body.format),\n bytes,\n requestOperations(body.operations),\n body.preflightDigest,\n body.csvDialect as Partial<CsvDialect>,\n );\n return context.json({\n bytes: Buffer.from(serialized.bytes).toString('base64'),\n encoding: 'base64',\n manifest: serialized.manifest,\n operationLog: serialized.operationLog,\n });\n } catch (error) {\n return errorResponse(context, error);\n }\n });\n return app;\n}\n","import { randomUUID } from 'node:crypto';\n\nimport type { PoApi, PoApiContext, PoApiHandler } from '@agimon-ai/po-core/packageApi';\nimport { Hono } from 'hono';\n\nimport { createAuthorBridgeState, type AuthorBridgeState } from '../../../../../../../models/authorBridgeState';\nimport {\n createAuthorCanvasRegistry,\n type AuthorCanvasRegistry,\n} from '../../../../../../../services/authorCanvasRegistry';\nimport type { AuthorCatalog } from '../../../../../../../services/authorCatalog/type';\nimport routes from '../../../../../../../types/apiRoutes';\nimport { API_BASE_PATH, type AuthorSessionView } from '../../../../../../../types/authorApi';\nimport { createAuthorBridgeApi } from './authorBridgeApi';\nimport { createAuthorDocumentApi } from './authorDocumentApi';\n\nexport interface AuthorApiOptions {\n sessionId?: string;\n cwd?: string;\n environment?: Readonly<Record<string, string | undefined>>;\n readState?: () => Omit<AuthorSessionView, 'sessionId'>;\n registry?: AuthorCanvasRegistry;\n}\n\nconst inactiveState = (): Omit<AuthorSessionView, 'sessionId'> => ({ activation: 'inactive', capabilityCount: 0 });\nconst createBridge = (): AuthorBridgeState =>\n createAuthorBridgeState({\n now: Date.now,\n issueToken: randomUUID,\n scheduleTimeout(callback, delayMs) {\n const timer = setTimeout(callback, delayMs);\n timer.unref?.();\n return () => clearTimeout(timer);\n },\n });\n\nexport function createAuthorApi(options: AuthorApiOptions = {}): Hono {\n const app = new Hono();\n const registry =\n options.registry ??\n createAuthorCanvasRegistry(options.cwd ?? process.cwd(), createBridge, options.sessionId, options.environment);\n app.get(routes.state.path, (context) =>\n context.json({\n sessionId: options.sessionId ?? null,\n ...(options.readState ?? inactiveState)(),\n } satisfies AuthorSessionView),\n );\n app.route('/', createAuthorBridgeApi(registry));\n app.route(\n '/',\n createAuthorDocumentApi({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.sessionId === undefined ? {} : { sessionId: options.sessionId }),\n ...(options.environment === undefined ? {} : { environment: options.environment }),\n open: (path, signal, alias) => registry.open(path, signal, alias),\n }),\n );\n return app;\n}\n\nexport const api: PoApi = {\n basePath: API_BASE_PATH,\n start(context: PoApiContext): PoApiHandler {\n // One server hosts many sessions, so its own directory is never a session's project.\n if (context.cwd === undefined) throw new Error('Author requires the session working directory.');\n const registry = createAuthorCanvasRegistry(context.cwd, createBridge, context.sessionId, context.environment);\n const app = createAuthorApi({\n ...(context.sessionId === undefined ? {} : { sessionId: context.sessionId }),\n cwd: context.cwd,\n ...(context.environment === undefined ? {} : { environment: context.environment }),\n registry,\n });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n};\n\n/** The session API and tools share the same browser ownership and pending requests. */\nexport function createAuthorSessionApi(\n cwd: string,\n sessionId: string,\n environment: Readonly<Record<string, string | undefined>>,\n): { api: PoApi; catalog: AuthorCatalog } {\n const registry = createAuthorCanvasRegistry(cwd, createBridge, sessionId, environment);\n return {\n catalog: {\n open: (path, signal, alias) => registry.open(path, signal, alias),\n async describe(signal, alias) {\n signal?.throwIfAborted();\n return registry.describe(alias);\n },\n execute: (input, signal) => registry.invoke(input, signal),\n },\n api: {\n basePath: API_BASE_PATH,\n start() {\n const app = createAuthorApi({ cwd, sessionId, environment, registry });\n return { fetch: (request) => app.fetch(request), close: () => registry.dispose() };\n },\n },\n };\n}\n","import { PO_CODEMODE_SERVICE, readPoCodemode } from '@agimon-ai/po-core/codemode';\nimport { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\nimport { serverMinorModes } from '@agimon-ai/po-minor-mode';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { authorMinorMode } from '../../../../models/authorMode';\nimport { createAuthorCatalog } from '../../../../services/authorCatalog';\nimport { createWebmcpNamespace } from '../../../../services/webmcpNamespace';\nimport { api, createAuthorSessionApi } from './api/author/_lib/authorApi';\n\nexport default defineRoot(({ agent, host, signal }: PoServerPluginContext) => {\n const environment = host.context.environment;\n if (agent && environment === undefined) throw new Error('Author requires an admitted session environment.');\n const session =\n agent && environment ? createAuthorSessionApi(agent.context.cwd, agent.context.sessionId, environment) : undefined;\n const isActive = () => (agent?.context.selection.state?.['minor-mode'] ?? []).includes(authorMinorMode.descriptor.id);\n const mode = agent\n ? authorMinorMode.createOwner({\n isActive,\n detail: () => 'document authoring available',\n async setActive(enabled) {\n const modes = (agent.context.selection.state?.['minor-mode'] ?? []).filter(\n (id) => id !== authorMinorMode.descriptor.id,\n );\n await agent.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, authorMinorMode.descriptor.id] : modes,\n });\n },\n })\n : undefined;\n let disposed = false;\n const catalog = createAuthorCatalog(session?.catalog);\n const assertAvailable = () => {\n signal.throwIfAborted();\n if (disposed) throw new Error('Author session is disposed.');\n if (!isActive()) throw new Error('Author mode is not active.');\n };\n const mountNamespace = (context: Context) => {\n if (!agent) return;\n const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAvailable);\n context.inject([PO_CODEMODE_SERVICE], (scoped) => {\n const registration = readPoCodemode(scoped)?.register('@agimon-ai/po-author', namespace);\n return () => registration?.dispose();\n });\n };\n return {\n onDispose: () => {\n disposed = true;\n },\n value: {\n api: session?.api ?? api,\n catalog,\n // Registration is gated by AUTHOR_TOOL_WHEN; this re-checks a call already in flight when the mode turns off.\n assertAvailable,\n service: undefined,\n },\n services: [...(mode ? [serverMinorModes([mode])] : []), mountNamespace],\n };\n});\n","import type { AuthorViewportCapabilityDescriptor } from './author';\n\nexport const authorChannelType = 'author_webmcp';\n\nexport interface AuthorRegisterMessage {\n alias: string;\n kind: 'register';\n generation: number;\n}\n\nexport interface AuthorReleaseMessage {\n alias: string;\n kind: 'release';\n generation: number;\n}\nexport interface AuthorCatalogMessage {\n alias: string;\n kind: 'catalog';\n generation: number;\n ownerToken: string;\n tools: AuthorViewportCapabilityDescriptor[];\n}\n\nexport interface AuthorResultMessage {\n alias: string;\n kind: 'result';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n result: unknown;\n}\n\nexport interface AuthorCancelledMessage {\n alias: string;\n kind: 'cancelled';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport type AuthorBrowserMessage =\n | AuthorRegisterMessage\n | AuthorReleaseMessage\n | AuthorCatalogMessage\n | AuthorResultMessage\n | AuthorCancelledMessage;\n\nexport interface AuthorAcceptedMessage {\n alias?: string;\n kind: 'accepted';\n generation: number;\n ownerToken: string;\n catalogToken?: string;\n leaseMs: number;\n}\n\nexport interface AuthorRequestMessage {\n alias?: string;\n kind: 'request';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n name: string;\n arguments: Record<string, unknown>;\n}\n\nexport interface AuthorCancelMessage {\n alias?: string;\n kind: 'cancel';\n generation: number;\n ownerToken: string;\n catalogToken: string;\n requestId: string;\n}\n\nexport interface AuthorRejectedMessage {\n alias?: string;\n kind: 'rejected';\n reason: string;\n}\n\nexport type AuthorHubMessage =\n | AuthorAcceptedMessage\n | AuthorRequestMessage\n | AuthorCancelMessage\n | AuthorRejectedMessage;\n\nexport interface AuthorWebView {\n activation: 'inactive' | 'active';\n capabilityCount: number;\n}\n","import type {\n PoHubChannelConnection,\n PoHubChannelHost,\n PoHubChannelSource,\n PoHubSessionScope,\n PoHubChannel,\n} from '@agimon-ai/po-core/hubChannel';\n\nimport { AUTHOR_ALIAS_PATTERN } from '../../schemas/authorTools';\nimport routes from '../../types/apiRoutes';\nimport { API_BASE_PATH } from '../../types/authorApi';\nimport { authorChannelType, type AuthorBrowserMessage, type AuthorHubMessage } from '../../types/webAuthor';\n\n/**\n * Which route carries each message the browser sends.\n *\n * The paths come from the package's one route table, so the hub cannot address\n * a bridge route the session no longer serves. `release` is absent because it\n * is answered by the disconnect route rather than one of its own.\n */\nconst BRIDGE_ROUTE: Readonly<Record<Exclude<AuthorBrowserMessage['kind'], 'release'>, string>> = {\n register: routes.bridgeRegister.path,\n catalog: routes.bridgeCatalog.path,\n result: routes.bridgeResult.path,\n cancelled: routes.bridgeCancelled.path,\n};\n\ninterface Binding {\n alias: string;\n scope: PoHubSessionScope;\n connectionId: string;\n generation: number;\n ownerToken: string;\n poll?: AbortController;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction browserMessage(value: unknown): AuthorBrowserMessage | undefined {\n if (\n !isRecord(value) ||\n typeof value.kind !== 'string' ||\n typeof value.alias !== 'string' ||\n !AUTHOR_ALIAS_PATTERN.test(value.alias)\n )\n return undefined;\n if (!['register', 'release', 'catalog', 'result', 'cancelled'].includes(value.kind)) return undefined;\n return value as unknown as AuthorBrowserMessage;\n}\n\nasync function responsePayload(response: Response): Promise<AuthorHubMessage> {\n const value = (await response.json()) as unknown;\n if (response.ok) return value as AuthorHubMessage;\n const reason =\n isRecord(value) && typeof value.error === 'string' ? value.error : `Author bridge HTTP ${response.status}`;\n return { kind: 'rejected', reason };\n}\n\nexport function createAuthorChannel(): PoHubChannel {\n const bindings = new Map<string, Binding>();\n let host: PoHubChannelHost | undefined;\n let closed = false;\n const keyOf = (sessionId: string, connectionId: string, alias: string): string =>\n `${sessionId}\\0${connectionId}\\0${alias}`;\n const send = async (scope: PoHubSessionScope, path: string, value: Record<string, unknown>, signal?: AbortSignal) =>\n await host!.requestSessionApi(scope, {\n basePath: API_BASE_PATH,\n path,\n method: 'POST',\n body: JSON.stringify(value),\n ...(signal === undefined ? {} : { signal }),\n });\n const publish = (binding: Binding, payload: AuthorHubMessage): boolean =>\n host?.publishToConnection?.(binding.connectionId, binding.scope.sessionId, { ...payload, alias: binding.alias }) ??\n false;\n\n const poll = async (binding: Binding): Promise<void> => {\n binding.poll?.abort();\n const controller = new AbortController();\n binding.poll = controller;\n while (!closed && bindings.get(keyOf(binding.scope.sessionId, binding.connectionId, binding.alias)) === binding) {\n try {\n const response = await send(\n binding.scope,\n routes.bridgeNext.path,\n {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n ownerToken: binding.ownerToken,\n },\n controller.signal,\n );\n const payload = await responsePayload(response);\n if (controller.signal.aborted) break;\n if (!publish(binding, payload) || payload.kind === 'rejected') break;\n } catch (error) {\n if (!controller.signal.aborted) host?.onNotice(error instanceof Error ? error.message : String(error));\n break;\n }\n }\n if (binding.poll === controller) binding.poll = undefined;\n };\n\n const channel: PoHubChannel = {\n frameType: authorChannelType,\n lifecycle: 'hub',\n receiveWithoutSubscription: true,\n start(channelHost) {\n host = channelHost;\n const source: PoHubChannelSource = {\n payloadFor: () => undefined,\n sessionRemoved(sessionId) {\n for (const [key, binding] of bindings) {\n if (binding.scope.sessionId !== sessionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n close() {\n closed = true;\n for (const binding of bindings.values()) {\n binding.poll?.abort();\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n bindings.clear();\n },\n };\n return source;\n },\n receive(scope, payload, connection) {\n const message = browserMessage(payload);\n if (message === undefined || host === undefined || closed) return;\n void (async () => {\n const key = keyOf(scope.sessionId, connection.connectionId, message.alias);\n const previous = bindings.get(key);\n if (message.kind === 'release') {\n if (previous === undefined || previous.generation !== message.generation) return;\n previous.poll?.abort();\n bindings.delete(key);\n await send(scope, routes.bridgeDisconnect.path, {\n alias: message.alias,\n bindingId: connection.connectionId,\n generation: message.generation,\n });\n return;\n }\n const route = BRIDGE_ROUTE[message.kind];\n const response = await send(scope, route, { ...message, bindingId: connection.connectionId });\n const reply = await responsePayload(response);\n if (reply.kind === 'accepted') {\n const current = bindings.get(key);\n if (current?.generation === reply.generation && current.ownerToken === reply.ownerToken) {\n publish(current, reply);\n if (current.poll === undefined) void poll(current);\n return;\n }\n const binding: Binding = {\n alias: message.alias,\n scope,\n connectionId: connection.connectionId,\n generation: reply.generation,\n ownerToken: reply.ownerToken,\n };\n current?.poll?.abort();\n bindings.set(key, binding);\n publish(binding, reply);\n void poll(binding);\n } else if (reply.kind === 'rejected') {\n if (previous !== undefined) publish(previous, reply);\n else\n host?.publishToConnection?.(connection.connectionId, scope.sessionId, { ...reply, alias: message.alias });\n }\n })().catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n },\n disconnected(connection: PoHubChannelConnection) {\n for (const [key, binding] of bindings) {\n if (binding.connectionId !== connection.connectionId) continue;\n binding.poll?.abort();\n bindings.delete(key);\n void send(binding.scope, routes.bridgeDisconnect.path, {\n alias: binding.alias,\n bindingId: binding.connectionId,\n generation: binding.generation,\n }).catch((error: unknown) => host?.onNotice(error instanceof Error ? error.message : String(error)));\n }\n },\n };\n return channel;\n}\n","import { defineChannel } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorChannel } from '../../../services/webAuthorChannel';\n\nexport default defineChannel(createAuthorChannel);\n","import { defineServerMethod, type PoServerHostService } from '@agimon-ai/po-core/serverPlugin';\n\nimport { authorBridgeMethod } from '../../schemas/authorFacade';\nimport { authorChannelType } from '../../types/webAuthor';\n\nexport function createAuthorBridgeMethod(scope: 'global' | 'workspace', host: PoServerHostService) {\n return defineServerMethod(authorBridgeMethod(scope), ({ sessionId, message }, caller) => {\n if (!caller.connectionId) throw new Error('Author bridge requires an authenticated browser connection.');\n if (!host.context.receiveChannel?.(sessionId, authorChannelType, message, caller.connectionId))\n throw new Error('Author bridge session is outside this mount.');\n return {};\n });\n}\n","import { defineMethod } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createAuthorBridgeMethod } from '../../../services/authorBridgeMethod';\n\nexport default defineMethod(({ host }: PoServerPluginContext) =>\n host.scope === 'session'\n ? { register: () => ({ dispose: () => undefined }) }\n : createAuthorBridgeMethod(host.scope, host),\n);\n","import { defineRoute, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\ntype AuthorServerScope = Awaited<ReturnType<typeof import('../../root.server').default>>['value'];\n\nexport default defineRoute((context: WithRoot<PoServerPluginContext, AuthorServerScope>) => context.root.api);\n","import { defineCommand as defineRoutedCommand, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createAuthorCommand } from '../../../../../services/authorCommand';\nimport type { AuthorExtensionService } from '../../../../../types/extension';\n\nexport default defineRoutedCommand((context: WithRoot<unknown, { readonly service?: AuthorExtensionService }>) =>\n createAuthorCommand(context.root.service),\n);\n","import { defineHook } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_GUIDANCE } from '../../../../../constants/author';\n\nexport default defineHook<'before_agent_start'>({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor', mode: 'author' } },\n event: 'before_agent_start',\n handle(event) {\n const systemPrompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n return { systemPrompt: `${systemPrompt}\\n\\n${AUTHOR_GUIDANCE}`.trim() };\n },\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nconst skillFile = 'src/prompts/codemode-how-to-author/SKILL.md';\n\nexport default defineResource({\n name: 'codemode-how-to-author',\n description:\n 'Call Author canvas capabilities through the webmcp namespace in code mode. Use for canvas discovery, capability calls, and their catalog tokens from exec.',\n kind: 'skill' as const,\n pinned: true,\n path: packageResourcePath(import.meta.url, skillFile),\n read: () => readPackageResource(import.meta.url, skillFile),\n});\n","import { defineResource } from '@agimon-ai/po-core/extensionFile';\nimport { packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverPlugin';\n\nexport default defineResource({\n when: { state: { 'minor-mode': 'author' }, attribution: { kind: 'minor' as const, mode: 'author' } },\n name: 'po-use-author',\n description: 'Use the Author workflow for focused document review, canvas steering, and bounded authoring.',\n kind: 'skill' as const,\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n read: () => readPackageResource(import.meta.url, 'src/prompts/po-use-author/SKILL.md'),\n});\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[1]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[0]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","import { defineTool, type WithRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { AUTHOR_TOOL_WHEN, createAuthorTools, type AuthorToolRoot } from '../../../../../services/authorTools';\n\nexport default defineTool((context: WithRoot<unknown, AuthorToolRoot>) => ({\n ...createAuthorTools(context.root.catalog, context.root.assertAvailable)[2]!,\n when: AUTHOR_TOOL_WHEN,\n}));\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelAuthorWebmcp from '../src/extensions/(backend)/channel/author-webmcp.server';\nimport methodBridge from '../src/extensions/(backend)/method/bridge.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/author/route.server';\nimport commandAuthor from '../src/extensions/workspaces/sessions/(backend)/command/author.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport resourceCodemodeHowToAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-author.server';\nimport resourcePoUseAuthor from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-author.server';\nimport toolDescribeAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/describe-author-tools.server';\nimport toolOpenAuthoringFile from '../src/extensions/workspaces/sessions/(backend)/tool/open-authoring-file.server';\nimport toolUseAuthorTools from '../src/extensions/workspaces/sessions/(backend)/tool/use-author-tools.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-author',\n providerOverrides: composeServerProviderOverrides(rootSession),\n injects: composeRootInjects({ session: [rootSession] }),\n global: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return [() => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n workspace: (context) => ({\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n }),\n session: async (context) => {\n const scopeSession = await context.scopeRoot('session', rootSession, context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'author_webmcp' }, at(channelAuthorWebmcp, context))]); },\n get commands(): PoServerSessionPlugin['commands'] { return [via({ name: 'author' }, at(commandAuthor, contextSession))]; },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession))]; },\n get methods(): PoServerSessionPlugin['methods'] { return [at(methodBridge, context)]; },\n get resources(): PoServerSessionPlugin['resources'] { return [at(resourceCodemodeHowToAuthor, contextSession), at(resourcePoUseAuthor, contextSession)]; },\n get tools(): PoServerSessionPlugin['tools'] { return [via({ name: 'describe_author_tools' }, at(toolDescribeAuthorTools, contextSession)), via({ name: 'open_authoring_file' }, at(toolOpenAuthoringFile, contextSession)), via({ name: 'use_author_tools' }, at(toolUseAuthorTools, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;AAMA,MAAM,eAAe;;;;;;;;;;;;;;;AAgBrB,SAAS,KAAQ,OAAa;CAC5B,OAAO,UAAU,KAAA,IAAY,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACvE;AAEA,SAAgB,sBACd,SACA,WACA,iBACqB;CACrB,OAAO;EACL,MAAM;EACN,SACE;EACF,cAAc;EACd,KAAK,KAAK;GACR,IAAI,IAAI,cAAc,WAAW,MAAM,IAAI,MAAM,qDAAqD;GACtG,IAAI,WAAW;GACf,IAAI,gBAAgB;IAClB,WAAW;GACb,CAAC;GACD,MAAM,cAAc;IAClB,IAAI,OAAO,eAAe;IAC1B,IAAI,UAAU,MAAM,IAAI,MAAM,gCAAgC;IAC9D,gBAAgB;GAClB;GACA,MAAM,UAAmC,OAAO,OAAO,IAAI;GAC3D,QAAQ,WAAW,OAAO,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aAAa;EAAM;EAC9D,OAAO;GACL,GAAG,iBAAiB,YAAY;GAChC,IAAI,MAAoC;IAAE,OAAO,CAAC,GAAGG,sBAAU,cAAc,CAAC;GAAG;GACjF,IAAI,WAA8C;IAAE,OAAO,QAAQ,CAAC,QAAQ,OAAO,QAAQ,IAAI,KAAA,UAAkB,IAAI,EAAE,WAAW,gBAAgB,GAAG,GAAGF,8BAAqB,OAAO,CAAC,CAAC,CAAC;GAAG;GAC1L,IAAI,WAA8C;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,SAAS,GAAG,GAAGG,uBAAe,cAAc,CAAC,CAAC;GAAG;GACzH,IAAI,QAAwC;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,mCAAsB,cAAc,CAAC,CAAC;GAAG;GACvI,IAAI,UAA4C;IAAE,OAAO,CAAC,GAAGH,uBAAc,OAAO,CAAC;GAAG;GACtF,IAAI,YAAgD;IAAE,OAAO,CAAC,GAAGI,uCAA6B,cAAc,GAAG,GAAGC,8BAAqB,cAAc,CAAC;GAAG;GACzJ,IAAI,QAAwC;IAAE,OAAO;KAAC,IAAI,EAAE,MAAM,wBAAwB,GAAG,GAAGC,sCAAyB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,sBAAsB,GAAG,GAAGC,oCAAuB,cAAc,CAAC;KAAG,IAAI,EAAE,MAAM,mBAAmB,GAAG,GAAGC,iCAAoB,cAAc,CAAC;IAAC;GAAG;GACxS,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-author",
3
- "version": "0.0.0-alpha.32",
3
+ "version": "0.0.0-alpha.34",
4
4
  "description": "Visual steering workspace for focused document review and bounded authoring",
5
5
  "keywords": [
6
6
  "ai",
@@ -66,11 +66,11 @@
66
66
  "access": "public"
67
67
  },
68
68
  "dependencies": {
69
- "@agimon-ai/po-artifact": "0.0.0-alpha.31",
70
- "@agimon-ai/po-core": "0.0.0-alpha.32",
71
- "@agimon-ai/po-minor-mode": "0.0.0-alpha.32",
72
- "@agimon-ai/po-web-components": "0.0.0-alpha.32",
73
- "@agimon-ai/po-web-security": "0.0.0-alpha.32",
69
+ "@agimon-ai/po-artifact": "0.0.0-alpha.33",
70
+ "@agimon-ai/po-core": "0.0.0-alpha.34",
71
+ "@agimon-ai/po-minor-mode": "0.0.0-alpha.34",
72
+ "@agimon-ai/po-web-components": "0.0.0-alpha.34",
73
+ "@agimon-ai/po-web-security": "0.0.0-alpha.34",
74
74
  "@deepseek-ai/cordis": "4.0.5",
75
75
  "csv-parse": "7.0.3",
76
76
  "hono": "4.13.13",
@@ -80,8 +80,8 @@
80
80
  "yazl": "3.3.1"
81
81
  },
82
82
  "devDependencies": {
83
- "@agimon-ai/po-build": "0.0.0-alpha.32",
84
- "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.32",
83
+ "@agimon-ai/po-build": "0.0.0-alpha.34",
84
+ "@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.34",
85
85
  "@earendil-works/pi-coding-agent": "1.3.0",
86
86
  "@tanstack/react-store": "0.11.2",
87
87
  "@tanstack/store": "0.11.2",