@introspection-ai/recipes 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/child/session.d.ts +2 -0
- package/dist/child/session.d.ts.map +1 -1
- package/dist/child/session.js +3 -0
- package/dist/child/session.js.map +1 -1
- package/dist/connector-tools.d.ts +4 -0
- package/dist/connector-tools.d.ts.map +1 -1
- package/dist/connector-tools.js.map +1 -1
- package/dist/documents/index.d.ts +5 -2
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +3 -1
- package/dist/documents/index.js.map +1 -1
- package/dist/documents/module.d.ts +29 -10
- package/dist/documents/module.d.ts.map +1 -1
- package/dist/documents/module.js +22 -4
- package/dist/documents/module.js.map +1 -1
- package/dist/documents/profile.d.ts +34 -0
- package/dist/documents/profile.d.ts.map +1 -0
- package/dist/documents/profile.js +94 -0
- package/dist/documents/profile.js.map +1 -0
- package/dist/documents/python.d.ts +30 -0
- package/dist/documents/python.d.ts.map +1 -0
- package/dist/documents/python.js +64 -0
- package/dist/documents/python.js.map +1 -0
- package/dist/extensions.d.ts +16 -0
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +12 -0
- package/dist/extensions.js.map +1 -1
- package/dist/mcp-chunks/chunk-ZK2E4S7E.js +12520 -0
- package/dist/mcp-daemon.js +1 -1
- package/dist/mcp-run-worker.js +1 -1
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +89 -14
- package/dist/pi-extension.js.map +1 -1
- package/dist/python.d.ts +56 -0
- package/dist/python.d.ts.map +1 -0
- package/dist/python.js +100 -0
- package/dist/python.js.map +1 -0
- package/dist/recipe/package.d.ts +22 -0
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +118 -6
- package/dist/recipe/package.js.map +1 -1
- package/dist/recipe/python.d.ts +141 -0
- package/dist/recipe/python.d.ts.map +1 -0
- package/dist/recipe/python.js +698 -0
- package/dist/recipe/python.js.map +1 -0
- package/dist/recipe/resolve.d.ts +3 -0
- package/dist/recipe/resolve.d.ts.map +1 -1
- package/dist/recipe/resolve.js +2 -0
- package/dist/recipe/resolve.js.map +1 -1
- package/dist/run-controller.d.ts +2 -0
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +3 -0
- package/dist/run-controller.js.map +1 -1
- package/dist/session.d.ts +8 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +37 -15
- package/dist/session.js.map +1 -1
- package/docs/documents.md +134 -17
- package/docs/pi-extension.md +4 -1
- package/docs/recipe-format.md +99 -4
- package/documents/SKILL.md +63 -0
- package/package.json +16 -10
- package/dist/mcp-chunks/chunk-UVEZNUN3.js +0 -3312
package/README.md
CHANGED
|
@@ -127,8 +127,11 @@ tests.
|
|
|
127
127
|
- `@introspection-ai/recipes/session` — create a live Pi Recipe session
|
|
128
128
|
- `@introspection-ai/recipes/mcp` — MCP declarations, bindings, and selection
|
|
129
129
|
- `@introspection-ai/recipes/pi-extension` — Pi extension entrypoint
|
|
130
|
-
- `@introspection-ai/recipes/extensions` — session identity
|
|
131
|
-
Recipe extension
|
|
130
|
+
- `@introspection-ai/recipes/extensions` — session identity, the prepared
|
|
131
|
+
Python of each package (`packagePython`), and conditional Recipe extension
|
|
132
|
+
helpers
|
|
133
|
+
- `@introspection-ai/recipes/python` — `pythonExecutable` and
|
|
134
|
+
`runPythonJson`: run a package's Python helper with JSON in and out
|
|
132
135
|
- `@introspection-ai/recipes/channels` defines the provider-neutral `channels`
|
|
133
136
|
tool, capability descriptors, and opaque message references. Replies answer
|
|
134
137
|
the task's origin; capable adapters also support explicit read and send targets.
|
package/dist/child/session.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface CreateIsolatedChildSessionOptions {
|
|
|
9
9
|
agentName: string;
|
|
10
10
|
cwd: string;
|
|
11
11
|
env: NodeJS.ProcessEnv;
|
|
12
|
+
/** Where the host prepared the Python environments; see `pythonEnvironmentRoot` on the session. */
|
|
13
|
+
pythonEnvironmentRoot?: string;
|
|
12
14
|
credentials?: CredentialStore;
|
|
13
15
|
/** Host settings the child layers its own `session` policy over. */
|
|
14
16
|
settingsManager?: SettingsManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/child/session.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,iCAAiC;IAChD,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,oEAAoE;IACpE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7C,oEAAoE;IACpE,UAAU,CA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,
|
|
46
46
|
cwd: opts.cwd,
|
|
47
47
|
env: { ...opts.env },
|
|
48
|
+
...(opts.pythonEnvironmentRoot
|
|
49
|
+
? { pythonEnvironmentRoot: opts.pythonEnvironmentRoot }
|
|
50
|
+
: {}),
|
|
48
51
|
...(opts.credentials ? { credentials: opts.credentials } : {}),
|
|
49
52
|
...(opts.settingsManager
|
|
50
53
|
? { settingsManager: opts.settingsManager }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/child/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAM/C,OAAO,EACL,0BAA0B,GAI3B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/child/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,mBA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
|
cwd?: string;
|
|
16
|
+
/** Prepared package Python environments by package name (see `prepareRecipePython`). */
|
|
17
|
+
python?: Readonly<Record<string, {
|
|
18
|
+
interpreter: string;
|
|
19
|
+
}>>;
|
|
16
20
|
}
|
|
17
21
|
export interface RecipeConnectorToolLoadout {
|
|
18
22
|
toolNames: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-tools.d.ts","sourceRoot":"","sources":["../src/connector-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKxE,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,+BAA+B;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"connector-tools.d.ts","sourceRoot":"","sources":["../src/connector-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKxE,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,E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js","sourceRoot":"","sources":["../src/connector-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,wBAAwB,GAGzB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"connector-tools.js","sourceRoot":"","sources":["../src/connector-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,wBAAwB,GAGzB,MAAM,qBAAqB,CAAC;AA8C7B,SAAS,oBAAoB,CAC3B,OAA6B,EAC7B,MAAc;IAEd,OAAO,IAAI,KAAK,CACd,0BAA0B,wBAAwB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,MAAM,EAAE,CACjF,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAChC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAG,KAA+C,CAAC;IAC7D,OAAO,CACL,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ;QAC3B,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAC7B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,aAAa,KAAK,SAAS,CACxC,CAAC;AACJ,CAAC;AAED,SAAS,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AAK,eAAe,CAAC,MAAM,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO;QACL,UAAU,EAAE;YACV,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;YACjD,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD;QACD,OAAO,EAAE;YACP,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,sBAAsB,EAAE,QAAQ;iBAC7B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC;iBACpC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAC3B,iBAAiB,EAAE,QAAQ;iBACxB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;iBACrC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SAC5B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { DOCUMENT_COMMANDS, documentCommandsFor, documentConnectorTools, registerDocumentTools, workspacePath, } from "./tools.js";
|
|
2
2
|
export type { DocumentCommand, DocumentToolHost, RegisterDocumentToolsOptions } from "./tools.js";
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
3
|
+
export { documentPythonExecutable, RECIPE_DOCUMENTS_PYTHON_ENV, runDocumentHelper, } from "./python.js";
|
|
4
|
+
export type { DocumentHelperOptions } from "./python.js";
|
|
5
|
+
export { createDocumentFormatModule, DOCUMENTS_SKILL, loadRecipeDocuments } from "./module.js";
|
|
6
|
+
export { DOCUMENT_PROFILE_NAME, documentProfileShapeProblem, documentProfileSkillProblem, isDocumentProfilePath, recipeProfileSkill, resolveDocumentProfile, } from "./profile.js";
|
|
7
|
+
export type { DocumentAdapterOptions, DocumentFormatModuleOptions, LoadedRecipeDocuments, RecipeDocumentFormatModule } from "./module.js";
|
|
5
8
|
export type { DocumentAdapter, DocumentAdapterContext, DocumentCapabilities, DocumentCommentInput, DocumentEdit, DocumentImage, DocumentProposeEditsInput, DocumentReadInput, DocumentRemoveSectionInput, DocumentRenderInput, DocumentRespondInput, DocumentResponse, DocumentResult, DocumentReviseInput, DocumentRevision, DocumentWriteTarget, } from "./types.js";
|
|
6
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAClG,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC1I,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/documents/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { DOCUMENT_COMMANDS, documentCommandsFor, documentConnectorTools, registerDocumentTools, workspacePath, } from "./tools.js";
|
|
2
|
-
export {
|
|
2
|
+
export { documentPythonExecutable, RECIPE_DOCUMENTS_PYTHON_ENV, runDocumentHelper, } from "./python.js";
|
|
3
|
+
export { createDocumentFormatModule, DOCUMENTS_SKILL, loadRecipeDocuments } from "./module.js";
|
|
4
|
+
export { DOCUMENT_PROFILE_NAME, documentProfileShapeProblem, documentProfileSkillProblem, isDocumentProfilePath, recipeProfileSkill, resolveDocumentProfile, } from "./profile.js";
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
|
|
@@ -2,6 +2,8 @@ import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { type RecipePackageDocument } from "../recipe/package.js";
|
|
3
3
|
import { documentConnectorTools } from "./tools.js";
|
|
4
4
|
import type { DocumentAdapter, DocumentCapabilities } from "./types.js";
|
|
5
|
+
/** The core `documents` skill, offered to every agent that selects the tool. It ships beside `dist/`. */
|
|
6
|
+
export declare const DOCUMENTS_SKILL: string;
|
|
5
7
|
/** What a format package exports as its default: transport plus a capability descriptor, no schemas. */
|
|
6
8
|
export interface RecipeDocumentFormatModule {
|
|
7
9
|
readonly kind: "documents";
|
|
@@ -9,19 +11,28 @@ export interface RecipeDocumentFormatModule {
|
|
|
9
11
|
readonly extensions: readonly string[];
|
|
10
12
|
/** Static, so the loader can build the tool before any session exists. */
|
|
11
13
|
readonly capabilities: DocumentCapabilities;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/** Profiles this format ships: name to the absolute path of its SKILL.md (see profile.ts). */
|
|
15
|
+
readonly profiles?: Readonly<Record<string, string>>;
|
|
16
|
+
createAdapter(options: DocumentAdapterOptions): DocumentAdapter;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What the host passes a format's `createAdapter`. `python` is the
|
|
20
|
+
* interpreter of the environment the format package's own
|
|
21
|
+
* `pi.runtime.python` declares, prepared by the host; absent when the package
|
|
22
|
+
* declares none. An adapter that ignores it keeps working.
|
|
23
|
+
*/
|
|
24
|
+
export interface DocumentAdapterOptions {
|
|
25
|
+
env: NodeJS.ProcessEnv;
|
|
26
|
+
cwd: string;
|
|
27
|
+
python?: string;
|
|
16
28
|
}
|
|
17
29
|
export interface DocumentFormatModuleOptions {
|
|
18
30
|
format: string;
|
|
19
31
|
extensions: readonly string[];
|
|
20
32
|
capabilities: DocumentCapabilities;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}): DocumentAdapter;
|
|
33
|
+
/** Profiles shipped with the format: name to the absolute path of its SKILL.md. */
|
|
34
|
+
profiles?: Readonly<Record<string, string>>;
|
|
35
|
+
createAdapter(options: DocumentAdapterOptions): DocumentAdapter;
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* Build a format module from an adapter factory. The neutral tool, its
|
|
@@ -34,10 +45,14 @@ export interface LoadedRecipeDocuments {
|
|
|
34
45
|
factory: ExtensionFactory;
|
|
35
46
|
};
|
|
36
47
|
toolNames: string[];
|
|
48
|
+
/** The core `documents` skill, then each declared profile's skill, offered beside the tool. */
|
|
49
|
+
skillPaths?: string[];
|
|
37
50
|
}
|
|
38
51
|
/**
|
|
39
|
-
* Load every `pi.documents` format package and
|
|
40
|
-
* `documents`, one extension
|
|
52
|
+
* Load every `pi.documents` format package and the profile each declaration
|
|
53
|
+
* names (only those) and, when the agent selects `documents`, one extension
|
|
54
|
+
* registering the shared tool and offering the core `documents` skill with
|
|
55
|
+
* each profile's hints beside it.
|
|
41
56
|
*
|
|
42
57
|
* Each declaration's `commands` allowlist narrows what that format may do;
|
|
43
58
|
* the tool exposes the union of what the formats allow.
|
|
@@ -46,6 +61,10 @@ export declare function loadRecipeDocuments(declarations: readonly RecipePackage
|
|
|
46
61
|
recipeDir: string;
|
|
47
62
|
env?: NodeJS.ProcessEnv;
|
|
48
63
|
cwd?: string;
|
|
64
|
+
/** Prepared package environments by package name (see `prepareRecipePython`). */
|
|
65
|
+
python?: Readonly<Record<string, {
|
|
66
|
+
interpreter: string;
|
|
67
|
+
}>>;
|
|
49
68
|
}): Promise<LoadedRecipeDocuments>;
|
|
50
69
|
export { documentConnectorTools };
|
|
51
70
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/documents/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/documents/module.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAGL,sBAAsB,EAGvB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAExE,yGAAyG;AACzG,eAAO,MAAM,eAAe,QAAsE,CAAC;AAEnG,wGAAwG;AACxG,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,8FAA8F;IAC9F,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CAAC;CACjE;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC,U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url";
|
|
1
2
|
import { loadRecipeModule } from "../recipe/extensions.js";
|
|
2
3
|
import { recipeDocumentPackageName } from "../recipe/package.js";
|
|
3
4
|
import { DOCUMENT_COMMANDS, documentCommandsFor, documentConnectorTools, registerDocumentTools, } from "./tools.js";
|
|
5
|
+
import { resolveDocumentProfile } from "./profile.js";
|
|
6
|
+
/** The core `documents` skill, offered to every agent that selects the tool. It ships beside `dist/`. */
|
|
7
|
+
export const DOCUMENTS_SKILL = fileURLToPath(new URL("../../documents/SKILL.md", import.meta.url));
|
|
4
8
|
function sameCapabilities(left, right) {
|
|
5
9
|
const a = documentCommandsFor(left);
|
|
6
10
|
const b = documentCommandsFor(right);
|
|
@@ -20,6 +24,7 @@ export function createDocumentFormatModule(options) {
|
|
|
20
24
|
format: options.format,
|
|
21
25
|
extensions: options.extensions.map((extension) => extension.toLowerCase()),
|
|
22
26
|
capabilities: options.capabilities,
|
|
27
|
+
profiles: { ...options.profiles },
|
|
23
28
|
createAdapter(createOptions) {
|
|
24
29
|
const adapter = options.createAdapter(createOptions);
|
|
25
30
|
if (adapter.format !== options.format) {
|
|
@@ -47,8 +52,10 @@ function parseFormatModule(value, declaration) {
|
|
|
47
52
|
}
|
|
48
53
|
const knownCommands = new Set(DOCUMENT_COMMANDS);
|
|
49
54
|
/**
|
|
50
|
-
* Load every `pi.documents` format package and
|
|
51
|
-
* `documents`, one extension
|
|
55
|
+
* Load every `pi.documents` format package and the profile each declaration
|
|
56
|
+
* names (only those) and, when the agent selects `documents`, one extension
|
|
57
|
+
* registering the shared tool and offering the core `documents` skill with
|
|
58
|
+
* each profile's hints beside it.
|
|
52
59
|
*
|
|
53
60
|
* Each declaration's `commands` allowlist narrows what that format may do;
|
|
54
61
|
* the tool exposes the union of what the formats allow.
|
|
@@ -76,20 +83,30 @@ export async function loadRecipeDocuments(declarations, agentTools, options) {
|
|
|
76
83
|
throw new Error(`Document format '${declaration.format}' does not support command: ${command}`);
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
|
-
|
|
86
|
+
const profile = declaration.profile === undefined
|
|
87
|
+
? undefined
|
|
88
|
+
: resolveDocumentProfile(declaration.profile, { format: declaration.format, shipped: module.profiles, recipeDir: options.recipeDir });
|
|
89
|
+
return { declaration, module, profile };
|
|
80
90
|
}));
|
|
81
91
|
const enabled = modules.filter(({ declaration }) => declaration.commands?.length !== 0);
|
|
82
92
|
if (!agentTools.includes("documents") || enabled.length === 0)
|
|
83
93
|
return { toolNames: [] };
|
|
94
|
+
const skillPaths = [DOCUMENTS_SKILL];
|
|
95
|
+
for (const { profile } of enabled) {
|
|
96
|
+
if (profile && !skillPaths.includes(profile))
|
|
97
|
+
skillPaths.push(profile);
|
|
98
|
+
}
|
|
84
99
|
return {
|
|
85
100
|
toolNames: ["documents"],
|
|
101
|
+
skillPaths,
|
|
86
102
|
extension: {
|
|
87
103
|
owner: `<documents:${enabled.map(({ declaration }) => declaration.format).join(",")}>`,
|
|
88
104
|
factory: (pi) => {
|
|
89
105
|
const env = options.env ?? process.env;
|
|
90
106
|
const cwd = options.cwd ?? process.cwd();
|
|
91
107
|
const adapters = enabled.map(({ declaration, module }) => {
|
|
92
|
-
const
|
|
108
|
+
const python = options.python?.[recipeDocumentPackageName(declaration.format)]?.interpreter;
|
|
109
|
+
const adapter = module.createAdapter({ env, cwd, ...(python ? { python } : {}) });
|
|
93
110
|
const allowed = declaration.commands;
|
|
94
111
|
if (allowed === undefined)
|
|
95
112
|
return adapter;
|
|
@@ -108,6 +125,7 @@ export async function loadRecipeDocuments(declarations, agentTools, options) {
|
|
|
108
125
|
});
|
|
109
126
|
});
|
|
110
127
|
registerDocumentTools(pi, adapters, { cwd });
|
|
128
|
+
pi.on("resources_discover", () => ({ skillPaths }));
|
|
111
129
|
},
|
|
112
130
|
},
|
|
113
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/documents/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":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,CAAC,CAAC;4BAChE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;4BAChE,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,aAAa,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;4BACnF,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;yBAC9D;qBACF,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBACH,qBAAqB,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC7C,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YACtD,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document profile is a skill: a folder holding a `SKILL.md` whose
|
|
3
|
+
* frontmatter `name` is the folder's name, in lower case, with a
|
|
4
|
+
* `description`. A format package ships some by name; a Recipe can bring its
|
|
5
|
+
* own by a relative path to the folder (or its `SKILL.md`). A profile is only
|
|
6
|
+
* read, never run. See docs/documents.md, "Write your own profile".
|
|
7
|
+
*/
|
|
8
|
+
/** A profile name a format ships, such as `legal-redlining-en-US`. */
|
|
9
|
+
export declare const DOCUMENT_PROFILE_NAME: RegExp;
|
|
10
|
+
/** A relative path to a profile folder or its SKILL.md, rather than a shipped name. */
|
|
11
|
+
export declare function isDocumentProfilePath(profile: string): boolean;
|
|
12
|
+
/** Why a `pi.documents[].profile` value has the wrong shape, or undefined when the shape is right. */
|
|
13
|
+
export declare function documentProfileShapeProblem(profile: unknown): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Check a profile's SKILL.md follows the contract: frontmatter whose `name`
|
|
16
|
+
* is its folder's name in lower case, and a `description`. Returns the problem,
|
|
17
|
+
* or undefined when it follows the contract.
|
|
18
|
+
*/
|
|
19
|
+
export declare function documentProfileSkillProblem(skillPath: string): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The SKILL.md of a profile a Recipe brings by path: the folder or the file,
|
|
22
|
+
* inside the Recipe by its real path, following the contract.
|
|
23
|
+
*/
|
|
24
|
+
export declare function recipeProfileSkill(profile: string, recipeDir: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* The SKILL.md a declaration's `profile` selects: one the format ships, by
|
|
27
|
+
* name (case-insensitive), or the Recipe's own, by relative path.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveDocumentProfile(profile: string, options: {
|
|
30
|
+
format: string;
|
|
31
|
+
shipped?: Readonly<Record<string, string>>;
|
|
32
|
+
recipeDir: string;
|
|
33
|
+
}): string;
|
|
34
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/documents/profile.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AAEH,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,QAA+B,CAAC;AAElE,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,sGAAsG;AACtG,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOhF;AAUD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASjF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAc7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACzF,MAAM,CAUR"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { assertRecipePathContained } from "../recipe/package.js";
|
|
5
|
+
/**
|
|
6
|
+
* A document profile is a skill: a folder holding a `SKILL.md` whose
|
|
7
|
+
* frontmatter `name` is the folder's name, in lower case, with a
|
|
8
|
+
* `description`. A format package ships some by name; a Recipe can bring its
|
|
9
|
+
* own by a relative path to the folder (or its `SKILL.md`). A profile is only
|
|
10
|
+
* read, never run. See docs/documents.md, "Write your own profile".
|
|
11
|
+
*/
|
|
12
|
+
/** A profile name a format ships, such as `legal-redlining-en-US`. */
|
|
13
|
+
export const DOCUMENT_PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9-]*$/;
|
|
14
|
+
/** A relative path to a profile folder or its SKILL.md, rather than a shipped name. */
|
|
15
|
+
export function isDocumentProfilePath(profile) {
|
|
16
|
+
return profile.includes("/") || profile.includes("\\") || profile.startsWith(".");
|
|
17
|
+
}
|
|
18
|
+
/** Why a `pi.documents[].profile` value has the wrong shape, or undefined when the shape is right. */
|
|
19
|
+
export function documentProfileShapeProblem(profile) {
|
|
20
|
+
const usage = "must be the name of a profile the format ships, such as legal-redlining-en-US, or a relative path to a profile folder in the Recipe";
|
|
21
|
+
if (typeof profile !== "string" || !profile.trim())
|
|
22
|
+
return usage;
|
|
23
|
+
if (!isDocumentProfilePath(profile))
|
|
24
|
+
return DOCUMENT_PROFILE_NAME.test(profile) ? undefined : usage;
|
|
25
|
+
const absolute = isAbsolute(profile) || profile.startsWith("\\") || /^[A-Za-z]:/.test(profile);
|
|
26
|
+
if (absolute || profile.split(/[\\/]/).includes(".."))
|
|
27
|
+
return `'${profile}' must be a relative path inside the Recipe`;
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The frontmatter of a SKILL.md, or undefined when it has none. */
|
|
31
|
+
function frontmatter(text) {
|
|
32
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
|
|
33
|
+
if (!match)
|
|
34
|
+
return undefined;
|
|
35
|
+
const parsed = parse(match[1] ?? "");
|
|
36
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check a profile's SKILL.md follows the contract: frontmatter whose `name`
|
|
40
|
+
* is its folder's name in lower case, and a `description`. Returns the problem,
|
|
41
|
+
* or undefined when it follows the contract.
|
|
42
|
+
*/
|
|
43
|
+
export function documentProfileSkillProblem(skillPath) {
|
|
44
|
+
const folder = basename(dirname(skillPath));
|
|
45
|
+
const fields = frontmatter(readFileSync(skillPath, "utf8"));
|
|
46
|
+
if (!fields)
|
|
47
|
+
return "has no frontmatter; start it with --- name and description ---";
|
|
48
|
+
if (fields.name !== folder || folder !== folder.toLowerCase()) {
|
|
49
|
+
return `frontmatter name must be its folder's name in lower case ('${folder.toLowerCase()}'), not '${String(fields.name ?? "")}'`;
|
|
50
|
+
}
|
|
51
|
+
if (typeof fields.description !== "string" || !fields.description.trim())
|
|
52
|
+
return "frontmatter needs a description";
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The SKILL.md of a profile a Recipe brings by path: the folder or the file,
|
|
57
|
+
* inside the Recipe by its real path, following the contract.
|
|
58
|
+
*/
|
|
59
|
+
export function recipeProfileSkill(profile, recipeDir) {
|
|
60
|
+
const shape = documentProfileShapeProblem(profile);
|
|
61
|
+
if (shape)
|
|
62
|
+
throw new Error(`Document profile ${shape}`);
|
|
63
|
+
const target = resolve(recipeDir, profile);
|
|
64
|
+
if (!existsSync(target))
|
|
65
|
+
throw new Error(`Document profile ${profile} doesn't exist in the Recipe`);
|
|
66
|
+
// Where it really resolves: a symlink inside the Recipe can point outside it.
|
|
67
|
+
assertRecipePathContained(recipeDir, target, `document profile ${profile}`);
|
|
68
|
+
const skill = statSync(target).isDirectory() ? join(target, "SKILL.md") : target;
|
|
69
|
+
if (basename(skill) !== "SKILL.md")
|
|
70
|
+
throw new Error(`Document profile ${profile} must be a folder holding a SKILL.md, or that SKILL.md`);
|
|
71
|
+
if (!existsSync(skill))
|
|
72
|
+
throw new Error(`Document profile ${profile} has no SKILL.md`);
|
|
73
|
+
assertRecipePathContained(recipeDir, skill, `document profile ${profile}`);
|
|
74
|
+
const problem = documentProfileSkillProblem(skill);
|
|
75
|
+
if (problem)
|
|
76
|
+
throw new Error(`Document profile ${profile}: SKILL.md ${problem}`);
|
|
77
|
+
return skill;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The SKILL.md a declaration's `profile` selects: one the format ships, by
|
|
81
|
+
* name (case-insensitive), or the Recipe's own, by relative path.
|
|
82
|
+
*/
|
|
83
|
+
export function resolveDocumentProfile(profile, options) {
|
|
84
|
+
if (isDocumentProfilePath(profile))
|
|
85
|
+
return recipeProfileSkill(profile, options.recipeDir);
|
|
86
|
+
const shipped = options.shipped ?? {};
|
|
87
|
+
const found = Object.keys(shipped).find((name) => name.toLowerCase() === profile.toLowerCase());
|
|
88
|
+
if (found)
|
|
89
|
+
return shipped[found];
|
|
90
|
+
const names = Object.keys(shipped);
|
|
91
|
+
throw new Error(`Unknown document profile '${profile}': the ${options.format} format ships ${names.length ? names.join(", ") : "no profiles"}. ` +
|
|
92
|
+
"Bring your own as a relative path to a profile folder in the Recipe.");
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/documents/profile.ts"],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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAChG,IAAI,KAAK;QAAE,OAAO,OAAO,CAAC,KAAK,CAAE,CAAC;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,IAAI,KAAK,CACb,6BAA6B,OAAO,UAAU,OAAO,CAAC,MAAM,iBAAiB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI;QAC9H,sEAAsE,CACzE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DocumentResult } from "./types.js";
|
|
2
|
+
/** Names an interpreter for every document helper, winning over the prepared one (tests, custom hosts). */
|
|
3
|
+
export declare const RECIPE_DOCUMENTS_PYTHON_ENV = "RECIPE_DOCUMENTS_PYTHON";
|
|
4
|
+
/**
|
|
5
|
+
* The interpreter a document helper runs with, first match wins:
|
|
6
|
+
*
|
|
7
|
+
* 1. `RECIPE_DOCUMENTS_PYTHON`: an explicit override (tests, custom hosts).
|
|
8
|
+
* 2. `python`: the interpreter of the format package's own environment, which
|
|
9
|
+
* the host prepares from the package's `pi.runtime.python` and passes to
|
|
10
|
+
* `createAdapter`. A Recipe declares no Python for its documents.
|
|
11
|
+
* 3. `VIRTUAL_ENV`: an activated environment, for hosts that pass none.
|
|
12
|
+
* 4. `python3` from `PATH`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function documentPythonExecutable(env?: NodeJS.ProcessEnv, python?: string, platform?: NodeJS.Platform): string;
|
|
15
|
+
export interface DocumentHelperOptions {
|
|
16
|
+
env: NodeJS.ProcessEnv;
|
|
17
|
+
cwd: string;
|
|
18
|
+
/** The format package's prepared interpreter; see `documentPythonExecutable`. */
|
|
19
|
+
python?: string;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Run one document helper request with `runPythonJson`: JSON on stdin, a
|
|
25
|
+
* `DocumentResult` on stdout. A helper that answers `{ "error": ... }` fails
|
|
26
|
+
* the tool call with that message; `details.timing.call_ms` records the
|
|
27
|
+
* round trip.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runDocumentHelper(script: string, request: Record<string, unknown>, options: DocumentHelperOptions): Promise<DocumentResult>;
|
|
30
|
+
//# sourceMappingURL=python.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/documents/python.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,2GAA2G;AAC3G,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AAErE;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAER;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CA8BzB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PythonJsonError, pythonExecutable, runPythonJson } from "../python.js";
|
|
2
|
+
/** Names an interpreter for every document helper, winning over the prepared one (tests, custom hosts). */
|
|
3
|
+
export const RECIPE_DOCUMENTS_PYTHON_ENV = "RECIPE_DOCUMENTS_PYTHON";
|
|
4
|
+
/**
|
|
5
|
+
* The interpreter a document helper runs with, first match wins:
|
|
6
|
+
*
|
|
7
|
+
* 1. `RECIPE_DOCUMENTS_PYTHON`: an explicit override (tests, custom hosts).
|
|
8
|
+
* 2. `python`: the interpreter of the format package's own environment, which
|
|
9
|
+
* the host prepares from the package's `pi.runtime.python` and passes to
|
|
10
|
+
* `createAdapter`. A Recipe declares no Python for its documents.
|
|
11
|
+
* 3. `VIRTUAL_ENV`: an activated environment, for hosts that pass none.
|
|
12
|
+
* 4. `python3` from `PATH`.
|
|
13
|
+
*/
|
|
14
|
+
export function documentPythonExecutable(env = process.env, python, platform = process.platform) {
|
|
15
|
+
return pythonExecutable({ env, ...(python ? { python } : {}), override: RECIPE_DOCUMENTS_PYTHON_ENV, platform });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Run one document helper request with `runPythonJson`: JSON on stdin, a
|
|
19
|
+
* `DocumentResult` on stdout. A helper that answers `{ "error": ... }` fails
|
|
20
|
+
* the tool call with that message; `details.timing.call_ms` records the
|
|
21
|
+
* round trip.
|
|
22
|
+
*/
|
|
23
|
+
export async function runDocumentHelper(script, request, options) {
|
|
24
|
+
const started = performance.now();
|
|
25
|
+
let output;
|
|
26
|
+
try {
|
|
27
|
+
output = await runPythonJson(script, request, {
|
|
28
|
+
python: documentPythonExecutable(options.env, options.python),
|
|
29
|
+
env: options.env,
|
|
30
|
+
cwd: options.cwd,
|
|
31
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
32
|
+
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (!(error instanceof PythonJsonError))
|
|
37
|
+
throw error;
|
|
38
|
+
const reported = helperError(error.output);
|
|
39
|
+
if (reported !== undefined)
|
|
40
|
+
throw new Error(reported);
|
|
41
|
+
const cause = error.cause instanceof Error ? error.cause.message : "no output";
|
|
42
|
+
throw new Error(`document helper failed: ${(error.stderr || cause).slice(-600)}`);
|
|
43
|
+
}
|
|
44
|
+
const reported = helperError(output);
|
|
45
|
+
if (reported !== undefined)
|
|
46
|
+
throw new Error(reported);
|
|
47
|
+
const result = output;
|
|
48
|
+
if (!result || typeof result.text !== "string") {
|
|
49
|
+
throw new Error("document helper failed: no output");
|
|
50
|
+
}
|
|
51
|
+
const timing = (result.details?.timing ?? {});
|
|
52
|
+
result.details = {
|
|
53
|
+
...result.details,
|
|
54
|
+
timing: { ...timing, call_ms: Math.round(performance.now() - started) },
|
|
55
|
+
};
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function helperError(output) {
|
|
59
|
+
if (output && typeof output === "object" && typeof output.error === "string") {
|
|
60
|
+
return output.error;
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../src/documents/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGhF,2GAA2G;AAC3G,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAG,GAAsB,OAAO,CAAC,GAAG,EACpC,MAAe,EACf,QAAQ,GAAoB,OAAO,CAAC,QAAQ;IAE5C,OAAO,gBAAgB,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,2BAA2B,EAAE,QAAQ,EAAE,CAAC,CAAC;AACnH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AC;IACD,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,MAAyE,CAAC;IACzF,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,CAA2B,CAAC;IACxE,MAAM,CAAC,OAAO,GAAG;QACf,GAAG,MAAM,CAAC,OAAO;QACjB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE;KACxE,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,MAAe;IAClC,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAQ,MAA8B,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtG,OAAQ,MAA4B,CAAC,KAAK,CAAC;IAC7C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/extensions.d.ts
CHANGED
|
@@ -9,7 +9,23 @@ export interface RecipeExtensionSessionContext {
|
|
|
9
9
|
readonly session: {
|
|
10
10
|
readonly role: "root" | "subagent";
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* The interpreter the host prepared for a direct dependency that declares
|
|
14
|
+
* `pi.runtime.python`, by package name; `undefined` when that package
|
|
15
|
+
* declares none or is not a direct dependency. Pass it to
|
|
16
|
+
* `pythonExecutable({ python })` from `@introspection-ai/recipes/python`.
|
|
17
|
+
*/
|
|
18
|
+
packagePython(name: string): string | undefined;
|
|
12
19
|
}
|
|
20
|
+
/** @internal Build the frozen context a host binds to its extensions. */
|
|
21
|
+
export declare function createRecipeExtensionSessionContext(options: {
|
|
22
|
+
recipe: string;
|
|
23
|
+
agent: string;
|
|
24
|
+
role: "root" | "subagent";
|
|
25
|
+
python?: Readonly<Record<string, {
|
|
26
|
+
readonly interpreter: string;
|
|
27
|
+
}>>;
|
|
28
|
+
}): RecipeExtensionSessionContext;
|
|
13
29
|
export interface RecipeExtensionRegistrationRegistry {
|
|
14
30
|
claim(kind: string, name: string, owner: string): void;
|
|
15
31
|
release(kind: string, name: string, owner: string): void;
|