@introspection-ai/recipes 0.38.0 → 0.40.1
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 +10 -4
- package/dist/channels/index.d.ts +2 -2
- package/dist/channels/index.d.ts.map +1 -1
- package/dist/channels/index.js +1 -1
- package/dist/channels/index.js.map +1 -1
- package/dist/channels/module.d.ts +18 -0
- package/dist/channels/module.d.ts.map +1 -1
- package/dist/channels/module.js +6 -0
- package/dist/channels/module.js.map +1 -1
- 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 +6 -0
- package/dist/connector-tools.d.ts.map +1 -1
- package/dist/connector-tools.js +26 -11
- package/dist/connector-tools.js.map +1 -1
- package/dist/documents/index.d.ts +4 -2
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +2 -1
- package/dist/documents/index.js.map +1 -1
- package/dist/documents/module.d.ts +44 -11
- package/dist/documents/module.d.ts.map +1 -1
- package/dist/documents/module.js +35 -24
- 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-EZKOZO3F.js} +5184 -1309
- 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/companions.d.ts +68 -0
- package/dist/recipe/companions.d.ts.map +1 -0
- package/dist/recipe/companions.js +149 -0
- package/dist/recipe/companions.js.map +1 -0
- package/dist/recipe/extensions.d.ts +6 -0
- package/dist/recipe/extensions.d.ts.map +1 -1
- package/dist/recipe/extensions.js +51 -14
- package/dist/recipe/extensions.js.map +1 -1
- package/dist/recipe/package.d.ts +72 -9
- package/dist/recipe/package.d.ts.map +1 -1
- package/dist/recipe/package.js +261 -76
- package/dist/recipe/package.js.map +1 -1
- package/dist/recipe/python.d.ts +152 -0
- package/dist/recipe/python.d.ts.map +1 -0
- package/dist/recipe/python.js +708 -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 +32 -16
- package/dist/recipe/resolve.js.map +1 -1
- package/dist/recipe/skills.d.ts +15 -1
- package/dist/recipe/skills.d.ts.map +1 -1
- package/dist/recipe/skills.js +26 -9
- package/dist/recipe/skills.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/agent-composition.md +2 -2
- package/docs/channels.md +55 -11
- package/docs/documents.md +109 -27
- package/docs/interactions.md +1 -1
- package/docs/pi-extension.md +4 -1
- package/docs/recipe-format.md +262 -62
- package/docs/slack.md +4 -5
- package/package.json +17 -7
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** The version of the running `@introspection-ai/recipes`. */
|
|
2
|
+
export declare function recipesVersion(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Companion package name to compatible version range, from
|
|
5
|
+
* `package.json#optionalDependencies`. Inside this repository a range reads
|
|
6
|
+
* `workspace:<range>`; the published manifest carries `<range>`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function companionPackages(): Readonly<Record<string, string>>;
|
|
9
|
+
/** Whether Recipes installs `name` alongside itself, so a Recipe may omit it. */
|
|
10
|
+
export declare function isCompanionPackage(name: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the host imports `name` itself and so always provides it: Recipes,
|
|
13
|
+
* and Recipes' own peers (the Pi packages and typebox).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isHostPeerPackage(name: string): boolean;
|
|
16
|
+
/** Where the running `@introspection-ai/recipes` is installed; companion packages resolve from here. */
|
|
17
|
+
export declare function hostRecipesDir(): string;
|
|
18
|
+
/** A channel or document format package, found for one Recipe. */
|
|
19
|
+
export interface ResolvedRecipePackage {
|
|
20
|
+
name: string;
|
|
21
|
+
/** The package's real directory. */
|
|
22
|
+
packageDir: string;
|
|
23
|
+
version: string;
|
|
24
|
+
/**
|
|
25
|
+
* `recipe`: resolved from the Recipe, a dependency it pins or a peer the
|
|
26
|
+
* platform provides in an ancestor `node_modules`. `host`: the copy installed
|
|
27
|
+
* alongside the running Recipes.
|
|
28
|
+
*/
|
|
29
|
+
source: "recipe" | "host";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Find `name` for the Recipe at `recipeDir`: the copy Node resolves from the
|
|
33
|
+
* Recipe first, else, for a companion package, the copy Node resolves from where
|
|
34
|
+
* `@introspection-ai/recipes` itself is installed (`hostDir`). Undefined when
|
|
35
|
+
* neither has it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveRecipePackage(recipeDir: string, name: string, hostDir?: string): ResolvedRecipePackage | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Fail when the package's `peerDependencies["@introspection-ai/recipes"]`
|
|
40
|
+
* range does not admit the running Recipes version, naming the package, its
|
|
41
|
+
* version and range, the running version, and the fix. A package declaring no
|
|
42
|
+
* range is not checked; neither is a `workspace:` link that names no range.
|
|
43
|
+
*/
|
|
44
|
+
export declare function assertRecipesCompatible(pkg: ResolvedRecipePackage, running?: string): void;
|
|
45
|
+
/** The contract a module must implement: its name in errors, and the version this host implements. */
|
|
46
|
+
export interface RecipeModuleApi {
|
|
47
|
+
name: string;
|
|
48
|
+
version: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fail when a loaded module declares an `apiVersion` other than the one this
|
|
52
|
+
* host implements. A module without one predates the contract version and
|
|
53
|
+
* imports Recipes itself, so `assertRecipesCompatible` covers it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function assertModuleApi(pkg: ResolvedRecipePackage, imported: unknown, api: RecipeModuleApi, running?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Import a channel or document format package for the Recipe at `recipeDir`,
|
|
58
|
+
* from the Recipe or the host (see `resolveRecipePackage`), checking it accepts
|
|
59
|
+
* the running Recipes version: its Recipes peer range when it declares one,
|
|
60
|
+
* and the contract version (`apiVersion`) its module declares. `what` names the declaration in errors,
|
|
61
|
+
* such as `Recipe channel 'slack'`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function loadRecipePackageModule(recipeDir: string, name: string, options: {
|
|
64
|
+
what: string;
|
|
65
|
+
api: RecipeModuleApi;
|
|
66
|
+
hostDir?: string;
|
|
67
|
+
}): Promise<unknown>;
|
|
68
|
+
//# sourceMappingURL=companions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"companions.d.ts","sourceRoot":"","sources":["../../src/recipe/companions.ts"],"names":[],"mappings":"AA0CA,8DAA8D;AAC9D,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAMpE;AAaD,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wGAAwG;AACxG,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAyB,GACjC,qBAAqB,GAAG,SAAS,CAOnC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,qBAAqB,EAAE,OAAO,GAAE,MAAyB,GAAG,IAAI,CAc5G;AAWD,sGAAsG;AACtG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,qBAAqB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAE,MAAyB,GAAG,IAAI,CAO7I;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,eAAe,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAChE,OAAO,CAAC,OAAO,CAAC,CAoBlB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import semver from "semver";
|
|
5
|
+
import { loadRecipeModule, packageEntry } from "./extensions.js";
|
|
6
|
+
import { resolveDependencyDir } from "./package.js";
|
|
7
|
+
/**
|
|
8
|
+
* Companion packages: the first-party channel and document format packages
|
|
9
|
+
* Recipes installs alongside itself, as its `optionalDependencies`. Installing
|
|
10
|
+
* `@introspection-ai/recipes` (Pi's npm folder, a runtime image, npm or npx)
|
|
11
|
+
* puts them in the same `node_modules`. A Recipe may declare `pi.channels` or
|
|
12
|
+
* `pi.documents` for one without listing its package, and the copy beside the
|
|
13
|
+
* running Recipes is used. A Recipe that lists the package in `dependencies`
|
|
14
|
+
* pins it, and its copy wins.
|
|
15
|
+
*
|
|
16
|
+
* `optionalDependencies` in this package's `package.json` is the one list
|
|
17
|
+
* (package name to the compatible version range); an installer can read it
|
|
18
|
+
* with `npm view @introspection-ai/recipes@<v> optionalDependencies --json`.
|
|
19
|
+
*/
|
|
20
|
+
const RECIPES_PACKAGE = "@introspection-ai/recipes";
|
|
21
|
+
/** This package's own `package.json`: `src/recipe` and `dist/recipe` both sit two levels below it. */
|
|
22
|
+
const recipesManifestPath = fileURLToPath(new URL("../../package.json", import.meta.url));
|
|
23
|
+
let recipesManifest;
|
|
24
|
+
/** Read on first use, so a bundle that never loads a package never looks for it. */
|
|
25
|
+
function readRecipesManifest() {
|
|
26
|
+
recipesManifest ??= JSON.parse(readFileSync(recipesManifestPath, "utf8"));
|
|
27
|
+
return recipesManifest;
|
|
28
|
+
}
|
|
29
|
+
/** The version of the running `@introspection-ai/recipes`. */
|
|
30
|
+
export function recipesVersion() {
|
|
31
|
+
return readRecipesManifest().version;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Companion package name to compatible version range, from
|
|
35
|
+
* `package.json#optionalDependencies`. Inside this repository a range reads
|
|
36
|
+
* `workspace:<range>`; the published manifest carries `<range>`.
|
|
37
|
+
*/
|
|
38
|
+
export function companionPackages() {
|
|
39
|
+
return Object.fromEntries(Object.entries(readRecipesManifest().optionalDependencies ?? {})
|
|
40
|
+
.filter(([name]) => isCompanionName(name))
|
|
41
|
+
.map(([name, range]) => [name, range.replace(/^workspace:/, "")]));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The published manifest's `optionalDependencies` also names the MCP client's
|
|
45
|
+
* platform binaries, which the release stamps in; only the tool packages
|
|
46
|
+
* (`@introspection-ai/recipe-*`) are companions.
|
|
47
|
+
*/
|
|
48
|
+
function isCompanionName(name) {
|
|
49
|
+
return name.startsWith(COMPANION_PREFIX);
|
|
50
|
+
}
|
|
51
|
+
const COMPANION_PREFIX = "@introspection-ai/recipe-";
|
|
52
|
+
/** Whether Recipes installs `name` alongside itself, so a Recipe may omit it. */
|
|
53
|
+
export function isCompanionPackage(name) {
|
|
54
|
+
return isCompanionName(name) && Object.hasOwn(readRecipesManifest().optionalDependencies ?? {}, name);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whether the host imports `name` itself and so always provides it: Recipes,
|
|
58
|
+
* and Recipes' own peers (the Pi packages and typebox).
|
|
59
|
+
*/
|
|
60
|
+
export function isHostPeerPackage(name) {
|
|
61
|
+
return name === RECIPES_PACKAGE || Object.hasOwn(readRecipesManifest().peerDependencies ?? {}, name);
|
|
62
|
+
}
|
|
63
|
+
/** Where the running `@introspection-ai/recipes` is installed; companion packages resolve from here. */
|
|
64
|
+
export function hostRecipesDir() {
|
|
65
|
+
return realpathSync(dirname(recipesManifestPath));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Find `name` for the Recipe at `recipeDir`: the copy Node resolves from the
|
|
69
|
+
* Recipe first, else, for a companion package, the copy Node resolves from where
|
|
70
|
+
* `@introspection-ai/recipes` itself is installed (`hostDir`). Undefined when
|
|
71
|
+
* neither has it.
|
|
72
|
+
*/
|
|
73
|
+
export function resolveRecipePackage(recipeDir, name, hostDir = hostRecipesDir()) {
|
|
74
|
+
const fromRecipe = resolveDependencyDir(recipeDir, name);
|
|
75
|
+
const source = fromRecipe ? "recipe" : "host";
|
|
76
|
+
const packageDir = fromRecipe ?? (isCompanionPackage(name) ? resolveDependencyDir(hostDir, name) : undefined);
|
|
77
|
+
if (!packageDir)
|
|
78
|
+
return undefined;
|
|
79
|
+
const manifest = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
|
|
80
|
+
return { name, packageDir, version: typeof manifest.version === "string" ? manifest.version : "0.0.0", source };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Fail when the package's `peerDependencies["@introspection-ai/recipes"]`
|
|
84
|
+
* range does not admit the running Recipes version, naming the package, its
|
|
85
|
+
* version and range, the running version, and the fix. A package declaring no
|
|
86
|
+
* range is not checked; neither is a `workspace:` link that names no range.
|
|
87
|
+
*/
|
|
88
|
+
export function assertRecipesCompatible(pkg, running = recipesVersion()) {
|
|
89
|
+
const manifest = JSON.parse(readFileSync(join(pkg.packageDir, "package.json"), "utf8"));
|
|
90
|
+
const declared = manifest.peerDependencies?.[RECIPES_PACKAGE];
|
|
91
|
+
if (typeof declared !== "string")
|
|
92
|
+
return;
|
|
93
|
+
// pnpm publishes `workspace:<range>` as `<range>`; `workspace:^` and the like
|
|
94
|
+
// only occur in an unpublished checkout, linked to this very package.
|
|
95
|
+
const range = declared.startsWith("workspace:") ? declared.slice("workspace:".length) : declared;
|
|
96
|
+
if (declared.startsWith("workspace:") && semver.validRange(range) === null)
|
|
97
|
+
return;
|
|
98
|
+
if (semver.satisfies(running, range, { includePrerelease: true }))
|
|
99
|
+
return;
|
|
100
|
+
throw new Error(`${describe(pkg)} requires ${RECIPES_PACKAGE} ${range}, but ${RECIPES_PACKAGE} ${running} is running. ${fix(pkg)}`);
|
|
101
|
+
}
|
|
102
|
+
function describe(pkg) {
|
|
103
|
+
const copy = pkg.source === "recipe" ? "resolved from the Recipe" : "installed alongside Recipes";
|
|
104
|
+
return `${pkg.name}@${pkg.version} (${copy}, ${pkg.packageDir})`;
|
|
105
|
+
}
|
|
106
|
+
function fix(pkg) {
|
|
107
|
+
return `Raise or remove the Recipe's pin on ${pkg.name} in its dependencies, or run \`introspection upgrade\`.`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Fail when a loaded module declares an `apiVersion` other than the one this
|
|
111
|
+
* host implements. A module without one predates the contract version and
|
|
112
|
+
* imports Recipes itself, so `assertRecipesCompatible` covers it.
|
|
113
|
+
*/
|
|
114
|
+
export function assertModuleApi(pkg, imported, api, running = recipesVersion()) {
|
|
115
|
+
const module = imported && typeof imported === "object" && "default" in imported ? imported.default : imported;
|
|
116
|
+
const declared = module && typeof module === "object" ? module.apiVersion : undefined;
|
|
117
|
+
if (declared === undefined || declared === api.version)
|
|
118
|
+
return;
|
|
119
|
+
throw new Error(`${describe(pkg)} implements ${api.name} API ${String(declared)}, but ${RECIPES_PACKAGE} ${running} implements ${api.name} API ${api.version}. ${fix(pkg)}`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Import a channel or document format package for the Recipe at `recipeDir`,
|
|
123
|
+
* from the Recipe or the host (see `resolveRecipePackage`), checking it accepts
|
|
124
|
+
* the running Recipes version: its Recipes peer range when it declares one,
|
|
125
|
+
* and the contract version (`apiVersion`) its module declares. `what` names the declaration in errors,
|
|
126
|
+
* such as `Recipe channel 'slack'`.
|
|
127
|
+
*/
|
|
128
|
+
export async function loadRecipePackageModule(recipeDir, name, options) {
|
|
129
|
+
const resolved = resolveRecipePackage(recipeDir, name, options.hostDir);
|
|
130
|
+
if (!resolved) {
|
|
131
|
+
throw new Error(isCompanionPackage(name)
|
|
132
|
+
? `${options.what} requires ${name}: add it to the Recipe dependencies, or reinstall Recipes, which installs it alongside itself (\`introspection upgrade\`)`
|
|
133
|
+
: `${options.what} requires ${name} in the Recipe dependencies`);
|
|
134
|
+
}
|
|
135
|
+
assertRecipesCompatible(resolved);
|
|
136
|
+
const entry = packageEntry(resolved.packageDir);
|
|
137
|
+
if (!entry)
|
|
138
|
+
throw new Error(`${options.what}: ${name} at ${resolved.packageDir} has no entry point`);
|
|
139
|
+
let imported;
|
|
140
|
+
try {
|
|
141
|
+
imported = await loadRecipeModule(recipeDir, entry);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
throw new Error(`${options.what}: failed to load ${name} from ${resolved.packageDir}`, { cause: error });
|
|
145
|
+
}
|
|
146
|
+
assertModuleApi(resolved, imported, options.api);
|
|
147
|
+
return imported;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=companions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"companions.js","sourceRoot":"","sources":["../../src/recipe/companions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;;;;;;;GAYG;AAEH,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAEpD,sGAAsG;AACtG,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAQ1F,IAAI,eAA4C,CAAC;AAEjD,oFAAoF;AACpF,SAAS,mBAAmB;IAC1B,eAAe,KAAK,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAoB,CAAC;IAC7F,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,cAAc;IAC5B,OAAO,mBAAmB,EAAE,CAAC,OAAO,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,oBAAoB,IA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
2
2
|
export declare function resolvePackageFromHost(specifier: string, hostEntry?: string | undefined): string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* The file an ESM `import` of the package at `packageDir` loads: its root
|
|
5
|
+
* export, whether written as `exports["."]` or as conditions at the top of
|
|
6
|
+
* `exports`; else `module` or `main`; else `index.js`, as Node defaults to.
|
|
7
|
+
*/
|
|
8
|
+
export declare function packageEntry(packageDir: string): string | undefined;
|
|
3
9
|
/**
|
|
4
10
|
* Load a recipe-declared extension module and return its factory. TS sources
|
|
5
11
|
* load through jiti with package aliases pinned to this package's resolved
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/recipe/extensions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAIxE,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAM,GAAG,SAA2B,GAC9C,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/recipe/extensions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAIxE,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,MAAM,GAAG,SAA2B,GAC9C,MAAM,GAAG,SAAS,CAepB;AA8BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmBnE;AAyED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAY3B;AAED,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAQlB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, realpathSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
2
2
|
import { createRequire, findPackageJSON } from "node:module";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -16,24 +16,61 @@ export function resolvePackageFromHost(specifier, hostEntry = process.argv[1]) {
|
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
18
|
const manifestPath = findPackageJSON(specifier, realHostEntry);
|
|
19
|
-
|
|
20
|
-
return undefined;
|
|
21
|
-
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
22
|
-
const rootExport = typeof manifest.exports === "string"
|
|
23
|
-
? manifest.exports
|
|
24
|
-
: manifest.exports?.["."];
|
|
25
|
-
const entry = typeof rootExport === "string"
|
|
26
|
-
? rootExport
|
|
27
|
-
: rootExport?.import ??
|
|
28
|
-
rootExport?.default ??
|
|
29
|
-
manifest.module ??
|
|
30
|
-
manifest.main;
|
|
31
|
-
return entry ? resolve(dirname(manifestPath), entry) : undefined;
|
|
19
|
+
return manifestPath ? packageEntry(dirname(manifestPath)) : undefined;
|
|
32
20
|
}
|
|
33
21
|
catch {
|
|
34
22
|
return undefined;
|
|
35
23
|
}
|
|
36
24
|
}
|
|
25
|
+
/** The conditions an ESM `import` in Node matches, in Node's order of preference. */
|
|
26
|
+
const IMPORT_CONDITIONS = ["import", "node", "default"];
|
|
27
|
+
/**
|
|
28
|
+
* The target an `exports` value resolves to for an ESM import, following
|
|
29
|
+
* Node's rules: a string is the target, an array is tried in order, and a
|
|
30
|
+
* conditions object takes its first key, in its own order, that `import` in
|
|
31
|
+
* Node matches.
|
|
32
|
+
*/
|
|
33
|
+
function exportTarget(value) {
|
|
34
|
+
if (typeof value === "string")
|
|
35
|
+
return value;
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
for (const item of value) {
|
|
38
|
+
const target = exportTarget(item);
|
|
39
|
+
if (target)
|
|
40
|
+
return target;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
if (value && typeof value === "object") {
|
|
45
|
+
for (const [condition, nested] of Object.entries(value)) {
|
|
46
|
+
if (!IMPORT_CONDITIONS.includes(condition))
|
|
47
|
+
continue;
|
|
48
|
+
const target = exportTarget(nested);
|
|
49
|
+
if (target)
|
|
50
|
+
return target;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The file an ESM `import` of the package at `packageDir` loads: its root
|
|
57
|
+
* export, whether written as `exports["."]` or as conditions at the top of
|
|
58
|
+
* `exports`; else `module` or `main`; else `index.js`, as Node defaults to.
|
|
59
|
+
*/
|
|
60
|
+
export function packageEntry(packageDir) {
|
|
61
|
+
const manifest = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
|
|
62
|
+
const { exports } = manifest;
|
|
63
|
+
const isSubpathMap = !!exports &&
|
|
64
|
+
typeof exports === "object" &&
|
|
65
|
+
!Array.isArray(exports) &&
|
|
66
|
+
Object.keys(exports).some((key) => key.startsWith("."));
|
|
67
|
+
const rootExport = isSubpathMap ? exports["."] : exports;
|
|
68
|
+
const entry = exportTarget(rootExport) ??
|
|
69
|
+
manifest.module ??
|
|
70
|
+
manifest.main ??
|
|
71
|
+
(existsSync(join(packageDir, "index.js")) ? "index.js" : undefined);
|
|
72
|
+
return entry ? resolve(packageDir, entry) : undefined;
|
|
73
|
+
}
|
|
37
74
|
function resolvePackage(specifier) {
|
|
38
75
|
try {
|
|
39
76
|
return import.meta.resolve(specifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../src/recipe/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3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;
|
|
55
55
|
imports: string[];
|
|
56
56
|
}
|
|
57
|
-
export interface RecipeSystemPackageRequirement {
|
|
58
|
-
id: string;
|
|
59
|
-
version: string;
|
|
60
|
-
}
|
|
61
57
|
export interface RecipeRuntimeRequirements {
|
|
62
58
|
python?: RecipePythonRuntimeRequirement;
|
|
63
|
-
system: {
|
|
64
|
-
packages: RecipeSystemPackageRequirement[];
|
|
65
|
-
};
|
|
66
59
|
}
|
|
67
60
|
export interface RecipePackageManifest {
|
|
68
61
|
name: string;
|
|
@@ -83,19 +76,89 @@ export interface RecipeValidationFinding {
|
|
|
83
76
|
code: string;
|
|
84
77
|
message: string;
|
|
85
78
|
packageName?: string;
|
|
79
|
+
/** Absent for an error. A warning never makes a report invalid. */
|
|
80
|
+
severity?: "warning";
|
|
86
81
|
}
|
|
82
|
+
/** The findings that make a report invalid: every finding but warnings. */
|
|
83
|
+
export declare function recipeValidationErrors(findings: readonly RecipeValidationFinding[]): RecipeValidationFinding[];
|
|
87
84
|
export interface RecipeValidationReport {
|
|
88
85
|
valid: boolean;
|
|
89
86
|
findings: RecipeValidationFinding[];
|
|
90
87
|
}
|
|
91
|
-
|
|
88
|
+
/** Whether `value` is a dotted Python module name such as `docx` or `paper_docx.api`. */
|
|
89
|
+
export declare function isPythonModuleName(value: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Throw unless `path`'s real path is inside `packageDir`'s real path. `owner`
|
|
92
|
+
* starts the message; a dependency package passes `Dependency <name>`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function assertRecipePathContained(packageDir: string, path: string, label: string, owner?: string): void;
|
|
92
95
|
export declare class RecipePackageError extends Error {
|
|
93
96
|
constructor(message: string);
|
|
94
97
|
}
|
|
95
98
|
export declare function readPiPackageManifest(packageDir: string): RecipePackageManifest;
|
|
96
99
|
export declare function resolvePiPackageMcpManifestPaths(pkg: RecipePackageManifest): string[];
|
|
97
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Resolve a package's declared resources of one kind. `owner` names the
|
|
102
|
+
* package in errors: the Recipe by default, `Dependency <name>` for a
|
|
103
|
+
* dependency package.
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolvePiPackageResourcePaths(pkg: RecipePackageManifest, key: keyof RecipePackageResources, owner?: string): string[];
|
|
98
106
|
export declare function defaultPiPackageResourcePaths(pkg: RecipePackageManifest, key: keyof RecipePackageResources): string[];
|
|
99
107
|
export declare function packageResourcePaths(pkg: RecipePackageManifest, key: keyof RecipePackageResources): string[];
|
|
100
108
|
export declare function validatePiPackageManifest(pkg: RecipePackageManifest): RecipeValidationReport;
|
|
109
|
+
/**
|
|
110
|
+
* Validate the `pi.runtime.python` a dependency package (not the Recipe)
|
|
111
|
+
* declares: the same shape a Recipe's takes, a project directory holding
|
|
112
|
+
* `pyproject.toml` and its `uv.lock` inside the package, and, when the package
|
|
113
|
+
* lists `files`, both files shipped in it. Returns no requirement when the
|
|
114
|
+
* package declares none.
|
|
115
|
+
*/
|
|
116
|
+
export declare function validateRecipePythonPackage(packageDir: string): RecipeValidationReport & {
|
|
117
|
+
name: string;
|
|
118
|
+
python?: RecipePythonRuntimeRequirement;
|
|
119
|
+
};
|
|
120
|
+
/** A direct dependency of the Recipe, as Node resolves it from the Recipe directory. */
|
|
121
|
+
export interface InstalledRecipeDependency {
|
|
122
|
+
/** The name the Recipe's `package.json` declares it under. */
|
|
123
|
+
name: string;
|
|
124
|
+
/** The real path of the installed package (pnpm links into `.pnpm`). */
|
|
125
|
+
packageDir: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The directory of `name` as Node resolves it from `recipeDir`: the first
|
|
129
|
+
* `node_modules/<name>/package.json` walking up from the Recipe's real path,
|
|
130
|
+
* so a dependency hoisted beside the Recipe (npm, npx, `npm install --prefix`)
|
|
131
|
+
* is found as well as one nested inside it or linked by pnpm. A package with
|
|
132
|
+
* no entry point (a skills-only package) still resolves, because this reads
|
|
133
|
+
* Node's lookup folders rather than resolving an entry. Falls back to
|
|
134
|
+
* `findPackageJSON` for anything only Node's resolver can see.
|
|
135
|
+
*/
|
|
136
|
+
export declare function resolveDependencyDir(recipeDir: string, name: string): string | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The Recipe's direct dependencies that are installed, in declaration order,
|
|
139
|
+
* from the `package.json` blocks named by `keys`, each found with Node's
|
|
140
|
+
* resolution from the Recipe directory. Transitive dependencies are never
|
|
141
|
+
* read, and a declared dependency that does not resolve is skipped.
|
|
142
|
+
*/
|
|
143
|
+
export declare function installedRecipeDependencies(recipeDir: string, keys: readonly ("dependencies" | "peerDependencies")[]): InstalledRecipeDependency[];
|
|
144
|
+
/** One package's skill resources: the Recipe's own, or a dependency's `pi.skills`. */
|
|
145
|
+
export interface RecipeSkillResource {
|
|
146
|
+
/** A skill file or a directory searched for `SKILL.md`. */
|
|
147
|
+
path: string;
|
|
148
|
+
/** The package the resource must stay inside (a real path for a dependency). */
|
|
149
|
+
packageDir: string;
|
|
150
|
+
/** The dependency's name; absent for the Recipe's own skills. */
|
|
151
|
+
dependency?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The skill resources each direct `dependencies` or `peerDependencies` entry
|
|
155
|
+
* declares with an explicit `pi.skills`, resolved inside that package (a peer
|
|
156
|
+
* is provided by the platform, often from an ancestor `node_modules`). One
|
|
157
|
+
* that is not installed is skipped. Dev and transitive dependencies are not
|
|
158
|
+
* read, a dependency without `pi.skills`
|
|
159
|
+
* contributes nothing (its `skills/` folder is not discovered by convention),
|
|
160
|
+
* and an installed dependency whose `pi.skills` is malformed, unmatched or
|
|
161
|
+
* escapes the package throws an error naming it.
|
|
162
|
+
*/
|
|
163
|
+
export declare function recipeDependencySkillResources(recipeDir: string): RecipeSkillResource[];
|
|
101
164
|
//# sourceMappingURL=package.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/recipe/package.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"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