@jsm-mit/agent-platform-canister-package 0.0.1 → 0.0.2
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/declarations/agent-platform-canister/agent-platform-canister.did +7 -0
- package/declarations/agent-platform-canister/agent-platform-canister.did.d.ts +3 -0
- package/declarations/agent-platform-canister/agent-platform-canister.did.js +3 -0
- package/dist/actors/agent-configs-actor.d.ts +2 -1
- package/dist/actors/agent-configs-actor.d.ts.map +1 -1
- package/dist/actors/agent-configs-actor.js +4 -2
- package/dist/interfaces.d.ts +10 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +4 -2
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +10 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type UpsertAgentConfigArgs =
|
|
2
2
|
record {
|
|
3
|
+
channelType: ChannelType;
|
|
3
4
|
customConfigJson: opt text;
|
|
4
5
|
disclosesAsAi: bool;
|
|
5
6
|
id: AgentId;
|
|
@@ -88,10 +89,16 @@ type ChatMessage =
|
|
|
88
89
|
toolCallId: opt text;
|
|
89
90
|
toolName: opt text;
|
|
90
91
|
};
|
|
92
|
+
type ChannelType =
|
|
93
|
+
variant {
|
|
94
|
+
chat;
|
|
95
|
+
whatsapp;
|
|
96
|
+
};
|
|
91
97
|
type AppendMessageBatchArgs = record {entries: vec MessageBatchEntry;};
|
|
92
98
|
type AgentId = text;
|
|
93
99
|
type AgentConfig =
|
|
94
100
|
record {
|
|
101
|
+
channelType: opt ChannelType;
|
|
95
102
|
createdAt: int;
|
|
96
103
|
customConfigJson: opt text;
|
|
97
104
|
disclosesAsAi: bool;
|
|
@@ -5,6 +5,7 @@ import type { IDL } from "@icp-sdk/core/candid";
|
|
|
5
5
|
export interface AgentConfig {
|
|
6
6
|
id: AgentId;
|
|
7
7
|
tools: Array<ToolBinding>;
|
|
8
|
+
channelType: [] | [ChannelType];
|
|
8
9
|
name: string;
|
|
9
10
|
createdAt: bigint;
|
|
10
11
|
updatedAt: bigint;
|
|
@@ -16,6 +17,7 @@ export type AgentId = string;
|
|
|
16
17
|
export interface AppendMessageBatchArgs {
|
|
17
18
|
entries: Array<MessageBatchEntry>;
|
|
18
19
|
}
|
|
20
|
+
export type ChannelType = { chat: null } | { whatsapp: null };
|
|
19
21
|
export interface ChatMessage {
|
|
20
22
|
content: string;
|
|
21
23
|
role: ChatMessageRole;
|
|
@@ -61,6 +63,7 @@ export interface ToolBinding {
|
|
|
61
63
|
export interface UpsertAgentConfigArgs {
|
|
62
64
|
id: AgentId;
|
|
63
65
|
tools: Array<ToolBinding>;
|
|
66
|
+
channelType: ChannelType;
|
|
64
67
|
name: string;
|
|
65
68
|
persona: string;
|
|
66
69
|
disclosesAsAi: boolean;
|
|
@@ -41,9 +41,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
41
41
|
paramsJson: IDL.Text,
|
|
42
42
|
tool: IDL.Text,
|
|
43
43
|
});
|
|
44
|
+
const ChannelType = IDL.Variant({ chat: IDL.Null, whatsapp: IDL.Null });
|
|
44
45
|
const AgentConfig = IDL.Record({
|
|
45
46
|
id: AgentId,
|
|
46
47
|
tools: IDL.Vec(ToolBinding),
|
|
48
|
+
channelType: IDL.Opt(ChannelType),
|
|
47
49
|
name: IDL.Text,
|
|
48
50
|
createdAt: IDL.Int,
|
|
49
51
|
updatedAt: IDL.Int,
|
|
@@ -62,6 +64,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
62
64
|
const UpsertAgentConfigArgs = IDL.Record({
|
|
63
65
|
id: AgentId,
|
|
64
66
|
tools: IDL.Vec(ToolBinding),
|
|
67
|
+
channelType: ChannelType,
|
|
65
68
|
name: IDL.Text,
|
|
66
69
|
persona: IDL.Text,
|
|
67
70
|
disclosesAsAi: IDL.Bool,
|
|
@@ -8,7 +8,8 @@ export declare class AgentConfigsActor extends ActorBase {
|
|
|
8
8
|
* Creates the config on first write, otherwise updates it in place —
|
|
9
9
|
* `createdAt` is preserved across an update. Admin only.
|
|
10
10
|
* @param input - The full desired config; `id` decides create-vs-update. `tools`
|
|
11
|
-
* defaults to [] (a tool-less agent) when omitted.
|
|
11
|
+
* defaults to [] (a tool-less agent) when omitted. `channelType` is required —
|
|
12
|
+
* every agent must declare which outbound channel it uses.
|
|
12
13
|
* @returns The stored config as it now stands.
|
|
13
14
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, or `InvalidData` — a bounded field was too long/too many entries). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
14
15
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-configs-actor.d.ts","sourceRoot":"","sources":["../../src/actors/agent-configs-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,6DAA6D;AAC7D,qBAAa,iBAAkB,SAAQ,SAAS;gBAChC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD
|
|
1
|
+
{"version":3,"file":"agent-configs-actor.d.ts","sourceRoot":"","sources":["../../src/actors/agent-configs-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,6DAA6D;AAC7D,qBAAa,iBAAkB,SAAQ,SAAS;gBAChC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;;;;;OAUG;IACU,4BAA4B,CACrC,KAAK,EAAE,sBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC;IAe3B;;;;;;OAMG;IACU,yBAAyB,CAClC,EAAE,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC;IAO3B;;;;;;;OAOG;IACU,2BAA2B,CACpC,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,EAAE,CAAC;IAO7B;;;;;;OAMG;IACU,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKvE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {} from "@icp-sdk/core/agent";
|
|
2
2
|
import { ActorBase } from "../actor-base.js";
|
|
3
|
-
import { mapAgentConfigView, toOpt } from "../mappers.js";
|
|
3
|
+
import { mapAgentConfigView, toChannelTypeVariant, toOpt } from "../mappers.js";
|
|
4
4
|
/** 1:1 wrapper for the canister's AgentConfigsController. */
|
|
5
5
|
export class AgentConfigsActor extends ActorBase {
|
|
6
6
|
constructor(canisterId, identity) {
|
|
@@ -10,7 +10,8 @@ export class AgentConfigsActor extends ActorBase {
|
|
|
10
10
|
* Creates the config on first write, otherwise updates it in place —
|
|
11
11
|
* `createdAt` is preserved across an update. Admin only.
|
|
12
12
|
* @param input - The full desired config; `id` decides create-vs-update. `tools`
|
|
13
|
-
* defaults to [] (a tool-less agent) when omitted.
|
|
13
|
+
* defaults to [] (a tool-less agent) when omitted. `channelType` is required —
|
|
14
|
+
* every agent must declare which outbound channel it uses.
|
|
14
15
|
* @returns The stored config as it now stands.
|
|
15
16
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, or `InvalidData` — a bounded field was too long/too many entries). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
16
17
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
@@ -24,6 +25,7 @@ export class AgentConfigsActor extends ActorBase {
|
|
|
24
25
|
disclosesAsAi: input.disclosesAsAi,
|
|
25
26
|
tools: input.tools ?? [],
|
|
26
27
|
customConfigJson: toOpt(input.customConfigJson),
|
|
28
|
+
channelType: toChannelTypeVariant(input.channelType),
|
|
27
29
|
}));
|
|
28
30
|
return mapAgentConfigView(config);
|
|
29
31
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type ChatMessageRoleView = "user" | "assistant" | "tool";
|
|
2
|
+
/** Which outbound channel an agent's replies go out on — decided once at creation,
|
|
3
|
+
* per AGENT-PLATFORM decision 2026-08-19. "chat" is accepted/stored but nothing
|
|
4
|
+
* downstream acts on it yet — only "whatsapp" is implemented (agents-village). */
|
|
5
|
+
export type ChannelTypeView = "whatsapp" | "chat";
|
|
2
6
|
/** Candid `ChatMessage` with the role variant as a string union and opts flattened —
|
|
3
7
|
* matches chat-agent-package's own ChatMessage shape so history round-trips without
|
|
4
8
|
* further translation on the consumer side. */
|
|
@@ -34,6 +38,9 @@ export interface AgentConfigView {
|
|
|
34
38
|
paramsJson: string;
|
|
35
39
|
}[];
|
|
36
40
|
customConfigJson?: string;
|
|
41
|
+
/** Undefined only for an agent created before this field existed and not yet
|
|
42
|
+
* re-saved — every agent upserted through UpsertAgentConfigInput always has one. */
|
|
43
|
+
channelType?: ChannelTypeView;
|
|
37
44
|
/** Nanoseconds since epoch */
|
|
38
45
|
createdAt: bigint;
|
|
39
46
|
/** Nanoseconds since epoch */
|
|
@@ -43,7 +50,8 @@ export interface AgentConfigView {
|
|
|
43
50
|
* plain optional (candid `opt` shaping done by the wrapper); tools is optional here
|
|
44
51
|
* even though the canister's own UpsertAgentConfigArgs requires it — the wrapper
|
|
45
52
|
* defaults a missing tools to [] for a tool-less agent, so callers don't have to
|
|
46
|
-
* spell out `tools: []` every time.
|
|
53
|
+
* spell out `tools: []` every time. channelType is required — the canister's own
|
|
54
|
+
* UpsertAgentConfigArgs requires it too, per AGENT-PLATFORM decision 2026-08-19. */
|
|
47
55
|
export interface UpsertAgentConfigInput {
|
|
48
56
|
id: string;
|
|
49
57
|
name: string;
|
|
@@ -54,5 +62,6 @@ export interface UpsertAgentConfigInput {
|
|
|
54
62
|
paramsJson: string;
|
|
55
63
|
}[];
|
|
56
64
|
customConfigJson?: string;
|
|
65
|
+
channelType: ChannelTypeView;
|
|
57
66
|
}
|
|
58
67
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEhE;;+CAE+C;AAC/C,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;wEACwE;AACxE,MAAM,WAAW,sBAAsB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACL,IAAI,EAAE,mBAAmB,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC;CACL;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C,gBAAgB,CAAC,EAAE,M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AS,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;oFAKoF;AACpF,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,eAAe,CAAC;CAChC"}
|
package/dist/mappers.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { AgentConfig, ChatMessage, ChatMessageRole } from "../declarations/agent-platform-canister/agent-platform-canister.did.js";
|
|
2
|
-
import type { ChatMessageRoleView, ChatMessageView, AgentConfigView } from "./interfaces.js";
|
|
1
|
+
import type { AgentConfig, ChannelType, ChatMessage, ChatMessageRole } from "../declarations/agent-platform-canister/agent-platform-canister.did.js";
|
|
2
|
+
import type { ChannelTypeView, ChatMessageRoleView, ChatMessageView, AgentConfigView } from "./interfaces.js";
|
|
3
3
|
declare function toOpt<T>(value: T | undefined): [] | [T];
|
|
4
4
|
export declare function mapChatMessageRoleView(role: ChatMessageRole): ChatMessageRoleView;
|
|
5
5
|
export declare function toChatMessageRoleVariant(role: ChatMessageRoleView): ChatMessageRole;
|
|
6
6
|
export declare function mapChatMessageView(message: ChatMessage): ChatMessageView;
|
|
7
|
+
export declare function mapChannelTypeView(channelType: ChannelType): ChannelTypeView;
|
|
8
|
+
export declare function toChannelTypeVariant(channelType: ChannelTypeView): ChannelType;
|
|
7
9
|
export declare function mapAgentConfigView(config: AgentConfig): AgentConfigView;
|
|
8
10
|
export { toOpt };
|
|
9
11
|
//# sourceMappingURL=mappers.d.ts.map
|
package/dist/mappers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EACX,WAAW,EACX,eAAe,EAClB,MAAM,wEAAwE,CAAC;AAChF,OAAO,KAAK,EACR,mBAAmB,EACnB,eAAe,EACf,eAAe,EAClB,MAAM,iBAAiB,CAAC;AAMzB,iBAAS,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAEhD;AAED,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,eAAe,GACtB,mBAAmB,CAErB;AAED,wBAAgB,wBAAwB,CACpC,IAAI,EAAE,mBAAmB,GAC1B,eAAe,CAEjB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CAQxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe,EAClB,MAAM,wEAAwE,CAAC;AAChF,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,eAAe,EAClB,MAAM,iBAAiB,CAAC;AAMzB,iBAAS,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAEhD;AAED,wBAAgB,sBAAsB,CAClC,IAAI,EAAE,eAAe,GACtB,mBAAmB,CAErB;AAED,wBAAgB,wBAAwB,CACpC,IAAI,EAAE,mBAAmB,GAC1B,eAAe,CAEjB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,eAAe,CAQxE;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,eAAe,CAE5E;AAED,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,eAAe,GAC7B,WAAW,CAEb;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAiBvE;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/dist/mappers.js
CHANGED
|
@@ -19,7 +19,14 @@ export function mapChatMessageView(message) {
|
|
|
19
19
|
timestamp: message.timestamp,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
+
export function mapChannelTypeView(channelType) {
|
|
23
|
+
return Object.keys(channelType)[0];
|
|
24
|
+
}
|
|
25
|
+
export function toChannelTypeVariant(channelType) {
|
|
26
|
+
return { [channelType]: null };
|
|
27
|
+
}
|
|
22
28
|
export function mapAgentConfigView(config) {
|
|
29
|
+
const channelType = fromOpt(config.channelType);
|
|
23
30
|
return {
|
|
24
31
|
id: config.id,
|
|
25
32
|
name: config.name,
|
|
@@ -27,6 +34,9 @@ export function mapAgentConfigView(config) {
|
|
|
27
34
|
disclosesAsAi: config.disclosesAsAi,
|
|
28
35
|
tools: config.tools,
|
|
29
36
|
customConfigJson: fromOpt(config.customConfigJson),
|
|
37
|
+
channelType: channelType !== undefined
|
|
38
|
+
? mapChannelTypeView(channelType)
|
|
39
|
+
: undefined,
|
|
30
40
|
createdAt: config.createdAt,
|
|
31
41
|
updatedAt: config.updatedAt,
|
|
32
42
|
};
|