@introspection-ai/recipes 0.38.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 +3 -1
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +1 -0
- package/dist/documents/index.js.map +1 -1
- package/dist/documents/module.d.ts +17 -8
- package/dist/documents/module.d.ts.map +1 -1
- package/dist/documents/module.js +2 -1
- package/dist/documents/module.js.map +1 -1
- 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-EQCSXVQ7.js → chunk-ZK2E4S7E.js} +2035 -165
- 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 +14 -0
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +87 -0
- 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 +39 -17
- package/docs/pi-extension.md +4 -1
- package/docs/recipe-format.md +99 -4
- package/package.json +10 -5
package/docs/recipe-format.md
CHANGED
|
@@ -382,10 +382,105 @@ first model call or reject the Recipe with an actionable diagnostic.
|
|
|
382
382
|
```
|
|
383
383
|
|
|
384
384
|
`python.project` names a Recipe-relative Python project directory and
|
|
385
|
-
`python.lockfile` names its committed `uv.lock
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
dependency graph.
|
|
385
|
+
`python.lockfile` names its committed `uv.lock`, which must be the
|
|
386
|
+
`uv.lock` beside the project's `pyproject.toml`. Hosts MUST install with
|
|
387
|
+
frozen resolution (`uv sync --frozen --no-dev`) and MUST NOT install into
|
|
388
|
+
system Python or resolve an unlocked dependency graph. `version` is passed to
|
|
389
|
+
uv as the interpreter request. `imports` are optional boot preflights, each a
|
|
390
|
+
dotted Python module name (`docx`, `paper_docx.api`); hosts import them with
|
|
391
|
+
`PYTHONHOME` removed.
|
|
392
|
+
|
|
393
|
+
### Package declarations
|
|
394
|
+
|
|
395
|
+
A package the Recipe depends on MAY declare `pi.runtime.python` in its own
|
|
396
|
+
`package.json`, with the same fields relative to the package. Hosts read it
|
|
397
|
+
from each direct `dependencies` or `peerDependencies` entry installed in the
|
|
398
|
+
Recipe's `node_modules`; `devDependencies` and transitive dependencies are
|
|
399
|
+
not read, and a declared dependency that is not installed is skipped. A
|
|
400
|
+
package declaring it MUST ship the project's `pyproject.toml` and `uv.lock`:
|
|
401
|
+
when its `package.json` lists `files`, both must be covered. `pi.runtime.system`
|
|
402
|
+
is a Recipe-only declaration.
|
|
403
|
+
|
|
404
|
+
Each declaration gets its own environment:
|
|
405
|
+
|
|
406
|
+
- **The Recipe's own declaration is the shell environment.** Hosts activate
|
|
407
|
+
it for the agent's shell tools: `VIRTUAL_ENV` and `UV_PROJECT_ENVIRONMENT`
|
|
408
|
+
name it, its `bin` (`Scripts` on Windows) comes first on `PATH`, and
|
|
409
|
+
`PYTHONHOME` is removed.
|
|
410
|
+
- **Each package's declaration gets a separate environment**, installed with
|
|
411
|
+
`--no-editable` and never activated or put on `PATH`. The host hands the
|
|
412
|
+
package its interpreter; a documents format receives it as
|
|
413
|
+
`createAdapter({ env, cwd, python })`.
|
|
414
|
+
|
|
415
|
+
A package extension asks for a package's interpreter with
|
|
416
|
+
`packagePython(name)` on its session context, by the package's name; it is
|
|
417
|
+
`undefined` when that package declares no `pi.runtime.python` or is not a
|
|
418
|
+
direct dependency. `@introspection-ai/recipes/python` runs a script with it:
|
|
419
|
+
`pythonExecutable({ python, env, override })` picks the interpreter
|
|
420
|
+
(`env[override]`, then `python`, then `VIRTUAL_ENV`, then `python3`), and
|
|
421
|
+
`runPythonJson(script, request, { python, env, cwd, signal, timeoutMs })`
|
|
422
|
+
runs `python -I <script>` with the request as JSON on stdin and resolves its
|
|
423
|
+
stdout parsed as JSON (default timeout 300 s, 64 MB output):
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
import { getRecipeSessionContext } from "@introspection-ai/recipes/extensions";
|
|
427
|
+
import { pythonExecutable, runPythonJson } from "@introspection-ai/recipes/python";
|
|
428
|
+
|
|
429
|
+
export default function tables(pi) {
|
|
430
|
+
const python = pythonExecutable({
|
|
431
|
+
python: getRecipeSessionContext(pi).packagePython("@acme/recipe-tables"),
|
|
432
|
+
override: "ACME_TABLES_PYTHON",
|
|
433
|
+
});
|
|
434
|
+
// ... later, in a tool:
|
|
435
|
+
// await runPythonJson(helperScript, { path }, { python, cwd: ctx.cwd });
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
No declaration has to agree with another: two packages may lock different
|
|
440
|
+
versions of the same library.
|
|
441
|
+
|
|
442
|
+
### Preparing environments
|
|
443
|
+
|
|
444
|
+
`prepareRecipePython(recipeDir, options)` from
|
|
445
|
+
`@introspection-ai/recipes/recipe` finds every declaration and prepares it:
|
|
446
|
+
|
|
447
|
+
- `mode: "check"` runs `uv sync --frozen --no-dev --check --offline`, then
|
|
448
|
+
`uv python find` with the environment active, and the import preflight. The
|
|
449
|
+
second step catches an environment whose interpreter no longer satisfies the
|
|
450
|
+
declared version or `requires-python`, which uv's check passes. It writes
|
|
451
|
+
nothing and uses no network.
|
|
452
|
+
- `mode: "sync"` checks first and installs only a missing or outdated
|
|
453
|
+
environment, with `uv sync --frozen --no-dev --compile-bytecode`. A current
|
|
454
|
+
environment is never recompiled.
|
|
455
|
+
- uv runs with `--no-python-downloads` unless `allowPythonDownloads` is set.
|
|
456
|
+
|
|
457
|
+
By default environments live in a shared cache,
|
|
458
|
+
`~/.introspection/python/<hash>`, keyed by the environment kind (shell or
|
|
459
|
+
package), platform and architecture, the `uv.lock` and `pyproject.toml`
|
|
460
|
+
contents, and the declared `version`. Without a declared `version` it also
|
|
461
|
+
keys on what uv would pick the interpreter from: `UV_PYTHON`, every
|
|
462
|
+
`.python-version` or `.python-versions` file from the project directory up to
|
|
463
|
+
the filesystem root, and uv's global pin. A Recipe project that is itself a
|
|
464
|
+
package (it has `[build-system]`, so it installs editable) also keys on its
|
|
465
|
+
directory. `environmentRoot` (or `PI_RECIPES_PYTHON_ROOT`) fixes the
|
|
466
|
+
location instead: the shell environment is `<root>/python` and each package's
|
|
467
|
+
`<root>/python-packages/<name>`, so a host baking environments into a Recipe
|
|
468
|
+
image passes `<recipe>/.pi`. Concurrent preparations of one environment are
|
|
469
|
+
serialised by a lock file beside it.
|
|
470
|
+
|
|
471
|
+
Each prepared environment reports its directory and interpreter, plus the
|
|
472
|
+
activation for the shell environment. Failures are named errors:
|
|
473
|
+
`RecipePythonUvMissingError` (uv not installed), `RecipePythonVersionError`
|
|
474
|
+
(no interpreter satisfies the version), `RecipePythonOutdatedError` (check
|
|
475
|
+
mode found an environment missing or not matching its lock) and
|
|
476
|
+
`RecipePythonImportError`.
|
|
477
|
+
|
|
478
|
+
**Hosts fail closed.** Pi's extension prepares in sync mode with interpreter
|
|
479
|
+
downloads allowed when it loads a Recipe, tells the user when a first build
|
|
480
|
+
downloads packages, and refuses to start the session if any environment fails.
|
|
481
|
+
The session API (`createAgentSession`) only checks: it never installs, so the
|
|
482
|
+
host prepares the environments before it creates sessions, and an unprepared
|
|
483
|
+
one fails construction.
|
|
389
484
|
|
|
390
485
|
System package ids name versioned, host-approved bundles. They are not apt,
|
|
391
486
|
brew, or shell commands. A host that does not provide a declared bundle MUST
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@introspection-ai/recipes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "The open format for vertical agents, built on Pi.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"types": "./dist/channels/index.d.ts",
|
|
68
68
|
"import": "./dist/channels/index.js"
|
|
69
69
|
},
|
|
70
|
+
"./python": {
|
|
71
|
+
"types": "./dist/python.d.ts",
|
|
72
|
+
"import": "./dist/python.js"
|
|
73
|
+
},
|
|
70
74
|
"./documents": {
|
|
71
75
|
"types": "./dist/documents/index.d.ts",
|
|
72
76
|
"import": "./dist/documents/index.js"
|
|
@@ -90,6 +94,7 @@
|
|
|
90
94
|
"@opentelemetry/api": "^1.9.1",
|
|
91
95
|
"ajv": "^8.20.0",
|
|
92
96
|
"mcporter": "0.16.1",
|
|
97
|
+
"minimatch": "^10.2.6",
|
|
93
98
|
"yaml": "^2.9.0"
|
|
94
99
|
},
|
|
95
100
|
"peerDependencies": {
|
|
@@ -111,10 +116,10 @@
|
|
|
111
116
|
"vitest": "^5.0.1"
|
|
112
117
|
},
|
|
113
118
|
"optionalDependencies": {
|
|
114
|
-
"@introspection-ai/mcp-client-linux-x64": "0.
|
|
115
|
-
"@introspection-ai/mcp-client-linux-arm64": "0.
|
|
116
|
-
"@introspection-ai/mcp-client-darwin-arm64": "0.
|
|
117
|
-
"@introspection-ai/mcp-client-darwin-x64": "0.
|
|
119
|
+
"@introspection-ai/mcp-client-linux-x64": "0.39.0",
|
|
120
|
+
"@introspection-ai/mcp-client-linux-arm64": "0.39.0",
|
|
121
|
+
"@introspection-ai/mcp-client-darwin-arm64": "0.39.0",
|
|
122
|
+
"@introspection-ai/mcp-client-darwin-x64": "0.39.0"
|
|
118
123
|
},
|
|
119
124
|
"scripts": {
|
|
120
125
|
"build": "pnpm build:ts && pnpm build:native",
|