@rine-network/cli 0.19.0 → 0.20.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/main.js +189 -70
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { Command, Option } from "commander";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
|
-
import { ACTING_AGENT_ENV, ACTING_AGENT_HEADER, ACTOR_SURFACES, FUNNEL_TIERS, GROUP_NOT_FOUND_LEAD, HttpClient, IdempotencyStore, MLS_ERR_GROUP_INACTIVE, MLS_EVICTED_BY_COMMIT, MlsInitInFlightError, RineApiError, SENDER_KEY_UNAVAILABLE_CODE, SENDER_KEY_UNAVAILABLE_PREVIEW, THREAD_REF_SURFACES, THREAD_UNAVAILABLE, UUID_RE, VOTE_DURATION_RULE, VOTE_ELECTORATE_RULE, X402Error, X402FacilitatorError, X402_ERROR, X402_MESSAGE_TYPE, actorFromEnv, addMlsGroupMembers, admissionHeadline, admittedAgentIds, agentKeysExist, agentLabel, asSenderKeyUnavailable, assertNoMlsDowngrade, buildIssueCertDeps, buildPaymentMessage, buildPaymentPayload, buildPaymentRequiredMessage, buildPeerVerification, buildReceiptMessage, cacheToken, compareVerificationWordsForAgent, connectTunnel, createWallet, decryptGroupMessageWithRecovery, decryptMessage, decryptThreadRows, deleteGroupMember, deleteHookSecret, describeMlsReclamation, describeMlsRecovery, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, encryptionLine, ensureCert, evictionMessage, externalJoinMlsGroup, fetchAgents, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, getWalletAddress, groupAcceptsMlsSendOnly, groupAdmissionSkipSentence, groupEncryption, groupEncryption as groupEncryption$1, groupIsMls, groupMlsInitInFlight, handleCompletionNote, handleWebhookRequest, hasSpiffeEndpoint, holdsAnyMlsState, holdsMlsState, hookNameError, ingestSenderKeyDistribution, initMlsGroup, inviteNominates, isAuthenticityFailure, isAutoPayable, isMlsResyncUnavailable, isMlsWelcomeRefusedError, isNoMlsStateError, isX402MessageType, jitteredRefreshMargin, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsGroup, loadMlsState, loadPolicy, loadSenderKeyStates, loadTokenCache, loadWalletKey, makeEdgePipeFactory, matchedQuoteToWire, mlsAdmissionSkipSentence, mlsErrorCode, mlsInitInFlightSync, normalizeActor, normalizeHandle, openMlsClient, parseFacilitatorHeaders, parseX402Payload, peerVerificationLines, performAgentCreation, performRegistration, processMlsWelcomes, readDailySpent, readThreadPage, recordPeerVerification, recoverGroup, refusalReceiptBody, renewalDueWithJitter, requireAuthenticPlaintext, reserveSpend, resolveAgent, resolveApiUrl, resolveConfigDir, resolveFacilitatorConfig, resolveGroup, resolveGroupByHandle, resolveGroupForJoin, resolvePayeeRequirement, resolveThreadRef, resolveToUuid, resumeMlsGroupAdmission, retireLocalGroupState, retirementMessage, saveAgentKeys, saveCredentials, saveHookSecret, savePolicy, savePqEncryptionKey, saveTokenCache, selectRequirement, sendGroupInviteNotification, sendReceipt, senderKeyExplainer, settleToReceipt, singleActorValue, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug, verificationWordsLines, verifyIdentitySpiffe, walletKeyExists, withEvictionPointer } from "@rine-network/core";
|
|
5
|
+
import { ACTING_AGENT_ENV, ACTING_AGENT_HEADER, ACTOR_SURFACES, FUNNEL_TIERS, GROUP_NOT_FOUND_LEAD, HttpClient, IdempotencyStore, MLS_ERR_GROUP_INACTIVE, MLS_EVICTED_BY_COMMIT, MlsInitInFlightError, RineApiError, SENDER_KEY_UNAVAILABLE_CODE, SENDER_KEY_UNAVAILABLE_PREVIEW, THREAD_REF_SURFACES, THREAD_UNAVAILABLE, UUID_RE, VOTE_DURATION_RULE, VOTE_ELECTORATE_RULE, X402Error, X402FacilitatorError, X402_ERROR, X402_MESSAGE_TYPE, actorFromEnv, addMlsGroupMembers, admissionHeadline, admittedAgentIds, agentKeysExist, agentLabel, asSenderKeyUnavailable, assertNoMlsDowngrade, buildIssueCertDeps, buildPaymentMessage, buildPaymentPayload, buildPaymentRequiredMessage, buildPeerVerification, buildReceiptMessage, cacheToken, cliSyncRemedy, compareVerificationWordsForAgent, connectTunnel, createWallet, decryptGroupMessageWithRecovery, decryptMessage, decryptThreadRows, deleteGroupMember, deleteHookSecret, describeMlsReclamation, describeMlsRecovery, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, encryptionLine, ensureCert, evictionMessage, externalJoinMlsGroup, fetchAgents, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, getWalletAddress, groupAcceptsMlsSendOnly, groupAdmissionSkipSentence, groupEncryption, groupEncryption as groupEncryption$1, groupIsMls, groupMlsInitInFlight, handleCompletionNote, handleWebhookRequest, hasSpiffeEndpoint, holdsAnyMlsState, holdsMlsState, hookNameError, ingestSenderKeyDistribution, initMlsGroup, inviteNominates, isAuthenticityFailure, isAutoPayable, isEpochConflict, isMlsResyncUnavailable, isMlsWelcomeRefusedError, isNoMlsStateError, isRecoverableMlsRead, isX402MessageType, jitteredRefreshMargin, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsGroup, loadMlsState, loadPolicy, loadSenderKeyStates, loadTokenCache, loadWalletKey, makeEdgePipeFactory, matchedQuoteToWire, mlsAdmissionSkipSentence, mlsErrorCode, mlsInitInFlightSync, mlsReadRefusal, normalizeActor, normalizeHandle, openMlsClient, parseFacilitatorHeaders, parseX402Payload, peerVerificationLines, performAgentCreation, performRegistration, processMlsWelcomes, readDailySpent, readThreadPage, readableGroupById, recordPeerVerification, recoverGroup, refusalReceiptBody, renewalDueWithJitter, requireAuthenticPlaintext, reserveSpend, resolveAgent, resolveApiUrl, resolveConfigDir, resolveFacilitatorConfig, resolveGroup, resolveGroupByHandle, resolveGroupForJoin, resolvePayeeRequirement, resolveThreadRef, resolveToUuid, resumeMlsGroupAdmission, retireLocalGroupState, retirementMessage, saveAgentKeys, saveCredentials, saveHookSecret, savePolicy, savePqEncryptionKey, saveTokenCache, selectRequirement, sendGroupInviteNotification, sendReceipt, senderKeyExplainer, settleToReceipt, singleActorValue, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug, verificationWordsLines, verifyIdentitySpiffe, walletKeyExists, withEvictionPointer } from "@rine-network/core";
|
|
6
6
|
import readline from "node:readline";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { resolve4 } from "node:dns/promises";
|
|
@@ -1589,10 +1589,38 @@ const DESCRIPTION_HELP = "Group description — durable house rules every member
|
|
|
1589
1589
|
const INVITEE_REQUIRED = "--invitee is required, and it repeats: give the flag once per agent to invite several in one call and be told what happened to each. One --invitee behaves exactly as a single invitation always did.\nEach invitee is an agent handle written in full — the agent's name, an at sign, and its org's domain — or an agent UUID.\nOn this command --agent names the agent doing the inviting, not the agent being invited.";
|
|
1590
1590
|
//#endregion
|
|
1591
1591
|
//#region src/commands/group-mls.ts
|
|
1592
|
-
/**
|
|
1592
|
+
/**
|
|
1593
|
+
* Why an MLS commit the server refused for its epoch check did not land, and
|
|
1594
|
+
* what puts it right.
|
|
1595
|
+
*
|
|
1596
|
+
* The server states this as `MLS epoch conflict: group at epoch 5, commit
|
|
1597
|
+
* targets 5`, and both numbers are correct: the first is the group's stored
|
|
1598
|
+
* epoch, the second is the epoch the client's commit would have produced. An
|
|
1599
|
+
* equal pair is the honest signature of a commit built one epoch behind — but
|
|
1600
|
+
* it reads as a contradiction, and it arrives behind `RineApiError`'s
|
|
1601
|
+
* `409: ` with no remedy attached. So the fact is stated instead of the
|
|
1602
|
+
* arithmetic. 🔴 Do not "fix" the server's numbers to make them differ.
|
|
1603
|
+
*
|
|
1604
|
+
* `groupRef` is whatever the caller addressed the group by, so the command it
|
|
1605
|
+
* names back is one the operator can paste.
|
|
1606
|
+
*/
|
|
1607
|
+
function epochConflictMessage(groupRef) {
|
|
1608
|
+
return `Another member's commit landed first, so this one was built one epoch behind and the server's epoch check refused it. Nothing was committed and the group is exactly where it was. Run \`rine group sync ${groupRef}\` to catch this agent's state up, then run the command again.`;
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* A failure's message, in rine's words wherever rine has any.
|
|
1612
|
+
*
|
|
1613
|
+
* Two things reach an operator through here that should not, and both are
|
|
1614
|
+
* recognised by a machine-readable CODE rather than by matching words: the MLS
|
|
1615
|
+
* core's own vocabulary for an invariant rine states as a membership fact, and
|
|
1616
|
+
* `RineApiError`'s `${status}: ${detail}` — a bare `409: ` in front of a
|
|
1617
|
+
* sentence about epochs is the one place these commands drop to a status code.
|
|
1618
|
+
* `formatError` is what every other CLI failure path already renders through.
|
|
1619
|
+
*/
|
|
1593
1620
|
function mlsFailureText(err, groupId) {
|
|
1594
1621
|
if (mlsErrorCode(err) === MLS_ERR_GROUP_INACTIVE) return evictedMessage(groupId);
|
|
1595
|
-
|
|
1622
|
+
if (isEpochConflict(err)) return epochConflictMessage(groupId);
|
|
1623
|
+
return formatError(err);
|
|
1596
1624
|
}
|
|
1597
1625
|
/**
|
|
1598
1626
|
* Report a best-effort MLS step that failed without failing the command.
|
|
@@ -1804,7 +1832,7 @@ function groupDetailRow(g, handles) {
|
|
|
1804
1832
|
* would make `Members` disagree with the table under it.
|
|
1805
1833
|
*
|
|
1806
1834
|
* An em dash is a server that does not report the field at all, on the same
|
|
1807
|
-
* distinction {@link
|
|
1835
|
+
* distinction {@link barCell} draws: "not yours" and "this build cannot tell
|
|
1808
1836
|
* you" are different facts, and printing `false` for the second would state
|
|
1809
1837
|
* something about another org's seat that nothing here knows.
|
|
1810
1838
|
*/
|
|
@@ -1858,37 +1886,75 @@ function voteEligibilityClause(r) {
|
|
|
1858
1886
|
}
|
|
1859
1887
|
}
|
|
1860
1888
|
/**
|
|
1861
|
-
* How
|
|
1862
|
-
*
|
|
1889
|
+
* How one bar of a vote stands, in one cell: votes cast, of the votes that bar
|
|
1890
|
+
* takes.
|
|
1891
|
+
*
|
|
1892
|
+
* 🔴 The wire carries a SHORTFALL — `approvals_needed` and `denials_needed` are
|
|
1893
|
+
* both "how many MORE it takes" — and this cell prints a THRESHOLD, which is the
|
|
1894
|
+
* shortfall added back onto what has been cast. The two are the same number only
|
|
1895
|
+
* while nothing has been cast, which is why `0 of 2` was right and `1 of 1` was
|
|
1896
|
+
* not: a bar rendered as cast-of-shortfall reads as met on every row somebody
|
|
1897
|
+
* has already voted on. The arithmetic is the server's and is correct; the
|
|
1898
|
+
* addition here is a rendering of it, not a second opinion about it.
|
|
1899
|
+
*
|
|
1900
|
+
* Both bars come from the same electorate, so each falls as members leave in
|
|
1901
|
+
* exactly the way the other does — a standing denial can refuse a request nobody
|
|
1902
|
+
* has voted on since, and a departure can carry one nobody has approved since.
|
|
1903
|
+
* That is also the one state where the threshold this prints sits UNDER what the
|
|
1904
|
+
* required count was when the vote opened, and printing it is the honest answer:
|
|
1905
|
+
* the bar as it stands now is the bar the next vote is measured against.
|
|
1906
|
+
*
|
|
1907
|
+
* A number the server did not report is an em dash and never a zero: "no more
|
|
1908
|
+
* votes are needed" and "this server does not report this bar" are different
|
|
1909
|
+
* facts, and printing `0` for the second would tell an operator the request is
|
|
1910
|
+
* one vote from resolving. A threshold cannot be known from half the pair, so an
|
|
1911
|
+
* unreported shortfall takes the dash on the right of the `of`, and an
|
|
1912
|
+
* unreported cast count takes it on both.
|
|
1863
1913
|
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1867
|
-
*
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1914
|
+
* 🔴 A shortfall of **zero** is the one case the addition cannot resolve, and it
|
|
1915
|
+
* is reachable: the server clamps at zero (`max(required - cast, 0)`,
|
|
1916
|
+
* `src/rine/api/group_vote_math.py`), so a request whose electorate shrank below
|
|
1917
|
+
* what it already holds reports `needed = 0` while still pending — nothing votes
|
|
1918
|
+
* again, so nothing resolves it. Adding gives `cast`, and printing that would
|
|
1919
|
+
* state a bar of 3 on a request whose bar is 2: the one number an operator
|
|
1920
|
+
* quotes, wrong, with the meaning ("met") still right. What the shortfall proves
|
|
1921
|
+
* is an upper bound and not a value, so the cell says exactly that much.
|
|
1870
1922
|
*/
|
|
1871
|
-
function
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
return `${
|
|
1923
|
+
function barCell(cast, needed) {
|
|
1924
|
+
if (cast === null && needed === null) return "—";
|
|
1925
|
+
if (cast !== null && needed === 0) return `${cast} of ${cast} or fewer`;
|
|
1926
|
+
const required = cast === null || needed === null ? null : cast + needed;
|
|
1927
|
+
return `${cast ?? "—"} of ${required ?? "—"}`;
|
|
1876
1928
|
}
|
|
1877
1929
|
/**
|
|
1878
1930
|
* One row per request, carrying the arithmetic a member needs before spending a
|
|
1879
1931
|
* call: approvals that count, how many more each bar wants, and how many
|
|
1880
1932
|
* eligible voters are still in the group.
|
|
1881
1933
|
*
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1934
|
+
* 🔴 `Approved` and `Denials` are ONE convention, read together: each is
|
|
1935
|
+
* {@link barCell}'s cast-of-threshold. They were two, and side by side the pair
|
|
1936
|
+
* `Approved 1 | Needed 1` read as "one of one, carried" on a request that was
|
|
1937
|
+
* still open — the approval bar printed its shortfall in a column of its own
|
|
1938
|
+
* while the denial bar printed a cell. Neither number was wrong; the two
|
|
1939
|
+
* spellings of the same fact were. `Needed` stays beside `Approved` as the
|
|
1940
|
+
* shortfall it always was — how many more calls resolve this — and now says the
|
|
1941
|
+
* same thing as the cell to its left rather than a different-looking one.
|
|
1942
|
+
*
|
|
1943
|
+
* The counts are null on an invitation, which nobody votes on, so `Approved`,
|
|
1944
|
+
* `Needed` and `Eligible` render blank there. `Denials` says `—` instead, on the
|
|
1945
|
+
* distinction {@link barCell} draws: it is the one cell whose emptiness could
|
|
1946
|
+
* otherwise be read as a zero.
|
|
1947
|
+
*
|
|
1948
|
+
* `Needed` is an em dash when no bar is reachable — everyone eligible has left,
|
|
1949
|
+
* and the request stands until it expires — and `Approved` is then `N of —` for
|
|
1950
|
+
* the same reason: what has been cast is known, what it would take is not.
|
|
1951
|
+
* `Denials` reports the other direction as one cell rather than a second
|
|
1952
|
+
* `Denied`/`Deny Needed` pair, because eleven columns is what a terminal shows
|
|
1953
|
+
* and twelve is not.
|
|
1888
1954
|
*
|
|
1889
1955
|
* A request a member filed on somebody else's behalf is born carrying that
|
|
1890
|
-
* member's own approval, so `Approved: 1` on an untouched row is
|
|
1891
|
-
*
|
|
1956
|
+
* member's own approval, so `Approved: 1 of 2` on an untouched row is ordinary
|
|
1957
|
+
* here and not a double count.
|
|
1892
1958
|
*/
|
|
1893
1959
|
function requestRow(r) {
|
|
1894
1960
|
const approvals = r.approvals ?? null;
|
|
@@ -1896,9 +1962,9 @@ function requestRow(r) {
|
|
|
1896
1962
|
"Request ID": r.id,
|
|
1897
1963
|
"Agent ID": r.agent_id,
|
|
1898
1964
|
Message: r.message ?? "",
|
|
1899
|
-
Approved: approvals
|
|
1965
|
+
Approved: approvals === null ? "" : barCell(approvals, r.approvals_needed ?? null),
|
|
1900
1966
|
Needed: approvals === null ? "" : r.approvals_needed ?? "—",
|
|
1901
|
-
Denials:
|
|
1967
|
+
Denials: barCell(r.denials ?? null, r.denials_needed ?? null),
|
|
1902
1968
|
Eligible: r.electorate_size ?? "",
|
|
1903
1969
|
"Your Vote": r.your_vote ?? "",
|
|
1904
1970
|
"Can Vote": voteEligibilityClause(r),
|
|
@@ -2048,7 +2114,7 @@ function printCreated$1(group, roster, admission, json, handles) {
|
|
|
2048
2114
|
}
|
|
2049
2115
|
}
|
|
2050
2116
|
function registerGroupCreate(program, group) {
|
|
2051
|
-
group.command("create").description("Create a new group").requiredOption("--name <name>", "Group name (DNS-safe slug)").option("--description <desc>", DESCRIPTION_HELP).option("--enrollment <policy>", "Enrollment policy (open|closed|majority|unanimity). `open` runs Sender Keys, which are NOT post-quantum").option("--visibility <vis>", "Required. `public` lists the group at dir.rine.network and turns the join signal off; `private` does neither").option("--member <id>", "Invite an agent into the new group (repeatable). A roster invites — it never seats — and it invites under every enrollment policy, because you are the only member at founding and a vote would auto-approve each row", collect, []).option("--isolated", "Isolate group communication").option("--vote-duration <hours>", VOTE_DURATION_RULE).action(withClient(program, async (ctx, opts) => {
|
|
2117
|
+
group.command("create").description("Create a new group").requiredOption("--name <name>", "Group name (DNS-safe slug)").option("--description <desc>", DESCRIPTION_HELP).option("--enrollment <policy>", "Enrollment policy (open|closed|majority|unanimity). `open` runs Sender Keys, which are NOT post-quantum").option("--visibility <vis>", "Required. `public` lists the group at dir.rine.network and turns the join signal off; `private` does neither").option("--member <id>", "Invite an agent into the new group (repeatable). A roster invites — it never seats — and it invites under every enrollment policy, because you are the only member at founding and a vote would auto-approve each row", collect, []).option("--isolated", "Isolate group communication").option("--vote-duration <hours>", VOTE_DURATION_RULE).addOption(actorOption("which agent is acting, and founds the group")).action(withClient(program, async (ctx, opts) => {
|
|
2052
2118
|
const refusal = visibilityRefusal(opts.visibility);
|
|
2053
2119
|
if (refusal) {
|
|
2054
2120
|
printError(refusal);
|
|
@@ -2103,7 +2169,7 @@ function registerGroupCrud(program, group) {
|
|
|
2103
2169
|
if (gOpts.json) printJson(data);
|
|
2104
2170
|
else printTable(data.items.map(groupRow));
|
|
2105
2171
|
}));
|
|
2106
|
-
group.command("get").description("Get group details").argument("<group-ref>", GROUP_REFERENCE_HELP).action(withClient(program, async (ctx, ref) => {
|
|
2172
|
+
group.command("get").description("Get group details").argument("<group-ref>", GROUP_REFERENCE_HELP).addOption(actorOption("which agent is acting, and whose eviction from this group is reported")).action(withClient(program, async (ctx, ref) => {
|
|
2107
2173
|
const { row: data } = await groupTarget(ctx, ref);
|
|
2108
2174
|
const evicted = await evictionState(ctx, data);
|
|
2109
2175
|
if (ctx.gOpts.json) {
|
|
@@ -2404,7 +2470,7 @@ async function coverageFor(ctx, groupId, memberIds) {
|
|
|
2404
2470
|
}
|
|
2405
2471
|
}
|
|
2406
2472
|
function registerGroupMembership(program, group) {
|
|
2407
|
-
group.command("members").description("List group members").argument("<group-ref>", GROUP_REFERENCE_HELP).action(withClient(program, async (ctx, ref) => {
|
|
2473
|
+
group.command("members").description("List group members").argument("<group-ref>", GROUP_REFERENCE_HELP).addOption(actorOption("which agent is acting, and whose sender-key coverage is reported")).action(withClient(program, async (ctx, ref) => {
|
|
2408
2474
|
const { id: groupId } = await groupTarget(ctx, ref);
|
|
2409
2475
|
let data;
|
|
2410
2476
|
try {
|
|
@@ -2424,7 +2490,7 @@ function registerGroupMembership(program, group) {
|
|
|
2424
2490
|
const warning = coverage ? coverageWarning(coverage) : "";
|
|
2425
2491
|
if (warning) printText(warning);
|
|
2426
2492
|
}));
|
|
2427
|
-
group.command("join").description("Join a group").argument("<group-ref>", GROUP_REFERENCE_HELP).option("--message <msg>", "Join request message").action(withClient(program, async (ctx, ref, opts) => {
|
|
2493
|
+
group.command("join").description("Join a group").argument("<group-ref>", GROUP_REFERENCE_HELP).addOption(actorOption("which agent joins the group")).option("--message <msg>", "Join request message").action(withClient(program, async (ctx, ref, opts) => {
|
|
2428
2494
|
const { id: groupId } = await joinGroupTarget(ctx, ref);
|
|
2429
2495
|
const body = {};
|
|
2430
2496
|
if (opts.message) body.message = opts.message;
|
|
@@ -2456,7 +2522,7 @@ function registerGroupMembership(program, group) {
|
|
|
2456
2522
|
if (wipe.retired) printText(retirementMessage(left, heldMlsState));
|
|
2457
2523
|
}
|
|
2458
2524
|
}));
|
|
2459
|
-
group.command("kick").description("Remove a member from the group (admin)").argument("<group-ref>", GROUP_REFERENCE_HELP).argument("<agent-id>", "Agent ID or handle to remove").action(withClient(program, async (ctx, ref, agentId) => {
|
|
2525
|
+
group.command("kick").description("Remove a member from the group (admin)").argument("<group-ref>", GROUP_REFERENCE_HELP).argument("<agent-id>", "Agent ID or handle to remove").addOption(actorOption("which agent is acting, and removes the member")).action(withClient(program, async (ctx, ref, agentId) => {
|
|
2460
2526
|
announceHandleCompletion(agentId);
|
|
2461
2527
|
const resolved = await resolveToUuid(ctx.apiUrl, agentId);
|
|
2462
2528
|
let groupId = ref;
|
|
@@ -2523,19 +2589,19 @@ function voteOutcomeSentence(status) {
|
|
|
2523
2589
|
}
|
|
2524
2590
|
}
|
|
2525
2591
|
function registerGroupRequests(program, group) {
|
|
2526
|
-
group.command("requests").description("List what this group still owes an answer on").argument("<group-ref>", GROUP_REFERENCE_HELP).option("--outstanding <filter>", "pending (the vote queue — requests agents filed for themselves and nominations members filed for them), invited (unaccepted invitations), or live (both)", "pending").action(withClient(program, async (ctx, ref, opts) => {
|
|
2592
|
+
group.command("requests").description("List what this group still owes an answer on").argument("<group-ref>", GROUP_REFERENCE_HELP).addOption(actorOption("which agent is asking, and whose vote the rows report")).option("--outstanding <filter>", "pending (the vote queue — requests agents filed for themselves and nominations members filed for them), invited (unaccepted invitations), or live (both)", "pending").action(withClient(program, async (ctx, ref, opts) => {
|
|
2527
2593
|
const { client, gOpts } = ctx;
|
|
2528
2594
|
const { id: groupId } = await groupTarget(ctx, ref);
|
|
2529
2595
|
const data = await client.get(`/groups/${groupId}/requests`, { outstanding: opts.outstanding });
|
|
2530
2596
|
if (gOpts.json) printJson(data);
|
|
2531
2597
|
else printTable(data.items.map(requestRow));
|
|
2532
2598
|
}));
|
|
2533
|
-
group.command("invites").description("List group invitations and nominations addressed to you. The Status column tells them apart: `invited` is a voucher `rine group join` spends, `pending` a nomination a member filed for you that the group's electorate decides — joining that one records that you want in and leaves the request with them.").action(withClient(program, async ({ client, gOpts, extraHeaders }) => {
|
|
2599
|
+
group.command("invites").description("List group invitations and nominations addressed to you. The Status column tells them apart: `invited` is a voucher `rine group join` spends, `pending` a nomination a member filed for you that the group's electorate decides — joining that one records that you want in and leaves the request with them.").addOption(actorOption("whose invitations and nominations to list")).action(withClient(program, async ({ client, gOpts, extraHeaders }) => {
|
|
2534
2600
|
const items = await listMyInvites(client, extraHeaders);
|
|
2535
2601
|
if (gOpts.json) printJson(items);
|
|
2536
2602
|
else printTable(items.map(inviteRow));
|
|
2537
2603
|
}));
|
|
2538
|
-
group.command("resume-admission").description("Seat every member and invitee this group has not seated yet").argument("<group-ref>", GROUP_REFERENCE_HELP).option("--reclaim", "Also retire ratchet-tree leaves no member and no live invitation or nomination accounts for — a lapsed invitation frees its seat but not its leaf. Costs one O(N) commit per leaf, billed to every member. Never automatic, and any member may run it: nothing retires a leaf until somebody does.").action(withClient(program, async (ctx, ref, opts) => {
|
|
2604
|
+
group.command("resume-admission").description("Seat every member and invitee this group has not seated yet").argument("<group-ref>", GROUP_REFERENCE_HELP).addOption(actorOption("which agent is acting, and seats the others")).option("--reclaim", "Also retire ratchet-tree leaves no member and no live invitation or nomination accounts for — a lapsed invitation frees its seat but not its leaf. Costs one O(N) commit per leaf, billed to every member. Never automatic, and any member may run it: nothing retires a leaf until somebody does.").action(withClient(program, async (ctx, ref, opts) => {
|
|
2539
2605
|
const { id: groupId, row: target } = await groupTarget(ctx, ref);
|
|
2540
2606
|
if (target.enrollment_policy === "open") {
|
|
2541
2607
|
printError(NOT_AN_MLS_GROUP);
|
|
@@ -2551,7 +2617,7 @@ function registerGroupRequests(program, group) {
|
|
|
2551
2617
|
process.exitCode = 1;
|
|
2552
2618
|
}
|
|
2553
2619
|
}));
|
|
2554
|
-
group.command("vote").description(`Vote on a join request. ${VOTE_ELECTORATE_RULE} \`rine group requests\` says whether your own vote counts before you spend a call on it. A vote that carries an agent's own application seats it; one that carries a nomination the agent has not answered yet turns it into an invitation for them to accept.`).argument("<group-ref>", GROUP_REFERENCE_HELP).argument("<request-id>", "Join request ID").requiredOption("--vote <vote>", "Vote: approve or deny").action(withClient(program, async (ctx, ref, requestId, opts) => {
|
|
2620
|
+
group.command("vote").description(`Vote on a join request. ${VOTE_ELECTORATE_RULE} \`rine group requests\` says whether your own vote counts before you spend a call on it. A vote that carries an agent's own application seats it; one that carries a nomination the agent has not answered yet turns it into an invitation for them to accept.`).argument("<group-ref>", GROUP_REFERENCE_HELP).argument("<request-id>", "Join request ID").addOption(actorOption("which agent casts the vote")).requiredOption("--vote <vote>", "Vote: approve or deny").action(withClient(program, async (ctx, ref, requestId, opts) => {
|
|
2555
2621
|
if (opts.vote !== "approve" && opts.vote !== "deny") {
|
|
2556
2622
|
printError("--vote must be 'approve' or 'deny'");
|
|
2557
2623
|
process.exitCode = 2;
|
|
@@ -2582,7 +2648,7 @@ async function seatApplicant(ctx, groupId, applicantId) {
|
|
|
2582
2648
|
//#endregion
|
|
2583
2649
|
//#region src/commands/group-sync.ts
|
|
2584
2650
|
function registerGroupSync(program, group) {
|
|
2585
|
-
group.command("sync").description("Catch this agent's group encryption state up, and say what it cost").argument("<group-ref>", GROUP_REFERENCE_HELP).action(withClient(program, async (ctx, ref) => {
|
|
2651
|
+
group.command("sync").description("Catch this agent's group encryption state up, and say what it cost").argument("<group-ref>", GROUP_REFERENCE_HELP).addOption(actorOption("which agent's group state is caught up")).action(withClient(program, async (ctx, ref) => {
|
|
2586
2652
|
const { row: target } = await groupTarget(ctx, ref);
|
|
2587
2653
|
const label = target.handle ?? target.id;
|
|
2588
2654
|
if (groupMlsInitInFlight(target)) {
|
|
@@ -3016,10 +3082,7 @@ async function openMessage(opts) {
|
|
|
3016
3082
|
refusal: null
|
|
3017
3083
|
};
|
|
3018
3084
|
} catch (err) {
|
|
3019
|
-
return { refusal:
|
|
3020
|
-
message: `Decryption failed: ${text(err)}`,
|
|
3021
|
-
code: null
|
|
3022
|
-
} };
|
|
3085
|
+
return { refusal: refusalFor(err, null) };
|
|
3023
3086
|
}
|
|
3024
3087
|
const groupId = data.group_id;
|
|
3025
3088
|
try {
|
|
@@ -3028,19 +3091,43 @@ async function openMessage(opts) {
|
|
|
3028
3091
|
refusal: null
|
|
3029
3092
|
};
|
|
3030
3093
|
} catch (err) {
|
|
3094
|
+
return { refusal: refusalFor(err, groupId) };
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
/**
|
|
3098
|
+
* Why the message stayed closed, chosen by the failure's machine-readable CODE
|
|
3099
|
+
* and never by its words.
|
|
3100
|
+
*
|
|
3101
|
+
* `groupId` is null for a 1:1 envelope, where no group arm can apply.
|
|
3102
|
+
*
|
|
3103
|
+
* `rine thread` has degraded correctly since it was written — a recognised
|
|
3104
|
+
* cause becomes a rine sentence, an unrecognised one becomes `[unavailable]` —
|
|
3105
|
+
* while this path interpolated whatever it caught. What that let through was
|
|
3106
|
+
* mls-rs's own KDF error, *the provided length of the key 0 is shorter than the
|
|
3107
|
+
* minimum length 32*: the crypto library refusing to derive from an epoch
|
|
3108
|
+
* secret this member never held. Same message, same agent, same moment, two
|
|
3109
|
+
* renderers, and the raw one was the outlier.
|
|
3110
|
+
*/
|
|
3111
|
+
function refusalFor(err, groupId) {
|
|
3112
|
+
if (groupId !== null) {
|
|
3031
3113
|
const unavailable = asSenderKeyUnavailable(err, groupId);
|
|
3032
|
-
if (unavailable !== null) return {
|
|
3114
|
+
if (unavailable !== null) return {
|
|
3033
3115
|
message: unavailable.message,
|
|
3034
3116
|
code: SENDER_KEY_UNAVAILABLE_CODE
|
|
3035
|
-
}
|
|
3036
|
-
|
|
3037
|
-
message:
|
|
3117
|
+
};
|
|
3118
|
+
if (mlsErrorCode(err) === MLS_ERR_GROUP_INACTIVE) return {
|
|
3119
|
+
message: mlsFailureText(err, groupId),
|
|
3038
3120
|
code: null
|
|
3039
|
-
}
|
|
3121
|
+
};
|
|
3122
|
+
if (isRecoverableMlsRead(err)) return {
|
|
3123
|
+
message: mlsReadRefusal(groupId, cliSyncRemedy(groupId)),
|
|
3124
|
+
code: null
|
|
3125
|
+
};
|
|
3040
3126
|
}
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3127
|
+
return {
|
|
3128
|
+
message: `Decryption failed: ${formatError(err)}`,
|
|
3129
|
+
code: null
|
|
3130
|
+
};
|
|
3044
3131
|
}
|
|
3045
3132
|
//#endregion
|
|
3046
3133
|
//#region src/commands/messages-rows.ts
|
|
@@ -3137,17 +3224,7 @@ function addReadCommand(parent, program) {
|
|
|
3137
3224
|
});
|
|
3138
3225
|
else {
|
|
3139
3226
|
if (decResult.catchUp?.evicted) printError(MLS_EVICTED_BY_COMMIT);
|
|
3140
|
-
printTable([
|
|
3141
|
-
ID: data.id,
|
|
3142
|
-
"Conversation ID": data.conversation_id,
|
|
3143
|
-
From: msgFrom(data),
|
|
3144
|
-
To: msgTo(data),
|
|
3145
|
-
Group: msgGroup(data),
|
|
3146
|
-
Type: data.type,
|
|
3147
|
-
Verified: verifiedMark(decResult.verificationStatus),
|
|
3148
|
-
Payload: decResult.plaintext?.slice(0, 200) ?? THREAD_UNAVAILABLE,
|
|
3149
|
-
Created: data.created_at
|
|
3150
|
-
}]);
|
|
3227
|
+
printTable([openedRow(data, verifiedMark(decResult.verificationStatus), decResult.plaintext?.slice(0, 200) ?? THREAD_UNAVAILABLE)]);
|
|
3151
3228
|
}
|
|
3152
3229
|
return;
|
|
3153
3230
|
}
|
|
@@ -3159,19 +3236,39 @@ function addReadCommand(parent, program) {
|
|
|
3159
3236
|
decrypt_error_code: refusal.code
|
|
3160
3237
|
} : {}
|
|
3161
3238
|
});
|
|
3239
|
+
else if (refusal !== null) printTable([openedRow(data, verifiedMark("unverifiable"), THREAD_UNAVAILABLE)]);
|
|
3162
3240
|
else printTable([{
|
|
3163
|
-
|
|
3164
|
-
"Conversation ID": data.conversation_id,
|
|
3165
|
-
From: msgFrom(data),
|
|
3166
|
-
To: msgTo(data),
|
|
3167
|
-
Group: msgGroup(data),
|
|
3168
|
-
Type: data.type,
|
|
3241
|
+
...readRow(data),
|
|
3169
3242
|
Encryption: data.encryption_version,
|
|
3170
3243
|
"Encrypted Payload": `${data.encrypted_payload.slice(0, 40)}...`,
|
|
3171
3244
|
Created: data.created_at
|
|
3172
3245
|
}]);
|
|
3173
3246
|
}));
|
|
3174
3247
|
}
|
|
3248
|
+
/** The columns every rendering of one read shares, in one order. */
|
|
3249
|
+
function readRow(data) {
|
|
3250
|
+
return {
|
|
3251
|
+
ID: data.id,
|
|
3252
|
+
"Conversation ID": data.conversation_id,
|
|
3253
|
+
From: msgFrom(data),
|
|
3254
|
+
To: msgTo(data),
|
|
3255
|
+
Group: msgGroup(data),
|
|
3256
|
+
Type: data.type
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
/**
|
|
3260
|
+
* One row for a message this read tried to open — whether it opened, withheld
|
|
3261
|
+
* its content or would not open at all. One shape for all three, so a refused
|
|
3262
|
+
* read and a successful one are read off the same columns.
|
|
3263
|
+
*/
|
|
3264
|
+
function openedRow(data, verified, payload) {
|
|
3265
|
+
return {
|
|
3266
|
+
...readRow(data),
|
|
3267
|
+
Verified: verified,
|
|
3268
|
+
Payload: payload,
|
|
3269
|
+
Created: data.created_at
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3175
3272
|
//#endregion
|
|
3176
3273
|
//#region src/commands/messages.ts
|
|
3177
3274
|
function resolvePayload(payload, payloadFile) {
|
|
@@ -3190,6 +3287,26 @@ function resolvePayload(payload, payloadFile) {
|
|
|
3190
3287
|
return { error: "Payload must be valid JSON" };
|
|
3191
3288
|
}
|
|
3192
3289
|
}
|
|
3290
|
+
/**
|
|
3291
|
+
* What a caller is told when the ID they typed named a group, not an agent.
|
|
3292
|
+
*
|
|
3293
|
+
* 🔴 It quotes the caller's own spelling and the handle the wire will carry,
|
|
3294
|
+
* and nothing else. A third handle would be a placeholder in a sentence about
|
|
3295
|
+
* a real send, and an `@org` slot for the caller to fill would advertise a
|
|
3296
|
+
* spelling this notice is not about.
|
|
3297
|
+
*
|
|
3298
|
+
* 🔴 It stays on this surface rather than moving into `@rine-network/core`,
|
|
3299
|
+
* for `GROUP_REFERENCE_HELP`'s reason (`group-target.ts`): a constant in the
|
|
3300
|
+
* shared package is a constant the Python stack is then expected to twin and a
|
|
3301
|
+
* gate is expected to hold, and this is one CLI's rendering of a substitution
|
|
3302
|
+
* the shared door discharges through its RETURN VALUE — `RecipientTarget`
|
|
3303
|
+
* carries `spelling` beside `handle` so every other surface can compare the
|
|
3304
|
+
* two and say it in its own idiom. Hoisting it would mint an obligation
|
|
3305
|
+
* nothing pays.
|
|
3306
|
+
*/
|
|
3307
|
+
function groupIdRecipientNote(spelling, handle) {
|
|
3308
|
+
return `Note: '${spelling}' is a group ID, so this was addressed to the group '${handle}' and not to an agent.`;
|
|
3309
|
+
}
|
|
3193
3310
|
async function encryptMlsWithRecovery(client, configDir, senderAgentId, groupId, payload) {
|
|
3194
3311
|
const hdrs = { [ACTING_AGENT_HEADER]: senderAgentId };
|
|
3195
3312
|
await processMlsWelcomes(configDir, senderAgentId, client).catch(() => {});
|
|
@@ -3207,7 +3324,7 @@ async function encryptMlsWithRecovery(client, configDir, senderAgentId, groupId,
|
|
|
3207
3324
|
}
|
|
3208
3325
|
function addMessageCommands(parent, program) {
|
|
3209
3326
|
addReadCommand(parent, program);
|
|
3210
|
-
parent.command("send").description("Send an encrypted message").requiredOption("--to <address>", "Recipient: an agent handle (kofi@acme.rine.network), an agent ID, or a group — by handle (#logistics@acme.rine.network)
|
|
3327
|
+
parent.command("send").description("Send an encrypted message").requiredOption("--to <address>", "Recipient: an agent handle (kofi@acme.rine.network), an agent ID, or a group — by handle (#logistics@acme.rine.network), by sigiled name (#logistics), or by the group's own ID").option("--type <type>", "Message type (default: rine.v1.dm)").option("--payload <json>", "Message payload as JSON string").option("--payload-file <path>", "Read payload JSON from file (use - for stdin)").addOption(actorOption("which agent is acting, and sends")).addOption(actorAliasOption("--from <address>", "which agent is acting — the retired spelling of --agent (handle or agent ID)")).option("--idempotency-key <key>", "Idempotency key header").option("--no-marker", "For x402 message types: omit the cleartext status marker").action(withClient(program, async (ctx, opts) => {
|
|
3211
3328
|
const { client, gOpts, configDir, apiUrl, actingAgent } = ctx;
|
|
3212
3329
|
const result = resolvePayload(opts.payload, opts.payloadFile);
|
|
3213
3330
|
if ("error" in result) {
|
|
@@ -3221,7 +3338,9 @@ function addMessageCommands(parent, program) {
|
|
|
3221
3338
|
const senderAgentId = await actingAgent();
|
|
3222
3339
|
const extraHeaders = {};
|
|
3223
3340
|
if (opts.idempotencyKey) extraHeaders["Idempotency-Key"] = opts.idempotencyKey;
|
|
3224
|
-
const
|
|
3341
|
+
const groupNamedById = UUID_RE.test(to) ? await readableGroupById(client, to) : void 0;
|
|
3342
|
+
const isGroupSend = to.startsWith("#") || groupNamedById !== void 0;
|
|
3343
|
+
if (groupNamedById !== void 0) printError(groupIdRecipientNote(opts.to, groupNamedById.handle));
|
|
3225
3344
|
let recipientAgentId;
|
|
3226
3345
|
if (isGroupSend) recipientAgentId = void 0;
|
|
3227
3346
|
else if (!to.includes("@")) recipientAgentId = to;
|
|
@@ -3241,14 +3360,14 @@ function addMessageCommands(parent, program) {
|
|
|
3241
3360
|
else body.to_agent_id = to;
|
|
3242
3361
|
if (from?.includes("@")) body.from_handle = from;
|
|
3243
3362
|
if (isGroupSend) {
|
|
3244
|
-
const group = await resolveGroupByHandle(client, to).catch(async (err) => {
|
|
3363
|
+
const group = groupNamedById ?? await resolveGroupByHandle(client, to).catch(async (err) => {
|
|
3245
3364
|
throw await withEvictionPointerIfHeld(ctx, err);
|
|
3246
3365
|
});
|
|
3247
3366
|
body.to_handle = group.handle;
|
|
3248
3367
|
const mlsOnly = groupAcceptsMlsSendOnly(group);
|
|
3249
3368
|
assertNoMlsDowngrade(configDir, senderAgentId, group.id, mlsOnly);
|
|
3250
3369
|
if (mlsOnly) {
|
|
3251
|
-
if (group.mls_group_id == null) throw new MlsInitInFlightError(
|
|
3370
|
+
if (group.mls_group_id == null) throw new MlsInitInFlightError(group.handle);
|
|
3252
3371
|
const encResult = await encryptMlsWithRecovery(client, configDir, senderAgentId, group.id, parsedPayload);
|
|
3253
3372
|
Object.assign(body, encResult);
|
|
3254
3373
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-network/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "CLI client for rine.network \u2014 EU-first messaging infrastructure for AI agents",
|
|
5
5
|
"author": "mmmbs <mmmbs@proton.me>",
|
|
6
6
|
"license": "EUPL-1.2",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dev": "tsx src/main.ts"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@rine-network/core": "^0.
|
|
31
|
+
"@rine-network/core": "^0.15.0",
|
|
32
32
|
"commander": "^12.0.0",
|
|
33
33
|
"eventsource-client": "^1.1.0"
|
|
34
34
|
},
|