@jsm-mit/agent-platform-canister-package 0.1.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 +46 -13
- package/declarations/agent-platform-canister/agent-platform-canister.did.d.ts +104 -69
- package/declarations/agent-platform-canister/agent-platform-canister.did.js +121 -91
- package/dist/actors/admin-actor.d.ts +48 -0
- package/dist/actors/admin-actor.d.ts.map +1 -1
- package/dist/actors/admin-actor.js +70 -0
- package/dist/actors/agent-configs-actor.d.ts +12 -1
- package/dist/actors/agent-configs-actor.d.ts.map +1 -1
- package/dist/actors/agent-configs-actor.js +17 -1
- 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 +18 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/mappers.d.ts +4 -3
- package/dist/mappers.d.ts.map +1 -1
- package/dist/mappers.js +11 -0
- package/package.json +11 -6
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
|
|
@@ -4,6 +4,7 @@ type UpsertAgentConfigArgs =
|
|
|
4
4
|
disclosesAsAi: bool;
|
|
5
5
|
id: AgentId;
|
|
6
6
|
name: text;
|
|
7
|
+
owner: opt principal;
|
|
7
8
|
persona: text;
|
|
8
9
|
tools: vec ToolBinding;
|
|
9
10
|
};
|
|
@@ -12,30 +13,43 @@ type ToolBinding =
|
|
|
12
13
|
paramsJson: text;
|
|
13
14
|
tool: text;
|
|
14
15
|
};
|
|
15
|
-
type
|
|
16
|
+
type SetConfigChangeNotificationsArgs = record {
|
|
17
|
+
settings:
|
|
18
|
+
opt ConfigChangeNotifications;};
|
|
19
|
+
type SetAgentPersonaArgs =
|
|
20
|
+
record {
|
|
21
|
+
agentId: AgentId;
|
|
22
|
+
persona: text;
|
|
23
|
+
};
|
|
24
|
+
type Result_7 =
|
|
16
25
|
variant {
|
|
17
26
|
err: Error;
|
|
18
27
|
ok;
|
|
19
28
|
};
|
|
20
|
-
type
|
|
29
|
+
type Result_6 =
|
|
21
30
|
variant {
|
|
22
31
|
err: Error;
|
|
23
32
|
ok: vec principal;
|
|
24
33
|
};
|
|
25
|
-
type
|
|
34
|
+
type Result_5 =
|
|
26
35
|
variant {
|
|
27
36
|
err: Error;
|
|
28
37
|
ok: vec ChatMessage;
|
|
29
38
|
};
|
|
39
|
+
type Result_4 =
|
|
40
|
+
variant {
|
|
41
|
+
err: Error;
|
|
42
|
+
ok: vec AgentConfigView;
|
|
43
|
+
};
|
|
30
44
|
type Result_3 =
|
|
31
45
|
variant {
|
|
32
46
|
err: Error;
|
|
33
|
-
ok:
|
|
47
|
+
ok: principal;
|
|
34
48
|
};
|
|
35
49
|
type Result_2 =
|
|
36
50
|
variant {
|
|
37
51
|
err: Error;
|
|
38
|
-
ok:
|
|
52
|
+
ok: opt ConfigChangeNotifications;
|
|
39
53
|
};
|
|
40
54
|
type Result_1 =
|
|
41
55
|
variant {
|
|
@@ -45,7 +59,7 @@ type Result_1 =
|
|
|
45
59
|
type Result =
|
|
46
60
|
variant {
|
|
47
61
|
err: Error;
|
|
48
|
-
ok:
|
|
62
|
+
ok: AgentConfigView;
|
|
49
63
|
};
|
|
50
64
|
type MessageBatchEntry =
|
|
51
65
|
record {
|
|
@@ -74,6 +88,11 @@ type Error =
|
|
|
74
88
|
logsJson: text;
|
|
75
89
|
};
|
|
76
90
|
type ConversationId = text;
|
|
91
|
+
type ConfigChangeNotifications =
|
|
92
|
+
record {
|
|
93
|
+
channel: text;
|
|
94
|
+
rabbitCanisterId: principal;
|
|
95
|
+
};
|
|
77
96
|
type ChatMessageRole =
|
|
78
97
|
variant {
|
|
79
98
|
assistant;
|
|
@@ -89,31 +108,45 @@ type ChatMessage =
|
|
|
89
108
|
toolName: opt text;
|
|
90
109
|
};
|
|
91
110
|
type AppendMessageBatchArgs = record {entries: vec MessageBatchEntry;};
|
|
111
|
+
type AppArgs = record {"principal": principal;};
|
|
92
112
|
type AgentId = text;
|
|
93
|
-
type
|
|
113
|
+
type AgentConfigView =
|
|
94
114
|
record {
|
|
95
115
|
createdAt: int;
|
|
116
|
+
createdBy: opt principal;
|
|
96
117
|
customConfigJson: opt text;
|
|
97
118
|
disclosesAsAi: bool;
|
|
98
119
|
id: AgentId;
|
|
99
120
|
name: text;
|
|
121
|
+
owner: opt principal;
|
|
100
122
|
persona: text;
|
|
101
123
|
tools: vec ToolBinding;
|
|
102
124
|
updatedAt: int;
|
|
103
125
|
};
|
|
104
126
|
service : {
|
|
105
127
|
addAdmin: ("principal": principal) -> (Result_1);
|
|
106
|
-
|
|
128
|
+
/// Trusts another app's canister with agents of its own (Sultana's core). Admin only.
|
|
129
|
+
addApp: (args: AppArgs) -> (Result_1);
|
|
130
|
+
appendMessageBatch: (args: AppendMessageBatchArgs) -> (Result_7);
|
|
107
131
|
clearLogs: () -> ();
|
|
108
|
-
deleteAgentConfig: (id: AgentId) -> (
|
|
109
|
-
getAdmins: () -> (
|
|
132
|
+
deleteAgentConfig: (id: AgentId) -> (Result_7);
|
|
133
|
+
getAdmins: () -> (Result_6) query;
|
|
110
134
|
getAgentConfig: (id: AgentId) -> (Result) query;
|
|
135
|
+
getApps: () -> (Result_6) query;
|
|
136
|
+
getConfigChangeNotifications: () -> (Result_2) query;
|
|
111
137
|
getConversationHistory: (args: GetConversationHistoryArgs) ->
|
|
112
|
-
(
|
|
138
|
+
(Result_5) query;
|
|
113
139
|
getLogs: () -> (text) query;
|
|
114
|
-
listAgentConfigs: (limit: nat) -> (
|
|
115
|
-
registerAsAdmin: () -> (
|
|
140
|
+
listAgentConfigs: (limit: nat) -> (Result_4) query;
|
|
141
|
+
registerAsAdmin: () -> (Result_3);
|
|
116
142
|
removeAdmin: ("principal": principal) -> (Result_1);
|
|
143
|
+
removeApp: (args: AppArgs) -> (Result_1);
|
|
144
|
+
/// The one field an agent's owner may change — the salon owner editing what their
|
|
145
|
+
/// receptionist says. Admins and the creating app may use it too.
|
|
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);
|
|
117
150
|
setLoggingEnabled: (enabled: bool) -> (Result_1);
|
|
118
151
|
upsertAgentConfig: (args: UpsertAgentConfigArgs) -> (Result);
|
|
119
152
|
whoAmI: () -> (principal) query;
|
|
@@ -1,86 +1,121 @@
|
|
|
1
|
-
import type { Principal } from
|
|
2
|
-
import type { ActorMethod } from
|
|
3
|
-
import type { IDL } from
|
|
1
|
+
import type { Principal } from '@icp-sdk/core/principal';
|
|
2
|
+
import type { ActorMethod } from '@icp-sdk/core/agent';
|
|
3
|
+
import type { IDL } from '@icp-sdk/core/candid';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
export interface AgentConfigView {
|
|
6
|
+
'id' : AgentId,
|
|
7
|
+
'tools' : Array<ToolBinding>,
|
|
8
|
+
'owner' : [] | [Principal],
|
|
9
|
+
'name' : string,
|
|
10
|
+
'createdAt' : bigint,
|
|
11
|
+
'createdBy' : [] | [Principal],
|
|
12
|
+
'updatedAt' : bigint,
|
|
13
|
+
'persona' : string,
|
|
14
|
+
'disclosesAsAi' : boolean,
|
|
15
|
+
'customConfigJson' : [] | [string],
|
|
14
16
|
}
|
|
15
17
|
export type AgentId = string;
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
}
|
|
18
|
+
export interface AppArgs { 'principal' : Principal }
|
|
19
|
+
export interface AppendMessageBatchArgs { 'entries' : Array<MessageBatchEntry> }
|
|
19
20
|
export interface ChatMessage {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
'content' : string,
|
|
22
|
+
'role' : ChatMessageRole,
|
|
23
|
+
'timestamp' : bigint,
|
|
24
|
+
'toolName' : [] | [string],
|
|
25
|
+
'toolCallId' : [] | [string],
|
|
25
26
|
}
|
|
26
|
-
export type ChatMessageRole =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export interface
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
export type ChatMessageRole = { 'tool' : null } |
|
|
28
|
+
{ 'user' : null } |
|
|
29
|
+
{ 'assistant' : null };
|
|
30
|
+
export interface ConfigChangeNotifications {
|
|
31
|
+
'rabbitCanisterId' : Principal,
|
|
32
|
+
'channel' : string,
|
|
32
33
|
}
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
export type ConversationId = string;
|
|
35
|
+
export interface Error { 'details' : ErrorDetails, 'logsJson' : string }
|
|
36
|
+
export type ErrorDetails = { 'InterCanisterConnectionError' : null } |
|
|
37
|
+
{ 'RemoteCanisterError' : string } |
|
|
38
|
+
{ 'NotFound' : null } |
|
|
39
|
+
{ 'NotAuthorized' : string } |
|
|
40
|
+
{ 'InvalidData' : string } |
|
|
41
|
+
{ 'AlreadyExists' : null } |
|
|
42
|
+
{ 'ReturnsNull' : null };
|
|
41
43
|
export interface GetConversationHistoryArgs {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
'limit' : bigint,
|
|
45
|
+
'conversationId' : ConversationId,
|
|
44
46
|
}
|
|
45
47
|
export interface MessageBatchEntry {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
'agentId' : AgentId,
|
|
49
|
+
'conversationId' : ConversationId,
|
|
50
|
+
'message' : ChatMessage,
|
|
49
51
|
}
|
|
50
|
-
export type Result = { ok:
|
|
51
|
-
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
export type
|
|
55
|
-
|
|
56
|
-
export type
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
export type Result = { 'ok' : AgentConfigView } |
|
|
53
|
+
{ 'err' : Error };
|
|
54
|
+
export type Result_1 = { 'ok' : boolean } |
|
|
55
|
+
{ 'err' : Error };
|
|
56
|
+
export type Result_2 = { 'ok' : [] | [ConfigChangeNotifications] } |
|
|
57
|
+
{ 'err' : Error };
|
|
58
|
+
export type Result_3 = { 'ok' : Principal } |
|
|
59
|
+
{ 'err' : Error };
|
|
60
|
+
export type Result_4 = { 'ok' : Array<AgentConfigView> } |
|
|
61
|
+
{ 'err' : Error };
|
|
62
|
+
export type Result_5 = { 'ok' : Array<ChatMessage> } |
|
|
63
|
+
{ 'err' : Error };
|
|
64
|
+
export type Result_6 = { 'ok' : Array<Principal> } |
|
|
65
|
+
{ 'err' : Error };
|
|
66
|
+
export type Result_7 = { 'ok' : null } |
|
|
67
|
+
{ 'err' : Error };
|
|
68
|
+
export interface SetAgentPersonaArgs { 'agentId' : AgentId, 'persona' : string }
|
|
69
|
+
export interface SetConfigChangeNotificationsArgs {
|
|
70
|
+
'settings' : [] | [ConfigChangeNotifications],
|
|
60
71
|
}
|
|
72
|
+
export interface ToolBinding { 'paramsJson' : string, 'tool' : string }
|
|
61
73
|
export interface UpsertAgentConfigArgs {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
'id' : AgentId,
|
|
75
|
+
'tools' : Array<ToolBinding>,
|
|
76
|
+
'owner' : [] | [Principal],
|
|
77
|
+
'name' : string,
|
|
78
|
+
'persona' : string,
|
|
79
|
+
'disclosesAsAi' : boolean,
|
|
80
|
+
'customConfigJson' : [] | [string],
|
|
68
81
|
}
|
|
69
82
|
export interface _SERVICE {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
'addAdmin' : ActorMethod<[Principal], Result_1>,
|
|
84
|
+
/**
|
|
85
|
+
* / Trusts another app's canister with agents of its own (Sultana's core). Admin only.
|
|
86
|
+
*/
|
|
87
|
+
'addApp' : ActorMethod<[AppArgs], Result_1>,
|
|
88
|
+
'appendMessageBatch' : ActorMethod<[AppendMessageBatchArgs], Result_7>,
|
|
89
|
+
'clearLogs' : ActorMethod<[], undefined>,
|
|
90
|
+
'deleteAgentConfig' : ActorMethod<[AgentId], Result_7>,
|
|
91
|
+
'getAdmins' : ActorMethod<[], Result_6>,
|
|
92
|
+
'getAgentConfig' : ActorMethod<[AgentId], Result>,
|
|
93
|
+
'getApps' : ActorMethod<[], Result_6>,
|
|
94
|
+
'getConfigChangeNotifications' : ActorMethod<[], Result_2>,
|
|
95
|
+
'getConversationHistory' : ActorMethod<
|
|
96
|
+
[GetConversationHistoryArgs],
|
|
97
|
+
Result_5
|
|
98
|
+
>,
|
|
99
|
+
'getLogs' : ActorMethod<[], string>,
|
|
100
|
+
'listAgentConfigs' : ActorMethod<[bigint], Result_4>,
|
|
101
|
+
'registerAsAdmin' : ActorMethod<[], Result_3>,
|
|
102
|
+
'removeAdmin' : ActorMethod<[Principal], Result_1>,
|
|
103
|
+
'removeApp' : ActorMethod<[AppArgs], Result_1>,
|
|
104
|
+
/**
|
|
105
|
+
* / The one field an agent's owner may change — the salon owner editing what their
|
|
106
|
+
* / receptionist says. Admins and the creating app may use it too.
|
|
107
|
+
*/
|
|
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
|
+
>,
|
|
116
|
+
'setLoggingEnabled' : ActorMethod<[boolean], Result_1>,
|
|
117
|
+
'upsertAgentConfig' : ActorMethod<[UpsertAgentConfigArgs], Result>,
|
|
118
|
+
'whoAmI' : ActorMethod<[], Principal>,
|
|
84
119
|
}
|
|
85
120
|
export declare const idlFactory: IDL.InterfaceFactory;
|
|
86
121
|
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
@@ -1,93 +1,123 @@
|
|
|
1
1
|
export const idlFactory = ({ IDL }) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
2
|
+
const ErrorDetails = IDL.Variant({
|
|
3
|
+
'InterCanisterConnectionError' : IDL.Null,
|
|
4
|
+
'RemoteCanisterError' : IDL.Text,
|
|
5
|
+
'NotFound' : IDL.Null,
|
|
6
|
+
'NotAuthorized' : IDL.Text,
|
|
7
|
+
'InvalidData' : IDL.Text,
|
|
8
|
+
'AlreadyExists' : IDL.Null,
|
|
9
|
+
'ReturnsNull' : IDL.Null,
|
|
10
|
+
});
|
|
11
|
+
const Error = IDL.Record({ 'details' : ErrorDetails, 'logsJson' : IDL.Text });
|
|
12
|
+
const Result_1 = IDL.Variant({ 'ok' : IDL.Bool, 'err' : Error });
|
|
13
|
+
const AppArgs = IDL.Record({ 'principal' : IDL.Principal });
|
|
14
|
+
const AgentId = IDL.Text;
|
|
15
|
+
const ConversationId = IDL.Text;
|
|
16
|
+
const ChatMessageRole = IDL.Variant({
|
|
17
|
+
'tool' : IDL.Null,
|
|
18
|
+
'user' : IDL.Null,
|
|
19
|
+
'assistant' : IDL.Null,
|
|
20
|
+
});
|
|
21
|
+
const ChatMessage = IDL.Record({
|
|
22
|
+
'content' : IDL.Text,
|
|
23
|
+
'role' : ChatMessageRole,
|
|
24
|
+
'timestamp' : IDL.Int,
|
|
25
|
+
'toolName' : IDL.Opt(IDL.Text),
|
|
26
|
+
'toolCallId' : IDL.Opt(IDL.Text),
|
|
27
|
+
});
|
|
28
|
+
const MessageBatchEntry = IDL.Record({
|
|
29
|
+
'agentId' : AgentId,
|
|
30
|
+
'conversationId' : ConversationId,
|
|
31
|
+
'message' : ChatMessage,
|
|
32
|
+
});
|
|
33
|
+
const AppendMessageBatchArgs = IDL.Record({
|
|
34
|
+
'entries' : IDL.Vec(MessageBatchEntry),
|
|
35
|
+
});
|
|
36
|
+
const Result_7 = IDL.Variant({ 'ok' : IDL.Null, 'err' : Error });
|
|
37
|
+
const Result_6 = IDL.Variant({
|
|
38
|
+
'ok' : IDL.Vec(IDL.Principal),
|
|
39
|
+
'err' : Error,
|
|
40
|
+
});
|
|
41
|
+
const ToolBinding = IDL.Record({
|
|
42
|
+
'paramsJson' : IDL.Text,
|
|
43
|
+
'tool' : IDL.Text,
|
|
44
|
+
});
|
|
45
|
+
const AgentConfigView = IDL.Record({
|
|
46
|
+
'id' : AgentId,
|
|
47
|
+
'tools' : IDL.Vec(ToolBinding),
|
|
48
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
49
|
+
'name' : IDL.Text,
|
|
50
|
+
'createdAt' : IDL.Int,
|
|
51
|
+
'createdBy' : IDL.Opt(IDL.Principal),
|
|
52
|
+
'updatedAt' : IDL.Int,
|
|
53
|
+
'persona' : IDL.Text,
|
|
54
|
+
'disclosesAsAi' : IDL.Bool,
|
|
55
|
+
'customConfigJson' : IDL.Opt(IDL.Text),
|
|
56
|
+
});
|
|
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
|
+
});
|
|
66
|
+
const GetConversationHistoryArgs = IDL.Record({
|
|
67
|
+
'limit' : IDL.Nat,
|
|
68
|
+
'conversationId' : ConversationId,
|
|
69
|
+
});
|
|
70
|
+
const Result_5 = IDL.Variant({ 'ok' : IDL.Vec(ChatMessage), 'err' : Error });
|
|
71
|
+
const Result_4 = IDL.Variant({
|
|
72
|
+
'ok' : IDL.Vec(AgentConfigView),
|
|
73
|
+
'err' : Error,
|
|
74
|
+
});
|
|
75
|
+
const Result_3 = IDL.Variant({ 'ok' : IDL.Principal, 'err' : Error });
|
|
76
|
+
const SetAgentPersonaArgs = IDL.Record({
|
|
77
|
+
'agentId' : AgentId,
|
|
78
|
+
'persona' : IDL.Text,
|
|
79
|
+
});
|
|
80
|
+
const SetConfigChangeNotificationsArgs = IDL.Record({
|
|
81
|
+
'settings' : IDL.Opt(ConfigChangeNotifications),
|
|
82
|
+
});
|
|
83
|
+
const UpsertAgentConfigArgs = IDL.Record({
|
|
84
|
+
'id' : AgentId,
|
|
85
|
+
'tools' : IDL.Vec(ToolBinding),
|
|
86
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
87
|
+
'name' : IDL.Text,
|
|
88
|
+
'persona' : IDL.Text,
|
|
89
|
+
'disclosesAsAi' : IDL.Bool,
|
|
90
|
+
'customConfigJson' : IDL.Opt(IDL.Text),
|
|
91
|
+
});
|
|
92
|
+
return IDL.Service({
|
|
93
|
+
'addAdmin' : IDL.Func([IDL.Principal], [Result_1], []),
|
|
94
|
+
'addApp' : IDL.Func([AppArgs], [Result_1], []),
|
|
95
|
+
'appendMessageBatch' : IDL.Func([AppendMessageBatchArgs], [Result_7], []),
|
|
96
|
+
'clearLogs' : IDL.Func([], [], []),
|
|
97
|
+
'deleteAgentConfig' : IDL.Func([AgentId], [Result_7], []),
|
|
98
|
+
'getAdmins' : IDL.Func([], [Result_6], ['query']),
|
|
99
|
+
'getAgentConfig' : IDL.Func([AgentId], [Result], ['query']),
|
|
100
|
+
'getApps' : IDL.Func([], [Result_6], ['query']),
|
|
101
|
+
'getConfigChangeNotifications' : IDL.Func([], [Result_2], ['query']),
|
|
102
|
+
'getConversationHistory' : IDL.Func(
|
|
103
|
+
[GetConversationHistoryArgs],
|
|
104
|
+
[Result_5],
|
|
105
|
+
['query'],
|
|
106
|
+
),
|
|
107
|
+
'getLogs' : IDL.Func([], [IDL.Text], ['query']),
|
|
108
|
+
'listAgentConfigs' : IDL.Func([IDL.Nat], [Result_4], ['query']),
|
|
109
|
+
'registerAsAdmin' : IDL.Func([], [Result_3], []),
|
|
110
|
+
'removeAdmin' : IDL.Func([IDL.Principal], [Result_1], []),
|
|
111
|
+
'removeApp' : IDL.Func([AppArgs], [Result_1], []),
|
|
112
|
+
'setAgentPersona' : IDL.Func([SetAgentPersonaArgs], [Result], []),
|
|
113
|
+
'setConfigChangeNotifications' : IDL.Func(
|
|
114
|
+
[SetConfigChangeNotificationsArgs],
|
|
115
|
+
[Result_2],
|
|
116
|
+
[],
|
|
117
|
+
),
|
|
118
|
+
'setLoggingEnabled' : IDL.Func([IDL.Bool], [Result_1], []),
|
|
119
|
+
'upsertAgentConfig' : IDL.Func([UpsertAgentConfigArgs], [Result], []),
|
|
120
|
+
'whoAmI' : IDL.Func([], [IDL.Principal], ['query']),
|
|
121
|
+
});
|
|
93
122
|
};
|
|
123
|
+
export const init = ({ IDL }) => { return []; };
|
|
@@ -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 {
|
|
@@ -71,5 +72,52 @@ export declare class AdminActor extends ActorBase {
|
|
|
71
72
|
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
72
73
|
*/
|
|
73
74
|
setLoggingEnabledAsyncUnsafe(enabled: boolean): Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Trusts another app's canister with agents of its own (Sultana's core creating an
|
|
77
|
+
* agent per salon). An app is NOT an admin: it may create agents and afterwards
|
|
78
|
+
* change only what it created, which is what keeps one app out of another's agents.
|
|
79
|
+
* Admin only; adding a principal twice is a no-op.
|
|
80
|
+
* @throws Error with message `CanisterError` when the caller is not the admin, the principal is anonymous, or the allowlist is full. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
81
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
82
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
83
|
+
*/
|
|
84
|
+
addAppAsyncUnsafe(principalText: string): Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Takes that right away. Agents the app already created keep working; from then on
|
|
87
|
+
* only a canister admin can change them. Admin only.
|
|
88
|
+
* @throws Error with message `CanisterError` when the caller is not the admin. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
89
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
90
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
91
|
+
*/
|
|
92
|
+
removeAppAsyncUnsafe(principalText: string): Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* The apps trusted with agents of their own. Admin only.
|
|
95
|
+
* @throws Error with message `CanisterError` when the caller is not the admin. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
96
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
97
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
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>;
|
|
74
122
|
}
|
|
75
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,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAInD;;;;;;OAMG;IACU,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAOjD;;;;;;;OAOG;IACU,kBAAkB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOtD;;;;OAIG;IACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlD;;;;;;OAMG;IACU,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMzE;;;;;;;OAOG;IACU,sBAAsB,CAC/B,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,OAAO,CAAC;IAMnB;;;;;;OAMG;IACU,oBAAoB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAOtD;;;;;;;;OAQG;IACU,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC;IAO1D;;;;;;;OAOG;IACU,4BAA4B,CACrC,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,OAAO,CAAC;IAMnB;;;;;;;;OAQG;IACU,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvE;;;;;;OAMG;IACU,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM1E;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKpD;;;;;;;;;;;;OAYG;IACU,uCAAuC,CAChD,QAAQ,EAAE,iCAAiC,GAAG,IAAI,GACnD,OAAO,CAAC,iCAAiC,GAAG,IAAI,CAAC;IAmBpD;;;;;;OAMG;IACU,uCAAuC,IAAI,OAAO,CAAC,iCAAiC,GAAG,IAAI,CAAC;CAM5G"}
|
|
@@ -2,6 +2,7 @@ import {} from "@icp-sdk/core/agent";
|
|
|
2
2
|
import { Principal } from "@icp-sdk/core/principal";
|
|
3
3
|
import { BetterJSON } from "@jsm-mit/utils-package";
|
|
4
4
|
import { ActorBase } 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 {
|
|
@@ -95,4 +96,73 @@ export class AdminActor extends ActorBase {
|
|
|
95
96
|
async setLoggingEnabledAsyncUnsafe(enabled) {
|
|
96
97
|
return this.executeFunctionAsyncUnsafe(() => this.actor.setLoggingEnabled(enabled));
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Trusts another app's canister with agents of its own (Sultana's core creating an
|
|
101
|
+
* agent per salon). An app is NOT an admin: it may create agents and afterwards
|
|
102
|
+
* change only what it created, which is what keeps one app out of another's agents.
|
|
103
|
+
* Admin only; adding a principal twice is a no-op.
|
|
104
|
+
* @throws Error with message `CanisterError` when the caller is not the admin, the principal is anonymous, or the allowlist is full. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
105
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
106
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
107
|
+
*/
|
|
108
|
+
async addAppAsyncUnsafe(principalText) {
|
|
109
|
+
return this.executeFunctionAsyncUnsafe(() => this.actor.addApp({ principal: Principal.fromText(principalText) }));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Takes that right away. Agents the app already created keep working; from then on
|
|
113
|
+
* only a canister admin can change them. Admin only.
|
|
114
|
+
* @throws Error with message `CanisterError` when the caller is not the admin. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
115
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
116
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
117
|
+
*/
|
|
118
|
+
async removeAppAsyncUnsafe(principalText) {
|
|
119
|
+
return this.executeFunctionAsyncUnsafe(() => this.actor.removeApp({ principal: Principal.fromText(principalText) }));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The apps trusted with agents of their own. Admin only.
|
|
123
|
+
* @throws Error with message `CanisterError` when the caller is not the admin. Examine "cause" for {errorKey, errorMessage, logs}.
|
|
124
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
125
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
126
|
+
*/
|
|
127
|
+
async getAppsAsyncUnsafe() {
|
|
128
|
+
const apps = await this.executeFunctionAsyncUnsafe(() => this.actor.getApps());
|
|
129
|
+
return apps.map((principal) => principal.toString());
|
|
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
|
+
}
|
|
98
168
|
}
|
|
@@ -16,7 +16,18 @@ export declare class AgentConfigsActor extends ActorBase {
|
|
|
16
16
|
*/
|
|
17
17
|
upsertAgentConfigAsyncUnsafe(input: UpsertAgentConfigInput): Promise<AgentConfigView>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Changes what the agent says it is — the one field its owner may touch. A full
|
|
20
|
+
* upsert belongs to the app that created the agent, because it would also re-point
|
|
21
|
+
* the agent's channel.
|
|
22
|
+
*
|
|
23
|
+
* Allowed for the agent's owner, the app that created it and canister admins.
|
|
24
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` for anybody else, `NotFound`, `InvalidData` for an empty or oversized persona). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
25
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
26
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
27
|
+
*/
|
|
28
|
+
setAgentPersonaAsyncUnsafe(agentId: string, persona: string): Promise<AgentConfigView>;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches one agent's config. Its owner, the app that created it, and canister admins.
|
|
20
31
|
* @param id - The agent id.
|
|
21
32
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, errorKey `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
22
33
|
* @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;
|
|
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;AAE7C,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;;;;;;;;;OASG;IACU,4BAA4B,CACrC,KAAK,EAAE,sBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC;IAe3B;;;;;;;;;OASG;IACU,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAOnG;;;;;;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,5 +1,6 @@
|
|
|
1
1
|
import {} from "@icp-sdk/core/agent";
|
|
2
2
|
import { ActorBase } from "../actor-base.js";
|
|
3
|
+
import { Principal } from "@icp-sdk/core/principal";
|
|
3
4
|
import { mapAgentConfigView, toOpt } from "../mappers.js";
|
|
4
5
|
/** 1:1 wrapper for the canister's AgentConfigsController. */
|
|
5
6
|
export class AgentConfigsActor extends ActorBase {
|
|
@@ -24,11 +25,26 @@ export class AgentConfigsActor extends ActorBase {
|
|
|
24
25
|
disclosesAsAi: input.disclosesAsAi,
|
|
25
26
|
tools: input.tools ?? [],
|
|
26
27
|
customConfigJson: toOpt(input.customConfigJson),
|
|
28
|
+
owner: toOpt(input.owner ? Principal.fromText(input.owner) : undefined),
|
|
27
29
|
}));
|
|
28
30
|
return mapAgentConfigView(config);
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
33
|
+
* Changes what the agent says it is — the one field its owner may touch. A full
|
|
34
|
+
* upsert belongs to the app that created the agent, because it would also re-point
|
|
35
|
+
* the agent's channel.
|
|
36
|
+
*
|
|
37
|
+
* Allowed for the agent's owner, the app that created it and canister admins.
|
|
38
|
+
* @throws Error with message `CanisterError` when the canister returns a business error (`NotAuthorized` for anybody else, `NotFound`, `InvalidData` for an empty or oversized persona). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
39
|
+
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
|
40
|
+
* @throws Error with message `CallRefusedAtInspectionStage` when the canister's `inspect` rejects the call before execution.
|
|
41
|
+
*/
|
|
42
|
+
async setAgentPersonaAsyncUnsafe(agentId, persona) {
|
|
43
|
+
const config = await this.executeFunctionAsyncUnsafe(() => this.actor.setAgentPersona({ agentId, persona }));
|
|
44
|
+
return mapAgentConfigView(config);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetches one agent's config. Its owner, the app that created it, and canister admins.
|
|
32
48
|
* @param id - The agent id.
|
|
33
49
|
* @throws Error with message `CanisterError` when the canister returns a business error (not authorized, errorKey `NotFound`). Examine "cause" for {errorKey, errorMessage, logs}.
|
|
34
50
|
* @throws Error with message `CriticalCanisterError` when there is no communication with the canister or the canister code traps during execution.
|
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
|
@@ -39,11 +39,27 @@ export interface AgentConfigView {
|
|
|
39
39
|
* {"type":"whatsapp","number":...,"peers":[...]}) — this package stays agnostic
|
|
40
40
|
* to its shape; agents-village is the one that parses it. */
|
|
41
41
|
customConfigJson?: string;
|
|
42
|
+
/** The app that created this agent — another canister's principal. Undefined for a
|
|
43
|
+
* configuration written before agents had an owner; only a canister admin may touch
|
|
44
|
+
* one of those. */
|
|
45
|
+
createdBy?: string;
|
|
46
|
+
/** The person allowed to change the agent's words (and nothing else). */
|
|
47
|
+
owner?: string;
|
|
42
48
|
/** Nanoseconds since epoch */
|
|
43
49
|
createdAt: bigint;
|
|
44
50
|
/** Nanoseconds since epoch */
|
|
45
51
|
updatedAt: bigint;
|
|
46
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
|
+
}
|
|
47
63
|
/** Input for AgentConfigsActor.upsertAgentConfigAsyncUnsafe — customConfigJson as a
|
|
48
64
|
* plain optional (candid `opt` shaping done by the wrapper); tools is optional here
|
|
49
65
|
* even though the canister's own UpsertAgentConfigArgs requires it — the wrapper
|
|
@@ -59,5 +75,7 @@ export interface UpsertAgentConfigInput {
|
|
|
59
75
|
paramsJson: string;
|
|
60
76
|
}[];
|
|
61
77
|
customConfigJson?: string;
|
|
78
|
+
/** Read only when the agent is CREATED: the person who may change its words later. */
|
|
79
|
+
owner?: string;
|
|
62
80
|
}
|
|
63
81
|
//# 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;;;;iEAI6D;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACrB;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;
|
|
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;;;;iEAI6D;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;uBAEmB;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;8FAG8F;AAC9F,MAAM,WAAW,iCAAiC;IAC9C;4CACwC;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,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 {
|
|
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
|
-
export declare function mapAgentConfigView(config:
|
|
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,
|
|
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
|
@@ -27,8 +27,19 @@ export function mapAgentConfigView(config) {
|
|
|
27
27
|
disclosesAsAi: config.disclosesAsAi,
|
|
28
28
|
tools: config.tools,
|
|
29
29
|
customConfigJson: fromOpt(config.customConfigJson),
|
|
30
|
+
createdBy: fromOpt(config.createdBy)?.toString(),
|
|
31
|
+
owner: fromOpt(config.owner)?.toString(),
|
|
30
32
|
createdAt: config.createdAt,
|
|
31
33
|
updatedAt: config.updatedAt,
|
|
32
34
|
};
|
|
33
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
|
+
}
|
|
34
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": "",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"build": "tsc",
|
|
23
23
|
"clean": "rm -rf dist",
|
|
24
24
|
"prepare": "npm run build",
|
|
25
|
-
"publish-public": "
|
|
25
|
+
"publish-public": "bash scripts/publish-public.sh",
|
|
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 .",
|
|
32
|
-
"
|
|
33
|
-
"prepublishOnly": "npm run guard:clean"
|
|
33
|
+
"stamp-canister": "bash scripts/stamp-canister-commit.sh"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@jsm-mit/utils-package": "^0.5.0"
|
|
@@ -39,12 +39,17 @@
|
|
|
39
39
|
"@icp-sdk/core": "^6.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"@icp-sdk/core": "^6.1.0",
|
|
42
43
|
"@jsm-mit/cli-game-helpers": "^0.1.0",
|
|
43
44
|
"@types/node": "^22.0.0",
|
|
44
45
|
"dotenv": "^16.4.0",
|
|
45
46
|
"prettier": "^3.3.0",
|
|
46
47
|
"tsx": "^4.19.0",
|
|
47
|
-
"typescript": "^5.6.0"
|
|
48
|
-
|
|
48
|
+
"typescript": "^5.6.0"
|
|
49
|
+
},
|
|
50
|
+
"agentPlatformCanister": {
|
|
51
|
+
"repo": "agent-platform-canister",
|
|
52
|
+
"repoUrl": "https://github.com/JSM-Agent-Platform/agent-platform-canister",
|
|
53
|
+
"commit": "ef1892ea4ce350afd6dc13e1452167aa7e9b4970"
|
|
49
54
|
}
|
|
50
55
|
}
|