@sjawhar/opencode-legion-envoy 1.29.1 → 1.30.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
@@ -28,8 +28,9 @@ This package exposes:
28
28
  - `dispatch_read`
29
29
  - `dispatch_search`
30
30
  - `dispatch_open_asks`
31
+ - `dispatch_whoami`
31
32
 
32
- The sixteen native `dispatch_*` tools create and read Dispatch issues, asks, comments,
33
+ The seventeen native `dispatch_*` tools create and read Dispatch issues, asks, comments,
33
34
  documents, and artifacts, or search all of them. They are present when `dispatch.enabled`
34
35
  resolves a server URL and bearer token from envoy.json (`~/.config/opencode/envoy.json`, merged
35
36
  with `<repo>/.opencode/envoy.json`) or the `DISPATCH_URL` and `DISPATCH_TOKEN` environment
@@ -13792,7 +13792,8 @@ var dispatchToolSpecs = [
13792
13792
  force: z.boolean().describe("Create even though POSSIBLE_DUPLICATE listed similar issues; pass it only after reading them.").optional(),
13793
13793
  spec: z.string().describe(`Optional initial primary-document markdown. ${SPEC_WRITING_GUIDANCE}`).optional(),
13794
13794
  labels: z.array(z.string({ min: 1, max: 40 }), { max: 20 }).describe("Optional initial labels, at most 20 labels of up to 40 characters.").optional(),
13795
- priority: z.number({ int: true, min: 0, max: 3 }).describe("Optional coarse priority: P0 is highest and P3 is lowest.").optional()
13795
+ priority: z.number({ int: true, min: 0, max: 3 }).describe("Optional coarse priority: P0 is highest and P3 is lowest.").optional(),
13796
+ assignee: z.string().describe("GitHub login of the human who answers this issue's asks; defaults to your owner when you act for a person, else the parent's assignee, else unassigned.").optional()
13796
13797
  })
13797
13798
  },
13798
13799
  {
@@ -13997,6 +13998,12 @@ var dispatchToolSpecs = [
13997
13998
  description: "List this session's active unanswered asks across issues and project documents, including age and whose reply is needed. Call before saying you are waiting for human input.",
13998
13999
  arguments: () => ({}),
13999
14000
  strict: true
14001
+ },
14002
+ {
14003
+ name: "dispatch_whoami",
14004
+ description: "Who Dispatch takes this session for: {session, owner}. owner is the lowercase GitHub login of the human whose personal token you run under (the default assignee of issues you create), or null under the shared token.",
14005
+ arguments: () => ({}),
14006
+ strict: true
14000
14007
  }
14001
14008
  ];
14002
14009
  // ../contracts/src/envelope.ts
@@ -14810,6 +14817,9 @@ class DispatchClient {
14810
14817
  ...since === undefined ? {} : { since }
14811
14818
  });
14812
14819
  }
14820
+ async whoami() {
14821
+ return this.#json("GET", ["api", "v1", "whoami"]);
14822
+ }
14813
14823
  async resolveAsk(id, input) {
14814
14824
  return this.#json("POST", ["api", "v1", "asks", id, "resolve"], input);
14815
14825
  }
@@ -15223,7 +15233,8 @@ var issueFreeTools = {
15223
15233
  dispatch_resolve_comment: true,
15224
15234
  dispatch_follow: true,
15225
15235
  dispatch_search: true,
15226
- dispatch_open_asks: true
15236
+ dispatch_open_asks: true,
15237
+ dispatch_whoami: true
15227
15238
  };
15228
15239
  function canonicalExternalIssueRef(value) {
15229
15240
  const match = value.trim().match(externalIssueRefPattern);
@@ -15639,10 +15650,13 @@ function issueSummary(issue, events, references, graph) {
15639
15650
  const specApproval = spec === undefined ? undefined : approvalLine(spec);
15640
15651
  if (issue.priority === undefined)
15641
15652
  throw new Error("Dispatch issue is missing priority");
15653
+ if (issue.assignee === undefined)
15654
+ throw new Error("Dispatch issue is missing assignee");
15642
15655
  return [
15643
15656
  `Title: ${issue.title}`,
15644
15657
  `Key: ${issue.key}`,
15645
15658
  `Status: ${issue.status}`,
15659
+ `Assignee: ${issue.assignee ?? "unassigned"}`,
15646
15660
  ...issue.priority === null ? [] : [`Priority: P${issue.priority}`],
15647
15661
  `Labels: ${issue.labels.length === 0 ? "none" : issue.labels.join(", ")}`,
15648
15662
  `Route: ${issue.route ?? "none"}`,
@@ -15890,6 +15904,18 @@ async function executeDispatchTool(input) {
15890
15904
  const response = await client.openAsks(sessionId);
15891
15905
  return { text: formatOpenAsksSummary(response, configUrl), details: { ...response } };
15892
15906
  }
15907
+ if (input.tool === "dispatch_whoami") {
15908
+ const sessionId = input.sessionId?.trim();
15909
+ if (!sessionId)
15910
+ throw new Error("host session id is required for dispatch_whoami");
15911
+ const client = new DispatchClient(configUrl, configToken, fetchImpl, input.signal);
15912
+ const identity = await client.whoami();
15913
+ const owner = identity.kind === "agent" ? identity.owner : identity.login.toLowerCase();
15914
+ return {
15915
+ text: owner === null ? `Session ${sessionId} runs under the shared token: no owner, so issues you create without an assignee are unassigned (or inherit their parent's).` : `Session ${sessionId} acts for ${owner}: issues you create without an assignee are assigned to ${owner}.`,
15916
+ details: { session: sessionId, owner }
15917
+ };
15918
+ }
15893
15919
  const args = parsed.success ? parsed.data : ownerArguments.args;
15894
15920
  const actor = toolActor(await resolveOrigin(env, exec, input.cwd), input);
15895
15921
  const client = new DispatchClient(configUrl, configToken, fetchImpl, input.signal);
@@ -15916,6 +15942,7 @@ async function executeDispatchTool(input) {
15916
15942
  const force = optionalBoolean(args, "force");
15917
15943
  const spec = optionalString(args, "spec");
15918
15944
  const priority = optionalNumber(args, "priority");
15945
+ const assignee = optionalString(args, "assignee");
15919
15946
  const labels = args.labels;
15920
15947
  try {
15921
15948
  const created = await client.issue({
@@ -15926,6 +15953,7 @@ async function executeDispatchTool(input) {
15926
15953
  ...force === undefined ? {} : { force },
15927
15954
  ...spec === undefined ? {} : { spec },
15928
15955
  ...priority === undefined ? {} : { priority },
15956
+ ...assignee === undefined ? {} : { assignee },
15929
15957
  ...Array.isArray(labels) ? { labels } : {},
15930
15958
  actor
15931
15959
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/opencode-legion-envoy",
3
- "version": "1.29.1",
3
+ "version": "1.30.0",
4
4
  "type": "module",
5
5
  "main": "dist/src/server.js",
6
6
  "exports": {
@@ -90,13 +90,21 @@ exactly one owner to every owner-scoped tool: `issue` for an issue, or `project`
90
90
  [References](#references) for the resulting ref shape). On first use, an external issue reference creates its native issue in the
91
91
  project configured for that repository in Dispatch Settings, then falls back to `DISPATCH_DEFAULT_PROJECT`.
92
92
 
93
- Issue reads include `rank`, the server-owned ordering key used by project boards; reorder through `PATCH /api/v1/issues/{key}` with neighboring issue keys. They also include nullable coarse priority (`P0` highest through `P3` lowest).
93
+ Issue reads include `rank`, the server-owned ordering key used by project boards; reorder through `PATCH /api/v1/issues/{key}` with neighboring issue keys. They also include nullable coarse priority (`P0` highest through `P3` lowest) and `assignee`: the lowercase GitHub login of the human who answers the issue's asks, or `null` when nobody holds it. `dispatch_read` of an issue prints it as `Assignee: <login>` or `Assignee: unassigned`.
94
+
95
+ ### Who answers an ask
96
+
97
+ An ask goes to the issue's assignee: their Inbox opens on **Mine**, which lists asks on the issues they hold plus an Unassigned band; an ask on an unassigned issue waits in that band for someone to take it. Find out who Dispatch takes you for with:
98
+ ```ts
99
+ dispatch_whoami({})
100
+ ```
101
+ It returns `details` `{ session, owner }`: `owner` is the lowercase login of the human whose personal token you run under, or `null` under the shared token. An issue you create without `assignee` goes to your owner; under the shared token it inherits its parent's assignee, or stays unassigned without a parent. If an issue you are asking on is unassigned and the answer matters, assign it to your owner (`PATCH /api/v1/issues/{key}` with `{"assignee": "<login>"}`; any authenticated caller may reassign, and an unlisted login is refused with `ASSIGNEE_NOT_ALLOWED`) or name in the question who should answer it. Never reassign an issue a human holds to get an answer faster: that is the human's call.
94
102
 
95
103
  Architects create newly tracked child work with:
96
104
  ```ts
97
- dispatch_issue({ project, title, parent?, external?, spec?, force?, labels?: string[], priority?: 0 | 1 | 2 | 3 })
105
+ dispatch_issue({ project, title, parent?, external?, spec?, force?, labels?: string[], priority?: 0 | 1 | 2 | 3, assignee?: string })
98
106
  ```
99
- `labels` are optional initial labels: Dispatch trims them, preserves their case, and removes case-insensitive duplicates. Set `priority` on creation only when the human's intent makes the bucket clear; otherwise priority remains the human's decision. It returns
107
+ `labels` are optional initial labels: Dispatch trims them, preserves their case, and removes case-insensitive duplicates. Set `priority` on creation only when the human's intent makes the bucket clear; otherwise priority remains the human's decision. Set `assignee` (a GitHub login on the sign-in allowlist) only when the human said who owns the work; otherwise the default above applies, so a child inherits its parent's assignee. It returns
100
108
  `details` `{ issue }`; creating an issue does not subscribe you to it (see [Following](#following)). Use `dispatch_issue` only to create an issue; never use it to park a question. When `spec` is supplied,
101
109
  follow [Writing a spec](#writing-a-spec).
102
110
 
@@ -75,7 +75,10 @@ exercise a criterion end to end, building that path is a child issue of this tre
75
75
  the role-token `<project>` (the daemon's own project, e.g. `acme`), a different string. A
76
76
  root session has `LEGION_TREE == LEGION_ISSUE`. The daemon establishes the sub-issue
77
77
  relationship from `parent`. Keep the returned issue keys in ordered waves; a child is
78
- inert until released.
78
+ inert until released. Do not pass `assignee`: the default keeps the tree's questions in one
79
+ Inbox — under the shared token a child inherits its parent's assignee (the human who
80
+ answers the tree's asks); under a personal token it goes to that token's owner, whom
81
+ `dispatch_whoami` names. Set it only when a human told you a specific person owns that child.
79
82
 
80
83
  Specifications written into Dispatch follow [`skills/dispatch`'s Writing a spec](../dispatch/SKILL.md#writing-a-spec).
81
84
  Wave releases, child closures, and your own status are visible from the issue tree and the
@@ -107,6 +107,9 @@ override a Sami ruling quoted here.
107
107
  1. Read `legion state --json`, then inspect the reported Dispatch issue with `dispatch_read`.
108
108
  Verify the issue is in this project, is eligible for a root process, and whether it
109
109
  has pre-existing children. Dispatch and daemon state, not the wake text, decide triage.
110
+ Note the `Assignee:` line: that human answers the tree's asks, and their Inbox opens on
111
+ the issues they hold. Never reassign during triage — who holds an issue is the humans'
112
+ decision, made from the issue header.
110
113
  2. If it should run now, admit the root issue:
111
114
 
112
115
  ```text
@@ -123,6 +126,11 @@ override a Sami ruling quoted here.
123
126
  (or `icebox` for longer-term deferral). Dispatch status is the durable record;
124
127
  there is no separate marker to maintain. Do not triage a system-created child as a root
125
128
  issue.
129
+ 4. When you post a triage note (a `dispatch_comment` on the issue saying what you decided and
130
+ why), name who will be asked: `Assigned to <login>, who will get this tree's questions`,
131
+ or, when the `Assignee:` line says `unassigned`, `Unassigned — nobody's Inbox shows this
132
+ tree's questions until someone takes it from the issue header (Assignee, beside Priority)`.
133
+ An unassigned root still runs; the architect's asks wait in every Inbox's Unassigned band.
126
134
 
127
135
  ## Backlog eligibility
128
136