agent-protocols 0.4.1 → 0.6.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 +3 -3
- package/dist/delegation.d.ts +28 -4
- package/dist/delegation.d.ts.map +1 -1
- package/dist/delegation.js +60 -6
- package/dist/delegation.js.map +1 -1
- package/dist/discourse.d.ts +67 -3
- package/dist/discourse.d.ts.map +1 -1
- package/dist/discourse.js +149 -2
- package/dist/discourse.js.map +1 -1
- package/dist/errors.d.ts +6 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -3
- package/dist/errors.js.map +1 -1
- package/dist/http-client.d.ts +24 -4
- package/dist/http-client.d.ts.map +1 -1
- package/dist/http-client.js +40 -9
- package/dist/http-client.js.map +1 -1
- package/dist/identity.d.ts +17 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +40 -8
- package/dist/identity.js.map +1 -1
- package/dist/local-connector/catalog.d.ts +55 -0
- package/dist/local-connector/catalog.d.ts.map +1 -0
- package/dist/local-connector/catalog.js +151 -0
- package/dist/local-connector/catalog.js.map +1 -0
- package/dist/local-connector/engine.d.ts +94 -0
- package/dist/local-connector/engine.d.ts.map +1 -0
- package/dist/local-connector/engine.js +1234 -0
- package/dist/local-connector/engine.js.map +1 -0
- package/dist/local-connector/inputs.d.ts +231 -0
- package/dist/local-connector/inputs.d.ts.map +1 -0
- package/dist/local-connector/inputs.js +4 -0
- package/dist/local-connector/inputs.js.map +1 -0
- package/dist/local-connector/internal.d.ts +6 -0
- package/dist/local-connector/internal.d.ts.map +1 -0
- package/dist/local-connector/internal.js +18 -0
- package/dist/local-connector/internal.js.map +1 -0
- package/dist/local-connector/projection.d.ts +16 -0
- package/dist/local-connector/projection.d.ts.map +1 -0
- package/dist/local-connector/projection.js +306 -0
- package/dist/local-connector/projection.js.map +1 -0
- package/dist/local-connector/state.d.ts +66 -0
- package/dist/local-connector/state.d.ts.map +1 -0
- package/dist/local-connector/state.js +18 -0
- package/dist/local-connector/state.js.map +1 -0
- package/dist/local-connector/views.d.ts +169 -0
- package/dist/local-connector/views.d.ts.map +1 -0
- package/dist/local-connector/views.js +98 -0
- package/dist/local-connector/views.js.map +1 -0
- package/dist/local-connector.d.ts +5 -234
- package/dist/local-connector.d.ts.map +1 -1
- package/dist/local-connector.js +26 -251
- package/dist/local-connector.js.map +1 -1
- package/dist/profile.d.ts +12 -3
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +15 -1
- package/dist/profile.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Structured result types the connector returns to callers, plus the pure
|
|
2
|
+
// projection that turns a ServerRecord into a TimelineItem. These are the
|
|
3
|
+
// shapes a caller reads back; they carry no signing keys or live handles.
|
|
4
|
+
import { eventType, } from "../discourse.js";
|
|
5
|
+
import { isRecord, normalizeHost } from "./internal.js";
|
|
6
|
+
export function syncStateFromRoomResponse(host, room, options = {}) {
|
|
7
|
+
const head = room.head ?? { seq: room.seq, hash: room.hash };
|
|
8
|
+
return {
|
|
9
|
+
host: normalizeHost(host),
|
|
10
|
+
room_id: room.id,
|
|
11
|
+
head_seq: head.seq,
|
|
12
|
+
head_hash: head.hash,
|
|
13
|
+
synced_seq: room.seq,
|
|
14
|
+
remote_seq: options.remoteSeq ?? room.seq,
|
|
15
|
+
subscribed: options.subscribed ?? false,
|
|
16
|
+
unread_count: options.unreadCount ?? 0,
|
|
17
|
+
pending_inbox_count: options.pendingInboxCount ?? 0,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function roomSummaryFromResponse(host, room, options = {}) {
|
|
21
|
+
const payload = room.envelope?.event.payload;
|
|
22
|
+
return {
|
|
23
|
+
room_id: room.id,
|
|
24
|
+
host: normalizeHost(host),
|
|
25
|
+
topic: room.topic ?? payload?.topic,
|
|
26
|
+
status: room.status,
|
|
27
|
+
visibility: room.visibility ?? payload?.visibility,
|
|
28
|
+
start_time: room.start_time ?? payload?.start_time,
|
|
29
|
+
end_time: room.end_time ?? payload?.end_time,
|
|
30
|
+
tags: room.tags ?? payload?.tags,
|
|
31
|
+
language: room.language ?? payload?.language,
|
|
32
|
+
role: options.role,
|
|
33
|
+
unread_count: options.unreadCount ?? 0,
|
|
34
|
+
pending_inbox_count: options.pendingInboxCount ?? 0,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function timelineItemFromRecord(record) {
|
|
38
|
+
const event = record.envelope.event;
|
|
39
|
+
const payload = event.payload;
|
|
40
|
+
const message = messagePayload(payload);
|
|
41
|
+
return {
|
|
42
|
+
room_id: record.room_id,
|
|
43
|
+
seq: record.seq,
|
|
44
|
+
event_id: record.envelope.hash,
|
|
45
|
+
type: event.type,
|
|
46
|
+
kind: timelineKind(event.type),
|
|
47
|
+
actor: event.actor,
|
|
48
|
+
created_at: event.created_at,
|
|
49
|
+
received_at: record.received_at,
|
|
50
|
+
summary: summarizePayload(event.type, payload),
|
|
51
|
+
content_type: message?.content_type,
|
|
52
|
+
content: message?.content,
|
|
53
|
+
mentions: event.mentions ?? [],
|
|
54
|
+
references: message?.references ?? [],
|
|
55
|
+
payload,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function timelineKind(type) {
|
|
59
|
+
if (type === eventType.MESSAGE_CREATE)
|
|
60
|
+
return "message";
|
|
61
|
+
if (type.startsWith("room."))
|
|
62
|
+
return "room";
|
|
63
|
+
if (type.startsWith("type."))
|
|
64
|
+
return "type";
|
|
65
|
+
return "custom";
|
|
66
|
+
}
|
|
67
|
+
function summarizePayload(type, payload) {
|
|
68
|
+
if (type === eventType.MESSAGE_CREATE) {
|
|
69
|
+
const message = messagePayload(payload);
|
|
70
|
+
if (typeof message?.content === "string")
|
|
71
|
+
return truncate(message.content, 200);
|
|
72
|
+
}
|
|
73
|
+
if (isRecord(payload)) {
|
|
74
|
+
const summary = payload.summary ?? payload.reason ?? payload.title ?? payload.state;
|
|
75
|
+
if (typeof summary === "string" && summary.trim() !== "") {
|
|
76
|
+
return truncate(summary, 200);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return type;
|
|
80
|
+
}
|
|
81
|
+
function messagePayload(payload) {
|
|
82
|
+
if (!isRecord(payload))
|
|
83
|
+
return undefined;
|
|
84
|
+
if (typeof payload.content_type !== "string")
|
|
85
|
+
return undefined;
|
|
86
|
+
return {
|
|
87
|
+
content_type: payload.content_type,
|
|
88
|
+
content: payload.content,
|
|
89
|
+
references: Array.isArray(payload.references)
|
|
90
|
+
? payload.references.filter((value) => typeof value === "string")
|
|
91
|
+
: undefined,
|
|
92
|
+
extra: isRecord(payload.extra) ? payload.extra : undefined,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function truncate(value, maxLength) {
|
|
96
|
+
return value.length <= maxLength ? value : `${value.slice(0, maxLength - 1)}...`;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/local-connector/views.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAE1E,OAAO,EAUL,SAAS,GACV,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA2LxD,MAAM,UAAU,yBAAyB,CACvC,IAAY,EACZ,IAAkB,EAClB,UAKI,EAAE;IAEN,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7D,OAAO;QACL,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC;QACzB,OAAO,EAAE,IAAI,CAAC,EAAE;QAChB,QAAQ,EAAE,IAAI,CAAC,GAAG;QAClB,SAAS,EAAE,IAAI,CAAC,IAAI;QACpB,UAAU,EAAE,IAAI,CAAC,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|
-
export
|
|
6
|
-
export declare const TOOL_ROOMS_SEARCH = "agent_protocols_rooms_search";
|
|
7
|
-
export declare const TOOL_ROOMS_LIST = "agent_protocols_rooms_list";
|
|
8
|
-
export declare const TOOL_ROOM_OPEN = "agent_protocols_room_open";
|
|
9
|
-
export declare const TOOL_ROOM_STATE = "agent_protocols_room_state";
|
|
10
|
-
export declare const TOOL_ROOM_MEMBERS_LIST = "agent_protocols_room_members_list";
|
|
11
|
-
export declare const TOOL_ROOM_MEMBER_GET = "agent_protocols_room_member_get";
|
|
12
|
-
export declare const TOOL_AGENT_STATUS_LIST = "agent_protocols_agent_status_list";
|
|
13
|
-
export declare const TOOL_AGENT_STATUS_GET = "agent_protocols_agent_status_get";
|
|
14
|
-
export declare const TOOL_AGENT_STATUS_SET = "agent_protocols_agent_status_set";
|
|
15
|
-
export declare const TOOL_AGENT_STATUS_CLEAR = "agent_protocols_agent_status_clear";
|
|
16
|
-
export declare const TOOL_ROOM_TIMELINE = "agent_protocols_room_timeline";
|
|
17
|
-
export declare const TOOL_ROOM_UNREAD = "agent_protocols_room_unread";
|
|
18
|
-
export declare const TOOL_ROOM_MARK_READ = "agent_protocols_room_mark_read";
|
|
19
|
-
export declare const TOOL_INBOX_NEXT = "agent_protocols_inbox_next";
|
|
20
|
-
export declare const TOOL_INBOX_ACK = "agent_protocols_inbox_ack";
|
|
21
|
-
export declare const TOOL_DRAFTS_LIST = "agent_protocols_drafts_list";
|
|
22
|
-
export declare const TOOL_DRAFT_GET = "agent_protocols_draft_get";
|
|
23
|
-
export declare const TOOL_DRAFT_COMMIT = "agent_protocols_draft_commit";
|
|
24
|
-
export declare const TOOL_DRAFT_DROP = "agent_protocols_draft_drop";
|
|
25
|
-
export declare const TOOL_PROFILE_UPDATE = "agent_protocols_profile_update";
|
|
26
|
-
export declare const TOOL_ROOM_CREATE = "agent_protocols_room_create";
|
|
27
|
-
export declare const TOOL_ROOM_JOIN = "agent_protocols_room_join";
|
|
28
|
-
/** @deprecated Use `agent_protocols_room_join`. */
|
|
29
|
-
export declare const TOOL_ROOM_JOIN_REQUEST = "agent_protocols_room_join_request";
|
|
30
|
-
/** @deprecated Use `agent_protocols_room_join`. */
|
|
31
|
-
export declare const TOOL_ROOM_JOIN_WHEN_APPROVED = "agent_protocols_room_join_when_approved";
|
|
32
|
-
export declare const TOOL_ROOM_LEAVE = "agent_protocols_room_leave";
|
|
33
|
-
export declare const TOOL_ROOM_SEND_MESSAGE = "agent_protocols_room_send_message";
|
|
34
|
-
export declare const TOOL_ROOM_SUBMIT_EVENT = "agent_protocols_room_submit_event";
|
|
35
|
-
export declare const TOOL_JOIN_REQUESTS_LIST = "agent_protocols_join_requests_list";
|
|
36
|
-
export declare const TOOL_JOIN_REQUEST_REVIEW = "agent_protocols_join_request_review";
|
|
37
|
-
export declare const RESOURCE_IDENTITY_CURRENT = "agent-protocols://identity/current";
|
|
38
|
-
export declare const RESOURCE_HOSTS = "agent-protocols://hosts";
|
|
39
|
-
export declare const RESOURCE_ROOMS = "agent-protocols://rooms";
|
|
40
|
-
export declare const RESOURCE_INBOX_PENDING = "agent-protocols://inbox/pending";
|
|
41
|
-
export declare const RESOURCE_DRAFTS_HELD = "agent-protocols://drafts/held";
|
|
42
|
-
export declare const RESOURCE_ROOM_AGENT_STATUS_SUFFIX = "/agent-status";
|
|
43
|
-
export type LocalConnectorToolName = typeof TOOL_IDENTITY_CURRENT | typeof TOOL_HOSTS_LIST | typeof TOOL_HOST_ADD | typeof TOOL_ROOMS_SEARCH | typeof TOOL_ROOMS_LIST | typeof TOOL_ROOM_OPEN | typeof TOOL_ROOM_STATE | typeof TOOL_ROOM_MEMBERS_LIST | typeof TOOL_ROOM_MEMBER_GET | typeof TOOL_AGENT_STATUS_LIST | typeof TOOL_AGENT_STATUS_GET | typeof TOOL_AGENT_STATUS_SET | typeof TOOL_AGENT_STATUS_CLEAR | typeof TOOL_ROOM_TIMELINE | typeof TOOL_ROOM_UNREAD | typeof TOOL_ROOM_MARK_READ | typeof TOOL_INBOX_NEXT | typeof TOOL_INBOX_ACK | typeof TOOL_DRAFTS_LIST | typeof TOOL_DRAFT_GET | typeof TOOL_DRAFT_COMMIT | typeof TOOL_DRAFT_DROP | typeof TOOL_PROFILE_UPDATE | typeof TOOL_ROOM_CREATE | typeof TOOL_ROOM_JOIN | typeof TOOL_ROOM_JOIN_REQUEST | typeof TOOL_ROOM_JOIN_WHEN_APPROVED | typeof TOOL_ROOM_LEAVE | typeof TOOL_ROOM_SEND_MESSAGE | typeof TOOL_ROOM_SUBMIT_EVENT | typeof TOOL_JOIN_REQUESTS_LIST | typeof TOOL_JOIN_REQUEST_REVIEW;
|
|
44
|
-
export interface LocalConnectorToolAnnotations {
|
|
45
|
-
readOnlyHint: boolean;
|
|
46
|
-
idempotentHint: boolean;
|
|
47
|
-
destructiveHint: boolean;
|
|
48
|
-
openWorldHint: boolean;
|
|
49
|
-
}
|
|
50
|
-
export interface LocalConnectorToolDefinition {
|
|
51
|
-
name: LocalConnectorToolName;
|
|
52
|
-
description: string;
|
|
53
|
-
input_schema: Record<string, unknown>;
|
|
54
|
-
output_schema: Record<string, unknown>;
|
|
55
|
-
annotations: LocalConnectorToolAnnotations;
|
|
56
|
-
}
|
|
57
|
-
export declare function standardToolDefinitions(): LocalConnectorToolDefinition[];
|
|
58
|
-
export interface SyncState {
|
|
59
|
-
host: string;
|
|
60
|
-
room_id: string;
|
|
61
|
-
head_seq: number;
|
|
62
|
-
head_hash: string;
|
|
63
|
-
synced_seq: number;
|
|
64
|
-
remote_seq: number;
|
|
65
|
-
subscribed: boolean;
|
|
66
|
-
unread_count: number;
|
|
67
|
-
pending_inbox_count: number;
|
|
68
|
-
}
|
|
69
|
-
export interface AgentProtocolsHost {
|
|
70
|
-
host: string;
|
|
71
|
-
label?: string;
|
|
72
|
-
allowed: boolean;
|
|
73
|
-
features?: string[];
|
|
74
|
-
profile_service?: string;
|
|
75
|
-
last_checked_at?: number;
|
|
76
|
-
}
|
|
77
|
-
export type RoomMemberStatus = "active" | "left" | "removed" | "unknown";
|
|
78
|
-
export interface RoomMemberProfile {
|
|
79
|
-
name?: string;
|
|
80
|
-
username?: string;
|
|
81
|
-
description?: string;
|
|
82
|
-
avatar_url?: string;
|
|
83
|
-
}
|
|
84
|
-
export interface RoomMemberView {
|
|
85
|
-
agent_id: AgentId;
|
|
86
|
-
role: Role;
|
|
87
|
-
status: RoomMemberStatus;
|
|
88
|
-
is_creator: boolean;
|
|
89
|
-
perspective?: string;
|
|
90
|
-
joined_seq?: number;
|
|
91
|
-
left_seq?: number | null;
|
|
92
|
-
last_event_seq?: number;
|
|
93
|
-
profile?: RoomMemberProfile;
|
|
94
|
-
extra?: Record<string, unknown>;
|
|
95
|
-
}
|
|
96
|
-
export interface TimelineItem {
|
|
97
|
-
room_id: string;
|
|
98
|
-
seq: number;
|
|
99
|
-
event_id: string;
|
|
100
|
-
type: string;
|
|
101
|
-
kind: string;
|
|
102
|
-
actor: AgentId;
|
|
103
|
-
created_at: number;
|
|
104
|
-
received_at: number;
|
|
105
|
-
summary: string;
|
|
106
|
-
content_type?: string;
|
|
107
|
-
content?: unknown;
|
|
108
|
-
mentions?: AgentId[];
|
|
109
|
-
references?: string[];
|
|
110
|
-
payload: unknown;
|
|
111
|
-
}
|
|
112
|
-
export type InboxKind = "room.message.new" | "room.mention" | "room.turn.assigned" | "room.steer" | "room.join.requested" | "room.join.approved" | "room.role.changed" | "room.state.changed" | "room.event.custom";
|
|
113
|
-
export type InboxPriority = "low" | "normal" | "high";
|
|
114
|
-
export interface InboxItem {
|
|
115
|
-
id: string;
|
|
116
|
-
kind: InboxKind;
|
|
117
|
-
priority: InboxPriority;
|
|
118
|
-
room_id?: string;
|
|
119
|
-
seq?: number;
|
|
120
|
-
event_id?: string;
|
|
121
|
-
actor?: AgentId;
|
|
122
|
-
created_at: number;
|
|
123
|
-
requires_response: boolean;
|
|
124
|
-
deadline?: number | null;
|
|
125
|
-
reason: string;
|
|
126
|
-
suggested_tools?: LocalConnectorToolName[];
|
|
127
|
-
message?: unknown;
|
|
128
|
-
}
|
|
129
|
-
export type HeadMismatchPolicy = "hold" | "reject" | "send_anyway";
|
|
130
|
-
export type HeldDraftKind = "message" | "event";
|
|
131
|
-
export type DraftAction = "revise" | "send_as_is" | "stay_silent" | "send_anyway";
|
|
132
|
-
export interface HeldDraft {
|
|
133
|
-
id: string;
|
|
134
|
-
room_id: string;
|
|
135
|
-
kind: HeldDraftKind;
|
|
136
|
-
created_at: number;
|
|
137
|
-
base_seq?: number;
|
|
138
|
-
base_hash?: string;
|
|
139
|
-
current_sync: SyncState;
|
|
140
|
-
draft: unknown;
|
|
141
|
-
reason: string;
|
|
142
|
-
options?: DraftAction[];
|
|
143
|
-
}
|
|
144
|
-
export interface ActiveTurn {
|
|
145
|
-
turn_id: string;
|
|
146
|
-
speaker: AgentId;
|
|
147
|
-
assigned_seq: number;
|
|
148
|
-
expires_at?: number | null;
|
|
149
|
-
instruction?: string;
|
|
150
|
-
source_event_id: string;
|
|
151
|
-
}
|
|
152
|
-
export interface RoomSummary {
|
|
153
|
-
room_id: string;
|
|
154
|
-
host: string;
|
|
155
|
-
topic?: string;
|
|
156
|
-
status: RoomState;
|
|
157
|
-
visibility?: Visibility;
|
|
158
|
-
start_time?: number;
|
|
159
|
-
end_time?: number;
|
|
160
|
-
tags?: string[];
|
|
161
|
-
language?: string;
|
|
162
|
-
role?: Role;
|
|
163
|
-
unread_count: number;
|
|
164
|
-
pending_inbox_count: number;
|
|
165
|
-
}
|
|
166
|
-
export interface RoomStateView {
|
|
167
|
-
host: string;
|
|
168
|
-
room_id: string;
|
|
169
|
-
status: RoomState;
|
|
170
|
-
visibility?: Visibility;
|
|
171
|
-
topic?: string;
|
|
172
|
-
agenda?: string;
|
|
173
|
-
guidance?: string;
|
|
174
|
-
creator?: AgentId;
|
|
175
|
-
created_at?: number;
|
|
176
|
-
start_time?: number;
|
|
177
|
-
end_time?: number;
|
|
178
|
-
tags?: string[];
|
|
179
|
-
language?: string;
|
|
180
|
-
policy?: RoomPolicy;
|
|
181
|
-
types?: TypeDef[];
|
|
182
|
-
self_member?: RoomMemberView;
|
|
183
|
-
members_count: number;
|
|
184
|
-
active_turn?: ActiveTurn;
|
|
185
|
-
unread_count: number;
|
|
186
|
-
pending_inbox_count: number;
|
|
187
|
-
}
|
|
188
|
-
export type RoomsListMembership = "member" | "creator" | "moderator" | "pending" | "all";
|
|
189
|
-
export interface RoomSendMessageInput {
|
|
190
|
-
room_id: string;
|
|
191
|
-
content: string;
|
|
192
|
-
content_type?: string;
|
|
193
|
-
mentions?: AgentId[];
|
|
194
|
-
references?: string[];
|
|
195
|
-
extra?: Record<string, unknown>;
|
|
196
|
-
base_seq?: number;
|
|
197
|
-
base_hash?: string;
|
|
198
|
-
on_head_mismatch?: HeadMismatchPolicy;
|
|
199
|
-
}
|
|
200
|
-
export interface RoomSubmitEventInput {
|
|
201
|
-
room_id: string;
|
|
202
|
-
type: string;
|
|
203
|
-
payload: Record<string, unknown>;
|
|
204
|
-
mentions?: AgentId[];
|
|
205
|
-
references?: string[];
|
|
206
|
-
base_seq?: number;
|
|
207
|
-
base_hash?: string;
|
|
208
|
-
on_head_mismatch?: HeadMismatchPolicy;
|
|
209
|
-
}
|
|
210
|
-
export interface RoomWriteResult {
|
|
211
|
-
status: "sent" | "held" | "rejected";
|
|
212
|
-
record?: ServerRecord;
|
|
213
|
-
item?: TimelineItem;
|
|
214
|
-
draft?: HeldDraft;
|
|
215
|
-
changes?: TimelineItem[];
|
|
216
|
-
sync: SyncState;
|
|
217
|
-
}
|
|
218
|
-
export interface AgentStatusToolResult {
|
|
219
|
-
statuses?: AgentStatus[];
|
|
220
|
-
status?: AgentStatus;
|
|
221
|
-
sync?: SyncState;
|
|
222
|
-
}
|
|
223
|
-
export declare function syncStateFromRoomResponse(host: string, room: RoomResponse, options?: {
|
|
224
|
-
subscribed?: boolean;
|
|
225
|
-
unreadCount?: number;
|
|
226
|
-
pendingInboxCount?: number;
|
|
227
|
-
remoteSeq?: number;
|
|
228
|
-
}): SyncState;
|
|
229
|
-
export declare function roomSummaryFromResponse(host: string, room: RoomResponse, options?: {
|
|
230
|
-
role?: Role;
|
|
231
|
-
unreadCount?: number;
|
|
232
|
-
pendingInboxCount?: number;
|
|
233
|
-
}): RoomSummary;
|
|
234
|
-
export declare function timelineItemFromRecord(record: ServerRecord): TimelineItem;
|
|
1
|
+
export * from "./local-connector/catalog.js";
|
|
2
|
+
export * from "./local-connector/views.js";
|
|
3
|
+
export * from "./local-connector/inputs.js";
|
|
4
|
+
export * from "./local-connector/state.js";
|
|
5
|
+
export * from "./local-connector/engine.js";
|
|
235
6
|
//# sourceMappingURL=local-connector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-connector.d.ts","sourceRoot":"","sources":["../src/local-connector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-connector.d.ts","sourceRoot":"","sources":["../src/local-connector.ts"],"names":[],"mappings":"AAsBA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC"}
|
package/dist/local-connector.js
CHANGED
|
@@ -1,252 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
/** @deprecated Use `agent_protocols_room_join`. */
|
|
28
|
-
export const TOOL_ROOM_JOIN_REQUEST = "agent_protocols_room_join_request";
|
|
29
|
-
/** @deprecated Use `agent_protocols_room_join`. */
|
|
30
|
-
export const TOOL_ROOM_JOIN_WHEN_APPROVED = "agent_protocols_room_join_when_approved";
|
|
31
|
-
export const TOOL_ROOM_LEAVE = "agent_protocols_room_leave";
|
|
32
|
-
export const TOOL_ROOM_SEND_MESSAGE = "agent_protocols_room_send_message";
|
|
33
|
-
export const TOOL_ROOM_SUBMIT_EVENT = "agent_protocols_room_submit_event";
|
|
34
|
-
export const TOOL_JOIN_REQUESTS_LIST = "agent_protocols_join_requests_list";
|
|
35
|
-
export const TOOL_JOIN_REQUEST_REVIEW = "agent_protocols_join_request_review";
|
|
36
|
-
export const RESOURCE_IDENTITY_CURRENT = "agent-protocols://identity/current";
|
|
37
|
-
export const RESOURCE_HOSTS = "agent-protocols://hosts";
|
|
38
|
-
export const RESOURCE_ROOMS = "agent-protocols://rooms";
|
|
39
|
-
export const RESOURCE_INBOX_PENDING = "agent-protocols://inbox/pending";
|
|
40
|
-
export const RESOURCE_DRAFTS_HELD = "agent-protocols://drafts/held";
|
|
41
|
-
export const RESOURCE_ROOM_AGENT_STATUS_SUFFIX = "/agent-status";
|
|
42
|
-
export function standardToolDefinitions() {
|
|
43
|
-
const rows = [
|
|
44
|
-
[
|
|
45
|
-
TOOL_IDENTITY_CURRENT,
|
|
46
|
-
"Return the active local Agent ID and non-secret connector configuration.",
|
|
47
|
-
true,
|
|
48
|
-
true,
|
|
49
|
-
false,
|
|
50
|
-
],
|
|
51
|
-
[TOOL_HOSTS_LIST, "List configured Agent Discourse hosts.", true, true, false],
|
|
52
|
-
[
|
|
53
|
-
TOOL_HOST_ADD,
|
|
54
|
-
"Add an allowed Agent Discourse host after discovery.",
|
|
55
|
-
false,
|
|
56
|
-
true,
|
|
57
|
-
true,
|
|
58
|
-
],
|
|
59
|
-
[TOOL_ROOMS_SEARCH, "Search public rooms on an allowed host.", true, false, true],
|
|
60
|
-
[TOOL_ROOMS_LIST, "List locally known rooms and unread summaries.", true, true, false],
|
|
61
|
-
[
|
|
62
|
-
TOOL_ROOM_OPEN,
|
|
63
|
-
"Open a room, refresh local state, and optionally mark it subscribed.",
|
|
64
|
-
false,
|
|
65
|
-
true,
|
|
66
|
-
true,
|
|
67
|
-
],
|
|
68
|
-
[TOOL_ROOM_STATE, "Read the local materialized room state.", true, true, false],
|
|
69
|
-
[TOOL_ROOM_MEMBERS_LIST, "List materialized room members.", true, true, false],
|
|
70
|
-
[TOOL_ROOM_MEMBER_GET, "Read one materialized room member.", true, true, false],
|
|
71
|
-
[
|
|
72
|
-
TOOL_AGENT_STATUS_LIST,
|
|
73
|
-
"Read current transient agent statuses for a room.",
|
|
74
|
-
true,
|
|
75
|
-
false,
|
|
76
|
-
true,
|
|
77
|
-
],
|
|
78
|
-
[
|
|
79
|
-
TOOL_AGENT_STATUS_GET,
|
|
80
|
-
"Read one agent's current transient status in a room.",
|
|
81
|
-
true,
|
|
82
|
-
false,
|
|
83
|
-
true,
|
|
84
|
-
],
|
|
85
|
-
[
|
|
86
|
-
TOOL_AGENT_STATUS_SET,
|
|
87
|
-
"Update the active local agent's transient status in a room.",
|
|
88
|
-
false,
|
|
89
|
-
false,
|
|
90
|
-
true,
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
TOOL_AGENT_STATUS_CLEAR,
|
|
94
|
-
"Clear the active local agent's transient status in a room.",
|
|
95
|
-
false,
|
|
96
|
-
true,
|
|
97
|
-
true,
|
|
98
|
-
],
|
|
99
|
-
[TOOL_ROOM_TIMELINE, "Read simplified timeline items from the local cache.", true, true, false],
|
|
100
|
-
[
|
|
101
|
-
TOOL_ROOM_UNREAD,
|
|
102
|
-
"Read unread timeline items, optionally marking them read.",
|
|
103
|
-
false,
|
|
104
|
-
true,
|
|
105
|
-
false,
|
|
106
|
-
],
|
|
107
|
-
[TOOL_ROOM_MARK_READ, "Mark a room timeline read through a sequence number.", false, true, false],
|
|
108
|
-
[TOOL_INBOX_NEXT, "Read or claim pending actionable inbox items.", false, true, false],
|
|
109
|
-
[TOOL_INBOX_ACK, "Acknowledge, dismiss, or defer inbox items.", false, true, false],
|
|
110
|
-
[
|
|
111
|
-
TOOL_DRAFTS_LIST,
|
|
112
|
-
"List local held drafts that need explicit agent action.",
|
|
113
|
-
true,
|
|
114
|
-
true,
|
|
115
|
-
false,
|
|
116
|
-
],
|
|
117
|
-
[
|
|
118
|
-
TOOL_DRAFT_GET,
|
|
119
|
-
"Read one local held draft with room changes since it was held.",
|
|
120
|
-
true,
|
|
121
|
-
true,
|
|
122
|
-
false,
|
|
123
|
-
],
|
|
124
|
-
[TOOL_DRAFT_COMMIT, "Revise, send, or silence a local held draft.", false, false, true],
|
|
125
|
-
[TOOL_DRAFT_DROP, "Drop a local held draft without submitting it.", false, true, false],
|
|
126
|
-
[TOOL_PROFILE_UPDATE, "Sign and submit a profile.update envelope.", false, false, true],
|
|
127
|
-
[TOOL_ROOM_CREATE, "Sign and submit a room.create envelope.", false, false, true],
|
|
128
|
-
[
|
|
129
|
-
TOOL_ROOM_JOIN,
|
|
130
|
-
"Create a join request when needed or sign and submit room.join.",
|
|
131
|
-
false,
|
|
132
|
-
false,
|
|
133
|
-
true,
|
|
134
|
-
],
|
|
135
|
-
[TOOL_ROOM_LEAVE, "Sign and submit room.leave.", false, false, true],
|
|
136
|
-
[TOOL_ROOM_SEND_MESSAGE, "Sign and submit message.create.", false, false, true],
|
|
137
|
-
[TOOL_ROOM_SUBMIT_EVENT, "Sign and submit a room-defined event.", false, false, true],
|
|
138
|
-
[TOOL_JOIN_REQUESTS_LIST, "List visible join requests for a room.", true, false, true],
|
|
139
|
-
[TOOL_JOIN_REQUEST_REVIEW, "Sign and submit room.join.review.", false, false, true],
|
|
140
|
-
];
|
|
141
|
-
return rows.map(([name, description, readOnly, idempotent, openWorld]) => ({
|
|
142
|
-
name,
|
|
143
|
-
description,
|
|
144
|
-
input_schema: { type: "object" },
|
|
145
|
-
output_schema: { type: "object" },
|
|
146
|
-
annotations: {
|
|
147
|
-
readOnlyHint: readOnly,
|
|
148
|
-
idempotentHint: idempotent,
|
|
149
|
-
destructiveHint: false,
|
|
150
|
-
openWorldHint: openWorld,
|
|
151
|
-
},
|
|
152
|
-
}));
|
|
153
|
-
}
|
|
154
|
-
export function syncStateFromRoomResponse(host, room, options = {}) {
|
|
155
|
-
const head = room.head ?? { seq: room.seq, hash: room.hash };
|
|
156
|
-
return {
|
|
157
|
-
host: normalizeHost(host),
|
|
158
|
-
room_id: room.id,
|
|
159
|
-
head_seq: head.seq,
|
|
160
|
-
head_hash: head.hash,
|
|
161
|
-
synced_seq: room.seq,
|
|
162
|
-
remote_seq: options.remoteSeq ?? room.seq,
|
|
163
|
-
subscribed: options.subscribed ?? false,
|
|
164
|
-
unread_count: options.unreadCount ?? 0,
|
|
165
|
-
pending_inbox_count: options.pendingInboxCount ?? 0,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
export function roomSummaryFromResponse(host, room, options = {}) {
|
|
169
|
-
const payload = room.envelope?.event.payload;
|
|
170
|
-
return {
|
|
171
|
-
room_id: room.id,
|
|
172
|
-
host: normalizeHost(host),
|
|
173
|
-
topic: room.topic ?? payload?.topic,
|
|
174
|
-
status: room.status,
|
|
175
|
-
visibility: room.visibility ?? payload?.visibility,
|
|
176
|
-
start_time: room.start_time ?? payload?.start_time,
|
|
177
|
-
end_time: room.end_time ?? payload?.end_time,
|
|
178
|
-
tags: room.tags ?? payload?.tags,
|
|
179
|
-
language: room.language ?? payload?.language,
|
|
180
|
-
role: options.role,
|
|
181
|
-
unread_count: options.unreadCount ?? 0,
|
|
182
|
-
pending_inbox_count: options.pendingInboxCount ?? 0,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
export function timelineItemFromRecord(record) {
|
|
186
|
-
const event = record.envelope.event;
|
|
187
|
-
const payload = event.payload;
|
|
188
|
-
const message = messagePayload(payload);
|
|
189
|
-
return {
|
|
190
|
-
room_id: record.room_id,
|
|
191
|
-
seq: record.seq,
|
|
192
|
-
event_id: record.envelope.hash,
|
|
193
|
-
type: event.type,
|
|
194
|
-
kind: timelineKind(event.type),
|
|
195
|
-
actor: event.actor,
|
|
196
|
-
created_at: event.created_at,
|
|
197
|
-
received_at: record.received_at,
|
|
198
|
-
summary: summarizePayload(event.type, payload),
|
|
199
|
-
content_type: message?.content_type,
|
|
200
|
-
content: message?.content,
|
|
201
|
-
mentions: event.mentions ?? [],
|
|
202
|
-
references: message?.references ?? [],
|
|
203
|
-
payload,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
function timelineKind(type) {
|
|
207
|
-
if (type === eventType.MESSAGE_CREATE)
|
|
208
|
-
return "message";
|
|
209
|
-
if (type.startsWith("room."))
|
|
210
|
-
return "room";
|
|
211
|
-
if (type.startsWith("type."))
|
|
212
|
-
return "type";
|
|
213
|
-
return "custom";
|
|
214
|
-
}
|
|
215
|
-
function summarizePayload(type, payload) {
|
|
216
|
-
if (type === eventType.MESSAGE_CREATE) {
|
|
217
|
-
const message = messagePayload(payload);
|
|
218
|
-
if (typeof message?.content === "string")
|
|
219
|
-
return truncate(message.content, 200);
|
|
220
|
-
}
|
|
221
|
-
if (isRecord(payload)) {
|
|
222
|
-
const summary = payload.summary ?? payload.reason ?? payload.title ?? payload.state;
|
|
223
|
-
if (typeof summary === "string" && summary.trim() !== "") {
|
|
224
|
-
return truncate(summary, 200);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return type;
|
|
228
|
-
}
|
|
229
|
-
function messagePayload(payload) {
|
|
230
|
-
if (!isRecord(payload))
|
|
231
|
-
return undefined;
|
|
232
|
-
if (typeof payload.content_type !== "string")
|
|
233
|
-
return undefined;
|
|
234
|
-
return {
|
|
235
|
-
content_type: payload.content_type,
|
|
236
|
-
content: payload.content,
|
|
237
|
-
references: Array.isArray(payload.references)
|
|
238
|
-
? payload.references.filter((value) => typeof value === "string")
|
|
239
|
-
: undefined,
|
|
240
|
-
extra: isRecord(payload.extra) ? payload.extra : undefined,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function truncate(value, maxLength) {
|
|
244
|
-
return value.length <= maxLength ? value : `${value.slice(0, maxLength - 1)}...`;
|
|
245
|
-
}
|
|
246
|
-
function normalizeHost(host) {
|
|
247
|
-
return host.replace(/\/$/, "");
|
|
248
|
-
}
|
|
249
|
-
function isRecord(value) {
|
|
250
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
251
|
-
}
|
|
1
|
+
// Local Agent Protocols MCP connector.
|
|
2
|
+
//
|
|
3
|
+
// Transport-neutral: it exposes the standard local connector tool names,
|
|
4
|
+
// schemas, structured result types, a JSON dispatcher (`LocalConnector`), and
|
|
5
|
+
// local room-state projection. An MCP stdio server can wrap `LocalConnector`
|
|
6
|
+
// without giving the agent direct access to signing keys or reusable request
|
|
7
|
+
// JWTs.
|
|
8
|
+
//
|
|
9
|
+
// `LocalConnector` is one deep module. Its implementation is organized into
|
|
10
|
+
// submodules under `local-connector/` that vary independently, and this file is
|
|
11
|
+
// the module's public interface — a curated re-export of exactly those five:
|
|
12
|
+
// - catalog: the static tool/resource surface advertised to tools/list
|
|
13
|
+
// - views: the structured result types callers read back
|
|
14
|
+
// - inputs: the per-tool request shapes
|
|
15
|
+
// - state: the in-memory store records are projected into
|
|
16
|
+
// - engine: the LocalConnector class tying signing, HTTP, and projection
|
|
17
|
+
// together
|
|
18
|
+
//
|
|
19
|
+
// The pure record projection (`projection.ts`) and shared primitives
|
|
20
|
+
// (`internal.ts`) are internal seams — used by the engine and its tests, but
|
|
21
|
+
// deliberately absent from this interface.
|
|
22
|
+
export * from "./local-connector/catalog.js";
|
|
23
|
+
export * from "./local-connector/views.js";
|
|
24
|
+
export * from "./local-connector/inputs.js";
|
|
25
|
+
export * from "./local-connector/state.js";
|
|
26
|
+
export * from "./local-connector/engine.js";
|
|
252
27
|
//# sourceMappingURL=local-connector.js.map
|