@introspection-ai/recipe-documents-docx 0.1.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
@@ -4,12 +4,68 @@ The Word (`.docx`) format for the Recipes [`documents` tool](../../../docs/docum
4
4
  `read`, `propose_edits`, `comment`, `respond` and `remove_section`, on paper-docx.
5
5
  `render` is not registered.
6
6
 
7
+ ## With and without a profile
8
+
9
+ The tool is the same either way: the same commands, the same checks, and the original
10
+ is never changed. A profile only adds guidance the agent reads.
11
+
12
+ **Without a profile** — any Word work: editing a policy, filling a template, marking up
13
+ a memo, answering comments.
14
+
7
15
  ```json
8
16
  { "pi": { "documents": [{ "format": "docx" }] } }
9
17
  ```
10
18
 
11
- The helpers in `python/` run with the Recipe's `pi.runtime.python` environment, which must
12
- provide `paper-docx==0.2.0`. `python/uv.lock` pins what the tests run on.
19
+ The agent gets the core `documents` skill: which command fits which change, how to quote
20
+ text so an edit lands, and what to do when an edit fails. It says nothing about any one
21
+ kind of work, so the Recipe's own skills decide how changes should read.
22
+
23
+ **With `legal-redlining-en-US`** — contract redlines, and responses to the other side's
24
+ redline.
25
+
26
+ ```json
27
+ { "pi": { "documents": [{ "format": "docx", "profile": "legal-redlining-en-US" }] } }
28
+ ```
29
+
30
+ The agent also gets `profiles/legal-redlining-en-us/SKILL.md`, which covers:
31
+
32
+ - planning a first markup by what moves a right, an obligation or a risk;
33
+ - making the changes in `revise` batches, one rationale comment per change;
34
+ - removing a clause with `remove_section`, leaving `Reserved.` so numbering still lines up;
35
+ - answering the other side's changes with counters and replies, so the discussion stays
36
+ visible, rather than accepting or rejecting;
37
+ - writing each rationale as the reason, in your side's voice, never narrating the edit.
38
+
39
+ The profile is generic legal practice. A firm's own positions, playbook and comment
40
+ style belong in the Recipe's skills, beside it.
41
+
42
+ **Your own profile** — for another kind of work with its own way of using the tool,
43
+ write a profile in the Recipe: a folder holding a `SKILL.md` whose frontmatter `name` is
44
+ the folder's name, and point `profile` at it.
45
+
46
+ ```json
47
+ { "pi": { "documents": [{ "format": "docx", "profile": "./profiles/house-style-en-gb" }] } }
48
+ ```
49
+
50
+ [Write your own profile](../../../docs/documents.md#write-your-own-profile) has the
51
+ contract, what a profile should say, and a complete example.
52
+
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`.
13
69
 
14
70
  Licences: the anchoring and section removal follow RedlineBench's redline engine (MIT,
15
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>;
@@ -34,6 +39,11 @@ export declare class DocxDocumentAdapter implements DocumentAdapter {
34
39
  * tools: [documents]
35
40
  * ```
36
41
  */
42
+ /**
43
+ * Contract redlining in US English: how to plan a first markup and answer the
44
+ * other side's redline. A Recipe selects it with `"profile": "legal-redlining-en-US"`.
45
+ */
46
+ export declare const LEGAL_REDLINING_EN_US: string;
37
47
  export declare const docxDocumentFormatModule: import("@introspection-ai/recipes/documents").RecipeDocumentFormatModule;
38
48
  export default docxDocumentFormatModule;
39
49
  //# sourceMappingURL=index.d.ts.map
@@ -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,EAA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/B,MAAM,qCAAqC,CAAC;AAE7C,sDAAsD;AACtD,eAAO,MAAM,WAAW,QAAsE,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,oBAQxC,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);
@@ -61,11 +66,17 @@ export class DocxDocumentAdapter {
61
66
  * tools: [documents]
62
67
  * ```
63
68
  */
69
+ /**
70
+ * Contract redlining in US English: how to plan a first markup and answer the
71
+ * other side's redline. A Recipe selects it with `"profile": "legal-redlining-en-US"`.
72
+ */
73
+ export const LEGAL_REDLINING_EN_US = fileURLToPath(new URL("../profiles/legal-redlining-en-us/SKILL.md", import.meta.url));
64
74
  export const docxDocumentFormatModule = createDocumentFormatModule({
65
75
  format: "docx",
66
76
  extensions: [".docx"],
67
77
  capabilities: DOCX_DOCUMENT_CAPABILITIES,
68
- createAdapter: ({ env }) => new DocxDocumentAdapter(env),
78
+ profiles: { "legal-redlining-en-US": LEGAL_REDLINING_EN_US },
79
+ createAdapter: ({ env, python }) => new DocxDocumentAdapter(env, DOCX_HELPER, python),
69
80
  });
70
81
  export default docxDocumentFormatModule;
71
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;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1D,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,0BAA0B,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/F;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAyB;IAC9D,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,OAAO,mBAAmB;IAKD,GAAG;IAAoD,MAAM;IAJjF,MAAM,GAAG,MAAM,CAAC;IAChB,UAAU,GAAG,CAAC,OAAO,CAAU,CAAC;IAChC,YAAY,GAAG,0BAA0B,CAAC;IAEnD,YAA6B,GAAG,GAAsB,OAAO,CAAC,GAAG,EAAmB,MAAM,GAAG,WAAW;mBAA3E,GAAG;sBAAoD,MAAM;IAAiB,CAAC;IAEpG,IAAI,CAAC,GAA2B,EAAE,OAAe,EAAE,KAAa;QACtE,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,EA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AAG,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC;CACtF,CAAC,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@introspection-ai/recipe-documents-docx",
3
- "version": "0.1.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",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "dist",
12
+ "profiles",
12
13
  "python/*.py",
13
14
  "python/recipe_documents_docx/*.py",
14
15
  "python/recipe_documents_docx/LICENSE-redline-bench",
@@ -30,11 +31,25 @@
30
31
  },
31
32
  "./package.json": "./package.json"
32
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
+ },
33
49
  "peerDependencies": {
34
- "@introspection-ai/recipes": ">=0.37.0 <1.0.0"
50
+ "@introspection-ai/recipes": ">=0.39.0"
35
51
  },
36
52
  "devDependencies": {
37
- "@introspection-ai/recipes": ">=0.37.0",
38
53
  "@types/node": "^26.1.2",
39
54
  "typescript": "^7.0.2"
40
55
  },
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: legal-redlining-en-us
3
+ description: How to use the documents tool for a contract redline, or a response to the other side's redline (profile legal-redlining-en-US). Read it with the documents skill before changing a contract.
4
+ ---
5
+
6
+ # Documents for legal redlining
7
+
8
+ This profile layers on the core `documents` skill. Every change is a tracked change with
9
+ its rationale as a margin comment, written for the other side's lawyer to read.
10
+
11
+ ## A first markup
12
+
13
+ 1. `read` the brief and the whole contract, every part.
14
+ 2. Plan by priority before editing: what moves a right, an obligation or a risk. Leave
15
+ drafting preferences alone unless the brief asks for them.
16
+ 3. Make the changes in one `revise` batch, or as few as possible, in document order. For
17
+ each paragraph give its `paragraph` id, its full revised `text` (copy the current text
18
+ from `read` and change only what must move) and the `rationale`.
19
+ 4. Revise table cells by their ids (`p-105.r2c3`); a short rationale is fine for the cells
20
+ of a row that share a reason.
21
+ 5. Use `propose_edits` for a small fix after a batch, such as one figure, quoted from a
22
+ fresh `read`.
23
+ 6. Remove a whole numbered clause with `remove_section`: it strikes `from`..`through` and
24
+ leaves `Reserved.` after `keep` (the heading), so the numbering after it still lines
25
+ up. Strike a clause's words with `revise` only when the clause stays.
26
+
27
+ ## A response turn
28
+
29
+ Tracked changes and comments in a file aren't always the other side's. Sort them by
30
+ author first: some can be your own side's earlier turn, or your own edits from this
31
+ session. Treat it as a response turn only when the request says the file came back from
32
+ the other side, or the authors show it did. Then, for the other side's markup:
33
+
34
+ - Leave their changes in place and layer yours on top, so they see what you did.
35
+ - `respond` with `counter` answers one of their changes with your own tracked change,
36
+ inside their language, with the rationale on its `thread` when the point has one.
37
+ Prefer it to rejecting: a counter keeps the discussion visible.
38
+ - Agree with `respond` `{action: "reply", thread, text: "Accepted."}`. Accept or reject
39
+ only when the request asks to resolve changes for good, such as cleaning a draft
40
+ before it goes out; those leave no trace.
41
+ - Changes the tool says it can't accept or reject here are for the lawyer to resolve in
42
+ Word: list them in the open decisions.
43
+
44
+ ## Rationale
45
+
46
+ Write each rationale as the reason, in one or two sentences, in your side's voice: what
47
+ the change protects and why the original doesn't work for you. Never narrate the edit
48
+ ("Changed thirty to sixty"); the tracked change already shows it.
49
+
50
+ ## When an edit fails
51
+
52
+ Fix that edit from its reason and the closest text, and resubmit only it. An edit that
53
+ fails twice is skipped: list it under "Edits not applied" in the open decisions, and never
54
+ retry it by widening it to more text. Read the redline back once before you finish and
55
+ check every change has its rationale.
@@ -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,OAAO,CAAC,GAAG;IACnE,IAAI,GAAG,CAAC,uBAAuB;QAAE,OAAO,GAAG,CAAC,uBAAuB,CAAC;IACpE,IAAI,GAAG,CAAC,WAAW;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtE,OAAO,SAAS,CAAC;AACnB,CAAC;AAQD,2GAA2G;AAC3G,MAAM,UAAU,SAAS,CACvB,MAAc,EACd,OAAgC,EAChC,OAA0F;IAE1F,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAClC,OAAO,IAAI,OAAO,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,QAAQ,CACpB,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,EAC7B,CAAC,IAAI,EAAE,MAAM,CAAC,EACd;YACE,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,uBAAuB,EAAE,GAAG,EAAE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