@introspection-ai/recipes 0.20.0 → 0.22.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 +10 -4
- package/dist/channels/index.d.ts +7 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +4 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/module.d.ts +43 -0
- package/dist/channels/module.d.ts.map +1 -0
- package/dist/channels/module.js +61 -0
- package/dist/channels/module.js.map +1 -0
- package/dist/channels/refs.d.ts +28 -0
- package/dist/channels/refs.d.ts.map +1 -0
- package/dist/channels/refs.js +91 -0
- package/dist/channels/refs.js.map +1 -0
- package/dist/channels/tools.d.ts +56 -0
- package/dist/channels/tools.d.ts.map +1 -0
- package/dist/channels/tools.js +324 -0
- package/dist/channels/tools.js.map +1 -0
- package/dist/channels/types.d.ts +209 -0
- package/dist/channels/types.d.ts.map +1 -0
- package/dist/channels/types.js +23 -0
- package/dist/channels/types.js.map +1 -0
- package/dist/child-agent.d.ts +2 -0
- package/dist/child-agent.d.ts.map +1 -1
- package/dist/child-agent.js +33 -1
- package/dist/child-agent.js.map +1 -1
- package/dist/connector-tools.d.ts +37 -0
- package/dist/connector-tools.d.ts.map +1 -0
- package/dist/connector-tools.js +88 -0
- package/dist/connector-tools.js.map +1 -0
- package/dist/mcp-chunks/{auth-command-IQ4J332A.js → auth-command-4OEOMU2V.js} +22 -22
- package/dist/mcp-chunks/call-arguments-RPXZJOXL.js +15 -0
- package/dist/mcp-chunks/{call-command-WPQ3MDOE.js → call-command-AUEKSBMD.js} +31 -31
- package/dist/mcp-chunks/{chunk-3FB4ZJ4Z.js → chunk-3VLPWGJL.js} +4 -4
- package/dist/mcp-chunks/{chunk-WKUCIR2F.js → chunk-47N2EELW.js} +32 -29
- package/dist/mcp-chunks/{chunk-NACLB5YH.js → chunk-4NDR45CX.js} +5 -5
- package/dist/mcp-chunks/{chunk-RXSZ2W6Y.js → chunk-5WGJPYOR.js} +1 -1
- package/dist/mcp-chunks/{chunk-JJG2OEHI.js → chunk-6CYJ6RN3.js} +1 -1
- package/dist/mcp-chunks/{chunk-IUFDFNNP.js → chunk-6DL2C6V5.js} +1 -1
- package/dist/mcp-chunks/{chunk-NPU7EMGE.js → chunk-6QH47GNE.js} +5 -5
- package/dist/mcp-chunks/{chunk-UDG3RHKX.js → chunk-756YH7S4.js} +2 -2
- package/dist/mcp-chunks/{chunk-B4XFULJ6.js → chunk-7CS27CWE.js} +6 -6
- package/dist/mcp-chunks/{chunk-SCD2NAX5.js → chunk-7KEDX7SE.js} +2 -2
- package/dist/mcp-chunks/{chunk-24FKKIXI.js → chunk-AB7MHBEG.js} +11 -11
- package/dist/mcp-chunks/{chunk-ITJWLDF5.js → chunk-ACTRQW5L.js} +2 -2
- package/dist/mcp-chunks/{chunk-ETYYCEQF.js → chunk-ADINDBOF.js} +2 -2
- package/dist/mcp-chunks/{chunk-QONTHFPO.js → chunk-AF74TOWM.js} +4 -4
- package/dist/mcp-chunks/{chunk-GQHTGV5E.js → chunk-AFKE4BTR.js} +15 -15
- package/dist/mcp-chunks/{chunk-RDOD354S.js → chunk-DEYKPG4K.js} +4 -4
- package/dist/mcp-chunks/{chunk-UAIJZBGL.js → chunk-E4YYMOT2.js} +10 -10
- package/dist/mcp-chunks/{chunk-DIIFWDZ7.js → chunk-HBDCHBJP.js} +1 -1
- package/dist/mcp-chunks/{chunk-NMF5S5DC.js → chunk-HDUKEFBI.js} +2 -2
- package/dist/mcp-chunks/{chunk-5YBCGQA7.js → chunk-HHMWZ2FZ.js} +1 -1
- package/dist/mcp-chunks/{chunk-2CTVPSHF.js → chunk-IPH6U7SE.js} +3 -3
- package/dist/mcp-chunks/{chunk-NSZY5WLR.js → chunk-J3J3NQ4X.js} +1 -1
- package/dist/mcp-chunks/{chunk-U23EY5DN.js → chunk-J6VOMOKI.js} +1 -1
- package/dist/mcp-chunks/{chunk-KJ3CMHWS.js → chunk-JILBFEBD.js} +1 -1
- package/dist/mcp-chunks/{chunk-YDJ7E2PH.js → chunk-JZDXKYQM.js} +4 -4
- package/dist/mcp-chunks/{chunk-FZ7K5EGL.js → chunk-KMH3PHLA.js} +5 -5
- package/dist/mcp-chunks/{chunk-FW5QVG6V.js → chunk-KPXFBRTG.js} +1 -1
- package/dist/mcp-chunks/{chunk-ZI44YPFF.js → chunk-L4CUJJI5.js} +4 -4
- package/dist/mcp-chunks/{chunk-GPCLDF6U.js → chunk-LC2CCTQN.js} +1 -1
- package/dist/mcp-chunks/{chunk-3MIFROM7.js → chunk-LJCZWKGJ.js} +1 -1
- package/dist/mcp-chunks/{chunk-SHZVDY6Z.js → chunk-MFFE5QSH.js} +1 -1
- package/dist/mcp-chunks/{chunk-HULRE4D2.js → chunk-MOML5C2E.js} +1 -1
- package/dist/mcp-chunks/{chunk-TAVMVGD5.js → chunk-MRXSXBZT.js} +2 -2
- package/dist/mcp-chunks/{chunk-LI4L4FOV.js → chunk-NMFI6AUD.js} +21 -21
- package/dist/mcp-chunks/{chunk-EEYUPDRX.js → chunk-NWLOPQT7.js} +1 -1
- package/dist/mcp-chunks/{chunk-ZSKQI4TS.js → chunk-OGFFBNIC.js} +4 -4
- package/dist/mcp-chunks/{chunk-QK6LUI5Q.js → chunk-PPIXUCYQ.js} +2 -2
- package/dist/mcp-chunks/{chunk-ILULMM2E.js → chunk-PPOHGQKM.js} +2 -2
- package/dist/mcp-chunks/{chunk-FNQV2ONG.js → chunk-PRZCYXVO.js} +2 -2
- package/dist/mcp-chunks/{chunk-LYZRCACV.js → chunk-Q7ESBNJG.js} +2 -2
- package/dist/mcp-chunks/{chunk-VC6SKXTI.js → chunk-RE4EVQNC.js} +1 -1
- package/dist/mcp-chunks/{chunk-AJPFOQLF.js → chunk-RO2Y34XX.js} +1 -1
- package/dist/mcp-chunks/{chunk-G5C4WVDQ.js → chunk-SAK5KCLR.js} +1 -1
- package/dist/mcp-chunks/{chunk-ILSK6AWI.js → chunk-SCGMRUKI.js} +1 -1
- package/dist/mcp-chunks/{chunk-MNAVFYYV.js → chunk-SQTXZR56.js} +10 -10
- package/dist/mcp-chunks/{chunk-VREKED5H.js → chunk-TGJOZDKG.js} +2 -2
- package/dist/mcp-chunks/{chunk-ZNKNF2BV.js → chunk-US57PK4B.js} +1 -1
- package/dist/mcp-chunks/{chunk-RYAUNXFA.js → chunk-V4RYLZM5.js} +1 -1
- package/dist/mcp-chunks/{chunk-54UGGTOX.js → chunk-X3FOKZ5C.js} +1 -1
- package/dist/mcp-chunks/{chunk-XRRT3SZM.js → chunk-XVJAASVZ.js} +10 -10
- package/dist/mcp-chunks/{chunk-MDVNQ4HM.js → chunk-YX2NKW6O.js} +1 -1
- package/dist/mcp-chunks/{chunk-5HQYKAE7.js → chunk-Z7O6NF7X.js} +16 -16
- package/dist/mcp-chunks/{chunk-MWD5PZ4G.js → chunk-ZKFG37TB.js} +2 -2
- package/dist/mcp-chunks/{chunk-VJ2TSA5R.js → chunk-ZRZ7C6L3.js} +13 -8
- package/dist/mcp-chunks/{chunk-N2HVJU7X.js → chunk-ZZSD2JT7.js} +1 -1
- package/dist/mcp-chunks/{cli-Z7KV4PCE.js → cli-B7WQQUME.js} +67 -67
- package/dist/mcp-chunks/client-4ZHIBB67.js +21 -0
- package/dist/mcp-chunks/{config-command-XXCDOB3M.js → config-command-FF3JPMOP.js} +26 -26
- package/dist/mcp-chunks/daemon-command-FKW6YELL.js +35 -0
- package/dist/mcp-chunks/{emit-ts-command-FEHTMXXB.js → emit-ts-command-4X56IZ32.js} +16 -16
- package/dist/mcp-chunks/{generate-cli-runner-OA6XL77R.js → generate-cli-runner-MIPF73SJ.js} +42 -42
- package/dist/mcp-chunks/{inspect-cli-command-UQKKE5VO.js → inspect-cli-command-GX54ZXKR.js} +8 -8
- package/dist/mcp-chunks/{launch-KMPDJOUH.js → launch-E2LWGPZS.js} +1 -1
- package/dist/mcp-chunks/{lifecycle-R3IP22MJ.js → lifecycle-TONHXXXJ.js} +1 -1
- package/dist/mcp-chunks/{list-command-7ENYKBF6.js → list-command-YUGRZO4G.js} +28 -28
- package/dist/mcp-chunks/{output-utils-N75TOWBX.js → output-utils-AZY6N2VQ.js} +3 -3
- package/dist/mcp-chunks/{record-command-XHPCL7IG.js → record-command-25DLELA2.js} +5 -5
- package/dist/mcp-chunks/{replay-command-CB56L3ZA.js → replay-command-6SLDG6PC.js} +6 -6
- package/dist/mcp-chunks/{resource-command-STEBHVT7.js → resource-command-YVOB4JCU.js} +8 -8
- package/dist/mcp-chunks/{result-utils-UONY2KNY.js → result-utils-ZXB5DM36.js} +2 -2
- package/dist/mcp-chunks/runtime-NOWGTHZ5.js +39 -0
- package/dist/mcp-chunks/{runtime-wrapper-SYYAQVO6.js → runtime-wrapper-ZZPAFQE4.js} +5 -5
- package/dist/mcp-chunks/{serve-command-VYSFRZFE.js → serve-command-QYGM2AMB.js} +26 -26
- package/dist/mcp-chunks/{timeouts-T3JP3MUF.js → timeouts-P3TBB3AX.js} +3 -3
- package/dist/mcp-chunks/{vault-command-AJ3X7GDI.js → vault-command-VDMPATIX.js} +6 -6
- package/dist/mcp-daemon.js +29 -29
- package/dist/mcp-run-worker.js +29 -29
- package/dist/mcp-tools.d.ts +1 -6
- package/dist/mcp-tools.d.ts.map +1 -1
- package/dist/mcp-tools.js +5 -73
- package/dist/mcp-tools.js.map +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +24 -0
- package/dist/mcp.js.map +1 -1
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +66 -35
- package/dist/pi-extension.js.map +1 -1
- package/dist/recipe-agent.d.ts.map +1 -1
- package/dist/recipe-agent.js +3 -2
- package/dist/recipe-agent.js.map +1 -1
- package/dist/recipe-extensions.d.ts +1 -0
- package/dist/recipe-extensions.d.ts.map +1 -1
- package/dist/recipe-extensions.js +32 -11
- package/dist/recipe-extensions.js.map +1 -1
- package/dist/recipe-package.d.ts +5 -0
- package/dist/recipe-package.d.ts.map +1 -1
- package/dist/recipe-package.js +68 -3
- package/dist/recipe-package.js.map +1 -1
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +7 -3
- package/dist/run-controller.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +71 -16
- package/dist/session.js.map +1 -1
- package/dist/test-utils.d.ts +1 -0
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +1 -0
- package/dist/test-utils.js.map +1 -1
- package/dist/tool-search.d.ts +21 -0
- package/dist/tool-search.d.ts.map +1 -0
- package/dist/tool-search.js +176 -0
- package/dist/tool-search.js.map +1 -0
- package/docs/channels.md +166 -0
- package/docs/index.md +2 -0
- package/docs/mcp-configuration.md +6 -4
- package/docs/pi-extension.md +12 -8
- package/docs/recipe-format.md +37 -0
- package/docs/slack.md +135 -0
- package/package.json +23 -14
- package/dist/mcp-chunks/call-arguments-MCCBPJMY.js +0 -15
- package/dist/mcp-chunks/client-B3FMQNGF.js +0 -21
- package/dist/mcp-chunks/daemon-command-BAREANTC.js +0 -35
- package/dist/mcp-chunks/runtime-Z45IVD24.js +0 -39
- package/dist/recipe-check.d.ts +0 -18
- package/dist/recipe-check.d.ts.map +0 -1
- package/dist/recipe-check.js +0 -263
- package/dist/recipe-check.js.map +0 -1
- package/vendor/introspection-recipe-check/darwin-arm64/introspection-recipe-check +0 -0
- package/vendor/introspection-recipe-check/darwin-x64/introspection-recipe-check +0 -0
- package/vendor/introspection-recipe-check/linux-arm64/introspection-recipe-check +0 -0
- package/vendor/introspection-recipe-check/linux-x64/introspection-recipe-check +0 -0
- package/vendor/introspection-recipe-check/linux-x64-musl/introspection-recipe-check +0 -0
- package/vendor/introspection-recipe-check/win32-x64/introspection-recipe-check.exe +0 -0
- package/vendor/mcp-client/darwin-arm64/mcp-client +0 -0
- package/vendor/mcp-client/darwin-x64/mcp-client +0 -0
- package/vendor/mcp-client/linux-arm64/mcp-client +0 -0
- package/vendor/mcp-client/linux-x64/mcp-client +0 -0
package/README.md
CHANGED
|
@@ -129,6 +129,11 @@ tests.
|
|
|
129
129
|
- `@introspection-ai/recipes/pi-extension` — Pi extension entrypoint
|
|
130
130
|
- `@introspection-ai/recipes/extensions` — session identity and conditional
|
|
131
131
|
Recipe extension helpers
|
|
132
|
+
- `@introspection-ai/recipes/channels` is the provider neutral `channel_*` tool
|
|
133
|
+
contract: capability descriptors, opaque message references, and the
|
|
134
|
+
registration that binds every tool to the task's own conversation
|
|
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`.
|
|
132
137
|
- `@introspection-ai/recipes/agents` — portable agent-run controller and tool
|
|
133
138
|
contract
|
|
134
139
|
- `@introspection-ai/recipes/interactions` — portable user-input and approval contract
|
|
@@ -148,10 +153,11 @@ adapters and deployment cookbooks belong outside this package.
|
|
|
148
153
|
introspection check
|
|
149
154
|
```
|
|
150
155
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
Validation is an authoring and host concern, not a launch-time one. Run
|
|
157
|
+
`introspection check` while authoring and in CI; a host that executes Recipes
|
|
158
|
+
should validate before it starts a session, as the Introspection platform does
|
|
159
|
+
when a task is created. A `pi --recipe` launch does **not** re-validate, so a
|
|
160
|
+
Recipe that was never checked can start with errors the validator would catch.
|
|
155
161
|
|
|
156
162
|
## Documentation
|
|
157
163
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ChannelRefStore } from "./refs.js";
|
|
2
|
+
export { CHANNEL_TOOL_IDS, channelConnectorTools, channelToolIdsFor, channelToolName, registerChannelTools, } from "./tools.js";
|
|
3
|
+
export type { ChannelToolHost, ChannelToolId, RegisterChannelToolsOptions, } from "./tools.js";
|
|
4
|
+
export { createChannelConnectorModule } from "./module.js";
|
|
5
|
+
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";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RecipeConnectorModule } from "../connector-tools.js";
|
|
2
|
+
import type { ChannelAdapter, ChannelCapabilities, ChannelTarget } from "./types.js";
|
|
3
|
+
export interface ChannelConnectorSession {
|
|
4
|
+
readonly adapter: ChannelAdapter;
|
|
5
|
+
/** Resolved lazily so a task with no channel origin still starts. */
|
|
6
|
+
readonly target: ChannelTarget | (() => ChannelTarget);
|
|
7
|
+
}
|
|
8
|
+
export interface ChannelConnectorModuleOptions {
|
|
9
|
+
provider: string;
|
|
10
|
+
/**
|
|
11
|
+
* What this channel supports, as static data.
|
|
12
|
+
*
|
|
13
|
+
* Declared separately from `createSession` because the loader builds the tool
|
|
14
|
+
* catalog before any session exists. A capability discovered by failing a
|
|
15
|
+
* call would also waste an agent turn.
|
|
16
|
+
*/
|
|
17
|
+
capabilities: ChannelCapabilities;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the bound conversation and a client for it.
|
|
20
|
+
*
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
createSession(options: {
|
|
25
|
+
env: NodeJS.ProcessEnv;
|
|
26
|
+
cwd: string;
|
|
27
|
+
}): ChannelConnectorSession;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build a `RecipeConnectorModule` from a channel adapter.
|
|
31
|
+
*
|
|
32
|
+
* A provider package supplies transport plus a capability descriptor; the
|
|
33
|
+
* neutral tool schemas, the opaque handles, and the capability filtering live
|
|
34
|
+
* 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.
|
|
37
|
+
*
|
|
38
|
+
* The result satisfies the existing connector contract. The manifest selects
|
|
39
|
+
* the provider package, the agent list selects tools from its catalog, and
|
|
40
|
+
* `tool_search` exposes selected tools that are not active by default.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createChannelConnectorModule(options: ChannelConnectorModuleOptions): RecipeConnectorModule;
|
|
43
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ChannelRefStore } from "./refs.js";
|
|
2
|
+
import { CHANNEL_TOOL_IDS, channelConnectorTools, registerChannelTools, } from "./tools.js";
|
|
3
|
+
const channelToolIds = new Set(CHANNEL_TOOL_IDS);
|
|
4
|
+
/** Whether two capability descriptors say the same thing. */
|
|
5
|
+
function sameCapabilities(left, right) {
|
|
6
|
+
const keys = Object.keys(right);
|
|
7
|
+
return (Object.keys(left).length === keys.length &&
|
|
8
|
+
keys.every((key) => left[key] === right[key]));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Build a `RecipeConnectorModule` from a channel adapter.
|
|
12
|
+
*
|
|
13
|
+
* A provider package supplies transport plus a capability descriptor; the
|
|
14
|
+
* neutral tool schemas, the opaque handles, and the capability filtering live
|
|
15
|
+
* 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.
|
|
18
|
+
*
|
|
19
|
+
* The result satisfies the existing connector contract. The manifest selects
|
|
20
|
+
* the provider package, the agent list selects tools from its catalog, and
|
|
21
|
+
* `tool_search` exposes selected tools that are not active by default.
|
|
22
|
+
*/
|
|
23
|
+
export function createChannelConnectorModule(options) {
|
|
24
|
+
const connectorTools = channelConnectorTools(options.capabilities);
|
|
25
|
+
const deferredToolIds = new Set(connectorTools
|
|
26
|
+
.filter((tool) => !tool.defaultActive)
|
|
27
|
+
.map((tool) => tool.id));
|
|
28
|
+
return {
|
|
29
|
+
provider: options.provider,
|
|
30
|
+
tools: connectorTools,
|
|
31
|
+
createExtension(moduleOptions) {
|
|
32
|
+
const unknown = moduleOptions.tools.filter((tool) => !channelToolIds.has(tool));
|
|
33
|
+
if (unknown.length > 0) {
|
|
34
|
+
throw new Error(`Unknown ${options.provider} channel tool(s): ${unknown.join(", ")}`);
|
|
35
|
+
}
|
|
36
|
+
const tools = moduleOptions.tools;
|
|
37
|
+
return (pi) => {
|
|
38
|
+
const session = options.createSession({
|
|
39
|
+
env: moduleOptions.env ?? process.env,
|
|
40
|
+
cwd: moduleOptions.cwd ?? process.cwd(),
|
|
41
|
+
});
|
|
42
|
+
if (session.adapter.provider !== options.provider) {
|
|
43
|
+
throw new Error(`Channel adapter for '${options.provider}' returned provider '${session.adapter.provider}'`);
|
|
44
|
+
}
|
|
45
|
+
if (!sameCapabilities(session.adapter.capabilities, options.capabilities)) {
|
|
46
|
+
// The loader selected tools from the declared catalog. An adapter
|
|
47
|
+
// with a different capability set would register a different tool
|
|
48
|
+
// surface. Compare values so an adapter may rebuild the descriptor.
|
|
49
|
+
throw new Error(`Channel adapter '${options.provider}' returned capabilities that differ from its declared catalog`);
|
|
50
|
+
}
|
|
51
|
+
registerChannelTools(pi, session.adapter, {
|
|
52
|
+
target: session.target,
|
|
53
|
+
tools,
|
|
54
|
+
deferredTools: tools.filter((tool) => deferredToolIds.has(tool)),
|
|
55
|
+
refs: new ChannelRefStore(),
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +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,C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pG,CAAC;gBACJ,CAAC;gBACD,oBAAoB,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE;oBACxC,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,KAAK;oBACL,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAChE,IAAI,EAAE,IAAI,eAAe,EAAE;iBAC5B,CAAC,CAAC;YACL,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ChannelCursor, ChannelFileIdentity, ChannelMessageIdentity, ChannelRefResolver, FileRef, MessageRef } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Session-scoped opaque handles for messages and pagination cursors.
|
|
4
|
+
*
|
|
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.
|
|
7
|
+
* The store is also where authorship lives. `resolveAuthored` is the single
|
|
8
|
+
* check behind `channel_edit` and `channel_retract`, which keeps those tools
|
|
9
|
+
* scoped to the agent's own messages rather than everything the provider
|
|
10
|
+
* credential could reach.
|
|
11
|
+
* Handles die with the session. A ref from an earlier task is unresolvable
|
|
12
|
+
* rather than dangerous.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ChannelRefStore implements ChannelRefResolver {
|
|
15
|
+
private readonly messages;
|
|
16
|
+
private readonly byIdentity;
|
|
17
|
+
private readonly cursors;
|
|
18
|
+
private readonly files;
|
|
19
|
+
private readonly byFileIdentity;
|
|
20
|
+
message(identity: ChannelMessageIdentity): MessageRef;
|
|
21
|
+
resolveMessage(ref: MessageRef): ChannelMessageIdentity;
|
|
22
|
+
resolveAuthored(ref: MessageRef): ChannelMessageIdentity;
|
|
23
|
+
cursor(providerCursor: string): ChannelCursor;
|
|
24
|
+
resolveCursor(cursor: ChannelCursor): string;
|
|
25
|
+
file(identity: ChannelFileIdentity): FileRef;
|
|
26
|
+
resolveFile(ref: FileRef): ChannelFileIdentity;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
const MESSAGE_PREFIX = "msg_";
|
|
3
|
+
const CURSOR_PREFIX = "cur_";
|
|
4
|
+
const FILE_PREFIX = "file_";
|
|
5
|
+
function handle(prefix) {
|
|
6
|
+
return `${prefix}${randomUUID().replaceAll("-", "").slice(0, 16)}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Session-scoped opaque handles for messages and pagination cursors.
|
|
10
|
+
*
|
|
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.
|
|
13
|
+
* The store is also where authorship lives. `resolveAuthored` is the single
|
|
14
|
+
* check behind `channel_edit` and `channel_retract`, which keeps those tools
|
|
15
|
+
* scoped to the agent's own messages rather than everything the provider
|
|
16
|
+
* credential could reach.
|
|
17
|
+
* Handles die with the session. A ref from an earlier task is unresolvable
|
|
18
|
+
* rather than dangerous.
|
|
19
|
+
*/
|
|
20
|
+
export class ChannelRefStore {
|
|
21
|
+
messages = new Map();
|
|
22
|
+
byIdentity = new Map();
|
|
23
|
+
cursors = new Map();
|
|
24
|
+
files = new Map();
|
|
25
|
+
byFileIdentity = new Map();
|
|
26
|
+
message(identity) {
|
|
27
|
+
const key = `${identity.conversation} ${identity.id}`;
|
|
28
|
+
const existing = this.byIdentity.get(key);
|
|
29
|
+
if (existing) {
|
|
30
|
+
const previous = this.messages.get(existing);
|
|
31
|
+
this.messages.set(existing, {
|
|
32
|
+
...previous,
|
|
33
|
+
...identity,
|
|
34
|
+
authoredByAgent: previous.authoredByAgent || identity.authoredByAgent,
|
|
35
|
+
permalink: identity.permalink ?? previous.permalink,
|
|
36
|
+
});
|
|
37
|
+
return existing;
|
|
38
|
+
}
|
|
39
|
+
const ref = handle(MESSAGE_PREFIX);
|
|
40
|
+
this.messages.set(ref, identity);
|
|
41
|
+
this.byIdentity.set(key, ref);
|
|
42
|
+
return ref;
|
|
43
|
+
}
|
|
44
|
+
resolveMessage(ref) {
|
|
45
|
+
const identity = this.messages.get(ref);
|
|
46
|
+
if (!identity) {
|
|
47
|
+
throw new Error(`Unknown message reference '${ref}'. Use a reference returned by a channel tool in this session.`);
|
|
48
|
+
}
|
|
49
|
+
return identity;
|
|
50
|
+
}
|
|
51
|
+
resolveAuthored(ref) {
|
|
52
|
+
const identity = this.resolveMessage(ref);
|
|
53
|
+
if (!identity.authoredByAgent) {
|
|
54
|
+
throw new Error(`Message '${ref}' was not sent by this agent. Only messages the agent posted can be edited or retracted.`);
|
|
55
|
+
}
|
|
56
|
+
return identity;
|
|
57
|
+
}
|
|
58
|
+
cursor(providerCursor) {
|
|
59
|
+
const cursor = handle(CURSOR_PREFIX);
|
|
60
|
+
this.cursors.set(cursor, providerCursor);
|
|
61
|
+
return cursor;
|
|
62
|
+
}
|
|
63
|
+
resolveCursor(cursor) {
|
|
64
|
+
const providerCursor = this.cursors.get(cursor);
|
|
65
|
+
if (!providerCursor) {
|
|
66
|
+
throw new Error(`Unknown cursor '${cursor}'. Use a cursor returned by a previous channel_read call.`);
|
|
67
|
+
}
|
|
68
|
+
return providerCursor;
|
|
69
|
+
}
|
|
70
|
+
file(identity) {
|
|
71
|
+
const key = `${identity.conversation} ${identity.id}`;
|
|
72
|
+
const existing = this.byFileIdentity.get(key);
|
|
73
|
+
if (existing)
|
|
74
|
+
return existing;
|
|
75
|
+
const ref = handle(FILE_PREFIX);
|
|
76
|
+
this.files.set(ref, identity);
|
|
77
|
+
this.byFileIdentity.set(key, ref);
|
|
78
|
+
return ref;
|
|
79
|
+
}
|
|
80
|
+
resolveFile(ref) {
|
|
81
|
+
const identity = this.files.get(ref);
|
|
82
|
+
if (!identity) {
|
|
83
|
+
// The whole point: a provider file id the model invented resolves to
|
|
84
|
+
// nothing, so `channel_fetch_file` can only reach files this
|
|
85
|
+
// conversation actually carried.
|
|
86
|
+
throw new Error(`Unknown file reference '${ref}'. Use a file reference from a message in this conversation.`);
|
|
87
|
+
}
|
|
88
|
+
return identity;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/channels/refs.ts"],"names":[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,CAAC,EAAE,EAAE,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,OAAO,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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { ChannelRefStore } from "./refs.js";
|
|
3
|
+
import type { ChannelAdapter, ChannelCapabilities, ChannelTarget } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The neutral operation vocabulary.
|
|
6
|
+
*
|
|
7
|
+
* These ids are private to the channel implementation. An agent writes the
|
|
8
|
+
* complete `channel_<id>` name in its YAML tool list.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHANNEL_TOOL_IDS: readonly ["reply", "read", "react", "edit", "retract", "attach", "fetch_file", "post_document"];
|
|
11
|
+
export type ChannelToolId = (typeof CHANNEL_TOOL_IDS)[number];
|
|
12
|
+
export declare function channelToolName(id: ChannelToolId): string;
|
|
13
|
+
/** Which operations an adapter's capabilities actually support. */
|
|
14
|
+
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";
|
|
17
|
+
name: string;
|
|
18
|
+
defaultActive: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
export interface RegisterChannelToolsOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The bound conversation, or a thunk resolving it.
|
|
23
|
+
*
|
|
24
|
+
* Resolved by the host, never from model input. A thunk defers the "this
|
|
25
|
+
* task has no channel origin" failure to the first tool call, so a Recipe
|
|
26
|
+
* that declares a channel connector still starts when the same Recipe is
|
|
27
|
+
* run from a non-channel trigger such as an automation.
|
|
28
|
+
*/
|
|
29
|
+
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[];
|
|
34
|
+
refs?: ChannelRefStore;
|
|
35
|
+
}
|
|
36
|
+
/** Host surface used here. Opaque so Pi's TypeBox copy stays behind this seam. */
|
|
37
|
+
export interface ChannelToolHost {
|
|
38
|
+
registerTool(...args: never[]): unknown;
|
|
39
|
+
on: ExtensionAPI["on"];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
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.
|
|
54
|
+
*/
|
|
55
|
+
export declare function registerChannelTools(pi: ChannelToolHost, adapter: ChannelAdapter, options: RegisterChannelToolsOptions): void;
|
|
56
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +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,EAEnB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,YAC3B,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,CACP,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAS9D,wBAAgB,eAAe,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,CAEzD;AAED,mEAAmE;AACnE,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,mBAAmB,GAChC,aAAa,EAAE,CAUjB;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,mBAAmB;;;;IAOtE;AAkCD,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;OAOG;IACH,MAAM,EAAE,aAAa,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC;IAC9C,4EAA4E;IAC5E,KAAK,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC,gFAAgF;IAChF,aAAa,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED,kFAAkF;AAClF,MAA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