@allocator-one/harness-cli 1.14.0 → 1.15.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.
@@ -4,20 +4,27 @@ import {
4
4
  CLI_VERSION,
5
5
  CONDITION_KINDS,
6
6
  Client,
7
+ GATE_OWNER_ROLES,
7
8
  HttpError,
8
9
  IDEMPOTENCY_KEY_FORMAT,
10
+ JOBS_MAX_LIMIT,
11
+ JOB_STATES,
12
+ JOB_STATUS_ALIASES,
9
13
  MAX_IDEMPOTENCY_KEY_BYTES,
10
14
  PLAN_EXECUTORS,
11
15
  RELATION_CREATE_TYPES,
12
16
  RELATION_UPDATE_TYPES,
17
+ STEER_MAX_CHARACTERS,
13
18
  TransportError,
14
19
  UsageError,
15
20
  activity,
16
21
  archive,
22
+ assignments,
17
23
  blocked,
18
24
  close,
19
25
  comment,
20
26
  comments,
27
+ conditionList,
21
28
  create,
22
29
  deleteComment,
23
30
  dep,
@@ -27,7 +34,14 @@ import {
27
34
  docUpdate,
28
35
  editComment,
29
36
  errorDetails,
37
+ explainExpertRefusal,
30
38
  gateSet,
39
+ jobCancel,
40
+ jobContinue,
41
+ jobPause,
42
+ jobShow,
43
+ jobSteer,
44
+ jobsList,
31
45
  labelCreate,
32
46
  labelDelete,
33
47
  labelList,
@@ -47,6 +61,9 @@ import {
47
61
  planHold,
48
62
  planRelease,
49
63
  planShow,
64
+ procedureRun,
65
+ procedureSave,
66
+ procedureShow,
50
67
  projectCreate,
51
68
  projectList,
52
69
  projectShow,
@@ -59,6 +76,7 @@ import {
59
76
  resolveConfig,
60
77
  search,
61
78
  show,
79
+ skillsList,
62
80
  stateAdd,
63
81
  stateDelete,
64
82
  stateOrder,
@@ -68,11 +86,13 @@ import {
68
86
  teamList,
69
87
  teamRename,
70
88
  teamSetDefault,
89
+ toolsList,
90
+ toolsSearch,
71
91
  update,
72
92
  upload,
73
93
  userList,
74
94
  workflowStates
75
- } from "./chunk-F2YVTB2A.js";
95
+ } from "./chunk-I2S2JVCQ.js";
76
96
 
77
97
  // src/mcp/server.ts
78
98
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -95,8 +115,11 @@ function toolError(message) {
95
115
  return { content: [{ type: "text", text: message }], isError: true };
96
116
  }
97
117
  async function run(work) {
118
+ let token = "";
98
119
  try {
99
- const output = await work(context());
120
+ const ctx = context();
121
+ token = ctx.config.token;
122
+ const output = await work(ctx);
100
123
  const content = [{ type: "text", text: JSON.stringify(output.json) }];
101
124
  if (output.notice !== void 0 && output.notice !== "") {
102
125
  content.push({ type: "text", text: output.notice.trimEnd() });
@@ -106,7 +129,8 @@ async function run(work) {
106
129
  return { content, isError: true };
107
130
  }
108
131
  return { content };
109
- } catch (error) {
132
+ } catch (caught) {
133
+ const error = explainExpertRefusal(caught, token);
110
134
  if (error instanceof NeedsLoginError) return toolError(error.message);
111
135
  if (error instanceof HttpError) {
112
136
  return toolError(`${error.message} (HTTP ${error.status})${errorDetails(error.body)}`);
@@ -125,9 +149,14 @@ var identifier = z.string().describe("issue identifier, e.g. IO-123");
125
149
  var commentId = z.string().uuid().describe("comment UUID from issue_show or comment_list");
126
150
  var dateField = z.string().optional().describe('YYYY-MM-DD; "" clears the date');
127
151
  var planCondition = z.object({
128
- kind: z.enum(CONDITION_KINDS),
152
+ kind: z.enum(CONDITION_KINDS).optional().describe("not_before, gate or event; optional with gate"),
129
153
  not_before: z.string().optional().describe("not_before: an ISO 8601 UTC instant"),
130
- label: z.string().optional().describe("gate: what a person ticks, e.g. Finance sign-off"),
154
+ gate: z.string().optional().describe("shorthand for kind gate with this key; the label defaults to it, e.g. finance-sign-off"),
155
+ key: z.string().optional().describe("gate: a stable lowercase slug (a-z, 0-9 and -), unique among the step's gates; gate_set takes it"),
156
+ label: z.string().optional().describe("gate: what a person ticks, e.g. Finance sign-off; defaults to the key"),
157
+ owner: z.string().nullable().optional().describe(
158
+ `gate: who ticks it. role:<role> (${GATE_OWNER_ROLES.join(", ")}), user:<id or email> (a member who can use Operator) or expert:<email> (an outside expert, never a member's email). Only the owner ticks an owned gate, and nobody names an owner they would hold themselves (owner_is_actor). null or absent: no owner`
159
+ ),
131
160
  event: z.string().optional().describe("event: deal_stage_changed, opportunity_stage_changed, form_submitted or investment_executed"),
132
161
  subject_id: z.string().optional().describe("event: the record the event is about (one you can read)"),
133
162
  target_id: z.string().optional().describe("event: the stage or status a stage change must reach")
@@ -168,6 +197,125 @@ var planStepEdit = z.object({
168
197
  key: z.string().nullable().optional().describe("the step's new key")
169
198
  }).passthrough();
170
199
  var idempotencyKey = z.string().min(1).max(MAX_IDEMPOTENCY_KEY_BYTES).regex(IDEMPOTENCY_KEY_FORMAT, "must use printable ASCII without leading or trailing spaces");
200
+ var OPERATOR_APPROVAL_NOTE = "Approval happens in the app: give a person the approval_url (pending_approval.url on job_show); no tool approves a change set. By reference only, never the objective's text.";
201
+ var OPERATOR_JOB_TOOLS = [
202
+ {
203
+ name: "jobs_list",
204
+ description: "List the Operator jobs the caller sees in the workbench, newest first: state, waiting_on (approval, person, reconciliation, verification or delivery), objective_kind, owner, plan step, window, and the workbench url and approval_url. " + OPERATOR_APPROVAL_NOTE + " Pages by cursor; all follows every page, and a second text item says when older jobs exist.",
205
+ readOnly: true,
206
+ shape: {
207
+ status: z.array(z.enum([...JOB_STATES, ...JOB_STATUS_ALIASES])).min(1).optional().describe("job states, or the aliases open (not done), waiting and done"),
208
+ mine: z.boolean().optional().describe("only jobs the caller owns"),
209
+ limit: z.number().int().min(1).max(JOBS_MAX_LIMIT).optional().describe("jobs per page (default 20)"),
210
+ all: z.boolean().optional().describe("follow every page")
211
+ },
212
+ handler: (ctx, args) => jobsList(ctx, {
213
+ status: args["status"] === void 0 ? void 0 : args["status"].join(","),
214
+ mine: args["mine"],
215
+ limit: args["limit"],
216
+ all: args["all"]
217
+ })
218
+ },
219
+ {
220
+ name: "job_show",
221
+ description: "One Operator job by reference: state and waiting_on, plan version, progress (stage, situation, needs_viewer), window (remaining and budget, in ms), spend in cents, blockers, pending_approval with its url, grant, verification status, effect counts, artifact links, pinned skill identity, people, saved procedures and viewer_can. " + OPERATOR_APPROVAL_NOTE + " Poll it to follow a job: it has ended when state is completed, failed or cancelled, and a person has to act exactly when waiting_on is set; a job paused with no waiting_on resumes by itself.",
222
+ readOnly: true,
223
+ shape: { id: z.string().uuid().describe("Operator job UUID, from jobs_list") },
224
+ handler: (ctx, args) => jobShow(ctx, args["id"])
225
+ }
226
+ ];
227
+ var OPERATOR_CONTROL_NOTE = "Not idempotent: never retry it on your own; when an error says the outcome is unknown (a timeout, a dropped connection or a 5xx), read the job with job_show before trying again. Approving stays in the app: no tool approves a change set. Returns the job as job_show does, by reference only.";
228
+ var jobId = z.string().uuid().describe("Operator job UUID, from jobs_list");
229
+ var OPERATOR_CONTROL_TOOLS = [
230
+ {
231
+ name: "job_steer",
232
+ description: "Steer an Operator job as Steer does in the app: posts the instruction in the job's room, attributed to the caller. The job's owner and collaborators may steer, wherever the app offers it (not a finished, failed or awaiting-approval job). Work the instruction changes needs a fresh approval: earlier approvals stop applying to it. Steering a running job stops its current run so it can take the instruction. " + OPERATOR_CONTROL_NOTE,
233
+ readOnly: false,
234
+ idempotent: false,
235
+ shape: {
236
+ id: jobId,
237
+ instruction: z.string().min(1).describe(
238
+ `what to change, in plain language: 1 to ${STEER_MAX_CHARACTERS} characters once trimmed`
239
+ )
240
+ },
241
+ handler: (ctx, args) => jobSteer(ctx, args["id"], args["instruction"])
242
+ },
243
+ {
244
+ name: "job_cancel",
245
+ description: "Cancel an Operator job as Cancel does in the app; only the job's execution principal may. It cannot be undone, but committed effects stay committed: the job's effects still count them, and staged ones that never ran count as unknown. " + OPERATOR_CONTROL_NOTE,
246
+ readOnly: false,
247
+ destructive: true,
248
+ idempotent: false,
249
+ shape: { id: jobId },
250
+ handler: (ctx, args) => jobCancel(ctx, args["id"])
251
+ },
252
+ {
253
+ name: "job_pause",
254
+ description: "Pause a running Operator job as Pause does in the app; only the job's execution principal may. Holds it for a person without resetting its active-time budget; continuing it runs it again. " + OPERATOR_CONTROL_NOTE,
255
+ readOnly: false,
256
+ idempotent: false,
257
+ shape: { id: jobId },
258
+ handler: (ctx, args) => jobPause(ctx, args["id"])
259
+ }
260
+ ];
261
+ var NOT_IDEMPOTENT = 'Not idempotent: never retry it automatically, not after a timeout or a 5xx either. An "Outcome unknown" error may have landed and says what to check before calling again; only "cannot reach the API" means the request never reached the server, so nothing changed.';
262
+ var OPERATOR_LIFECYCLE_TOOLS = [
263
+ {
264
+ name: "job_continue",
265
+ description: "Continue an Operator job, as Continue does in the app: opens a new audited window for a job that ran out of time or waits on a person, or retries a failed run or verification. Only the job's execution principal may. Returns the job as job_show does. Approval still happens in the app, at its approval_url. " + NOT_IDEMPOTENT,
266
+ readOnly: false,
267
+ destructive: false,
268
+ idempotent: false,
269
+ shape: { id: z.string().uuid().describe("Operator job UUID, from jobs_list") },
270
+ handler: (ctx, args) => jobContinue(ctx, args["id"])
271
+ },
272
+ {
273
+ name: "job_changes",
274
+ description: "An Operator job's latest change set by reference: its manifest id, version, status, digest, plan version, maximum effect count, and each action's type, version, order, effect count, required capability ids and digest; never values or targets. change_set is null while the job has proposed nothing. Beside it, the job's state, waiting_on, workbench url and approval_url: review and approve in the app, at that link.",
275
+ readOnly: true,
276
+ shape: { id: z.string().uuid().describe("Operator job UUID, from jobs_list") },
277
+ handler: (ctx, args) => jobShow(ctx, args["id"], { changes: true })
278
+ },
279
+ {
280
+ name: "procedure_save",
281
+ description: "Save a completed Operator job whose work was verified as a versioned procedure, as Save procedure does in the app. Only the job's owner can. Returns the procedure as procedure_show does, or only its id and url when it can't be read back. Saving again saves another procedure. " + NOT_IDEMPOTENT,
282
+ readOnly: false,
283
+ destructive: false,
284
+ idempotent: false,
285
+ shape: {
286
+ job_id: z.string().uuid().describe("Operator job UUID, from jobs_list"),
287
+ name: z.string().trim().min(1).describe("the procedure's name; trimmed and cut to 200 characters")
288
+ },
289
+ handler: (ctx, args) => procedureSave(ctx, args["job_id"], args["name"])
290
+ },
291
+ {
292
+ name: "procedure_show",
293
+ description: "One saved Operator procedure: its name, source job_id and job_url (the app), current_version, each version's recipe_digest, capability_ids and action_roster, and the parameter_schema a run of the current version takes (scoped_inputs.required naming contact_reconciliation means a run needs group_id and source_resource_id). Never a version's recipe or anything the saved job read.",
294
+ readOnly: true,
295
+ shape: { id: z.string().uuid().describe("Operator procedure UUID, from job_show's procedures") },
296
+ handler: (ctx, args) => procedureShow(ctx, args["id"])
297
+ },
298
+ {
299
+ name: "procedure_run",
300
+ description: "Run a saved Operator procedure as a new job, as Rerun does in the app: fresh inputs, the caller's own current rights, and a change set that needs its own approval in the app. Nothing of the saved job carries over. Returns the new job as job_show does, or only its id and url when it can't be read back; give a person its approval_url. " + NOT_IDEMPOTENT,
301
+ readOnly: false,
302
+ destructive: false,
303
+ idempotent: false,
304
+ shape: {
305
+ id: z.string().uuid().describe("Operator procedure UUID"),
306
+ version: z.number().int().min(1).optional().describe("the version expected to be current; the run is refused if it no longer is (default: the current one)"),
307
+ parameters: z.record(z.unknown()).optional().describe("values for the procedure's parameter_schema (procedure_show), default {}"),
308
+ group_id: z.string().min(1).optional().describe("the contact group to reconcile, when scoped_inputs require it"),
309
+ source_resource_id: z.string().min(1).optional().describe("the uploaded file to reconcile against, when scoped_inputs require it")
310
+ },
311
+ handler: (ctx, args) => procedureRun(ctx, args["id"], {
312
+ version: args["version"],
313
+ parameters: args["parameters"],
314
+ group: args["group_id"],
315
+ source: args["source_resource_id"]
316
+ })
317
+ }
318
+ ];
171
319
  var TOOLS = [
172
320
  // ── Issues ──
173
321
  {
@@ -222,7 +370,7 @@ var TOOLS = [
222
370
  },
223
371
  {
224
372
  name: "activity_list",
225
- description: "Mixed issue activity: comments, creation, state and assignee changes. Returns the newest page unless all=true.",
373
+ description: "Mixed issue activity: comments, creation, state and assignee changes, wait-condition events, and field changes (priority, labels, parent, title, description, archived) with from/to values. actor_label, when set, is the agent or CLI label a write was made under. Returns the newest page unless all=true.",
226
374
  readOnly: true,
227
375
  shape: {
228
376
  id: identifier,
@@ -723,7 +871,7 @@ var TOOLS = [
723
871
  // ── Plans and gates ──
724
872
  {
725
873
  name: "plan_create",
726
- description: "Create a plan: a root issue and up to 99 steps, created in one transaction or not at all, and held until a person releases it (plan_release). Steps refer to each other by key: parent (containment) and blocked_by (dependencies). executor operator files a step in the organization's Operator team, where only the plan driver claims it; a person's step goes to its team (or the plan's). conditions are wait conditions (not_before, gate, event). An invalid plan writes nothing and the error lists every violation by step key. Reuse idempotency_key when retrying.",
874
+ description: "Create a plan: a root issue and up to 99 steps, created in one transaction or not at all, and held until a person releases it (plan_release). Steps refer to each other by key: parent (containment) and blocked_by (dependencies). executor operator files a step in the organization's Operator team, where only the plan driver claims it; a person's step goes to its team (or the plan's). conditions are wait conditions (not_before, gate, event); a gate may carry a key (gate: <key> is shorthand) and an owner, who alone ticks it. An invalid plan writes nothing and the error lists every violation by step key. Reuse idempotency_key when retrying.",
727
875
  readOnly: false,
728
876
  shape: {
729
877
  team: z.string().optional().describe("team key for the root and people's steps; defaults to HARNESS_TEAM"),
@@ -734,7 +882,7 @@ var TOOLS = [
734
882
  },
735
883
  {
736
884
  name: "plan_show",
737
- description: "A plan's status, budgets, current revision and spend estimate, and its whole tree root first: each step's key, executor, parent, state, ready flag, held flag (edited since release), in_revision and wait conditions, plus the blocks edges between steps.",
885
+ description: "A plan's status, budgets, current revision and spend estimate, and its whole tree root first: each step's key, executor, parent, state, ready flag, held flag (edited since release), in_revision, wait conditions (a gate's key and owner) and waiting_for (each open gate's owner and holders, the people who can tick it: [] when nobody can, null when unowned or not known), plus the blocks edges between steps.",
738
886
  readOnly: true,
739
887
  shape: { id: planId },
740
888
  handler: (ctx, args) => planShow(ctx, args["id"])
@@ -779,15 +927,35 @@ var TOOLS = [
779
927
  },
780
928
  {
781
929
  name: "gate_set",
782
- description: "Satisfy (satisfied true) or un-satisfy (false) a gate wait condition on an issue, found by its label or condition id (issue_show lists conditions). Needs staff standing in the organization.",
930
+ description: "Satisfy (satisfied true) or un-satisfy (false) a gate wait condition on an issue, found by its key, label or condition id (condition_list and issue_show list conditions). Needs staff standing in the organization or a place in its plan's room; only an owned gate's owner ticks it, and its owner or staff untick it. Anyone else gets a 403 naming the owner. An outside expert's pxc_ credential ticks the gates it owns on a step assigned to it (assignment_list); any other step is 404.",
783
931
  readOnly: false,
784
932
  shape: {
785
933
  issue: identifier,
786
- gate: z.string().describe("the gate's label, or its condition id"),
934
+ gate: z.string().describe("the gate's key, its label, or its condition id"),
787
935
  satisfied: z.boolean()
788
936
  },
789
937
  handler: (ctx, args) => gateSet(ctx, args["issue"], args["gate"], args["satisfied"])
790
938
  },
939
+ {
940
+ name: "condition_list",
941
+ description: "An issue's wait conditions (not_before, gate, event), oldest first: each one's id, kind, a gate's key, label and owner, and whether, when and by whom it was satisfied. gate_set ticks a gate. With an outside expert's pxc_ credential: only the gates it owns on a step assigned to it, in the expert view (owner as {kind, role}, satisfied_by as {kind: you|role|expert|member}); any other step is 404.",
942
+ readOnly: true,
943
+ shape: { issue: identifier },
944
+ handler: (ctx, args) => conditionList(ctx, args["issue"])
945
+ },
946
+ {
947
+ name: "assignment_list",
948
+ description: "An outside expert's own assignments, for their pxc_ credential: expert ({id, role}), plan ({id, status} or null), and assignments, each step assigned to them with its identifier, title, state, due_date, description (null when Operator runs the step), open_blockers (a count) and the gates on it they own. gate_set ticks one. A pxc_ credential reaches only this, condition_list and gate_set: every other tool is refused as expert_bound_credential. Any other credential is refused as expert_credential_required.",
949
+ readOnly: true,
950
+ shape: {},
951
+ handler: (ctx) => assignments(ctx)
952
+ },
953
+ // ── Operator jobs (CLI-43) ──
954
+ ...OPERATOR_JOB_TOOLS,
955
+ // ── Operator job controls (CLI-46) ──
956
+ ...OPERATOR_CONTROL_TOOLS,
957
+ // ── Operator job lifecycle (CLI-47) ──
958
+ ...OPERATOR_LIFECYCLE_TOOLS,
791
959
  // ── Uploads ──
792
960
  {
793
961
  name: "upload",
@@ -795,25 +963,52 @@ var TOOLS = [
795
963
  readOnly: false,
796
964
  shape: { path: z.string().describe("local file path") },
797
965
  handler: (ctx, args) => upload(ctx, args["path"])
966
+ },
967
+ // ── Operator's catalog (CLI-44) ──
968
+ {
969
+ name: "tools_search",
970
+ description: "Browse or search what Operator can use now in this organization: only capabilities that are switched on appear. Without query, the index in id order (25 a page); with query, a keyword search ranked by score (15 a page). domain narrows either to one domain. Each capability carries its domain, summary, description, mode, effect and kind: read, write, or send (a write delivered beyond the platform). Write and send capabilities, and any proposal, always need a person's approval in the app before they take effect; nothing here runs or approves anything. A page that isn't the last comes with a notice naming the next cursor; all=true follows every page.",
971
+ readOnly: true,
972
+ shape: {
973
+ query: z.string().optional().describe("search terms, at most 200 bytes; omit to browse the index"),
974
+ domain: z.string().optional().describe("only this capability domain, e.g. crm"),
975
+ cursor: z.string().optional().describe("the next page's cursor, from the previous call's notice"),
976
+ all: z.boolean().optional().describe("follow every page")
977
+ },
978
+ handler: (ctx, args) => {
979
+ const opts = { domain: args["domain"], cursor: args["cursor"], all: args["all"] };
980
+ return args["query"] === void 0 ? toolsList(ctx, opts) : toolsSearch(ctx, args["query"], opts);
981
+ }
982
+ },
983
+ {
984
+ name: "skills_list",
985
+ description: "The organization's skills assigned to Operator, in title order: each skill's id, title, invocation_name and content_sha256. A skill's content and description are never exposed.",
986
+ readOnly: true,
987
+ shape: {},
988
+ handler: (ctx) => skillsList(ctx)
798
989
  }
799
990
  ];
800
- function buildServer() {
801
- const server = new McpServer({ name: "harness", version: CLI_VERSION });
991
+ function buildServer(name = "harness") {
992
+ const server = new McpServer({ name, version: CLI_VERSION });
802
993
  for (const tool of TOOLS) {
803
994
  server.registerTool(
804
995
  tool.name,
805
996
  {
806
997
  description: tool.description,
807
998
  inputSchema: tool.shape,
808
- annotations: { readOnlyHint: tool.readOnly }
999
+ annotations: {
1000
+ readOnlyHint: tool.readOnly,
1001
+ ...tool.destructive === void 0 ? {} : { destructiveHint: tool.destructive },
1002
+ ...tool.idempotent === void 0 ? {} : { idempotentHint: tool.idempotent }
1003
+ }
809
1004
  },
810
1005
  ((args) => run((ctx) => tool.handler(ctx, args)))
811
1006
  );
812
1007
  }
813
1008
  return server;
814
1009
  }
815
- async function startMcpServer() {
816
- const server = buildServer();
1010
+ async function startMcpServer(name = "harness") {
1011
+ const server = buildServer(name);
817
1012
  await server.connect(new StdioServerTransport());
818
1013
  }
819
1014
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allocator-one/harness-cli",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "CLI and MCP server for Harness, allocator.one's issue tracker",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,6 +26,7 @@
26
26
  "typecheck": "tsc --noEmit",
27
27
  "pretest": "npm run build",
28
28
  "test": "vitest run",
29
+ "package:operator": "node scripts/operator-package.mjs ./build/operator",
29
30
  "codegen": "openapi-typescript spec/openapi.json -o src/generated/api.ts",
30
31
  "spec:refresh": "node scripts/spec-refresh.mjs",
31
32
  "prepublishOnly": "npm run build"