@sjawhar/pi-envoy 14.0.2 → 14.2.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/README.md +18 -3
- package/dist/dispatch.js +273 -91
- package/dist/envoy.js +3287 -2441
- package/dist/skills/envoy/SKILL.md +1 -1
- package/dist/skills/envoy/references/deliveries.md +5 -3
- package/dist/skills/envoy/references/legion.md +2 -1
- package/dist/skills/envoy/references/roles.md +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,8 +20,10 @@ without one, and answers the sender with an error once four seconds pass without
|
|
|
20
20
|
topic published straight onto NATS is forwarded once, and a miss is a `receipt_timeout` exception.
|
|
21
21
|
The same route forwards a team or other ad-hoc topic's message to each session registered on the
|
|
22
22
|
topic that holds its own NATS connection, as this one does, other than its sender, and the sender's
|
|
23
|
-
error names each session that did not reply.
|
|
24
|
-
|
|
23
|
+
error names each session that did not reply. The stream stores each forward on the recipient's
|
|
24
|
+
agent subject, and when the listener supports consumer delivery that session takes the stored copy
|
|
25
|
+
once, also after a restart or a dropped connection (below). A role message is not kept for a later
|
|
26
|
+
claimant, and on the core path a session does not recover one it missed.
|
|
25
27
|
|
|
26
28
|
This extension claims the role for the session the host has open, and every automatic claim is
|
|
27
29
|
soft: it names the session it continues, which is a fork's or branch's parent, or the session
|
|
@@ -54,7 +56,20 @@ and `summary`) for recovery after an interrupt. `envoy_role_get` returns the cur
|
|
|
54
56
|
last-seen timestamp for a role. `envoy_subscribe` reports listener warnings in both its text and
|
|
55
57
|
details result, including subscriptions whose stream currently has no matching event.
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
The session's messages come from a durable consumer the listener keeps for it on Envoy's
|
|
60
|
+
notification stream and relays on `notifications.envoy.deliver.<session id>`, which
|
|
61
|
+
the session subscribes before it registers: its own agent subject, the stored copies of role
|
|
62
|
+
messages to a role it holds, and every followed topic the stream stores, in stream order. The
|
|
63
|
+
session answers each frame `received` as it decodes and `done` once Oh My Pi wrote the card or
|
|
64
|
+
turn to the session file, so a frame not written when the session stops, or published while it
|
|
65
|
+
was down or disconnected, comes again and is shown once, for up to 72 hours. Team and other
|
|
66
|
+
ad-hoc topics, which the stream does not store, stay live only on the session's own
|
|
67
|
+
subscription. "Consumer delivery" in `AGENTS.md` has the rules, and
|
|
68
|
+
`packages/envoy/AGENTS.md`, "Session consumers", states them once for every host.
|
|
69
|
+
|
|
70
|
+
The core path is the rollout fallback dispatch://INFRA-771 removes, for a listener that answers
|
|
71
|
+
`core` and for a plugin of an earlier release. There a message
|
|
72
|
+
published while the session's NATS connection or one of its subscriptions was down is
|
|
58
73
|
recovered from Envoy's notification stream, which keeps messages for 72 hours: the session asks
|
|
59
74
|
its listener (`POST /v1/replay`) for what the stream stored on its own agent subject and on each
|
|
60
75
|
topic it follows, after the place it last read to, and shows each missed message once, as a card
|
package/dist/dispatch.js
CHANGED
|
@@ -14861,93 +14861,6 @@ function itemFromSearch(search) {
|
|
|
14861
14861
|
return ask === null ? { id, kind: "comment" } : { id, kind: "ask" };
|
|
14862
14862
|
}
|
|
14863
14863
|
|
|
14864
|
-
// ../contracts/src/dispatch-block-ref.ts
|
|
14865
|
-
var encoder = new TextEncoder;
|
|
14866
|
-
function encodeBlockId(id) {
|
|
14867
|
-
let encoded = "";
|
|
14868
|
-
for (const character of id) {
|
|
14869
|
-
for (const byte of encoder.encode(character)) {
|
|
14870
|
-
const bare = byte >= 48 && byte <= 57 || byte >= 65 && byte <= 90 || byte >= 97 && byte <= 122 || byte === 45;
|
|
14871
|
-
encoded += bare ? String.fromCharCode(byte) : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
14872
|
-
}
|
|
14873
|
-
}
|
|
14874
|
-
return encoded;
|
|
14875
|
-
}
|
|
14876
|
-
function decodeBlockId(encoded) {
|
|
14877
|
-
if (encoded === "" || encoded.includes("@")) {
|
|
14878
|
-
return;
|
|
14879
|
-
}
|
|
14880
|
-
let id;
|
|
14881
|
-
try {
|
|
14882
|
-
id = decodeURIComponent(encoded);
|
|
14883
|
-
} catch {
|
|
14884
|
-
return;
|
|
14885
|
-
}
|
|
14886
|
-
return id === "" || hasControlCharacter(id) ? undefined : id;
|
|
14887
|
-
}
|
|
14888
|
-
var MAX_BLOCK_PIN = 9223372036854775807n;
|
|
14889
|
-
function parseBlockFragment(encoded) {
|
|
14890
|
-
const at = encoded.indexOf("@");
|
|
14891
|
-
const pin = at === -1 ? undefined : encoded.slice(at + 1).match(/^v([1-9][0-9]*)$/)?.[1];
|
|
14892
|
-
if (at !== -1 && (pin === undefined || BigInt(pin) > MAX_BLOCK_PIN)) {
|
|
14893
|
-
return;
|
|
14894
|
-
}
|
|
14895
|
-
const block = decodeBlockId(at === -1 ? encoded : encoded.slice(0, at));
|
|
14896
|
-
if (block === undefined) {
|
|
14897
|
-
return;
|
|
14898
|
-
}
|
|
14899
|
-
return pin === undefined ? { block } : { block, pin };
|
|
14900
|
-
}
|
|
14901
|
-
// ../contracts/src/dispatch-snippet.ts
|
|
14902
|
-
var HTML_ENTITIES = [
|
|
14903
|
-
["<", "<"],
|
|
14904
|
-
[">", ">"],
|
|
14905
|
-
["'", "'"],
|
|
14906
|
-
[""", '"'],
|
|
14907
|
-
["&", "&"]
|
|
14908
|
-
];
|
|
14909
|
-
function decodeEntities(text) {
|
|
14910
|
-
let decoded = text;
|
|
14911
|
-
for (const [entity, character] of HTML_ENTITIES) {
|
|
14912
|
-
decoded = decoded.replaceAll(entity, character);
|
|
14913
|
-
}
|
|
14914
|
-
return decoded;
|
|
14915
|
-
}
|
|
14916
|
-
function hasOnlyBalancedMarkers(snippet) {
|
|
14917
|
-
let marked = false;
|
|
14918
|
-
for (const marker of snippet.matchAll(/<mark>|<\/mark>/gu)) {
|
|
14919
|
-
if (marker[0] === "<mark>") {
|
|
14920
|
-
if (marked)
|
|
14921
|
-
return false;
|
|
14922
|
-
marked = true;
|
|
14923
|
-
} else {
|
|
14924
|
-
if (!marked)
|
|
14925
|
-
return false;
|
|
14926
|
-
marked = false;
|
|
14927
|
-
}
|
|
14928
|
-
}
|
|
14929
|
-
return !marked;
|
|
14930
|
-
}
|
|
14931
|
-
function snippetSegments(snippet) {
|
|
14932
|
-
if (!hasOnlyBalancedMarkers(snippet)) {
|
|
14933
|
-
return snippet === "" ? [] : [{ text: decodeEntities(snippet), mark: false }];
|
|
14934
|
-
}
|
|
14935
|
-
let mark = false;
|
|
14936
|
-
const segments = [];
|
|
14937
|
-
for (const part of snippet.split(/(<mark>|<\/mark>)/u)) {
|
|
14938
|
-
if (part === "<mark>") {
|
|
14939
|
-
mark = true;
|
|
14940
|
-
} else if (part === "</mark>") {
|
|
14941
|
-
mark = false;
|
|
14942
|
-
} else if (part !== "") {
|
|
14943
|
-
segments.push({ text: decodeEntities(part), mark });
|
|
14944
|
-
}
|
|
14945
|
-
}
|
|
14946
|
-
return segments;
|
|
14947
|
-
}
|
|
14948
|
-
function snippetText(snippet) {
|
|
14949
|
-
return snippetSegments(snippet).map(({ text, mark }) => mark ? `**${text}**` : text).join("");
|
|
14950
|
-
}
|
|
14951
14864
|
// ../contracts/src/dispatch-text-rules.ts
|
|
14952
14865
|
var SESSION_ID_PATTERN = "[^/?#\\s\\p{Z}\\p{Cc}<>\"'`\\[\\]|]+";
|
|
14953
14866
|
var sessionIdOnly = new RegExp(`^${SESSION_ID_PATTERN}$`, "u");
|
|
@@ -14963,6 +14876,7 @@ var PICTURE_TYPES = {
|
|
|
14963
14876
|
function isPictureType(mime) {
|
|
14964
14877
|
return PICTURE_TYPES[mime] === true;
|
|
14965
14878
|
}
|
|
14879
|
+
|
|
14966
14880
|
// ../contracts/src/dispatch-tools.ts
|
|
14967
14881
|
function dispatchToolSchema(spec, z, opts) {
|
|
14968
14882
|
const shape = spec.arguments(z);
|
|
@@ -15524,6 +15438,249 @@ var dispatchToolSpecs = [
|
|
|
15524
15438
|
strict: true
|
|
15525
15439
|
}
|
|
15526
15440
|
];
|
|
15441
|
+
|
|
15442
|
+
// ../contracts/src/dispatch-block-ref.ts
|
|
15443
|
+
var encoder = new TextEncoder;
|
|
15444
|
+
function encodeBlockId(id) {
|
|
15445
|
+
let encoded = "";
|
|
15446
|
+
for (const character of id) {
|
|
15447
|
+
for (const byte of encoder.encode(character)) {
|
|
15448
|
+
const bare = byte >= 48 && byte <= 57 || byte >= 65 && byte <= 90 || byte >= 97 && byte <= 122 || byte === 45;
|
|
15449
|
+
encoded += bare ? String.fromCharCode(byte) : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
15450
|
+
}
|
|
15451
|
+
}
|
|
15452
|
+
return encoded;
|
|
15453
|
+
}
|
|
15454
|
+
var MAX_BLOCK_ID_BYTES = 256;
|
|
15455
|
+
function decodeBlockId(encoded) {
|
|
15456
|
+
if (encoded === "" || encoded.includes("@")) {
|
|
15457
|
+
return;
|
|
15458
|
+
}
|
|
15459
|
+
let id;
|
|
15460
|
+
try {
|
|
15461
|
+
id = decodeURIComponent(encoded);
|
|
15462
|
+
} catch {
|
|
15463
|
+
return;
|
|
15464
|
+
}
|
|
15465
|
+
return id === "" || hasControlCharacter(id) ? undefined : id;
|
|
15466
|
+
}
|
|
15467
|
+
var MAX_BLOCK_PIN = 9223372036854775807n;
|
|
15468
|
+
function parseBlockFragment(encoded) {
|
|
15469
|
+
const at = encoded.indexOf("@");
|
|
15470
|
+
const pin = at === -1 ? undefined : encoded.slice(at + 1).match(/^v([1-9][0-9]*)$/)?.[1];
|
|
15471
|
+
if (at !== -1 && (pin === undefined || BigInt(pin) > MAX_BLOCK_PIN)) {
|
|
15472
|
+
return;
|
|
15473
|
+
}
|
|
15474
|
+
const block = decodeBlockId(at === -1 ? encoded : encoded.slice(0, at));
|
|
15475
|
+
if (block === undefined) {
|
|
15476
|
+
return;
|
|
15477
|
+
}
|
|
15478
|
+
return pin === undefined ? { block } : { block, pin };
|
|
15479
|
+
}
|
|
15480
|
+
var PROJECT_KEY = PROJECT_KEY_PATTERN.source.slice(1, -1);
|
|
15481
|
+
var ISSUE_KEY = `${PROJECT_KEY}-[1-9][0-9]*`;
|
|
15482
|
+
var DOCUMENT_SLUG = "[a-z0-9]+(?:-[a-z0-9]+)*";
|
|
15483
|
+
var ISSUE_KEY_ONLY = new RegExp(`^${ISSUE_KEY}$`);
|
|
15484
|
+
var BLOCK_REFERENCE = new RegExp(`^dispatch://(?:(${ISSUE_KEY})/spec|(${ISSUE_KEY}|${PROJECT_KEY})/artifact/(${DOCUMENT_SLUG}))#b-(.*)$`, "s");
|
|
15485
|
+
var ITEM_BLOCK_REFERENCE = new RegExp(`^dispatch://(?:${ISSUE_KEY}/(comment|message)|${PROJECT_KEY}/artifact/${DOCUMENT_SLUG}/(comment))/([^/?#]+)#b-(.*)$`, "s");
|
|
15486
|
+
var atIdBound = `dispatch://CORE-1/spec#b-${"x".repeat(MAX_BLOCK_ID_BYTES)}`;
|
|
15487
|
+
var DISPATCH_BLOCK_POINTER_VALUES = [
|
|
15488
|
+
{
|
|
15489
|
+
value: "dispatch://CORE-1/spec#b-x",
|
|
15490
|
+
ok: true,
|
|
15491
|
+
why: "a block of an issue's primary document"
|
|
15492
|
+
},
|
|
15493
|
+
{
|
|
15494
|
+
value: "dispatch://CORE-1/artifact/notes-md#b-x",
|
|
15495
|
+
ok: true,
|
|
15496
|
+
why: "a block of an issue's document"
|
|
15497
|
+
},
|
|
15498
|
+
{
|
|
15499
|
+
value: "dispatch://CORE/artifact/handbook-md#b-x",
|
|
15500
|
+
ok: true,
|
|
15501
|
+
why: "a block of a project's document"
|
|
15502
|
+
},
|
|
15503
|
+
{
|
|
15504
|
+
value: "dispatch://CORE/artifact/spec#b-x",
|
|
15505
|
+
ok: true,
|
|
15506
|
+
why: "a project's document whose slug is spec"
|
|
15507
|
+
},
|
|
15508
|
+
{ value: "dispatch://CORE-1/spec#b-d%C3%A9cision%3A1", ok: true, why: "a Unicode id" },
|
|
15509
|
+
{ value: "dispatch://CORE-1/spec#b-x@v2", ok: true, why: "a pinned block" },
|
|
15510
|
+
{ value: "dispatch://CORE-1/spec#b-x@v9223372036854775807", ok: true, why: "the largest pin" },
|
|
15511
|
+
{
|
|
15512
|
+
value: "dispatch://CORE-1/spec#b-x dispatch://CORE/artifact/handbook-md#b-y",
|
|
15513
|
+
ok: true,
|
|
15514
|
+
why: "two references separated by one space"
|
|
15515
|
+
},
|
|
15516
|
+
{ value: "", ok: true, why: "no pointers" },
|
|
15517
|
+
{ value: atIdBound, ok: true, why: "an id of exactly 256 bytes" },
|
|
15518
|
+
{
|
|
15519
|
+
value: "dispatch://CORE-1/artifact/spec#b-x",
|
|
15520
|
+
ok: false,
|
|
15521
|
+
why: "an issue's primary document is written /spec"
|
|
15522
|
+
},
|
|
15523
|
+
{ value: "dispatch://CORE-1/spec", ok: false, why: "a document, not a block" },
|
|
15524
|
+
{
|
|
15525
|
+
value: "dispatch://agent/s1/artifact/x#b-y",
|
|
15526
|
+
ok: false,
|
|
15527
|
+
why: "an agent's document has no blocks to point at"
|
|
15528
|
+
},
|
|
15529
|
+
{ value: "dispatch://CORE-1/spec#b-d%c3%a9", ok: false, why: "lower-case hex" },
|
|
15530
|
+
{ value: "dispatch://CORE-1/spec#b-%41", ok: false, why: "an over-encoded ASCII letter" },
|
|
15531
|
+
{ value: "dispatch://CORE-1/spec#b-x%2Dy", ok: false, why: "an over-encoded -" },
|
|
15532
|
+
{ value: "dispatch://CORE-1/spec#b-%FF", ok: false, why: "invalid UTF-8" },
|
|
15533
|
+
{ value: "dispatch://CORE-1/spec#b-%0A", ok: false, why: "a control character" },
|
|
15534
|
+
{ value: "dispatch://CORE-1/spec#x", ok: false, why: "a fragment that is not b-" },
|
|
15535
|
+
{ value: "dispatch://CORE-1/spec#c-x", ok: false, why: "a fragment that is not b-" },
|
|
15536
|
+
{ value: "dispatch://CORE-1/spec#b-", ok: false, why: "an empty id" },
|
|
15537
|
+
{ value: `${atIdBound}x`, ok: false, why: "an id over 256 bytes" },
|
|
15538
|
+
{ value: "dispatch://CORE-1/artifact/notes-md@v2#b-x", ok: false, why: "a versioned document" },
|
|
15539
|
+
{ value: "dispatch://CORE-1#b-x", ok: false, why: "an issue names no document" },
|
|
15540
|
+
{
|
|
15541
|
+
value: "dispatch://CORE-1/spec#b-x@v9223372036854775808",
|
|
15542
|
+
ok: false,
|
|
15543
|
+
why: "a pin past the largest"
|
|
15544
|
+
},
|
|
15545
|
+
{ value: "dispatch://CORE-1/spec#b-x@v01", ok: false, why: "a pin with a leading zero" },
|
|
15546
|
+
{ value: "dispatch://CORE-1/spec#b-x@v0", ok: false, why: "a pin of zero" },
|
|
15547
|
+
{
|
|
15548
|
+
value: "https://dispatch.example/issues/CORE-1/spec#b-x",
|
|
15549
|
+
ok: false,
|
|
15550
|
+
why: "a dashboard URL of a block"
|
|
15551
|
+
},
|
|
15552
|
+
{ value: "dispatch://CORE-1/spec#b-x.", ok: false, why: "trailing punctuation" },
|
|
15553
|
+
{ value: "dispatch://CORE-1/spec#b-x)", ok: false, why: "a trailing parenthesis" },
|
|
15554
|
+
{
|
|
15555
|
+
value: "dispatch://CORE-1/spec#b-x,dispatch://CORE-1/spec#b-y",
|
|
15556
|
+
ok: false,
|
|
15557
|
+
why: "references joined by a comma"
|
|
15558
|
+
},
|
|
15559
|
+
{
|
|
15560
|
+
value: "dispatch://CORE-1/spec#b-x dispatch://CORE-1/spec#b-x",
|
|
15561
|
+
ok: false,
|
|
15562
|
+
why: "a repeated reference"
|
|
15563
|
+
},
|
|
15564
|
+
{
|
|
15565
|
+
value: "dispatch://CORE-1/spec#b-x dispatch://CORE-1/spec#b-y",
|
|
15566
|
+
ok: false,
|
|
15567
|
+
why: "a doubled space"
|
|
15568
|
+
},
|
|
15569
|
+
{ value: " dispatch://CORE-1/spec#b-x", ok: false, why: "a leading space" },
|
|
15570
|
+
{ value: "dispatch://CORE-1/spec#b-x ", ok: false, why: "a trailing space" },
|
|
15571
|
+
{
|
|
15572
|
+
value: "dispatch://CORE-1/spec#b-x\tdispatch://CORE-1/spec#b-y",
|
|
15573
|
+
ok: false,
|
|
15574
|
+
why: "a tab between references"
|
|
15575
|
+
},
|
|
15576
|
+
{
|
|
15577
|
+
value: "dispatch://CORE-1/spec#b-x\uFEFFdispatch://CORE-1/spec#b-y",
|
|
15578
|
+
ok: false,
|
|
15579
|
+
why: "U+FEFF between references"
|
|
15580
|
+
},
|
|
15581
|
+
{
|
|
15582
|
+
value: "dispatch://CORE-1/comment/11111111-1111-4111-8111-111111111111#b-b2",
|
|
15583
|
+
ok: false,
|
|
15584
|
+
why: "a block of an issue's comment",
|
|
15585
|
+
problem: "a block[] attribute points only at a block of a document"
|
|
15586
|
+
},
|
|
15587
|
+
{
|
|
15588
|
+
value: "dispatch://CORE-1/comment/11111111-1111-4111-8111-111111111111#b-b2@v1",
|
|
15589
|
+
ok: false,
|
|
15590
|
+
why: "a block of a revision of an issue's comment",
|
|
15591
|
+
problem: "a block[] attribute points only at a block of a document"
|
|
15592
|
+
},
|
|
15593
|
+
{
|
|
15594
|
+
value: "dispatch://CORE/artifact/handbook-md/comment/88888888-8888-4888-8888-888888888888#b-b2",
|
|
15595
|
+
ok: false,
|
|
15596
|
+
why: "a block of a project document's comment",
|
|
15597
|
+
problem: "a block[] attribute points only at a block of a document"
|
|
15598
|
+
},
|
|
15599
|
+
{
|
|
15600
|
+
value: "dispatch://CORE-1/message/33333333-3333-4333-8333-333333333333#b-b2",
|
|
15601
|
+
ok: false,
|
|
15602
|
+
why: "a block of an issue message",
|
|
15603
|
+
problem: "a block[] attribute points only at a block of a document"
|
|
15604
|
+
},
|
|
15605
|
+
{
|
|
15606
|
+
value: "dispatch://CORE-1/artifact/notes-md/comment/c1#b-x",
|
|
15607
|
+
ok: false,
|
|
15608
|
+
why: "an issue document's comment, a shape no reference has",
|
|
15609
|
+
problem: "is not a block reference as Dispatch writes one"
|
|
15610
|
+
},
|
|
15611
|
+
{
|
|
15612
|
+
value: "dispatch://CORE-1/comment/%ZZ#b-x",
|
|
15613
|
+
ok: false,
|
|
15614
|
+
why: "a comment id that does not decode",
|
|
15615
|
+
problem: "is not a block reference as Dispatch writes one"
|
|
15616
|
+
},
|
|
15617
|
+
{
|
|
15618
|
+
value: "dispatch://CORE-1/spec#b-x dispatch://CORE-1/message/33333333-3333-4333-8333-333333333333#b-b2",
|
|
15619
|
+
ok: false,
|
|
15620
|
+
why: "a document's block, then an issue message's",
|
|
15621
|
+
problem: "a block[] attribute points only at a block of a document"
|
|
15622
|
+
}
|
|
15623
|
+
];
|
|
15624
|
+
var TYPED_BLOCK_ID_SHORTCUT_EXCLUDED = `
|
|
15625
|
+
\r "#&'.<=>\`}`;
|
|
15626
|
+
function typedBlockIdAttribute(id) {
|
|
15627
|
+
if (id !== "" && ![...TYPED_BLOCK_ID_SHORTCUT_EXCLUDED].some((stop) => id.includes(stop))) {
|
|
15628
|
+
return `#${id}`;
|
|
15629
|
+
}
|
|
15630
|
+
const value = id.replaceAll("&", "&").replaceAll('"', """).replaceAll(`
|
|
15631
|
+
`, "
").replaceAll("\r", "
");
|
|
15632
|
+
return `id="${value}"`;
|
|
15633
|
+
}
|
|
15634
|
+
// ../contracts/src/dispatch-snippet.ts
|
|
15635
|
+
var HTML_ENTITIES = [
|
|
15636
|
+
["<", "<"],
|
|
15637
|
+
[">", ">"],
|
|
15638
|
+
["'", "'"],
|
|
15639
|
+
[""", '"'],
|
|
15640
|
+
["&", "&"]
|
|
15641
|
+
];
|
|
15642
|
+
function decodeEntities(text) {
|
|
15643
|
+
let decoded = text;
|
|
15644
|
+
for (const [entity, character] of HTML_ENTITIES) {
|
|
15645
|
+
decoded = decoded.replaceAll(entity, character);
|
|
15646
|
+
}
|
|
15647
|
+
return decoded;
|
|
15648
|
+
}
|
|
15649
|
+
function hasOnlyBalancedMarkers(snippet) {
|
|
15650
|
+
let marked = false;
|
|
15651
|
+
for (const marker of snippet.matchAll(/<mark>|<\/mark>/gu)) {
|
|
15652
|
+
if (marker[0] === "<mark>") {
|
|
15653
|
+
if (marked)
|
|
15654
|
+
return false;
|
|
15655
|
+
marked = true;
|
|
15656
|
+
} else {
|
|
15657
|
+
if (!marked)
|
|
15658
|
+
return false;
|
|
15659
|
+
marked = false;
|
|
15660
|
+
}
|
|
15661
|
+
}
|
|
15662
|
+
return !marked;
|
|
15663
|
+
}
|
|
15664
|
+
function snippetSegments(snippet) {
|
|
15665
|
+
if (!hasOnlyBalancedMarkers(snippet)) {
|
|
15666
|
+
return snippet === "" ? [] : [{ text: decodeEntities(snippet), mark: false }];
|
|
15667
|
+
}
|
|
15668
|
+
let mark = false;
|
|
15669
|
+
const segments = [];
|
|
15670
|
+
for (const part of snippet.split(/(<mark>|<\/mark>)/u)) {
|
|
15671
|
+
if (part === "<mark>") {
|
|
15672
|
+
mark = true;
|
|
15673
|
+
} else if (part === "</mark>") {
|
|
15674
|
+
mark = false;
|
|
15675
|
+
} else if (part !== "") {
|
|
15676
|
+
segments.push({ text: decodeEntities(part), mark });
|
|
15677
|
+
}
|
|
15678
|
+
}
|
|
15679
|
+
return segments;
|
|
15680
|
+
}
|
|
15681
|
+
function snippetText(snippet) {
|
|
15682
|
+
return snippetSegments(snippet).map(({ text, mark }) => mark ? `**${text}**` : text).join("");
|
|
15683
|
+
}
|
|
15527
15684
|
// ../contracts/src/envelope.ts
|
|
15528
15685
|
var isSubject = (value) => typeof value === "string" && value.length > 0;
|
|
15529
15686
|
var EnvelopeSchema = object({
|
|
@@ -15912,7 +16069,7 @@ function parseCommand(argv, io) {
|
|
|
15912
16069
|
for (let index = 0;index < rest.length; index++) {
|
|
15913
16070
|
const token = rest[index];
|
|
15914
16071
|
if (!token.startsWith("--")) {
|
|
15915
|
-
if (
|
|
16072
|
+
if (ISSUE_KEY2.test(token) && surface.flags.has("--issue")) {
|
|
15916
16073
|
if (index === 0) {
|
|
15917
16074
|
if (claim("issue", `the issue key ${token}`, false))
|
|
15918
16075
|
args["issue"] = token;
|
|
@@ -16031,7 +16188,7 @@ function appendedItem(kind, flag, value, number) {
|
|
|
16031
16188
|
const parsed = number(flag, value);
|
|
16032
16189
|
return parsed === undefined ? undefined : { value: parsed };
|
|
16033
16190
|
}
|
|
16034
|
-
var
|
|
16191
|
+
var ISSUE_KEY2 = /^[A-Z][A-Z0-9]*-\d+$/;
|
|
16035
16192
|
function quoteWord(value) {
|
|
16036
16193
|
return BARE_WORD.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
16037
16194
|
}
|
|
@@ -19523,7 +19680,8 @@ async function refuseOpenDecisionBlocks(client, tool, resolved) {
|
|
|
19523
19680
|
const stillOpen = (named, state) => state === "answered" ? `${named}, answered but still open in version ${latest}: it settles into a version on its own in about two seconds; wait for that version` : `${named}, ${state} but still open in version ${latest}: write the decision into the text with dispatch doc-edit, which writes a version that carries it`;
|
|
19524
19681
|
const open = blocks.flatMap((block) => {
|
|
19525
19682
|
const ask = asks.get(block.id);
|
|
19526
|
-
const
|
|
19683
|
+
const id = typedBlockIdAttribute(block.id);
|
|
19684
|
+
const openers = lines.filter((line) => line.includes(`ask{${id} `) || line.includes(`ask{${id}}`));
|
|
19527
19685
|
const states = openers.map((line) => /\bstate="(\w+)"/.exec(line)?.[1]);
|
|
19528
19686
|
const named = ask === undefined ? `block ${block.id}` : `${JSON.stringify(ask.question)} (block ${block.id}, ask ${ask.id})`;
|
|
19529
19687
|
if (states.length === 0)
|
|
@@ -21615,6 +21773,15 @@ var InterestWireSchema = object({
|
|
|
21615
21773
|
updated_at: number2().int().optional(),
|
|
21616
21774
|
warnings: array(string2()).optional()
|
|
21617
21775
|
});
|
|
21776
|
+
var DeliveryAnswerWireSchema = discriminatedUnion("mode", [
|
|
21777
|
+
object({
|
|
21778
|
+
mode: literal("consumer"),
|
|
21779
|
+
subject: string2().min(1),
|
|
21780
|
+
stream_id: string2(),
|
|
21781
|
+
gap: boolean2()
|
|
21782
|
+
}),
|
|
21783
|
+
object({ mode: literal("core"), reason: string2() })
|
|
21784
|
+
]);
|
|
21618
21785
|
var SessionWireSchema = object({
|
|
21619
21786
|
session_id: string2(),
|
|
21620
21787
|
machine_id: string2(),
|
|
@@ -21670,6 +21837,20 @@ var ReplayWireSchema = object({
|
|
|
21670
21837
|
refused: string2().optional()
|
|
21671
21838
|
}))
|
|
21672
21839
|
});
|
|
21840
|
+
var DELIVERY_NOT_ANSWERED = "not_answered";
|
|
21841
|
+
var DELIVERY_UNREADABLE = "unreadable_answer";
|
|
21842
|
+
function parseSubscribeAnswer(body) {
|
|
21843
|
+
const interest = InterestWireSchema.parse(body);
|
|
21844
|
+
const raw = typeof body === "object" && body !== null && "delivery" in body ? body.delivery : undefined;
|
|
21845
|
+
if (raw === undefined || raw === null) {
|
|
21846
|
+
return { ...interest, delivery: { mode: "core", reason: DELIVERY_NOT_ANSWERED } };
|
|
21847
|
+
}
|
|
21848
|
+
const delivery = DeliveryAnswerWireSchema.safeParse(raw);
|
|
21849
|
+
return {
|
|
21850
|
+
...interest,
|
|
21851
|
+
delivery: delivery.success ? delivery.data : { mode: "core", reason: DELIVERY_UNREADABLE }
|
|
21852
|
+
};
|
|
21853
|
+
}
|
|
21673
21854
|
function expandSubscriptionTopics(topics) {
|
|
21674
21855
|
const expanded = new Set;
|
|
21675
21856
|
for (const topic of topics) {
|
|
@@ -21755,7 +21936,7 @@ function createEnvoyClient(config) {
|
|
|
21755
21936
|
body: JSON.stringify(body)
|
|
21756
21937
|
}, options);
|
|
21757
21938
|
return {
|
|
21758
|
-
subscribe: async (input) =>
|
|
21939
|
+
subscribe: async (input) => parseSubscribeAnswer(JSON.parse(await post("/v1/interests/subscribe", {
|
|
21759
21940
|
session_id: input.sessionID,
|
|
21760
21941
|
dir: input.directory,
|
|
21761
21942
|
topics: expandSubscriptionTopics(input.topics),
|
|
@@ -21764,6 +21945,7 @@ function createEnvoyClient(config) {
|
|
|
21764
21945
|
...input.capabilities === undefined ? {} : { capabilities: input.capabilities },
|
|
21765
21946
|
driving: input.driving,
|
|
21766
21947
|
...input.selfSubscribed === undefined ? {} : { self_subscribed: input.selfSubscribed },
|
|
21948
|
+
...input.delivery === undefined ? {} : { delivery: input.delivery },
|
|
21767
21949
|
...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID },
|
|
21768
21950
|
host: machineID(),
|
|
21769
21951
|
plugin: input.plugin.name,
|