@copilotkit/channels-core 0.5.0 → 0.5.1-canary.1785633429
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 +35 -14
- package/dist/action-registry.d.ts +15 -3
- package/dist/action-registry.d.ts.map +1 -1
- package/dist/action-registry.js +61 -9
- package/dist/action-registry.test.js +107 -2
- package/dist/action-store.d.ts +23 -0
- package/dist/action-store.d.ts.map +1 -1
- package/dist/action-store.js +11 -0
- package/dist/canonical-run-loop.test.js +6 -1
- package/dist/channel-identity.test.d.ts +2 -0
- package/dist/channel-identity.test.d.ts.map +1 -0
- package/dist/channel-identity.test.js +297 -0
- package/dist/channel-memory.test.d.ts +2 -0
- package/dist/channel-memory.test.d.ts.map +1 -0
- package/dist/channel-memory.test.js +199 -0
- package/dist/commands.d.ts +5 -3
- package/dist/commands.d.ts.map +1 -1
- package/dist/create-channel.d.ts +30 -56
- package/dist/create-channel.d.ts.map +1 -1
- package/dist/create-channel.foundations.test.js +30 -7
- package/dist/create-channel.js +209 -72
- package/dist/create-channel.test.js +293 -66
- package/dist/hitl-continuation.test.d.ts +2 -0
- package/dist/hitl-continuation.test.d.ts.map +1 -0
- package/dist/hitl-continuation.test.js +393 -0
- package/dist/identity.d.ts +51 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +56 -0
- package/dist/identity.test.d.ts +2 -0
- package/dist/identity.test.d.ts.map +1 -0
- package/dist/identity.test.js +109 -0
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/managed-v1-await-choice-guard.test.js +4 -1
- package/dist/memory.d.ts +23 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +25 -0
- package/dist/modal-submit.test.js +21 -6
- package/dist/open-modal.test.js +16 -4
- package/dist/platform-adapter.d.ts +29 -6
- package/dist/platform-adapter.d.ts.map +1 -1
- package/dist/platform-adapter.test.js +2 -0
- package/dist/reactions.test.js +49 -11
- package/dist/run-loop.test.js +30 -5
- package/dist/sanitize-agent-events.test.js +2 -0
- package/dist/source-platform.test.js +24 -9
- package/dist/state/kv-action-store.d.ts.map +1 -1
- package/dist/state/kv-action-store.js +1 -0
- package/dist/state/kv-action-store.test.js +11 -0
- package/dist/state/memory-store.d.ts +1 -0
- package/dist/state/memory-store.d.ts.map +1 -1
- package/dist/state/memory-store.js +9 -0
- package/dist/state/state-store.d.ts +2 -0
- package/dist/state/state-store.d.ts.map +1 -1
- package/dist/telemetry/create-channel-telemetry.test.js +4 -2
- package/dist/telemetry/e2e-telemetry.test.js +1 -0
- package/dist/telemetry/install-id.test.js +5 -0
- package/dist/testing/fake-adapter.d.ts +26 -9
- package/dist/testing/fake-adapter.d.ts.map +1 -1
- package/dist/testing/fake-adapter.js +65 -21
- package/dist/testing/state-store-conformance.d.ts.map +1 -1
- package/dist/testing/state-store-conformance.js +16 -0
- package/dist/thread-capabilities.test.js +29 -9
- package/dist/thread-ephemeral.test.js +8 -5
- package/dist/thread-promise-contract.test.js +4 -0
- package/dist/thread-reactions.test.js +8 -2
- package/dist/thread.d.ts +50 -7
- package/dist/thread.d.ts.map +1 -1
- package/dist/thread.js +163 -17
- package/dist/thread.test.js +4 -0
- package/dist/tools.d.ts +5 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +2 -1
- package/dist/transcripts.d.ts +6 -13
- package/dist/transcripts.d.ts.map +1 -1
- package/dist/transcripts.js +12 -12
- package/dist/transcripts.test.js +28 -29
- package/dist/welcome.test.d.ts +2 -0
- package/dist/welcome.test.d.ts.map +1 -0
- package/dist/welcome.test.js +53 -0
- package/package.json +5 -5
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,yBAAyB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AAO,EACL,gCAAgC,EAChC,iCAAiC,EACjC,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,qBAAqB,CAAC;AAK7B,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EACL,8BAA8B,EAC9B,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { sanitizeAgentEventStream } from "./sanitize-agent-events.js";
|
|
|
8
8
|
// The usual `agent` for a Channel is an AG-UI agent over HTTP. Re-exported so
|
|
9
9
|
// wiring one up needs no second import (any `AbstractAgent` still works).
|
|
10
10
|
export { HttpAgent } from "@ag-ui/client";
|
|
11
|
+
export { ChannelIdentityResolutionError, ChannelIdentityResultError, resolveChannelUser, } from "./identity.js";
|
|
11
12
|
// Thread
|
|
12
13
|
export { Thread } from "./thread.js";
|
|
13
14
|
// Slash commands
|
|
@@ -15,7 +16,7 @@ export { defineChannelCommand, normalizeCommandName, toCommandSpec, } from "./co
|
|
|
15
16
|
// Action store
|
|
16
17
|
export { InMemoryActionStore } from "./action-store.js";
|
|
17
18
|
// Action registry
|
|
18
|
-
export { ActionRegistry, ActionExpiredError } from "./action-registry.js";
|
|
19
|
+
export { ActionRegistry, ActionContinuationMismatchError, ActionExpiredError, } from "./action-registry.js";
|
|
19
20
|
export { MemoryStore } from "./state/memory-store.js";
|
|
20
21
|
// NOTE: `runStateStoreConformance` is intentionally NOT re-exported here. It
|
|
21
22
|
// pulls in `vitest`, so re-exporting it from the package entry would drag a
|
|
@@ -32,7 +33,10 @@ export { toAgentToolDescriptors, parseToolArgs, stringifyHandlerResult, defineCh
|
|
|
32
33
|
export { mintId, stableStringify } from "./mint-id.js";
|
|
33
34
|
// Run loop
|
|
34
35
|
export { runAgentLoop } from "./run-loop.js";
|
|
36
|
+
export { ChannelContinuationRequiredError, ChannelMemorySubjectRequiredError, ChannelMemoryUnavailableError, ChannelMemoryUserRequiredError, } from "./thread.js";
|
|
35
37
|
export { ChannelDeliveryTerminatedError, isChannelDeliveryTerminatedError, } from "./delivery-error.js";
|
|
38
|
+
// Per-run Intelligence Memory grants.
|
|
39
|
+
export { ChannelMemoryGrantInvalidError, hasMemoryAccess, resolveMemoryGrant, } from "./memory.js";
|
|
36
40
|
// Test utilities (also surfaces them for downstream adapter packages' tests).
|
|
37
41
|
export { FakeAdapter, makeFakeRunRenderer } from "./testing/fake-adapter.js";
|
|
38
42
|
export { FakeAgent } from "./testing/fake-agent.js";
|
|
@@ -11,7 +11,10 @@ class NonBlockingManagedAdapter extends FakeAdapter {
|
|
|
11
11
|
}
|
|
12
12
|
async function setupNonBlockingManagedThread() {
|
|
13
13
|
const adapter = new NonBlockingManagedAdapter();
|
|
14
|
-
const channel = createChannel({
|
|
14
|
+
const channel = createChannel({
|
|
15
|
+
identifyUser: "platform",
|
|
16
|
+
adapters: [adapter],
|
|
17
|
+
});
|
|
15
18
|
let thread;
|
|
16
19
|
channel.onThreadStarted(({ thread: activeThread }) => {
|
|
17
20
|
thread = activeThread;
|
package/dist/memory.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ApplicationUser } from "@copilotkit/channels-ui";
|
|
2
|
+
/** Access granted to one Intelligence Memory scope for one agent run. */
|
|
3
|
+
export type MemoryAccess = "none" | "read" | "read-write";
|
|
4
|
+
/** Explicit user and project Memory access for one agent run. */
|
|
5
|
+
export interface MemoryGrant {
|
|
6
|
+
readonly user?: MemoryAccess;
|
|
7
|
+
readonly project?: MemoryAccess;
|
|
8
|
+
}
|
|
9
|
+
/** Fully resolved, immutable Memory context passed to managed execution. */
|
|
10
|
+
export interface ResolvedChannelMemory {
|
|
11
|
+
readonly grant: Required<MemoryGrant>;
|
|
12
|
+
readonly user: ApplicationUser | null;
|
|
13
|
+
}
|
|
14
|
+
/** A JavaScript caller bypassed the typed Channel Memory grant contract. */
|
|
15
|
+
export declare class ChannelMemoryGrantInvalidError extends Error {
|
|
16
|
+
readonly code = "channel_memory_grant_invalid";
|
|
17
|
+
constructor();
|
|
18
|
+
}
|
|
19
|
+
/** Fill omitted scopes with no access. */
|
|
20
|
+
export declare function resolveMemoryGrant(grant: MemoryGrant): Required<MemoryGrant>;
|
|
21
|
+
/** True when a grant requests any Intelligence Memory operation. */
|
|
22
|
+
export declare function hasMemoryAccess(grant: Required<MemoryGrant>): boolean;
|
|
23
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAE1D,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;CACjC;AAED,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CACvC;AAED,4EAA4E;AAC5E,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,QAAQ,CAAC,IAAI,kCAAkC;;CAMhD;AAID,0CAA0C;AAC1C,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,CAY5E;AAED,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAErE"}
|
package/dist/memory.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** A JavaScript caller bypassed the typed Channel Memory grant contract. */
|
|
2
|
+
export class ChannelMemoryGrantInvalidError extends Error {
|
|
3
|
+
code = "channel_memory_grant_invalid";
|
|
4
|
+
constructor() {
|
|
5
|
+
super('Channel Memory access must be "none", "read", or "read-write"');
|
|
6
|
+
this.name = "ChannelMemoryGrantInvalidError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const MEMORY_ACCESS = new Set(["none", "read", "read-write"]);
|
|
10
|
+
/** Fill omitted scopes with no access. */
|
|
11
|
+
export function resolveMemoryGrant(grant) {
|
|
12
|
+
const resolved = Object.freeze({
|
|
13
|
+
user: grant.user ?? "none",
|
|
14
|
+
project: grant.project ?? "none",
|
|
15
|
+
});
|
|
16
|
+
if (!MEMORY_ACCESS.has(resolved.user) ||
|
|
17
|
+
!MEMORY_ACCESS.has(resolved.project)) {
|
|
18
|
+
throw new ChannelMemoryGrantInvalidError();
|
|
19
|
+
}
|
|
20
|
+
return resolved;
|
|
21
|
+
}
|
|
22
|
+
/** True when a grant requests any Intelligence Memory operation. */
|
|
23
|
+
export function hasMemoryAccess(grant) {
|
|
24
|
+
return grant.user !== "none" || grant.project !== "none";
|
|
25
|
+
}
|
|
@@ -5,7 +5,10 @@ import { FakeAdapter } from "./testing/fake-adapter.js";
|
|
|
5
5
|
describe("channel.onModalSubmit / onModalClose", () => {
|
|
6
6
|
it("routes a submission by callbackId and parses values; thread present when conversation context exists", async () => {
|
|
7
7
|
const fake = new FakeAdapter();
|
|
8
|
-
const channel = createChannel({
|
|
8
|
+
const channel = createChannel({
|
|
9
|
+
adapters: [fake],
|
|
10
|
+
identifyUser: ({ actor }) => ({ id: actor.id, name: actor.id }),
|
|
11
|
+
});
|
|
9
12
|
const seen = [];
|
|
10
13
|
channel.onModalSubmit("triage", (evt) => {
|
|
11
14
|
seen.push({
|
|
@@ -19,7 +22,7 @@ describe("channel.onModalSubmit / onModalClose", () => {
|
|
|
19
22
|
const res = await fake.emitModalSubmit({
|
|
20
23
|
callbackId: "triage",
|
|
21
24
|
values: { summary: "boom", prio: "high" },
|
|
22
|
-
|
|
25
|
+
actor: { id: "U1", kind: "human" },
|
|
23
26
|
conversationKey: "c",
|
|
24
27
|
replyTarget: {},
|
|
25
28
|
});
|
|
@@ -35,7 +38,10 @@ describe("channel.onModalSubmit / onModalClose", () => {
|
|
|
35
38
|
});
|
|
36
39
|
it("returns the handler's field errors so the adapter can keep the modal open", async () => {
|
|
37
40
|
const fake = new FakeAdapter();
|
|
38
|
-
const channel = createChannel({
|
|
41
|
+
const channel = createChannel({
|
|
42
|
+
identifyUser: "platform",
|
|
43
|
+
adapters: [fake],
|
|
44
|
+
});
|
|
39
45
|
channel.onModalSubmit("triage", (evt) => evt.values.summary ? undefined : { errors: { summary: "Required" } });
|
|
40
46
|
await channel.ɵruntime.start();
|
|
41
47
|
const res = await fake.emitModalSubmit({
|
|
@@ -46,7 +52,10 @@ describe("channel.onModalSubmit / onModalClose", () => {
|
|
|
46
52
|
});
|
|
47
53
|
it("ignores submissions with no registered handler", async () => {
|
|
48
54
|
const fake = new FakeAdapter();
|
|
49
|
-
const channel = createChannel({
|
|
55
|
+
const channel = createChannel({
|
|
56
|
+
identifyUser: "platform",
|
|
57
|
+
adapters: [fake],
|
|
58
|
+
});
|
|
50
59
|
await channel.ɵruntime.start();
|
|
51
60
|
const res = await fake.emitModalSubmit({
|
|
52
61
|
callbackId: "unknown",
|
|
@@ -56,13 +65,19 @@ describe("channel.onModalSubmit / onModalClose", () => {
|
|
|
56
65
|
});
|
|
57
66
|
it("routes a close by callbackId", async () => {
|
|
58
67
|
const fake = new FakeAdapter();
|
|
59
|
-
const channel = createChannel({
|
|
68
|
+
const channel = createChannel({
|
|
69
|
+
identifyUser: "platform",
|
|
70
|
+
adapters: [fake],
|
|
71
|
+
});
|
|
60
72
|
const closed = [];
|
|
61
73
|
channel.onModalClose("triage", (evt) => {
|
|
62
74
|
closed.push(evt.callbackId);
|
|
63
75
|
});
|
|
64
76
|
await channel.ɵruntime.start();
|
|
65
|
-
await fake.emitModalClose({
|
|
77
|
+
await fake.emitModalClose({
|
|
78
|
+
callbackId: "triage",
|
|
79
|
+
actor: { id: "U2", kind: "human" },
|
|
80
|
+
});
|
|
66
81
|
expect(closed).toEqual(["triage"]);
|
|
67
82
|
});
|
|
68
83
|
});
|
package/dist/open-modal.test.js
CHANGED
|
@@ -13,7 +13,10 @@ const view = Modal({
|
|
|
13
13
|
describe("ctx.openModal", () => {
|
|
14
14
|
it("opens a modal from an interaction when a triggerId is present", async () => {
|
|
15
15
|
const fake = new FakeAdapter();
|
|
16
|
-
const channel = createChannel({
|
|
16
|
+
const channel = createChannel({
|
|
17
|
+
identifyUser: "platform",
|
|
18
|
+
adapters: [fake],
|
|
19
|
+
});
|
|
17
20
|
let res;
|
|
18
21
|
channel.onInteraction("ck:open", async (ctx) => {
|
|
19
22
|
res = await ctx.openModal(view);
|
|
@@ -28,7 +31,10 @@ describe("ctx.openModal", () => {
|
|
|
28
31
|
});
|
|
29
32
|
it("opens a modal from a command", async () => {
|
|
30
33
|
const fake = new FakeAdapter();
|
|
31
|
-
const channel = createChannel({
|
|
34
|
+
const channel = createChannel({
|
|
35
|
+
identifyUser: "platform",
|
|
36
|
+
adapters: [fake],
|
|
37
|
+
});
|
|
32
38
|
let res;
|
|
33
39
|
channel.onCommand("triage", async (ctx) => {
|
|
34
40
|
res = await ctx.openModal(view);
|
|
@@ -40,7 +46,10 @@ describe("ctx.openModal", () => {
|
|
|
40
46
|
});
|
|
41
47
|
it("omits openModal when no triggerId is present", async () => {
|
|
42
48
|
const fake = new FakeAdapter();
|
|
43
|
-
const channel = createChannel({
|
|
49
|
+
const channel = createChannel({
|
|
50
|
+
identifyUser: "platform",
|
|
51
|
+
adapters: [fake],
|
|
52
|
+
});
|
|
44
53
|
let hasOpen = true;
|
|
45
54
|
channel.onInteraction("ck:noop", (ctx) => {
|
|
46
55
|
hasOpen = typeof ctx.openModal === "function";
|
|
@@ -52,7 +61,10 @@ describe("ctx.openModal", () => {
|
|
|
52
61
|
});
|
|
53
62
|
it("omits openModal when the adapter has no modal support", async () => {
|
|
54
63
|
const fake = new FakeAdapter({ modals: false });
|
|
55
|
-
const channel = createChannel({
|
|
64
|
+
const channel = createChannel({
|
|
65
|
+
identifyUser: "platform",
|
|
66
|
+
adapters: [fake],
|
|
67
|
+
});
|
|
56
68
|
let hasOpen = true;
|
|
57
69
|
channel.onInteraction("ck:x", (ctx) => {
|
|
58
70
|
hasOpen = typeof ctx.openModal === "function";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AgentSubscriber, AbstractAgent } from "@ag-ui/client";
|
|
2
|
-
import type { AgentContentPart, ChannelNode, EmojiValue, EphemeralResult, MessageRef, MessageOperation,
|
|
2
|
+
import type { AgentContentPart, ChannelNode, EmojiValue, EphemeralResult, MessageRef, MessageOperation, ProviderActor, ThreadMessage } from "@copilotkit/channels-ui";
|
|
3
|
+
import type { IngressIdentityContext } from "./identity.js";
|
|
4
|
+
import type { ResolvedChannelMemory } from "./memory.js";
|
|
3
5
|
import type { CommandSpec } from "./commands.js";
|
|
4
6
|
import type { StateStore } from "./state/state-store.js";
|
|
5
7
|
import type { AgentToolDescriptor, ContextEntry } from "./tools.js";
|
|
@@ -94,6 +96,8 @@ export interface ChannelAgentLifecycleArgs {
|
|
|
94
96
|
* agent command and never crosses the managed run-open boundary.
|
|
95
97
|
*/
|
|
96
98
|
isResume?: boolean;
|
|
99
|
+
/** Explicit Memory access resolved before agent execution. */
|
|
100
|
+
memory?: ResolvedChannelMemory;
|
|
97
101
|
execute(subscriber: AgentSubscriber, canonicalRun?: CanonicalRunIdentity): Promise<ChannelAgentLoopResult>;
|
|
98
102
|
}
|
|
99
103
|
/**
|
|
@@ -104,7 +108,10 @@ export interface ChannelAgentLifecycleArgs {
|
|
|
104
108
|
export interface IngressEventBase {
|
|
105
109
|
conversationKey: string;
|
|
106
110
|
replyTarget: ReplyTarget;
|
|
107
|
-
|
|
111
|
+
/** Provider account that caused this event. */
|
|
112
|
+
actor: ProviderActor;
|
|
113
|
+
/** Provider facts used by the Channel identity strategy. */
|
|
114
|
+
identityContext: IngressIdentityContext;
|
|
108
115
|
/**
|
|
109
116
|
* Provider that produced this event when it differs from the transport
|
|
110
117
|
* adapter identity. Multiplexing adapters set it per event.
|
|
@@ -126,6 +133,8 @@ export interface IngressIds {
|
|
|
126
133
|
export interface IncomingTurn extends IngressEventBase, IngressIds {
|
|
127
134
|
userText: string;
|
|
128
135
|
operation: MessageOperation;
|
|
136
|
+
/** Delivery-scoped opaque capability for mutating or reacting to this message. */
|
|
137
|
+
messageRef?: MessageRef;
|
|
129
138
|
/**
|
|
130
139
|
* Optional multimodal content parts built by the adapter (e.g. inbound
|
|
131
140
|
* image/file attachments). Carried through to `IncomingMessage.contentParts`.
|
|
@@ -136,6 +145,8 @@ export interface IncomingTurn extends IngressEventBase, IngressIds {
|
|
|
136
145
|
export interface InteractionEvent extends IngressEventBase, IngressIds {
|
|
137
146
|
id: string;
|
|
138
147
|
value?: unknown;
|
|
148
|
+
/** Submitted input id → value, separate from the clicked action's envelope. */
|
|
149
|
+
values?: Record<string, unknown>;
|
|
139
150
|
/** The message the interaction occurred on (the picker), so handlers can update it in place. */
|
|
140
151
|
messageRef?: MessageRef;
|
|
141
152
|
/** Opaque platform trigger for opening a modal (Slack `trigger_id`; Discord interaction id). */
|
|
@@ -160,6 +171,10 @@ export interface IncomingCommand extends IngressEventBase, IngressIds {
|
|
|
160
171
|
export interface IncomingThreadStart extends IngressEventBase {
|
|
161
172
|
platform: string;
|
|
162
173
|
}
|
|
174
|
+
/** A provider installation or conversation activation that should be welcomed. */
|
|
175
|
+
export interface IncomingWelcome extends IngressEventBase, IngressIds {
|
|
176
|
+
platform: string;
|
|
177
|
+
}
|
|
163
178
|
/** A reaction added/removed on a message. Adapters that can't observe reactions never emit it. */
|
|
164
179
|
export interface IncomingReaction extends IngressEventBase {
|
|
165
180
|
/** Platform-native emoji token (Slack shortcode, Unicode, Discord custom). */
|
|
@@ -194,7 +209,8 @@ export interface IncomingModalSubmit {
|
|
|
194
209
|
callbackId: string;
|
|
195
210
|
/** Field id → value (text string, selected option value, etc.). */
|
|
196
211
|
values: Record<string, unknown>;
|
|
197
|
-
|
|
212
|
+
actor: ProviderActor;
|
|
213
|
+
identityContext: IngressIdentityContext;
|
|
198
214
|
privateMetadata?: string;
|
|
199
215
|
/** Present when the submission carries a conversation context (so the engine can build a Thread). */
|
|
200
216
|
conversationKey?: string;
|
|
@@ -205,7 +221,8 @@ export interface IncomingModalSubmit {
|
|
|
205
221
|
/** A modal dismissal (Slack `view_closed`; requires `notifyOnClose`). */
|
|
206
222
|
export interface IncomingModalClose {
|
|
207
223
|
callbackId: string;
|
|
208
|
-
|
|
224
|
+
actor: ProviderActor;
|
|
225
|
+
identityContext: IngressIdentityContext;
|
|
209
226
|
privateMetadata?: string;
|
|
210
227
|
/** Present when the dismissal carries a conversation context (so the engine can build a Thread). */
|
|
211
228
|
conversationKey?: string;
|
|
@@ -220,6 +237,8 @@ export interface ModalSubmitResult {
|
|
|
220
237
|
export interface IngressSink {
|
|
221
238
|
onTurn(turn: IncomingTurn): void | Promise<void>;
|
|
222
239
|
onInteraction(evt: InteractionEvent): void | Promise<void>;
|
|
240
|
+
/** A provider installation or conversation activation became usable. */
|
|
241
|
+
onWelcome(evt: IncomingWelcome): void | Promise<void>;
|
|
223
242
|
/** A slash command fired. Routed to the matching `channel.onCommand` handler (ignored if none). */
|
|
224
243
|
onCommand(cmd: IncomingCommand): void | Promise<void>;
|
|
225
244
|
/** A conversation surface opened. Adapters without the concept never call it. */
|
|
@@ -273,6 +292,8 @@ export interface PlatformAdapter {
|
|
|
273
292
|
readonly platform: string;
|
|
274
293
|
readonly capabilities: SurfaceCapabilities;
|
|
275
294
|
readonly ackDeadlineMs: number;
|
|
295
|
+
/** Return the trusted canonical Thread bound to an opaque reply target. */
|
|
296
|
+
getCanonicalThreadId?(target: ReplyTarget): string;
|
|
276
297
|
start(sink: IngressSink, ctx?: AdapterStartContext): Promise<void>;
|
|
277
298
|
stop(): Promise<void>;
|
|
278
299
|
render(ir: ChannelNode[]): NativePayload;
|
|
@@ -289,6 +310,8 @@ export interface PlatformAdapter {
|
|
|
289
310
|
* containing delivery.
|
|
290
311
|
*/
|
|
291
312
|
assertRunAgentSupported?(target: ReplyTarget): void;
|
|
313
|
+
/** True when this adapter is attached to an Intelligence Memory backend. */
|
|
314
|
+
supportsIntelligenceMemory?: boolean;
|
|
292
315
|
runAgentLifecycle?(args: ChannelAgentLifecycleArgs): Promise<ChannelAgentLoopResult>;
|
|
293
316
|
/**
|
|
294
317
|
* Optional delivery-lifecycle hook. {@link Thread} invokes this synchronously
|
|
@@ -297,7 +320,7 @@ export interface PlatformAdapter {
|
|
|
297
320
|
*/
|
|
298
321
|
trackThreadOperation?<T>(target: ReplyTarget, operation: () => Promise<T>): Promise<T>;
|
|
299
322
|
decodeInteraction(raw: unknown): InteractionEvent | undefined;
|
|
300
|
-
lookupUser(q: UserQuery): Promise<
|
|
323
|
+
lookupUser(q: UserQuery): Promise<ProviderActor | undefined>;
|
|
301
324
|
readonly conversationStore: ConversationStore;
|
|
302
325
|
/**
|
|
303
326
|
* Optional persistence backend supplied by the adapter. `createChannel` uses it
|
|
@@ -391,7 +414,7 @@ export interface PlatformAdapter {
|
|
|
391
414
|
* native vs DM fallback based on `opts.fallbackToDM` and returns
|
|
392
415
|
* `{ ok, usedFallback }` or `null` (native unsupported and no fallback).
|
|
393
416
|
*/
|
|
394
|
-
postEphemeral?(target: ReplyTarget, user:
|
|
417
|
+
postEphemeral?(target: ReplyTarget, user: ProviderActor | string, ir: ChannelNode[], opts: {
|
|
395
418
|
fallbackToDM: boolean;
|
|
396
419
|
}): Promise<EphemeralResult | null>;
|
|
397
420
|
/** Optional modal render (pure; backs `openModal`). Throws `ModalRenderError` on unsupported elements. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-adapter.d.ts","sourceRoot":"","sources":["../src/platform-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"platform-adapter.d.ts","sourceRoot":"","sources":["../src/platform-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEpE,mHAAmH;AACnH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAClC,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC;AAEpC,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;I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
+
onWelcome: () => { },
|
|
12
13
|
onCommand: () => { },
|
|
13
14
|
onThreadStarted: () => { },
|
|
14
15
|
onReaction: () => { },
|
|
@@ -28,6 +29,7 @@ describe("FakeAdapter", () => {
|
|
|
28
29
|
onInteraction: (e) => {
|
|
29
30
|
id = e.id;
|
|
30
31
|
},
|
|
32
|
+
onWelcome: () => { },
|
|
31
33
|
onCommand: () => { },
|
|
32
34
|
onThreadStarted: () => { },
|
|
33
35
|
onReaction: () => { },
|
package/dist/reactions.test.js
CHANGED
|
@@ -8,7 +8,10 @@ const tick = () => new Promise((r) => setTimeout(r, 0));
|
|
|
8
8
|
describe("channel.onReaction", () => {
|
|
9
9
|
it("routes a specific reaction, normalizing the platform token", async () => {
|
|
10
10
|
const fake = new FakeAdapter();
|
|
11
|
-
const channel = createChannel({
|
|
11
|
+
const channel = createChannel({
|
|
12
|
+
adapters: [fake],
|
|
13
|
+
identifyUser: ({ actor }) => actor.kind === "human" ? { id: actor.id, name: actor.id } : null,
|
|
14
|
+
});
|
|
12
15
|
const seen = [];
|
|
13
16
|
channel.onReaction([emoji.thumbs_up], (evt) => {
|
|
14
17
|
seen.push({ emoji: evt.emoji, raw: evt.rawEmoji, added: evt.added });
|
|
@@ -24,13 +27,17 @@ describe("channel.onReaction", () => {
|
|
|
24
27
|
});
|
|
25
28
|
it("fires a catch-all for any reaction and reports added/removed", async () => {
|
|
26
29
|
const fake = new FakeAdapter();
|
|
27
|
-
const channel = createChannel({
|
|
30
|
+
const channel = createChannel({
|
|
31
|
+
adapters: [fake],
|
|
32
|
+
identifyUser: ({ actor }) => actor.kind === "human" ? { id: actor.id, name: actor.id } : null,
|
|
33
|
+
});
|
|
28
34
|
const seen = [];
|
|
29
35
|
channel.onReaction((evt) => {
|
|
30
36
|
seen.push({
|
|
31
37
|
raw: evt.rawEmoji,
|
|
32
38
|
added: evt.added,
|
|
33
39
|
user: evt.user?.id,
|
|
40
|
+
actor: evt.actor.id,
|
|
34
41
|
messageId: evt.messageId,
|
|
35
42
|
platform: evt.thread.platform,
|
|
36
43
|
});
|
|
@@ -39,17 +46,25 @@ describe("channel.onReaction", () => {
|
|
|
39
46
|
fake.emitReaction({
|
|
40
47
|
rawEmoji: "🎉",
|
|
41
48
|
added: true,
|
|
42
|
-
|
|
49
|
+
actor: { id: "U1", kind: "human" },
|
|
43
50
|
messageId: "m9",
|
|
44
51
|
});
|
|
45
52
|
fake.emitReaction({ rawEmoji: "🎉", added: false, messageId: "m9" });
|
|
46
53
|
await tick();
|
|
47
54
|
expect(seen).toEqual([
|
|
48
|
-
{
|
|
55
|
+
{
|
|
56
|
+
raw: "🎉",
|
|
57
|
+
added: true,
|
|
58
|
+
user: "U1",
|
|
59
|
+
actor: "U1",
|
|
60
|
+
messageId: "m9",
|
|
61
|
+
platform: "fake",
|
|
62
|
+
},
|
|
49
63
|
{
|
|
50
64
|
raw: "🎉",
|
|
51
65
|
added: false,
|
|
52
66
|
user: undefined,
|
|
67
|
+
actor: "",
|
|
53
68
|
messageId: "m9",
|
|
54
69
|
platform: "fake",
|
|
55
70
|
},
|
|
@@ -59,7 +74,10 @@ describe("channel.onReaction", () => {
|
|
|
59
74
|
// A fake whose platform === "slack" so normalizeEmoji maps the shortcode.
|
|
60
75
|
const fake = new FakeAdapter();
|
|
61
76
|
Object.defineProperty(fake, "platform", { value: "slack" });
|
|
62
|
-
const channel = createChannel({
|
|
77
|
+
const channel = createChannel({
|
|
78
|
+
identifyUser: "platform",
|
|
79
|
+
adapters: [fake],
|
|
80
|
+
});
|
|
63
81
|
const hits = [];
|
|
64
82
|
channel.onReaction(["thumbs_up"], (evt) => {
|
|
65
83
|
hits.push(evt.emoji);
|
|
@@ -75,7 +93,10 @@ describe("channel.onReaction", () => {
|
|
|
75
93
|
// its source provider. Core must normalize by that source platform, so a
|
|
76
94
|
// Teams `<codepoint>_<name>` token resolves to its canonical name.
|
|
77
95
|
const fake = new FakeAdapter({ platform: "intelligence" });
|
|
78
|
-
const channel = createChannel({
|
|
96
|
+
const channel = createChannel({
|
|
97
|
+
identifyUser: "platform",
|
|
98
|
+
adapters: [fake],
|
|
99
|
+
});
|
|
79
100
|
const hits = [];
|
|
80
101
|
channel.onReaction(["refresh"], (evt) => {
|
|
81
102
|
hits.push(evt.emoji);
|
|
@@ -91,7 +112,10 @@ describe("channel.onReaction", () => {
|
|
|
91
112
|
});
|
|
92
113
|
it("routes a reaction on a posted message to its <Message onReaction>", async () => {
|
|
93
114
|
const fake = new FakeAdapter();
|
|
94
|
-
const channel = createChannel({
|
|
115
|
+
const channel = createChannel({
|
|
116
|
+
identifyUser: "platform",
|
|
117
|
+
adapters: [fake],
|
|
118
|
+
});
|
|
95
119
|
const seen = [];
|
|
96
120
|
channel.onMessage(async ({ thread }) => {
|
|
97
121
|
await thread.post(Message({
|
|
@@ -117,7 +141,10 @@ describe("channel.onReaction", () => {
|
|
|
117
141
|
});
|
|
118
142
|
it("resolves <Message onReaction> by postedMessageId when the reaction id differs (Channel path)", async () => {
|
|
119
143
|
const fake = new FakeAdapter();
|
|
120
|
-
const channel = createChannel({
|
|
144
|
+
const channel = createChannel({
|
|
145
|
+
identifyUser: "platform",
|
|
146
|
+
adapters: [fake],
|
|
147
|
+
});
|
|
121
148
|
const seen = [];
|
|
122
149
|
channel.onMessage(async ({ thread }) => {
|
|
123
150
|
await thread.post(Message({
|
|
@@ -156,6 +183,7 @@ describe("channel.onReaction", () => {
|
|
|
156
183
|
// Bot 1 posts the component message, persisting a reaction snapshot.
|
|
157
184
|
const fake1 = new FakeAdapter();
|
|
158
185
|
const bot1 = createChannel({
|
|
186
|
+
identifyUser: "platform",
|
|
159
187
|
adapters: [fake1],
|
|
160
188
|
store: { adapter: backend },
|
|
161
189
|
components: [Card],
|
|
@@ -172,6 +200,7 @@ describe("channel.onReaction", () => {
|
|
|
172
200
|
// Its reaction hot cache is empty, so it must resolve via the durable snapshot.
|
|
173
201
|
const fake2 = new FakeAdapter();
|
|
174
202
|
const bot2 = createChannel({
|
|
203
|
+
identifyUser: "platform",
|
|
175
204
|
adapters: [fake2],
|
|
176
205
|
store: { adapter: backend },
|
|
177
206
|
components: [Card],
|
|
@@ -183,7 +212,10 @@ describe("channel.onReaction", () => {
|
|
|
183
212
|
});
|
|
184
213
|
it("gives the handler a thread to post new UI and the reacted message's ref", async () => {
|
|
185
214
|
const fake = new FakeAdapter();
|
|
186
|
-
const channel = createChannel({
|
|
215
|
+
const channel = createChannel({
|
|
216
|
+
identifyUser: "platform",
|
|
217
|
+
adapters: [fake],
|
|
218
|
+
});
|
|
187
219
|
let seenRefId;
|
|
188
220
|
channel.onMessage(async ({ thread }) => {
|
|
189
221
|
await thread.post(Message({
|
|
@@ -207,7 +239,10 @@ describe("channel.onReaction", () => {
|
|
|
207
239
|
});
|
|
208
240
|
it("does not fire a message handler for a reaction on a different message", async () => {
|
|
209
241
|
const fake = new FakeAdapter();
|
|
210
|
-
const channel = createChannel({
|
|
242
|
+
const channel = createChannel({
|
|
243
|
+
identifyUser: "platform",
|
|
244
|
+
adapters: [fake],
|
|
245
|
+
});
|
|
211
246
|
let fired = false;
|
|
212
247
|
channel.onMessage(async ({ thread }) => {
|
|
213
248
|
await thread.post(Message({
|
|
@@ -229,7 +264,10 @@ describe("channel.onReaction", () => {
|
|
|
229
264
|
// Slack alias to the canonical "thumbs_up", so the filter must too.
|
|
230
265
|
const fake = new FakeAdapter();
|
|
231
266
|
Object.defineProperty(fake, "platform", { value: "slack" });
|
|
232
|
-
const channel = createChannel({
|
|
267
|
+
const channel = createChannel({
|
|
268
|
+
identifyUser: "platform",
|
|
269
|
+
adapters: [fake],
|
|
270
|
+
});
|
|
233
271
|
const hits = [];
|
|
234
272
|
channel.onReaction(["👍"], (evt) => {
|
|
235
273
|
hits.push(evt.emoji);
|
package/dist/run-loop.test.js
CHANGED
|
@@ -40,7 +40,12 @@ describe("runAgentLoop", () => {
|
|
|
40
40
|
tools,
|
|
41
41
|
toolDescriptors,
|
|
42
42
|
context,
|
|
43
|
-
makeToolCtx: () => ({
|
|
43
|
+
makeToolCtx: () => ({
|
|
44
|
+
thread: {},
|
|
45
|
+
user: null,
|
|
46
|
+
actor: { id: "actor", kind: "unknown" },
|
|
47
|
+
platform: "fake",
|
|
48
|
+
}),
|
|
44
49
|
});
|
|
45
50
|
expect(recorded).toEqual([{ msg: "hi" }]);
|
|
46
51
|
expect(agent.runAgentCalls).toBe(2);
|
|
@@ -77,7 +82,12 @@ describe("runAgentLoop", () => {
|
|
|
77
82
|
tools: new Map([["recoverable", tool]]),
|
|
78
83
|
toolDescriptors,
|
|
79
84
|
context,
|
|
80
|
-
makeToolCtx: () => ({
|
|
85
|
+
makeToolCtx: () => ({
|
|
86
|
+
thread: {},
|
|
87
|
+
user: null,
|
|
88
|
+
actor: { id: "actor", kind: "unknown" },
|
|
89
|
+
platform: "fake",
|
|
90
|
+
}),
|
|
81
91
|
});
|
|
82
92
|
expect(agent.runAgentCalls).toBe(2);
|
|
83
93
|
expect(agent.messages.find(({ role }) => role === "tool")).toMatchObject({
|
|
@@ -103,7 +113,12 @@ describe("runAgentLoop", () => {
|
|
|
103
113
|
tools,
|
|
104
114
|
toolDescriptors,
|
|
105
115
|
context,
|
|
106
|
-
makeToolCtx: () => ({
|
|
116
|
+
makeToolCtx: () => ({
|
|
117
|
+
thread: {},
|
|
118
|
+
user: null,
|
|
119
|
+
actor: { id: "actor", kind: "unknown" },
|
|
120
|
+
platform: "fake",
|
|
121
|
+
}),
|
|
107
122
|
handleInterrupt,
|
|
108
123
|
});
|
|
109
124
|
expect(handleInterrupt).toHaveBeenCalledTimes(1);
|
|
@@ -132,7 +147,12 @@ describe("runAgentLoop", () => {
|
|
|
132
147
|
tools,
|
|
133
148
|
toolDescriptors,
|
|
134
149
|
context,
|
|
135
|
-
makeToolCtx: () => ({
|
|
150
|
+
makeToolCtx: () => ({
|
|
151
|
+
thread: {},
|
|
152
|
+
user: null,
|
|
153
|
+
actor: { id: "actor", kind: "unknown" },
|
|
154
|
+
platform: "fake",
|
|
155
|
+
}),
|
|
136
156
|
handleInterrupt,
|
|
137
157
|
};
|
|
138
158
|
const result = await runAgentLoop(args);
|
|
@@ -153,7 +173,12 @@ describe("runAgentLoop", () => {
|
|
|
153
173
|
tools,
|
|
154
174
|
toolDescriptors,
|
|
155
175
|
context,
|
|
156
|
-
makeToolCtx: () => ({
|
|
176
|
+
makeToolCtx: () => ({
|
|
177
|
+
thread: {},
|
|
178
|
+
user: null,
|
|
179
|
+
actor: { id: "actor", kind: "unknown" },
|
|
180
|
+
platform: "fake",
|
|
181
|
+
}),
|
|
157
182
|
};
|
|
158
183
|
const result = await runAgentLoop(args);
|
|
159
184
|
expect(result.interrupted).toBe(false);
|
|
@@ -139,6 +139,7 @@ describe("createChannel({ sanitizeAgentEvents })", () => {
|
|
|
139
139
|
async function runTurn(agent, opts) {
|
|
140
140
|
const fake = new FakeAdapter();
|
|
141
141
|
const channel = createChannel({
|
|
142
|
+
identifyUser: "platform",
|
|
142
143
|
adapters: [fake],
|
|
143
144
|
agent: () => agent,
|
|
144
145
|
...opts,
|
|
@@ -167,6 +168,7 @@ describe("createChannel({ sanitizeAgentEvents })", () => {
|
|
|
167
168
|
// sanitizing has to live on the transport to reach the cloned instance.
|
|
168
169
|
const fake = new FakeAdapter();
|
|
169
170
|
const channel = createChannel({
|
|
171
|
+
identifyUser: "platform",
|
|
170
172
|
adapters: [fake],
|
|
171
173
|
agent: agentServing(nullParentRun()),
|
|
172
174
|
});
|