@agimon-ai/po-author 0.0.0-alpha.35 → 0.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/server.cjs +17 -5
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +17 -5
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +625 -16
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{structuredDocuments-OYXnnCrZ.cjs → structuredDocuments-BAFRIGk8.cjs} +7 -1
- package/dist/{structuredDocuments-OYXnnCrZ.cjs.map → structuredDocuments-BAFRIGk8.cjs.map} +1 -1
- package/dist/{structuredDocuments-BAvFI8VH.mjs → structuredDocuments-pCTpu4Fh.mjs} +2 -2
- package/dist/{structuredDocuments-BAvFI8VH.mjs.map → structuredDocuments-pCTpu4Fh.mjs.map} +1 -1
- package/package.json +9 -8
- package/src/prompts/codemode-how-to-author/SKILL.md +3 -3
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_structuredDocuments = require("../structuredDocuments-
|
|
5
|
+
const require_structuredDocuments = require("../structuredDocuments-BAFRIGk8.cjs");
|
|
6
6
|
const require_authorFacade = require("../authorFacade-BkIMF1lR.cjs");
|
|
7
7
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
8
8
|
let _agimon_ai_po_minor_mode = require("@agimon-ai/po-minor-mode");
|
|
@@ -28,6 +28,8 @@ const DECLARATIONS = `interface AuthorViewportCatalogSnapshot {
|
|
|
28
28
|
nextStep?: string;
|
|
29
29
|
}
|
|
30
30
|
declare const webmcp: {
|
|
31
|
+
/** Open or reuse a canvas for a relative repository file or a session artifact. The returned alias is canonical; its catalog may still be opening. */
|
|
32
|
+
open(input: { path: string; alias?: string }): Promise<{ path: string; byteLength: number; alias?: string; status?: 'opening' | 'ready' | 'unavailable'; reused?: boolean }>;
|
|
31
33
|
/** Ready canvases, or one canvas's tools and its catalog token. */
|
|
32
34
|
describe(input?: { alias?: string }): Promise<AuthorViewportCatalogSnapshot>;
|
|
33
35
|
/** Call one tool with an explicit current token. Await same-canvas calls sequentially. */
|
|
@@ -39,7 +41,7 @@ function copy(value) {
|
|
|
39
41
|
function createWebmcpNamespace(catalog, sessionId, assertAvailable) {
|
|
40
42
|
return {
|
|
41
43
|
name: "webmcp",
|
|
42
|
-
summary: "Author canvas WebMCP: describe
|
|
44
|
+
summary: "Author canvas WebMCP: open a file as a canvas, describe its catalog, then call one tool with its explicit token. Await same-canvas calls sequentially; structured errors remain data.",
|
|
43
45
|
declarations: DECLARATIONS,
|
|
44
46
|
bind(run) {
|
|
45
47
|
if (run.sessionId !== sessionId) throw new Error("Author WebMCP namespace belongs to another session.");
|
|
@@ -53,6 +55,13 @@ function createWebmcpNamespace(catalog, sessionId, assertAvailable) {
|
|
|
53
55
|
assertAvailable();
|
|
54
56
|
};
|
|
55
57
|
const members = Object.create(null);
|
|
58
|
+
members.open = async (input) => {
|
|
59
|
+
check();
|
|
60
|
+
const { path, alias } = require_structuredDocuments.parseOpenAuthoringFileInput(copy(input));
|
|
61
|
+
const result = await catalog.open(path, run.signal, alias);
|
|
62
|
+
check();
|
|
63
|
+
return copy(result);
|
|
64
|
+
};
|
|
56
65
|
members.describe = async (input) => {
|
|
57
66
|
check();
|
|
58
67
|
const { alias } = require_structuredDocuments.parseDescribeAuthorToolsInput(copy(input === void 0 ? {} : input));
|
|
@@ -665,14 +674,17 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ ag
|
|
|
665
674
|
}) : void 0;
|
|
666
675
|
let disposed = false;
|
|
667
676
|
const catalog = require_structuredDocuments.createAuthorCatalog(session?.catalog);
|
|
668
|
-
const
|
|
677
|
+
const assertAlive = () => {
|
|
669
678
|
signal.throwIfAborted();
|
|
670
679
|
if (disposed) throw new Error("Author session is disposed.");
|
|
680
|
+
};
|
|
681
|
+
const assertAvailable = () => {
|
|
682
|
+
assertAlive();
|
|
671
683
|
if (!isActive()) throw new Error("Author mode is not active.");
|
|
672
684
|
};
|
|
673
685
|
const mountNamespace = (context) => {
|
|
674
686
|
if (!agent) return;
|
|
675
|
-
const namespace = createWebmcpNamespace(catalog, agent.context.sessionId,
|
|
687
|
+
const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAlive);
|
|
676
688
|
context.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE], (scoped) => {
|
|
677
689
|
const registration = (0, _agimon_ai_po_core_codemode.readPoCodemode)(scoped)?.register("@agimon-ai/po-author", namespace);
|
|
678
690
|
return () => registration?.dispose();
|
|
@@ -904,7 +916,7 @@ var before_agent_start_server_default = (0, _agimon_ai_po_core_extensionFile.def
|
|
|
904
916
|
const skillFile = "src/prompts/codemode-how-to-author/SKILL.md";
|
|
905
917
|
var codemode_how_to_author_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
|
|
906
918
|
name: "codemode-how-to-author",
|
|
907
|
-
description: "
|
|
919
|
+
description: "Open a file as a canvas the person sees, then read and change it through the tools that canvas offers. Use to review or edit a document, image or sheet together with the person; works without Author mode.",
|
|
908
920
|
kind: "skill",
|
|
909
921
|
pinned: true,
|
|
910
922
|
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, skillFile),
|
|
@@ -1 +1 @@
|
|
|
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,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,UAAUA,4BAAAA,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,SAASC,4BAAAA,wBAAwB,KAAK,KAAK,CAAC;IAClD,MAAM,SAAS,MAAM,QAAQ,QAAQ,QAAQ,IAAI,MAAM;IACvD,MAAM;IACN,OAAO,KAAK,OAAO,MAAM;GAC3B;GACA,OAAO;EACT;CACF;AACF;;;ACnDA,MAAa,4BAA4B;AAUzC,SAAS,OAAO,MAAc,WAA4B;CACxD,MAAM,WAAWC,U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,CAAC;GAAG;GACjF,IAAI,WAA8C;IAAE,OAAO,QAAQ,CAAC,QAAQ,OAAO,QAAQ,IAAI,KAAA,UAAkB,IAAI,EAAE,WAAW,gBAAgB,GAAG,GAAGH,8BAAqB,OAAO,CAAC,CAAC,CAAC;GAAG;GAC1L,IAAI,WAA8C;IAAE,OAAO,CAAC,IAAI,EAAE,MAAM,SAAS,GAAG,GAAGI,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,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":["parseOpenAuthoringFileInput","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 {\n parseDescribeAuthorToolsInput,\n parseOpenAuthoringFileInput,\n parseUseAuthorToolInput,\n} 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 /** Open or reuse a canvas for a relative repository file or a session artifact. The returned alias is canonical; its catalog may still be opening. */\n open(input: { path: string; alias?: string }): Promise<{ path: string; byteLength: number; alias?: string; status?: 'opening' | 'ready' | 'unavailable'; reused?: boolean }>;\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: open a file as a canvas, describe its catalog, 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.open = async (input: unknown) => {\n check();\n const { path, alias } = parseOpenAuthoringFileInput(copy(input));\n const result = await catalog.open(path, run.signal, alias);\n check();\n return copy(result);\n };\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 assertAlive = () => {\n signal.throwIfAborted();\n if (disposed) throw new Error('Author session is disposed.');\n };\n const assertAvailable = () => {\n assertAlive();\n if (!isActive()) throw new Error('Author mode is not active.');\n };\n const mountNamespace = (context: Context) => {\n if (!agent) return;\n // The webmcp namespace and its pinned skill stay available without Author mode; only the direct tools are mode-gated.\n const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAlive);\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 'Open a file as a canvas the person sees, then read and change it through the tools that canvas offers. Use to review or edit a document, image or sheet together with the person; works without Author mode.',\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":";;;;;;;;;;;;;;;;;;;;AAUA,MAAM,eAAe;;;;;;;;;;;;;;;;;AAkBrB,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,OAAO,OAAO,UAAmB;IACvC,MAAM;IACN,MAAM,EAAE,MAAM,UAAUA,4BAAAA,4BAA4B,KAAK,KAAK,CAAC;IAC/D,MAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK;IAC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AwB,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,5 +1,5 @@
|
|
|
1
1
|
import { o as authorBridgeMethod } from "../authorFacade-CpLG3duk.mjs";
|
|
2
|
-
import { A as AUTHOR_ALIAS_PATTERN, C as AuthorBridgeError, D as createAuthorTools, E as AUTHOR_TOOL_WHEN, F as
|
|
2
|
+
import { A as AUTHOR_ALIAS_PATTERN, C as AuthorBridgeError, D as createAuthorTools, E as AUTHOR_TOOL_WHEN, F as parseUseAuthorToolInput, I as AUTHOR_ARTIFACT_PREFIX, N as parseDescribeAuthorToolsInput, P as parseOpenAuthoringFileInput, R as AUTHOR_GUIDANCE, T as createAuthorCatalog, _ as DocumentRequestError, b as authorMinorMode, n as preflightStructuredDocument, r as serializeStructuredDocument, t as parseStructuredDocument, v as documentTooLarge, w as createAuthorBridgeState, y as createAuthorCommand } from "../structuredDocuments-pCTpu4Fh.mjs";
|
|
3
3
|
import { composeServerProviderOverrides, defineServerMethod, defineServerPlugin, packageResourcePath, readPackageResource } from "@agimon-ai/po-core/serverPlugin";
|
|
4
4
|
import { serverMinorModes } from "@agimon-ai/po-minor-mode";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
@@ -22,6 +22,8 @@ const DECLARATIONS = `interface AuthorViewportCatalogSnapshot {
|
|
|
22
22
|
nextStep?: string;
|
|
23
23
|
}
|
|
24
24
|
declare const webmcp: {
|
|
25
|
+
/** Open or reuse a canvas for a relative repository file or a session artifact. The returned alias is canonical; its catalog may still be opening. */
|
|
26
|
+
open(input: { path: string; alias?: string }): Promise<{ path: string; byteLength: number; alias?: string; status?: 'opening' | 'ready' | 'unavailable'; reused?: boolean }>;
|
|
25
27
|
/** Ready canvases, or one canvas's tools and its catalog token. */
|
|
26
28
|
describe(input?: { alias?: string }): Promise<AuthorViewportCatalogSnapshot>;
|
|
27
29
|
/** Call one tool with an explicit current token. Await same-canvas calls sequentially. */
|
|
@@ -33,7 +35,7 @@ function copy(value) {
|
|
|
33
35
|
function createWebmcpNamespace(catalog, sessionId, assertAvailable) {
|
|
34
36
|
return {
|
|
35
37
|
name: "webmcp",
|
|
36
|
-
summary: "Author canvas WebMCP: describe
|
|
38
|
+
summary: "Author canvas WebMCP: open a file as a canvas, describe its catalog, then call one tool with its explicit token. Await same-canvas calls sequentially; structured errors remain data.",
|
|
37
39
|
declarations: DECLARATIONS,
|
|
38
40
|
bind(run) {
|
|
39
41
|
if (run.sessionId !== sessionId) throw new Error("Author WebMCP namespace belongs to another session.");
|
|
@@ -47,6 +49,13 @@ function createWebmcpNamespace(catalog, sessionId, assertAvailable) {
|
|
|
47
49
|
assertAvailable();
|
|
48
50
|
};
|
|
49
51
|
const members = Object.create(null);
|
|
52
|
+
members.open = async (input) => {
|
|
53
|
+
check();
|
|
54
|
+
const { path, alias } = parseOpenAuthoringFileInput(copy(input));
|
|
55
|
+
const result = await catalog.open(path, run.signal, alias);
|
|
56
|
+
check();
|
|
57
|
+
return copy(result);
|
|
58
|
+
};
|
|
50
59
|
members.describe = async (input) => {
|
|
51
60
|
check();
|
|
52
61
|
const { alias } = parseDescribeAuthorToolsInput(copy(input === void 0 ? {} : input));
|
|
@@ -659,14 +668,17 @@ var root_server_default = defineRoot(({ agent, host, signal }) => {
|
|
|
659
668
|
}) : void 0;
|
|
660
669
|
let disposed = false;
|
|
661
670
|
const catalog = createAuthorCatalog(session?.catalog);
|
|
662
|
-
const
|
|
671
|
+
const assertAlive = () => {
|
|
663
672
|
signal.throwIfAborted();
|
|
664
673
|
if (disposed) throw new Error("Author session is disposed.");
|
|
674
|
+
};
|
|
675
|
+
const assertAvailable = () => {
|
|
676
|
+
assertAlive();
|
|
665
677
|
if (!isActive()) throw new Error("Author mode is not active.");
|
|
666
678
|
};
|
|
667
679
|
const mountNamespace = (context) => {
|
|
668
680
|
if (!agent) return;
|
|
669
|
-
const namespace = createWebmcpNamespace(catalog, agent.context.sessionId,
|
|
681
|
+
const namespace = createWebmcpNamespace(catalog, agent.context.sessionId, assertAlive);
|
|
670
682
|
context.inject([PO_CODEMODE_SERVICE], (scoped) => {
|
|
671
683
|
const registration = readPoCodemode(scoped)?.register("@agimon-ai/po-author", namespace);
|
|
672
684
|
return () => registration?.dispose();
|
|
@@ -898,7 +910,7 @@ var before_agent_start_server_default = defineHook({
|
|
|
898
910
|
const skillFile = "src/prompts/codemode-how-to-author/SKILL.md";
|
|
899
911
|
var codemode_how_to_author_server_default = defineResource({
|
|
900
912
|
name: "codemode-how-to-author",
|
|
901
|
-
description: "
|
|
913
|
+
description: "Open a file as a canvas the person sees, then read and change it through the tools that canvas offers. Use to review or edit a document, image or sheet together with the person; works without Author mode.",
|
|
902
914
|
kind: "skill",
|
|
903
915
|
pinned: true,
|
|
904
916
|
path: packageResourcePath(import.meta.url, skillFile),
|