@openscout/protocol 0.2.16 → 0.2.17
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/package.json +2 -1
- package/src/actors.ts +85 -0
- package/src/agent-address.ts +1 -0
- package/src/agent-identity.test.ts +265 -0
- package/src/agent-identity.ts +508 -0
- package/src/agent-selectors.ts +1 -0
- package/src/collaboration.ts +272 -0
- package/src/common.ts +71 -0
- package/src/conversations.ts +37 -0
- package/src/deliveries.ts +46 -0
- package/src/events.ts +84 -0
- package/src/index.ts +14 -0
- package/src/invocations.ts +55 -0
- package/src/mesh.ts +16 -0
- package/src/messages.ts +55 -0
- package/src/relay-agent-card.test.ts +54 -0
- package/src/relay-agent-card.ts +76 -0
- package/src/transports.ts +92 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { AgentEndpoint, AgentHarness } from "./actors.js";
|
|
2
|
+
import type { MetadataMap, ScoutId } from "./common.js";
|
|
3
|
+
|
|
4
|
+
export interface RelayReturnAddress {
|
|
5
|
+
actorId: ScoutId;
|
|
6
|
+
handle: string;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
selector?: string;
|
|
9
|
+
defaultSelector?: string;
|
|
10
|
+
conversationId?: ScoutId;
|
|
11
|
+
replyToMessageId?: ScoutId;
|
|
12
|
+
nodeId?: ScoutId;
|
|
13
|
+
projectRoot?: string;
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
metadata?: MetadataMap;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RelayAgentCard {
|
|
19
|
+
id: ScoutId;
|
|
20
|
+
agentId: ScoutId;
|
|
21
|
+
definitionId: ScoutId;
|
|
22
|
+
displayName: string;
|
|
23
|
+
handle: string;
|
|
24
|
+
selector?: string;
|
|
25
|
+
defaultSelector?: string;
|
|
26
|
+
projectName?: string;
|
|
27
|
+
projectRoot: string;
|
|
28
|
+
currentDirectory: string;
|
|
29
|
+
harness: AgentHarness;
|
|
30
|
+
transport: AgentEndpoint["transport"];
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
branch?: string;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
createdById?: ScoutId;
|
|
35
|
+
brokerRegistered: boolean;
|
|
36
|
+
inboxConversationId?: ScoutId;
|
|
37
|
+
returnAddress: RelayReturnAddress;
|
|
38
|
+
metadata?: MetadataMap;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function buildRelayReturnAddress(input: RelayReturnAddress): RelayReturnAddress {
|
|
42
|
+
const next: RelayReturnAddress = {
|
|
43
|
+
actorId: input.actorId,
|
|
44
|
+
handle: input.handle.trim(),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (input.displayName?.trim()) {
|
|
48
|
+
next.displayName = input.displayName.trim();
|
|
49
|
+
}
|
|
50
|
+
if (input.selector?.trim()) {
|
|
51
|
+
next.selector = input.selector.trim();
|
|
52
|
+
}
|
|
53
|
+
if (input.defaultSelector?.trim()) {
|
|
54
|
+
next.defaultSelector = input.defaultSelector.trim();
|
|
55
|
+
}
|
|
56
|
+
if (input.conversationId?.trim()) {
|
|
57
|
+
next.conversationId = input.conversationId.trim();
|
|
58
|
+
}
|
|
59
|
+
if (input.replyToMessageId?.trim()) {
|
|
60
|
+
next.replyToMessageId = input.replyToMessageId.trim();
|
|
61
|
+
}
|
|
62
|
+
if (input.nodeId?.trim()) {
|
|
63
|
+
next.nodeId = input.nodeId.trim();
|
|
64
|
+
}
|
|
65
|
+
if (input.projectRoot?.trim()) {
|
|
66
|
+
next.projectRoot = input.projectRoot.trim();
|
|
67
|
+
}
|
|
68
|
+
if (input.sessionId?.trim()) {
|
|
69
|
+
next.sessionId = input.sessionId.trim();
|
|
70
|
+
}
|
|
71
|
+
if (input.metadata && Object.keys(input.metadata).length > 0) {
|
|
72
|
+
next.metadata = input.metadata;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return next;
|
|
76
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { DeliveryTransport, MetadataMap, ScoutId } from "./common.js";
|
|
2
|
+
import type { AgentDefinition, AgentEndpoint, ActorIdentity } from "./actors.js";
|
|
3
|
+
import type { ConversationBinding, ConversationDefinition } from "./conversations.js";
|
|
4
|
+
import type { InvocationRequest } from "./invocations.js";
|
|
5
|
+
import type { NodeDefinition } from "./mesh.js";
|
|
6
|
+
import type { MessageRecord } from "./messages.js";
|
|
7
|
+
import type { CollaborationEvent, CollaborationRecord } from "./collaboration.js";
|
|
8
|
+
|
|
9
|
+
export interface SubscriptionRequest {
|
|
10
|
+
actorId: ScoutId;
|
|
11
|
+
conversationIds?: ScoutId[];
|
|
12
|
+
flightIds?: ScoutId[];
|
|
13
|
+
eventKinds?: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PostMessageCommand {
|
|
17
|
+
kind: "conversation.post";
|
|
18
|
+
message: MessageRecord;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface InvokeAgentCommand {
|
|
22
|
+
kind: "agent.invoke";
|
|
23
|
+
invocation: InvocationRequest;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface EnsureAwakeCommand {
|
|
27
|
+
kind: "agent.ensure_awake";
|
|
28
|
+
agentId: ScoutId;
|
|
29
|
+
requesterId: ScoutId;
|
|
30
|
+
reason: string;
|
|
31
|
+
metadata?: MetadataMap;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SubscribeCommand {
|
|
35
|
+
kind: "stream.subscribe";
|
|
36
|
+
subscription: SubscriptionRequest;
|
|
37
|
+
transport: Extract<DeliveryTransport, "local_socket" | "websocket">;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface NodeUpsertCommand {
|
|
41
|
+
kind: "node.upsert";
|
|
42
|
+
node: NodeDefinition;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ActorUpsertCommand {
|
|
46
|
+
kind: "actor.upsert";
|
|
47
|
+
actor: ActorIdentity;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AgentUpsertCommand {
|
|
51
|
+
kind: "agent.upsert";
|
|
52
|
+
agent: AgentDefinition;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface AgentEndpointUpsertCommand {
|
|
56
|
+
kind: "agent.endpoint.upsert";
|
|
57
|
+
endpoint: AgentEndpoint;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ConversationUpsertCommand {
|
|
61
|
+
kind: "conversation.upsert";
|
|
62
|
+
conversation: ConversationDefinition;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface BindingUpsertCommand {
|
|
66
|
+
kind: "binding.upsert";
|
|
67
|
+
binding: ConversationBinding;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface CollaborationUpsertCommand {
|
|
71
|
+
kind: "collaboration.upsert";
|
|
72
|
+
record: CollaborationRecord;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface CollaborationEventAppendCommand {
|
|
76
|
+
kind: "collaboration.event.append";
|
|
77
|
+
event: CollaborationEvent;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type ControlCommand =
|
|
81
|
+
| NodeUpsertCommand
|
|
82
|
+
| ActorUpsertCommand
|
|
83
|
+
| AgentUpsertCommand
|
|
84
|
+
| AgentEndpointUpsertCommand
|
|
85
|
+
| ConversationUpsertCommand
|
|
86
|
+
| BindingUpsertCommand
|
|
87
|
+
| CollaborationUpsertCommand
|
|
88
|
+
| CollaborationEventAppendCommand
|
|
89
|
+
| PostMessageCommand
|
|
90
|
+
| InvokeAgentCommand
|
|
91
|
+
| EnsureAwakeCommand
|
|
92
|
+
| SubscribeCommand;
|