@agimon-ai/doompi-core 0.0.1-alpha.110 → 0.0.1-alpha.111
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/childSession.cjs +1 -0
- package/dist/childSession.d.mts +2 -2
- package/dist/childSession.mjs +2 -2
- package/dist/headless.cjs +2 -0
- package/dist/headless.d.mts +2 -2
- package/dist/headless.mjs +2 -2
- package/dist/headlessSessionHost.d.mts +1 -1
- package/dist/remoteRuntime.d.mts.map +1 -1
- package/dist/sqliteSessionStorage.d.mts.map +1 -1
- package/dist/src/pi/piSessionRuntime.d.mts +1 -1
- package/dist/src/schemas/headless.cjs +14 -0
- package/dist/src/schemas/headless.cjs.map +1 -1
- package/dist/src/schemas/headless.d.mts +8 -0
- package/dist/src/schemas/headless.d.mts.map +1 -1
- package/dist/src/schemas/headless.mjs +13 -1
- package/dist/src/schemas/headless.mjs.map +1 -1
- package/dist/src/schemas/sessionProtocol.d.mts.map +1 -1
- package/dist/src/systems/child/adapters/headlessChildSessionService.cjs +70 -3
- package/dist/src/systems/child/adapters/headlessChildSessionService.cjs.map +1 -1
- package/dist/src/systems/child/adapters/headlessChildSessionService.d.mts +3 -2
- package/dist/src/systems/child/adapters/headlessChildSessionService.d.mts.map +1 -1
- package/dist/src/systems/child/adapters/headlessChildSessionService.mjs +70 -4
- package/dist/src/systems/child/adapters/headlessChildSessionService.mjs.map +1 -1
- package/dist/src/systems/child/types/childSession.cjs +2 -0
- package/dist/src/systems/child/types/childSession.cjs.map +1 -1
- package/dist/src/systems/child/types/childSession.d.mts +19 -0
- package/dist/src/systems/child/types/childSession.d.mts.map +1 -1
- package/dist/src/systems/child/types/childSession.mjs +2 -1
- package/dist/src/systems/child/types/childSession.mjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessHost.cjs +10 -2
- package/dist/src/systems/main/adapters/headlessHost.cjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessHost.d.mts +1 -1
- package/dist/src/systems/main/adapters/headlessHost.d.mts.map +1 -1
- package/dist/src/systems/main/adapters/headlessHost.mjs +11 -3
- package/dist/src/systems/main/adapters/headlessHost.mjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs +21 -13
- package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs +23 -15
- package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
- package/dist/terminalPiChildSessionService.cjs +20 -4
- package/dist/terminalPiChildSessionService.cjs.map +1 -1
- package/dist/terminalPiChildSessionService.d.mts +3 -2
- package/dist/terminalPiChildSessionService.d.mts.map +1 -1
- package/dist/terminalPiChildSessionService.mjs +21 -5
- package/dist/terminalPiChildSessionService.mjs.map +1 -1
- package/package.json +13 -13
package/dist/childSession.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_childSession = require("./src/systems/child/types/childSession.cjs");
|
|
3
3
|
const require_index = require("./src/systems/child/services/childSession/index.cjs");
|
|
4
|
+
exports.DOOM_CHILD_SESSION_HOOKS_SERVICE = require_childSession.DOOM_CHILD_SESSION_HOOKS_SERVICE;
|
|
4
5
|
exports.DOOM_CHILD_SESSION_MCP_TOOL_SERVICE = require_childSession.DOOM_CHILD_SESSION_MCP_TOOL_SERVICE;
|
|
5
6
|
exports.DOOM_CHILD_SESSION_SERVICE = require_childSession.DOOM_CHILD_SESSION_SERVICE;
|
|
6
7
|
exports.createDoomChildSessionService = require_index.createDoomChildSessionService;
|
package/dist/childSession.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, DoomChildSessionCapabilityCeiling, DoomChildSessionEvent, DoomChildSessionFreshSource, DoomChildSessionHandle, DoomChildSessionIntercom, DoomChildSessionMcpCatalog, DoomChildSessionMcpTool, DoomChildSessionRequest, DoomChildSessionRuntime, DoomChildSessionRuntimeFactory, DoomChildSessionScope, DoomChildSessionService, DoomChildSessionServiceProvider, DoomChildSessionSource, DoomChildSessionState, DoomChildSessionTerminalPiForkSource, DoomChildSessionTool, DoomChildSessionToolResult, DoomChildSessionUsage, DoomChildSessionV4ForkSource, DoomChildSessionV4RestoreSource, readDoomChildSessionService, requireDoomChildSessionService } from "./src/systems/child/types/childSession.mjs";
|
|
1
|
+
import { DOOM_CHILD_SESSION_HOOKS_SERVICE, DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, DoomChildSessionCapabilityCeiling, DoomChildSessionEvent, DoomChildSessionFreshSource, DoomChildSessionHandle, DoomChildSessionHookBinding, DoomChildSessionHookScope, DoomChildSessionHooks, DoomChildSessionIntercom, DoomChildSessionMcpCatalog, DoomChildSessionMcpTool, DoomChildSessionRequest, DoomChildSessionRuntime, DoomChildSessionRuntimeFactory, DoomChildSessionScope, DoomChildSessionService, DoomChildSessionServiceProvider, DoomChildSessionSource, DoomChildSessionState, DoomChildSessionTerminalPiForkSource, DoomChildSessionTool, DoomChildSessionToolResult, DoomChildSessionUsage, DoomChildSessionV4ForkSource, DoomChildSessionV4RestoreSource, readDoomChildSessionService, requireDoomChildSessionService } from "./src/systems/child/types/childSession.mjs";
|
|
2
2
|
import { DoomChildSessionServiceDependencies, createDoomChildSessionService } from "./src/systems/child/services/childSession/index.mjs";
|
|
3
|
-
export { DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, DoomChildSessionCapabilityCeiling, DoomChildSessionEvent, DoomChildSessionFreshSource, DoomChildSessionHandle, DoomChildSessionIntercom, DoomChildSessionMcpCatalog, DoomChildSessionMcpTool, DoomChildSessionRequest, DoomChildSessionRuntime, DoomChildSessionRuntimeFactory, DoomChildSessionScope, DoomChildSessionService, DoomChildSessionServiceDependencies, DoomChildSessionServiceProvider, DoomChildSessionSource, DoomChildSessionState, DoomChildSessionTerminalPiForkSource, DoomChildSessionTool, DoomChildSessionToolResult, DoomChildSessionUsage, DoomChildSessionV4ForkSource, DoomChildSessionV4RestoreSource, createDoomChildSessionService, readDoomChildSessionService, requireDoomChildSessionService };
|
|
3
|
+
export { DOOM_CHILD_SESSION_HOOKS_SERVICE, DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, DoomChildSessionCapabilityCeiling, DoomChildSessionEvent, DoomChildSessionFreshSource, DoomChildSessionHandle, DoomChildSessionHookBinding, DoomChildSessionHookScope, DoomChildSessionHooks, DoomChildSessionIntercom, DoomChildSessionMcpCatalog, DoomChildSessionMcpTool, DoomChildSessionRequest, DoomChildSessionRuntime, DoomChildSessionRuntimeFactory, DoomChildSessionScope, DoomChildSessionService, DoomChildSessionServiceDependencies, DoomChildSessionServiceProvider, DoomChildSessionSource, DoomChildSessionState, DoomChildSessionTerminalPiForkSource, DoomChildSessionTool, DoomChildSessionToolResult, DoomChildSessionUsage, DoomChildSessionV4ForkSource, DoomChildSessionV4RestoreSource, createDoomChildSessionService, readDoomChildSessionService, requireDoomChildSessionService };
|
package/dist/childSession.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, readDoomChildSessionService, requireDoomChildSessionService } from "./src/systems/child/types/childSession.mjs";
|
|
1
|
+
import { DOOM_CHILD_SESSION_HOOKS_SERVICE, DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, readDoomChildSessionService, requireDoomChildSessionService } from "./src/systems/child/types/childSession.mjs";
|
|
2
2
|
import { createDoomChildSessionService } from "./src/systems/child/services/childSession/index.mjs";
|
|
3
|
-
export { DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, createDoomChildSessionService, readDoomChildSessionService, requireDoomChildSessionService };
|
|
3
|
+
export { DOOM_CHILD_SESSION_HOOKS_SERVICE, DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, DOOM_CHILD_SESSION_SERVICE, createDoomChildSessionService, readDoomChildSessionService, requireDoomChildSessionService };
|
package/dist/headless.cjs
CHANGED
|
@@ -3,6 +3,8 @@ const require_headless = require("./src/schemas/headless.cjs");
|
|
|
3
3
|
exports.DOOM_HEADLESS_HOST_SERVICE = require_headless.DOOM_HEADLESS_HOST_SERVICE;
|
|
4
4
|
exports.DOOM_HEADLESS_OWNER = require_headless.DOOM_HEADLESS_OWNER;
|
|
5
5
|
exports.DOOM_LOAD_SKILL_TOOL = require_headless.DOOM_LOAD_SKILL_TOOL;
|
|
6
|
+
exports.DoomHeadlessPromptAdmissionError = require_headless.DoomHeadlessPromptAdmissionError;
|
|
7
|
+
exports.isDoomHeadlessPromptAdmissionError = require_headless.isDoomHeadlessPromptAdmissionError;
|
|
6
8
|
exports.readDoomHeadlessHost = require_headless.readDoomHeadlessHost;
|
|
7
9
|
exports.readDoomHeadlessOwner = require_headless.readDoomHeadlessOwner;
|
|
8
10
|
exports.requireDoomHeadlessHost = require_headless.requireDoomHeadlessHost;
|
package/dist/headless.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessActivity, DoomHeadlessCapability, DoomHeadlessCapabilitySnapshot, DoomHeadlessClient, DoomHeadlessClientRequest, DoomHeadlessCommand, DoomHeadlessCompactionResult, DoomHeadlessCondition, DoomHeadlessContent, DoomHeadlessEventName, DoomHeadlessExecutionContext, DoomHeadlessHook, DoomHeadlessHookEvent, DoomHeadlessHookResult, DoomHeadlessHostService, DoomHeadlessModelSettings, DoomHeadlessRegistration, DoomHeadlessResource, DoomHeadlessSelection, DoomHeadlessSelectionChange, DoomHeadlessSession, DoomHeadlessTool, DoomHeadlessToolCompletionRequest, DoomHeadlessToolCompletionResult, DoomHeadlessToolRestriction, DoomHeadlessToolResult, DoomMcpSkillAccess, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult } from "./src/schemas/headless.mjs";
|
|
2
|
-
export { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessActivity, DoomHeadlessCapability, DoomHeadlessCapabilitySnapshot, DoomHeadlessClient, DoomHeadlessClientRequest, DoomHeadlessCommand, DoomHeadlessCompactionResult, DoomHeadlessCondition, DoomHeadlessContent, DoomHeadlessEventName, DoomHeadlessExecutionContext, DoomHeadlessHook, DoomHeadlessHookEvent, DoomHeadlessHookResult, DoomHeadlessHostService, DoomHeadlessModelSettings, DoomHeadlessRegistration, DoomHeadlessResource, DoomHeadlessSelection, DoomHeadlessSelectionChange, DoomHeadlessSession, DoomHeadlessTool, DoomHeadlessToolCompletionRequest, DoomHeadlessToolCompletionResult, DoomHeadlessToolRestriction, DoomHeadlessToolResult, DoomMcpSkillAccess, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult };
|
|
1
|
+
import { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessActivity, DoomHeadlessCapability, DoomHeadlessCapabilitySnapshot, DoomHeadlessClient, DoomHeadlessClientRequest, DoomHeadlessCommand, DoomHeadlessCompactionResult, DoomHeadlessCondition, DoomHeadlessContent, DoomHeadlessEventName, DoomHeadlessExecutionContext, DoomHeadlessHook, DoomHeadlessHookEvent, DoomHeadlessHookResult, DoomHeadlessHostService, DoomHeadlessModelSettings, DoomHeadlessPromptAdmissionError, DoomHeadlessRegistration, DoomHeadlessResource, DoomHeadlessSelection, DoomHeadlessSelectionChange, DoomHeadlessSession, DoomHeadlessTool, DoomHeadlessToolCompletionRequest, DoomHeadlessToolCompletionResult, DoomHeadlessToolRestriction, DoomHeadlessToolResult, DoomMcpSkillAccess, isDoomHeadlessPromptAdmissionError, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult } from "./src/schemas/headless.mjs";
|
|
2
|
+
export { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessActivity, DoomHeadlessCapability, DoomHeadlessCapabilitySnapshot, DoomHeadlessClient, DoomHeadlessClientRequest, DoomHeadlessCommand, DoomHeadlessCompactionResult, DoomHeadlessCondition, DoomHeadlessContent, DoomHeadlessEventName, DoomHeadlessExecutionContext, DoomHeadlessHook, DoomHeadlessHookEvent, DoomHeadlessHookResult, DoomHeadlessHostService, DoomHeadlessModelSettings, DoomHeadlessPromptAdmissionError, DoomHeadlessRegistration, DoomHeadlessResource, DoomHeadlessSelection, DoomHeadlessSelectionChange, DoomHeadlessSession, DoomHeadlessTool, DoomHeadlessToolCompletionRequest, DoomHeadlessToolCompletionResult, DoomHeadlessToolRestriction, DoomHeadlessToolResult, DoomMcpSkillAccess, isDoomHeadlessPromptAdmissionError, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult };
|
package/dist/headless.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult } from "./src/schemas/headless.mjs";
|
|
2
|
-
export { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult };
|
|
1
|
+
import { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessPromptAdmissionError, isDoomHeadlessPromptAdmissionError, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult } from "./src/schemas/headless.mjs";
|
|
2
|
+
export { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessPromptAdmissionError, isDoomHeadlessPromptAdmissionError, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DirectHarnessRuntime } from "./src/types/server/directHarnessRuntime.mjs";
|
|
1
2
|
import { ContextProjectionInput } from "./contextProjection.mjs";
|
|
2
3
|
import { DoomSessionContext } from "./src/schemas/hubChannel.mjs";
|
|
3
4
|
import { DoomWebComposition } from "./src/schemas/packageApi.mjs";
|
|
@@ -12,7 +13,6 @@ import { HeadlessHost } from "./src/systems/main/adapters/headlessHost.mjs";
|
|
|
12
13
|
import { LoadedMcpPlugin } from "./src/server/mcpBundleLoader.mjs";
|
|
13
14
|
import "./mcpFacet.mjs";
|
|
14
15
|
import "./packageApi.mjs";
|
|
15
|
-
import { DirectHarnessRuntime } from "./src/types/server/directHarnessRuntime.mjs";
|
|
16
16
|
import { SessionToolSurface } from "./src/types/server/sessionToolSurface.mjs";
|
|
17
17
|
import { Context } from "@deepseek-ai/cordis";
|
|
18
18
|
//#region src/systems/main/types/headlessSessionHost.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteRuntime.d.mts","names":[],"sources":["../src/server/remoteRuntime.ts"],"mappings":";;;;iBA4GiB;EACf;EACA;EACA;IAAiB;IAAmB;;EACpC,SAAS;;EAET,QAAQ,SAAS,UAAU,QAAQ;EACnC,gBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"remoteRuntime.d.mts","names":["WebSocket"],"sources":["../src/server/remoteRuntime.ts"],"mappings":";;;;iBA4GiB;EACf;EACA;EACA;IAAiB;IAAmB;;EACpC,SAAS;;EAET,QAAQ,SAAS,UAAU,QAAQ;EACnC,gBAAgB,kBAAkB,oBAAoBA;EACtD,mBAAmB;EACnB,eAAe;;EAEf;;iBAGe;WACN,QAAQ;EACjB,WAAW,SAAS,UAAU,QAAQ;EACtC,SAAS;;;wBAyBK,oBAAoB,SAAS,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqliteSessionStorage.d.mts","names":[],"sources":["../src/services/sqliteSessionStorage/index.ts"],"mappings":";;;;;qBAaa,4BAA0B;qBAE1B;;qBAEA,yDAAkB;;;;;qBAMlB,yDAAkB;;;;;;;wBAQf,2BAA2B;;wBA0BrB,2BAA2B,eAAe,QAAQ;;wBA4ClD,yBACpB,SAAS,KACP,qHAGF,SAAS,UAAO;;;;;IAwC6B,QAAA,eAAA,YAAO;;
|
|
1
|
+
{"version":3,"file":"sqliteSessionStorage.d.mts","names":["_$___historyImport0.HistoryOwnershipLease"],"sources":["../src/services/sqliteSessionStorage/index.ts"],"mappings":";;;;;qBAaa,4BAA0B;qBAE1B;;qBAEA,yDAAkB;;;;;qBAMlB,yDAAkB;;;;;;;wBAQf,2BAA2B;;wBA0BrB,2BAA2B,eAAe,QAAQ;;wBA4ClD,yBACpB,SAAS,KACP,qHAGF,SAAS,UAAO;;;;;IAwC6B,QAAA,eAAA,YAAO;;gBAAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SessionService, SessionServiceState, SessionSnapshot, TranscriptPage, TranscriptPageRequest } from "../schemas/sessionProtocol.mjs";
|
|
2
|
-
import "../../sessionProtocol.mjs";
|
|
3
2
|
import { DirectHarnessFrame, DirectHarnessRuntime } from "../types/server/directHarnessRuntime.mjs";
|
|
3
|
+
import "../../sessionProtocol.mjs";
|
|
4
4
|
import { ServerTelemetry } from "../../serverTelemetry.mjs";
|
|
5
5
|
import { RpcTranscript } from "../services/rpcTranscript/index.mjs";
|
|
6
6
|
import { Context, MutableReplicatedState } from "@earendil-works/chord";
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */
|
|
3
3
|
const DOOM_HEADLESS_HOST_SERVICE = "doom/headless-host";
|
|
4
4
|
const DOOM_HEADLESS_OWNER = Symbol.for("doom/headless-owner");
|
|
5
|
+
const PROMPT_ADMISSION_ERROR = "DoomHeadlessPromptAdmissionError";
|
|
6
|
+
/** Admission is a host boundary, not an advisory facet-hook failure. */
|
|
7
|
+
var DoomHeadlessPromptAdmissionError = class extends Error {
|
|
8
|
+
constructor(cause) {
|
|
9
|
+
super(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
10
|
+
this.name = PROMPT_ADMISSION_ERROR;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/** Error identity must survive independently bundled server and extension graphs. */
|
|
14
|
+
function isDoomHeadlessPromptAdmissionError(error) {
|
|
15
|
+
return error instanceof Error && error.name === PROMPT_ADMISSION_ERROR;
|
|
16
|
+
}
|
|
5
17
|
function readDoomHeadlessOwner(context) {
|
|
6
18
|
return context[DOOM_HEADLESS_OWNER];
|
|
7
19
|
}
|
|
@@ -36,6 +48,8 @@ function requireDoomHeadlessHost(context) {
|
|
|
36
48
|
exports.DOOM_HEADLESS_HOST_SERVICE = DOOM_HEADLESS_HOST_SERVICE;
|
|
37
49
|
exports.DOOM_HEADLESS_OWNER = DOOM_HEADLESS_OWNER;
|
|
38
50
|
exports.DOOM_LOAD_SKILL_TOOL = DOOM_LOAD_SKILL_TOOL;
|
|
51
|
+
exports.DoomHeadlessPromptAdmissionError = DoomHeadlessPromptAdmissionError;
|
|
52
|
+
exports.isDoomHeadlessPromptAdmissionError = isDoomHeadlessPromptAdmissionError;
|
|
39
53
|
exports.readDoomHeadlessHost = readDoomHeadlessHost;
|
|
40
54
|
exports.readDoomHeadlessOwner = readDoomHeadlessOwner;
|
|
41
55
|
exports.requireDoomHeadlessHost = requireDoomHeadlessHost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.cjs","names":[],"sources":["../../../src/schemas/headless.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { ThinkingLevel } from '@earendil-works/pi-agent-core';\nimport type { CallToolResult, Tool } from '@modelcontextprotocol/server';\nimport type { Static, TSchema } from 'typebox';\n\nimport type { DoomSessionContext } from './hubChannel';\nimport type { DoomNotificationRequest } from './notification';\nimport type { DoomServerBundleEntry } from './serverBundle';\n\n/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */\nexport const DOOM_HEADLESS_HOST_SERVICE = 'doom/headless-host';\nexport const DOOM_HEADLESS_OWNER = Symbol.for('doom/headless-owner');\n\nexport interface DoomHeadlessSelection {\n readonly majorMode: string;\n readonly activeLayers: readonly string[];\n readonly domains: readonly string[];\n readonly profile?: string;\n /** Feature-owned activation sets, keyed by the contributing capability. */\n readonly state?: Readonly<Record<string, readonly string[]>>;\n}\n\n/** One package-owned selection transition. Server facets change exactly one axis per operation. */\nexport type DoomHeadlessSelectionChange =\n | { readonly axis: 'majorMode'; readonly majorMode: string }\n | { readonly axis: 'domains'; readonly domains: readonly string[] }\n | { readonly axis: 'profile'; readonly profile?: string }\n | { readonly axis: 'state'; readonly key: string; readonly values: readonly string[] };\n\nexport function readDoomHeadlessOwner(context: Context): DoomServerBundleEntry | undefined {\n return (context as Context & { [DOOM_HEADLESS_OWNER]?: DoomServerBundleEntry })[DOOM_HEADLESS_OWNER];\n}\n\nexport interface DoomHeadlessRegistration {\n dispose(): void;\n}\n\nexport type DoomHeadlessContent = { type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string };\n\nexport interface DoomHeadlessToolResult {\n content: DoomHeadlessContent[];\n /** Public MCP result data. Internal renderer details are not a remote result contract. */\n structuredContent?: Record<string, unknown>;\n /** Component-only MCP metadata, never inferred from internal renderer details. */\n _meta?: CallToolResult['_meta'];\n details?: unknown;\n isError?: boolean;\n}\n\n/**\n * Narrows a Pi tool result to the headless contract. Pi types `structuredContent` as any JSON\n * value, while MCP only accepts an object, so anything else is dropped rather than forwarded.\n */\nexport function toDoomHeadlessToolResult(result: {\n readonly content: DoomHeadlessContent[];\n readonly details?: unknown;\n readonly structuredContent?: unknown;\n readonly isError?: boolean;\n}): DoomHeadlessToolResult {\n const { structuredContent } = result;\n return {\n content: result.content,\n details: result.details,\n ...(typeof structuredContent === 'object' && structuredContent !== null && !Array.isArray(structuredContent)\n ? { structuredContent: structuredContent as Record<string, unknown> }\n : {}),\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n}\n\nexport interface DoomHeadlessClientRequest {\n kind: 'confirm' | 'select' | 'input';\n title: string;\n message?: string;\n options?: readonly { label: string; description?: string; value: string }[];\n initialValue?: string;\n multiline?: boolean;\n}\n\nexport interface DoomHeadlessClient {\n /**\n * Operator-facing surface only: the body is flattened to one line and capped at 4096 characters\n * by schemas/notification.ts:73-83, and the model never sees it. Use session.admitPrompt to\n * reach the model.\n */\n notify(request: DoomNotificationRequest): void | Promise<void>;\n request(request: DoomHeadlessClientRequest, signal?: AbortSignal): Promise<unknown>;\n setStatus(source: string, text: string | undefined): void;\n appendComposerText?(text: string): void;\n}\n\nexport interface DoomHeadlessModelSettings {\n model?: { provider: string; id: string };\n thinkingLevel: ThinkingLevel;\n}\n\nexport interface DoomHeadlessSession {\n readModelSettings?(): Promise<DoomHeadlessModelSettings>;\n setFastMode?(enabled: boolean): Promise<void>;\n setModelSettings?(settings: Partial<DoomHeadlessModelSettings>): Promise<void>;\n /** Query durable history on demand; hosts do not retain the entire transcript. */\n entries(query?: {\n type?: 'custom' | 'message';\n customType?: string;\n limit?: number;\n }): readonly Record<string, unknown>[] | Promise<readonly Record<string, unknown>[]>;\n appendCustomEntry(type: string, data: unknown): Promise<void>;\n /**\n * Delivers operator input through prompt preflight and awaits its turn.\n * Environmental input uses admitPrompt with origin omitted instead.\n * An idle agent is woken; busy delivery uses Durable steering or follow-up.\n */\n prompt(text: string, delivery?: 'prompt' | 'steer' | 'followUp'): Promise<void>;\n /**\n * Admits input without awaiting its turn. Environmental input omits origin and never\n * changes the operator queue. Operator origin uses prompt preflight, including voice\n * capture; 'interrupt' cancels the active run and admits operator input while preserving\n * retained queued work.\n */\n admitPrompt?(\n text: string,\n delivery?: 'prompt' | 'steer' | 'followUp' | 'interrupt',\n origin?: 'operator',\n ): Promise<void>;\n abort(): Promise<void>;\n compact(instructions?: string): Promise<void>;\n activity(): Promise<{ hasPendingMessages: boolean; isIdle: boolean }>;\n /** Renames the durable session and publishes the updated title to presentation clients. */\n setName?(name: string): Promise<void>;\n /** Capture the current persisted branch for an in-process child fork. */\n forkSource?(): Promise<{ kind: 'v4-fork'; sessionFile: string; branch: string; entryId?: string }>;\n}\n\n/** A grant-filtered skill view available only during one remote MCP tool invocation. */\nexport interface DoomMcpSkillAccess {\n list(): Promise<readonly { name: string; description: string }[]>;\n read(name: string): Promise<string>;\n}\n\n/** A stateless auxiliary request. These tools are private to this request, never registered on the agent. */\nexport interface DoomHeadlessToolCompletionRequest {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n tools: readonly Pick<DoomHeadlessTool, 'name' | 'description' | 'parameters'>[];\n}\n\nexport interface DoomHeadlessToolCompletionResult {\n toolCalls: readonly { id: string; name: string; arguments: unknown }[];\n usage: { totalTokens: number };\n}\n\nexport interface DoomHeadlessExecutionContext {\n readonly cwd: string;\n /** The checkout the session runs in, distinct from the tool execution directory. */\n readonly repoRoot: string;\n readonly sessionId: string;\n /** The session's baseline context, when its host knows its workspace. */\n readonly sessionContext?: DoomSessionContext;\n /** Immutable session configuration. Facets must not read or mutate process.env. */\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly client: DoomHeadlessClient;\n readonly session: DoomHeadlessSession;\n readonly model?: { provider: string; id: string };\n readonly textCompletion?: {\n available(reference: string): boolean;\n complete(\n reference: string,\n request: {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n },\n ): Promise<string>;\n };\n readonly toolCompletion?: {\n complete(reference: string, request: DoomHeadlessToolCompletionRequest): Promise<DoomHeadlessToolCompletionResult>;\n };\n readonly selection: DoomHeadlessSelection;\n /** Present only while an authenticated remote MCP tool is running. */\n readonly mcpSkills?: DoomMcpSkillAccess;\n shutdown(): void;\n}\n\n/** Conditions narrow an eligible owner's contributions; they can never restore a disabled owner. */\nexport interface DoomHeadlessCondition {\n state?: Readonly<Record<string, string>>;\n attribution?: { kind: 'minor' | 'domain'; mode: string; label?: string };\n domain?: string;\n}\n\nexport interface DoomHeadlessToolRestriction {\n when?: DoomHeadlessCondition;\n /** Optional capability ceiling. An empty list disables every tool. */\n allowedTools?: readonly string[];\n /**\n * Narrow exclusions without disabling unrelated tools. Exclude a tool your package owns, or a\n * specific foreign tool the mode exists to withdraw. Never enumerate an allowlist here.\n */\n excludedTools?: readonly string[];\n}\n\nexport interface DoomHeadlessTool<TParameters extends TSchema = TSchema> {\n when?: DoomHeadlessCondition;\n name: string;\n label?: string;\n description: string;\n parameters: TParameters;\n annotations?: Tool['annotations'];\n outputSchema?: Tool['outputSchema'];\n /** Remote presentation only. Component tool access must be explicitly opted into. */\n _meta?: Tool['_meta'] & {\n ui?: {\n resourceUri?: string;\n visibility?: ('model' | 'app')[];\n };\n };\n promptSnippet?: string;\n promptGuidelines?: readonly string[];\n executionMode?: 'parallel' | 'serial';\n execute(\n toolCallId: string,\n parameters: Static<TParameters>,\n signal: AbortSignal | undefined,\n onUpdate: ((result: DoomHeadlessToolResult) => void) | undefined,\n context: DoomHeadlessExecutionContext,\n ): Promise<DoomHeadlessToolResult>;\n}\n\n/**\n * One package contribution to the session's resource surface.\n *\n * `kind` decides what the model is billed for, and the difference is large:\n * - `context` is EAGER. `read()` runs on every prompt build and the text is pasted\n * into the system prompt verbatim. Reserve it for small live session state that\n * exists nowhere on disk. Never use it for a file the package ships: a README\n * registered this way costs its full length on every single turn.\n * - `skill` is LAZY. Only `name`, `description` and `path` reach the prompt; the\n * agent reads the file itself when the description matches the task.\n * - `prompt` is inert until the user invokes it by name.\n *\n * The rule in one line: if it is a file the package ships, it is a `skill`.\n */\nexport interface DoomHeadlessResource {\n when?: DoomHeadlessCondition;\n name: string;\n /** Model-visible selection signal. A `skill` without one tells the agent nothing. */\n description?: string;\n /** Absolute path of the file `read()` returns, so an advertised skill is one the agent can open. */\n path?: string;\n kind: 'prompt' | 'skill' | 'context';\n read(context: DoomHeadlessExecutionContext): string | Promise<string>;\n}\n\nexport interface DoomHeadlessCommand {\n when?: DoomHeadlessCondition;\n name: string;\n description: string;\n execute(args: string, context: DoomHeadlessExecutionContext): void | Promise<void>;\n}\n\nexport type DoomHeadlessEventName =\n | 'session_start'\n | 'session_shutdown'\n | 'session_tree'\n | 'before_agent_start'\n | 'agent_start'\n | 'agent_settled'\n | 'turn_start'\n | 'turn_end'\n | 'context'\n | 'before_provider_request'\n | 'message_start'\n | 'message_update'\n | 'message_end'\n | 'tool_call'\n | 'tool_execution_start'\n | 'tool_execution_update'\n | 'tool_execution_end'\n | 'tool_result'\n | 'model_select'\n | 'session_before_compact'\n | 'session_compact';\n\nexport type DoomHeadlessHookEvent<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { lane: string; runId: string; model: { provider: string; id: string }; payload: unknown }\n : E extends 'session_before_compact'\n ? { reason: string; preparation: unknown; instructions?: string; customInstructions?: string }\n : E extends 'model_select'\n ? { model: { provider: string; id: string } }\n : Readonly<Record<string, unknown>>;\n\nexport interface DoomHeadlessCompactionResult {\n summary: string;\n tokensBefore: number;\n retainedTail: Record<string, unknown>[];\n usage?: Record<string, unknown>;\n details?: unknown;\n}\n\nexport type DoomHeadlessHookResult<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { payload: unknown } | void\n : E extends 'session_before_compact'\n ? { cancel?: boolean; decline?: boolean; compaction?: DoomHeadlessCompactionResult } | void\n : E extends 'context'\n ? { messages?: unknown[]; systemPrompt?: string } | void\n : E extends 'before_agent_start'\n ? { systemPrompt?: string } | void\n : E extends 'tool_call'\n ? { args?: Record<string, unknown>; block?: { reason: string; terminate?: boolean } } | void\n : E extends 'tool_result'\n ? {\n content?: DoomHeadlessContent[];\n details?: unknown;\n isError?: boolean;\n usage?: Record<string, unknown>;\n terminate?: boolean;\n } | void\n : unknown;\n\nexport type DoomHeadlessHook<E extends DoomHeadlessEventName = DoomHeadlessEventName> = E extends DoomHeadlessEventName\n ? {\n when?: DoomHeadlessCondition;\n event: E;\n handle(\n event: Readonly<DoomHeadlessHookEvent<E>>,\n context: DoomHeadlessExecutionContext,\n ): DoomHeadlessHookResult<E> | Promise<DoomHeadlessHookResult<E>>;\n }\n : never;\n\n/** A retained facet can register activity without starting disabled watchers or services. */\nexport interface DoomHeadlessActivity {\n when?: DoomHeadlessCondition;\n name: string;\n start(context: DoomHeadlessExecutionContext): (() => void | Promise<void>) | Promise<() => void | Promise<void>>;\n}\n\n/** Read-only metadata for the currently applied session, never executable declarations or resource bodies. */\nexport interface DoomHeadlessCapability {\n readonly source: string;\n readonly name: string;\n readonly kind: 'tool' | 'skill';\n readonly when?: DoomHeadlessCondition;\n readonly active: boolean;\n readonly discoverable: boolean;\n readonly reason?: 'inactive' | 'restricted' | 'shadowed' | 'unavailable' | 'not-discoverable';\n}\n\nexport interface DoomHeadlessCapabilitySnapshot {\n readonly revision: number;\n readonly ready: boolean;\n readonly capabilities: readonly DoomHeadlessCapability[];\n}\n\n/** Registrations inherit package ownership from the caller's Cordis facet. */\n/**\n * The tool a server session loads skills through. When a session carries it, the prompt lists\n * every skill by name and points here, so a skill needs no file the agent could read.\n */\nexport const DOOM_LOAD_SKILL_TOOL = 'load_skill';\n\nexport interface DoomHeadlessHostService {\n readonly context: DoomHeadlessExecutionContext;\n /** The instructions of an applied skill by exact name, or undefined when none is applied. */\n readSkill(name: string): string | undefined;\n changeSelection(change: DoomHeadlessSelectionChange): Promise<void>;\n assertActive(source?: string): void;\n subscribeSelection(listener: (selection: DoomHeadlessSelection) => void | Promise<void>): () => void;\n /** Inspect only a coherently applied generation. A transition returns ready=false and no partial inventory. */\n inspectCapabilities(): DoomHeadlessCapabilitySnapshot;\n registerToolRestriction(restriction: DoomHeadlessToolRestriction): DoomHeadlessRegistration;\n registerTool<TParameters extends TSchema>(tool: DoomHeadlessTool<TParameters>): DoomHeadlessRegistration;\n registerResource(resource: DoomHeadlessResource): DoomHeadlessRegistration;\n registerCommand(command: DoomHeadlessCommand): DoomHeadlessRegistration;\n registerHook(hook: DoomHeadlessHook): DoomHeadlessRegistration;\n registerActivity(activity: DoomHeadlessActivity): DoomHeadlessRegistration;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'doom/headless-host': DoomHeadlessHostService;\n }\n}\n\nexport function readDoomHeadlessHost(context: Context): DoomHeadlessHostService | undefined {\n return context.get(DOOM_HEADLESS_HOST_SERVICE) as DoomHeadlessHostService | undefined;\n}\n\nexport function requireDoomHeadlessHost(context: Context): DoomHeadlessHostService {\n const host = readDoomHeadlessHost(context);\n if (!host) throw new Error('This contribution requires the Doom headless session host.');\n return host;\n}\n"],"mappings":";;AAUA,MAAa,6BAA6B;AAC1C,MAAa,sBAAsB,OAAO,IAAI,qBAAqB;AAkBnE,SAAgB,sBAAsB,SAAqD;CACzF,OAAQ,QAAwE;AAClF;;;;;AAsBA,SAAgB,yBAAyB,QAKd;CACzB,MAAM,EAAE,sBAAsB;CAC9B,OAAO;EACL,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,GAAI,OAAO,sBAAsB,YAAY,sBAAsB,QAAQ,CAAC,MAAM,QAAQ,iBAAiB,IACvG,EAAqB,kBAA6C,IAClE,CAAC;EACL,GAAI,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,OAAO,QAAQ;CACpE;AACF;;;;;;AAwSA,MAAa,uBAAuB;AAyBpC,SAAgB,qBAAqB,SAAuD;CAC1F,OAAO,QAAQ,IAAI,0BAA0B;AAC/C;AAEA,SAAgB,wBAAwB,SAA2C;CACjF,MAAM,OAAO,qBAAqB,OAAO;CACzC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,4DAA4D;CACvF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"headless.cjs","names":[],"sources":["../../../src/schemas/headless.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { ThinkingLevel } from '@earendil-works/pi-agent-core';\nimport type { CallToolResult, Tool } from '@modelcontextprotocol/server';\nimport type { Static, TSchema } from 'typebox';\n\nimport type { DoomSessionContext } from './hubChannel';\nimport type { DoomNotificationRequest } from './notification';\nimport type { DoomServerBundleEntry } from './serverBundle';\n\n/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */\nexport const DOOM_HEADLESS_HOST_SERVICE = 'doom/headless-host';\nexport const DOOM_HEADLESS_OWNER = Symbol.for('doom/headless-owner');\n\nconst PROMPT_ADMISSION_ERROR = 'DoomHeadlessPromptAdmissionError';\n\n/** Admission is a host boundary, not an advisory facet-hook failure. */\nexport class DoomHeadlessPromptAdmissionError extends Error {\n constructor(cause: unknown) {\n super(cause instanceof Error ? cause.message : String(cause), { cause });\n this.name = PROMPT_ADMISSION_ERROR;\n }\n}\n\n/** Error identity must survive independently bundled server and extension graphs. */\nexport function isDoomHeadlessPromptAdmissionError(error: unknown): boolean {\n return error instanceof Error && error.name === PROMPT_ADMISSION_ERROR;\n}\nexport interface DoomHeadlessSelection {\n readonly majorMode: string;\n readonly activeLayers: readonly string[];\n readonly domains: readonly string[];\n readonly profile?: string;\n /** Feature-owned activation sets, keyed by the contributing capability. */\n readonly state?: Readonly<Record<string, readonly string[]>>;\n}\n\n/** One package-owned selection transition. Server facets change exactly one axis per operation. */\nexport type DoomHeadlessSelectionChange =\n | { readonly axis: 'majorMode'; readonly majorMode: string }\n | { readonly axis: 'domains'; readonly domains: readonly string[] }\n | { readonly axis: 'profile'; readonly profile?: string }\n | { readonly axis: 'state'; readonly key: string; readonly values: readonly string[] };\n\nexport function readDoomHeadlessOwner(context: Context): DoomServerBundleEntry | undefined {\n return (context as Context & { [DOOM_HEADLESS_OWNER]?: DoomServerBundleEntry })[DOOM_HEADLESS_OWNER];\n}\n\nexport interface DoomHeadlessRegistration {\n dispose(): void;\n}\n\nexport type DoomHeadlessContent = { type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string };\n\nexport interface DoomHeadlessToolResult {\n content: DoomHeadlessContent[];\n /** Public MCP result data. Internal renderer details are not a remote result contract. */\n structuredContent?: Record<string, unknown>;\n /** Component-only MCP metadata, never inferred from internal renderer details. */\n _meta?: CallToolResult['_meta'];\n details?: unknown;\n isError?: boolean;\n}\n\n/**\n * Narrows a Pi tool result to the headless contract. Pi types `structuredContent` as any JSON\n * value, while MCP only accepts an object, so anything else is dropped rather than forwarded.\n */\nexport function toDoomHeadlessToolResult(result: {\n readonly content: DoomHeadlessContent[];\n readonly details?: unknown;\n readonly structuredContent?: unknown;\n readonly isError?: boolean;\n}): DoomHeadlessToolResult {\n const { structuredContent } = result;\n return {\n content: result.content,\n details: result.details,\n ...(typeof structuredContent === 'object' && structuredContent !== null && !Array.isArray(structuredContent)\n ? { structuredContent: structuredContent as Record<string, unknown> }\n : {}),\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n}\n\nexport interface DoomHeadlessClientRequest {\n kind: 'confirm' | 'select' | 'input';\n title: string;\n message?: string;\n options?: readonly { label: string; description?: string; value: string }[];\n initialValue?: string;\n multiline?: boolean;\n}\n\nexport interface DoomHeadlessClient {\n /**\n * Operator-facing surface only: the body is flattened to one line and capped at 4096 characters\n * by schemas/notification.ts:73-83, and the model never sees it. Use session.admitPrompt to\n * reach the model.\n */\n notify(request: DoomNotificationRequest): void | Promise<void>;\n request(request: DoomHeadlessClientRequest, signal?: AbortSignal): Promise<unknown>;\n setStatus(source: string, text: string | undefined): void;\n appendComposerText?(text: string): void;\n}\n\nexport interface DoomHeadlessModelSettings {\n model?: { provider: string; id: string };\n thinkingLevel: ThinkingLevel;\n}\n\nexport interface DoomHeadlessSession {\n readModelSettings?(): Promise<DoomHeadlessModelSettings>;\n setFastMode?(enabled: boolean): Promise<void>;\n setModelSettings?(settings: Partial<DoomHeadlessModelSettings>): Promise<void>;\n /** Query durable history on demand; hosts do not retain the entire transcript. */\n entries(query?: {\n type?: 'custom' | 'message';\n customType?: string;\n limit?: number;\n }): readonly Record<string, unknown>[] | Promise<readonly Record<string, unknown>[]>;\n appendCustomEntry(type: string, data: unknown): Promise<void>;\n /**\n * Delivers operator input through prompt preflight and awaits its turn.\n * Environmental input uses admitPrompt with origin omitted instead.\n * An idle agent is woken; busy delivery uses Durable steering or follow-up.\n */\n prompt(text: string, delivery?: 'prompt' | 'steer' | 'followUp'): Promise<void>;\n /**\n * Admits input without awaiting its turn. Environmental input omits origin and never\n * changes the operator queue. Operator origin uses prompt preflight, including voice\n * capture; 'interrupt' cancels the active run and admits operator input while preserving\n * retained queued work.\n */\n admitPrompt?(\n text: string,\n delivery?: 'prompt' | 'steer' | 'followUp' | 'interrupt',\n origin?: 'operator',\n ): Promise<void>;\n abort(): Promise<void>;\n compact(instructions?: string): Promise<void>;\n activity(): Promise<{ hasPendingMessages: boolean; isIdle: boolean }>;\n /** Renames the durable session and publishes the updated title to presentation clients. */\n setName?(name: string): Promise<void>;\n /** Capture the current persisted branch for an in-process child fork. */\n forkSource?(): Promise<{ kind: 'v4-fork'; sessionFile: string; branch: string; entryId?: string }>;\n}\n\n/** A grant-filtered skill view available only during one remote MCP tool invocation. */\nexport interface DoomMcpSkillAccess {\n list(): Promise<readonly { name: string; description: string }[]>;\n read(name: string): Promise<string>;\n}\n\n/** A stateless auxiliary request. These tools are private to this request, never registered on the agent. */\nexport interface DoomHeadlessToolCompletionRequest {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n tools: readonly Pick<DoomHeadlessTool, 'name' | 'description' | 'parameters'>[];\n}\n\nexport interface DoomHeadlessToolCompletionResult {\n toolCalls: readonly { id: string; name: string; arguments: unknown }[];\n usage: { totalTokens: number };\n}\n\nexport interface DoomHeadlessExecutionContext {\n readonly cwd: string;\n /** The checkout the session runs in, distinct from the tool execution directory. */\n readonly repoRoot: string;\n readonly sessionId: string;\n /** The session's baseline context, when its host knows its workspace. */\n readonly sessionContext?: DoomSessionContext;\n /** Immutable session configuration. Facets must not read or mutate process.env. */\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly client: DoomHeadlessClient;\n readonly session: DoomHeadlessSession;\n readonly model?: { provider: string; id: string };\n /** Operation cancellation, supplied only for an active invocation. */\n readonly signal?: AbortSignal;\n readonly textCompletion?: {\n available(reference: string): boolean;\n complete(\n reference: string,\n request: {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n },\n ): Promise<string>;\n };\n readonly toolCompletion?: {\n complete(reference: string, request: DoomHeadlessToolCompletionRequest): Promise<DoomHeadlessToolCompletionResult>;\n };\n readonly selection: DoomHeadlessSelection;\n /** Present only while an authenticated remote MCP tool is running. */\n readonly mcpSkills?: DoomMcpSkillAccess;\n shutdown(): void;\n}\n\n/** Conditions narrow an eligible owner's contributions; they can never restore a disabled owner. */\nexport interface DoomHeadlessCondition {\n state?: Readonly<Record<string, string>>;\n attribution?: { kind: 'minor' | 'domain'; mode: string; label?: string };\n domain?: string;\n}\n\nexport interface DoomHeadlessToolRestriction {\n when?: DoomHeadlessCondition;\n /** Optional capability ceiling. An empty list disables every tool. */\n allowedTools?: readonly string[];\n /**\n * Narrow exclusions without disabling unrelated tools. Exclude a tool your package owns, or a\n * specific foreign tool the mode exists to withdraw. Never enumerate an allowlist here.\n */\n excludedTools?: readonly string[];\n}\n\nexport interface DoomHeadlessTool<TParameters extends TSchema = TSchema> {\n when?: DoomHeadlessCondition;\n name: string;\n label?: string;\n description: string;\n parameters: TParameters;\n annotations?: Tool['annotations'];\n outputSchema?: Tool['outputSchema'];\n /** Remote presentation only. Component tool access must be explicitly opted into. */\n _meta?: Tool['_meta'] & {\n ui?: {\n resourceUri?: string;\n visibility?: ('model' | 'app')[];\n };\n };\n promptSnippet?: string;\n promptGuidelines?: readonly string[];\n executionMode?: 'parallel' | 'serial';\n execute(\n toolCallId: string,\n parameters: Static<TParameters>,\n signal: AbortSignal | undefined,\n onUpdate: ((result: DoomHeadlessToolResult) => void) | undefined,\n context: DoomHeadlessExecutionContext,\n ): Promise<DoomHeadlessToolResult>;\n}\n\n/**\n * One package contribution to the session's resource surface.\n *\n * `kind` decides what the model is billed for, and the difference is large:\n * - `context` is EAGER. `read()` runs on every prompt build and the text is pasted\n * into the system prompt verbatim. Reserve it for small live session state that\n * exists nowhere on disk. Never use it for a file the package ships: a README\n * registered this way costs its full length on every single turn.\n * - `skill` is LAZY. Only `name`, `description` and `path` reach the prompt; the\n * agent reads the file itself when the description matches the task.\n * - `prompt` is inert until the user invokes it by name.\n *\n * The rule in one line: if it is a file the package ships, it is a `skill`.\n */\nexport interface DoomHeadlessResource {\n when?: DoomHeadlessCondition;\n name: string;\n /** Model-visible selection signal. A `skill` without one tells the agent nothing. */\n description?: string;\n /** Absolute path of the file `read()` returns, so an advertised skill is one the agent can open. */\n path?: string;\n kind: 'prompt' | 'skill' | 'context';\n read(context: DoomHeadlessExecutionContext): string | Promise<string>;\n}\n\nexport interface DoomHeadlessCommand {\n when?: DoomHeadlessCondition;\n name: string;\n description: string;\n execute(args: string, context: DoomHeadlessExecutionContext): void | Promise<void>;\n}\n\nexport type DoomHeadlessEventName =\n | 'session_start'\n | 'session_shutdown'\n | 'session_tree'\n | 'before_agent_start'\n | 'agent_start'\n | 'agent_settled'\n | 'turn_start'\n | 'turn_end'\n | 'context'\n | 'before_provider_request'\n | 'message_start'\n | 'message_update'\n | 'message_end'\n | 'tool_call'\n | 'tool_execution_start'\n | 'tool_execution_update'\n | 'tool_execution_end'\n | 'tool_result'\n | 'model_select'\n | 'session_before_compact'\n | 'session_compact';\n\nexport type DoomHeadlessHookEvent<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { lane: string; runId: string; model: { provider: string; id: string }; payload: unknown }\n : E extends 'session_before_compact'\n ? { reason: string; preparation: unknown; instructions?: string; customInstructions?: string }\n : E extends 'model_select'\n ? { model: { provider: string; id: string } }\n : Readonly<Record<string, unknown>>;\n\nexport interface DoomHeadlessCompactionResult {\n summary: string;\n tokensBefore: number;\n retainedTail: Record<string, unknown>[];\n usage?: Record<string, unknown>;\n details?: unknown;\n}\n\nexport type DoomHeadlessHookResult<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { payload: unknown } | void\n : E extends 'session_before_compact'\n ? { cancel?: boolean; decline?: boolean; compaction?: DoomHeadlessCompactionResult } | void\n : E extends 'context'\n ? { messages?: unknown[]; systemPrompt?: string } | void\n : E extends 'before_agent_start'\n ? { systemPrompt?: string } | void\n : E extends 'tool_call'\n ? { args?: Record<string, unknown>; block?: { reason: string; terminate?: boolean } } | void\n : E extends 'tool_result'\n ? {\n content?: DoomHeadlessContent[];\n details?: unknown;\n isError?: boolean;\n usage?: Record<string, unknown>;\n terminate?: boolean;\n } | void\n : unknown;\n\nexport type DoomHeadlessHook<E extends DoomHeadlessEventName = DoomHeadlessEventName> = E extends DoomHeadlessEventName\n ? {\n when?: DoomHeadlessCondition;\n event: E;\n handle(\n event: Readonly<DoomHeadlessHookEvent<E>>,\n context: DoomHeadlessExecutionContext,\n ): DoomHeadlessHookResult<E> | Promise<DoomHeadlessHookResult<E>>;\n }\n : never;\n\n/** A retained facet can register activity without starting disabled watchers or services. */\nexport interface DoomHeadlessActivity {\n when?: DoomHeadlessCondition;\n name: string;\n start(context: DoomHeadlessExecutionContext): (() => void | Promise<void>) | Promise<() => void | Promise<void>>;\n}\n\n/** Read-only metadata for the currently applied session, never executable declarations or resource bodies. */\nexport interface DoomHeadlessCapability {\n readonly source: string;\n readonly name: string;\n readonly kind: 'tool' | 'skill';\n readonly when?: DoomHeadlessCondition;\n readonly active: boolean;\n readonly discoverable: boolean;\n readonly reason?: 'inactive' | 'restricted' | 'shadowed' | 'unavailable' | 'not-discoverable';\n}\n\nexport interface DoomHeadlessCapabilitySnapshot {\n readonly revision: number;\n readonly ready: boolean;\n readonly capabilities: readonly DoomHeadlessCapability[];\n}\n\n/** Registrations inherit package ownership from the caller's Cordis facet. */\n/**\n * The tool a server session loads skills through. When a session carries it, the prompt lists\n * every skill by name and points here, so a skill needs no file the agent could read.\n */\nexport const DOOM_LOAD_SKILL_TOOL = 'load_skill';\n\nexport interface DoomHeadlessHostService {\n readonly context: DoomHeadlessExecutionContext;\n /** The instructions of an applied skill by exact name, or undefined when none is applied. */\n readSkill(name: string): string | undefined;\n changeSelection(change: DoomHeadlessSelectionChange): Promise<void>;\n assertActive(source?: string): void;\n subscribeSelection(listener: (selection: DoomHeadlessSelection) => void | Promise<void>): () => void;\n /** Inspect only a coherently applied generation. A transition returns ready=false and no partial inventory. */\n inspectCapabilities(): DoomHeadlessCapabilitySnapshot;\n registerToolRestriction(restriction: DoomHeadlessToolRestriction): DoomHeadlessRegistration;\n registerTool<TParameters extends TSchema>(tool: DoomHeadlessTool<TParameters>): DoomHeadlessRegistration;\n registerResource(resource: DoomHeadlessResource): DoomHeadlessRegistration;\n registerCommand(command: DoomHeadlessCommand): DoomHeadlessRegistration;\n registerHook(hook: DoomHeadlessHook): DoomHeadlessRegistration;\n registerActivity(activity: DoomHeadlessActivity): DoomHeadlessRegistration;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'doom/headless-host': DoomHeadlessHostService;\n }\n}\n\nexport function readDoomHeadlessHost(context: Context): DoomHeadlessHostService | undefined {\n return context.get(DOOM_HEADLESS_HOST_SERVICE) as DoomHeadlessHostService | undefined;\n}\n\nexport function requireDoomHeadlessHost(context: Context): DoomHeadlessHostService {\n const host = readDoomHeadlessHost(context);\n if (!host) throw new Error('This contribution requires the Doom headless session host.');\n return host;\n}\n"],"mappings":";;AAUA,MAAa,6BAA6B;AAC1C,MAAa,sBAAsB,OAAO,IAAI,qBAAqB;AAEnE,MAAM,yBAAyB;;AAG/B,IAAa,mCAAb,cAAsD,MAAM;CAC1D,YAAY,OAAgB;EAC1B,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,MAAM,CAAC;EACvE,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,mCAAmC,OAAyB;CAC1E,OAAO,iBAAiB,SAAS,MAAM,SAAS;AAClD;AAiBA,SAAgB,sBAAsB,SAAqD;CACzF,OAAQ,QAAwE;AAClF;;;;;AAsBA,SAAgB,yBAAyB,QAKd;CACzB,MAAM,EAAE,sBAAsB;CAC9B,OAAO;EACL,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,GAAI,OAAO,sBAAsB,YAAY,sBAAsB,QAAQ,CAAC,MAAM,QAAQ,iBAAiB,IACvG,EAAqB,kBAA6C,IAClE,CAAC;EACL,GAAI,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,OAAO,QAAQ;CACpE;AACF;;;;;;AA0SA,MAAa,uBAAuB;AAyBpC,SAAgB,qBAAqB,SAAuD;CAC1F,OAAO,QAAQ,IAAI,0BAA0B;AAC/C;AAEA,SAAgB,wBAAwB,SAA2C;CACjF,MAAM,OAAO,qBAAqB,OAAO;CACzC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,4DAA4D;CACvF,OAAO;AACT"}
|
|
@@ -9,6 +9,12 @@ import { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
|
9
9
|
/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */
|
|
10
10
|
export declare const DOOM_HEADLESS_HOST_SERVICE = "doom/headless-host";
|
|
11
11
|
export declare const DOOM_HEADLESS_OWNER: unique symbol;
|
|
12
|
+
/** Admission is a host boundary, not an advisory facet-hook failure. */
|
|
13
|
+
export declare class DoomHeadlessPromptAdmissionError extends Error {
|
|
14
|
+
constructor(cause: unknown);
|
|
15
|
+
}
|
|
16
|
+
/** Error identity must survive independently bundled server and extension graphs. */
|
|
17
|
+
export declare function isDoomHeadlessPromptAdmissionError(error: unknown): boolean;
|
|
12
18
|
export interface DoomHeadlessSelection {
|
|
13
19
|
readonly majorMode: string;
|
|
14
20
|
readonly activeLayers: readonly string[];
|
|
@@ -175,6 +181,8 @@ export interface DoomHeadlessExecutionContext {
|
|
|
175
181
|
provider: string;
|
|
176
182
|
id: string;
|
|
177
183
|
};
|
|
184
|
+
/** Operation cancellation, supplied only for an active invocation. */
|
|
185
|
+
readonly signal?: AbortSignal;
|
|
178
186
|
readonly textCompletion?: {
|
|
179
187
|
available(reference: string): boolean;
|
|
180
188
|
complete(reference: string, request: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../../src/schemas/headless.ts"],"mappings":";;;;;;;;;qBAUa;qBACA;
|
|
1
|
+
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../../src/schemas/headless.ts"],"mappings":"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"}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */
|
|
3
3
|
const DOOM_HEADLESS_HOST_SERVICE = "doom/headless-host";
|
|
4
4
|
const DOOM_HEADLESS_OWNER = Symbol.for("doom/headless-owner");
|
|
5
|
+
const PROMPT_ADMISSION_ERROR = "DoomHeadlessPromptAdmissionError";
|
|
6
|
+
/** Admission is a host boundary, not an advisory facet-hook failure. */
|
|
7
|
+
var DoomHeadlessPromptAdmissionError = class extends Error {
|
|
8
|
+
constructor(cause) {
|
|
9
|
+
super(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
10
|
+
this.name = PROMPT_ADMISSION_ERROR;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/** Error identity must survive independently bundled server and extension graphs. */
|
|
14
|
+
function isDoomHeadlessPromptAdmissionError(error) {
|
|
15
|
+
return error instanceof Error && error.name === PROMPT_ADMISSION_ERROR;
|
|
16
|
+
}
|
|
5
17
|
function readDoomHeadlessOwner(context) {
|
|
6
18
|
return context[DOOM_HEADLESS_OWNER];
|
|
7
19
|
}
|
|
@@ -33,6 +45,6 @@ function requireDoomHeadlessHost(context) {
|
|
|
33
45
|
return host;
|
|
34
46
|
}
|
|
35
47
|
//#endregion
|
|
36
|
-
export { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult };
|
|
48
|
+
export { DOOM_HEADLESS_HOST_SERVICE, DOOM_HEADLESS_OWNER, DOOM_LOAD_SKILL_TOOL, DoomHeadlessPromptAdmissionError, isDoomHeadlessPromptAdmissionError, readDoomHeadlessHost, readDoomHeadlessOwner, requireDoomHeadlessHost, toDoomHeadlessToolResult };
|
|
37
49
|
|
|
38
50
|
//# sourceMappingURL=headless.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.mjs","names":[],"sources":["../../../src/schemas/headless.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { ThinkingLevel } from '@earendil-works/pi-agent-core';\nimport type { CallToolResult, Tool } from '@modelcontextprotocol/server';\nimport type { Static, TSchema } from 'typebox';\n\nimport type { DoomSessionContext } from './hubChannel';\nimport type { DoomNotificationRequest } from './notification';\nimport type { DoomServerBundleEntry } from './serverBundle';\n\n/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */\nexport const DOOM_HEADLESS_HOST_SERVICE = 'doom/headless-host';\nexport const DOOM_HEADLESS_OWNER = Symbol.for('doom/headless-owner');\n\nexport interface DoomHeadlessSelection {\n readonly majorMode: string;\n readonly activeLayers: readonly string[];\n readonly domains: readonly string[];\n readonly profile?: string;\n /** Feature-owned activation sets, keyed by the contributing capability. */\n readonly state?: Readonly<Record<string, readonly string[]>>;\n}\n\n/** One package-owned selection transition. Server facets change exactly one axis per operation. */\nexport type DoomHeadlessSelectionChange =\n | { readonly axis: 'majorMode'; readonly majorMode: string }\n | { readonly axis: 'domains'; readonly domains: readonly string[] }\n | { readonly axis: 'profile'; readonly profile?: string }\n | { readonly axis: 'state'; readonly key: string; readonly values: readonly string[] };\n\nexport function readDoomHeadlessOwner(context: Context): DoomServerBundleEntry | undefined {\n return (context as Context & { [DOOM_HEADLESS_OWNER]?: DoomServerBundleEntry })[DOOM_HEADLESS_OWNER];\n}\n\nexport interface DoomHeadlessRegistration {\n dispose(): void;\n}\n\nexport type DoomHeadlessContent = { type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string };\n\nexport interface DoomHeadlessToolResult {\n content: DoomHeadlessContent[];\n /** Public MCP result data. Internal renderer details are not a remote result contract. */\n structuredContent?: Record<string, unknown>;\n /** Component-only MCP metadata, never inferred from internal renderer details. */\n _meta?: CallToolResult['_meta'];\n details?: unknown;\n isError?: boolean;\n}\n\n/**\n * Narrows a Pi tool result to the headless contract. Pi types `structuredContent` as any JSON\n * value, while MCP only accepts an object, so anything else is dropped rather than forwarded.\n */\nexport function toDoomHeadlessToolResult(result: {\n readonly content: DoomHeadlessContent[];\n readonly details?: unknown;\n readonly structuredContent?: unknown;\n readonly isError?: boolean;\n}): DoomHeadlessToolResult {\n const { structuredContent } = result;\n return {\n content: result.content,\n details: result.details,\n ...(typeof structuredContent === 'object' && structuredContent !== null && !Array.isArray(structuredContent)\n ? { structuredContent: structuredContent as Record<string, unknown> }\n : {}),\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n}\n\nexport interface DoomHeadlessClientRequest {\n kind: 'confirm' | 'select' | 'input';\n title: string;\n message?: string;\n options?: readonly { label: string; description?: string; value: string }[];\n initialValue?: string;\n multiline?: boolean;\n}\n\nexport interface DoomHeadlessClient {\n /**\n * Operator-facing surface only: the body is flattened to one line and capped at 4096 characters\n * by schemas/notification.ts:73-83, and the model never sees it. Use session.admitPrompt to\n * reach the model.\n */\n notify(request: DoomNotificationRequest): void | Promise<void>;\n request(request: DoomHeadlessClientRequest, signal?: AbortSignal): Promise<unknown>;\n setStatus(source: string, text: string | undefined): void;\n appendComposerText?(text: string): void;\n}\n\nexport interface DoomHeadlessModelSettings {\n model?: { provider: string; id: string };\n thinkingLevel: ThinkingLevel;\n}\n\nexport interface DoomHeadlessSession {\n readModelSettings?(): Promise<DoomHeadlessModelSettings>;\n setFastMode?(enabled: boolean): Promise<void>;\n setModelSettings?(settings: Partial<DoomHeadlessModelSettings>): Promise<void>;\n /** Query durable history on demand; hosts do not retain the entire transcript. */\n entries(query?: {\n type?: 'custom' | 'message';\n customType?: string;\n limit?: number;\n }): readonly Record<string, unknown>[] | Promise<readonly Record<string, unknown>[]>;\n appendCustomEntry(type: string, data: unknown): Promise<void>;\n /**\n * Delivers operator input through prompt preflight and awaits its turn.\n * Environmental input uses admitPrompt with origin omitted instead.\n * An idle agent is woken; busy delivery uses Durable steering or follow-up.\n */\n prompt(text: string, delivery?: 'prompt' | 'steer' | 'followUp'): Promise<void>;\n /**\n * Admits input without awaiting its turn. Environmental input omits origin and never\n * changes the operator queue. Operator origin uses prompt preflight, including voice\n * capture; 'interrupt' cancels the active run and admits operator input while preserving\n * retained queued work.\n */\n admitPrompt?(\n text: string,\n delivery?: 'prompt' | 'steer' | 'followUp' | 'interrupt',\n origin?: 'operator',\n ): Promise<void>;\n abort(): Promise<void>;\n compact(instructions?: string): Promise<void>;\n activity(): Promise<{ hasPendingMessages: boolean; isIdle: boolean }>;\n /** Renames the durable session and publishes the updated title to presentation clients. */\n setName?(name: string): Promise<void>;\n /** Capture the current persisted branch for an in-process child fork. */\n forkSource?(): Promise<{ kind: 'v4-fork'; sessionFile: string; branch: string; entryId?: string }>;\n}\n\n/** A grant-filtered skill view available only during one remote MCP tool invocation. */\nexport interface DoomMcpSkillAccess {\n list(): Promise<readonly { name: string; description: string }[]>;\n read(name: string): Promise<string>;\n}\n\n/** A stateless auxiliary request. These tools are private to this request, never registered on the agent. */\nexport interface DoomHeadlessToolCompletionRequest {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n tools: readonly Pick<DoomHeadlessTool, 'name' | 'description' | 'parameters'>[];\n}\n\nexport interface DoomHeadlessToolCompletionResult {\n toolCalls: readonly { id: string; name: string; arguments: unknown }[];\n usage: { totalTokens: number };\n}\n\nexport interface DoomHeadlessExecutionContext {\n readonly cwd: string;\n /** The checkout the session runs in, distinct from the tool execution directory. */\n readonly repoRoot: string;\n readonly sessionId: string;\n /** The session's baseline context, when its host knows its workspace. */\n readonly sessionContext?: DoomSessionContext;\n /** Immutable session configuration. Facets must not read or mutate process.env. */\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly client: DoomHeadlessClient;\n readonly session: DoomHeadlessSession;\n readonly model?: { provider: string; id: string };\n readonly textCompletion?: {\n available(reference: string): boolean;\n complete(\n reference: string,\n request: {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n },\n ): Promise<string>;\n };\n readonly toolCompletion?: {\n complete(reference: string, request: DoomHeadlessToolCompletionRequest): Promise<DoomHeadlessToolCompletionResult>;\n };\n readonly selection: DoomHeadlessSelection;\n /** Present only while an authenticated remote MCP tool is running. */\n readonly mcpSkills?: DoomMcpSkillAccess;\n shutdown(): void;\n}\n\n/** Conditions narrow an eligible owner's contributions; they can never restore a disabled owner. */\nexport interface DoomHeadlessCondition {\n state?: Readonly<Record<string, string>>;\n attribution?: { kind: 'minor' | 'domain'; mode: string; label?: string };\n domain?: string;\n}\n\nexport interface DoomHeadlessToolRestriction {\n when?: DoomHeadlessCondition;\n /** Optional capability ceiling. An empty list disables every tool. */\n allowedTools?: readonly string[];\n /**\n * Narrow exclusions without disabling unrelated tools. Exclude a tool your package owns, or a\n * specific foreign tool the mode exists to withdraw. Never enumerate an allowlist here.\n */\n excludedTools?: readonly string[];\n}\n\nexport interface DoomHeadlessTool<TParameters extends TSchema = TSchema> {\n when?: DoomHeadlessCondition;\n name: string;\n label?: string;\n description: string;\n parameters: TParameters;\n annotations?: Tool['annotations'];\n outputSchema?: Tool['outputSchema'];\n /** Remote presentation only. Component tool access must be explicitly opted into. */\n _meta?: Tool['_meta'] & {\n ui?: {\n resourceUri?: string;\n visibility?: ('model' | 'app')[];\n };\n };\n promptSnippet?: string;\n promptGuidelines?: readonly string[];\n executionMode?: 'parallel' | 'serial';\n execute(\n toolCallId: string,\n parameters: Static<TParameters>,\n signal: AbortSignal | undefined,\n onUpdate: ((result: DoomHeadlessToolResult) => void) | undefined,\n context: DoomHeadlessExecutionContext,\n ): Promise<DoomHeadlessToolResult>;\n}\n\n/**\n * One package contribution to the session's resource surface.\n *\n * `kind` decides what the model is billed for, and the difference is large:\n * - `context` is EAGER. `read()` runs on every prompt build and the text is pasted\n * into the system prompt verbatim. Reserve it for small live session state that\n * exists nowhere on disk. Never use it for a file the package ships: a README\n * registered this way costs its full length on every single turn.\n * - `skill` is LAZY. Only `name`, `description` and `path` reach the prompt; the\n * agent reads the file itself when the description matches the task.\n * - `prompt` is inert until the user invokes it by name.\n *\n * The rule in one line: if it is a file the package ships, it is a `skill`.\n */\nexport interface DoomHeadlessResource {\n when?: DoomHeadlessCondition;\n name: string;\n /** Model-visible selection signal. A `skill` without one tells the agent nothing. */\n description?: string;\n /** Absolute path of the file `read()` returns, so an advertised skill is one the agent can open. */\n path?: string;\n kind: 'prompt' | 'skill' | 'context';\n read(context: DoomHeadlessExecutionContext): string | Promise<string>;\n}\n\nexport interface DoomHeadlessCommand {\n when?: DoomHeadlessCondition;\n name: string;\n description: string;\n execute(args: string, context: DoomHeadlessExecutionContext): void | Promise<void>;\n}\n\nexport type DoomHeadlessEventName =\n | 'session_start'\n | 'session_shutdown'\n | 'session_tree'\n | 'before_agent_start'\n | 'agent_start'\n | 'agent_settled'\n | 'turn_start'\n | 'turn_end'\n | 'context'\n | 'before_provider_request'\n | 'message_start'\n | 'message_update'\n | 'message_end'\n | 'tool_call'\n | 'tool_execution_start'\n | 'tool_execution_update'\n | 'tool_execution_end'\n | 'tool_result'\n | 'model_select'\n | 'session_before_compact'\n | 'session_compact';\n\nexport type DoomHeadlessHookEvent<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { lane: string; runId: string; model: { provider: string; id: string }; payload: unknown }\n : E extends 'session_before_compact'\n ? { reason: string; preparation: unknown; instructions?: string; customInstructions?: string }\n : E extends 'model_select'\n ? { model: { provider: string; id: string } }\n : Readonly<Record<string, unknown>>;\n\nexport interface DoomHeadlessCompactionResult {\n summary: string;\n tokensBefore: number;\n retainedTail: Record<string, unknown>[];\n usage?: Record<string, unknown>;\n details?: unknown;\n}\n\nexport type DoomHeadlessHookResult<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { payload: unknown } | void\n : E extends 'session_before_compact'\n ? { cancel?: boolean; decline?: boolean; compaction?: DoomHeadlessCompactionResult } | void\n : E extends 'context'\n ? { messages?: unknown[]; systemPrompt?: string } | void\n : E extends 'before_agent_start'\n ? { systemPrompt?: string } | void\n : E extends 'tool_call'\n ? { args?: Record<string, unknown>; block?: { reason: string; terminate?: boolean } } | void\n : E extends 'tool_result'\n ? {\n content?: DoomHeadlessContent[];\n details?: unknown;\n isError?: boolean;\n usage?: Record<string, unknown>;\n terminate?: boolean;\n } | void\n : unknown;\n\nexport type DoomHeadlessHook<E extends DoomHeadlessEventName = DoomHeadlessEventName> = E extends DoomHeadlessEventName\n ? {\n when?: DoomHeadlessCondition;\n event: E;\n handle(\n event: Readonly<DoomHeadlessHookEvent<E>>,\n context: DoomHeadlessExecutionContext,\n ): DoomHeadlessHookResult<E> | Promise<DoomHeadlessHookResult<E>>;\n }\n : never;\n\n/** A retained facet can register activity without starting disabled watchers or services. */\nexport interface DoomHeadlessActivity {\n when?: DoomHeadlessCondition;\n name: string;\n start(context: DoomHeadlessExecutionContext): (() => void | Promise<void>) | Promise<() => void | Promise<void>>;\n}\n\n/** Read-only metadata for the currently applied session, never executable declarations or resource bodies. */\nexport interface DoomHeadlessCapability {\n readonly source: string;\n readonly name: string;\n readonly kind: 'tool' | 'skill';\n readonly when?: DoomHeadlessCondition;\n readonly active: boolean;\n readonly discoverable: boolean;\n readonly reason?: 'inactive' | 'restricted' | 'shadowed' | 'unavailable' | 'not-discoverable';\n}\n\nexport interface DoomHeadlessCapabilitySnapshot {\n readonly revision: number;\n readonly ready: boolean;\n readonly capabilities: readonly DoomHeadlessCapability[];\n}\n\n/** Registrations inherit package ownership from the caller's Cordis facet. */\n/**\n * The tool a server session loads skills through. When a session carries it, the prompt lists\n * every skill by name and points here, so a skill needs no file the agent could read.\n */\nexport const DOOM_LOAD_SKILL_TOOL = 'load_skill';\n\nexport interface DoomHeadlessHostService {\n readonly context: DoomHeadlessExecutionContext;\n /** The instructions of an applied skill by exact name, or undefined when none is applied. */\n readSkill(name: string): string | undefined;\n changeSelection(change: DoomHeadlessSelectionChange): Promise<void>;\n assertActive(source?: string): void;\n subscribeSelection(listener: (selection: DoomHeadlessSelection) => void | Promise<void>): () => void;\n /** Inspect only a coherently applied generation. A transition returns ready=false and no partial inventory. */\n inspectCapabilities(): DoomHeadlessCapabilitySnapshot;\n registerToolRestriction(restriction: DoomHeadlessToolRestriction): DoomHeadlessRegistration;\n registerTool<TParameters extends TSchema>(tool: DoomHeadlessTool<TParameters>): DoomHeadlessRegistration;\n registerResource(resource: DoomHeadlessResource): DoomHeadlessRegistration;\n registerCommand(command: DoomHeadlessCommand): DoomHeadlessRegistration;\n registerHook(hook: DoomHeadlessHook): DoomHeadlessRegistration;\n registerActivity(activity: DoomHeadlessActivity): DoomHeadlessRegistration;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'doom/headless-host': DoomHeadlessHostService;\n }\n}\n\nexport function readDoomHeadlessHost(context: Context): DoomHeadlessHostService | undefined {\n return context.get(DOOM_HEADLESS_HOST_SERVICE) as DoomHeadlessHostService | undefined;\n}\n\nexport function requireDoomHeadlessHost(context: Context): DoomHeadlessHostService {\n const host = readDoomHeadlessHost(context);\n if (!host) throw new Error('This contribution requires the Doom headless session host.');\n return host;\n}\n"],"mappings":";;AAUA,MAAa,6BAA6B;AAC1C,MAAa,sBAAsB,OAAO,IAAI,qBAAqB;AAkBnE,SAAgB,sBAAsB,SAAqD;CACzF,OAAQ,QAAwE;AAClF;;;;;AAsBA,SAAgB,yBAAyB,QAKd;CACzB,MAAM,EAAE,sBAAsB;CAC9B,OAAO;EACL,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,GAAI,OAAO,sBAAsB,YAAY,sBAAsB,QAAQ,CAAC,MAAM,QAAQ,iBAAiB,IACvG,EAAqB,kBAA6C,IAClE,CAAC;EACL,GAAI,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,OAAO,QAAQ;CACpE;AACF;;;;;;AAwSA,MAAa,uBAAuB;AAyBpC,SAAgB,qBAAqB,SAAuD;CAC1F,OAAO,QAAQ,IAAI,0BAA0B;AAC/C;AAEA,SAAgB,wBAAwB,SAA2C;CACjF,MAAM,OAAO,qBAAqB,OAAO;CACzC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,4DAA4D;CACvF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"headless.mjs","names":[],"sources":["../../../src/schemas/headless.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport type { ThinkingLevel } from '@earendil-works/pi-agent-core';\nimport type { CallToolResult, Tool } from '@modelcontextprotocol/server';\nimport type { Static, TSchema } from 'typebox';\n\nimport type { DoomSessionContext } from './hubChannel';\nimport type { DoomNotificationRequest } from './notification';\nimport type { DoomServerBundleEntry } from './serverBundle';\n\n/** Session-only contributions. This is not a Pi ExtensionAPI or a TUI adapter. */\nexport const DOOM_HEADLESS_HOST_SERVICE = 'doom/headless-host';\nexport const DOOM_HEADLESS_OWNER = Symbol.for('doom/headless-owner');\n\nconst PROMPT_ADMISSION_ERROR = 'DoomHeadlessPromptAdmissionError';\n\n/** Admission is a host boundary, not an advisory facet-hook failure. */\nexport class DoomHeadlessPromptAdmissionError extends Error {\n constructor(cause: unknown) {\n super(cause instanceof Error ? cause.message : String(cause), { cause });\n this.name = PROMPT_ADMISSION_ERROR;\n }\n}\n\n/** Error identity must survive independently bundled server and extension graphs. */\nexport function isDoomHeadlessPromptAdmissionError(error: unknown): boolean {\n return error instanceof Error && error.name === PROMPT_ADMISSION_ERROR;\n}\nexport interface DoomHeadlessSelection {\n readonly majorMode: string;\n readonly activeLayers: readonly string[];\n readonly domains: readonly string[];\n readonly profile?: string;\n /** Feature-owned activation sets, keyed by the contributing capability. */\n readonly state?: Readonly<Record<string, readonly string[]>>;\n}\n\n/** One package-owned selection transition. Server facets change exactly one axis per operation. */\nexport type DoomHeadlessSelectionChange =\n | { readonly axis: 'majorMode'; readonly majorMode: string }\n | { readonly axis: 'domains'; readonly domains: readonly string[] }\n | { readonly axis: 'profile'; readonly profile?: string }\n | { readonly axis: 'state'; readonly key: string; readonly values: readonly string[] };\n\nexport function readDoomHeadlessOwner(context: Context): DoomServerBundleEntry | undefined {\n return (context as Context & { [DOOM_HEADLESS_OWNER]?: DoomServerBundleEntry })[DOOM_HEADLESS_OWNER];\n}\n\nexport interface DoomHeadlessRegistration {\n dispose(): void;\n}\n\nexport type DoomHeadlessContent = { type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string };\n\nexport interface DoomHeadlessToolResult {\n content: DoomHeadlessContent[];\n /** Public MCP result data. Internal renderer details are not a remote result contract. */\n structuredContent?: Record<string, unknown>;\n /** Component-only MCP metadata, never inferred from internal renderer details. */\n _meta?: CallToolResult['_meta'];\n details?: unknown;\n isError?: boolean;\n}\n\n/**\n * Narrows a Pi tool result to the headless contract. Pi types `structuredContent` as any JSON\n * value, while MCP only accepts an object, so anything else is dropped rather than forwarded.\n */\nexport function toDoomHeadlessToolResult(result: {\n readonly content: DoomHeadlessContent[];\n readonly details?: unknown;\n readonly structuredContent?: unknown;\n readonly isError?: boolean;\n}): DoomHeadlessToolResult {\n const { structuredContent } = result;\n return {\n content: result.content,\n details: result.details,\n ...(typeof structuredContent === 'object' && structuredContent !== null && !Array.isArray(structuredContent)\n ? { structuredContent: structuredContent as Record<string, unknown> }\n : {}),\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n}\n\nexport interface DoomHeadlessClientRequest {\n kind: 'confirm' | 'select' | 'input';\n title: string;\n message?: string;\n options?: readonly { label: string; description?: string; value: string }[];\n initialValue?: string;\n multiline?: boolean;\n}\n\nexport interface DoomHeadlessClient {\n /**\n * Operator-facing surface only: the body is flattened to one line and capped at 4096 characters\n * by schemas/notification.ts:73-83, and the model never sees it. Use session.admitPrompt to\n * reach the model.\n */\n notify(request: DoomNotificationRequest): void | Promise<void>;\n request(request: DoomHeadlessClientRequest, signal?: AbortSignal): Promise<unknown>;\n setStatus(source: string, text: string | undefined): void;\n appendComposerText?(text: string): void;\n}\n\nexport interface DoomHeadlessModelSettings {\n model?: { provider: string; id: string };\n thinkingLevel: ThinkingLevel;\n}\n\nexport interface DoomHeadlessSession {\n readModelSettings?(): Promise<DoomHeadlessModelSettings>;\n setFastMode?(enabled: boolean): Promise<void>;\n setModelSettings?(settings: Partial<DoomHeadlessModelSettings>): Promise<void>;\n /** Query durable history on demand; hosts do not retain the entire transcript. */\n entries(query?: {\n type?: 'custom' | 'message';\n customType?: string;\n limit?: number;\n }): readonly Record<string, unknown>[] | Promise<readonly Record<string, unknown>[]>;\n appendCustomEntry(type: string, data: unknown): Promise<void>;\n /**\n * Delivers operator input through prompt preflight and awaits its turn.\n * Environmental input uses admitPrompt with origin omitted instead.\n * An idle agent is woken; busy delivery uses Durable steering or follow-up.\n */\n prompt(text: string, delivery?: 'prompt' | 'steer' | 'followUp'): Promise<void>;\n /**\n * Admits input without awaiting its turn. Environmental input omits origin and never\n * changes the operator queue. Operator origin uses prompt preflight, including voice\n * capture; 'interrupt' cancels the active run and admits operator input while preserving\n * retained queued work.\n */\n admitPrompt?(\n text: string,\n delivery?: 'prompt' | 'steer' | 'followUp' | 'interrupt',\n origin?: 'operator',\n ): Promise<void>;\n abort(): Promise<void>;\n compact(instructions?: string): Promise<void>;\n activity(): Promise<{ hasPendingMessages: boolean; isIdle: boolean }>;\n /** Renames the durable session and publishes the updated title to presentation clients. */\n setName?(name: string): Promise<void>;\n /** Capture the current persisted branch for an in-process child fork. */\n forkSource?(): Promise<{ kind: 'v4-fork'; sessionFile: string; branch: string; entryId?: string }>;\n}\n\n/** A grant-filtered skill view available only during one remote MCP tool invocation. */\nexport interface DoomMcpSkillAccess {\n list(): Promise<readonly { name: string; description: string }[]>;\n read(name: string): Promise<string>;\n}\n\n/** A stateless auxiliary request. These tools are private to this request, never registered on the agent. */\nexport interface DoomHeadlessToolCompletionRequest {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n tools: readonly Pick<DoomHeadlessTool, 'name' | 'description' | 'parameters'>[];\n}\n\nexport interface DoomHeadlessToolCompletionResult {\n toolCalls: readonly { id: string; name: string; arguments: unknown }[];\n usage: { totalTokens: number };\n}\n\nexport interface DoomHeadlessExecutionContext {\n readonly cwd: string;\n /** The checkout the session runs in, distinct from the tool execution directory. */\n readonly repoRoot: string;\n readonly sessionId: string;\n /** The session's baseline context, when its host knows its workspace. */\n readonly sessionContext?: DoomSessionContext;\n /** Immutable session configuration. Facets must not read or mutate process.env. */\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly client: DoomHeadlessClient;\n readonly session: DoomHeadlessSession;\n readonly model?: { provider: string; id: string };\n /** Operation cancellation, supplied only for an active invocation. */\n readonly signal?: AbortSignal;\n readonly textCompletion?: {\n available(reference: string): boolean;\n complete(\n reference: string,\n request: {\n systemPrompt: string;\n input: string;\n maxTokens: number;\n cacheRetention?: 'none' | 'short' | 'long';\n signal?: AbortSignal;\n },\n ): Promise<string>;\n };\n readonly toolCompletion?: {\n complete(reference: string, request: DoomHeadlessToolCompletionRequest): Promise<DoomHeadlessToolCompletionResult>;\n };\n readonly selection: DoomHeadlessSelection;\n /** Present only while an authenticated remote MCP tool is running. */\n readonly mcpSkills?: DoomMcpSkillAccess;\n shutdown(): void;\n}\n\n/** Conditions narrow an eligible owner's contributions; they can never restore a disabled owner. */\nexport interface DoomHeadlessCondition {\n state?: Readonly<Record<string, string>>;\n attribution?: { kind: 'minor' | 'domain'; mode: string; label?: string };\n domain?: string;\n}\n\nexport interface DoomHeadlessToolRestriction {\n when?: DoomHeadlessCondition;\n /** Optional capability ceiling. An empty list disables every tool. */\n allowedTools?: readonly string[];\n /**\n * Narrow exclusions without disabling unrelated tools. Exclude a tool your package owns, or a\n * specific foreign tool the mode exists to withdraw. Never enumerate an allowlist here.\n */\n excludedTools?: readonly string[];\n}\n\nexport interface DoomHeadlessTool<TParameters extends TSchema = TSchema> {\n when?: DoomHeadlessCondition;\n name: string;\n label?: string;\n description: string;\n parameters: TParameters;\n annotations?: Tool['annotations'];\n outputSchema?: Tool['outputSchema'];\n /** Remote presentation only. Component tool access must be explicitly opted into. */\n _meta?: Tool['_meta'] & {\n ui?: {\n resourceUri?: string;\n visibility?: ('model' | 'app')[];\n };\n };\n promptSnippet?: string;\n promptGuidelines?: readonly string[];\n executionMode?: 'parallel' | 'serial';\n execute(\n toolCallId: string,\n parameters: Static<TParameters>,\n signal: AbortSignal | undefined,\n onUpdate: ((result: DoomHeadlessToolResult) => void) | undefined,\n context: DoomHeadlessExecutionContext,\n ): Promise<DoomHeadlessToolResult>;\n}\n\n/**\n * One package contribution to the session's resource surface.\n *\n * `kind` decides what the model is billed for, and the difference is large:\n * - `context` is EAGER. `read()` runs on every prompt build and the text is pasted\n * into the system prompt verbatim. Reserve it for small live session state that\n * exists nowhere on disk. Never use it for a file the package ships: a README\n * registered this way costs its full length on every single turn.\n * - `skill` is LAZY. Only `name`, `description` and `path` reach the prompt; the\n * agent reads the file itself when the description matches the task.\n * - `prompt` is inert until the user invokes it by name.\n *\n * The rule in one line: if it is a file the package ships, it is a `skill`.\n */\nexport interface DoomHeadlessResource {\n when?: DoomHeadlessCondition;\n name: string;\n /** Model-visible selection signal. A `skill` without one tells the agent nothing. */\n description?: string;\n /** Absolute path of the file `read()` returns, so an advertised skill is one the agent can open. */\n path?: string;\n kind: 'prompt' | 'skill' | 'context';\n read(context: DoomHeadlessExecutionContext): string | Promise<string>;\n}\n\nexport interface DoomHeadlessCommand {\n when?: DoomHeadlessCondition;\n name: string;\n description: string;\n execute(args: string, context: DoomHeadlessExecutionContext): void | Promise<void>;\n}\n\nexport type DoomHeadlessEventName =\n | 'session_start'\n | 'session_shutdown'\n | 'session_tree'\n | 'before_agent_start'\n | 'agent_start'\n | 'agent_settled'\n | 'turn_start'\n | 'turn_end'\n | 'context'\n | 'before_provider_request'\n | 'message_start'\n | 'message_update'\n | 'message_end'\n | 'tool_call'\n | 'tool_execution_start'\n | 'tool_execution_update'\n | 'tool_execution_end'\n | 'tool_result'\n | 'model_select'\n | 'session_before_compact'\n | 'session_compact';\n\nexport type DoomHeadlessHookEvent<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { lane: string; runId: string; model: { provider: string; id: string }; payload: unknown }\n : E extends 'session_before_compact'\n ? { reason: string; preparation: unknown; instructions?: string; customInstructions?: string }\n : E extends 'model_select'\n ? { model: { provider: string; id: string } }\n : Readonly<Record<string, unknown>>;\n\nexport interface DoomHeadlessCompactionResult {\n summary: string;\n tokensBefore: number;\n retainedTail: Record<string, unknown>[];\n usage?: Record<string, unknown>;\n details?: unknown;\n}\n\nexport type DoomHeadlessHookResult<E extends DoomHeadlessEventName> = E extends 'before_provider_request'\n ? { payload: unknown } | void\n : E extends 'session_before_compact'\n ? { cancel?: boolean; decline?: boolean; compaction?: DoomHeadlessCompactionResult } | void\n : E extends 'context'\n ? { messages?: unknown[]; systemPrompt?: string } | void\n : E extends 'before_agent_start'\n ? { systemPrompt?: string } | void\n : E extends 'tool_call'\n ? { args?: Record<string, unknown>; block?: { reason: string; terminate?: boolean } } | void\n : E extends 'tool_result'\n ? {\n content?: DoomHeadlessContent[];\n details?: unknown;\n isError?: boolean;\n usage?: Record<string, unknown>;\n terminate?: boolean;\n } | void\n : unknown;\n\nexport type DoomHeadlessHook<E extends DoomHeadlessEventName = DoomHeadlessEventName> = E extends DoomHeadlessEventName\n ? {\n when?: DoomHeadlessCondition;\n event: E;\n handle(\n event: Readonly<DoomHeadlessHookEvent<E>>,\n context: DoomHeadlessExecutionContext,\n ): DoomHeadlessHookResult<E> | Promise<DoomHeadlessHookResult<E>>;\n }\n : never;\n\n/** A retained facet can register activity without starting disabled watchers or services. */\nexport interface DoomHeadlessActivity {\n when?: DoomHeadlessCondition;\n name: string;\n start(context: DoomHeadlessExecutionContext): (() => void | Promise<void>) | Promise<() => void | Promise<void>>;\n}\n\n/** Read-only metadata for the currently applied session, never executable declarations or resource bodies. */\nexport interface DoomHeadlessCapability {\n readonly source: string;\n readonly name: string;\n readonly kind: 'tool' | 'skill';\n readonly when?: DoomHeadlessCondition;\n readonly active: boolean;\n readonly discoverable: boolean;\n readonly reason?: 'inactive' | 'restricted' | 'shadowed' | 'unavailable' | 'not-discoverable';\n}\n\nexport interface DoomHeadlessCapabilitySnapshot {\n readonly revision: number;\n readonly ready: boolean;\n readonly capabilities: readonly DoomHeadlessCapability[];\n}\n\n/** Registrations inherit package ownership from the caller's Cordis facet. */\n/**\n * The tool a server session loads skills through. When a session carries it, the prompt lists\n * every skill by name and points here, so a skill needs no file the agent could read.\n */\nexport const DOOM_LOAD_SKILL_TOOL = 'load_skill';\n\nexport interface DoomHeadlessHostService {\n readonly context: DoomHeadlessExecutionContext;\n /** The instructions of an applied skill by exact name, or undefined when none is applied. */\n readSkill(name: string): string | undefined;\n changeSelection(change: DoomHeadlessSelectionChange): Promise<void>;\n assertActive(source?: string): void;\n subscribeSelection(listener: (selection: DoomHeadlessSelection) => void | Promise<void>): () => void;\n /** Inspect only a coherently applied generation. A transition returns ready=false and no partial inventory. */\n inspectCapabilities(): DoomHeadlessCapabilitySnapshot;\n registerToolRestriction(restriction: DoomHeadlessToolRestriction): DoomHeadlessRegistration;\n registerTool<TParameters extends TSchema>(tool: DoomHeadlessTool<TParameters>): DoomHeadlessRegistration;\n registerResource(resource: DoomHeadlessResource): DoomHeadlessRegistration;\n registerCommand(command: DoomHeadlessCommand): DoomHeadlessRegistration;\n registerHook(hook: DoomHeadlessHook): DoomHeadlessRegistration;\n registerActivity(activity: DoomHeadlessActivity): DoomHeadlessRegistration;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'doom/headless-host': DoomHeadlessHostService;\n }\n}\n\nexport function readDoomHeadlessHost(context: Context): DoomHeadlessHostService | undefined {\n return context.get(DOOM_HEADLESS_HOST_SERVICE) as DoomHeadlessHostService | undefined;\n}\n\nexport function requireDoomHeadlessHost(context: Context): DoomHeadlessHostService {\n const host = readDoomHeadlessHost(context);\n if (!host) throw new Error('This contribution requires the Doom headless session host.');\n return host;\n}\n"],"mappings":";;AAUA,MAAa,6BAA6B;AAC1C,MAAa,sBAAsB,OAAO,IAAI,qBAAqB;AAEnE,MAAM,yBAAyB;;AAG/B,IAAa,mCAAb,cAAsD,MAAM;CAC1D,YAAY,OAAgB;EAC1B,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,MAAM,CAAC;EACvE,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,mCAAmC,OAAyB;CAC1E,OAAO,iBAAiB,SAAS,MAAM,SAAS;AAClD;AAiBA,SAAgB,sBAAsB,SAAqD;CACzF,OAAQ,QAAwE;AAClF;;;;;AAsBA,SAAgB,yBAAyB,QAKd;CACzB,MAAM,EAAE,sBAAsB;CAC9B,OAAO;EACL,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,GAAI,OAAO,sBAAsB,YAAY,sBAAsB,QAAQ,CAAC,MAAM,QAAQ,iBAAiB,IACvG,EAAqB,kBAA6C,IAClE,CAAC;EACL,GAAI,OAAO,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,OAAO,QAAQ;CACpE;AACF;;;;;;AA0SA,MAAa,uBAAuB;AAyBpC,SAAgB,qBAAqB,SAAuD;CAC1F,OAAO,QAAQ,IAAI,0BAA0B;AAC/C;AAEA,SAAgB,wBAAwB,SAA2C;CACjF,MAAM,OAAO,qBAAqB,OAAO;CACzC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,4DAA4D;CACvF,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionProtocol.d.mts","names":[],"sources":["../../../src/schemas/sessionProtocol.ts"],"mappings":";;;qBAIa;qBACA;qBACA;
|
|
1
|
+
{"version":3,"file":"sessionProtocol.d.mts","names":["JsonValue"],"sources":["../../../src/schemas/sessionProtocol.ts"],"mappings":"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"}
|
|
@@ -68,7 +68,7 @@ function childRuntime(runtime, intercom, release) {
|
|
|
68
68
|
abort: () => runtime.abort(),
|
|
69
69
|
dispose: async () => {
|
|
70
70
|
try {
|
|
71
|
-
release?.();
|
|
71
|
+
await release?.();
|
|
72
72
|
} finally {
|
|
73
73
|
try {
|
|
74
74
|
await runtime.dispose();
|
|
@@ -79,6 +79,57 @@ function childRuntime(runtime, intercom, release) {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
/** Own the hook lifetime independently of the caller's startup signal. */
|
|
83
|
+
function bindChildHooks(request, hooks, readRuntime, signal) {
|
|
84
|
+
const lifetime = new AbortController();
|
|
85
|
+
const abort = () => lifetime.abort(signal?.reason);
|
|
86
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
87
|
+
if (signal?.aborted) abort();
|
|
88
|
+
const admittedRuntime = () => {
|
|
89
|
+
lifetime.signal.throwIfAborted();
|
|
90
|
+
const runtime = readRuntime();
|
|
91
|
+
if (!runtime) throw new Error("Child hook runtime is not available.");
|
|
92
|
+
return runtime;
|
|
93
|
+
};
|
|
94
|
+
const { intercom, ...data } = request;
|
|
95
|
+
const freeze = (value) => {
|
|
96
|
+
if (typeof value !== "object" || value === null) return;
|
|
97
|
+
for (const child of Object.values(value)) freeze(child);
|
|
98
|
+
Object.freeze(value);
|
|
99
|
+
};
|
|
100
|
+
const snapshot = structuredClone(data);
|
|
101
|
+
freeze(snapshot);
|
|
102
|
+
let binding;
|
|
103
|
+
try {
|
|
104
|
+
binding = hooks?.bind({
|
|
105
|
+
request: Object.freeze({
|
|
106
|
+
...snapshot,
|
|
107
|
+
...intercom ? { intercom } : {}
|
|
108
|
+
}),
|
|
109
|
+
sessionId: () => readRuntime()?.sessionId,
|
|
110
|
+
signal: lifetime.signal,
|
|
111
|
+
async sendMessage(text, delivery) {
|
|
112
|
+
await admittedRuntime().submitInternalMessage(text, delivery);
|
|
113
|
+
},
|
|
114
|
+
async appendCustomEntry(type, data) {
|
|
115
|
+
await admittedRuntime().appendCustomEntry(type, data);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
lifetime.abort();
|
|
120
|
+
signal?.removeEventListener("abort", abort);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
let disposal;
|
|
124
|
+
return {
|
|
125
|
+
...binding ? { binding } : {},
|
|
126
|
+
dispose: () => disposal ??= (async () => {
|
|
127
|
+
lifetime.abort();
|
|
128
|
+
signal?.removeEventListener("abort", abort);
|
|
129
|
+
await binding?.dispose();
|
|
130
|
+
})()
|
|
131
|
+
};
|
|
132
|
+
}
|
|
82
133
|
async function installIntercom(runtime, intercom, tools) {
|
|
83
134
|
if (!intercom) return;
|
|
84
135
|
const tool = intercom.bindRuntime(childRuntime(runtime));
|
|
@@ -336,7 +387,13 @@ function createHeadlessChildSessionService(options) {
|
|
|
336
387
|
historyOwnership: ownership
|
|
337
388
|
};
|
|
338
389
|
let runtime;
|
|
390
|
+
let hooks;
|
|
339
391
|
try {
|
|
392
|
+
hooks = bindChildHooks(request, options.hooks?.(), () => runtime, signal);
|
|
393
|
+
if (hooks.binding) {
|
|
394
|
+
runtimeOptions.beforeTool = hooks.binding.beforeTool;
|
|
395
|
+
runtimeOptions.afterTool = hooks.binding.afterTool;
|
|
396
|
+
}
|
|
340
397
|
runtime = await runtimeFactory(runtimeOptions);
|
|
341
398
|
if (requestedModel && model) await runtime.setModel(model);
|
|
342
399
|
if (thinking !== void 0) await runtime.setThinkingLevel(thinking);
|
|
@@ -344,15 +401,24 @@ function createHeadlessChildSessionService(options) {
|
|
|
344
401
|
const releaseMcp = bindChildMcpCatalog(runtime, request, options, runtimeOptions.tools ?? []);
|
|
345
402
|
const file = sessionFile(runtime);
|
|
346
403
|
const releaseNative = file ? require_nativeChildRuntimes.registerNativeChild(file, runtime) : void 0;
|
|
347
|
-
return childRuntime(runtime, request.intercom, () => {
|
|
404
|
+
return childRuntime(runtime, request.intercom, async () => {
|
|
348
405
|
try {
|
|
349
406
|
releaseMcp();
|
|
350
407
|
} finally {
|
|
351
|
-
|
|
408
|
+
try {
|
|
409
|
+
releaseNative?.();
|
|
410
|
+
} finally {
|
|
411
|
+
await hooks?.dispose();
|
|
412
|
+
}
|
|
352
413
|
}
|
|
353
414
|
});
|
|
354
415
|
} catch (error) {
|
|
355
416
|
const failures = [error];
|
|
417
|
+
try {
|
|
418
|
+
await hooks?.dispose();
|
|
419
|
+
} catch (cleanupError) {
|
|
420
|
+
failures.push(cleanupError);
|
|
421
|
+
}
|
|
356
422
|
let closed = false;
|
|
357
423
|
try {
|
|
358
424
|
if (runtime) {
|
|
@@ -389,6 +455,7 @@ function createHeadlessChildSessionServiceProvider(options) {
|
|
|
389
455
|
};
|
|
390
456
|
}
|
|
391
457
|
//#endregion
|
|
458
|
+
exports.bindChildHooks = bindChildHooks;
|
|
392
459
|
exports.bindChildMcpCatalog = bindChildMcpCatalog;
|
|
393
460
|
exports.composeDirectHarnessRequestOptions = composeDirectHarnessRequestOptions;
|
|
394
461
|
exports.createHeadlessChildSessionService = createHeadlessChildSessionService;
|