@introspection-ai/recipes 0.22.1 → 0.24.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.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/dist/api/memory.d.ts +3 -0
  3. package/dist/api/memory.d.ts.map +1 -0
  4. package/dist/api/memory.js +2 -0
  5. package/dist/api/memory.js.map +1 -0
  6. package/dist/api/session.d.ts +1 -0
  7. package/dist/api/session.d.ts.map +1 -1
  8. package/dist/channels/config.d.ts +10 -0
  9. package/dist/channels/config.d.ts.map +1 -0
  10. package/dist/channels/config.js +13 -0
  11. package/dist/channels/config.js.map +1 -0
  12. package/dist/channels/index.d.ts +4 -2
  13. package/dist/channels/index.d.ts.map +1 -1
  14. package/dist/channels/index.js +2 -1
  15. package/dist/channels/index.js.map +1 -1
  16. package/dist/channels/module.d.ts +11 -6
  17. package/dist/channels/module.d.ts.map +1 -1
  18. package/dist/channels/module.js +22 -10
  19. package/dist/channels/module.js.map +1 -1
  20. package/dist/channels/refs.d.ts +3 -3
  21. package/dist/channels/refs.d.ts.map +1 -1
  22. package/dist/channels/refs.js +11 -8
  23. package/dist/channels/refs.js.map +1 -1
  24. package/dist/channels/tools.d.ts +15 -22
  25. package/dist/channels/tools.d.ts.map +1 -1
  26. package/dist/channels/tools.js +279 -114
  27. package/dist/channels/tools.js.map +1 -1
  28. package/dist/channels/types.d.ts +34 -29
  29. package/dist/channels/types.d.ts.map +1 -1
  30. package/dist/channels/types.js +4 -17
  31. package/dist/channels/types.js.map +1 -1
  32. package/dist/child-session.d.ts +3 -0
  33. package/dist/child-session.d.ts.map +1 -1
  34. package/dist/child-session.js +4 -0
  35. package/dist/child-session.js.map +1 -1
  36. package/dist/connector-tools.d.ts +2 -0
  37. package/dist/connector-tools.d.ts.map +1 -1
  38. package/dist/connector-tools.js +17 -15
  39. package/dist/connector-tools.js.map +1 -1
  40. package/dist/mcp-chunks/{chunk-JZDXKYQM.js → chunk-PLSS6TQZ.js} +6 -1
  41. package/dist/mcp-daemon.js +1 -1
  42. package/dist/mcp-run-worker.js +1 -1
  43. package/dist/memory.d.ts +40 -0
  44. package/dist/memory.d.ts.map +1 -0
  45. package/dist/memory.js +146 -0
  46. package/dist/memory.js.map +1 -0
  47. package/dist/recipe-package.d.ts +4 -2
  48. package/dist/recipe-package.d.ts.map +1 -1
  49. package/dist/recipe-package.js +31 -18
  50. package/dist/recipe-package.js.map +1 -1
  51. package/dist/run-controller.d.ts +3 -0
  52. package/dist/run-controller.d.ts.map +1 -1
  53. package/dist/run-controller.js +4 -0
  54. package/dist/run-controller.js.map +1 -1
  55. package/dist/session.d.ts +5 -0
  56. package/dist/session.d.ts.map +1 -1
  57. package/dist/session.js +26 -4
  58. package/dist/session.js.map +1 -1
  59. package/docs/channels.md +171 -58
  60. package/docs/host-api.md +21 -0
  61. package/docs/pi-extension.md +1 -1
  62. package/docs/recipe-format.md +9 -7
  63. package/docs/slack.md +46 -53
  64. package/package.json +9 -5
package/README.md CHANGED
@@ -133,7 +133,7 @@ tests.
133
133
  contract: capability descriptors, opaque message references, and the
134
134
  registration that binds every tool to the task's own conversation
135
135
  - `@introspection-ai/recipe-channel-slack` is the optional Slack adapter. A
136
- Recipe adds it as a dependency when it declares Slack in `pi.connectors`.
136
+ Recipe adds it as a dependency when it declares Slack in `pi.channels`.
137
137
  - `@introspection-ai/recipes/agents` — portable agent-run controller and tool
138
138
  contract
139
139
  - `@introspection-ai/recipes/interactions` — portable user-input and approval contract
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_MEMORY_INDEX_MAX_BYTES, DEFAULT_MEMORY_INDEX_MAX_LINES, MemoryContextConfigError, formatMemoryForPrompt, loadMemoryIndex, } from "../memory.js";
2
+ export type { LoadMemoryIndexOptions, LoadMemoryIndexResult, MemoryContextOverride, MemoryContextSource, MemoryDiagnostic, MemoryIndex, } from "../memory.js";
3
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/api/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { DEFAULT_MEMORY_INDEX_MAX_BYTES, DEFAULT_MEMORY_INDEX_MAX_LINES, MemoryContextConfigError, formatMemoryForPrompt, loadMemoryIndex, } from "../memory.js";
2
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/api/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,GAChB,MAAM,cAAc,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { createAgentSession, RecipeCredentialError, RecipeMcpEnvironmentInUseError, RecipeModelError, RecipeModelTransportError, } from "../session.js";
2
2
  export type { CreateAgentSessionOptions, RecipeSessionHandle, RecipeSessionOtelOptions, } from "../session.js";
3
+ export type { MemoryContextOverride, MemoryContextSource, } from "../memory.js";
3
4
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/api/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/api/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type ChannelEnvironment = Record<string, string | undefined>;
2
+ /** Provider-neutral destination supplied by the Recipe host. */
3
+ export interface ChannelConfig {
4
+ provider: string;
5
+ channel_ref: string;
6
+ thread_ref: string | null;
7
+ }
8
+ /** Read the channel destination shared by every provider package. */
9
+ export declare function resolveChannelConfig(env?: ChannelEnvironment): ChannelConfig | null;
10
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/channels/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEpE,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,kBAAgC,GACpC,aAAa,GAAG,IAAI,CAUtB"}
@@ -0,0 +1,13 @@
1
+ /** Read the channel destination shared by every provider package. */
2
+ export function resolveChannelConfig(env = process.env) {
3
+ const provider = env.INTROSPECTION_TASK_CHANNEL_PROVIDER?.trim();
4
+ const channelRef = env.INTROSPECTION_TASK_CHANNEL_ID?.trim();
5
+ if (!provider || !channelRef)
6
+ return null;
7
+ return {
8
+ provider,
9
+ channel_ref: channelRef,
10
+ thread_ref: env.INTROSPECTION_TASK_THREAD_ID?.trim() || null,
11
+ };
12
+ }
13
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/channels/config.ts"],"names":[],"mappings":"AASA,qEAAqE;AACrE,MAAM,UAAU,oBAAoB,CAClC,GAAG,GAAuB,OAAO,CAAC,GAAG;IAErC,MAAM,QAAQ,GAAG,GAAG,CAAC,mCAAmC,EAAE,IAAI,EAAE,CAAC;IACjE,MAAM,UAAU,GAAG,GAAG,CAAC,6BAA6B,EAAE,IAAI,EAAE,CAAC;IAC7D,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE1C,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,UAAU;QACvB,UAAU,EAAE,GAAG,CAAC,4BAA4B,EAAE,IAAI,EAAE,IAAI,IAAI;KAC7D,CAAC;AACJ,CAAC"}
@@ -1,7 +1,9 @@
1
1
  export { ChannelRefStore } from "./refs.js";
2
- export { CHANNEL_TOOL_IDS, channelConnectorTools, channelToolIdsFor, channelToolName, registerChannelTools, } from "./tools.js";
2
+ export { resolveChannelConfig } from "./config.js";
3
+ export type { ChannelConfig, ChannelEnvironment } from "./config.js";
4
+ export { CHANNEL_TOOL_IDS, channelConnectorTools, channelToolIdsFor, registerChannelTools, } from "./tools.js";
3
5
  export type { ChannelToolHost, ChannelToolId, RegisterChannelToolsOptions, } from "./tools.js";
4
6
  export { createChannelConnectorModule } from "./module.js";
5
7
  export type { ChannelConnectorModuleOptions, ChannelConnectorSession, } from "./module.js";
6
- export type { ChannelAdapter, ChannelAdapterContext, ChannelAttachment, ChannelAuthor, ChannelCapabilities, ChannelCursor, ChannelFileIdentity, ChannelReadPage, ChannelLocalFile, ChannelMessage, ChannelMessageIdentity, ChannelPostResult, ChannelReactionAction, ChannelRefResolver, ChannelTarget, FileRef, MessageRef, } from "./types.js";
8
+ export type { ChannelAdapter, ChannelAdapterContext, ChannelAttachment, ChannelAuthor, ChannelCapabilities, ChannelCursor, ChannelFileIdentity, ChannelListEntry, ChannelReadPage, ChannelLocalFile, ChannelMessage, ChannelMessageIdentity, ChannelPostResult, ChannelReactionAction, ChannelRefResolver, ChannelTarget, FileRef, MessageRef, } from "./types.js";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,eAAe,EACf,aAAa,EACb,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EACV,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,UAAU,GACX,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,eAAe,EACf,aAAa,EACb,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EACV,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { ChannelRefStore } from "./refs.js";
2
- export { CHANNEL_TOOL_IDS, channelConnectorTools, channelToolIdsFor, channelToolName, registerChannelTools, } from "./tools.js";
2
+ export { resolveChannelConfig } from "./config.js";
3
+ export { CHANNEL_TOOL_IDS, channelConnectorTools, channelToolIdsFor, registerChannelTools, } from "./tools.js";
3
4
  export { createChannelConnectorModule } from "./module.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC"}
@@ -1,9 +1,13 @@
1
1
  import type { RecipeConnectorModule } from "../connector-tools.js";
2
+ import type { ChannelConfig } from "./config.js";
3
+ import { type ChannelToolId } from "./tools.js";
2
4
  import type { ChannelAdapter, ChannelCapabilities, ChannelTarget } from "./types.js";
3
5
  export interface ChannelConnectorSession {
4
6
  readonly adapter: ChannelAdapter;
5
7
  /** Resolved lazily so a task with no channel origin still starts. */
6
8
  readonly target: ChannelTarget | (() => ChannelTarget);
9
+ /** Optional tool-layer target policy, not a sandbox egress boundary. */
10
+ readonly validateTarget?: (target: ChannelTarget, operation: ChannelToolId) => void | Promise<void>;
7
11
  }
8
12
  export interface ChannelConnectorModuleOptions {
9
13
  provider: string;
@@ -16,12 +20,13 @@ export interface ChannelConnectorModuleOptions {
16
20
  */
17
21
  capabilities: ChannelCapabilities;
18
22
  /**
19
- * Resolve the bound conversation and a client for it.
23
+ * Resolve the default conversation and a client for one credential session.
20
24
  *
21
- * Called once per session. Throwing is the right failure for a task with no
22
- * channel origin: the tools would have nowhere to act.
25
+ * Called once per session. Return a lazy target for originless tasks so
26
+ * explicit read/send calls can still use the credential session.
23
27
  */
24
28
  createSession(options: {
29
+ config: ChannelConfig | null;
25
30
  env: NodeJS.ProcessEnv;
26
31
  cwd: string;
27
32
  }): ChannelConnectorSession;
@@ -32,12 +37,12 @@ export interface ChannelConnectorModuleOptions {
32
37
  * A provider package supplies transport plus a capability descriptor; the
33
38
  * neutral tool schemas, the opaque handles, and the capability filtering live
34
39
  * here. Two providers therefore cannot drift into differently-shaped versions
35
- * of the same operation, and neither can quietly grow an addressing argument,
36
- * because neither writes a tool schema at all.
40
+ * of the same operation. Targeting uses the common capability and schema,
41
+ * not provider-defined arguments.
37
42
  *
38
43
  * The result satisfies the existing connector contract. The manifest selects
39
44
  * the provider package, the agent list selects tools from its catalog, and
40
- * `tool_search` exposes selected tools that are not active by default.
45
+ * `channels` is active immediately; the connector can restrict its commands.
41
46
  */
42
47
  export declare function createChannelConnectorModule(options: ChannelConnectorModuleOptions): RecipeConnectorModule;
43
48
  //# sourceMappingURL=module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/channels/module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAQnE,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE;QACrB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;KACb,GAAG,uBAAuB,CAAC;CAC7B;AAgBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,qBAAqB,CA+CvB"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/channels/module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC;IACvD,wEAAwE;IACxE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrG;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;QAC7B,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;KACb,GAAG,uBAAuB,CAAC;CAC7B;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,qBAAqB,CAqDvB"}
@@ -1,8 +1,11 @@
1
+ import { resolveChannelConfig } from "./config.js";
1
2
  import { ChannelRefStore } from "./refs.js";
2
3
  import { CHANNEL_TOOL_IDS, channelConnectorTools, registerChannelTools, } from "./tools.js";
3
4
  const channelToolIds = new Set(CHANNEL_TOOL_IDS);
4
5
  /** Whether two capability descriptors say the same thing. */
5
6
  function sameCapabilities(left, right) {
7
+ left = { ...left, targeting: left.targeting ?? false, list: left.list ?? false };
8
+ right = { ...right, targeting: right.targeting ?? false, list: right.list ?? false };
6
9
  const keys = Object.keys(right);
7
10
  return (Object.keys(left).length === keys.length &&
8
11
  keys.every((key) => left[key] === right[key]));
@@ -13,29 +16,37 @@ function sameCapabilities(left, right) {
13
16
  * A provider package supplies transport plus a capability descriptor; the
14
17
  * neutral tool schemas, the opaque handles, and the capability filtering live
15
18
  * here. Two providers therefore cannot drift into differently-shaped versions
16
- * of the same operation, and neither can quietly grow an addressing argument,
17
- * because neither writes a tool schema at all.
19
+ * of the same operation. Targeting uses the common capability and schema,
20
+ * not provider-defined arguments.
18
21
  *
19
22
  * The result satisfies the existing connector contract. The manifest selects
20
23
  * the provider package, the agent list selects tools from its catalog, and
21
- * `tool_search` exposes selected tools that are not active by default.
24
+ * `channels` is active immediately; the connector can restrict its commands.
22
25
  */
23
26
  export function createChannelConnectorModule(options) {
24
27
  const connectorTools = channelConnectorTools(options.capabilities);
25
- const deferredToolIds = new Set(connectorTools
26
- .filter((tool) => !tool.defaultActive)
27
- .map((tool) => tool.id));
28
28
  return {
29
29
  provider: options.provider,
30
30
  tools: connectorTools,
31
31
  createExtension(moduleOptions) {
32
- const unknown = moduleOptions.tools.filter((tool) => !channelToolIds.has(tool));
32
+ const unknown = moduleOptions.tools.filter((tool) => tool !== "channels");
33
33
  if (unknown.length > 0) {
34
34
  throw new Error(`Unknown ${options.provider} channel tool(s): ${unknown.join(", ")}`);
35
35
  }
36
- const tools = moduleOptions.tools;
36
+ const commands = moduleOptions.commands;
37
+ const requireReply = moduleOptions.requireReply ?? (moduleOptions.tools.includes("channels") && commands?.length !== 0);
38
+ if (requireReply && (!moduleOptions.tools.includes("channels") ||
39
+ (commands !== undefined && !commands.includes("reply")))) {
40
+ throw new Error("requireReply needs the channels tool with the reply command enabled");
41
+ }
42
+ if (commands?.some((command) => !channelToolIds.has(command))) {
43
+ throw new Error("Unknown channels command in connector allowlist");
44
+ }
37
45
  return (pi) => {
46
+ if (!moduleOptions.tools.includes("channels"))
47
+ return;
38
48
  const session = options.createSession({
49
+ config: resolveChannelConfig(moduleOptions.env ?? process.env),
39
50
  env: moduleOptions.env ?? process.env,
40
51
  cwd: moduleOptions.cwd ?? process.cwd(),
41
52
  });
@@ -50,9 +61,10 @@ export function createChannelConnectorModule(options) {
50
61
  }
51
62
  registerChannelTools(pi, session.adapter, {
52
63
  target: session.target,
53
- tools,
54
- deferredTools: tools.filter((tool) => deferredToolIds.has(tool)),
64
+ commands: commands,
65
+ requireReply,
55
66
  refs: new ChannelRefStore(),
67
+ validateTarget: session.validateTarget,
56
68
  });
57
69
  };
58
70
  },
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/channels/module.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,YAAY,CAAC;AAmCpB,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS,gBAAgB,CAAC,CAAC;AAEzD,6DAA6D;AAC7D,SAAS,gBAAgB,CACvB,IAAyB,EACzB,KAA0B;IAE1B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAkC,CAAC;IACjE,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QACxC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAsC;IAEtC,MAAM,cAAc,GAAG,qBAAqB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,IAAI,GAAG,CAC7B,cAAc;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;SACrC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAmB,CAAC,CAC3C,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,cAAc;QACrB,eAAe,CAAC,aAAa;YAC3B,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CACxC,CAAC,IA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,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;oBAC9D,GAAG,EAAE,aAAa,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG;oBACrC,GAAG,EAAE,aAAa,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;iBACxC,CAAC,CAAC;gBACH,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;oBAClD,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,CAAC,QAAQ,wBAAwB,OAAO,CAAC,OAAO,CAAC,QAAQ,GAAG,CAC5F,CAAC;gBACJ,CAAC;gBACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC1E,kEAAkE;oBAClE,kEAAkE;oBAClE,oEAAoE;oBACpE,MAAM,IAAI,KAAK,CACb,oBAAoB,OAAO,CAAC,QAAQ,+DAA+D,CACpG,CAAC;gBACJ,CAAC;gBACD,oBAAoB,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE;oBACxC,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,QAAQ,EAAE,QAAgD;oBAC1D,YAAY;oBACZ,IAAI,EAAE,IAAI,eAAe,EAAE;oBAC3B,cAAc,EAAE,OAAO,CAAC,cAAc;iBACvC,CAAC,CAAC;YACL,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -3,7 +3,7 @@ import type { ChannelCursor, ChannelFileIdentity, ChannelMessageIdentity, Channe
3
3
  * Session-scoped opaque handles for messages and pagination cursors.
4
4
  *
5
5
  * The model only ever sees a handle this store minted, so it cannot name a
6
- * message it was never shown, and provider id formats stay out of tool schemas.
6
+ * message it was never shown to edit, retract, or react to.
7
7
  * The store is also where authorship lives. `resolveAuthored` is the single
8
8
  * check behind `channel_edit` and `channel_retract`, which keeps those tools
9
9
  * scoped to the agent's own messages rather than everything the provider
@@ -20,8 +20,8 @@ export declare class ChannelRefStore implements ChannelRefResolver {
20
20
  message(identity: ChannelMessageIdentity): MessageRef;
21
21
  resolveMessage(ref: MessageRef): ChannelMessageIdentity;
22
22
  resolveAuthored(ref: MessageRef): ChannelMessageIdentity;
23
- cursor(providerCursor: string): ChannelCursor;
24
- resolveCursor(cursor: ChannelCursor): string;
23
+ cursor(providerCursor: string, scope?: string): ChannelCursor;
24
+ resolveCursor(cursor: ChannelCursor, scope?: string): string;
25
25
  file(identity: ChannelFileIdentity): FileRef;
26
26
  resolveFile(ref: FileRef): ChannelFileIdentity;
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/channels/refs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;;;GAWG;AACH,qBAAa,eAAgB,YAAW,kBAAkB;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAC1E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2C;IACjE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA8B;IAE7D,OAAO,CAAC,QAAQ,EAAE,sBAAsB,GAAG,UAAU,CAiBpD;IAED,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,sBAAsB,CAQtD;IAED,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,sBAAsB,CAQvD;IAED,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,aAAa,CAI5C;IAED,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAQ3C;IAED,IAAI,CAAC,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAQ3C;IAED,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAW7C;CACF"}
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/channels/refs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;;;GAWG;AACH,qBAAa,eAAgB,YAAW,kBAAkB;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiD;IAC1E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+D;IACvF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2C;IACjE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA8B;IAE7D,OAAO,CAAC,QAAQ,EAAE,sBAAsB,GAAG,UAAU,CAiBpD;IAED,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,sBAAsB,CAQtD;IAED,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,sBAAsB,CAQvD;IAED,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAI5D;IAED,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAW3D;IAED,IAAI,CAAC,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAQ3C;IAED,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAW7C;CACF"}
@@ -9,7 +9,7 @@ function handle(prefix) {
9
9
  * Session-scoped opaque handles for messages and pagination cursors.
10
10
  *
11
11
  * The model only ever sees a handle this store minted, so it cannot name a
12
- * message it was never shown, and provider id formats stay out of tool schemas.
12
+ * message it was never shown to edit, retract, or react to.
13
13
  * The store is also where authorship lives. `resolveAuthored` is the single
14
14
  * check behind `channel_edit` and `channel_retract`, which keeps those tools
15
15
  * scoped to the agent's own messages rather than everything the provider
@@ -24,7 +24,7 @@ export class ChannelRefStore {
24
24
  files = new Map();
25
25
  byFileIdentity = new Map();
26
26
  message(identity) {
27
- const key = `${identity.conversation} ${identity.id}`;
27
+ const key = JSON.stringify([identity.conversation, identity.thread ?? null, identity.id]);
28
28
  const existing = this.byIdentity.get(key);
29
29
  if (existing) {
30
30
  const previous = this.messages.get(existing);
@@ -55,20 +55,23 @@ export class ChannelRefStore {
55
55
  }
56
56
  return identity;
57
57
  }
58
- cursor(providerCursor) {
58
+ cursor(providerCursor, scope) {
59
59
  const cursor = handle(CURSOR_PREFIX);
60
- this.cursors.set(cursor, providerCursor);
60
+ this.cursors.set(cursor, { value: providerCursor, scope });
61
61
  return cursor;
62
62
  }
63
- resolveCursor(cursor) {
63
+ resolveCursor(cursor, scope) {
64
64
  const providerCursor = this.cursors.get(cursor);
65
65
  if (!providerCursor) {
66
- throw new Error(`Unknown cursor '${cursor}'. Use a cursor returned by a previous channel_read call.`);
66
+ throw new Error(`Unknown cursor '${cursor}'. Use a cursor returned by a previous channels read call.`);
67
67
  }
68
- return providerCursor;
68
+ if (providerCursor.scope !== scope) {
69
+ throw new Error("Cursor belongs to another channel or thread. Repeat the original read target.");
70
+ }
71
+ return providerCursor.value;
69
72
  }
70
73
  file(identity) {
71
- const key = `${identity.conversation} ${identity.id}`;
74
+ const key = JSON.stringify([identity.conversation, identity.thread ?? null, identity.id]);
72
75
  const existing = this.byFileIdentity.get(key);
73
76
  if (existing)
74
77
  return existing;
@@ -1 +1 @@
1
- {"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/channels/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,SAAS,MAAM,CAAC,MAAc;IAC5B,O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AO,GAAG,CAAC;IACb,CAAC;IAED,WAAW,CAAC,GAAY;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,qEAAqE;YACrE,6DAA6D;YAC7D,iCAAiC;YACjC,MAAM,IAAI,KAAK,CACb,2BAA2B,GAAG,8DAA8D,CAC7F,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -4,16 +4,14 @@ import type { ChannelAdapter, ChannelCapabilities, ChannelTarget } from "./types
4
4
  /**
5
5
  * The neutral operation vocabulary.
6
6
  *
7
- * These ids are private to the channel implementation. An agent writes the
8
- * complete `channel_<id>` name in its YAML tool list.
7
+ * Commands of the registered `channels` tool.
9
8
  */
10
- export declare const CHANNEL_TOOL_IDS: readonly ["reply", "read", "react", "edit", "retract", "attach", "fetch_file", "post_document"];
9
+ export declare const CHANNEL_TOOL_IDS: readonly ["reply", "send", "list", "read", "react", "edit", "retract", "attach", "fetch_file", "post_document"];
11
10
  export type ChannelToolId = (typeof CHANNEL_TOOL_IDS)[number];
12
- export declare function channelToolName(id: ChannelToolId): string;
13
11
  /** Which operations an adapter's capabilities actually support. */
14
12
  export declare function channelToolIdsFor(capabilities: ChannelCapabilities): ChannelToolId[];
15
- export declare function channelConnectorTools(capabilities: ChannelCapabilities): {
16
- id: "attach" | "edit" | "fetch_file" | "post_document" | "react" | "read" | "reply" | "retract";
13
+ export declare function channelConnectorTools(_capabilities: ChannelCapabilities): {
14
+ id: string;
17
15
  name: string;
18
16
  defaultActive: boolean;
19
17
  }[];
@@ -27,30 +25,25 @@ export interface RegisterChannelToolsOptions {
27
25
  * run from a non-channel trigger such as an automation.
28
26
  */
29
27
  target: ChannelTarget | (() => ChannelTarget);
30
- /** Restrict registration to these ids; defaults to everything supported. */
31
- tools?: readonly ChannelToolId[];
32
- /** Selected tools that require `tool_search` before the model may call them. */
33
- deferredTools?: readonly ChannelToolId[];
28
+ /** Restrict commands; defaults to everything supported. An empty list exposes no tool. */
29
+ commands?: readonly ChannelToolId[];
30
+ /** Require a successful final reply on inbound turns. Defaults to true for enabled tools. */
31
+ requireReply?: boolean;
34
32
  refs?: ChannelRefStore;
33
+ /** Optional host tool-layer policy. This does not constrain shell/API egress. */
34
+ validateTarget?: (target: ChannelTarget, operation: ChannelToolId) => void | Promise<void>;
35
35
  }
36
36
  /** Host surface used here. Opaque so Pi's TypeBox copy stays behind this seam. */
37
37
  export interface ChannelToolHost {
38
38
  registerTool(...args: never[]): unknown;
39
39
  on: ExtensionAPI["on"];
40
+ sendMessage?: ExtensionAPI["sendMessage"];
40
41
  }
41
42
  /**
42
- * Register the bound channel tools an adapter supports.
43
- *
44
- * Two invariants are enforced by construction rather than by review:
45
- *
46
- * 1. **No schema below carries a conversation, thread, workspace, or user
47
- * argument.** The conversation comes from `options.target`, closed over
48
- * here. A model that cannot name a destination cannot reach one, so an
49
- * agent bound to a thread stays bound to that thread even if the underlying
50
- * credential could reach the whole workspace.
51
- * 2. **Unsupported operations are absent**, not stubs that answer "this
52
- * channel cannot do that" — such a stub costs a turn every time and teaches
53
- * the model nothing durable.
43
+ * Register tools for ONE provider credential session. Never share the adapter
44
+ * or reference store between installations. Explicit targeting is opt-in;
45
+ * reply/attach/documents retain their origin default. References identify
46
+ * previously observed resources; they are not durable authorization grants.
54
47
  */
55
48
  export declare function registerChannelTools(pi: ChannelToolHost, adapter: ChannelAdapter, options: RegisterChannelToolsOptions): void;
56
49
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/channels/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,cAAc,EAEd,mBAAmB,EAE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