@introspection-ai/recipe-documents-docx 0.2.0 → 0.3.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 CHANGED
@@ -50,8 +50,22 @@ the folder's name, and point `profile` at it.
50
50
  [Write your own profile](../../../docs/documents.md#write-your-own-profile) has the
51
51
  contract, what a profile should say, and a complete example.
52
52
 
53
- The helpers in `python/` run with the Recipe's `pi.runtime.python` environment, which must
54
- provide `paper-docx==0.2.0`. `python/uv.lock` pins what the tests run on.
53
+ ## Python
54
+
55
+ The helpers in `python/` run in this package's own Python environment. The package
56
+ declares it in `package.json#pi.runtime.python` (`python/pyproject.toml`, locked by
57
+ `python/uv.lock`, with paper-docx), and the host prepares it with uv beside the Recipe and
58
+ passes its interpreter to the adapter. A Recipe declares no Python for Word: it needs none
59
+ of its own, and one it does declare is its agent's shell environment, which the helpers
60
+ don't use. This needs `@introspection-ai/recipes` 0.39.0 or later.
61
+
62
+ The interpreter is the first of:
63
+
64
+ 1. `RECIPE_DOCUMENTS_PYTHON`, an explicit override;
65
+ 2. the package environment's interpreter, from the host;
66
+ 3. `VIRTUAL_ENV` (`bin/python`, or `Scripts\python.exe` on Windows), for a host that
67
+ prepares no package environment;
68
+ 4. `python3` on `PATH`.
55
69
 
56
70
  Licences: the anchoring and section removal follow RedlineBench's redline engine (MIT,
57
71
  Crosby Legal), see `python/recipe_documents_docx/LICENSE-redline-bench`. The rest is Apache-2.0.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type DocumentAdapter, type DocumentAdapterContext, type DocumentCapabilities, type DocumentCommentInput, type DocumentProposeEditsInput, type DocumentReadInput, type DocumentRemoveSectionInput, type DocumentRespondInput, type DocumentReviseInput, type DocumentResult } from "@introspection-ai/recipes/documents";
2
- export { pythonExecutable, runHelper } from "./python.js";
2
+ export { documentPythonExecutable as pythonExecutable, runDocumentHelper as runHelper, } from "@introspection-ai/recipes/documents";
3
3
  /** The helper entry point shipped in this package. */
4
4
  export declare const DOCX_HELPER: string;
5
5
  /**
@@ -11,10 +11,15 @@ export declare const DOCX_DOCUMENT_CAPABILITIES: DocumentCapabilities;
11
11
  export declare class DocxDocumentAdapter implements DocumentAdapter {
12
12
  private readonly env;
13
13
  private readonly script;
14
+ private readonly python?;
14
15
  readonly format = "docx";
15
16
  readonly extensions: readonly [".docx"];
16
17
  readonly capabilities: DocumentCapabilities;
17
- constructor(env?: NodeJS.ProcessEnv, script?: string);
18
+ /**
19
+ * `python` is the interpreter of this package's environment, which the host
20
+ * prepares from its `pi.runtime.python`; see `pythonExecutable` for the order.
21
+ */
22
+ constructor(env?: NodeJS.ProcessEnv, script?: string, python?: string | undefined);
18
23
  private call;
19
24
  read(ctx: DocumentAdapterContext, input: DocumentReadInput): Promise<DocumentResult>;
20
25
  revise(ctx: DocumentAdapterContext, input: DocumentReviseInput): Promise<DocumentResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,qCAAqC,CAAC;AAI7C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1D,sDAAsD;AACtD,eAAO,MAAM,WAAW,QAAsE,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,oBAQxC,CAAC;AAEF,qBAAa,mBAAoB,YAAW,eAAe;IAK7C,OAAO,CAAC,QAAQ,CAAC,GAAG;IAAmC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJ1F,QAAQ,CAAC,MAAM,UAAU;IACzB,QAAQ,CAAC,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BAQxC,CAAC;AAEF,qBAAa,mBAAoB,YAAW,eAAe;IAUvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAX1B,QAAQ,CAAC,MAAM,UAAU;IACzB,QAAQ,CAAC,UAAU,YAAI,OAAO,EAAW;IACzC,QAAQ,CAAC,YAAY,uBAA8B;IAEnD;;;OAGG;IACH,YACmB,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,MAAM,SAAc,EACpB,MAAM,CAAC,EAAE,MAAM,YAAA,EAC9B;IAEJ,OAAO,CAAC,IAAI;IAIZ,IAAI,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,iBAAiB,2BAEzD;IAED,MAAM,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,mBAAmB,2BAE7D;IAED,YAAY,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,yBAAyB,2BAEzE;IAED,OAAO,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,oBAAoB,2BAE/D;IAED,OAAO,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,oBAAoB,2BAE/D;IAED,aAAa,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,EAAE,0BAA0B,2BAE3E;CACF;AAED;;;;;;;;;;GAUG;AACH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAwF,CAAC;AAE3H,eAAO,MAAM,wBAAwB,0EAMnC,CAAC;eAEY,wBAAwB"}
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { fileURLToPath } from "node:url";
2
- import { createDocumentFormatModule, } from "@introspection-ai/recipes/documents";
3
- import { runHelper } from "./python.js";
4
- export { pythonExecutable, runHelper } from "./python.js";
2
+ import { createDocumentFormatModule, runDocumentHelper, } from "@introspection-ai/recipes/documents";
3
+ export { documentPythonExecutable as pythonExecutable, runDocumentHelper as runHelper, } from "@introspection-ai/recipes/documents";
5
4
  /** The helper entry point shipped in this package. */
6
5
  export const DOCX_HELPER = fileURLToPath(new URL("../python/docx_helper.py", import.meta.url));
7
6
  /**
@@ -21,15 +20,21 @@ export const DOCX_DOCUMENT_CAPABILITIES = {
21
20
  export class DocxDocumentAdapter {
22
21
  env;
23
22
  script;
23
+ python;
24
24
  format = "docx";
25
25
  extensions = [".docx"];
26
26
  capabilities = DOCX_DOCUMENT_CAPABILITIES;
27
- constructor(env = process.env, script = DOCX_HELPER) {
27
+ /**
28
+ * `python` is the interpreter of this package's environment, which the host
29
+ * prepares from its `pi.runtime.python`; see `pythonExecutable` for the order.
30
+ */
31
+ constructor(env = process.env, script = DOCX_HELPER, python) {
28
32
  this.env = env;
29
33
  this.script = script;
34
+ this.python = python;
30
35
  }
31
36
  call(ctx, command, input) {
32
- return runHelper(this.script, { command, ...input }, { env: this.env, cwd: ctx.cwd, signal: ctx.signal });
37
+ return runDocumentHelper(this.script, { command, ...input }, { env: this.env, cwd: ctx.cwd, python: this.python, signal: ctx.signal });
33
38
  }
34
39
  read(ctx, input) {
35
40
  return this.call(ctx, "read", input);
@@ -71,7 +76,7 @@ export const docxDocumentFormatModule = createDocumentFormatModule({
71
76
  extensions: [".docx"],
72
77
  capabilities: DOCX_DOCUMENT_CAPABILITIES,
73
78
  profiles: { "legal-redlining-en-US": LEGAL_REDLINING_EN_US },
74
- createAdapter: ({ env }) => new DocxDocumentAdapter(env),
79
+ createAdapter: ({ env, python }) => new DocxDocumentAdapter(env, DOCX_HELPER, python),
75
80
  });
76
81
  export default docxDocumentFormatModule;
77
82
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,0BAA0B,GAW3B,MAAM,qCAAqC,CAAC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  {
2
2
  "name": "@introspection-ai/recipe-documents-docx",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Word (.docx) format for the Introspection Recipes documents tool: tracked edits, comments and responses on paper-docx.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -31,11 +31,25 @@
31
31
  },
32
32
  "./package.json": "./package.json"
33
33
  },
34
+ "pi": {
35
+ "runtime": {
36
+ "python": {
37
+ "project": "python",
38
+ "lockfile": "python/uv.lock",
39
+ "version": ">=3.12,<3.15",
40
+ "imports": [
41
+ "docx"
42
+ ]
43
+ }
44
+ }
45
+ },
46
+ "dependencies": {
47
+ "@introspection-ai/recipes": ">=0.39.0"
48
+ },
34
49
  "peerDependencies": {
35
- "@introspection-ai/recipes": ">=0.37.0 <1.0.0"
50
+ "@introspection-ai/recipes": ">=0.39.0"
36
51
  },
37
52
  "devDependencies": {
38
- "@introspection-ai/recipes": ">=0.37.0",
39
53
  "@types/node": "^26.1.2",
40
54
  "typescript": "^7.0.2"
41
55
  },
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "recipe-documents-docx"
3
3
  version = "0.1.0"
4
- description = "Python helpers the @introspection-ai/recipe-documents-docx adapter runs. For its tests; a Recipe brings its own environment with paper-docx."
4
+ description = "Python helpers the @introspection-ai/recipe-documents-docx adapter runs, in the environment the host prepares from the package's pi.runtime.python."
5
5
  requires-python = ">=3.12,<3.15"
6
6
  dependencies = ["paper-docx==0.2.0"]
7
7
 
package/dist/python.d.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * How the helpers run: the Recipe's own Python environment.
3
- *
4
- * The runtime activates `pi.runtime.python` as VIRTUAL_ENV, and that
5
- * environment must provide paper-docx. A package-level Python environment
6
- * is a follow-up; until then the Recipe declares the dependency.
7
- * `RECIPE_DOCUMENTS_PYTHON` overrides the interpreter (tests, custom hosts).
8
- */
9
- export declare function pythonExecutable(env?: NodeJS.ProcessEnv): string;
10
- export interface HelperResult {
11
- text: string;
12
- details?: Record<string, unknown>;
13
- images?: Array<{
14
- label: string;
15
- data: string;
16
- mimeType: string;
17
- }>;
18
- }
19
- /** Run one helper request: JSON on stdin, JSON on stdout. A helper error becomes the tool call's error. */
20
- export declare function runHelper(script: string, request: Record<string, unknown>, options: {
21
- env: NodeJS.ProcessEnv;
22
- cwd: string;
23
- signal?: AbortSignal;
24
- timeoutMs?: number;
25
- }): Promise<HelperResult>;
26
- //# sourceMappingURL=python.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../src/python.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAI7E;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE;AAED,2GAA2G;AAC3G,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzF,OAAO,CAAC,YAAY,CAAC,CAmCvB"}
package/dist/python.js DELETED
@@ -1,52 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { resolve } from "node:path";
3
- /**
4
- * How the helpers run: the Recipe's own Python environment.
5
- *
6
- * The runtime activates `pi.runtime.python` as VIRTUAL_ENV, and that
7
- * environment must provide paper-docx. A package-level Python environment
8
- * is a follow-up; until then the Recipe declares the dependency.
9
- * `RECIPE_DOCUMENTS_PYTHON` overrides the interpreter (tests, custom hosts).
10
- */
11
- export function pythonExecutable(env = process.env) {
12
- if (env.RECIPE_DOCUMENTS_PYTHON)
13
- return env.RECIPE_DOCUMENTS_PYTHON;
14
- if (env.VIRTUAL_ENV)
15
- return resolve(env.VIRTUAL_ENV, "bin", "python");
16
- return "python3";
17
- }
18
- /** Run one helper request: JSON on stdin, JSON on stdout. A helper error becomes the tool call's error. */
19
- export function runHelper(script, request, options) {
20
- const started = performance.now();
21
- return new Promise((resolvePromise, reject) => {
22
- const child = execFile(pythonExecutable(options.env), ["-I", script], {
23
- cwd: options.cwd,
24
- env: { ...options.env, PYTHONDONTWRITEBYTECODE: "1", PYTHONIOENCODING: "utf-8" },
25
- timeout: options.timeoutMs ?? 300_000,
26
- maxBuffer: 64 << 20,
27
- signal: options.signal,
28
- }, (error, stdout, stderr) => {
29
- let output;
30
- try {
31
- output = JSON.parse(String(stdout || "null"));
32
- }
33
- catch {
34
- output = undefined;
35
- }
36
- if (output && typeof output.error === "string")
37
- return reject(new Error(output.error));
38
- if (!output || typeof output.text !== "string") {
39
- const detail = String(stderr || error?.message || "no output").slice(-600);
40
- return reject(new Error(`document helper failed: ${detail}`));
41
- }
42
- const timing = (output.details?.timing ?? {});
43
- output.details = {
44
- ...output.details,
45
- timing: { ...timing, call_ms: Math.round(performance.now() - started) },
46
- };
47
- resolvePromise(output);
48
- });
49
- child.stdin?.end(JSON.stringify(request));
50
- });
51
- }
52
- //# sourceMappingURL=python.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"python.js","sourceRoot":"","sources":["../src/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAG,GAAsB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