@introspection-ai/operator 0.1.3 → 0.1.4
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.
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
// Which Recipe session, if any, loaded an extension instance.
|
|
2
2
|
//
|
|
3
|
-
// The
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
3
|
+
// The Operator runs as a Recipe (`introspection init --operator` starts `pi --recipe <operator>`), and only then
|
|
4
|
+
// should its extensions act. Recipes binds a session context to every extension instance it loads
|
|
5
|
+
// (`getRecipeSessionContext`); an instance without one, or from another Recipe, does nothing.
|
|
6
|
+
//
|
|
7
|
+
// The import is static on purpose: Recipes' loader points a static import of `@introspection-ai/recipes` at the
|
|
8
|
+
// host's copy, which a dynamic `import()` from the Operator's own folder can't reach once the Operator is installed
|
|
9
|
+
// without its peers (`~/.introspection/operator`).
|
|
9
10
|
import { readFileSync } from "node:fs";
|
|
10
11
|
|
|
12
|
+
import { getRecipeSessionContext } from "@introspection-ai/recipes/extensions";
|
|
13
|
+
|
|
11
14
|
/** The name the package runs under as a Recipe: its package.json name. */
|
|
12
15
|
export const OPERATOR = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).name;
|
|
13
16
|
|
|
14
|
-
/**
|
|
15
|
-
* The Recipe session context bound to this instance, or undefined when Recipes didn't load it. Recipes resolves
|
|
16
|
-
* `@introspection-ai/recipes` for the extensions it loads, to the Recipe's own copy or its own; an instance Pi
|
|
17
|
-
* loaded may not find the package at all, which also means it isn't in a Recipe session.
|
|
18
|
-
*/
|
|
17
|
+
/** The Recipe session context bound to this instance, or undefined when Recipes didn't load it. */
|
|
19
18
|
export async function recipeSession(pi) {
|
|
20
|
-
let api;
|
|
21
|
-
try {
|
|
22
|
-
api = await import("@introspection-ai/recipes/extensions");
|
|
23
|
-
} catch {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
19
|
try {
|
|
27
|
-
return
|
|
20
|
+
return getRecipeSessionContext(pi);
|
|
28
21
|
} catch {
|
|
29
22
|
return undefined;
|
|
30
23
|
}
|
package/package.json
CHANGED