commonswarm 0.1.41 → 0.1.42
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/cswarm.cjs +48 -20
- package/package.json +1 -1
package/cswarm.cjs
CHANGED
|
@@ -22943,7 +22943,7 @@ async function sendFileCommand(options, command2) {
|
|
|
22943
22943
|
const body = await response.json().catch(() => null);
|
|
22944
22944
|
if (!response.ok) {
|
|
22945
22945
|
const code = typeof body?.error === "string" ? body.error : "http_error";
|
|
22946
|
-
const message = typeof body?.message === "string" ? body.message : `file command failed (HTTP ${response.status})`;
|
|
22946
|
+
const message = typeof body?.message === "string" ? body.message : `file command failed (HTTP ${response.status}) DEBUGBODY=${JSON.stringify(body).slice(0, 300)}`;
|
|
22947
22947
|
throw new FileCommandRefused(response.status, code, message);
|
|
22948
22948
|
}
|
|
22949
22949
|
if (!body || typeof body !== "object") {
|
|
@@ -30034,6 +30034,12 @@ function parseDeliveryReceipt(value) {
|
|
|
30034
30034
|
);
|
|
30035
30035
|
}
|
|
30036
30036
|
const row = value;
|
|
30037
|
+
if (Object.hasOwn(row, "recipient_user_id")) {
|
|
30038
|
+
return {
|
|
30039
|
+
recipient_user_id: uuid4(row.recipient_user_id, "recipient_user_id"),
|
|
30040
|
+
seen_at: nullableTimestamp2(row.seen_at, "seen_at")
|
|
30041
|
+
};
|
|
30042
|
+
}
|
|
30037
30043
|
const ackedAt = nullableTimestamp2(row.acked_at, "acked_at");
|
|
30038
30044
|
const ackOutcome = row.ack_outcome === null ? null : typeof row.ack_outcome === "string" && ACK_OUTCOMES.has(row.ack_outcome) ? row.ack_outcome : (() => {
|
|
30039
30045
|
throw new DeliveryReceiptReadError(
|
|
@@ -30085,10 +30091,10 @@ function parseDeliveryReceiptResult(value) {
|
|
|
30085
30091
|
);
|
|
30086
30092
|
}
|
|
30087
30093
|
const receipts = body.receipts.map(parseDeliveryReceipt);
|
|
30088
|
-
if (body.addressed === false && receipts.
|
|
30094
|
+
if (body.addressed === false && receipts.some((row) => "recipient_agent_principal_id" in row)) {
|
|
30089
30095
|
throw new DeliveryReceiptReadError(
|
|
30090
30096
|
"protocol",
|
|
30091
|
-
"delivery receipt read returned
|
|
30097
|
+
"delivery receipt read returned an agent recipient for a broadcast"
|
|
30092
30098
|
);
|
|
30093
30099
|
}
|
|
30094
30100
|
if (body.addressed === true && receipts.length === 0) {
|
|
@@ -30098,7 +30104,9 @@ function parseDeliveryReceiptResult(value) {
|
|
|
30098
30104
|
);
|
|
30099
30105
|
}
|
|
30100
30106
|
const recipientIds = new Set(
|
|
30101
|
-
receipts.map(
|
|
30107
|
+
receipts.map(
|
|
30108
|
+
(row) => "recipient_agent_principal_id" in row ? `agent:${row.recipient_agent_principal_id}` : `human:${row.recipient_user_id}`
|
|
30109
|
+
)
|
|
30102
30110
|
);
|
|
30103
30111
|
if (recipientIds.size !== receipts.length) {
|
|
30104
30112
|
throw new DeliveryReceiptReadError(
|
|
@@ -30197,6 +30205,9 @@ async function readAgentDeliveryReceipts(target2, token, workspaceId2, signalId,
|
|
|
30197
30205
|
}
|
|
30198
30206
|
|
|
30199
30207
|
// src/cloud/receipts.ts
|
|
30208
|
+
function humanReceipt(receipt) {
|
|
30209
|
+
return "recipient_user_id" in receipt;
|
|
30210
|
+
}
|
|
30200
30211
|
function signalReceiptCliState(receipt, nowMs) {
|
|
30201
30212
|
const state = deliveryReceiptState(receipt, nowMs);
|
|
30202
30213
|
if (state === "enqueued") return "not_delivered";
|
|
@@ -30215,13 +30226,24 @@ function newAskCommand(report, receipt) {
|
|
|
30215
30226
|
return `cswarm ask "<question>" --to ${receipt.recipient_agent_principal_id} --workspace-id ${report.workspaceId}`;
|
|
30216
30227
|
}
|
|
30217
30228
|
function renderSignalReceiptReport(report, nowMs = Date.now()) {
|
|
30229
|
+
const humanReceipts = report.receipts.filter(humanReceipt);
|
|
30230
|
+
const agentReceipts = report.receipts.filter(
|
|
30231
|
+
(receipt) => !humanReceipt(receipt)
|
|
30232
|
+
);
|
|
30233
|
+
const humanSections = humanReceipts.map(
|
|
30234
|
+
(receipt) => receipt.seen_at === null ? `Not seen yet \u2014 the member's browser reports seen state when the message is viewed.` : [
|
|
30235
|
+
`Seen by ${receipt.recipient_user_id} at ${receipt.seen_at}.`,
|
|
30236
|
+
"This is a browser proxy: the message row was in view while the document had focus."
|
|
30237
|
+
].join("\n")
|
|
30238
|
+
);
|
|
30218
30239
|
if (!report.addressed) {
|
|
30219
30240
|
return [
|
|
30220
30241
|
"This was a broadcast; no agent was addressed and none was woken.",
|
|
30242
|
+
...humanSections,
|
|
30221
30243
|
`To wake an agent, send a new ask with: cswarm ask "<text>" --to <agent> --workspace-id ${report.workspaceId}`
|
|
30222
30244
|
].join("\n");
|
|
30223
30245
|
}
|
|
30224
|
-
const sections =
|
|
30246
|
+
const sections = agentReceipts.map((receipt) => {
|
|
30225
30247
|
const state = deliveryReceiptState(receipt, nowMs);
|
|
30226
30248
|
if (state === "enqueued") {
|
|
30227
30249
|
return [
|
|
@@ -30276,25 +30298,31 @@ function renderSignalReceiptReport(report, nowMs = Date.now()) {
|
|
|
30276
30298
|
`Ask the agent's operator to check its listener with: ${listenerStatusCommand(report, receipt)}`
|
|
30277
30299
|
].join("\n");
|
|
30278
30300
|
});
|
|
30279
|
-
return sections.join("\n\n");
|
|
30301
|
+
return [...humanSections, ...sections].join("\n\n");
|
|
30280
30302
|
}
|
|
30281
30303
|
function signalReceiptJsonPayload(report, nowMs = Date.now()) {
|
|
30282
30304
|
return {
|
|
30283
30305
|
workspace_id: report.workspaceId,
|
|
30284
30306
|
signal_id: report.signalId,
|
|
30285
30307
|
broadcast: !report.addressed,
|
|
30286
|
-
receipts: report.receipts.map(
|
|
30287
|
-
|
|
30288
|
-
|
|
30289
|
-
|
|
30290
|
-
|
|
30291
|
-
|
|
30292
|
-
|
|
30293
|
-
|
|
30294
|
-
|
|
30295
|
-
|
|
30296
|
-
|
|
30297
|
-
|
|
30308
|
+
receipts: report.receipts.map(
|
|
30309
|
+
(receipt) => humanReceipt(receipt) ? {
|
|
30310
|
+
recipient_user_id: receipt.recipient_user_id,
|
|
30311
|
+
state: receipt.seen_at === null ? "not_seen" : "seen",
|
|
30312
|
+
seen_at: receipt.seen_at
|
|
30313
|
+
} : {
|
|
30314
|
+
recipient_agent_principal_id: receipt.recipient_agent_principal_id,
|
|
30315
|
+
state: signalReceiptCliState(receipt, nowMs),
|
|
30316
|
+
outcome: receipt.ack_outcome,
|
|
30317
|
+
enqueued_at: receipt.enqueued_at,
|
|
30318
|
+
delivered_at: receipt.delivered_at,
|
|
30319
|
+
leased_until: receipt.leased_until,
|
|
30320
|
+
acked_at: receipt.acked_at,
|
|
30321
|
+
attempt_count: receipt.attempt_count,
|
|
30322
|
+
lease_expiry_count: receipt.lease_expiry_count,
|
|
30323
|
+
last_error_code: receipt.last_error_code
|
|
30324
|
+
}
|
|
30325
|
+
)
|
|
30298
30326
|
};
|
|
30299
30327
|
}
|
|
30300
30328
|
|
|
@@ -39209,8 +39237,8 @@ var ACCEPTED_AGENT_CREDENTIAL_MESSAGES = [
|
|
|
39209
39237
|
AGENT_CREDENTIAL_MESSAGE_D088
|
|
39210
39238
|
];
|
|
39211
39239
|
function packageVersion() {
|
|
39212
|
-
if ("0.1.
|
|
39213
|
-
return "0.1.
|
|
39240
|
+
if ("0.1.42".length > 0) {
|
|
39241
|
+
return "0.1.42";
|
|
39214
39242
|
}
|
|
39215
39243
|
try {
|
|
39216
39244
|
const value = JSON.parse(
|