@jsm-mit/agent-platform-canister-package 0.2.0 → 0.3.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 +21 -1
- package/declarations/agent-platform-canister/agent-platform-canister.did +29 -12
- package/declarations/agent-platform-canister/agent-platform-canister.did.d.ts +29 -12
- package/declarations/agent-platform-canister/agent-platform-canister.did.js +29 -12
- package/dist/actors/admin-actor.d.ts +23 -0
- package/dist/actors/admin-actor.d.ts.map +1 -1
- package/dist/actors/admin-actor.js +38 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces.d.ts +10 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +3 -2
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +9 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -90,6 +90,25 @@ const history = await chatHistoryActor.getConversationHistoryAsyncUnsafe(
|
|
|
90
90
|
);
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
### Config change notifications (0.3.0)
|
|
94
|
+
|
|
95
|
+
The canister can report every real create, change or delete of an agent config
|
|
96
|
+
as one task on a rabbit-motoko channel, so agents-village reloads only that
|
|
97
|
+
agent. `commonId` is the agent id, the payload is
|
|
98
|
+
`{"agentId":"<id>","change":"upserted"|"deleted"}`. Writing identical values
|
|
99
|
+
and refused writes report nothing; a failed report is only logged on the
|
|
100
|
+
canister, the write stands. The agent-platform canister must be allowed to add
|
|
101
|
+
tasks on the channel in rabbit. Admin only.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
await adminActor.setConfigChangeNotificationsAsyncUnsafe({
|
|
105
|
+
rabbitCanisterId: "6aigz-vyaaa-aaaag-ayjqa-cai",
|
|
106
|
+
channel: "agent-config-changes",
|
|
107
|
+
});
|
|
108
|
+
const settings = await adminActor.getConfigChangeNotificationsAsyncUnsafe(); // or null
|
|
109
|
+
await adminActor.setConfigChangeNotificationsAsyncUnsafe(null); // switch off
|
|
110
|
+
```
|
|
111
|
+
|
|
93
112
|
## Error model
|
|
94
113
|
|
|
95
114
|
Every `...AsyncUnsafe` method throws one of exactly three errors — switch on
|
|
@@ -111,7 +130,8 @@ Every `...AsyncUnsafe` method throws one of exactly three errors — switch on
|
|
|
111
130
|
- `AdminActor` — admin allowlist and diagnostics: `registerAsAdminAsyncUnsafe`,
|
|
112
131
|
`addAdminAsyncUnsafe`, `removeAdminAsyncUnsafe`, `getAdminsAsyncUnsafe`,
|
|
113
132
|
`setLoggingEnabledAsyncUnsafe`, `whoAmIAsyncUnsafe`, `getLogsAsyncUnsafe`,
|
|
114
|
-
`clearLogsAsyncUnsafe
|
|
133
|
+
`clearLogsAsyncUnsafe`, `setConfigChangeNotificationsAsyncUnsafe`,
|
|
134
|
+
`getConfigChangeNotificationsAsyncUnsafe` (`ConfigChangeNotificationsSettings | null`).
|
|
115
135
|
- Configs/messages are returned as `AgentConfigView`/`ChatMessageView` (opts
|
|
116
136
|
flattened to optionals, the message role variant as a
|
|
117
137
|
`"user" | "assistant" | "tool"` string union); raw candid types remain
|
|
@@ -13,36 +13,44 @@ type ToolBinding =
|
|
|
13
13
|
paramsJson: text;
|
|
14
14
|
tool: text;
|
|
15
15
|
};
|
|
16
|
+
type SetConfigChangeNotificationsArgs = record {
|
|
17
|
+
settings:
|
|
18
|
+
opt ConfigChangeNotifications;};
|
|
16
19
|
type SetAgentPersonaArgs =
|
|
17
20
|
record {
|
|
18
21
|
agentId: AgentId;
|
|
19
22
|
persona: text;
|
|
20
23
|
};
|
|
21
|
-
type
|
|
24
|
+
type Result_7 =
|
|
22
25
|
variant {
|
|
23
26
|
err: Error;
|
|
24
27
|
ok;
|
|
25
28
|
};
|
|
26
|
-
type
|
|
29
|
+
type Result_6 =
|
|
27
30
|
variant {
|
|
28
31
|
err: Error;
|
|
29
32
|
ok: vec principal;
|
|
30
33
|
};
|
|
31
|
-
type
|
|
34
|
+
type Result_5 =
|
|
32
35
|
variant {
|
|
33
36
|
err: Error;
|
|
34
37
|
ok: vec ChatMessage;
|
|
35
38
|
};
|
|
36
|
-
type
|
|
39
|
+
type Result_4 =
|
|
37
40
|
variant {
|
|
38
41
|
err: Error;
|
|
39
42
|
ok: vec AgentConfigView;
|
|
40
43
|
};
|
|
41
|
-
type
|
|
44
|
+
type Result_3 =
|
|
42
45
|
variant {
|
|
43
46
|
err: Error;
|
|
44
47
|
ok: principal;
|
|
45
48
|
};
|
|
49
|
+
type Result_2 =
|
|
50
|
+
variant {
|
|
51
|
+
err: Error;
|
|
52
|
+
ok: opt ConfigChangeNotifications;
|
|
53
|
+
};
|
|
46
54
|
type Result_1 =
|
|
47
55
|
variant {
|
|
48
56
|
err: Error;
|
|
@@ -80,6 +88,11 @@ type Error =
|
|
|
80
88
|
logsJson: text;
|
|
81
89
|
};
|
|
82
90
|
type ConversationId = text;
|
|
91
|
+
type ConfigChangeNotifications =
|
|
92
|
+
record {
|
|
93
|
+
channel: text;
|
|
94
|
+
rabbitCanisterId: principal;
|
|
95
|
+
};
|
|
83
96
|
type ChatMessageRole =
|
|
84
97
|
variant {
|
|
85
98
|
assistant;
|
|
@@ -114,22 +127,26 @@ service : {
|
|
|
114
127
|
addAdmin: ("principal": principal) -> (Result_1);
|
|
115
128
|
/// Trusts another app's canister with agents of its own (Sultana's core). Admin only.
|
|
116
129
|
addApp: (args: AppArgs) -> (Result_1);
|
|
117
|
-
appendMessageBatch: (args: AppendMessageBatchArgs) -> (
|
|
130
|
+
appendMessageBatch: (args: AppendMessageBatchArgs) -> (Result_7);
|
|
118
131
|
clearLogs: () -> ();
|
|
119
|
-
deleteAgentConfig: (id: AgentId) -> (
|
|
120
|
-
getAdmins: () -> (
|
|
132
|
+
deleteAgentConfig: (id: AgentId) -> (Result_7);
|
|
133
|
+
getAdmins: () -> (Result_6) query;
|
|
121
134
|
getAgentConfig: (id: AgentId) -> (Result) query;
|
|
122
|
-
getApps: () -> (
|
|
135
|
+
getApps: () -> (Result_6) query;
|
|
136
|
+
getConfigChangeNotifications: () -> (Result_2) query;
|
|
123
137
|
getConversationHistory: (args: GetConversationHistoryArgs) ->
|
|
124
|
-
(
|
|
138
|
+
(Result_5) query;
|
|
125
139
|
getLogs: () -> (text) query;
|
|
126
|
-
listAgentConfigs: (limit: nat) -> (
|
|
127
|
-
registerAsAdmin: () -> (
|
|
140
|
+
listAgentConfigs: (limit: nat) -> (Result_4) query;
|
|
141
|
+
registerAsAdmin: () -> (Result_3);
|
|
128
142
|
removeAdmin: ("principal": principal) -> (Result_1);
|
|
129
143
|
removeApp: (args: AppArgs) -> (Result_1);
|
|
130
144
|
/// The one field an agent's owner may change — the salon owner editing what their
|
|
131
145
|
/// receptionist says. Admins and the creating app may use it too.
|
|
132
146
|
setAgentPersona: (args: SetAgentPersonaArgs) -> (Result);
|
|
147
|
+
/// Where agent configuration changes are reported; null switches the reports off. Admin only.
|
|
148
|
+
setConfigChangeNotifications: (args: SetConfigChangeNotificationsArgs) ->
|
|
149
|
+
(Result_2);
|
|
133
150
|
setLoggingEnabled: (enabled: bool) -> (Result_1);
|
|
134
151
|
upsertAgentConfig: (args: UpsertAgentConfigArgs) -> (Result);
|
|
135
152
|
whoAmI: () -> (principal) query;
|
|
@@ -27,6 +27,10 @@ export interface ChatMessage {
|
|
|
27
27
|
export type ChatMessageRole = { 'tool' : null } |
|
|
28
28
|
{ 'user' : null } |
|
|
29
29
|
{ 'assistant' : null };
|
|
30
|
+
export interface ConfigChangeNotifications {
|
|
31
|
+
'rabbitCanisterId' : Principal,
|
|
32
|
+
'channel' : string,
|
|
33
|
+
}
|
|
30
34
|
export type ConversationId = string;
|
|
31
35
|
export interface Error { 'details' : ErrorDetails, 'logsJson' : string }
|
|
32
36
|
export type ErrorDetails = { 'InterCanisterConnectionError' : null } |
|
|
@@ -49,17 +53,22 @@ export type Result = { 'ok' : AgentConfigView } |
|
|
|
49
53
|
{ 'err' : Error };
|
|
50
54
|
export type Result_1 = { 'ok' : boolean } |
|
|
51
55
|
{ 'err' : Error };
|
|
52
|
-
export type Result_2 = { 'ok' :
|
|
56
|
+
export type Result_2 = { 'ok' : [] | [ConfigChangeNotifications] } |
|
|
57
|
+
{ 'err' : Error };
|
|
58
|
+
export type Result_3 = { 'ok' : Principal } |
|
|
53
59
|
{ 'err' : Error };
|
|
54
|
-
export type
|
|
60
|
+
export type Result_4 = { 'ok' : Array<AgentConfigView> } |
|
|
55
61
|
{ 'err' : Error };
|
|
56
|
-
export type
|
|
62
|
+
export type Result_5 = { 'ok' : Array<ChatMessage> } |
|
|
57
63
|
{ 'err' : Error };
|
|
58
|
-
export type
|
|
64
|
+
export type Result_6 = { 'ok' : Array<Principal> } |
|
|
59
65
|
{ 'err' : Error };
|
|
60
|
-
export type
|
|
66
|
+
export type Result_7 = { 'ok' : null } |
|
|
61
67
|
{ 'err' : Error };
|
|
62
68
|
export interface SetAgentPersonaArgs { 'agentId' : AgentId, 'persona' : string }
|
|
69
|
+
export interface SetConfigChangeNotificationsArgs {
|
|
70
|
+
'settings' : [] | [ConfigChangeNotifications],
|
|
71
|
+
}
|
|
63
72
|
export interface ToolBinding { 'paramsJson' : string, 'tool' : string }
|
|
64
73
|
export interface UpsertAgentConfigArgs {
|
|
65
74
|
'id' : AgentId,
|
|
@@ -76,19 +85,20 @@ export interface _SERVICE {
|
|
|
76
85
|
* / Trusts another app's canister with agents of its own (Sultana's core). Admin only.
|
|
77
86
|
*/
|
|
78
87
|
'addApp' : ActorMethod<[AppArgs], Result_1>,
|
|
79
|
-
'appendMessageBatch' : ActorMethod<[AppendMessageBatchArgs],
|
|
88
|
+
'appendMessageBatch' : ActorMethod<[AppendMessageBatchArgs], Result_7>,
|
|
80
89
|
'clearLogs' : ActorMethod<[], undefined>,
|
|
81
|
-
'deleteAgentConfig' : ActorMethod<[AgentId],
|
|
82
|
-
'getAdmins' : ActorMethod<[],
|
|
90
|
+
'deleteAgentConfig' : ActorMethod<[AgentId], Result_7>,
|
|
91
|
+
'getAdmins' : ActorMethod<[], Result_6>,
|
|
83
92
|
'getAgentConfig' : ActorMethod<[AgentId], Result>,
|
|
84
|
-
'getApps' : ActorMethod<[],
|
|
93
|
+
'getApps' : ActorMethod<[], Result_6>,
|
|
94
|
+
'getConfigChangeNotifications' : ActorMethod<[], Result_2>,
|
|
85
95
|
'getConversationHistory' : ActorMethod<
|
|
86
96
|
[GetConversationHistoryArgs],
|
|
87
|
-
|
|
97
|
+
Result_5
|
|
88
98
|
>,
|
|
89
99
|
'getLogs' : ActorMethod<[], string>,
|
|
90
|
-
'listAgentConfigs' : ActorMethod<[bigint],
|
|
91
|
-
'registerAsAdmin' : ActorMethod<[],
|
|
100
|
+
'listAgentConfigs' : ActorMethod<[bigint], Result_4>,
|
|
101
|
+
'registerAsAdmin' : ActorMethod<[], Result_3>,
|
|
92
102
|
'removeAdmin' : ActorMethod<[Principal], Result_1>,
|
|
93
103
|
'removeApp' : ActorMethod<[AppArgs], Result_1>,
|
|
94
104
|
/**
|
|
@@ -96,6 +106,13 @@ export interface _SERVICE {
|
|
|
96
106
|
* / receptionist says. Admins and the creating app may use it too.
|
|
97
107
|
*/
|
|
98
108
|
'setAgentPersona' : ActorMethod<[SetAgentPersonaArgs], Result>,
|
|
109
|
+
/**
|
|
110
|
+
* / Where agent configuration changes are reported; null switches the reports off. Admin only.
|
|
111
|
+
*/
|
|
112
|
+
'setConfigChangeNotifications' : ActorMethod<
|
|
113
|
+
[SetConfigChangeNotificationsArgs],
|
|
114
|
+
Result_2
|
|
115
|
+
>,
|
|
99
116
|
'setLoggingEnabled' : ActorMethod<[boolean], Result_1>,
|
|
100
117
|
'upsertAgentConfig' : ActorMethod<[UpsertAgentConfigArgs], Result>,
|
|
101
118
|
'whoAmI' : ActorMethod<[], Principal>,
|
|
@@ -33,8 +33,8 @@ export const idlFactory = ({ IDL }) => {
|
|
|
33
33
|
const AppendMessageBatchArgs = IDL.Record({
|
|
34
34
|
'entries' : IDL.Vec(MessageBatchEntry),
|
|
35
35
|
});
|
|
36
|
-
const
|
|
37
|
-
const
|
|
36
|
+
const Result_7 = IDL.Variant({ 'ok' : IDL.Null, 'err' : Error });
|
|
37
|
+
const Result_6 = IDL.Variant({
|
|
38
38
|
'ok' : IDL.Vec(IDL.Principal),
|
|
39
39
|
'err' : Error,
|
|
40
40
|
});
|
|
@@ -55,20 +55,31 @@ export const idlFactory = ({ IDL }) => {
|
|
|
55
55
|
'customConfigJson' : IDL.Opt(IDL.Text),
|
|
56
56
|
});
|
|
57
57
|
const Result = IDL.Variant({ 'ok' : AgentConfigView, 'err' : Error });
|
|
58
|
+
const ConfigChangeNotifications = IDL.Record({
|
|
59
|
+
'rabbitCanisterId' : IDL.Principal,
|
|
60
|
+
'channel' : IDL.Text,
|
|
61
|
+
});
|
|
62
|
+
const Result_2 = IDL.Variant({
|
|
63
|
+
'ok' : IDL.Opt(ConfigChangeNotifications),
|
|
64
|
+
'err' : Error,
|
|
65
|
+
});
|
|
58
66
|
const GetConversationHistoryArgs = IDL.Record({
|
|
59
67
|
'limit' : IDL.Nat,
|
|
60
68
|
'conversationId' : ConversationId,
|
|
61
69
|
});
|
|
62
|
-
const
|
|
63
|
-
const
|
|
70
|
+
const Result_5 = IDL.Variant({ 'ok' : IDL.Vec(ChatMessage), 'err' : Error });
|
|
71
|
+
const Result_4 = IDL.Variant({
|
|
64
72
|
'ok' : IDL.Vec(AgentConfigView),
|
|
65
73
|
'err' : Error,
|
|
66
74
|
});
|
|
67
|
-
const
|
|
75
|
+
const Result_3 = IDL.Variant({ 'ok' : IDL.Principal, 'err' : Error });
|
|
68
76
|
const SetAgentPersonaArgs = IDL.Record({
|
|
69
77
|
'agentId' : AgentId,
|
|
70
78
|
'persona' : IDL.Text,
|
|
71
79
|
});
|
|
80
|
+
const SetConfigChangeNotificationsArgs = IDL.Record({
|
|
81
|
+
'settings' : IDL.Opt(ConfigChangeNotifications),
|
|
82
|
+
});
|
|
72
83
|
const UpsertAgentConfigArgs = IDL.Record({
|
|
73
84
|
'id' : AgentId,
|
|
74
85
|
'tools' : IDL.Vec(ToolBinding),
|
|
@@ -81,23 +92,29 @@ export const idlFactory = ({ IDL }) => {
|
|
|
81
92
|
return IDL.Service({
|
|
82
93
|
'addAdmin' : IDL.Func([IDL.Principal], [Result_1], []),
|
|
83
94
|
'addApp' : IDL.Func([AppArgs], [Result_1], []),
|
|
84
|
-
'appendMessageBatch' : IDL.Func([AppendMessageBatchArgs], [
|
|
95
|
+
'appendMessageBatch' : IDL.Func([AppendMessageBatchArgs], [Result_7], []),
|
|
85
96
|
'clearLogs' : IDL.Func([], [], []),
|
|
86
|
-
'deleteAgentConfig' : IDL.Func([AgentId], [
|
|
87
|
-
'getAdmins' : IDL.Func([], [
|
|
97
|
+
'deleteAgentConfig' : IDL.Func([AgentId], [Result_7], []),
|
|
98
|
+
'getAdmins' : IDL.Func([], [Result_6], ['query']),
|
|
88
99
|
'getAgentConfig' : IDL.Func([AgentId], [Result], ['query']),
|
|
89
|
-
'getApps' : IDL.Func([], [
|
|
100
|
+
'getApps' : IDL.Func([], [Result_6], ['query']),
|
|
101
|
+
'getConfigChangeNotifications' : IDL.Func([], [Result_2], ['query']),
|
|
90
102
|
'getConversationHistory' : IDL.Func(
|
|
91
103
|
[GetConversationHistoryArgs],
|
|
92
|
-
[
|
|
104
|
+
[Result_5],
|
|
93
105
|
['query'],
|
|
94
106
|
),
|
|
95
107
|
'getLogs' : IDL.Func([], [IDL.Text], ['query']),
|
|
96
|
-
'listAgentConfigs' : IDL.Func([IDL.Nat], [
|
|
97
|
-
'registerAsAdmin' : IDL.Func([], [
|
|
108
|
+
'listAgentConfigs' : IDL.Func([IDL.Nat], [Result_4], ['query']),
|
|
109
|
+
'registerAsAdmin' : IDL.Func([], [Result_3], []),
|
|
98
110
|
'removeAdmin' : IDL.Func([IDL.Principal], [Result_1], []),
|
|
99
111
|
'removeApp' : IDL.Func([AppArgs], [Result_1], []),
|
|
100
112
|
'setAgentPersona' : IDL.Func([SetAgentPersonaArgs], [Result], []),
|
|
113
|
+
'setConfigChangeNotifications' : IDL.Func(
|
|
114
|
+
[SetConfigChangeNotificationsArgs],
|
|
115
|
+
[Result_2],
|
|
116
|
+
[],
|
|
117
|
+
),
|
|
101
118
|
'setLoggingEnabled' : IDL.Func([IDL.Bool], [Result_1], []),
|
|
102
119
|
'upsertAgentConfig' : IDL.Func([UpsertAgentConfigArgs], [Result], []),
|
|
103
120
|
'whoAmI' : IDL.Func([], [IDL.Principal], ['query']),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Identity } from "@icp-sdk/core/agent";
|
|
2
2
|
import { ActorBase, type LogEntry } from "../actor-base.js";
|
|
3
|
+
import type { ConfigChangeNotificationsSettings } from "../interfaces.js";
|
|
3
4
|
/** 1:1 wrapper for the canister's AdminController plus the diagnostic endpoints
|
|
4
5
|
* (whoAmI, getLogs, clearLogs). */
|
|
5
6
|
export declare class AdminActor extends ActorBase {
|
|
@@ -96,5 +97,27 @@ export declare class AdminActor extends ActorBase {
|
|
|
96
97
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
97
98
|
*/
|
|
98
99
|
getAppsAsyncUnsafe(): Promise<string[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Points the canister's agent configuration change reports at a rabbit-motoko channel,
|
|
102
|
+
* or switches them off with `null`. Once set, every real create, change or delete of
|
|
103
|
+
* an agent config adds one task there (commonId = the agent id, payload
|
|
104
|
+
* `{"agentId":"<id>","change":"upserted"|"deleted"}`), so agents-village reloads only
|
|
105
|
+
* that agent. The canister must be allowed to add tasks on the channel in rabbit. Admin
|
|
106
|
+
* only.
|
|
107
|
+
* @param settings - The rabbit canister (text form) and channel, or `null` to switch off.
|
|
108
|
+
* @returns The committed settings.
|
|
109
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, errorKey `InvalidData` for an anonymous canister or an empty / longer than 100 chars channel). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
110
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
111
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
112
|
+
*/
|
|
113
|
+
setConfigChangeNotificationsAsyncUnsafe(settings: ConfigChangeNotificationsSettings | null): Promise<ConfigChangeNotificationsSettings | null>;
|
|
114
|
+
/**
|
|
115
|
+
* Where the canister reports agent configuration changes; `null` when the reports are
|
|
116
|
+
* off. Admin only.
|
|
117
|
+
* @throws Error with message `CanisterError` when the caller is not the admin. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
118
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
119
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
120
|
+
*/
|
|
121
|
+
getConfigChangeNotificationsAsyncUnsafe(): Promise<ConfigChangeNotificationsSettings | null>;
|
|
99
122
|
}
|
|
100
123
|
//# sourceMappingURL=admin-actor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-actor.d.ts","sourceRoot":"","sources":["../../src/actors/admin-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"admin-actor.d.ts","sourceRoot":"","sources":["../../src/actors/admin-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAG1E;mCACmC;AACnC,qBAAa,UAAW,SAAQ,SAAS;gBACzB,UAAU,EAAE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Base } from "../actor-base.js";
|
|
5
|
+
import { mapConfigChangeNotificationsSettings } from "../mappers.js";
|
|
5
6
|
/** 1:1 wrapper for the canister's AdminController plus the diagnostic endpoints
|
|
6
7
|
* (whoAmI, getLogs, clearLogs). */
|
|
7
8
|
export class AdminActor extends ActorBase {
|
|
@@ -127,4 +128,41 @@ export class AdminActor extends ActorBase {
|
|
|
127
128
|
const apps = await this.executeFunctionAsyncUnsafe(() => this.actor.getApps());
|
|
128
129
|
return apps.map((principal) => principal.toString());
|
|
129
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Points the canister's agent configuration change reports at a rabbit-motoko channel,
|
|
133
|
+
* or switches them off with `null`. Once set, every real create, change or delete of
|
|
134
|
+
* an agent config adds one task there (commonId = the agent id, payload
|
|
135
|
+
* `{"agentId":"<id>","change":"upserted"|"deleted"}`), so agents-village reloads only
|
|
136
|
+
* that agent. The canister must be allowed to add tasks on the channel in rabbit. Admin
|
|
137
|
+
* only.
|
|
138
|
+
* @param settings - The rabbit canister (text form) and channel, or `null` to switch off.
|
|
139
|
+
* @returns The committed settings.
|
|
140
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, errorKey `InvalidData` for an anonymous canister or an empty / longer than 100 chars channel). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
141
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
142
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
143
|
+
*/
|
|
144
|
+
async setConfigChangeNotificationsAsyncUnsafe(settings) {
|
|
145
|
+
const committed = await this.executeFunctionAsyncUnsafe(() => this.actor.setConfigChangeNotifications({
|
|
146
|
+
settings: settings === null
|
|
147
|
+
? []
|
|
148
|
+
: [
|
|
149
|
+
{
|
|
150
|
+
rabbitCanisterId: Principal.fromText(settings.rabbitCanisterId),
|
|
151
|
+
channel: settings.channel,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
}));
|
|
155
|
+
return mapConfigChangeNotificationsSettings(committed);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Where the canister reports agent configuration changes; `null` when the reports are
|
|
159
|
+
* off. Admin only.
|
|
160
|
+
* @throws Error with message `CanisterError` when the caller is not the admin. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
161
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
162
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
163
|
+
*/
|
|
164
|
+
async getConfigChangeNotificationsAsyncUnsafe() {
|
|
165
|
+
const settings = await this.executeFunctionAsyncUnsafe(() => this.actor.getConfigChangeNotifications());
|
|
166
|
+
return mapConfigChangeNotificationsSettings(settings);
|
|
167
|
+
}
|
|
130
168
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { ActorBase, type LogEntry } from "./actor-base.js";
|
|
|
2
2
|
export { AdminActor } from "./actors/admin-actor.js";
|
|
3
3
|
export { AgentConfigsActor } from "./actors/agent-configs-actor.js";
|
|
4
4
|
export { ChatHistoryActor } from "./actors/chat-history-actor.js";
|
|
5
|
-
export type { ChatMessageRoleView, ChatMessageView, MessageBatchEntryInput, AgentConfigView, UpsertAgentConfigInput, } from "./interfaces.js";
|
|
6
|
-
export { mapChatMessageRoleView, mapChatMessageView, mapAgentConfigView, } from "./mappers.js";
|
|
5
|
+
export type { ChatMessageRoleView, ChatMessageView, MessageBatchEntryInput, AgentConfigView, UpsertAgentConfigInput, ConfigChangeNotificationsSettings, } from "./interfaces.js";
|
|
6
|
+
export { mapChatMessageRoleView, mapChatMessageView, mapAgentConfigView, mapConfigChangeNotificationsSettings, } from "./mappers.js";
|
|
7
7
|
export type { ToolBinding, Error as CanisterErrorShape, ErrorDetails, } from "../declarations/agent-platform-canister/agent-platform-canister.did.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,YAAY,EACR,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,YAAY,EACR,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,iCAAiC,GACpC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,oCAAoC,GACvC,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,WAAW,EACX,KAAK,IAAI,kBAAkB,EAC3B,YAAY,GACf,MAAM,wEAAwE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export { ActorBase } from "./actor-base.js";
|
|
|
2
2
|
export { AdminActor } from "./actors/admin-actor.js";
|
|
3
3
|
export { AgentConfigsActor } from "./actors/agent-configs-actor.js";
|
|
4
4
|
export { ChatHistoryActor } from "./actors/chat-history-actor.js";
|
|
5
|
-
export { mapChatMessageRoleView, mapChatMessageView, mapAgentConfigView, } from "./mappers.js";
|
|
5
|
+
export { mapChatMessageRoleView, mapChatMessageView, mapAgentConfigView, mapConfigChangeNotificationsSettings, } from "./mappers.js";
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -50,6 +50,16 @@ export interface AgentConfigView {
|
|
|
50
50
|
/** Nanoseconds since epoch */
|
|
51
51
|
updatedAt: bigint;
|
|
52
52
|
}
|
|
53
|
+
/** Where the canister reports agent configuration changes: a task on this rabbit-motoko
|
|
54
|
+
* canister's channel for every real create, change or delete of an agent config
|
|
55
|
+
* (commonId = the agent id, payload `{"agentId":"<id>","change":"upserted"|"deleted"}`).
|
|
56
|
+
* Candid `opt ConfigChangeNotifications` with the principal as text; `null` = reports off. */
|
|
57
|
+
export interface ConfigChangeNotificationsSettings {
|
|
58
|
+
/** The rabbit-motoko canister (text form). The agent-platform canister must be allowed
|
|
59
|
+
* to add tasks on the channel there. */
|
|
60
|
+
rabbitCanisterId: string;
|
|
61
|
+
channel: string;
|
|
62
|
+
}
|
|
53
63
|
/** Input for AgentConfigsActor.upsertAgentConfigAsyncUnsafe — customConfigJson as a
|
|
54
64
|
* plain optional (candid `opt` shaping done by the wrapper); tools is optional here
|
|
55
65
|
* even though the canister's own UpsertAgentConfigArgs requires it — the wrapper
|
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;AA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,EAAE,MAAM,CAAC;CACnB;AAED;;;;uCAIuC;AACvC,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,sFAAsF;IACtF,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/mappers.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { AgentConfigView as CandidAgentConfig, ChatMessage, ChatMessageRole } from "../declarations/agent-platform-canister/agent-platform-canister.did.js";
|
|
2
|
-
import type { ChatMessageRoleView, ChatMessageView, AgentConfigView } from "./interfaces.js";
|
|
1
|
+
import type { AgentConfigView as CandidAgentConfig, ChatMessage, ChatMessageRole, ConfigChangeNotifications as CandidConfigChangeNotifications } from "../declarations/agent-platform-canister/agent-platform-canister.did.js";
|
|
2
|
+
import type { ChatMessageRoleView, ChatMessageView, AgentConfigView, ConfigChangeNotificationsSettings } 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
7
|
export declare function mapAgentConfigView(config: CandidAgentConfig): AgentConfigView;
|
|
8
|
+
export declare function mapConfigChangeNotificationsSettings(settings: [] | [CandidConfigChangeNotifications]): ConfigChangeNotificationsSettings | null;
|
|
8
9
|
export { toOpt };
|
|
9
10
|
//# 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,eAAe,IAAI,iBAAiB,EACpC,WAAW,EACX,eAAe,
|
|
1
|
+
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,IAAI,iBAAiB,EACpC,WAAW,EACX,eAAe,EACf,yBAAyB,IAAI,+BAA+B,EAC/D,MAAM,wEAAwE,CAAC;AAChF,OAAO,KAAK,EACR,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iCAAiC,EACpC,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,iBAAiB,GAAG,eAAe,CAa7E;AAED,wBAAgB,oCAAoC,CAChD,QAAQ,EAAE,EAAE,GAAG,CAAC,+BAA+B,CAAC,GACjD,iCAAiC,GAAG,IAAI,CAQ1C;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/dist/mappers.js
CHANGED
|
@@ -33,4 +33,13 @@ export function mapAgentConfigView(config) {
|
|
|
33
33
|
updatedAt: config.updatedAt,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
export function mapConfigChangeNotificationsSettings(settings) {
|
|
37
|
+
const value = fromOpt(settings);
|
|
38
|
+
if (value === undefined)
|
|
39
|
+
return null;
|
|
40
|
+
return {
|
|
41
|
+
rabbitCanisterId: value.rabbitCanisterId.toText(),
|
|
42
|
+
channel: value.channel,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
36
45
|
export { toOpt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/agent-platform-canister-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Wrapper TypeScript package for the agent-platform-canister canister.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit -p tsconfig.tests.json",
|
|
27
27
|
"sync-declarations": "bash scripts/sync-declarations.sh",
|
|
28
28
|
"test-suite": "bash scripts/run-tests.sh tests/test-suite.ts",
|
|
29
|
+
"redeploy": "bash scripts/redeploy.sh",
|
|
29
30
|
"sandbox": "npx tsx sandbox/main.ts",
|
|
30
31
|
"format": "prettier --write .",
|
|
31
32
|
"format:check": "prettier --check .",
|
|
@@ -49,6 +50,6 @@
|
|
|
49
50
|
"agentPlatformCanister": {
|
|
50
51
|
"repo": "agent-platform-canister",
|
|
51
52
|
"repoUrl": "https://github.com/JSM-Agent-Platform/agent-platform-canister",
|
|
52
|
-
"commit": "
|
|
53
|
+
"commit": "ef1892ea4ce350afd6dc13e1452167aa7e9b4970"
|
|
53
54
|
}
|
|
54
55
|
}
|