@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
|
@@ -46,7 +46,7 @@ class GithubUxcClient {
|
|
|
46
46
|
issue_number: input.issueNumber,
|
|
47
47
|
body: input.body,
|
|
48
48
|
},
|
|
49
|
-
options:
|
|
49
|
+
options: githubAuthOptions(input.auth),
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
async replyToReviewComment(input) {
|
|
@@ -60,7 +60,7 @@ class GithubUxcClient {
|
|
|
60
60
|
comment_id: input.commentId,
|
|
61
61
|
body: input.body,
|
|
62
62
|
},
|
|
63
|
-
options:
|
|
63
|
+
options: githubAuthOptions(input.auth),
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
async updateIssueState(input) {
|
|
@@ -73,7 +73,7 @@ class GithubUxcClient {
|
|
|
73
73
|
issue_number: input.issueNumber,
|
|
74
74
|
state: input.state,
|
|
75
75
|
},
|
|
76
|
-
options:
|
|
76
|
+
options: githubAuthOptions(input.auth),
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
async mergePullRequest(input) {
|
|
@@ -88,7 +88,7 @@ class GithubUxcClient {
|
|
|
88
88
|
commit_title: input.commitTitle ?? null,
|
|
89
89
|
commit_message: input.commitMessage ?? null,
|
|
90
90
|
},
|
|
91
|
-
options:
|
|
91
|
+
options: githubAuthOptions(input.auth),
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
async getPullRequestDetails(input) {
|
|
@@ -100,7 +100,7 @@ class GithubUxcClient {
|
|
|
100
100
|
repo: input.repo,
|
|
101
101
|
pull_number: input.pullNumber,
|
|
102
102
|
},
|
|
103
|
-
options:
|
|
103
|
+
options: githubReadOptions(input.auth),
|
|
104
104
|
});
|
|
105
105
|
const data = asRecord(response.data);
|
|
106
106
|
const head = asRecord(data.head);
|
|
@@ -333,7 +333,7 @@ async function hydrateGithubRepoEventIfNeeded(config, raw, client = DEFAULT_GITH
|
|
|
333
333
|
per_page: perPage,
|
|
334
334
|
page,
|
|
335
335
|
},
|
|
336
|
-
options:
|
|
336
|
+
options: githubReadOptions(config.uxcAuth),
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
catch {
|
|
@@ -705,6 +705,15 @@ function computeGithubHydrationPerPage(perPage) {
|
|
|
705
705
|
: GITHUB_EVENT_HYDRATION_MIN_PER_PAGE;
|
|
706
706
|
return Math.min(GITHUB_EVENT_HYDRATION_MAX_PER_PAGE, Math.max(GITHUB_EVENT_HYDRATION_MIN_PER_PAGE, configured));
|
|
707
707
|
}
|
|
708
|
+
function githubAuthOptions(auth) {
|
|
709
|
+
return { auth };
|
|
710
|
+
}
|
|
711
|
+
function githubReadOptions(auth) {
|
|
712
|
+
return {
|
|
713
|
+
auth,
|
|
714
|
+
artifact_compaction: false,
|
|
715
|
+
};
|
|
716
|
+
}
|
|
708
717
|
function extractGithubRepoEventUrl(event, issue, pullRequest, review, comment) {
|
|
709
718
|
return (asString(comment.html_url)
|
|
710
719
|
?? asString(review.html_url)
|
|
@@ -302,6 +302,30 @@ class RemoteSourceRuntime {
|
|
|
302
302
|
}
|
|
303
303
|
return module.summarizeDigestThread(items, moduleInputSource(source), grouping);
|
|
304
304
|
}
|
|
305
|
+
async listSourceOperations(source) {
|
|
306
|
+
if (!REMOTE_SOURCE_TYPES.has(source.sourceType)) {
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
309
|
+
const module = await this.moduleRegistry.resolve(source, this.homeDir);
|
|
310
|
+
if (typeof module.listSourceOperations !== "function") {
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
return module.listSourceOperations({ source: moduleInputSource(source) });
|
|
314
|
+
}
|
|
315
|
+
async invokeSourceOperation(source, operation, input) {
|
|
316
|
+
if (!REMOTE_SOURCE_TYPES.has(source.sourceType)) {
|
|
317
|
+
throw new Error(`source operations are not supported for source type ${source.sourceType}`);
|
|
318
|
+
}
|
|
319
|
+
const module = await this.moduleRegistry.resolve(source, this.homeDir);
|
|
320
|
+
if (typeof module.invokeSourceOperation !== "function") {
|
|
321
|
+
throw new Error(`source operations are not supported for source type ${source.sourceType}`);
|
|
322
|
+
}
|
|
323
|
+
return module.invokeSourceOperation({
|
|
324
|
+
source: moduleInputSource(source),
|
|
325
|
+
operation,
|
|
326
|
+
input,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
305
329
|
async syncAll() {
|
|
306
330
|
const sources = this.store
|
|
307
331
|
.listSources()
|
|
@@ -391,6 +415,7 @@ class RemoteSourceRuntime {
|
|
|
391
415
|
occurredAt: mapped.occurredAt,
|
|
392
416
|
metadata: mapped.metadata,
|
|
393
417
|
rawPayload: mapped.rawPayload,
|
|
418
|
+
providerRawPayload: mapped.providerRawPayload,
|
|
394
419
|
deliveryHandle: mapped.deliveryHandle ?? null,
|
|
395
420
|
});
|
|
396
421
|
appended += result.appended;
|
|
@@ -111,6 +111,8 @@ function validateModuleContract(module, sourcePath) {
|
|
|
111
111
|
validateOptionalHook(module.deriveNotificationGrouping, "deriveNotificationGrouping", sourcePath);
|
|
112
112
|
validateOptionalHook(module.listDeliveryOperations, "listDeliveryOperations", sourcePath);
|
|
113
113
|
validateOptionalHook(module.invokeDeliveryOperation, "invokeDeliveryOperation", sourcePath);
|
|
114
|
+
validateOptionalHook(module.listSourceOperations, "listSourceOperations", sourcePath);
|
|
115
|
+
validateOptionalHook(module.invokeSourceOperation, "invokeSourceOperation", sourcePath);
|
|
114
116
|
validateOptionalHook(module.summarizeDigestThread, "summarizeDigestThread", sourcePath);
|
|
115
117
|
}
|
|
116
118
|
function validateOptionalHook(value, name, sourcePath) {
|
|
@@ -297,7 +299,10 @@ function createGithubRepoRemoteModule(options) {
|
|
|
297
299
|
seen_window: 1024,
|
|
298
300
|
},
|
|
299
301
|
},
|
|
300
|
-
options: {
|
|
302
|
+
options: {
|
|
303
|
+
auth: config.uxcAuth,
|
|
304
|
+
artifact_compaction: false,
|
|
305
|
+
},
|
|
301
306
|
};
|
|
302
307
|
},
|
|
303
308
|
async mapRawEvent(rawPayload, source) {
|
|
@@ -312,6 +317,7 @@ function createGithubRepoRemoteModule(options) {
|
|
|
312
317
|
eventVariant: normalized.eventVariant,
|
|
313
318
|
metadata: normalized.metadata ?? {},
|
|
314
319
|
rawPayload: normalized.rawPayload ?? hydratedPayload,
|
|
320
|
+
providerRawPayload: hydratedPayload,
|
|
315
321
|
occurredAt: normalized.occurredAt,
|
|
316
322
|
deliveryHandle: normalized.deliveryHandle,
|
|
317
323
|
};
|
|
@@ -434,7 +440,10 @@ const GITHUB_REPO_CI_MODULE = {
|
|
|
434
440
|
seen_window: 1024,
|
|
435
441
|
},
|
|
436
442
|
},
|
|
437
|
-
options: {
|
|
443
|
+
options: {
|
|
444
|
+
auth: config.uxcAuth,
|
|
445
|
+
artifact_compaction: false,
|
|
446
|
+
},
|
|
438
447
|
};
|
|
439
448
|
},
|
|
440
449
|
mapRawEvent(rawPayload, source) {
|
|
@@ -448,6 +457,7 @@ const GITHUB_REPO_CI_MODULE = {
|
|
|
448
457
|
eventVariant: normalized.eventVariant,
|
|
449
458
|
metadata: normalized.metadata ?? {},
|
|
450
459
|
rawPayload: normalized.rawPayload ?? rawPayload,
|
|
460
|
+
providerRawPayload: rawPayload,
|
|
451
461
|
occurredAt: normalized.occurredAt,
|
|
452
462
|
deliveryHandle: normalized.deliveryHandle,
|
|
453
463
|
};
|
|
@@ -461,18 +471,22 @@ const FEISHU_BOT_MODULE = {
|
|
|
461
471
|
async invokeDeliveryOperation(input) {
|
|
462
472
|
return (0, feishu_1.invokeFeishuDeliveryOperation)(input.handle, input.operation, input.input);
|
|
463
473
|
},
|
|
474
|
+
listSourceOperations() {
|
|
475
|
+
return (0, feishu_1.feishuSourceOperations)();
|
|
476
|
+
},
|
|
477
|
+
async invokeSourceOperation(input) {
|
|
478
|
+
return (0, feishu_1.invokeFeishuSourceOperation)(input.source, input.operation, input.input);
|
|
479
|
+
},
|
|
464
480
|
describeCapabilities() {
|
|
465
481
|
return {
|
|
466
482
|
sourceKind: "feishu_bot",
|
|
467
483
|
aliases: ["feishu_bot"],
|
|
468
484
|
configSchema: [
|
|
469
|
-
{ name: "
|
|
470
|
-
{ name: "appSecret", type: "string", required: true, description: "Feishu app secret." },
|
|
485
|
+
{ name: "uxcAuth", type: "string", required: false, description: "Optional UXC auth profile for the Feishu/Lark app." },
|
|
471
486
|
{ name: "eventTypes", type: "string[]", required: false, description: "Optional Feishu event type allowlist." },
|
|
472
487
|
{ name: "chatIds", type: "string[]", required: false, description: "Optional Feishu chat allowlist." },
|
|
473
488
|
{ name: "schemaUrl", type: "string", required: false, description: "Optional Feishu OpenAPI schema URL." },
|
|
474
489
|
{ name: "replyInThread", type: "boolean", required: false, description: "Reply in thread when sending outbound messages." },
|
|
475
|
-
{ name: "uxcAuth", type: "string", required: false, description: "Optional uxc auth profile." },
|
|
476
490
|
],
|
|
477
491
|
metadataFields: [
|
|
478
492
|
{ name: "eventType", type: "string", description: "Feishu event type." },
|
|
@@ -494,13 +508,22 @@ const FEISHU_BOT_MODULE = {
|
|
|
494
508
|
validateConfig(source) {
|
|
495
509
|
(0, feishu_1.parseFeishuSourceConfig)(source);
|
|
496
510
|
},
|
|
511
|
+
listFollowTemplates() {
|
|
512
|
+
return (0, feishu_1.feishuFollowTemplateSpec)();
|
|
513
|
+
},
|
|
514
|
+
async expandFollowTemplate(input) {
|
|
515
|
+
return (0, feishu_1.expandFeishuFollowTemplate)(input);
|
|
516
|
+
},
|
|
497
517
|
buildManagedSourceSpec(source) {
|
|
498
518
|
const config = (0, feishu_1.parseFeishuSourceConfig)(source);
|
|
499
519
|
return {
|
|
500
520
|
endpoint: config.endpoint ?? feishu_1.FEISHU_OPENAPI_ENDPOINT,
|
|
501
521
|
mode: "stream",
|
|
502
522
|
transport_hint: "feishu_long_connection",
|
|
503
|
-
options: {
|
|
523
|
+
options: {
|
|
524
|
+
auth: config.uxcAuth,
|
|
525
|
+
artifact_compaction: false,
|
|
526
|
+
},
|
|
504
527
|
};
|
|
505
528
|
},
|
|
506
529
|
mapRawEvent(rawPayload, source) {
|
|
@@ -514,6 +537,7 @@ const FEISHU_BOT_MODULE = {
|
|
|
514
537
|
eventVariant: normalized.eventVariant,
|
|
515
538
|
metadata: normalized.metadata ?? {},
|
|
516
539
|
rawPayload: normalized.rawPayload ?? rawPayload,
|
|
540
|
+
providerRawPayload: rawPayload,
|
|
517
541
|
occurredAt: normalized.occurredAt,
|
|
518
542
|
deliveryHandle: normalized.deliveryHandle,
|
|
519
543
|
};
|
package/dist/src/store.js
CHANGED
|
@@ -288,8 +288,10 @@ class AgentInboxStore {
|
|
|
288
288
|
]);
|
|
289
289
|
this.persist();
|
|
290
290
|
}
|
|
291
|
-
listSourceHosts() {
|
|
292
|
-
const rows =
|
|
291
|
+
listSourceHosts(limit) {
|
|
292
|
+
const rows = typeof limit === "number"
|
|
293
|
+
? this.getAll("select * from source_hosts order by created_at asc, host_id asc limit ?", [limit])
|
|
294
|
+
: this.getAll("select * from source_hosts order by created_at asc, host_id asc");
|
|
293
295
|
return rows.map((row) => this.mapSourceHost(row));
|
|
294
296
|
}
|
|
295
297
|
updateSourceHostDefinition(hostId, input) {
|
|
@@ -362,8 +364,10 @@ class AgentInboxStore {
|
|
|
362
364
|
});
|
|
363
365
|
this.persist();
|
|
364
366
|
}
|
|
365
|
-
listSources() {
|
|
366
|
-
const rows =
|
|
367
|
+
listSources(limit) {
|
|
368
|
+
const rows = typeof limit === "number"
|
|
369
|
+
? this.getAll("select * from sources order by created_at asc, source_id asc limit ?", [limit])
|
|
370
|
+
: this.getAll("select * from sources order by created_at asc, source_id asc");
|
|
367
371
|
return rows.map((row) => this.mapSource(row));
|
|
368
372
|
}
|
|
369
373
|
getSourceIdleState(sourceId) {
|
|
@@ -505,8 +509,10 @@ class AgentInboxStore {
|
|
|
505
509
|
this.persist();
|
|
506
510
|
return this.getAgent(agentId);
|
|
507
511
|
}
|
|
508
|
-
listAgents() {
|
|
509
|
-
const rows =
|
|
512
|
+
listAgents(limit) {
|
|
513
|
+
const rows = typeof limit === "number"
|
|
514
|
+
? this.getAll("select * from agents order by created_at asc, agent_id asc limit ?", [limit])
|
|
515
|
+
: this.getAll("select * from agents order by created_at asc, agent_id asc");
|
|
510
516
|
return rows.map((row) => this.mapAgent(row));
|
|
511
517
|
}
|
|
512
518
|
getInbox(inboxId) {
|
|
@@ -556,8 +562,10 @@ class AgentInboxStore {
|
|
|
556
562
|
this.persist();
|
|
557
563
|
return this.getInbox(inboxId);
|
|
558
564
|
}
|
|
559
|
-
listInboxes() {
|
|
560
|
-
const rows =
|
|
565
|
+
listInboxes(limit) {
|
|
566
|
+
const rows = typeof limit === "number"
|
|
567
|
+
? this.getAll("select * from inboxes order by created_at asc, inbox_id asc limit ?", [limit])
|
|
568
|
+
: this.getAll("select * from inboxes order by created_at asc, inbox_id asc");
|
|
561
569
|
return rows.map((row) => this.mapInbox(row));
|
|
562
570
|
}
|
|
563
571
|
getSubscription(subscriptionId) {
|
|
@@ -583,16 +591,41 @@ class AgentInboxStore {
|
|
|
583
591
|
]);
|
|
584
592
|
this.persist();
|
|
585
593
|
}
|
|
586
|
-
listSubscriptions() {
|
|
587
|
-
const rows =
|
|
594
|
+
listSubscriptions(limit) {
|
|
595
|
+
const rows = typeof limit === "number"
|
|
596
|
+
? this.getAll("select * from subscriptions order by created_at asc, subscription_id asc limit ?", [limit])
|
|
597
|
+
: this.getAll("select * from subscriptions order by created_at asc, subscription_id asc");
|
|
588
598
|
return rows.map((row) => this.mapSubscription(row));
|
|
589
599
|
}
|
|
590
|
-
|
|
591
|
-
const
|
|
600
|
+
listSubscriptionsFiltered(filters) {
|
|
601
|
+
const clauses = [];
|
|
602
|
+
const params = [];
|
|
603
|
+
if (filters?.sourceId) {
|
|
604
|
+
clauses.push("source_id = ?");
|
|
605
|
+
params.push(filters.sourceId);
|
|
606
|
+
}
|
|
607
|
+
if (filters?.agentId) {
|
|
608
|
+
clauses.push("agent_id = ?");
|
|
609
|
+
params.push(filters.agentId);
|
|
610
|
+
}
|
|
611
|
+
const where = clauses.length > 0 ? ` where ${clauses.join(" and ")}` : "";
|
|
612
|
+
const limitClause = typeof filters?.limit === "number" ? " limit ?" : "";
|
|
613
|
+
if (typeof filters?.limit === "number") {
|
|
614
|
+
params.push(filters.limit);
|
|
615
|
+
}
|
|
616
|
+
const rows = this.getAll(`select * from subscriptions${where} order by created_at asc, subscription_id asc${limitClause}`, params);
|
|
617
|
+
return rows.map((row) => this.mapSubscription(row));
|
|
618
|
+
}
|
|
619
|
+
listSubscriptionsForSource(sourceId, limit) {
|
|
620
|
+
const rows = typeof limit === "number"
|
|
621
|
+
? this.getAll("select * from subscriptions where source_id = ? order by created_at asc, subscription_id asc limit ?", [sourceId, limit])
|
|
622
|
+
: this.getAll("select * from subscriptions where source_id = ? order by created_at asc, subscription_id asc", [sourceId]);
|
|
592
623
|
return rows.map((row) => this.mapSubscription(row));
|
|
593
624
|
}
|
|
594
|
-
listSubscriptionsForAgent(agentId) {
|
|
595
|
-
const rows =
|
|
625
|
+
listSubscriptionsForAgent(agentId, limit) {
|
|
626
|
+
const rows = typeof limit === "number"
|
|
627
|
+
? this.getAll("select * from subscriptions where agent_id = ? order by created_at asc, subscription_id asc limit ?", [agentId, limit])
|
|
628
|
+
: this.getAll("select * from subscriptions where agent_id = ? order by created_at asc, subscription_id asc", [agentId]);
|
|
596
629
|
return rows.map((row) => this.mapSubscription(row));
|
|
597
630
|
}
|
|
598
631
|
listSubscriptionsForHostTrackedResourceRef(hostId, trackedResourceRef) {
|
|
@@ -821,12 +854,16 @@ class AgentInboxStore {
|
|
|
821
854
|
this.persist();
|
|
822
855
|
return this.getActivationTarget(targetId);
|
|
823
856
|
}
|
|
824
|
-
listActivationTargets() {
|
|
825
|
-
const rows =
|
|
857
|
+
listActivationTargets(limit) {
|
|
858
|
+
const rows = typeof limit === "number"
|
|
859
|
+
? this.getAll("select * from activation_targets order by created_at asc, target_id asc limit ?", [limit])
|
|
860
|
+
: this.getAll("select * from activation_targets order by created_at asc, target_id asc");
|
|
826
861
|
return rows.map((row) => this.mapActivationTarget(row));
|
|
827
862
|
}
|
|
828
|
-
listActivationTargetsForAgent(agentId) {
|
|
829
|
-
const rows =
|
|
863
|
+
listActivationTargetsForAgent(agentId, limit) {
|
|
864
|
+
const rows = typeof limit === "number"
|
|
865
|
+
? this.getAll("select * from activation_targets where agent_id = ? order by created_at asc, target_id asc limit ?", [agentId, limit])
|
|
866
|
+
: this.getAll("select * from activation_targets where agent_id = ? order by created_at asc, target_id asc", [agentId]);
|
|
830
867
|
return rows.map((row) => this.mapActivationTarget(row));
|
|
831
868
|
}
|
|
832
869
|
deleteActivationTarget(agentId, targetId) {
|
|
@@ -902,12 +939,16 @@ class AgentInboxStore {
|
|
|
902
939
|
const row = this.getOne("select * from timers where schedule_id = ?", [scheduleId]);
|
|
903
940
|
return row ? this.mapTimer(row) : null;
|
|
904
941
|
}
|
|
905
|
-
listTimers() {
|
|
906
|
-
const rows =
|
|
942
|
+
listTimers(limit) {
|
|
943
|
+
const rows = typeof limit === "number"
|
|
944
|
+
? this.getAll("select * from timers order by created_at asc, schedule_id asc limit ?", [limit])
|
|
945
|
+
: this.getAll("select * from timers order by created_at asc, schedule_id asc");
|
|
907
946
|
return rows.map((row) => this.mapTimer(row));
|
|
908
947
|
}
|
|
909
|
-
listTimersForAgent(agentId) {
|
|
910
|
-
const rows =
|
|
948
|
+
listTimersForAgent(agentId, limit) {
|
|
949
|
+
const rows = typeof limit === "number"
|
|
950
|
+
? this.getAll("select * from timers where agent_id = ? order by created_at asc, schedule_id asc limit ?", [agentId, limit])
|
|
951
|
+
: this.getAll("select * from timers where agent_id = ? order by created_at asc, schedule_id asc", [agentId]);
|
|
911
952
|
return rows.map((row) => this.mapTimer(row));
|
|
912
953
|
}
|
|
913
954
|
listDueTimers(cutoffIso) {
|
|
@@ -1015,8 +1056,8 @@ class AgentInboxStore {
|
|
|
1015
1056
|
this.db.run(`
|
|
1016
1057
|
insert or ignore into inbox_items (
|
|
1017
1058
|
item_id, source_id, source_native_id, event_variant, inbox_id, occurred_at,
|
|
1018
|
-
metadata_json, raw_payload_json, delivery_handle_json, acked_at
|
|
1019
|
-
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1059
|
+
metadata_json, raw_payload_json, provider_raw_payload_json, delivery_handle_json, acked_at
|
|
1060
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1020
1061
|
`, [
|
|
1021
1062
|
item.itemId,
|
|
1022
1063
|
item.sourceId,
|
|
@@ -1026,6 +1067,7 @@ class AgentInboxStore {
|
|
|
1026
1067
|
item.occurredAt,
|
|
1027
1068
|
JSON.stringify(item.metadata),
|
|
1028
1069
|
JSON.stringify(item.rawPayload),
|
|
1070
|
+
item.providerRawPayload ? JSON.stringify(item.providerRawPayload) : null,
|
|
1029
1071
|
item.deliveryHandle ? JSON.stringify(item.deliveryHandle) : null,
|
|
1030
1072
|
item.ackedAt ?? null,
|
|
1031
1073
|
]);
|
|
@@ -1059,6 +1101,7 @@ class AgentInboxStore {
|
|
|
1059
1101
|
occurredAt: item.occurredAt,
|
|
1060
1102
|
metadata: item.metadata,
|
|
1061
1103
|
rawPayload: item.rawPayload,
|
|
1104
|
+
providerRawPayload: item.providerRawPayload,
|
|
1062
1105
|
deliveryHandle: item.deliveryHandle ?? null,
|
|
1063
1106
|
}),
|
|
1064
1107
|
count: 1,
|
|
@@ -1092,7 +1135,11 @@ class AgentInboxStore {
|
|
|
1092
1135
|
filters.push("sequence > ?");
|
|
1093
1136
|
params.push(Number(anchor.sequence));
|
|
1094
1137
|
}
|
|
1095
|
-
const
|
|
1138
|
+
const sql = `select * from inbox_entries where ${filters.join(" and ")} order by sequence asc${typeof options?.limit === "number" ? " limit ?" : ""}`;
|
|
1139
|
+
if (typeof options?.limit === "number") {
|
|
1140
|
+
params.push(options.limit);
|
|
1141
|
+
}
|
|
1142
|
+
const rows = this.getAll(sql, params);
|
|
1096
1143
|
return this.mapInboxEntries(rows);
|
|
1097
1144
|
}
|
|
1098
1145
|
getInboxEntry(entryId) {
|
|
@@ -1273,7 +1320,11 @@ class AgentInboxStore {
|
|
|
1273
1320
|
if (!includeAcked) {
|
|
1274
1321
|
filters.push("acked_at is null");
|
|
1275
1322
|
}
|
|
1276
|
-
const
|
|
1323
|
+
const sql = `select * from inbox_items where ${filters.join(" and ")} order by coalesce(inbox_sequence, rowid) asc${typeof options?.limit === "number" ? " limit ?" : ""}`;
|
|
1324
|
+
if (typeof options?.limit === "number") {
|
|
1325
|
+
params.push(options.limit);
|
|
1326
|
+
}
|
|
1327
|
+
const rows = this.getAll(sql, params);
|
|
1277
1328
|
return rows.map((row) => this.mapInboxItem(row));
|
|
1278
1329
|
}
|
|
1279
1330
|
ackItems(inboxId, itemIds, ackedAt) {
|
|
@@ -1406,8 +1457,10 @@ class AgentInboxStore {
|
|
|
1406
1457
|
const row = this.getOne("select * from streams where stream_id = ?", [streamId]);
|
|
1407
1458
|
return row ? this.mapStream(row) : null;
|
|
1408
1459
|
}
|
|
1409
|
-
listStreams() {
|
|
1410
|
-
const rows =
|
|
1460
|
+
listStreams(limit) {
|
|
1461
|
+
const rows = typeof limit === "number"
|
|
1462
|
+
? this.getAll("select * from streams order by created_at asc, stream_id asc limit ?", [limit])
|
|
1463
|
+
: this.getAll("select * from streams order by created_at asc, stream_id asc");
|
|
1411
1464
|
return rows.map((row) => this.mapStream(row));
|
|
1412
1465
|
}
|
|
1413
1466
|
getStreamBySourceId(sourceId) {
|
|
@@ -1418,14 +1471,15 @@ class AgentInboxStore {
|
|
|
1418
1471
|
const occurredAt = event.occurredAt ?? (0, util_1.nowIso)();
|
|
1419
1472
|
const metadataJson = JSON.stringify(event.metadata ?? {});
|
|
1420
1473
|
const rawPayloadJson = JSON.stringify(event.rawPayload ?? {});
|
|
1474
|
+
const providerRawPayloadJson = event.providerRawPayload ? JSON.stringify(event.providerRawPayload) : null;
|
|
1421
1475
|
const deliveryHandleJson = event.deliveryHandle ? JSON.stringify(event.deliveryHandle) : null;
|
|
1422
1476
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
1423
1477
|
const before = this.changes();
|
|
1424
1478
|
this.db.run(`
|
|
1425
1479
|
insert or ignore into stream_events (
|
|
1426
1480
|
stream_event_id, stream_id, source_id, source_native_id, event_variant,
|
|
1427
|
-
occurred_at, metadata_json, raw_payload_json, delivery_handle_json, created_at
|
|
1428
|
-
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1481
|
+
occurred_at, metadata_json, raw_payload_json, provider_raw_payload_json, delivery_handle_json, created_at
|
|
1482
|
+
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1429
1483
|
`, [
|
|
1430
1484
|
(0, util_1.generateCanonicalId)("evt"),
|
|
1431
1485
|
streamId,
|
|
@@ -1435,6 +1489,7 @@ class AgentInboxStore {
|
|
|
1435
1489
|
occurredAt,
|
|
1436
1490
|
metadataJson,
|
|
1437
1491
|
rawPayloadJson,
|
|
1492
|
+
providerRawPayloadJson,
|
|
1438
1493
|
deliveryHandleJson,
|
|
1439
1494
|
(0, util_1.nowIso)(),
|
|
1440
1495
|
]);
|
|
@@ -1821,6 +1876,9 @@ class AgentInboxStore {
|
|
|
1821
1876
|
occurredAt: String(row.occurred_at),
|
|
1822
1877
|
metadata: parseJson(row.metadata_json),
|
|
1823
1878
|
rawPayload: parseJson(row.raw_payload_json),
|
|
1879
|
+
providerRawPayload: row.provider_raw_payload_json
|
|
1880
|
+
? parseJson(row.provider_raw_payload_json)
|
|
1881
|
+
: undefined,
|
|
1824
1882
|
deliveryHandle: row.delivery_handle_json
|
|
1825
1883
|
? parseJson(row.delivery_handle_json)
|
|
1826
1884
|
: null,
|
|
@@ -1858,6 +1916,7 @@ class AgentInboxStore {
|
|
|
1858
1916
|
occurredAt: item.occurredAt,
|
|
1859
1917
|
metadata: item.metadata,
|
|
1860
1918
|
rawPayload: item.rawPayload,
|
|
1919
|
+
providerRawPayload: item.providerRawPayload,
|
|
1861
1920
|
item,
|
|
1862
1921
|
};
|
|
1863
1922
|
}
|
|
@@ -2130,6 +2189,9 @@ class AgentInboxStore {
|
|
|
2130
2189
|
occurredAt: String(row.occurred_at),
|
|
2131
2190
|
metadata: parseJson(row.metadata_json),
|
|
2132
2191
|
rawPayload: parseJson(row.raw_payload_json),
|
|
2192
|
+
providerRawPayload: row.provider_raw_payload_json
|
|
2193
|
+
? parseJson(row.provider_raw_payload_json)
|
|
2194
|
+
: undefined,
|
|
2133
2195
|
deliveryHandle: row.delivery_handle_json
|
|
2134
2196
|
? parseJson(row.delivery_handle_json)
|
|
2135
2197
|
: null,
|
package/drizzle/schema.ts
CHANGED
|
@@ -173,6 +173,7 @@ export const inboxItems = sqliteTable("inbox_items", {
|
|
|
173
173
|
occurredAt: text("occurred_at").notNull(),
|
|
174
174
|
metadataJson: text("metadata_json").notNull(),
|
|
175
175
|
rawPayloadJson: text("raw_payload_json").notNull(),
|
|
176
|
+
providerRawPayloadJson: text("provider_raw_payload_json"),
|
|
176
177
|
deliveryHandleJson: text("delivery_handle_json"),
|
|
177
178
|
ackedAt: text("acked_at"),
|
|
178
179
|
}, (table) => ({
|
|
@@ -302,6 +303,7 @@ export const streamEvents = sqliteTable("stream_events", {
|
|
|
302
303
|
occurredAt: text("occurred_at").notNull(),
|
|
303
304
|
metadataJson: text("metadata_json").notNull(),
|
|
304
305
|
rawPayloadJson: text("raw_payload_json").notNull(),
|
|
306
|
+
providerRawPayloadJson: text("provider_raw_payload_json"),
|
|
305
307
|
deliveryHandleJson: text("delivery_handle_json"),
|
|
306
308
|
createdAt: text("created_at").notNull(),
|
|
307
309
|
}, (table) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holon-run/agentinbox",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Local event subscription and delivery service for agents.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@fastify/swagger": "^9.5.2",
|
|
47
|
-
"@holon-run/uxc-daemon-client": "^0.15.
|
|
47
|
+
"@holon-run/uxc-daemon-client": "^0.15.4",
|
|
48
|
+
"commander": "^14.0.3",
|
|
48
49
|
"fastify": "^5.6.1",
|
|
49
50
|
"jexl": "^2.3.0",
|
|
50
51
|
"sql.js": "^1.13.0"
|
package/skills/README.md
CHANGED
|
@@ -7,12 +7,12 @@ For `AgentInbox`, the preferred first-run path is skill-first onboarding:
|
|
|
7
7
|
|
|
8
8
|
- hand the bundled `AgentInbox` skill to the agent
|
|
9
9
|
- let the agent verify `agentinbox`, `uxc`, and GitHub auth
|
|
10
|
-
- let the agent register the current session and set up standing subscriptions
|
|
10
|
+
- let the agent register the current runtime/session and set up standing subscriptions
|
|
11
11
|
|
|
12
12
|
<!-- INDEX:START -->
|
|
13
13
|
|
|
14
14
|
- [agentinbox](./agentinbox/)
|
|
15
|
-
Use the local AgentInbox service to onboard the current session, connect GitHub through UXC, and operate
|
|
15
|
+
Use the local AgentInbox service to onboard the current runtime/session, manage shared sources and subscriptions, connect external providers such as GitHub through UXC, and operate the agent inbox.
|
|
16
16
|
<!-- mdorigin:index kind=article -->
|
|
17
17
|
|
|
18
18
|
<!-- INDEX:END -->
|