@holon-run/agentinbox 1.0.5 → 1.1.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/dist/src/adapters.js +1 -1
- package/dist/src/http.js +2 -0
- package/dist/src/service.js +54 -2
- package/package.json +1 -1
package/dist/src/adapters.js
CHANGED
|
@@ -197,7 +197,7 @@ class AdapterRegistry {
|
|
|
197
197
|
async listDeliveryOperations(source, handle) {
|
|
198
198
|
const module = await this.resolveDeliveryModule(source, handle);
|
|
199
199
|
if (!module?.listDeliveryOperations) {
|
|
200
|
-
return
|
|
200
|
+
return null;
|
|
201
201
|
}
|
|
202
202
|
return module.listDeliveryOperations({ handle, source });
|
|
203
203
|
}
|
package/dist/src/http.js
CHANGED
|
@@ -1870,6 +1870,8 @@ function isBadRequestError(message) {
|
|
|
1870
1870
|
message.startsWith("deliver send is not supported") ||
|
|
1871
1871
|
message.startsWith("deliveryHandle requires") ||
|
|
1872
1872
|
message.startsWith("delivery operations are not supported") ||
|
|
1873
|
+
message.startsWith("unsupported delivery surface") ||
|
|
1874
|
+
message.startsWith("unsupported delivery operation") ||
|
|
1873
1875
|
message.startsWith("source operations are not supported") ||
|
|
1874
1876
|
message.startsWith("unknown GitHub delivery operation") ||
|
|
1875
1877
|
message.startsWith("unknown Feishu delivery operation") ||
|
package/dist/src/service.js
CHANGED
|
@@ -1620,6 +1620,12 @@ class AgentInboxService {
|
|
|
1620
1620
|
const handle = resolveDeliveryHandle(request);
|
|
1621
1621
|
const source = resolveDeliverySource(this.store, request.sourceId, handle);
|
|
1622
1622
|
const operations = await this.adapters.listDeliveryOperations(source, handle);
|
|
1623
|
+
if (operations === null) {
|
|
1624
|
+
throw new Error(`delivery operations are not supported for provider ${handle.provider}`);
|
|
1625
|
+
}
|
|
1626
|
+
if (operations.length === 0) {
|
|
1627
|
+
throw new Error(noDeliveryOperationsMessage(handle));
|
|
1628
|
+
}
|
|
1623
1629
|
return {
|
|
1624
1630
|
sourceId: source?.sourceId ?? null,
|
|
1625
1631
|
handle,
|
|
@@ -1629,6 +1635,15 @@ class AgentInboxService {
|
|
|
1629
1635
|
async invokeDelivery(request) {
|
|
1630
1636
|
const handle = resolveDeliveryHandle(request);
|
|
1631
1637
|
const source = resolveDeliverySource(this.store, request.sourceId, handle);
|
|
1638
|
+
const operations = await this.adapters.listDeliveryOperations(source, handle);
|
|
1639
|
+
if (operations !== null) {
|
|
1640
|
+
if (operations.length === 0) {
|
|
1641
|
+
throw new Error(noDeliveryOperationsMessage(handle));
|
|
1642
|
+
}
|
|
1643
|
+
if (!operations.some((operation) => operation.name === request.operation)) {
|
|
1644
|
+
throw new Error(unsupportedDeliveryOperationMessage(handle, request.operation, operations));
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1632
1647
|
const attempt = {
|
|
1633
1648
|
deliveryId: (0, util_1.generateCanonicalId)("dlv"),
|
|
1634
1649
|
provider: handle.provider,
|
|
@@ -1648,9 +1663,9 @@ class AgentInboxService {
|
|
|
1648
1663
|
}
|
|
1649
1664
|
async sendCanonicalDeliveryViaModule(source, handle, payload, attempt) {
|
|
1650
1665
|
const operations = await this.adapters.listDeliveryOperations(source, handle);
|
|
1651
|
-
const canonicalOperation = operations
|
|
1666
|
+
const canonicalOperation = operations?.find((operation) => operation.canonicalTextAlias);
|
|
1652
1667
|
if (!canonicalOperation) {
|
|
1653
|
-
throw new Error(
|
|
1668
|
+
throw new Error(deliverSendUnsupportedMessage(handle, operations));
|
|
1654
1669
|
}
|
|
1655
1670
|
const input = payload.text != null ? { ...payload, body: String(payload.text) } : payload;
|
|
1656
1671
|
return this.adapters.invokeDeliveryOperation(source, handle, canonicalOperation.name, input, attempt);
|
|
@@ -3885,6 +3900,43 @@ function listHostStreamKinds(hostType) {
|
|
|
3885
3900
|
return ["default"];
|
|
3886
3901
|
}
|
|
3887
3902
|
}
|
|
3903
|
+
const KNOWN_DELIVERY_SURFACES = {
|
|
3904
|
+
feishu: ["message_reply", "chat_message"],
|
|
3905
|
+
github: ["issue_comment", "pull_request_comment", "review_comment"],
|
|
3906
|
+
};
|
|
3907
|
+
function unsupportedDeliverySurfaceMessage(handle) {
|
|
3908
|
+
const supported = KNOWN_DELIVERY_SURFACES[handle.provider];
|
|
3909
|
+
const supportedHint = supported?.length
|
|
3910
|
+
? ` Supported surfaces for ${handle.provider}: ${supported.join(", ")}.`
|
|
3911
|
+
: "";
|
|
3912
|
+
return `unsupported delivery surface for ${handle.provider}: ${handle.surface}.${supportedHint} ${deliveryActionsHelp(handle)}`;
|
|
3913
|
+
}
|
|
3914
|
+
function noDeliveryOperationsMessage(handle) {
|
|
3915
|
+
if (!isKnownDeliverySurface(handle)) {
|
|
3916
|
+
return unsupportedDeliverySurfaceMessage(handle);
|
|
3917
|
+
}
|
|
3918
|
+
return `delivery operations are not supported for ${handle.provider}/${handle.surface}. ${deliveryActionsHelp(handle)}`;
|
|
3919
|
+
}
|
|
3920
|
+
function unsupportedDeliveryOperationMessage(handle, operation, operations) {
|
|
3921
|
+
const names = operations.map((item) => item.name).join(", ");
|
|
3922
|
+
return `unsupported delivery operation for ${handle.provider}/${handle.surface}: ${operation}. Available operations: ${names}. ${deliveryActionsHelp(handle)}`;
|
|
3923
|
+
}
|
|
3924
|
+
function deliverSendUnsupportedMessage(handle, operations) {
|
|
3925
|
+
if (!operations || operations.length === 0) {
|
|
3926
|
+
if (!isKnownDeliverySurface(handle)) {
|
|
3927
|
+
return unsupportedDeliverySurfaceMessage(handle);
|
|
3928
|
+
}
|
|
3929
|
+
return `deliver send is not supported for ${handle.provider}/${handle.surface}. ${deliveryActionsHelp(handle)}`;
|
|
3930
|
+
}
|
|
3931
|
+
const names = operations.map((item) => item.name).join(", ");
|
|
3932
|
+
return `deliver send is not supported for ${handle.provider}/${handle.surface}; use deliver invoke with one of: ${names}. ${deliveryActionsHelp(handle)}`;
|
|
3933
|
+
}
|
|
3934
|
+
function deliveryActionsHelp(handle) {
|
|
3935
|
+
return `Run \`agentinbox deliver actions --provider ${handle.provider} --surface ${handle.surface} --target ${handle.targetRef}\` to inspect supported operations and input schemas.`;
|
|
3936
|
+
}
|
|
3937
|
+
function isKnownDeliverySurface(handle) {
|
|
3938
|
+
return KNOWN_DELIVERY_SURFACES[handle.provider]?.includes(handle.surface) === true;
|
|
3939
|
+
}
|
|
3888
3940
|
function getHostConfigFields(hostType) {
|
|
3889
3941
|
switch (hostType) {
|
|
3890
3942
|
case "github":
|