@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 package's `pi` block has two readers. Recipes reads it when the package runs as a Recipe
4
- // (`pi --recipe <operator>`, which `introspection local` starts in a folder with no Recipe), and Pi reads it when
5
- // the package is installed with `pi install`, which loads every listed extension in every Pi session: the owner's
6
- // ordinary sessions, their own Recipe runs, and the Operator's own session a second time. Only Recipes binds a
7
- // session context to the instances it loads (`getRecipeSessionContext` from `@introspection-ai/recipes/extensions`),
8
- // so an instance with no context was loaded by Pi as a plain package, and must do nothing.
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 api.getRecipeSessionContext(pi);
20
+ return getRecipeSessionContext(pi);
28
21
  } catch {
29
22
  return undefined;
30
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@introspection-ai/operator",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The Introspection Operator: a Recipe and skills that build an agent with its owner (brainstorm, draft and review).",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {