spur-board 0.81.0 → 0.82.1
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/{chunk-D9dHqOgX.mjs → chunk-Bwz_FohV.mjs} +4 -7
- package/dist/{chunk-DAMwWWmT.mjs → chunk-Bzb7aI8R.mjs} +1 -2
- package/dist/{chunk-DncwJ_X0.mjs → chunk-C8T8iXEN.mjs} +4 -6
- package/dist/{chunk-BN-Cz4Ql.mjs → chunk-DidRk5le.mjs} +22 -43
- package/dist/cli.mjs +33 -31
- package/dist/client.mjs +1 -2
- package/dist/daemon.mjs +185 -295
- package/dist/mcp.mjs +9 -9
- package/dist/web/assets/{index-BUBSkFv-.js → index-BsPvo3Nk.js} +2 -2
- package/dist/web/index.html +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Q as ERRORS, c as tokenRequestStatusSchema, et as errorContextSchema, g as renderJsonError, o as tokenRequestResultSchema, rt as successEnvelopeSchema, tt as errorEnvelopeSchema } from "./chunk-
|
|
1
|
+
import { Q as ERRORS, c as tokenRequestStatusSchema, et as errorContextSchema, g as renderJsonError, o as tokenRequestResultSchema, rt as successEnvelopeSchema, tt as errorEnvelopeSchema } from "./chunk-DidRk5le.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { request } from "node:http";
|
|
5
5
|
import { request as request$1 } from "node:https";
|
|
6
|
-
|
|
6
|
+
// src/terminal.ts
|
|
7
7
|
/** Show control bytes as text so server data cannot change terminal state. */
|
|
8
8
|
function escapeTerminalControls(text) {
|
|
9
9
|
return Array.from(text, (character) => {
|
|
@@ -11,8 +11,7 @@ function escapeTerminalControls(text) {
|
|
|
11
11
|
return code < 32 || code >= 127 && code <= 159 ? `\\u${code.toString(16).padStart(4, "0")}` : character;
|
|
12
12
|
}).join("");
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
//#region src/exit-codes.ts
|
|
14
|
+
// src/exit-codes.ts
|
|
16
15
|
var CliError = class extends Error {
|
|
17
16
|
code;
|
|
18
17
|
context;
|
|
@@ -54,8 +53,7 @@ function renderCliError(error, json, key) {
|
|
|
54
53
|
["requestId", value.requestId]
|
|
55
54
|
].map(([label, text]) => `${label}: ${escapeTerminalControls(text)}`).join("\n");
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
//#region src/client.ts
|
|
56
|
+
// src/client.ts
|
|
59
57
|
function problemError(status, contentType, body) {
|
|
60
58
|
if (!body || typeof body !== "object") return new CliError("outcome_unknown");
|
|
61
59
|
const problem = body;
|
|
@@ -232,5 +230,4 @@ function requestSkillReload(version, config) {
|
|
|
232
230
|
decode: (response, raw) => decodeResponse(skillReloadOutput, response, raw)
|
|
233
231
|
});
|
|
234
232
|
}
|
|
235
|
-
//#endregion
|
|
236
233
|
export { requestTokenEnrollment as a, renderCliError as c, requestSkillReload as i, escapeTerminalControls as l, fetchTokenStatus as n, CliError as o, requestOperation as r, errorExitCode as s, fetchCatalogVersion as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../contracts/src/urls.ts
|
|
2
2
|
/**
|
|
3
3
|
* The base of an HTTP API at `url`, with one trailing slash, so `new URL('path', base)` keeps a
|
|
4
4
|
* path prefix such as `/api`.
|
|
@@ -6,5 +6,4 @@
|
|
|
6
6
|
function apiBaseUrl(url) {
|
|
7
7
|
return new URL(`${url.replace(/\/$/, "")}/`);
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { apiBaseUrl as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { d as buildCatalogSnapshot, ft as configSchema, mt as plainHttpAllowed, p as OPERATIONS } from "./chunk-
|
|
2
|
-
import { o as CliError, t as fetchCatalogVersion } from "./chunk-
|
|
1
|
+
import { d as buildCatalogSnapshot, ft as configSchema, mt as plainHttpAllowed, p as OPERATIONS } from "./chunk-DidRk5le.mjs";
|
|
2
|
+
import { o as CliError, t as fetchCatalogVersion } from "./chunk-Bwz_FohV.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import YAML from "yaml";
|
|
9
|
-
|
|
9
|
+
// src/config.ts
|
|
10
10
|
const CONNECT_TIMEOUT_MS = 2e3;
|
|
11
11
|
const RESPONSE_TIMEOUT_MS = 3e4;
|
|
12
12
|
/** A relative `BOARD_HOME` counts from `cwd`; relative XDG directories are ignored. */
|
|
@@ -146,8 +146,7 @@ function loadEnrollmentConfig(env = process.env) {
|
|
|
146
146
|
responseTimeoutMs: RESPONSE_TIMEOUT_MS
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
//#region src/version.ts
|
|
149
|
+
// src/version.ts
|
|
151
150
|
let clientVersion;
|
|
152
151
|
/** The catalog version this client was built with; the snapshot is built once per process. */
|
|
153
152
|
function clientCatalogVersion() {
|
|
@@ -262,5 +261,4 @@ function fileVerdictCache(path, cliVersion) {
|
|
|
262
261
|
return verdict;
|
|
263
262
|
} };
|
|
264
263
|
}
|
|
265
|
-
//#endregion
|
|
266
264
|
export { memoryVerdictCache as a, loadClientConfig as c, resolveDaemonAddress as d, tokenInFolder as f, fileVerdictCache as i, loadEnrollmentConfig as l, cliPackageVersion as n, configFile as o, compareCatalogs as r, dataDirectory as s, checkCatalog as t, readConfiguredPort as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
2
|
+
// ../contracts/src/enums.ts
|
|
3
3
|
/**
|
|
4
4
|
* Built-in board columns in canonical order, left to right. Everything stored or addressed
|
|
5
5
|
* (journal, store, addressee roles) uses the `id`; `name` is display text only.
|
|
@@ -224,8 +224,7 @@ const SLACK_BOT_SCOPES = [
|
|
|
224
224
|
"commands",
|
|
225
225
|
"reactions:write"
|
|
226
226
|
];
|
|
227
|
-
|
|
228
|
-
//#region ../contracts/src/config.ts
|
|
227
|
+
// ../contracts/src/config.ts
|
|
229
228
|
/**
|
|
230
229
|
* The daemon's default loopback port. It sits above 4310-4399, a margin the board keeps for
|
|
231
230
|
* Spur's server port 4310 and the ports from 4311 upward that Spur's MCP port takes. It also
|
|
@@ -694,7 +693,7 @@ const configObject = z.strictObject({
|
|
|
694
693
|
stand: z.strictObject({ portRange: z.strictObject({
|
|
695
694
|
min: z.int().min(1024).max(65535).default(DEFAULT_STAND_PORT_RANGE.min).describe("Inclusive first stand port; defaults to 4780 when a range is supplied."),
|
|
696
695
|
max: z.int().min(1024).max(65535).default(DEFAULT_STAND_PORT_RANGE.max).describe("Inclusive last stand port; defaults to 4799 when a range is supplied.")
|
|
697
|
-
}).optional().describe("Optional stand port range, effectively 4780..4799 when omitted. An explicit range (including {}) must exclude http.port and web.port; an omitted range preserves legacy configs and doctor warns on overlaps.
|
|
696
|
+
}).optional().describe("Optional stand port range, effectively 4780..4799 when omitted. An explicit range (including {}) must exclude http.port and web.port; an omitted range preserves legacy configs and doctor warns on overlaps. pnpm stand takes its web port, and an explicit API port, from this range and refuses http.port and web.port.") }).prefault({}),
|
|
698
697
|
adapters: z.strictObject({
|
|
699
698
|
spur: spurAdapterSection,
|
|
700
699
|
github: adapterSection(6e4),
|
|
@@ -993,8 +992,7 @@ function requiredSecretKeys(config) {
|
|
|
993
992
|
const slack = Boolean(config.slack.channels.feed || config.slack.channels.orchestrators);
|
|
994
993
|
return SECRET_ENV_KEYS.filter(({ requiredWhen }) => requiredWhen === "always" || requiredWhen === "jira" && jira || requiredWhen === "slack" && slack).map(({ name }) => name);
|
|
995
994
|
}
|
|
996
|
-
|
|
997
|
-
//#region ../contracts/src/errors.ts
|
|
995
|
+
// ../contracts/src/errors.ts
|
|
998
996
|
/**
|
|
999
997
|
* Process exit codes of the CLI. `notApplied` (3) means the command certainly did not take
|
|
1000
998
|
* effect; `outcomeUnknown` (5) means it may have, so the caller retries with the same key.
|
|
@@ -1330,8 +1328,7 @@ function err(error) {
|
|
|
1330
1328
|
error
|
|
1331
1329
|
};
|
|
1332
1330
|
}
|
|
1333
|
-
|
|
1334
|
-
//#region ../contracts/src/ids.ts
|
|
1331
|
+
// ../contracts/src/ids.ts
|
|
1335
1332
|
/**
|
|
1336
1333
|
* Number in an ID or a task key: at most 15 digits, so it always converts to a safe integer
|
|
1337
1334
|
* and two different IDs never share one number. A longer number is `usage`. It is the shared
|
|
@@ -1479,8 +1476,7 @@ function parseActorId(text) {
|
|
|
1479
1476
|
}
|
|
1480
1477
|
};
|
|
1481
1478
|
}
|
|
1482
|
-
|
|
1483
|
-
//#region ../contracts/src/facts.ts
|
|
1479
|
+
// ../contracts/src/facts.ts
|
|
1484
1480
|
const PR_STATES = [
|
|
1485
1481
|
"open",
|
|
1486
1482
|
"closed",
|
|
@@ -1710,8 +1706,7 @@ const sessionFactsSchema = z.strictObject({
|
|
|
1710
1706
|
...ticketFactsSchema.keyof().options.map((field) => `ticket.${field}`),
|
|
1711
1707
|
...sessionFactsSchema.keyof().options.map((field) => `session.${field}`)
|
|
1712
1708
|
];
|
|
1713
|
-
|
|
1714
|
-
//#region ../contracts/src/adapters.ts
|
|
1709
|
+
// ../contracts/src/adapters.ts
|
|
1715
1710
|
/** What the source answered for one requested entity. */
|
|
1716
1711
|
const ENTITY_STATUSES = [
|
|
1717
1712
|
"ok",
|
|
@@ -1902,8 +1897,7 @@ var AdapterError = class extends Error {
|
|
|
1902
1897
|
this.retryAt = options.retryAt;
|
|
1903
1898
|
}
|
|
1904
1899
|
};
|
|
1905
|
-
|
|
1906
|
-
//#region ../contracts/src/events.ts
|
|
1900
|
+
// ../contracts/src/events.ts
|
|
1907
1901
|
const EVENT_KINDS = [
|
|
1908
1902
|
"head_moved",
|
|
1909
1903
|
"pr_facts_changed",
|
|
@@ -2215,8 +2209,7 @@ z.object({
|
|
|
2215
2209
|
message: `actorRef is set only when actor is agent, not ${event.actor}`
|
|
2216
2210
|
});
|
|
2217
2211
|
});
|
|
2218
|
-
|
|
2219
|
-
//#region ../contracts/src/gateway/schemas.ts
|
|
2212
|
+
// ../contracts/src/gateway/schemas.ts
|
|
2220
2213
|
/** Opaque, gateway-issued reference to a conversation. Core stores it and never parses it. */
|
|
2221
2214
|
const conversationRefSchema = z.string().min(1).brand();
|
|
2222
2215
|
/** Opaque, gateway-issued reference to one message. */
|
|
@@ -2374,8 +2367,7 @@ z.discriminatedUnion("status", [
|
|
|
2374
2367
|
scope: z.enum(FAILURE_SCOPES)
|
|
2375
2368
|
})
|
|
2376
2369
|
]);
|
|
2377
|
-
|
|
2378
|
-
//#region ../contracts/src/error-renderers.ts
|
|
2370
|
+
// ../contracts/src/error-renderers.ts
|
|
2379
2371
|
/** One validated input supplies every transport representation. */
|
|
2380
2372
|
const errorInputSchema = z.strictObject({
|
|
2381
2373
|
code: z.enum(Object.keys(ERRORS)),
|
|
@@ -2454,8 +2446,7 @@ function renderLines(value) {
|
|
|
2454
2446
|
""
|
|
2455
2447
|
].join("\n");
|
|
2456
2448
|
}
|
|
2457
|
-
|
|
2458
|
-
//#region ../contracts/src/ops/define.ts
|
|
2449
|
+
// ../contracts/src/ops/define.ts
|
|
2459
2450
|
/** Who may call an operation. Core evaluates them (#34); the catalog only declares them. */
|
|
2460
2451
|
const GRANTS = [
|
|
2461
2452
|
"operator",
|
|
@@ -2526,8 +2517,7 @@ function defineOperation(spec) {
|
|
|
2526
2517
|
}
|
|
2527
2518
|
};
|
|
2528
2519
|
}
|
|
2529
|
-
|
|
2530
|
-
//#region ../contracts/src/ops/turn-schemas.ts
|
|
2520
|
+
// ../contracts/src/ops/turn-schemas.ts
|
|
2531
2521
|
/** One pull request comment or review a turn handed to its executor. */
|
|
2532
2522
|
const turnHandedSchema = z.strictObject({
|
|
2533
2523
|
...prRefSchema.shape,
|
|
@@ -2593,8 +2583,7 @@ const statusReturnedSchema = z.strictObject({
|
|
|
2593
2583
|
block: blockIdSchema.describe("The code block the return opened."),
|
|
2594
2584
|
findings: z.int().min(0).nullable().describe("Number of review findings the return sent; null when not given.")
|
|
2595
2585
|
});
|
|
2596
|
-
|
|
2597
|
-
//#region ../contracts/src/ops/schemas.ts
|
|
2586
|
+
// ../contracts/src/ops/schemas.ts
|
|
2598
2587
|
/**
|
|
2599
2588
|
* A comment as every output returns it. `untrusted` is always `true`: the text comes from a
|
|
2600
2589
|
* person or an agent, and an agent reading it treats it as data, never as instructions.
|
|
@@ -2822,8 +2811,7 @@ const schemaGetOutputSchema = z.strictObject({
|
|
|
2822
2811
|
outputSchema: jsonSchemaPayload("output")
|
|
2823
2812
|
}).describe("One operation.")).describe("Operations the caller may use.")
|
|
2824
2813
|
}).describe("The operation catalog.");
|
|
2825
|
-
|
|
2826
|
-
//#region ../contracts/src/ops/source-view-schema.ts
|
|
2814
|
+
// ../contracts/src/ops/source-view-schema.ts
|
|
2827
2815
|
const sourceViewSchema = z.strictObject({
|
|
2828
2816
|
pointsLastHour: z.int().nonnegative().optional().describe("Reported source points consumed during the preceding hour."),
|
|
2829
2817
|
source: z.string().min(1).describe("Adapter source identifier."),
|
|
@@ -2917,8 +2905,7 @@ const blockAnswerOutputSchema = z.strictObject({
|
|
|
2917
2905
|
block: blockViewSchema,
|
|
2918
2906
|
comment: commentSchema
|
|
2919
2907
|
});
|
|
2920
|
-
|
|
2921
|
-
//#region ../contracts/src/ops/config-view-schema.ts
|
|
2908
|
+
// ../contracts/src/ops/config-view-schema.ts
|
|
2922
2909
|
const configViewSchema = z.strictObject({
|
|
2923
2910
|
projects: z.array(z.strictObject({
|
|
2924
2911
|
id: z.string().min(1).describe("Board project ID."),
|
|
@@ -2947,8 +2934,7 @@ const configViewSchema = z.strictObject({
|
|
|
2947
2934
|
spurUiOrigin: z.url({ protocol: /^https?$/ }).nullable().describe("Origin of the Spur web UI clients link sessions to; null when not configured.")
|
|
2948
2935
|
}).describe("Web origins of the board listener and the Spur UI.")
|
|
2949
2936
|
}).describe("Allowlisted effective configuration without credentials or adapter settings.");
|
|
2950
|
-
|
|
2951
|
-
//#region ../contracts/src/ops/inbox-schemas.ts
|
|
2937
|
+
// ../contracts/src/ops/inbox-schemas.ts
|
|
2952
2938
|
/** One entry of the operator inbox: an operator item, a block addressed to the operator or a turn. */
|
|
2953
2939
|
const inboxEntrySchema = z.strictObject({
|
|
2954
2940
|
id: z.union([
|
|
@@ -2967,8 +2953,7 @@ const inboxEntrySchema = z.strictObject({
|
|
|
2967
2953
|
}).describe("One entry of the operator inbox.");
|
|
2968
2954
|
/** An operator inbox entry cleared, answered or closed in the last 24 hours. */
|
|
2969
2955
|
const inboxHandledSchema = inboxEntrySchema.extend({ handledAt: z.iso.datetime().describe("When it was cleared, answered or closed, ISO 8601 UTC.") }).describe("An operator inbox entry handled in the last 24 hours.");
|
|
2970
|
-
|
|
2971
|
-
//#region ../contracts/src/ops/catalog.ts
|
|
2956
|
+
// ../contracts/src/ops/catalog.ts
|
|
2972
2957
|
/** Longest free text an input takes: comments, questions, answers and reasons. */
|
|
2973
2958
|
const TEXT_MAX = 2e4;
|
|
2974
2959
|
/** Longest project, session or token name an input takes. */
|
|
@@ -4708,8 +4693,7 @@ const OPERATIONS = [
|
|
|
4708
4693
|
}]
|
|
4709
4694
|
})
|
|
4710
4695
|
];
|
|
4711
|
-
|
|
4712
|
-
//#region ../contracts/src/ops/roles.ts
|
|
4696
|
+
// ../contracts/src/ops/roles.ts
|
|
4713
4697
|
const ROLE_GRANTS = {
|
|
4714
4698
|
operator: /* @__PURE__ */ new Set([
|
|
4715
4699
|
"operator",
|
|
@@ -4733,8 +4717,7 @@ const ROLE_GRANTS = {
|
|
|
4733
4717
|
function roleCanUseOperation(operation, role, mode) {
|
|
4734
4718
|
return operation.grants === "any" || operation.grants.some((rule) => ROLE_GRANTS[role].has(rule.grant) && (mode === void 0 || rule.mode === void 0 || rule.mode === mode));
|
|
4735
4719
|
}
|
|
4736
|
-
|
|
4737
|
-
//#region ../contracts/src/ops/snapshot.ts
|
|
4720
|
+
// ../contracts/src/ops/snapshot.ts
|
|
4738
4721
|
/**
|
|
4739
4722
|
* The catalog as plain JSON: grants, exit codes, errors, and every operation with its JSON
|
|
4740
4723
|
* Schemas. Inputs are stored in input mode and also converted in output mode, so a
|
|
@@ -4786,8 +4769,7 @@ async function buildCatalogSnapshot(operations) {
|
|
|
4786
4769
|
...body
|
|
4787
4770
|
};
|
|
4788
4771
|
}
|
|
4789
|
-
|
|
4790
|
-
//#region ../contracts/src/systemd.ts
|
|
4772
|
+
// ../contracts/src/systemd.ts
|
|
4791
4773
|
/**
|
|
4792
4774
|
* systemd user-unit policy shared by the CLI unit writer and the daemon's board tick.
|
|
4793
4775
|
*
|
|
@@ -4806,8 +4788,7 @@ const SYSTEMD_SERVICE_SETTINGS = [
|
|
|
4806
4788
|
"TimeoutStopSec=15s",
|
|
4807
4789
|
"UMask=0077"
|
|
4808
4790
|
];
|
|
4809
|
-
|
|
4810
|
-
//#region ../contracts/src/tokens.ts
|
|
4791
|
+
// ../contracts/src/tokens.ts
|
|
4811
4792
|
/** Longest value each field of an operator token request takes, in characters. */
|
|
4812
4793
|
const TOKEN_REQUEST_LIMITS = {
|
|
4813
4794
|
name: 64,
|
|
@@ -4866,11 +4847,9 @@ const remoteDoctorReportSchema = z.object({
|
|
|
4866
4847
|
version: z.string(),
|
|
4867
4848
|
checks: z.array(z.object(checkShape))
|
|
4868
4849
|
});
|
|
4869
|
-
|
|
4870
|
-
//#region ../contracts/src/index.ts
|
|
4850
|
+
// ../contracts/src/index.ts
|
|
4871
4851
|
/** Exhaustiveness check: call it in the `default` branch of a switch over a union. */
|
|
4872
4852
|
function assertNever(value) {
|
|
4873
4853
|
throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
|
|
4874
4854
|
}
|
|
4875
|
-
//#endregion
|
|
4876
4855
|
export { err as $, prSourceId as A, prFactsSchema as B, userIdSchema as C, AdapterError as D, eventPayloadSchemas as E, REVIEW_STATES as F, JIRA_PROJECT_KEY as G, ringMarker as H, SESSION_HEALTH_STATES as I, encodeActorId as J, REF_NUMBER as K, SESSION_STATUSES as L, sourceCursorSchema as M, trackerSourceId as N, batchSchema as O, PR_STATES as P, ERRORS as Q, isExternalAuthor as R, messageRefSchema as S, VIAS as St, GATE_REASONS as T, sessionFactsSchema as U, prRefSchema as V, ticketFactsSchema as W, parseActorId as X, errorCodeOf as Y, parseRef as Z, renderMcpError as _, COLUMN_IDS as _t, requestHashOf as a, DEFAULT_LINK as at, inboundEventSchema as b, SLACK_BOT_SCOPES as bt, tokenRequestStatusSchema as c, DEFAULT_STAND_PORT_RANGE as ct, buildCatalogSnapshot as d, configBindings as dt, errorContextSchema as et, roleCanUseOperation as f, configSchema as ft, renderJsonError as g, resolveWebOrigin as gt, renderHttpProblem as h, requiredSecretKeys as ht, TOKEN_REQUEST_LIMITS as i, DEFAULT_HTTP_PORT as it, sessionTransitionSchema as j, entityRefSchema as k, BOARD_TICK_MS as l, RESERVED_PROJECT as lt, turnHandedSchema as m, plainHttpAllowed as mt, doctorReportSchema as n, ok as nt, tokenRequestResultSchema as o, DEFAULT_SLACK_APP_NAME as ot, OPERATIONS as p, defaultAddressee as pt, actorIdSchema as q, remoteDoctorReportSchema as r, successEnvelopeSchema as rt, tokenRequestSchema as s, DEFAULT_SLACK_COMMAND as st, assertNever as t, errorEnvelopeSchema as tt, SYSTEMD_SERVICE_SETTINGS as u, boardWideSpurProject as ut, SPACE_IDS as v, DISPATCHER_MODES as vt, EVENT_KINDS as w, interactionRefSchema as x, TASK_HOLDS as xt, conversationRefSchema as y, ITEM_KINDS as yt, parseRingMarker as z };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Q as ERRORS, a as requestHashOf, bt as SLACK_BOT_SCOPES, ct as DEFAULT_STAND_PORT_RANGE, f as roleCanUseOperation, ft as configSchema, gt as resolveWebOrigin, ht as requiredSecretKeys, p as OPERATIONS, q as actorIdSchema, r as remoteDoctorReportSchema, rt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS } from "./chunk-
|
|
2
|
-
import { t as apiBaseUrl } from "./chunk-
|
|
3
|
-
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-
|
|
4
|
-
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-
|
|
1
|
+
import { Q as ERRORS, a as requestHashOf, bt as SLACK_BOT_SCOPES, ct as DEFAULT_STAND_PORT_RANGE, f as roleCanUseOperation, ft as configSchema, gt as resolveWebOrigin, ht as requiredSecretKeys, p as OPERATIONS, q as actorIdSchema, r as remoteDoctorReportSchema, rt as successEnvelopeSchema, u as SYSTEMD_SERVICE_SETTINGS } from "./chunk-DidRk5le.mjs";
|
|
2
|
+
import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
|
|
3
|
+
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-Bwz_FohV.mjs";
|
|
4
|
+
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-C8T8iXEN.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
6
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
7
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -17,7 +17,7 @@ import { createServer } from "node:net";
|
|
|
17
17
|
import { access, cp, lstat, mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { createInterface } from "node:readline/promises";
|
|
20
|
-
|
|
20
|
+
// src/manifest.ts
|
|
21
21
|
function loadSlackManifestDefaults(env, home) {
|
|
22
22
|
let contents;
|
|
23
23
|
try {
|
|
@@ -29,7 +29,10 @@ function loadSlackManifestDefaults(env, home) {
|
|
|
29
29
|
const document = YAML.parseDocument(contents);
|
|
30
30
|
if (document.errors.length > 0) throw new CliError("config", void 0, void 0, "Fix the YAML in config.yaml.");
|
|
31
31
|
const parsed = configSchema.safeParse(document.toJS());
|
|
32
|
-
if (!parsed.success)
|
|
32
|
+
if (!parsed.success) {
|
|
33
|
+
const key = parsed.error.issues[0]?.path.map(String).join(".") || "config.yaml";
|
|
34
|
+
throw new CliError("config", void 0, void 0, `Fix ${key} in config.yaml.`);
|
|
35
|
+
}
|
|
33
36
|
return {
|
|
34
37
|
appName: parsed.data.slack.appName,
|
|
35
38
|
command: parsed.data.slack.command
|
|
@@ -66,8 +69,7 @@ function renderSlackManifest(options = {}) {
|
|
|
66
69
|
}
|
|
67
70
|
}, { lineWidth: 0 });
|
|
68
71
|
}
|
|
69
|
-
|
|
70
|
-
//#region src/port.ts
|
|
72
|
+
// src/port.ts
|
|
71
73
|
/** A private copy of the client's check: client.ts is the published entry, so it exports nothing new. */
|
|
72
74
|
const instanceHeader = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
73
75
|
/** Bind 127.0.0.1:port as the daemon would and close at once; returns the error code, or null when free. */
|
|
@@ -130,8 +132,7 @@ async function checkHttpPort(port, probe) {
|
|
|
130
132
|
if (await isBoardDaemon(port)) return null;
|
|
131
133
|
return `${label} is held by ${await holderOf(port, probe)}. Stop that process or set http.port in config.yaml to a free port, then start the service again.`;
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
//#region src/doctor.ts
|
|
135
|
+
// src/doctor.ts
|
|
135
136
|
function systemRun(command, args, env) {
|
|
136
137
|
const result = spawnSync(command, [...args], {
|
|
137
138
|
encoding: "utf8",
|
|
@@ -520,7 +521,7 @@ async function runDoctor(options = {}) {
|
|
|
520
521
|
});
|
|
521
522
|
const range = config.stand.portRange ?? DEFAULT_STAND_PORT_RANGE;
|
|
522
523
|
const overlaps = [["http.port", config.http.port], ["web.port", config.web.port]].filter(([, port]) => port !== void 0 && port >= range.min && port <= range.max).map(([field, port]) => `${field} ${String(port)}`);
|
|
523
|
-
checks.push(overlaps.length === 0 ? result("stand.port_range", true, "") : warning("stand.port_range", `Implicit stand port range ${String(range.min)}..${String(range.max)} overlaps ${overlaps.join(", ")}. Set a nonoverlapping stand.portRange.
|
|
524
|
+
checks.push(overlaps.length === 0 ? result("stand.port_range", true, "") : warning("stand.port_range", `Implicit stand port range ${String(range.min)}..${String(range.max)} overlaps ${overlaps.join(", ")}. Set a nonoverlapping stand.portRange. The stand refuses the overlapping ports.`));
|
|
524
525
|
if (options.offline) return checks;
|
|
525
526
|
const unitPath = unitFile(env, home);
|
|
526
527
|
let unit = null;
|
|
@@ -640,8 +641,7 @@ function renderDoctor(checks, json) {
|
|
|
640
641
|
return escapeTerminalControls(`${check.status.toUpperCase()} ${check.id}${present}${fix}`);
|
|
641
642
|
}).join("\n");
|
|
642
643
|
}
|
|
643
|
-
|
|
644
|
-
//#region src/service.ts
|
|
644
|
+
// src/service.ts
|
|
645
645
|
const serviceName = "spur-board.service";
|
|
646
646
|
function configHome(env, home) {
|
|
647
647
|
const configured = env["XDG_CONFIG_HOME"];
|
|
@@ -745,11 +745,12 @@ async function requireStart(runner, args, unit) {
|
|
|
745
745
|
enabled: "unknown"
|
|
746
746
|
}));
|
|
747
747
|
const origin = unit.written === void 0 ? "" : unit.written ? " (written by this run)" : " (already in place)";
|
|
748
|
-
|
|
748
|
+
const hint = [
|
|
749
749
|
`Unit file ${unit.file}${origin} is ${state.enabled}; the service is ${state.active}.`,
|
|
750
750
|
`systemctl ${args.join(" ")} failed: ${detail}.`,
|
|
751
751
|
"Read why with `journalctl --user -u spur-board.service -n 100` and run `board doctor`."
|
|
752
|
-
].join(" ")
|
|
752
|
+
].join(" ");
|
|
753
|
+
throw new CliError("service_start_failed", void 0, void 0, hint);
|
|
753
754
|
}
|
|
754
755
|
async function preflight(paths) {
|
|
755
756
|
for (const [label, path] of [["Node executable", paths.nodePath], ["daemon entry", paths.daemonEntry]]) {
|
|
@@ -870,10 +871,10 @@ async function uninstallService(options = {}) {
|
|
|
870
871
|
await requireSuccess(runner, "systemctl", ["--user", "daemon-reload"]);
|
|
871
872
|
return { changed: true };
|
|
872
873
|
}
|
|
873
|
-
|
|
874
|
-
//#region src/skill-reload.ts
|
|
874
|
+
// src/skill-reload.ts
|
|
875
875
|
function reasonOf(error) {
|
|
876
|
-
|
|
876
|
+
const reason = error instanceof CliError ? error.hint ?? ERRORS[error.code].message : error instanceof Error ? error.message : "unexpected error";
|
|
877
|
+
return escapeTerminalControls(reason).replace(/\.$/, "");
|
|
877
878
|
}
|
|
878
879
|
/**
|
|
879
880
|
* Asks the daemon to message running sessions about a new skill version. It never throws: the
|
|
@@ -886,20 +887,20 @@ async function askSessionsToReload(options) {
|
|
|
886
887
|
if (port === void 0 || port === 0) return;
|
|
887
888
|
}
|
|
888
889
|
try {
|
|
889
|
-
const
|
|
890
|
+
const config = {
|
|
890
891
|
address: resolveDaemonAddress(env, home),
|
|
891
892
|
session: void 0,
|
|
892
893
|
token: void 0,
|
|
893
894
|
connectTimeoutMs: 2e3,
|
|
894
895
|
responseTimeoutMs: 1e4
|
|
895
|
-
}
|
|
896
|
+
};
|
|
897
|
+
const { queued } = await requestSkillReload(version, config);
|
|
896
898
|
if (queued > 0) stderr(`Asked ${String(queued)} running session(s) to re-read the spur-board skill.\n`);
|
|
897
899
|
} catch (error) {
|
|
898
900
|
stderr(`Running sessions were not asked to re-read the spur-board skill: ${reasonOf(error)}. \`board doctor\` lists them under sessions.stale.\n`);
|
|
899
901
|
}
|
|
900
902
|
}
|
|
901
|
-
|
|
902
|
-
//#region src/skills.ts
|
|
903
|
+
// src/skills.ts
|
|
903
904
|
const stampName = ".spur-board-install.json";
|
|
904
905
|
const installId = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
905
906
|
const skills = [{
|
|
@@ -988,12 +989,14 @@ async function createMissingParents(paths) {
|
|
|
988
989
|
}
|
|
989
990
|
async function withInstallLock(home, env, action) {
|
|
990
991
|
const configured = env["XDG_STATE_HOME"];
|
|
991
|
-
const
|
|
992
|
+
const stateHome = configured && isAbsolute(configured) ? configured : join(home, ".local", "state");
|
|
993
|
+
const stateDir = join(stateHome, "spur-board");
|
|
992
994
|
await mkdir(stateDir, {
|
|
993
995
|
recursive: true,
|
|
994
996
|
mode: 448
|
|
995
997
|
});
|
|
996
|
-
const
|
|
998
|
+
const file = join(stateDir, "skills-install.lock");
|
|
999
|
+
const fd = openSync(file, constants.O_CREAT | constants.O_RDWR | constants.O_NOFOLLOW, 384);
|
|
997
1000
|
try {
|
|
998
1001
|
await new Promise((resolveLock, reject) => {
|
|
999
1002
|
const child = spawn("flock", [
|
|
@@ -1078,9 +1081,10 @@ async function recoverSkill(parent, destination, name) {
|
|
|
1078
1081
|
async function installIntoHome(home, packageRoot, version, options, env) {
|
|
1079
1082
|
const targets = await Promise.all(agents.map(async (agent) => {
|
|
1080
1083
|
const configured = agent === ".codex" ? env["CODEX_HOME"] : void 0;
|
|
1084
|
+
const root = configured ? resolve(configured) : join(home, agent);
|
|
1081
1085
|
return {
|
|
1082
1086
|
agent,
|
|
1083
|
-
...await resolvedParent(join(
|
|
1087
|
+
...await resolvedParent(join(root, "skills"))
|
|
1084
1088
|
};
|
|
1085
1089
|
}));
|
|
1086
1090
|
for (const { parent } of targets) for (const skill of skills) await targetDirectory(join(parent, skill.name));
|
|
@@ -1120,7 +1124,8 @@ async function installIntoHome(home, packageRoot, version, options, env) {
|
|
|
1120
1124
|
const backup = join(parent, `.${skill.name}-backup-${backupId}`);
|
|
1121
1125
|
const backupOwner = `${backup}.owner`;
|
|
1122
1126
|
const original = await lstat(destination, { bigint: true });
|
|
1123
|
-
|
|
1127
|
+
const identity = `${String(original.dev)}:${String(original.ino)}`;
|
|
1128
|
+
await writeFile(backupOwner, `spur-board backup ${backupId} ${identity}\n`, {
|
|
1124
1129
|
flag: "wx",
|
|
1125
1130
|
mode: 384
|
|
1126
1131
|
});
|
|
@@ -1166,8 +1171,7 @@ async function installSkills(options = {}) {
|
|
|
1166
1171
|
await Promise.all(skills.map((skill) => requireSource(join(packageRoot, "skills", skill.source))));
|
|
1167
1172
|
return withInstallLock(home, env, () => installIntoHome(home, packageRoot, version, options, env));
|
|
1168
1173
|
}
|
|
1169
|
-
|
|
1170
|
-
//#region src/update.ts
|
|
1174
|
+
// src/update.ts
|
|
1171
1175
|
const stateSchema = z.object({
|
|
1172
1176
|
schema: z.literal(1),
|
|
1173
1177
|
status: z.enum([
|
|
@@ -2058,8 +2062,7 @@ async function rollback(updater, options, yes) {
|
|
|
2058
2062
|
operator: [MCP_LINE]
|
|
2059
2063
|
};
|
|
2060
2064
|
}
|
|
2061
|
-
|
|
2062
|
-
//#region src/cli.ts
|
|
2065
|
+
// src/cli.ts
|
|
2063
2066
|
const processIo = {
|
|
2064
2067
|
stdout: (text) => process.stdout.write(text),
|
|
2065
2068
|
stderr: (text) => process.stderr.write(text),
|
|
@@ -2530,5 +2533,4 @@ async function runCli(argv, options = {}) {
|
|
|
2530
2533
|
return errorExitCode(cliError);
|
|
2531
2534
|
}
|
|
2532
2535
|
}
|
|
2533
|
-
//#endregion
|
|
2534
2536
|
export { createProgram, exampleCommand, runCli };
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { fetchCatalogVersion, fetchTokenStatus, requestOperation, requestSkillReload, requestTokenEnrollment };
|
|
1
|
+
export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-Bwz_FohV.mjs";
|