@sjawhar/pi-envoy 13.11.0 → 13.12.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 CHANGED
@@ -23,6 +23,21 @@ topic that holds its own NATS connection, as this one does, other than its sende
23
23
  error names each session that did not reply. Role messages are live only; they are not retained
24
24
  for a later claimant, and a session does not recover one it missed.
25
25
 
26
+ This extension claims the role for the session the host has open, and every automatic claim is
27
+ soft: it names the session it continues, which is a fork's or branch's parent, or the session
28
+ this process last held the role under. The listener moves the role off that predecessor only
29
+ when the predecessor has no live registration, when its live registration carries this extension
30
+ instance's own client instance id, or when either side carries no instance id. A predecessor
31
+ another process still runs keeps the role, and the claim is refused naming that holder. A refused
32
+ session keeps running and stays registered, without the role: it does not claim again at each
33
+ heartbeat, and it takes the role on its next session event once the holder is gone. Each
34
+ extension instance mints its client instance id when it starts and sends it on every registration
35
+ and on the deregistration at shutdown, where the listener removes the registration only while it
36
+ carries the same id or none. The queues, deadlines and shared role state behind all of this are
37
+ `src/registration-state.ts`, beside the extension's other `src/` modules: a queued task acts
38
+ through a handle that refuses every step past the task's deadline, or once its session is no
39
+ longer the open session.
40
+
26
41
  `envoy_list()` shows the union of the local subscriptions and the listener's persisted interest
27
42
  registry. Each reported interest identifies whether it is `live`, `registry`, or `both`, so
28
43
  temporary registration drift does not hide the extension's actual delivery state.
package/dist/dispatch.js CHANGED
@@ -15519,7 +15519,7 @@ var dispatchToolSpecs = [
15519
15519
  {
15520
15520
  name: "dispatch_whoami",
15521
15521
  example: {},
15522
- description: "Who Dispatch takes this session for: {session, owner}. owner is the lowercase email of the person whose personal token you run under (the first choice of assignee for issues you create), or null under the shared token, in which case a create with no assignee falls back to the parent's assignee and then to the project's default assignee.",
15522
+ description: "Who Dispatch takes this session for: {session, owner, service, project}. session is the session Dispatch records your writes as. It is the session your credential proved, and the tool says so when that is not the session you run in. owner is the lowercase email of the person you act for, and is the first choice of assignee for issues you create. owner is null under the shared token. With a null owner, a create with no assignee falls back to the parent's assignee and then to the project's default assignee. service is the subject of the verified service-account token that authenticated you, or null. project is the one project key your credential may write, or null when it names none.",
15523
15523
  arguments: () => ({}),
15524
15524
  strict: true
15525
15525
  }
@@ -19704,10 +19704,16 @@ async function executeDispatchTool(input) {
19704
19704
  const identity = await client.whoami();
19705
19705
  const owner = identity.kind === "agent" ? identity.owner : identity.login.toLowerCase();
19706
19706
  const service = identity.kind === "agent" ? identity.service ?? null : null;
19707
+ const proved = identity.kind === "agent" ? identity.session ?? null : null;
19708
+ const project = identity.kind === "agent" ? identity.project ?? null : null;
19709
+ const session = proved ?? sessionId;
19707
19710
  const unowned = "no owner, so an issue you create without an assignee takes its parent's assignee, else the project's default assignee, else nobody.";
19711
+ const acting = owner !== null ? `Session ${session} acts for ${owner}: issues you create without an assignee are assigned to ${owner}.` : service !== null ? `Session ${session} runs as service ${serviceSubjectLabel(service)}: ${unowned}` : `Session ${session} runs under the shared token: ${unowned}`;
19712
+ const elsewhere = proved !== null && proved !== sessionId ? ` Your credential names session ${proved}, which is not this host session (${sessionId}): Dispatch records every write you make as ${proved}.` : "";
19713
+ const writable = project !== null ? ` It may write project ${project} and no other.` : "";
19708
19714
  return {
19709
- text: owner !== null ? `Session ${sessionId} acts for ${owner}: issues you create without an assignee are assigned to ${owner}.` : service !== null ? `Session ${sessionId} runs as service ${serviceSubjectLabel(service)}: ${unowned}` : `Session ${sessionId} runs under the shared token: ${unowned}`,
19710
- details: { session: sessionId, owner, service }
19715
+ text: acting + elsewhere + writable,
19716
+ details: { session, owner, service, project }
19711
19717
  };
19712
19718
  }
19713
19719
  const args = checked.args;
@@ -21759,6 +21765,7 @@ function createEnvoyClient(config) {
21759
21765
  ...input.capabilities === undefined ? {} : { capabilities: input.capabilities },
21760
21766
  driving: input.driving,
21761
21767
  ...input.selfSubscribed === undefined ? {} : { self_subscribed: input.selfSubscribed },
21768
+ ...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID },
21762
21769
  host: machineID(),
21763
21770
  plugin: input.plugin.name,
21764
21771
  plugin_version: input.plugin.version
@@ -21802,8 +21809,11 @@ function createEnvoyClient(config) {
21802
21809
  ...response.holder === undefined ? {} : { holder: response.holder }
21803
21810
  };
21804
21811
  },
21805
- unregisterSession: async (sessionID) => {
21806
- await request(`/v1/sessions/${encodeURIComponent(sessionID)}`, { method: "DELETE" });
21812
+ unregisterSession: async (input) => {
21813
+ const query = input.clientInstanceID === undefined ? "" : `?client_instance_id=${encodeURIComponent(input.clientInstanceID)}`;
21814
+ await request(`/v1/sessions/${encodeURIComponent(input.sessionID)}${query}`, {
21815
+ method: "DELETE"
21816
+ });
21807
21817
  },
21808
21818
  setRole: async (input) => {
21809
21819
  const soft = input.soft === true;