@holon-run/agentinbox 1.0.3 → 1.0.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/README.md +13 -6
- package/dist/src/adapters.js +12 -0
- package/dist/src/cli.js +242 -62
- package/dist/src/current_agent.js +31 -0
- package/dist/src/http.js +127 -16
- package/dist/src/service.js +39 -30
- package/dist/src/source_hosts.js +2 -4
- package/dist/src/source_schema.js +1 -3
- package/dist/src/sources/feishu.js +1030 -31
- package/dist/src/sources/github.js +15 -6
- package/dist/src/sources/remote.js +25 -0
- package/dist/src/sources/remote_modules.js +30 -6
- package/dist/src/store.js +92 -30
- package/drizzle/migrations/0004_provider_raw_payload.sql +3 -0
- package/drizzle/schema.ts +2 -0
- package/package.json +3 -2
- package/skills/README.md +2 -2
- package/skills/agentinbox/SKILL.md +59 -14
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.summarizeActivationTarget = summarizeActivationTarget;
|
|
4
|
+
exports.isHolonRuntimeEnv = isHolonRuntimeEnv;
|
|
5
|
+
exports.detectHolonRuntimeContext = detectHolonRuntimeContext;
|
|
4
6
|
exports.resolveCurrentAgent = resolveCurrentAgent;
|
|
5
7
|
exports.annotateAgents = annotateAgents;
|
|
8
|
+
exports.isHolonRuntimeContext = isHolonRuntimeContext;
|
|
6
9
|
function summarizeActivationTarget(target) {
|
|
7
10
|
if (target.kind === "terminal") {
|
|
8
11
|
return {
|
|
@@ -25,6 +28,19 @@ function summarizeActivationTarget(target) {
|
|
|
25
28
|
status: target.status,
|
|
26
29
|
};
|
|
27
30
|
}
|
|
31
|
+
function isHolonRuntimeEnv(env = process.env) {
|
|
32
|
+
return normalizeOptionalString(env.HOLON_RUNTIME) === "1";
|
|
33
|
+
}
|
|
34
|
+
function detectHolonRuntimeContext(env = process.env) {
|
|
35
|
+
if (!isHolonRuntimeEnv(env)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const agentId = normalizeOptionalString(env.HOLON_AGENT_ID);
|
|
39
|
+
if (!agentId) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return { runtimeKind: "holon", agentId, externalTriggerUrl: normalizeOptionalString(env.HOLON_EXTERNAL_TRIGGER_URL) };
|
|
43
|
+
}
|
|
28
44
|
function resolveCurrentAgent(agents, context) {
|
|
29
45
|
if (!context) {
|
|
30
46
|
return null;
|
|
@@ -62,6 +78,9 @@ function annotateAgents(agents, context) {
|
|
|
62
78
|
};
|
|
63
79
|
}
|
|
64
80
|
function resolveAgentRecord(agents, context) {
|
|
81
|
+
if (isHolonRuntimeContext(context)) {
|
|
82
|
+
return agents.find((agent) => agent.agent.status === "active" && agent.agent.agentId === context.agentId) ?? null;
|
|
83
|
+
}
|
|
65
84
|
if (context.tmuxPaneId) {
|
|
66
85
|
const match = agents.find((agent) => terminalTargetsForCurrentMatch(agent).some((target) => target.backend === "tmux" && target.tmuxPaneId === context.tmuxPaneId));
|
|
67
86
|
if (match) {
|
|
@@ -129,6 +148,9 @@ function terminalIdentityForAgent(agent) {
|
|
|
129
148
|
return null;
|
|
130
149
|
}
|
|
131
150
|
function matchesCurrentTerminal(agent, context) {
|
|
151
|
+
if (isHolonRuntimeContext(context)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
132
154
|
return terminalTargetsForCurrentMatch(agent).some((target) => (context.tmuxPaneId != null && target.tmuxPaneId === context.tmuxPaneId)
|
|
133
155
|
|| (context.itermSessionId != null && target.itermSessionId === context.itermSessionId)
|
|
134
156
|
|| (context.tty != null && target.tty === context.tty));
|
|
@@ -137,9 +159,18 @@ function matchesCurrentRuntime(agent, context) {
|
|
|
137
159
|
if (agent.agent.status !== "active") {
|
|
138
160
|
return false;
|
|
139
161
|
}
|
|
162
|
+
if (isHolonRuntimeContext(context)) {
|
|
163
|
+
return agent.agent.agentId === context.agentId;
|
|
164
|
+
}
|
|
140
165
|
if (!context.runtimeSessionId) {
|
|
141
166
|
return false;
|
|
142
167
|
}
|
|
143
168
|
return activeTerminalTargets(agent).some((target) => target.runtimeKind === context.runtimeKind && target.runtimeSessionId === context.runtimeSessionId) || (agent.agent.runtimeKind === context.runtimeKind
|
|
144
169
|
&& agent.agent.runtimeSessionId === context.runtimeSessionId);
|
|
145
170
|
}
|
|
171
|
+
function isHolonRuntimeContext(context) {
|
|
172
|
+
return context.runtimeKind === "holon" && "agentId" in context;
|
|
173
|
+
}
|
|
174
|
+
function normalizeOptionalString(value) {
|
|
175
|
+
return value?.trim() || null;
|
|
176
|
+
}
|
package/dist/src/http.js
CHANGED
|
@@ -133,6 +133,13 @@ function buildFastifyServer(service) {
|
|
|
133
133
|
app.get("/hosts", {
|
|
134
134
|
schema: {
|
|
135
135
|
tags: ["sources"],
|
|
136
|
+
querystring: {
|
|
137
|
+
type: "object",
|
|
138
|
+
additionalProperties: false,
|
|
139
|
+
properties: {
|
|
140
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
141
|
+
},
|
|
142
|
+
},
|
|
136
143
|
response: {
|
|
137
144
|
200: {
|
|
138
145
|
type: "object",
|
|
@@ -143,7 +150,10 @@ function buildFastifyServer(service) {
|
|
|
143
150
|
},
|
|
144
151
|
},
|
|
145
152
|
},
|
|
146
|
-
}, async () =>
|
|
153
|
+
}, async (request) => {
|
|
154
|
+
const query = request.query;
|
|
155
|
+
return { hosts: service.listHosts(parseOptionalPositiveInteger(query.limit)) };
|
|
156
|
+
});
|
|
147
157
|
app.post("/hosts", {
|
|
148
158
|
schema: {
|
|
149
159
|
tags: ["sources"],
|
|
@@ -206,6 +216,13 @@ function buildFastifyServer(service) {
|
|
|
206
216
|
app.get("/streams", {
|
|
207
217
|
schema: {
|
|
208
218
|
tags: ["sources"],
|
|
219
|
+
querystring: {
|
|
220
|
+
type: "object",
|
|
221
|
+
additionalProperties: false,
|
|
222
|
+
properties: {
|
|
223
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
224
|
+
},
|
|
225
|
+
},
|
|
209
226
|
response: {
|
|
210
227
|
200: {
|
|
211
228
|
type: "object",
|
|
@@ -216,7 +233,10 @@ function buildFastifyServer(service) {
|
|
|
216
233
|
},
|
|
217
234
|
},
|
|
218
235
|
},
|
|
219
|
-
}, async () =>
|
|
236
|
+
}, async (request) => {
|
|
237
|
+
const query = request.query;
|
|
238
|
+
return { streams: service.listStreams(parseOptionalPositiveInteger(query.limit)) };
|
|
239
|
+
});
|
|
220
240
|
app.post("/streams", {
|
|
221
241
|
schema: {
|
|
222
242
|
tags: ["sources"],
|
|
@@ -280,6 +300,13 @@ function buildFastifyServer(service) {
|
|
|
280
300
|
app.get("/sources", {
|
|
281
301
|
schema: {
|
|
282
302
|
tags: ["sources"],
|
|
303
|
+
querystring: {
|
|
304
|
+
type: "object",
|
|
305
|
+
additionalProperties: false,
|
|
306
|
+
properties: {
|
|
307
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
308
|
+
},
|
|
309
|
+
},
|
|
283
310
|
response: {
|
|
284
311
|
200: {
|
|
285
312
|
type: "object",
|
|
@@ -290,7 +317,10 @@ function buildFastifyServer(service) {
|
|
|
290
317
|
},
|
|
291
318
|
},
|
|
292
319
|
},
|
|
293
|
-
}, async () =>
|
|
320
|
+
}, async (request) => {
|
|
321
|
+
const query = request.query;
|
|
322
|
+
return { sources: await service.listSourceViews(parseOptionalPositiveInteger(query.limit)) };
|
|
323
|
+
});
|
|
294
324
|
app.post("/sources", {
|
|
295
325
|
schema: {
|
|
296
326
|
tags: ["sources"],
|
|
@@ -351,6 +381,60 @@ function buildFastifyServer(service) {
|
|
|
351
381
|
const params = request.params;
|
|
352
382
|
return service.getResolvedSourceSchema(decodeURIComponent(params.sourceId));
|
|
353
383
|
});
|
|
384
|
+
app.get("/sources/:sourceId/actions", {
|
|
385
|
+
schema: {
|
|
386
|
+
tags: ["sources"],
|
|
387
|
+
params: {
|
|
388
|
+
type: "object",
|
|
389
|
+
required: ["sourceId"],
|
|
390
|
+
properties: {
|
|
391
|
+
sourceId: { type: "string", minLength: 1 },
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
response: {
|
|
395
|
+
200: jsonObjectSchema,
|
|
396
|
+
400: errorResponseSchema,
|
|
397
|
+
404: errorResponseSchema,
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
}, async (request) => {
|
|
401
|
+
const params = request.params;
|
|
402
|
+
return service.listSourceOperations(decodeURIComponent(params.sourceId));
|
|
403
|
+
});
|
|
404
|
+
app.post("/sources/:sourceId/invoke", {
|
|
405
|
+
schema: {
|
|
406
|
+
tags: ["sources"],
|
|
407
|
+
params: {
|
|
408
|
+
type: "object",
|
|
409
|
+
required: ["sourceId"],
|
|
410
|
+
properties: {
|
|
411
|
+
sourceId: { type: "string", minLength: 1 },
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
body: {
|
|
415
|
+
type: "object",
|
|
416
|
+
additionalProperties: false,
|
|
417
|
+
required: ["operation", "input"],
|
|
418
|
+
properties: {
|
|
419
|
+
operation: { type: "string", minLength: 1 },
|
|
420
|
+
input: jsonObjectSchema,
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
response: {
|
|
424
|
+
200: jsonObjectSchema,
|
|
425
|
+
400: errorResponseSchema,
|
|
426
|
+
404: errorResponseSchema,
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
}, async (request) => {
|
|
430
|
+
const params = request.params;
|
|
431
|
+
const body = request.body;
|
|
432
|
+
return service.invokeSourceOperation({
|
|
433
|
+
sourceId: decodeURIComponent(params.sourceId),
|
|
434
|
+
operation: body.operation,
|
|
435
|
+
input: body.input,
|
|
436
|
+
});
|
|
437
|
+
});
|
|
354
438
|
app.patch("/streams/:streamId", {
|
|
355
439
|
schema: {
|
|
356
440
|
tags: ["sources"],
|
|
@@ -548,6 +632,7 @@ function buildFastifyServer(service) {
|
|
|
548
632
|
occurredAt: { type: "string", minLength: 1 },
|
|
549
633
|
metadata: jsonObjectSchema,
|
|
550
634
|
rawPayload: jsonObjectSchema,
|
|
635
|
+
providerRawPayload: jsonObjectSchema,
|
|
551
636
|
},
|
|
552
637
|
},
|
|
553
638
|
response: {
|
|
@@ -564,6 +649,7 @@ function buildFastifyServer(service) {
|
|
|
564
649
|
occurredAt: body.occurredAt,
|
|
565
650
|
metadata: body.metadata ?? {},
|
|
566
651
|
rawPayload: body.rawPayload ?? {},
|
|
652
|
+
providerRawPayload: body.providerRawPayload,
|
|
567
653
|
});
|
|
568
654
|
});
|
|
569
655
|
app.delete("/sources/:sourceId", {
|
|
@@ -702,6 +788,7 @@ function buildFastifyServer(service) {
|
|
|
702
788
|
occurredAt: { type: "string", minLength: 1 },
|
|
703
789
|
metadata: jsonObjectSchema,
|
|
704
790
|
rawPayload: jsonObjectSchema,
|
|
791
|
+
providerRawPayload: jsonObjectSchema,
|
|
705
792
|
deliveryHandle: deliveryHandleSchema,
|
|
706
793
|
},
|
|
707
794
|
},
|
|
@@ -719,6 +806,7 @@ function buildFastifyServer(service) {
|
|
|
719
806
|
occurredAt: optionalString(body.occurredAt),
|
|
720
807
|
metadata: body.metadata ?? {},
|
|
721
808
|
rawPayload: body.rawPayload ?? {},
|
|
809
|
+
providerRawPayload: body.providerRawPayload,
|
|
722
810
|
deliveryHandle: body.deliveryHandle ?? null,
|
|
723
811
|
});
|
|
724
812
|
});
|
|
@@ -730,6 +818,7 @@ function buildFastifyServer(service) {
|
|
|
730
818
|
additionalProperties: false,
|
|
731
819
|
properties: {
|
|
732
820
|
include_targets: { type: "string", enum: ["true", "false"] },
|
|
821
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
733
822
|
},
|
|
734
823
|
},
|
|
735
824
|
response: {
|
|
@@ -744,17 +833,10 @@ function buildFastifyServer(service) {
|
|
|
744
833
|
},
|
|
745
834
|
}, async (request) => {
|
|
746
835
|
const query = request.query;
|
|
747
|
-
const agents = service.listAgents();
|
|
836
|
+
const agents = service.listAgents(parseOptionalPositiveInteger(query.limit));
|
|
748
837
|
if (query.include_targets === "true") {
|
|
749
|
-
const activationTargetsByAgentId =
|
|
750
|
-
|
|
751
|
-
const summarized = (0, current_agent_1.summarizeActivationTarget)(target);
|
|
752
|
-
if (targets) {
|
|
753
|
-
targets.push(summarized);
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
grouped.set(target.agentId, [summarized]);
|
|
757
|
-
}
|
|
838
|
+
const activationTargetsByAgentId = agents.reduce((grouped, agent) => {
|
|
839
|
+
grouped.set(agent.agentId, service.listActivationTargets(agent.agentId).map((target) => (0, current_agent_1.summarizeActivationTarget)(target)));
|
|
758
840
|
return grouped;
|
|
759
841
|
}, new Map());
|
|
760
842
|
return {
|
|
@@ -920,6 +1002,13 @@ function buildFastifyServer(service) {
|
|
|
920
1002
|
agentId: { type: "string", minLength: 1 },
|
|
921
1003
|
},
|
|
922
1004
|
},
|
|
1005
|
+
querystring: {
|
|
1006
|
+
type: "object",
|
|
1007
|
+
additionalProperties: false,
|
|
1008
|
+
properties: {
|
|
1009
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
1010
|
+
},
|
|
1011
|
+
},
|
|
923
1012
|
response: {
|
|
924
1013
|
200: {
|
|
925
1014
|
type: "object",
|
|
@@ -932,7 +1021,8 @@ function buildFastifyServer(service) {
|
|
|
932
1021
|
},
|
|
933
1022
|
}, async (request) => {
|
|
934
1023
|
const params = request.params;
|
|
935
|
-
|
|
1024
|
+
const query = request.query;
|
|
1025
|
+
return { targets: service.listActivationTargets(decodeURIComponent(params.agentId), parseOptionalPositiveInteger(query.limit)) };
|
|
936
1026
|
});
|
|
937
1027
|
app.post("/agents/:agentId/targets", {
|
|
938
1028
|
schema: {
|
|
@@ -1017,6 +1107,7 @@ function buildFastifyServer(service) {
|
|
|
1017
1107
|
additionalProperties: false,
|
|
1018
1108
|
properties: {
|
|
1019
1109
|
agent_id: { type: "string" },
|
|
1110
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
1020
1111
|
},
|
|
1021
1112
|
},
|
|
1022
1113
|
response: {
|
|
@@ -1031,7 +1122,7 @@ function buildFastifyServer(service) {
|
|
|
1031
1122
|
},
|
|
1032
1123
|
}, async (request) => {
|
|
1033
1124
|
const query = request.query;
|
|
1034
|
-
return { timers: service.listTimers(query.agent_id) };
|
|
1125
|
+
return { timers: service.listTimers(query.agent_id, parseOptionalPositiveInteger(query.limit)) };
|
|
1035
1126
|
});
|
|
1036
1127
|
app.post("/timers", {
|
|
1037
1128
|
schema: {
|
|
@@ -1135,6 +1226,7 @@ function buildFastifyServer(service) {
|
|
|
1135
1226
|
properties: {
|
|
1136
1227
|
source_id: { type: "string" },
|
|
1137
1228
|
agent_id: { type: "string" },
|
|
1229
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
1138
1230
|
},
|
|
1139
1231
|
},
|
|
1140
1232
|
response: {
|
|
@@ -1147,6 +1239,7 @@ function buildFastifyServer(service) {
|
|
|
1147
1239
|
subscriptions: service.listSubscriptions({
|
|
1148
1240
|
sourceId: query.source_id,
|
|
1149
1241
|
agentId: query.agent_id,
|
|
1242
|
+
limit: parseOptionalPositiveInteger(query.limit),
|
|
1150
1243
|
}),
|
|
1151
1244
|
};
|
|
1152
1245
|
});
|
|
@@ -1348,6 +1441,7 @@ function buildFastifyServer(service) {
|
|
|
1348
1441
|
properties: {
|
|
1349
1442
|
after_entry_id: { type: "string" },
|
|
1350
1443
|
include_acked: { type: "string", enum: ["true", "false"] },
|
|
1444
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
1351
1445
|
},
|
|
1352
1446
|
},
|
|
1353
1447
|
response: {
|
|
@@ -1367,6 +1461,7 @@ function buildFastifyServer(service) {
|
|
|
1367
1461
|
entries: service.listInboxItems(decodeURIComponent(params.agentId), {
|
|
1368
1462
|
afterEntryId: query.after_entry_id,
|
|
1369
1463
|
includeAcked: query.include_acked ? query.include_acked === "true" : undefined,
|
|
1464
|
+
limit: parseOptionalPositiveInteger(query.limit),
|
|
1370
1465
|
}),
|
|
1371
1466
|
};
|
|
1372
1467
|
});
|
|
@@ -1738,6 +1833,19 @@ function optionalString(value) {
|
|
|
1738
1833
|
const trimmed = value.trim();
|
|
1739
1834
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
1740
1835
|
}
|
|
1836
|
+
function parseOptionalPositiveInteger(value) {
|
|
1837
|
+
if (value === undefined) {
|
|
1838
|
+
return undefined;
|
|
1839
|
+
}
|
|
1840
|
+
if (!/^[1-9]\d*$/.test(value)) {
|
|
1841
|
+
throw new Error("expected positive integer");
|
|
1842
|
+
}
|
|
1843
|
+
const parsed = Number.parseInt(value, 10);
|
|
1844
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
1845
|
+
throw new Error("expected positive integer within safe range");
|
|
1846
|
+
}
|
|
1847
|
+
return parsed;
|
|
1848
|
+
}
|
|
1741
1849
|
function normalizeValidationMessage(message) {
|
|
1742
1850
|
if (message.includes("must be boolean")) {
|
|
1743
1851
|
return "expected boolean";
|
|
@@ -1762,10 +1870,13 @@ function isBadRequestError(message) {
|
|
|
1762
1870
|
message.startsWith("deliver send is not supported") ||
|
|
1763
1871
|
message.startsWith("deliveryHandle requires") ||
|
|
1764
1872
|
message.startsWith("delivery operations are not supported") ||
|
|
1873
|
+
message.startsWith("source operations are not supported") ||
|
|
1765
1874
|
message.startsWith("unknown GitHub delivery operation") ||
|
|
1766
1875
|
message.startsWith("unknown Feishu delivery operation") ||
|
|
1876
|
+
message.startsWith("unknown Feishu source operation") ||
|
|
1767
1877
|
message.startsWith("invalid GitHub targetRef") ||
|
|
1768
|
-
message.
|
|
1878
|
+
message.startsWith("get_message_context requires") ||
|
|
1879
|
+
message.includes("requires input.") ||
|
|
1769
1880
|
message.includes("requires input.body") ||
|
|
1770
1881
|
message.startsWith("subscriptions/reset requires") ||
|
|
1771
1882
|
message.startsWith("agents requires") ||
|
package/dist/src/service.js
CHANGED
|
@@ -144,14 +144,14 @@ class AgentInboxService {
|
|
|
144
144
|
await this.adapters.sourceAdapterFor(source.sourceType).ensureSource(source);
|
|
145
145
|
return source;
|
|
146
146
|
}
|
|
147
|
-
listSources() {
|
|
148
|
-
return this.store.listSources();
|
|
147
|
+
listSources(limit) {
|
|
148
|
+
return this.store.listSources(limit);
|
|
149
149
|
}
|
|
150
|
-
async listSourceViews() {
|
|
151
|
-
return this.attachSourceRuntimes(this.store.listSources());
|
|
150
|
+
async listSourceViews(limit) {
|
|
151
|
+
return this.attachSourceRuntimes(this.store.listSources(limit));
|
|
152
152
|
}
|
|
153
|
-
listHosts() {
|
|
154
|
-
return this.store.listSourceHosts();
|
|
153
|
+
listHosts(limit) {
|
|
154
|
+
return this.store.listSourceHosts(limit);
|
|
155
155
|
}
|
|
156
156
|
getHost(hostId) {
|
|
157
157
|
const host = this.store.getSourceHost(hostId);
|
|
@@ -269,8 +269,8 @@ class AgentInboxService {
|
|
|
269
269
|
return this.getStream(stream.sourceId);
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
|
-
listStreams() {
|
|
273
|
-
return this.listSources();
|
|
272
|
+
listStreams(limit) {
|
|
273
|
+
return this.listSources(limit);
|
|
274
274
|
}
|
|
275
275
|
getStream(streamId) {
|
|
276
276
|
return this.getSource(streamId);
|
|
@@ -282,6 +282,22 @@ class AgentInboxService {
|
|
|
282
282
|
const source = this.getSource(sourceId);
|
|
283
283
|
return this.adapters.resolveSourceSchema(source);
|
|
284
284
|
}
|
|
285
|
+
async listSourceOperations(sourceId) {
|
|
286
|
+
const source = this.getSource(sourceId);
|
|
287
|
+
return {
|
|
288
|
+
sourceId: source.sourceId,
|
|
289
|
+
operations: await this.adapters.listSourceOperations(source),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async invokeSourceOperation(request) {
|
|
293
|
+
const source = this.getSource(request.sourceId);
|
|
294
|
+
const data = await this.adapters.invokeSourceOperation(source, request.operation, request.input);
|
|
295
|
+
return {
|
|
296
|
+
sourceId: source.sourceId,
|
|
297
|
+
operation: request.operation,
|
|
298
|
+
data,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
285
301
|
async previewSourceSchema(input) {
|
|
286
302
|
try {
|
|
287
303
|
const source = buildPreviewSource(input);
|
|
@@ -590,8 +606,8 @@ class AgentInboxService {
|
|
|
590
606
|
notifyLeaseMs: notifyLeaseMs ?? null,
|
|
591
607
|
});
|
|
592
608
|
}
|
|
593
|
-
listAgents() {
|
|
594
|
-
return this.store.listAgents();
|
|
609
|
+
listAgents(limit) {
|
|
610
|
+
return this.store.listAgents(limit);
|
|
595
611
|
}
|
|
596
612
|
getAgent(agentId) {
|
|
597
613
|
const agent = this.store.getAgent(agentId);
|
|
@@ -666,12 +682,12 @@ class AgentInboxService {
|
|
|
666
682
|
this.rescheduleTimerSync();
|
|
667
683
|
return timer;
|
|
668
684
|
}
|
|
669
|
-
listTimers(agentId) {
|
|
685
|
+
listTimers(agentId, limit) {
|
|
670
686
|
if (agentId) {
|
|
671
687
|
this.getAgent(agentId);
|
|
672
|
-
return this.store.listTimersForAgent(agentId);
|
|
688
|
+
return this.store.listTimersForAgent(agentId, limit);
|
|
673
689
|
}
|
|
674
|
-
return this.store.listTimers();
|
|
690
|
+
return this.store.listTimers(limit);
|
|
675
691
|
}
|
|
676
692
|
getTimer(scheduleId) {
|
|
677
693
|
const timer = this.store.getTimer(scheduleId);
|
|
@@ -758,12 +774,12 @@ class AgentInboxService {
|
|
|
758
774
|
this.markAgentActive(agentId);
|
|
759
775
|
return target;
|
|
760
776
|
}
|
|
761
|
-
listActivationTargets(agentId) {
|
|
777
|
+
listActivationTargets(agentId, limit) {
|
|
762
778
|
if (agentId) {
|
|
763
779
|
this.getAgent(agentId);
|
|
764
|
-
return this.store.listActivationTargetsForAgent(agentId);
|
|
780
|
+
return this.store.listActivationTargetsForAgent(agentId, limit);
|
|
765
781
|
}
|
|
766
|
-
return this.store.listActivationTargets();
|
|
782
|
+
return this.store.listActivationTargets(limit);
|
|
767
783
|
}
|
|
768
784
|
getActivationTarget(targetId) {
|
|
769
785
|
const target = this.store.getActivationTarget(targetId);
|
|
@@ -1024,15 +1040,7 @@ class AgentInboxService {
|
|
|
1024
1040
|
return { removed: true, subscriptionId };
|
|
1025
1041
|
}
|
|
1026
1042
|
listSubscriptions(filters) {
|
|
1027
|
-
return this.store.
|
|
1028
|
-
if (filters?.sourceId && subscription.sourceId !== filters.sourceId) {
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1031
|
-
if (filters?.agentId && subscription.agentId !== filters.agentId) {
|
|
1032
|
-
return false;
|
|
1033
|
-
}
|
|
1034
|
-
return true;
|
|
1035
|
-
});
|
|
1043
|
+
return this.store.listSubscriptionsFiltered(filters);
|
|
1036
1044
|
}
|
|
1037
1045
|
getSubscription(subscriptionId) {
|
|
1038
1046
|
const subscription = this.store.getSubscription(subscriptionId);
|
|
@@ -1098,8 +1106,8 @@ class AgentInboxService {
|
|
|
1098
1106
|
}
|
|
1099
1107
|
return this.appendSourceEvent({ ...input, sourceId });
|
|
1100
1108
|
}
|
|
1101
|
-
listInboxAgentIds() {
|
|
1102
|
-
return this.store.listInboxes().map((inbox) => inbox.ownerAgentId);
|
|
1109
|
+
listInboxAgentIds(limit) {
|
|
1110
|
+
return this.store.listInboxes(limit).map((inbox) => inbox.ownerAgentId);
|
|
1103
1111
|
}
|
|
1104
1112
|
getInboxDetailsByAgent(agentId) {
|
|
1105
1113
|
const inbox = this.ensureInboxForAgent(agentId);
|
|
@@ -1193,6 +1201,7 @@ class AgentInboxService {
|
|
|
1193
1201
|
occurredAt,
|
|
1194
1202
|
metadata: {},
|
|
1195
1203
|
rawPayload: input.rawPayload,
|
|
1204
|
+
providerRawPayload: undefined,
|
|
1196
1205
|
deliveryHandle: null,
|
|
1197
1206
|
ackedAt: null,
|
|
1198
1207
|
};
|
|
@@ -1516,6 +1525,7 @@ class AgentInboxService {
|
|
|
1516
1525
|
subscriptionId: subscription.subscriptionId,
|
|
1517
1526
|
},
|
|
1518
1527
|
rawPayload: event.rawPayload,
|
|
1528
|
+
providerRawPayload: event.providerRawPayload,
|
|
1519
1529
|
deliveryHandle: event.deliveryHandle,
|
|
1520
1530
|
ackedAt: null,
|
|
1521
1531
|
};
|
|
@@ -3406,6 +3416,7 @@ function activationItemFromInboxItem(item) {
|
|
|
3406
3416
|
occurredAt: item.occurredAt,
|
|
3407
3417
|
metadata: item.metadata,
|
|
3408
3418
|
rawPayload: item.rawPayload,
|
|
3419
|
+
providerRawPayload: item.providerRawPayload,
|
|
3409
3420
|
deliveryHandle: item.deliveryHandle,
|
|
3410
3421
|
};
|
|
3411
3422
|
}
|
|
@@ -3882,9 +3893,7 @@ function getHostConfigFields(hostType) {
|
|
|
3882
3893
|
];
|
|
3883
3894
|
case "feishu":
|
|
3884
3895
|
return [
|
|
3885
|
-
{ name: "
|
|
3886
|
-
{ name: "appSecret", type: "string", description: "Feishu app secret.", required: true },
|
|
3887
|
-
{ name: "uxcAuth", type: "string", description: "Optional shared Feishu auth/runtime profile.", required: false },
|
|
3896
|
+
{ name: "uxcAuth", type: "string", description: "Optional shared Feishu/Lark UXC auth profile.", required: false },
|
|
3888
3897
|
];
|
|
3889
3898
|
case "local_event":
|
|
3890
3899
|
return [];
|
package/dist/src/source_hosts.js
CHANGED
|
@@ -32,13 +32,11 @@ function resolveSourceRegistration(input) {
|
|
|
32
32
|
if (input.sourceType === "feishu_bot") {
|
|
33
33
|
return {
|
|
34
34
|
hostType: "feishu",
|
|
35
|
-
hostKey: `
|
|
35
|
+
hostKey: `uxcAuth:${stringOrDefault(config.uxcAuth, input.configRef ?? input.sourceKey)}`,
|
|
36
36
|
hostConfig: {
|
|
37
|
-
...(valueOrUndefined(config.
|
|
38
|
-
...(valueOrUndefined(config.appSecret) ? { appSecret: config.appSecret } : {}),
|
|
37
|
+
...(valueOrUndefined(config.uxcAuth) ? { uxcAuth: config.uxcAuth } : {}),
|
|
39
38
|
...(valueOrUndefined(config.schemaUrl) ? { schemaUrl: config.schemaUrl } : {}),
|
|
40
39
|
...(valueOrUndefined(config.replyInThread) ? { replyInThread: config.replyInThread } : {}),
|
|
41
|
-
...(valueOrUndefined(config.uxcAuth) ? { uxcAuth: config.uxcAuth } : {}),
|
|
42
40
|
},
|
|
43
41
|
streamKind: "message_events",
|
|
44
42
|
streamKey: input.sourceKey,
|
|
@@ -146,13 +146,11 @@ const SOURCE_SCHEMAS = {
|
|
|
146
146
|
],
|
|
147
147
|
eventVariantExamples: ["im.message.receive_v1.text"],
|
|
148
148
|
configFields: [
|
|
149
|
-
{ name: "
|
|
150
|
-
{ name: "appSecret", type: "string", required: true, description: "Feishu app secret." },
|
|
149
|
+
{ name: "uxcAuth", type: "string", required: false, description: "Optional UXC auth profile for the Feishu/Lark app." },
|
|
151
150
|
{ name: "eventTypes", type: "string[]", required: false, description: "Optional Feishu event type allowlist." },
|
|
152
151
|
{ name: "chatIds", type: "string[]", required: false, description: "Optional Feishu chat allowlist." },
|
|
153
152
|
{ name: "schemaUrl", type: "string", required: false, description: "Optional Feishu OpenAPI schema URL." },
|
|
154
153
|
{ name: "replyInThread", type: "boolean", required: false, description: "Reply in thread when sending outbound messages." },
|
|
155
|
-
{ name: "uxcAuth", type: "string", required: false, description: "Optional uxc auth profile." },
|
|
156
154
|
],
|
|
157
155
|
},
|
|
158
156
|
};
|