@copilotkit/channels 0.1.1 → 0.2.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 +43 -185
- package/dist/discord.d.ts +2 -0
- package/dist/discord.d.ts.map +1 -0
- package/dist/discord.js +1 -0
- package/dist/index.d.ts +1 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -32
- package/dist/intelligence.d.ts +3 -0
- package/dist/intelligence.d.ts.map +1 -0
- package/dist/intelligence.js +1 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +1 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +1 -0
- package/dist/slack/codec.d.ts +2 -0
- package/dist/slack/codec.d.ts.map +1 -0
- package/dist/slack/codec.js +1 -0
- package/dist/slack/render.d.ts +2 -0
- package/dist/slack/render.d.ts.map +1 -0
- package/dist/slack/render.js +1 -0
- package/dist/slack.d.ts +2 -0
- package/dist/slack.d.ts.map +1 -0
- package/dist/slack.js +1 -0
- package/dist/teams/render.d.ts +2 -0
- package/dist/teams/render.d.ts.map +1 -0
- package/dist/teams/render.js +1 -0
- package/dist/teams.d.ts +2 -0
- package/dist/teams.d.ts.map +1 -0
- package/dist/teams.js +1 -0
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.d.ts.map +1 -0
- package/dist/telegram.js +1 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +1 -0
- package/dist/ui.d.ts +2 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +1 -0
- package/dist/umbrella.smoke.test.d.ts +2 -0
- package/dist/umbrella.smoke.test.d.ts.map +1 -0
- package/dist/umbrella.smoke.test.js +40 -0
- package/dist/whatsapp.d.ts +2 -0
- package/dist/whatsapp.d.ts.map +1 -0
- package/dist/whatsapp.js +1 -0
- package/package.json +78 -13
- package/dist/action-registry.d.ts +0 -59
- package/dist/action-registry.d.ts.map +0 -1
- package/dist/action-registry.js +0 -217
- package/dist/action-registry.test.d.ts +0 -2
- package/dist/action-registry.test.d.ts.map +0 -1
- package/dist/action-registry.test.js +0 -115
- package/dist/action-store.d.ts +0 -21
- package/dist/action-store.d.ts.map +0 -1
- package/dist/action-store.js +0 -23
- package/dist/action-store.test.d.ts +0 -2
- package/dist/action-store.test.d.ts.map +0 -1
- package/dist/action-store.test.js +0 -27
- package/dist/codec.d.ts +0 -25
- package/dist/codec.d.ts.map +0 -1
- package/dist/codec.js +0 -1
- package/dist/commands.d.ts +0 -73
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -38
- package/dist/commands.test.d.ts +0 -2
- package/dist/commands.test.d.ts.map +0 -1
- package/dist/commands.test.js +0 -23
- package/dist/create-bot.d.ts +0 -171
- package/dist/create-bot.d.ts.map +0 -1
- package/dist/create-bot.foundations.test.d.ts +0 -2
- package/dist/create-bot.foundations.test.d.ts.map +0 -1
- package/dist/create-bot.foundations.test.js +0 -147
- package/dist/create-bot.js +0 -579
- package/dist/create-bot.test.d.ts +0 -2
- package/dist/create-bot.test.d.ts.map +0 -1
- package/dist/create-bot.test.js +0 -936
- package/dist/mint-id.d.ts +0 -3
- package/dist/mint-id.d.ts.map +0 -1
- package/dist/mint-id.js +0 -20
- package/dist/mint-id.test.d.ts +0 -2
- package/dist/mint-id.test.d.ts.map +0 -1
- package/dist/mint-id.test.js +0 -16
- package/dist/modal-submit.test.d.ts +0 -2
- package/dist/modal-submit.test.d.ts.map +0 -1
- package/dist/modal-submit.test.js +0 -68
- package/dist/platform-adapter.d.ts +0 -331
- package/dist/platform-adapter.d.ts.map +0 -1
- package/dist/platform-adapter.js +0 -1
- package/dist/platform-adapter.test.d.ts +0 -2
- package/dist/platform-adapter.test.d.ts.map +0 -1
- package/dist/platform-adapter.test.js +0 -40
- package/dist/reactions.test.d.ts +0 -2
- package/dist/reactions.test.d.ts.map +0 -1
- package/dist/reactions.test.js +0 -225
- package/dist/run-loop.d.ts +0 -41
- package/dist/run-loop.d.ts.map +0 -1
- package/dist/run-loop.js +0 -102
- package/dist/run-loop.test.d.ts +0 -2
- package/dist/run-loop.test.d.ts.map +0 -1
- package/dist/run-loop.test.js +0 -125
- package/dist/standard-schema.d.ts +0 -52
- package/dist/standard-schema.d.ts.map +0 -1
- package/dist/standard-schema.js +0 -66
- package/dist/state/duration.d.ts +0 -3
- package/dist/state/duration.d.ts.map +0 -1
- package/dist/state/duration.js +0 -16
- package/dist/state/duration.test.d.ts +0 -2
- package/dist/state/duration.test.d.ts.map +0 -1
- package/dist/state/duration.test.js +0 -13
- package/dist/state/kv-action-store.d.ts +0 -7
- package/dist/state/kv-action-store.d.ts.map +0 -1
- package/dist/state/kv-action-store.js +0 -9
- package/dist/state/kv-action-store.test.d.ts +0 -2
- package/dist/state/kv-action-store.test.d.ts.map +0 -1
- package/dist/state/kv-action-store.test.js +0 -21
- package/dist/state/memory-store.d.ts +0 -41
- package/dist/state/memory-store.d.ts.map +0 -1
- package/dist/state/memory-store.js +0 -110
- package/dist/state/memory-store.test.d.ts +0 -2
- package/dist/state/memory-store.test.d.ts.map +0 -1
- package/dist/state/memory-store.test.js +0 -22
- package/dist/state/state-conversation-store.d.ts +0 -14
- package/dist/state/state-conversation-store.d.ts.map +0 -1
- package/dist/state/state-conversation-store.js +0 -22
- package/dist/state/state-conversation-store.test.d.ts +0 -2
- package/dist/state/state-conversation-store.test.d.ts.map +0 -1
- package/dist/state/state-conversation-store.test.js +0 -58
- package/dist/state/state-store.d.ts +0 -63
- package/dist/state/state-store.d.ts.map +0 -1
- package/dist/state/state-store.js +0 -1
- package/dist/telemetry/bot-telemetry.d.ts +0 -31
- package/dist/telemetry/bot-telemetry.d.ts.map +0 -1
- package/dist/telemetry/bot-telemetry.js +0 -70
- package/dist/telemetry/bot-telemetry.test.d.ts +0 -2
- package/dist/telemetry/bot-telemetry.test.d.ts.map +0 -1
- package/dist/telemetry/bot-telemetry.test.js +0 -56
- package/dist/telemetry/create-bot-telemetry.test.d.ts +0 -2
- package/dist/telemetry/create-bot-telemetry.test.d.ts.map +0 -1
- package/dist/telemetry/create-bot-telemetry.test.js +0 -71
- package/dist/telemetry/e2e-telemetry.test.d.ts +0 -2
- package/dist/telemetry/e2e-telemetry.test.d.ts.map +0 -1
- package/dist/telemetry/e2e-telemetry.test.js +0 -56
- package/dist/telemetry/events-catalog.test.d.ts +0 -2
- package/dist/telemetry/events-catalog.test.d.ts.map +0 -1
- package/dist/telemetry/events-catalog.test.js +0 -8
- package/dist/telemetry/install-id.d.ts +0 -8
- package/dist/telemetry/install-id.d.ts.map +0 -1
- package/dist/telemetry/install-id.js +0 -43
- package/dist/telemetry/install-id.test.d.ts +0 -2
- package/dist/telemetry/install-id.test.d.ts.map +0 -1
- package/dist/telemetry/install-id.test.js +0 -43
- package/dist/telemetry/platform-allowlist-coverage.test.d.ts +0 -2
- package/dist/telemetry/platform-allowlist-coverage.test.d.ts.map +0 -1
- package/dist/telemetry/platform-allowlist-coverage.test.js +0 -45
- package/dist/telemetry/sanitize-error.d.ts +0 -3
- package/dist/telemetry/sanitize-error.d.ts.map +0 -1
- package/dist/telemetry/sanitize-error.js +0 -31
- package/dist/telemetry/sanitize-error.test.d.ts +0 -2
- package/dist/telemetry/sanitize-error.test.d.ts.map +0 -1
- package/dist/telemetry/sanitize-error.test.js +0 -33
- package/dist/testing/fake-adapter.d.ts +0 -137
- package/dist/testing/fake-adapter.d.ts.map +0 -1
- package/dist/testing/fake-adapter.js +0 -273
- package/dist/testing/fake-agent.d.ts +0 -28
- package/dist/testing/fake-agent.d.ts.map +0 -1
- package/dist/testing/fake-agent.js +0 -36
- package/dist/testing/state-store-conformance.d.ts +0 -4
- package/dist/testing/state-store-conformance.d.ts.map +0 -1
- package/dist/testing/state-store-conformance.js +0 -117
- package/dist/thread-capabilities.test.d.ts +0 -2
- package/dist/thread-capabilities.test.d.ts.map +0 -1
- package/dist/thread-capabilities.test.js +0 -77
- package/dist/thread-ephemeral.test.d.ts +0 -2
- package/dist/thread-ephemeral.test.d.ts.map +0 -1
- package/dist/thread-ephemeral.test.js +0 -45
- package/dist/thread-reactions.test.d.ts +0 -2
- package/dist/thread-reactions.test.d.ts.map +0 -1
- package/dist/thread-reactions.test.js +0 -38
- package/dist/thread.d.ts +0 -154
- package/dist/thread.d.ts.map +0 -1
- package/dist/thread.js +0 -333
- package/dist/thread.test.d.ts +0 -2
- package/dist/thread.test.d.ts.map +0 -1
- package/dist/thread.test.js +0 -83
- package/dist/tools.d.ts +0 -67
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -38
- package/dist/tools.test.d.ts +0 -2
- package/dist/tools.test.d.ts.map +0 -1
- package/dist/tools.test.js +0 -31
- package/dist/transcripts.d.ts +0 -52
- package/dist/transcripts.d.ts.map +0 -1
- package/dist/transcripts.js +0 -67
- package/dist/transcripts.test.d.ts +0 -2
- package/dist/transcripts.test.d.ts.map +0 -1
- package/dist/transcripts.test.js +0 -108
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/channels",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Batteries-included CopilotKit Channels package with the core engine, JSX UI, and every supported platform adapter.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/CopilotKit/CopilotKit.git"
|
|
8
|
+
"url": "https://github.com/CopilotKit/CopilotKit.git",
|
|
9
|
+
"directory": "packages/channels"
|
|
9
10
|
},
|
|
10
11
|
"homepage": "https://github.com/CopilotKit/CopilotKit",
|
|
11
12
|
"keywords": [
|
|
@@ -13,10 +14,15 @@
|
|
|
13
14
|
"agent",
|
|
14
15
|
"bot",
|
|
15
16
|
"chatbot",
|
|
16
|
-
"
|
|
17
|
+
"channels",
|
|
17
18
|
"slack",
|
|
19
|
+
"microsoft-teams",
|
|
18
20
|
"teams",
|
|
21
|
+
"intelligence",
|
|
19
22
|
"discord",
|
|
23
|
+
"telegram",
|
|
24
|
+
"whatsapp",
|
|
25
|
+
"copilotkit",
|
|
20
26
|
"ag-ui"
|
|
21
27
|
],
|
|
22
28
|
"publishConfig": {
|
|
@@ -31,26 +37,75 @@
|
|
|
31
37
|
"import": "./dist/index.js"
|
|
32
38
|
},
|
|
33
39
|
"./testing": {
|
|
34
|
-
"types": "./dist/testing
|
|
35
|
-
"import": "./dist/testing
|
|
40
|
+
"types": "./dist/testing.d.ts",
|
|
41
|
+
"import": "./dist/testing.js"
|
|
42
|
+
},
|
|
43
|
+
"./jsx-runtime": {
|
|
44
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
45
|
+
"import": "./dist/jsx-runtime.js"
|
|
46
|
+
},
|
|
47
|
+
"./jsx-dev-runtime": {
|
|
48
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
49
|
+
"import": "./dist/jsx-dev-runtime.js"
|
|
50
|
+
},
|
|
51
|
+
"./ui": {
|
|
52
|
+
"types": "./dist/ui.d.ts",
|
|
53
|
+
"import": "./dist/ui.js"
|
|
54
|
+
},
|
|
55
|
+
"./slack": {
|
|
56
|
+
"types": "./dist/slack.d.ts",
|
|
57
|
+
"import": "./dist/slack.js"
|
|
58
|
+
},
|
|
59
|
+
"./slack/codec": {
|
|
60
|
+
"types": "./dist/slack/codec.d.ts",
|
|
61
|
+
"import": "./dist/slack/codec.js"
|
|
62
|
+
},
|
|
63
|
+
"./slack/render": {
|
|
64
|
+
"types": "./dist/slack/render.d.ts",
|
|
65
|
+
"import": "./dist/slack/render.js"
|
|
66
|
+
},
|
|
67
|
+
"./teams": {
|
|
68
|
+
"types": "./dist/teams.d.ts",
|
|
69
|
+
"import": "./dist/teams.js"
|
|
70
|
+
},
|
|
71
|
+
"./teams/render": {
|
|
72
|
+
"types": "./dist/teams/render.d.ts",
|
|
73
|
+
"import": "./dist/teams/render.js"
|
|
74
|
+
},
|
|
75
|
+
"./intelligence": {
|
|
76
|
+
"types": "./dist/intelligence.d.ts",
|
|
77
|
+
"import": "./dist/intelligence.js"
|
|
78
|
+
},
|
|
79
|
+
"./discord": {
|
|
80
|
+
"types": "./dist/discord.d.ts",
|
|
81
|
+
"import": "./dist/discord.js"
|
|
82
|
+
},
|
|
83
|
+
"./telegram": {
|
|
84
|
+
"types": "./dist/telegram.d.ts",
|
|
85
|
+
"import": "./dist/telegram.js"
|
|
86
|
+
},
|
|
87
|
+
"./whatsapp": {
|
|
88
|
+
"types": "./dist/whatsapp.d.ts",
|
|
89
|
+
"import": "./dist/whatsapp.js"
|
|
36
90
|
}
|
|
37
91
|
},
|
|
38
92
|
"files": [
|
|
39
93
|
"dist"
|
|
40
94
|
],
|
|
41
95
|
"dependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"@copilotkit/
|
|
46
|
-
"@copilotkit/
|
|
47
|
-
"@copilotkit/channels-
|
|
96
|
+
"@copilotkit/channels-core": "0.2.0",
|
|
97
|
+
"@copilotkit/channels-ui": "0.2.0",
|
|
98
|
+
"@copilotkit/channels-slack": "0.2.0",
|
|
99
|
+
"@copilotkit/channels-intelligence": "0.2.0",
|
|
100
|
+
"@copilotkit/channels-discord": "0.2.0",
|
|
101
|
+
"@copilotkit/channels-teams": "0.2.0",
|
|
102
|
+
"@copilotkit/channels-telegram": "0.2.0",
|
|
103
|
+
"@copilotkit/channels-whatsapp": "0.2.0"
|
|
48
104
|
},
|
|
49
105
|
"devDependencies": {
|
|
50
106
|
"@types/node": "^22.10.0",
|
|
51
107
|
"typescript": "^5.6.3",
|
|
52
108
|
"vitest": "^4.1.3",
|
|
53
|
-
"zod": "^3.25.76",
|
|
54
109
|
"@copilotkit/typescript-config": "^1.55.0-next.8"
|
|
55
110
|
},
|
|
56
111
|
"peerDependencies": {
|
|
@@ -61,6 +116,16 @@
|
|
|
61
116
|
"optional": true
|
|
62
117
|
}
|
|
63
118
|
},
|
|
119
|
+
"nx": {
|
|
120
|
+
"targets": {
|
|
121
|
+
"test": {
|
|
122
|
+
"dependsOn": [
|
|
123
|
+
"build",
|
|
124
|
+
"^build"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
64
129
|
"scripts": {
|
|
65
130
|
"build": "tsc -p tsconfig.json",
|
|
66
131
|
"check-types": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.check.json",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { BotNode, InteractionContext, ComponentFn, Renderable, MessageReactionHandler } from "@copilotkit/channels-ui";
|
|
2
|
-
import type { ActionStore } from "./action-store.js";
|
|
3
|
-
export declare class ActionExpiredError extends Error {
|
|
4
|
-
constructor(id: string);
|
|
5
|
-
}
|
|
6
|
-
export declare class ActionRegistry {
|
|
7
|
-
private store;
|
|
8
|
-
private components;
|
|
9
|
-
private hot;
|
|
10
|
-
private messageReactions;
|
|
11
|
-
constructor(opts: {
|
|
12
|
-
store: ActionStore;
|
|
13
|
-
});
|
|
14
|
-
/** Cache a `<Message onReaction>` handler for the posted message (same-process). */
|
|
15
|
-
registerMessageReaction(messageId: string, handler: MessageReactionHandler): void;
|
|
16
|
-
/**
|
|
17
|
-
* Persist the message's reaction handler as a `{ component, props }` snapshot
|
|
18
|
-
* keyed by `messageId`, so a reaction after a restart re-renders the component
|
|
19
|
-
* and re-derives the handler — durable exactly like a registered-component
|
|
20
|
-
* `onClick` (and degrading the same way for inline/anonymous components).
|
|
21
|
-
*/
|
|
22
|
-
persistMessageReaction(messageId: string, snap: {
|
|
23
|
-
component: string;
|
|
24
|
-
props: Record<string, unknown>;
|
|
25
|
-
conversationKey: string;
|
|
26
|
-
}): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Resolve the `onReaction` handler for `messageId`: the hot cache first, then
|
|
29
|
-
* the durable snapshot (re-rendering the named component and re-plucking the
|
|
30
|
-
* root's handler). Returns `undefined` when neither resolves — e.g. an inline
|
|
31
|
-
* handler whose closure can't be re-derived after a restart.
|
|
32
|
-
*/
|
|
33
|
-
resolveMessageReaction(messageId: string): Promise<MessageReactionHandler | undefined>;
|
|
34
|
-
registerComponent(name: string, fn: ComponentFn): void;
|
|
35
|
-
clearHotCache(): void;
|
|
36
|
-
bindTree(componentName: string, props: Record<string, unknown>, conversationKey: string): Promise<BotNode[]>;
|
|
37
|
-
bindRenderable(ui: Renderable, conversationKey: string): Promise<{
|
|
38
|
-
root: BotNode[];
|
|
39
|
-
onReaction?: MessageReactionHandler;
|
|
40
|
-
/**
|
|
41
|
-
* The component + props to persist for durable reaction routing, present
|
|
42
|
-
* only when `ui` was a component element with an `onReaction` (an inline IR
|
|
43
|
-
* tree has no component to re-render, so its handler stays in-memory).
|
|
44
|
-
*/
|
|
45
|
-
reactionComponent?: {
|
|
46
|
-
component: string;
|
|
47
|
-
props: Record<string, unknown>;
|
|
48
|
-
};
|
|
49
|
-
}>;
|
|
50
|
-
private walk;
|
|
51
|
-
/**
|
|
52
|
-
* Run the click handler for `id` and return the clicked element's `value`
|
|
53
|
-
* (so callers can resolve a HITL `awaitChoice` waiter even when the platform
|
|
54
|
-
* couldn't carry the value in its callback payload). Returns `undefined` when
|
|
55
|
-
* the element has no `value`.
|
|
56
|
-
*/
|
|
57
|
-
dispatch(id: string, ctx: InteractionContext): Promise<unknown>;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=action-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-registry.d.ts","sourceRoot":"","sources":["../src/action-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAEP,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,EAAE,EAAE,MAAM;CAIvB;AAcD,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,UAAU,CAAkC;IAKpD,OAAO,CAAC,GAAG,CAAgE;IAI3E,OAAO,CAAC,gBAAgB,CAA6C;gBAEzD,IAAI,EAAE;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE;IAIxC,oFAAoF;IACpF,uBAAuB,CACrB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,sBAAsB,GAC9B,IAAI;IAIP;;;;;OAKG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,eAAe,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;OAKG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAa9C,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI;IAItD,aAAa,IAAI,IAAI;IAMf,QAAQ,CACZ,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,OAAO,EAAE,CAAC;IAcf,cAAc,CAClB,EAAE,EAAE,UAAU,EACd,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC;QACT,IAAI,EAAE,OAAO,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,sBAAsB,CAAC;QACpC;;;;WAIG;QACH,iBAAiB,CAAC,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,CAAC;KAC3E,CAAC;YAuBY,IAAI;IA0ClB;;;;;OAKG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAsBtE"}
|
package/dist/action-registry.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { isBound, getBoundArgs, renderToIR } from "@copilotkit/channels-ui";
|
|
2
|
-
import { mintId } from "./mint-id.js";
|
|
3
|
-
export class ActionExpiredError extends Error {
|
|
4
|
-
constructor(id) {
|
|
5
|
-
super(`Action "${id}" has expired or is no longer available.`);
|
|
6
|
-
this.name = "ActionExpiredError";
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
const EVENT_PROPS = ["onClick", "onSelect", "onSubmit"];
|
|
10
|
-
function isComponentElement(ui) {
|
|
11
|
-
return (typeof ui === "object" &&
|
|
12
|
-
ui !== null &&
|
|
13
|
-
typeof ui.type === "function");
|
|
14
|
-
}
|
|
15
|
-
export class ActionRegistry {
|
|
16
|
-
store;
|
|
17
|
-
components = new Map();
|
|
18
|
-
// Cache the handler AND the element's `value` per minted id. The value is
|
|
19
|
-
// needed to resolve HITL `awaitChoice` waiters on platforms whose callback
|
|
20
|
-
// payload can't carry it (e.g. Telegram's 64-byte callback_data only holds
|
|
21
|
-
// the action id), where `evt.value` arrives undefined.
|
|
22
|
-
hot = new Map();
|
|
23
|
-
// Same-process fast path for `<Message onReaction>` handlers, keyed by the
|
|
24
|
-
// posted message's id. Mirrors the `hot` action cache; the durable snapshot
|
|
25
|
-
// (below) is the cross-restart counterpart, exactly like onClick.
|
|
26
|
-
messageReactions = new Map();
|
|
27
|
-
constructor(opts) {
|
|
28
|
-
this.store = opts.store;
|
|
29
|
-
}
|
|
30
|
-
/** Cache a `<Message onReaction>` handler for the posted message (same-process). */
|
|
31
|
-
registerMessageReaction(messageId, handler) {
|
|
32
|
-
this.messageReactions.set(messageId, handler);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Persist the message's reaction handler as a `{ component, props }` snapshot
|
|
36
|
-
* keyed by `messageId`, so a reaction after a restart re-renders the component
|
|
37
|
-
* and re-derives the handler — durable exactly like a registered-component
|
|
38
|
-
* `onClick` (and degrading the same way for inline/anonymous components).
|
|
39
|
-
*/
|
|
40
|
-
async persistMessageReaction(messageId, snap) {
|
|
41
|
-
await this.store.put(reactionKey(messageId), {
|
|
42
|
-
component: snap.component,
|
|
43
|
-
props: snap.props,
|
|
44
|
-
path: [],
|
|
45
|
-
conversationKey: snap.conversationKey,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Resolve the `onReaction` handler for `messageId`: the hot cache first, then
|
|
50
|
-
* the durable snapshot (re-rendering the named component and re-plucking the
|
|
51
|
-
* root's handler). Returns `undefined` when neither resolves — e.g. an inline
|
|
52
|
-
* handler whose closure can't be re-derived after a restart.
|
|
53
|
-
*/
|
|
54
|
-
async resolveMessageReaction(messageId) {
|
|
55
|
-
const hot = this.messageReactions.get(messageId);
|
|
56
|
-
if (hot)
|
|
57
|
-
return hot;
|
|
58
|
-
const snap = await this.store.get(reactionKey(messageId));
|
|
59
|
-
if (!snap?.component)
|
|
60
|
-
return undefined;
|
|
61
|
-
const fn = this.components.get(snap.component);
|
|
62
|
-
if (!fn)
|
|
63
|
-
return undefined;
|
|
64
|
-
const root = renderToIR(fn(snap.props));
|
|
65
|
-
return takeMessageReaction(root);
|
|
66
|
-
}
|
|
67
|
-
registerComponent(name, fn) {
|
|
68
|
-
this.components.set(name, fn);
|
|
69
|
-
}
|
|
70
|
-
clearHotCache() {
|
|
71
|
-
this.hot.clear();
|
|
72
|
-
}
|
|
73
|
-
// Renders the named component, binds all event-prop handlers in the tree
|
|
74
|
-
// (mint id, hot-cache + ActionStore snapshot, rewrite prop to { id }), returns the bound IR.
|
|
75
|
-
async bindTree(componentName, props, conversationKey) {
|
|
76
|
-
const fn = this.components.get(componentName);
|
|
77
|
-
const root = renderToIR((fn ? fn(props) : props));
|
|
78
|
-
await this.walk(root, [], componentName, props, conversationKey);
|
|
79
|
-
return root;
|
|
80
|
-
}
|
|
81
|
-
// Binds an arbitrary Renderable for posting. If `ui` is a component element
|
|
82
|
-
// (`{ type: fn, props }`), it is registered + bound by name (cold-path
|
|
83
|
-
// re-render supported). Otherwise the IR is bound inline with `component:""`,
|
|
84
|
-
// meaning a cold-cache dispatch throws ActionExpiredError (intended
|
|
85
|
-
// degradation for inline handlers that can't be re-derived). A top-level
|
|
86
|
-
// `<Message onReaction>` handler is pulled off the IR (so it never reaches the
|
|
87
|
-
// adapter) and returned for the caller to associate with the posted message.
|
|
88
|
-
async bindRenderable(ui, conversationKey) {
|
|
89
|
-
let root;
|
|
90
|
-
let component;
|
|
91
|
-
let props;
|
|
92
|
-
if (isComponentElement(ui)) {
|
|
93
|
-
const fn = ui.type;
|
|
94
|
-
component = fn.name || "anonymous";
|
|
95
|
-
props = (ui.props ?? {});
|
|
96
|
-
this.registerComponent(component, fn);
|
|
97
|
-
root = await this.bindTree(component, props, conversationKey);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
root = renderToIR(ui);
|
|
101
|
-
await this.walk(root, [], "", undefined, conversationKey);
|
|
102
|
-
}
|
|
103
|
-
const onReaction = takeMessageReaction(root);
|
|
104
|
-
return {
|
|
105
|
-
root,
|
|
106
|
-
onReaction,
|
|
107
|
-
reactionComponent: onReaction && component && props ? { component, props } : undefined,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
async walk(nodes, base, comp, props, conv) {
|
|
111
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
112
|
-
const node = nodes[i];
|
|
113
|
-
const path = [...base, i];
|
|
114
|
-
for (const ep of EVENT_PROPS) {
|
|
115
|
-
const handler = node.props[ep];
|
|
116
|
-
if (typeof handler === "function") {
|
|
117
|
-
const fullPath = [...path, ep];
|
|
118
|
-
const id = mintId(comp, fullPath, props);
|
|
119
|
-
this.hot.set(id, {
|
|
120
|
-
handler: handler,
|
|
121
|
-
value: node.props.value,
|
|
122
|
-
});
|
|
123
|
-
await this.store.put(id, {
|
|
124
|
-
component: comp,
|
|
125
|
-
props,
|
|
126
|
-
path: fullPath,
|
|
127
|
-
conversationKey: conv,
|
|
128
|
-
boundArgs: isBound(handler) ? getBoundArgs(handler) : undefined,
|
|
129
|
-
});
|
|
130
|
-
node.props[ep] = { id };
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const children = node.props.children;
|
|
134
|
-
if (Array.isArray(children)) {
|
|
135
|
-
await this.walk(children, [...path, "children"], comp, props, conv);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Run the click handler for `id` and return the clicked element's `value`
|
|
141
|
-
* (so callers can resolve a HITL `awaitChoice` waiter even when the platform
|
|
142
|
-
* couldn't carry the value in its callback payload). Returns `undefined` when
|
|
143
|
-
* the element has no `value`.
|
|
144
|
-
*/
|
|
145
|
-
async dispatch(id, ctx) {
|
|
146
|
-
let handler;
|
|
147
|
-
let value;
|
|
148
|
-
const hot = this.hot.get(id);
|
|
149
|
-
if (hot) {
|
|
150
|
-
handler = hot.handler;
|
|
151
|
-
value = hot.value;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
const snap = await this.store.get(id);
|
|
155
|
-
if (!snap || !snap.component)
|
|
156
|
-
throw new ActionExpiredError(id);
|
|
157
|
-
const fn = this.components.get(snap.component);
|
|
158
|
-
if (!fn)
|
|
159
|
-
throw new ActionExpiredError(id);
|
|
160
|
-
const tree = renderToIR(fn(snap.props));
|
|
161
|
-
handler = pluck(tree, snap.path);
|
|
162
|
-
value = pluckValue(tree, snap.path);
|
|
163
|
-
if (!handler)
|
|
164
|
-
throw new ActionExpiredError(id);
|
|
165
|
-
}
|
|
166
|
-
await handler({ ...ctx, action: { ...ctx.action, id } });
|
|
167
|
-
return value;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
/** Store key for a message's durable reaction snapshot (distinct from minted action ids). */
|
|
171
|
-
function reactionKey(messageId) {
|
|
172
|
-
return `reaction:${messageId}`;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Pull a top-level `<Message onReaction>` handler off the IR, deleting the prop
|
|
176
|
-
* so it never reaches the adapter (a function can't be serialized to a native
|
|
177
|
-
* payload). Returns the handler when the single root node is a `message`.
|
|
178
|
-
*/
|
|
179
|
-
function takeMessageReaction(root) {
|
|
180
|
-
const node = root.length === 1 ? root[0] : undefined;
|
|
181
|
-
if (!node || node.type !== "message" || !("onReaction" in node.props)) {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
const handler = node.props.onReaction;
|
|
185
|
-
delete node.props.onReaction;
|
|
186
|
-
return typeof handler === "function"
|
|
187
|
-
? handler
|
|
188
|
-
: undefined;
|
|
189
|
-
}
|
|
190
|
-
/** Navigate to the node owning the event-prop at `path` and read its `value`. */
|
|
191
|
-
function pluckValue(tree, path) {
|
|
192
|
-
let cur = tree;
|
|
193
|
-
for (const seg of path.slice(0, -1)) {
|
|
194
|
-
if (Array.isArray(cur))
|
|
195
|
-
cur = cur[seg];
|
|
196
|
-
else if (cur && typeof cur === "object")
|
|
197
|
-
cur = cur.props?.[seg];
|
|
198
|
-
else
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
return cur?.props?.value;
|
|
202
|
-
}
|
|
203
|
-
function pluck(tree, path) {
|
|
204
|
-
let cur = tree;
|
|
205
|
-
for (const seg of path.slice(0, -1)) {
|
|
206
|
-
if (Array.isArray(cur))
|
|
207
|
-
cur = cur[seg];
|
|
208
|
-
else if (cur && typeof cur === "object")
|
|
209
|
-
cur = cur.props?.[seg];
|
|
210
|
-
else
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
const ep = path[path.length - 1];
|
|
214
|
-
const node = cur;
|
|
215
|
-
const h = node?.props?.[ep];
|
|
216
|
-
return typeof h === "function" ? h : undefined;
|
|
217
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-registry.test.d.ts","sourceRoot":"","sources":["../src/action-registry.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
-
import { ActionRegistry, ActionExpiredError } from "./action-registry.js";
|
|
3
|
-
import { InMemoryActionStore } from "./action-store.js";
|
|
4
|
-
import { MemoryStore } from "./state/memory-store.js";
|
|
5
|
-
import { kvActionStore } from "./state/kv-action-store.js";
|
|
6
|
-
// Records each click so a test can assert the handler ran — dispatch() now
|
|
7
|
-
// returns the clicked element's `value` (needed to resolve HITL waiters on
|
|
8
|
-
// platforms whose callback payload can't carry it), not the handler's return.
|
|
9
|
-
const clicks = [];
|
|
10
|
-
function Confirm(props) {
|
|
11
|
-
return {
|
|
12
|
-
type: "actions",
|
|
13
|
-
props: {
|
|
14
|
-
children: [
|
|
15
|
-
{
|
|
16
|
-
type: "button",
|
|
17
|
-
props: {
|
|
18
|
-
value: { ok: props.action },
|
|
19
|
-
onClick: ({ action }) => {
|
|
20
|
-
clicks.push(`ok:${props.action}:${action.id}`);
|
|
21
|
-
},
|
|
22
|
-
children: "Yes",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const ctx = {};
|
|
30
|
-
describe("ActionRegistry", () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
clicks.length = 0;
|
|
33
|
-
});
|
|
34
|
-
it("dispatches via hot cache, runs the handler, and returns the element value", async () => {
|
|
35
|
-
const reg = new ActionRegistry({ store: new InMemoryActionStore() });
|
|
36
|
-
reg.registerComponent("Confirm", Confirm);
|
|
37
|
-
const ir = await reg.bindTree("Confirm", { action: "write" }, "conv1");
|
|
38
|
-
const button = ir[0].props.children[0];
|
|
39
|
-
const id = button.props.onClick.id;
|
|
40
|
-
expect(typeof id).toBe("string");
|
|
41
|
-
const value = await reg.dispatch(id, ctx);
|
|
42
|
-
expect(value).toEqual({ ok: "write" });
|
|
43
|
-
expect(clicks[0]).toContain("ok:write:");
|
|
44
|
-
});
|
|
45
|
-
it("cold path re-renders from snapshot when hot cache is cleared, still returning the value", async () => {
|
|
46
|
-
const reg = new ActionRegistry({ store: new InMemoryActionStore() });
|
|
47
|
-
reg.registerComponent("Confirm", Confirm);
|
|
48
|
-
const ir = await reg.bindTree("Confirm", { action: "write" }, "conv1");
|
|
49
|
-
const id = ir[0].props.children[0].props.onClick.id;
|
|
50
|
-
reg.clearHotCache();
|
|
51
|
-
const value = await reg.dispatch(id, ctx);
|
|
52
|
-
expect(value).toEqual({ ok: "write" });
|
|
53
|
-
expect(clicks[0]).toContain("ok:write:");
|
|
54
|
-
});
|
|
55
|
-
it("throws ActionExpiredError on full miss", async () => {
|
|
56
|
-
const reg = new ActionRegistry({ store: new InMemoryActionStore() });
|
|
57
|
-
await expect(reg.dispatch("ck:missing", ctx)).rejects.toBeInstanceOf(ActionExpiredError);
|
|
58
|
-
});
|
|
59
|
-
it("dispatches from a cold registry via a shared store (restart survival)", async () => {
|
|
60
|
-
const state = new MemoryStore();
|
|
61
|
-
// registryA: bind a tree and persist snapshot to shared state
|
|
62
|
-
const regA = new ActionRegistry({ store: kvActionStore(state) });
|
|
63
|
-
regA.registerComponent("Confirm", Confirm);
|
|
64
|
-
const ir = await regA.bindTree("Confirm", { action: "approve" }, "conv-cold");
|
|
65
|
-
const id = ir[0].props.children[0].props.onClick.id;
|
|
66
|
-
// registryB: fresh registry with no hot cache but sharing the same store
|
|
67
|
-
const regB = new ActionRegistry({ store: kvActionStore(state) });
|
|
68
|
-
regB.registerComponent("Confirm", Confirm);
|
|
69
|
-
const value = await regB.dispatch(id, ctx);
|
|
70
|
-
expect(value).toEqual({ ok: "approve" });
|
|
71
|
-
expect(clicks[0]).toContain("ok:approve:");
|
|
72
|
-
});
|
|
73
|
-
it("throws ActionExpiredError when the snapshot is absent (missing id)", async () => {
|
|
74
|
-
const reg = new ActionRegistry({
|
|
75
|
-
store: kvActionStore(new MemoryStore()),
|
|
76
|
-
});
|
|
77
|
-
await expect(reg.dispatch("ck:missing", ctx)).rejects.toBeInstanceOf(ActionExpiredError);
|
|
78
|
-
});
|
|
79
|
-
describe("components-seeded registry (createBot components option)", () => {
|
|
80
|
-
it("enables cold dispatch after simulated restart when component is pre-registered", async () => {
|
|
81
|
-
// Shared store survives the "restart" (like Redis across process restarts).
|
|
82
|
-
const sharedState = new MemoryStore();
|
|
83
|
-
// Registry A: bind a named component and persist its snapshot.
|
|
84
|
-
const regA = new ActionRegistry({ store: kvActionStore(sharedState) });
|
|
85
|
-
regA.registerComponent("Confirm", Confirm);
|
|
86
|
-
const ir = await regA.bindTree("Confirm", { action: "restart-test" }, "conv-restart");
|
|
87
|
-
const id = ir[0].props.children[0].props.onClick.id;
|
|
88
|
-
// Registry B: fresh process — no hot cache, but component is seeded via
|
|
89
|
-
// the createBot `components` option equivalent (registerComponent at startup).
|
|
90
|
-
const regB = new ActionRegistry({ store: kvActionStore(sharedState) });
|
|
91
|
-
regB.registerComponent("Confirm", Confirm);
|
|
92
|
-
// Cold dispatch must succeed and fire the handler.
|
|
93
|
-
const handlerFired = [];
|
|
94
|
-
// Wrap the existing Confirm component so we can assert the specific call.
|
|
95
|
-
const value = await regB.dispatch(id, ctx);
|
|
96
|
-
expect(value).toEqual({ ok: "restart-test" });
|
|
97
|
-
// The shared `clicks` array is populated by Confirm's onClick.
|
|
98
|
-
expect(clicks.some((c) => c.includes("ok:restart-test:"))).toBe(true);
|
|
99
|
-
});
|
|
100
|
-
it("throws ActionExpiredError when component is NOT pre-registered (no-registration degradation)", async () => {
|
|
101
|
-
const sharedState = new MemoryStore();
|
|
102
|
-
// Registry A: bind and persist.
|
|
103
|
-
const regA = new ActionRegistry({ store: kvActionStore(sharedState) });
|
|
104
|
-
regA.registerComponent("Confirm", Confirm);
|
|
105
|
-
const ir = await regA.bindTree("Confirm", { action: "no-reg" }, "conv-no-reg");
|
|
106
|
-
const id = ir[0].props.children[0].props.onClick.id;
|
|
107
|
-
// Registry B': fresh process, shared store, but component NOT registered.
|
|
108
|
-
const regBPrime = new ActionRegistry({
|
|
109
|
-
store: kvActionStore(sharedState),
|
|
110
|
-
});
|
|
111
|
-
// Without registration the cold path cannot re-render → ActionExpiredError.
|
|
112
|
-
await expect(regBPrime.dispatch(id, ctx)).rejects.toBeInstanceOf(ActionExpiredError);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
package/dist/action-store.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface ActionSnapshot {
|
|
2
|
-
component?: string;
|
|
3
|
-
props?: unknown;
|
|
4
|
-
path: (string | number)[];
|
|
5
|
-
boundArgs?: unknown;
|
|
6
|
-
conversationKey: string;
|
|
7
|
-
}
|
|
8
|
-
/** @deprecated Configure `createBot({ state })` instead. Action snapshots are stored via `StateStore.kv`. */
|
|
9
|
-
export interface ActionStore {
|
|
10
|
-
put(id: string, snap: ActionSnapshot, ttlMs?: number): Promise<void>;
|
|
11
|
-
get(id: string): Promise<ActionSnapshot | undefined>;
|
|
12
|
-
delete(id: string): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
/** @deprecated Configure `createBot({ state })` instead. Action snapshots are stored via `StateStore.kv`. */
|
|
15
|
-
export declare class InMemoryActionStore implements ActionStore {
|
|
16
|
-
private map;
|
|
17
|
-
put(id: string, snap: ActionSnapshot, ttlMs?: number): Promise<void>;
|
|
18
|
-
get(id: string): Promise<ActionSnapshot | undefined>;
|
|
19
|
-
delete(id: string): Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=action-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-store.d.ts","sourceRoot":"","sources":["../src/action-store.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AACD,6GAA6G;AAC7G,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACrD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AACD,6GAA6G;AAC7G,qBAAa,mBAAoB,YAAW,WAAW;IACrD,OAAO,CAAC,GAAG,CAAmE;IACxE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IASpD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
package/dist/action-store.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** @deprecated Configure `createBot({ state })` instead. Action snapshots are stored via `StateStore.kv`. */
|
|
2
|
-
export class InMemoryActionStore {
|
|
3
|
-
map = new Map();
|
|
4
|
-
async put(id, snap, ttlMs) {
|
|
5
|
-
this.map.set(id, {
|
|
6
|
-
snap,
|
|
7
|
-
expiresAt: ttlMs ? Date.now() + ttlMs : undefined,
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
async get(id) {
|
|
11
|
-
const e = this.map.get(id);
|
|
12
|
-
if (!e)
|
|
13
|
-
return undefined;
|
|
14
|
-
if (e.expiresAt !== undefined && Date.now() > e.expiresAt) {
|
|
15
|
-
this.map.delete(id);
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return e.snap;
|
|
19
|
-
}
|
|
20
|
-
async delete(id) {
|
|
21
|
-
this.map.delete(id);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-store.test.d.ts","sourceRoot":"","sources":["../src/action-store.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { InMemoryActionStore } from "./action-store.js";
|
|
3
|
-
describe("InMemoryActionStore", () => {
|
|
4
|
-
it("puts and gets a snapshot", async () => {
|
|
5
|
-
const s = new InMemoryActionStore();
|
|
6
|
-
await s.put("id1", { path: [0], conversationKey: "c" });
|
|
7
|
-
expect(await s.get("id1")).toMatchObject({ path: [0] });
|
|
8
|
-
});
|
|
9
|
-
it("expires entries past ttl", async () => {
|
|
10
|
-
vi.useFakeTimers();
|
|
11
|
-
try {
|
|
12
|
-
const s = new InMemoryActionStore();
|
|
13
|
-
await s.put("id1", { path: [0], conversationKey: "c" }, 1000);
|
|
14
|
-
vi.advanceTimersByTime(1500);
|
|
15
|
-
expect(await s.get("id1")).toBeUndefined();
|
|
16
|
-
}
|
|
17
|
-
finally {
|
|
18
|
-
vi.useRealTimers();
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
it("deletes entries", async () => {
|
|
22
|
-
const s = new InMemoryActionStore();
|
|
23
|
-
await s.put("id1", { path: [0], conversationKey: "c" });
|
|
24
|
-
await s.delete("id1");
|
|
25
|
-
expect(await s.get("id1")).toBeUndefined();
|
|
26
|
-
});
|
|
27
|
-
});
|
package/dist/codec.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { BotNode } from "@copilotkit/channels-ui";
|
|
2
|
-
/**
|
|
3
|
-
* A pure, dependency-free, per-platform codec shared by the local adapter and
|
|
4
|
-
* the Intelligence side. It exists so platform *semantics* (how to render IR to
|
|
5
|
-
* a native payload, and — later — how to normalize a native event to the
|
|
6
|
-
* neutral ingress shape) live in ONE place, instead of being duplicated between
|
|
7
|
-
* a credentialed local adapter (Bolt/discord.js) and the Connector Outbox /
|
|
8
|
-
* webhook ingress.
|
|
9
|
-
*
|
|
10
|
-
* Only the two creds/connection-bound concerns stay per-side: the transport
|
|
11
|
-
* (who holds the platform connection) and the credentialed send. The codec
|
|
12
|
-
* excludes both — `renderEgress` is pure (IR → native payload); the actual
|
|
13
|
-
* send happens in the Connector Outbox with Intelligence-owned credentials.
|
|
14
|
-
*
|
|
15
|
-
* TODO(OSS-363): add `normalizeIngress(raw): NeutralEvent` once the pure Slack
|
|
16
|
-
* ingress mapping (mention stripping, stable event-id derivation, real-user
|
|
17
|
-
* filtering, field extraction) is extracted from the Bolt listener so both the
|
|
18
|
-
* local adapter and Intelligence's webhook ingress consume the same logic.
|
|
19
|
-
*/
|
|
20
|
-
export interface PlatformCodec {
|
|
21
|
-
readonly platform: string;
|
|
22
|
-
/** IR → native payload. Pure; opaque to bot core. */
|
|
23
|
-
renderEgress(ir: BotNode[]): unknown;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=codec.d.ts.map
|
package/dist/codec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;CACtC"}
|
package/dist/codec.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|