@coasys/ad4m 0.13.1-staging.3 → 0.13.1-staging.5
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/lib/index.cjs +414 -160
- package/lib/index.js +414 -161
- package/lib/src/agent/AgentClient.d.ts +16 -1
- package/lib/src/agent/AgentClient.js +21 -2
- package/lib/src/ai/AITypes.d.ts +6 -2
- package/lib/src/apiClient.js +1 -1
- package/lib/src/generated/api/AgentMessage.d.ts +10 -0
- package/lib/src/generated/api/AgentReply.d.ts +9 -0
- package/{src/generated/api/PerspectiveRemovedWithOwner.ts → lib/src/generated/api/AgentReply.js} +1 -2
- package/lib/src/generated/api/Apps.d.ts +4 -0
- package/lib/src/generated/api/Events.d.ts +10 -12
- package/lib/src/generated/api/FlowStateChangedEvent.d.ts +3 -2
- package/lib/src/generated/api/Model.d.ts +4 -0
- package/lib/src/generated/api/ModelApi.d.ts +5 -1
- package/lib/src/generated/api/ModelApiInput.d.ts +7 -1
- package/lib/src/generated/api/Notification.d.ts +5 -1
- package/lib/src/generated/api/NotificationInput.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveEvent.d.ts +8 -0
- package/lib/src/generated/api/{PerspectiveLinkWithOwner.d.ts → PerspectiveLinkEvent.d.ts} +4 -2
- package/lib/src/generated/api/{PerspectiveLinkUpdatedWithOwner.d.ts → PerspectiveLinkUpdatedEvent.d.ts} +4 -2
- package/lib/src/generated/api/PerspectiveRemovedEvent.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveRemovedEvent.js +2 -0
- package/lib/src/generated/api/RequestCapabilityRequest.d.ts +1 -0
- package/lib/src/generated/api/RpcMethods.d.ts +16 -1
- package/lib/src/generated/api/RpcMethods.js +1 -0
- package/lib/src/generated/api/RunAgentRequest.d.ts +26 -0
- package/lib/src/generated/api/RuntimeUpdateNotificationParams.d.ts +6 -1
- package/lib/src/generated/api/UsersRevokeAllSessionsParams.d.ts +7 -0
- package/lib/src/generated/api/UsersRevokeAllSessionsParams.js +2 -0
- package/lib/src/generated/api/index.d.ts +3 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/model/types.d.ts +6 -0
- package/lib/src/neighbourhood/SfuManager.d.ts +15 -0
- package/lib/src/neighbourhood/SfuManager.js +39 -2
- package/lib/src/perspectives/Mentioning.d.ts +37 -0
- package/lib/src/perspectives/Mentioning.js +58 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +22 -0
- package/lib/src/perspectives/PerspectiveClient.js +13 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +19 -0
- package/lib/src/perspectives/PerspectiveProxy.js +19 -0
- package/lib/src/perspectives/TextContent.d.ts +4 -0
- package/lib/src/perspectives/TextContent.js +4 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +69 -10
- package/lib/src/perspectives/WakerSubscriptionManager.js +163 -61
- package/lib/src/runtime/RuntimeClient.d.ts +6 -3
- package/lib/src/runtime/RuntimeClient.js +2 -0
- package/lib/src/runtime/RuntimeTypes.d.ts +5 -1
- package/package.json +2 -2
- package/src/Ad4mClient.test.ts +53 -18
- package/src/agent/AgentClient.ts +26 -2
- package/src/ai/AITypes.ts +6 -2
- package/src/apiClient.test.ts +2 -3
- package/src/apiClient.ts +1 -1
- package/src/generated/api/AgentMessage.ts +10 -0
- package/src/generated/api/AgentReply.ts +10 -0
- package/src/generated/api/Apps.ts +6 -1
- package/src/generated/api/Events.ts +10 -12
- package/src/generated/api/FlowStateChangedEvent.ts +3 -2
- package/src/generated/api/Model.ts +4 -0
- package/src/generated/api/ModelApi.ts +5 -1
- package/src/generated/api/ModelApiInput.ts +8 -1
- package/src/generated/api/Notification.ts +5 -1
- package/src/generated/api/NotificationInput.ts +6 -1
- package/src/generated/api/PerspectiveEvent.ts +7 -0
- package/src/generated/api/{PerspectiveLinkUpdatedWithOwner.ts → PerspectiveLinkEvent.ts} +4 -1
- package/src/generated/api/PerspectiveLinkUpdatedEvent.ts +7 -0
- package/src/generated/api/PerspectiveRemovedEvent.ts +6 -0
- package/src/generated/api/RequestCapabilityRequest.ts +1 -1
- package/src/generated/api/RpcMethods.ts +8 -1
- package/src/generated/api/RunAgentRequest.ts +26 -0
- package/src/generated/api/RuntimeUpdateNotificationParams.ts +7 -1
- package/src/generated/api/UsersRevokeAllSessionsParams.ts +8 -0
- package/src/generated/api/index.ts +3 -0
- package/src/index.ts +1 -0
- package/src/model/types.ts +6 -0
- package/src/neighbourhood/SfuManager.test.ts +151 -2
- package/src/neighbourhood/SfuManager.ts +38 -1
- package/src/perspectives/Mentioning.test.ts +78 -0
- package/src/perspectives/Mentioning.ts +42 -0
- package/src/perspectives/PerspectiveClient.ts +30 -0
- package/src/perspectives/PerspectiveProxy.ts +26 -0
- package/src/perspectives/TextContent.ts +4 -0
- package/src/perspectives/WakerSubscriptionManager.test.ts +383 -151
- package/src/perspectives/WakerSubscriptionManager.ts +220 -61
- package/src/perspectives/link-updated-type.test.ts +2 -2
- package/src/perspectives/listener-leaks.test.ts +3 -3
- package/src/runtime/RuntimeClient.ts +6 -3
- package/src/runtime/RuntimeTypes.ts +8 -1
- package/lib/src/generated/api/MessageReceivedEvent.d.ts +0 -7
- package/lib/src/generated/api/PerspectiveRemovedWithOwner.d.ts +0 -5
- package/lib/src/generated/api/PerspectiveWithOwner.d.ts +0 -6
- package/src/generated/api/MessageReceivedEvent.ts +0 -7
- package/src/generated/api/PerspectiveLinkWithOwner.ts +0 -4
- package/src/generated/api/PerspectiveWithOwner.ts +0 -4
- /package/lib/src/generated/api/{PerspectiveRemovedWithOwner.js → AgentMessage.js} +0 -0
- /package/lib/src/generated/api/{MessageReceivedEvent.js → PerspectiveEvent.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveLinkUpdatedWithOwner.js → PerspectiveLinkEvent.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveLinkWithOwner.js → PerspectiveLinkUpdatedEvent.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveWithOwner.js → RunAgentRequest.js} +0 -0
|
@@ -48,7 +48,14 @@ export declare class AgentClient {
|
|
|
48
48
|
deleteEntanglementProofs(proofs: EntanglementProofInput[]): Promise<EntanglementProof[]>;
|
|
49
49
|
getEntanglementProofs(): Promise<EntanglementProof[]>;
|
|
50
50
|
entanglementProofPreFlight(deviceKey: string, deviceKeyType: string): Promise<EntanglementProof>;
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Asks the executor for a capability token. `agent` names the agent the token will act
|
|
53
|
+
* as: a managed user's email or an agent's DID; absent, the executor's main agent. That
|
|
54
|
+
* agent's owner approves the request (the operator for the main agent, the user for
|
|
55
|
+
* theirs). Returns the request id that {@link generateJwt} redeems with the approver's
|
|
56
|
+
* six-digit code.
|
|
57
|
+
*/
|
|
58
|
+
requestCapability(authInfo: AuthInfoInput, agent?: string): Promise<string>;
|
|
52
59
|
permitCapability(auth: string): Promise<string>;
|
|
53
60
|
generateJwt(requestId: string, rand: string): Promise<string>;
|
|
54
61
|
getApps(): Promise<Apps[]>;
|
|
@@ -60,6 +67,14 @@ export declare class AgentClient {
|
|
|
60
67
|
loginUser(email: string, password: string): Promise<string>;
|
|
61
68
|
requestLoginVerification(email: string, appInfo?: AuthInfoInput): Promise<VerificationRequestResult>;
|
|
62
69
|
verifyEmailCode(email: string, code: string, verificationType: string): Promise<string>;
|
|
70
|
+
/** Revokes this client's user token. The executor then closes the client's sockets. */
|
|
71
|
+
logout(): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Revokes every token of a user issued up to now, this client's own included, and closes
|
|
74
|
+
* their sockets. A user leaves out `email` (or names themselves); the operator names the
|
|
75
|
+
* user. Needs AGENT_UPDATE, which a login holds. Tokens from a later login work.
|
|
76
|
+
*/
|
|
77
|
+
revokeAllSessions(email?: string): Promise<boolean>;
|
|
63
78
|
hostingUserInfo(): Promise<HostingUserInfo>;
|
|
64
79
|
computeLog(since?: string, limit?: number, userEmail?: string): Promise<ComputeLogEntry[]>;
|
|
65
80
|
setHotWalletAddress(address: string): Promise<boolean>;
|
|
@@ -163,8 +163,15 @@ export class AgentClient {
|
|
|
163
163
|
async entanglementProofPreFlight(deviceKey, deviceKeyType) {
|
|
164
164
|
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.entanglementProofPreflight', { deviceKey, deviceKeyType });
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Asks the executor for a capability token. `agent` names the agent the token will act
|
|
168
|
+
* as: a managed user's email or an agent's DID; absent, the executor's main agent. That
|
|
169
|
+
* agent's owner approves the request (the operator for the main agent, the user for
|
|
170
|
+
* theirs). Returns the request id that {@link generateJwt} redeems with the approver's
|
|
171
|
+
* six-digit code.
|
|
172
|
+
*/
|
|
173
|
+
async requestCapability(authInfo, agent) {
|
|
174
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.requestCapability', agent === undefined ? { authInfo } : { authInfo, agent });
|
|
168
175
|
}
|
|
169
176
|
async permitCapability(auth) {
|
|
170
177
|
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.permitCapability', { auth });
|
|
@@ -200,6 +207,18 @@ export class AgentClient {
|
|
|
200
207
|
async verifyEmailCode(email, code, verificationType) {
|
|
201
208
|
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.verifyEmail', { email, code, verificationType });
|
|
202
209
|
}
|
|
210
|
+
/** Revokes this client's user token. The executor then closes the client's sockets. */
|
|
211
|
+
async logout() {
|
|
212
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.logout', {});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Revokes every token of a user issued up to now, this client's own included, and closes
|
|
216
|
+
* their sockets. A user leaves out `email` (or names themselves); the operator names the
|
|
217
|
+
* user. Needs AGENT_UPDATE, which a login holds. Tokens from a later login work.
|
|
218
|
+
*/
|
|
219
|
+
async revokeAllSessions(email) {
|
|
220
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.revokeAllSessions', email === undefined ? {} : { email });
|
|
221
|
+
}
|
|
203
222
|
// Hosting methods
|
|
204
223
|
async hostingUserInfo() {
|
|
205
224
|
const info = (await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('hosting.info', {})).userInfo ?? {
|
package/lib/src/ai/AITypes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare class ModelApi {
|
|
2
2
|
baseUrl: string;
|
|
3
|
-
|
|
3
|
+
/** Whether the model has a provider key. The executor never returns the key itself. */
|
|
4
|
+
hasApiKey: boolean;
|
|
4
5
|
model: string;
|
|
5
6
|
apiType: String;
|
|
6
7
|
/** Optional ceiling for the provider's context window (tokens).
|
|
@@ -28,7 +29,10 @@ export declare class Model {
|
|
|
28
29
|
}
|
|
29
30
|
export declare class ModelApiInput {
|
|
30
31
|
baseUrl: string;
|
|
31
|
-
|
|
32
|
+
/** The provider key. Empty or left out on `addModel`: no key. Left out on
|
|
33
|
+
* `updateModel`: the stored key stays, and the update is refused if `baseUrl`
|
|
34
|
+
* changes too. Empty on `updateModel`: the stored key is removed. */
|
|
35
|
+
apiKey?: string;
|
|
32
36
|
model: string;
|
|
33
37
|
apiType: string;
|
|
34
38
|
/** Optional ceiling for the provider's context window (tokens). */
|
package/lib/src/apiClient.js
CHANGED
|
@@ -98,7 +98,7 @@ export class ApiClient {
|
|
|
98
98
|
? new RpcError(401, event.reason || 'token expired or revoked')
|
|
99
99
|
: closedError(event?.code === CLOSE_TRY_AGAIN_LATER ? event.reason : undefined));
|
|
100
100
|
if (event?.code === CLOSE_AUTH_FAILED && this._ws === ws) {
|
|
101
|
-
this._failAuth(event.reason || 'token expired or revoked');
|
|
101
|
+
this._failAuth(event.reason || 'Unauthorized access: the token expired or was revoked');
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
104
|
this._onClose(ws, event?.code === CLOSE_TRY_AGAIN_LATER ? event.reason : undefined);
|
|
@@ -3,5 +3,9 @@ export type Apps = {
|
|
|
3
3
|
auth: AuthInfo;
|
|
4
4
|
requestId: string;
|
|
5
5
|
revoked: boolean | null;
|
|
6
|
+
/**
|
|
7
|
+
* Always empty: the executor does not keep app tokens, and an app receives its token
|
|
8
|
+
* once, from `agent.generateJwt`. The field stays for clients that require it.
|
|
9
|
+
*/
|
|
6
10
|
token: string;
|
|
7
11
|
};
|
|
@@ -7,14 +7,13 @@ import type { AutoProcessorNeighbourhoodState } from "./AutoProcessorNeighbourho
|
|
|
7
7
|
import type { ExceptionOccurredEvent } from "./ExceptionOccurredEvent";
|
|
8
8
|
import type { FlowStateChangedEvent } from "./FlowStateChangedEvent";
|
|
9
9
|
import type { HostingUserInfo } from "./HostingUserInfo";
|
|
10
|
-
import type { MessageReceivedEvent } from "./MessageReceivedEvent";
|
|
11
10
|
import type { NeighbourhoodSignalFilter } from "./NeighbourhoodSignalFilter";
|
|
12
11
|
import type { NotificationTriggeredEvent } from "./NotificationTriggeredEvent";
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
12
|
+
import type { PerspectiveEvent } from "./PerspectiveEvent";
|
|
13
|
+
import type { PerspectiveLinkEvent } from "./PerspectiveLinkEvent";
|
|
14
|
+
import type { PerspectiveLinkUpdatedEvent } from "./PerspectiveLinkUpdatedEvent";
|
|
15
|
+
import type { PerspectiveRemovedEvent } from "./PerspectiveRemovedEvent";
|
|
16
16
|
import type { PerspectiveStateFilter } from "./PerspectiveStateFilter";
|
|
17
|
-
import type { PerspectiveWithOwner } from "./PerspectiveWithOwner";
|
|
18
17
|
import type { QuerySubscriptionUpdateEvent } from "./QuerySubscriptionUpdateEvent";
|
|
19
18
|
import type { SfuCallRenegotiationOffer } from "./SfuCallRenegotiationOffer";
|
|
20
19
|
import type { SfuDataMessage } from "./SfuDataMessage";
|
|
@@ -27,15 +26,14 @@ export interface EventMap {
|
|
|
27
26
|
"agent-updated": AgentUpdatedEvent;
|
|
28
27
|
"apps-changed": Apps;
|
|
29
28
|
"hosting-user-info-changed": HostingUserInfo;
|
|
30
|
-
"perspective-added":
|
|
31
|
-
"perspective-removed":
|
|
32
|
-
"perspective-updated":
|
|
29
|
+
"perspective-added": PerspectiveEvent;
|
|
30
|
+
"perspective-removed": PerspectiveRemovedEvent;
|
|
31
|
+
"perspective-updated": PerspectiveEvent;
|
|
33
32
|
"sync-state-change": PerspectiveStateFilter;
|
|
34
|
-
"link-added":
|
|
35
|
-
"link-removed":
|
|
36
|
-
"link-updated":
|
|
33
|
+
"link-added": PerspectiveLinkEvent;
|
|
34
|
+
"link-removed": PerspectiveLinkEvent;
|
|
35
|
+
"link-updated": PerspectiveLinkUpdatedEvent;
|
|
37
36
|
"signal": NeighbourhoodSignalFilter;
|
|
38
|
-
"message-received": MessageReceivedEvent;
|
|
39
37
|
"notification-triggered": NotificationTriggeredEvent;
|
|
40
38
|
"exception-occurred": ExceptionOccurredEvent;
|
|
41
39
|
"transcription-text": TranscriptionTextFilter;
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
export type FlowStateChangedEvent = {
|
|
12
12
|
perspectiveUuid: string;
|
|
13
13
|
/**
|
|
14
|
-
* The agent whose replica derived this
|
|
15
|
-
*
|
|
14
|
+
* The agent whose replica derived this: the event's only recipient when it
|
|
15
|
+
* may read the perspective. Otherwise only the operator gets the main
|
|
16
|
+
* agent's event, and nobody gets another agent's.
|
|
16
17
|
*/
|
|
17
18
|
agentDid: string;
|
|
18
19
|
instance: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { LocalModel } from "./LocalModel";
|
|
2
2
|
import type { ModelApi } from "./ModelApi";
|
|
3
3
|
import type { ModelType } from "./ModelType";
|
|
4
|
+
/**
|
|
5
|
+
* A model as RPC results show it. Its provider key never leaves the executor:
|
|
6
|
+
* `api.hasApiKey` says whether one is set.
|
|
7
|
+
*/
|
|
4
8
|
export type Model = {
|
|
5
9
|
id: string;
|
|
6
10
|
name: string;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { ModelApiType } from "./ModelApiType";
|
|
2
|
+
/**
|
|
3
|
+
* A remote model's endpoint as RPC results show it: whether a provider key is set,
|
|
4
|
+
* never the key.
|
|
5
|
+
*/
|
|
2
6
|
export type ModelApi = {
|
|
3
7
|
baseUrl: string;
|
|
4
|
-
|
|
8
|
+
hasApiKey: boolean;
|
|
5
9
|
model: string;
|
|
6
10
|
apiType: ModelApiType;
|
|
7
11
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export type ModelApiInput = {
|
|
2
2
|
baseUrl: string;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The provider key. An empty key stores no key, and so does `ai.addModel` without
|
|
5
|
+
* one. `ai.updateModel` without one keeps the stored key; it refuses the update if
|
|
6
|
+
* `baseUrl` changes too, because a key goes only to the endpoint it was set for.
|
|
7
|
+
* Never serialised back out.
|
|
8
|
+
*/
|
|
9
|
+
apiKey?: string;
|
|
4
10
|
model: string;
|
|
5
11
|
apiType: string;
|
|
6
12
|
/**
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A notification as RPC results and events show it: whether a webhook credential is
|
|
3
|
+
* set, never the credential.
|
|
4
|
+
*/
|
|
1
5
|
export type Notification = {
|
|
2
6
|
id: string;
|
|
3
7
|
granted: boolean;
|
|
@@ -8,7 +12,7 @@ export type Notification = {
|
|
|
8
12
|
trigger: string;
|
|
9
13
|
perspectiveIds: Array<string>;
|
|
10
14
|
webhookUrl: string;
|
|
11
|
-
|
|
15
|
+
hasWebhookAuth: boolean;
|
|
12
16
|
/**
|
|
13
17
|
* The owner's DID: a managed user's, or the main agent's.
|
|
14
18
|
*/
|
|
@@ -6,5 +6,9 @@ export type NotificationInput = {
|
|
|
6
6
|
trigger: string;
|
|
7
7
|
perspectiveIds: Array<string>;
|
|
8
8
|
webhookUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Sent as the bearer credential to `webhookUrl`. Results and events say only
|
|
11
|
+
* whether one is set (`hasWebhookAuth`).
|
|
12
|
+
*/
|
|
9
13
|
webhookAuth: string;
|
|
10
14
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PerspectiveHandle } from "./PerspectiveHandle";
|
|
2
|
+
/**
|
|
3
|
+
* `perspective-added` / `perspective-updated`: one event to all of the perspective's owners.
|
|
4
|
+
*/
|
|
5
|
+
export type PerspectiveEvent = {
|
|
6
|
+
perspectiveUuid: string;
|
|
7
|
+
perspective: PerspectiveHandle;
|
|
8
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { DecoratedLinkExpression } from "./DecoratedLinkExpression";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* `link-added` / `link-removed`: one event to all of the perspective's owners.
|
|
4
|
+
*/
|
|
5
|
+
export type PerspectiveLinkEvent = {
|
|
3
6
|
perspectiveUuid: string;
|
|
4
7
|
link: DecoratedLinkExpression;
|
|
5
|
-
owner: string;
|
|
6
8
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { DecoratedLinkExpression } from "./DecoratedLinkExpression";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* `link-updated`: one event to all of the perspective's owners.
|
|
4
|
+
*/
|
|
5
|
+
export type PerspectiveLinkUpdatedEvent = {
|
|
3
6
|
perspectiveUuid: string;
|
|
4
7
|
newLink: DecoratedLinkExpression;
|
|
5
8
|
oldLink: DecoratedLinkExpression;
|
|
6
|
-
owner: string;
|
|
7
9
|
};
|
|
@@ -5,6 +5,7 @@ import type { Agent } from "./Agent";
|
|
|
5
5
|
import type { AgentAddEntanglementProofsParams } from "./AgentAddEntanglementProofsParams";
|
|
6
6
|
import type { AgentByDidParams } from "./AgentByDidParams";
|
|
7
7
|
import type { AgentRemoveAppParams } from "./AgentRemoveAppParams";
|
|
8
|
+
import type { AgentReply } from "./AgentReply";
|
|
8
9
|
import type { AgentRevokeTokenParams } from "./AgentRevokeTokenParams";
|
|
9
10
|
import type { AgentSignature } from "./AgentSignature";
|
|
10
11
|
import type { AgentStatus } from "./AgentStatus";
|
|
@@ -125,6 +126,7 @@ import type { PublishLanguageRequest } from "./PublishLanguageRequest";
|
|
|
125
126
|
import type { PublishNeighbourhoodRequest } from "./PublishNeighbourhoodRequest";
|
|
126
127
|
import type { RequestCapabilityRequest } from "./RequestCapabilityRequest";
|
|
127
128
|
import type { RequestPaymentRequest } from "./RequestPaymentRequest";
|
|
129
|
+
import type { RunAgentRequest } from "./RunAgentRequest";
|
|
128
130
|
import type { RunInterpretationRequest } from "./RunInterpretationRequest";
|
|
129
131
|
import type { RunInterpretationWithHarnessRequest } from "./RunInterpretationWithHarnessRequest";
|
|
130
132
|
import type { RuntimeComputeLogParams } from "./RuntimeComputeLogParams";
|
|
@@ -172,6 +174,7 @@ import type { UsersEmailTestParams } from "./UsersEmailTestParams";
|
|
|
172
174
|
import type { UsersEmailTestResult } from "./UsersEmailTestResult";
|
|
173
175
|
import type { UsersLoginParams } from "./UsersLoginParams";
|
|
174
176
|
import type { UsersRequestVerificationParams } from "./UsersRequestVerificationParams";
|
|
177
|
+
import type { UsersRevokeAllSessionsParams } from "./UsersRevokeAllSessionsParams";
|
|
175
178
|
import type { UsersSetCreditsParams } from "./UsersSetCreditsParams";
|
|
176
179
|
import type { UsersVerifyEmailParams } from "./UsersVerifyEmailParams";
|
|
177
180
|
import type { ValidOutput } from "./ValidOutput";
|
|
@@ -635,6 +638,10 @@ export interface RpcMethods {
|
|
|
635
638
|
params: PerspectiveSubscriptionParams;
|
|
636
639
|
result: PerspectiveResynced;
|
|
637
640
|
};
|
|
641
|
+
"perspective.runAgent": {
|
|
642
|
+
params: RunAgentRequest;
|
|
643
|
+
result: AgentReply;
|
|
644
|
+
};
|
|
638
645
|
"perspective.runInterpretation": {
|
|
639
646
|
params: RunInterpretationRequest;
|
|
640
647
|
result: Array<string>;
|
|
@@ -743,7 +750,7 @@ export interface RpcMethods {
|
|
|
743
750
|
};
|
|
744
751
|
"runtime.linkLanguageTemplates": {
|
|
745
752
|
params: Record<string, never>;
|
|
746
|
-
result: Array<
|
|
753
|
+
result: Array<LanguageMeta>;
|
|
747
754
|
};
|
|
748
755
|
"runtime.networkMetrics": {
|
|
749
756
|
params: Record<string, never>;
|
|
@@ -933,6 +940,10 @@ export interface RpcMethods {
|
|
|
933
940
|
params: UsersLoginParams;
|
|
934
941
|
result: string;
|
|
935
942
|
};
|
|
943
|
+
"user.logout": {
|
|
944
|
+
params: Record<string, never>;
|
|
945
|
+
result: boolean;
|
|
946
|
+
};
|
|
936
947
|
"user.multiUserEnabled": {
|
|
937
948
|
params: Record<string, never>;
|
|
938
949
|
result: boolean;
|
|
@@ -941,6 +952,10 @@ export interface RpcMethods {
|
|
|
941
952
|
params: UsersRequestVerificationParams;
|
|
942
953
|
result: VerificationRequestResult;
|
|
943
954
|
};
|
|
955
|
+
"user.revokeAllSessions": {
|
|
956
|
+
params: UsersRevokeAllSessionsParams;
|
|
957
|
+
result: boolean;
|
|
958
|
+
};
|
|
944
959
|
"user.setMultiUserEnabled": {
|
|
945
960
|
params: SetMultiUserRequest;
|
|
946
961
|
result: boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentMessage } from "./AgentMessage";
|
|
2
|
+
export type RunAgentRequest = {
|
|
3
|
+
uuid: string;
|
|
4
|
+
/**
|
|
5
|
+
* The conversation so far, the person's request last.
|
|
6
|
+
*/
|
|
7
|
+
messages: Array<AgentMessage>;
|
|
8
|
+
/**
|
|
9
|
+
* What the person is looking at, as a hint for the model (`{ "recordId": "…" }`).
|
|
10
|
+
*/
|
|
11
|
+
context?: Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Tools that write which the model may call — `instance_update`, `template_update`; only
|
|
14
|
+
* tools that write inside the perspective (`agent_session::SESSION_WRITES`). None means a
|
|
15
|
+
* session that only reads.
|
|
16
|
+
*/
|
|
17
|
+
writeTools?: Array<string>;
|
|
18
|
+
/**
|
|
19
|
+
* A model id; the node's default language model when absent.
|
|
20
|
+
*/
|
|
21
|
+
model?: string;
|
|
22
|
+
/**
|
|
23
|
+
* How many tool calls the model may make before it must answer. Default 20.
|
|
24
|
+
*/
|
|
25
|
+
maxToolCalls?: number;
|
|
26
|
+
};
|
|
@@ -7,5 +7,10 @@ export type RuntimeUpdateNotificationParams = {
|
|
|
7
7
|
trigger: string;
|
|
8
8
|
perspectiveIds: Array<string>;
|
|
9
9
|
webhookUrl: string;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Without it the update keeps the stored credential, and fails if `webhookUrl`
|
|
12
|
+
* changes too, because a credential goes only to the webhook it was set for. An empty
|
|
13
|
+
* string clears it.
|
|
14
|
+
*/
|
|
15
|
+
webhookAuth?: string;
|
|
11
16
|
};
|
|
@@ -2,6 +2,8 @@ export type { AddLinkExpressionRequest } from "./AddLinkExpressionRequest";
|
|
|
2
2
|
export type { AddLinkRequest } from "./AddLinkRequest";
|
|
3
3
|
export type { AddLinksBulkRequest } from "./AddLinksBulkRequest";
|
|
4
4
|
export type { AddSdnaRequest } from "./AddSdnaRequest";
|
|
5
|
+
export type { AgentMessage } from "./AgentMessage";
|
|
6
|
+
export type { AgentReply } from "./AgentReply";
|
|
5
7
|
export type { AgentsByDidsRequest } from "./AgentsByDidsRequest";
|
|
6
8
|
export type { ApplyTemplateRequest } from "./ApplyTemplateRequest";
|
|
7
9
|
export type { CommitBatchRequest } from "./CommitBatchRequest";
|
|
@@ -33,6 +35,7 @@ export type { QueryRequest } from "./QueryRequest";
|
|
|
33
35
|
export type { RemoveLinkRequest } from "./RemoveLinkRequest";
|
|
34
36
|
export type { RemoveLinksBulkRequest } from "./RemoveLinksBulkRequest";
|
|
35
37
|
export type { ResyncSubscriptionRequest } from "./ResyncSubscriptionRequest";
|
|
38
|
+
export type { RunAgentRequest } from "./RunAgentRequest";
|
|
36
39
|
export type { RunInterpretationRequest } from "./RunInterpretationRequest";
|
|
37
40
|
export type { SetDefaultModelRequest } from "./SetDefaultModelRequest";
|
|
38
41
|
export type { SetFreeHostingEnabledRequest } from "./SetFreeHostingEnabledRequest";
|
package/lib/src/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./perspectives/AutoProcessor";
|
|
|
21
21
|
export * from "./perspectives/InterpretationModels";
|
|
22
22
|
export * from "./perspectives/FlowModels";
|
|
23
23
|
export * from "./perspectives/TextContent";
|
|
24
|
+
export * from "./perspectives/Mentioning";
|
|
24
25
|
export * from "./perspectives/Container";
|
|
25
26
|
export * from "./perspectives/FlowInstance";
|
|
26
27
|
export * from "./perspectives/SparqlBindings";
|
package/lib/src/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./perspectives/AutoProcessor";
|
|
|
21
21
|
export * from "./perspectives/InterpretationModels";
|
|
22
22
|
export * from "./perspectives/FlowModels";
|
|
23
23
|
export * from "./perspectives/TextContent";
|
|
24
|
+
export * from "./perspectives/Mentioning";
|
|
24
25
|
export * from "./perspectives/Container";
|
|
25
26
|
// Also exports FlowFireOutcome / FlowProposeResult, the result shapes of the
|
|
26
27
|
// flow write API — they live beside the `proposeTransition()` surface.
|
package/lib/src/model/types.d.ts
CHANGED
|
@@ -484,6 +484,12 @@ export interface LinkRow {
|
|
|
484
484
|
valid: boolean;
|
|
485
485
|
invalid: boolean;
|
|
486
486
|
};
|
|
487
|
+
/**
|
|
488
|
+
* Where this executor holds the link, spelled as `perspective.get()` spells
|
|
489
|
+
* it. Absent only when the store recorded none. Not signed: it says nothing
|
|
490
|
+
* about who wrote the link.
|
|
491
|
+
*/
|
|
492
|
+
status?: "SHARED" | "LOCAL";
|
|
487
493
|
}
|
|
488
494
|
/** `instance.__links`: requested entry (spelled as requested) → its rows, oldest first. */
|
|
489
495
|
export type LinksMap = Record<string, LinkRow[]>;
|
|
@@ -101,6 +101,10 @@ export declare class SfuManager {
|
|
|
101
101
|
private rosterUnsubscribe;
|
|
102
102
|
private dataChannelUnsubscribe;
|
|
103
103
|
private disconnectedTimer;
|
|
104
|
+
/** Running while the room's roster leaves this agent out: see `noticeRoster`. */
|
|
105
|
+
private unlistedTimer;
|
|
106
|
+
/** How long the roster may leave this agent out before the call is rebuilt. */
|
|
107
|
+
private static readonly UNLISTED_GRACE_MS;
|
|
104
108
|
constructor(neighbourhood: SfuNeighbourhoodApi, roomId: string, agentDid: string, neighbourhoodUrl?: string, iceConfig?: SfuIceConfig, sfuConfig?: SfuConfig);
|
|
105
109
|
/**
|
|
106
110
|
* Rebuild the call after its connection failed: leave, then join again
|
|
@@ -121,6 +125,17 @@ export declare class SfuManager {
|
|
|
121
125
|
join(localStream: MediaStream): Promise<void>;
|
|
122
126
|
/** Drop the server-event subscriptions of the current join. */
|
|
123
127
|
private releaseServerEvents;
|
|
128
|
+
private clearUnlistedTimer;
|
|
129
|
+
/**
|
|
130
|
+
* The room's roster no longer lists this agent while `pc` is the call's:
|
|
131
|
+
* the server has dropped this session, and ICE may not say so. In E6
|
|
132
|
+
* (CI job 53158) one of six sessions never started a rebuild after a
|
|
133
|
+
* 20 s outage the server had dropped it for. Rebuild once the roster has
|
|
134
|
+
* left this agent out for `UNLISTED_GRACE_MS`; a roster that lists it
|
|
135
|
+
* again in that time cancels, since one published just before this
|
|
136
|
+
* join landed can arrive after it.
|
|
137
|
+
*/
|
|
138
|
+
private noticeRoster;
|
|
124
139
|
/** Undo a join that failed part way: its subscription and its connection. */
|
|
125
140
|
private abandon;
|
|
126
141
|
/**
|
|
@@ -82,6 +82,8 @@ export class SfuManager {
|
|
|
82
82
|
this.rosterUnsubscribe = null;
|
|
83
83
|
this.dataChannelUnsubscribe = null;
|
|
84
84
|
this.disconnectedTimer = null;
|
|
85
|
+
/** Running while the room's roster leaves this agent out: see `noticeRoster`. */
|
|
86
|
+
this.unlistedTimer = null;
|
|
85
87
|
this.neighbourhood = neighbourhood;
|
|
86
88
|
this.neighbourhoodUrl = neighbourhoodUrl || "";
|
|
87
89
|
this.roomId = roomId;
|
|
@@ -368,6 +370,37 @@ export class SfuManager {
|
|
|
368
370
|
this.renegotiationUnsubscribe = null;
|
|
369
371
|
this.rosterUnsubscribe?.();
|
|
370
372
|
this.rosterUnsubscribe = null;
|
|
373
|
+
this.clearUnlistedTimer();
|
|
374
|
+
}
|
|
375
|
+
clearUnlistedTimer() {
|
|
376
|
+
if (this.unlistedTimer) {
|
|
377
|
+
clearTimeout(this.unlistedTimer);
|
|
378
|
+
this.unlistedTimer = null;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* The room's roster no longer lists this agent while `pc` is the call's:
|
|
383
|
+
* the server has dropped this session, and ICE may not say so. In E6
|
|
384
|
+
* (CI job 53158) one of six sessions never started a rebuild after a
|
|
385
|
+
* 20 s outage the server had dropped it for. Rebuild once the roster has
|
|
386
|
+
* left this agent out for `UNLISTED_GRACE_MS`; a roster that lists it
|
|
387
|
+
* again in that time cancels, since one published just before this
|
|
388
|
+
* join landed can arrive after it.
|
|
389
|
+
*/
|
|
390
|
+
noticeRoster(pc, dids) {
|
|
391
|
+
if (dids.includes(this.agentDid)) {
|
|
392
|
+
this.clearUnlistedTimer();
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (this.unlistedTimer)
|
|
396
|
+
return;
|
|
397
|
+
this.unlistedTimer = setTimeout(() => {
|
|
398
|
+
this.unlistedTimer = null;
|
|
399
|
+
if (this.state.peerConnection !== pc)
|
|
400
|
+
return;
|
|
401
|
+
console.info("SFU: the room no longer lists this session, rebuilding the call");
|
|
402
|
+
void this.reconnect();
|
|
403
|
+
}, SfuManager.UNLISTED_GRACE_MS);
|
|
371
404
|
}
|
|
372
405
|
/** Undo a join that failed part way: its subscription and its connection. */
|
|
373
406
|
abandon(pc) {
|
|
@@ -402,8 +435,10 @@ export class SfuManager {
|
|
|
402
435
|
if (!ours(roster) || this.state.peerConnection !== pc)
|
|
403
436
|
return;
|
|
404
437
|
void joined.then(() => {
|
|
405
|
-
if (this.state.peerConnection
|
|
406
|
-
|
|
438
|
+
if (this.state.peerConnection !== pc)
|
|
439
|
+
return;
|
|
440
|
+
this.applyRoster(roster.participants, true);
|
|
441
|
+
this.noticeRoster(pc, roster.participants);
|
|
407
442
|
});
|
|
408
443
|
});
|
|
409
444
|
for (const unsubscribe of previous)
|
|
@@ -617,3 +652,5 @@ SfuManager.MAX_RECONNECTS = 3;
|
|
|
617
652
|
SfuManager.REJOIN_WINDOW_MS = 120000;
|
|
618
653
|
/** How long ICE may stay disconnected before a rebuild: the executor's `ICE_DISCONNECT_GRACE`. */
|
|
619
654
|
SfuManager.DISCONNECT_GRACE_MS = 10000;
|
|
655
|
+
/** How long the roster may leave this agent out before the call is rebuilt. */
|
|
656
|
+
SfuManager.UNLISTED_GRACE_MS = 3000;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Ad4mModel } from "../model/Ad4mModel";
|
|
2
|
+
/**
|
|
3
|
+
* The built-in abstract class `Mentioning { mentions }`: a record that
|
|
4
|
+
* mentions agents — a post, a message, a block of a document. `mentions` is
|
|
5
|
+
* a relation to their DIDs.
|
|
6
|
+
*
|
|
7
|
+
* Querying it reads every class that has a relation named `mentions`, or one
|
|
8
|
+
* aliased to `mentions`, under any predicate, whether or not the class has
|
|
9
|
+
* text. A class whose relation has another name aliases it:
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* @Model({ name: "Note", implements: [Mentioning] })
|
|
13
|
+
* class Note extends Ad4mModel {
|
|
14
|
+
* @HasMany({ through: "app://cc", alias: { Mentioning: "mentions" } })
|
|
15
|
+
* cc: string[] = [];
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* const mentioningMe = await Mentioning.findAll(perspective, { where: { mentions: myDid } });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The waker's mention subscription (`get_mention_waker_config`) reads it: a
|
|
22
|
+
* record whose `mentions` links the agent's DID, in a link another agent
|
|
23
|
+
* wrote, wakes the agent whatever its text says. Names in text it reads
|
|
24
|
+
* through {@link TextContent}.
|
|
25
|
+
*
|
|
26
|
+
* Built in: the executor declares it (mirrors
|
|
27
|
+
* `rust-executor/src/perspectives/hardwired_sdna/mentioning.json`) and reads
|
|
28
|
+
* it by its URI, `ad4m://Mentioning`, so a perspective never stores it and an
|
|
29
|
+
* app class named `Mentioning` does not replace it. `register()` on it writes
|
|
30
|
+
* nothing.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Mentioning extends Ad4mModel {
|
|
33
|
+
/** The URI the executor reads it by. */
|
|
34
|
+
static readonly builtinUri = "ad4m://Mentioning";
|
|
35
|
+
/** The agents (DIDs) the record mentions. */
|
|
36
|
+
mentions: string[];
|
|
37
|
+
}
|