@skrr-ai/cli 0.1.143 → 0.1.145

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.
Files changed (102) hide show
  1. package/README.md +13 -0
  2. package/dist/commands/agenda/plan.d.ts +7 -0
  3. package/dist/commands/agenda/plan.js +17 -0
  4. package/dist/commands/agenda/trigger/create.js +4 -2
  5. package/dist/commands/agenda/trigger/list.js +7 -7
  6. package/dist/commands/agent/message/approve.d.ts +17 -0
  7. package/dist/commands/agent/message/approve.js +70 -0
  8. package/dist/commands/agent/message/decline.d.ts +17 -0
  9. package/dist/commands/agent/message/decline.js +70 -0
  10. package/dist/commands/agent/message/pending.d.ts +18 -0
  11. package/dist/commands/agent/message/pending.js +79 -0
  12. package/dist/commands/agents/delete.d.ts +45 -0
  13. package/dist/commands/agents/delete.js +139 -2
  14. package/dist/commands/agents/plan-day.d.ts +50 -7
  15. package/dist/commands/agents/plan-day.js +293 -65
  16. package/dist/commands/agents/proactive-audit.d.ts +22 -0
  17. package/dist/commands/agents/proactive-audit.js +86 -0
  18. package/dist/commands/agents/schedule-overview.d.ts +7 -0
  19. package/dist/commands/agents/schedule-overview.js +49 -5
  20. package/dist/commands/agents/schedule-trace.js +42 -21
  21. package/dist/commands/agents/spawn.d.ts +78 -1
  22. package/dist/commands/agents/spawn.js +262 -6
  23. package/dist/commands/agents/todos/list.d.ts +5 -0
  24. package/dist/commands/agents/todos/list.js +19 -5
  25. package/dist/commands/agents/triggers/create.js +1 -1
  26. package/dist/commands/agents/triggers/update.js +1 -1
  27. package/dist/commands/agents/upcoming.d.ts +1 -0
  28. package/dist/commands/agents/upcoming.js +18 -7
  29. package/dist/commands/commitments/create.js +14 -4
  30. package/dist/commands/commitments/preflight.js +14 -3
  31. package/dist/commands/commitments/update.js +1 -1
  32. package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
  33. package/dist/commands/initiatives/worker/deactivate.js +78 -0
  34. package/dist/commands/login.js +8 -2
  35. package/dist/commands/logout.d.ts +20 -0
  36. package/dist/commands/logout.js +110 -5
  37. package/dist/commands/memory/maintain.js +16 -2
  38. package/dist/commands/spaces/delete.js +6 -1
  39. package/dist/commands/spaces/workflow-templates/insert.js +4 -0
  40. package/dist/commands/spaces/workflows/archive.js +6 -1
  41. package/dist/commands/spaces/workflows/publish.js +3 -1
  42. package/dist/commands/spaces/workflows/run.d.ts +1 -0
  43. package/dist/commands/spaces/workflows/run.js +17 -1
  44. package/dist/commands/spaces/workflows/triggers/create.js +3 -1
  45. package/dist/commands/store/show.js +22 -0
  46. package/dist/commands/tasks/workflow-context.js +3 -1
  47. package/dist/commands/triggers/capabilities.js +17 -1
  48. package/dist/commands/triggers/create.d.ts +2 -0
  49. package/dist/commands/triggers/create.js +23 -7
  50. package/dist/commands/triggers/fire-detail.js +12 -3
  51. package/dist/commands/triggers/list.d.ts +1 -0
  52. package/dist/commands/triggers/list.js +13 -1
  53. package/dist/commands/triggers/preflight.js +18 -0
  54. package/dist/commands/triggers/prune.js +9 -5
  55. package/dist/commands/triggers/update.js +13 -4
  56. package/dist/generated/agent-guides.json +35 -35
  57. package/dist/lib/agent-proactive-baseline.js +7 -1
  58. package/dist/lib/agentic-stream.d.ts +7 -0
  59. package/dist/lib/agentic-stream.js +22 -0
  60. package/dist/lib/commitments.d.ts +16 -9
  61. package/dist/lib/commitments.js +78 -5
  62. package/dist/lib/compasses.js +1 -1
  63. package/dist/lib/daemon-setup.js +9 -3
  64. package/dist/lib/daemonBroker.d.ts +7 -0
  65. package/dist/lib/daemonBroker.js +5 -0
  66. package/dist/lib/daemonHandoff.d.ts +2 -0
  67. package/dist/lib/daemonHandoff.js +10 -1
  68. package/dist/lib/daemonIslandProfile.d.ts +19 -0
  69. package/dist/lib/daemonIslandProfile.js +41 -0
  70. package/dist/lib/dedicated-power.js +10 -3
  71. package/dist/lib/format.d.ts +47 -0
  72. package/dist/lib/format.js +136 -1
  73. package/dist/lib/initiatives-worker.d.ts +25 -0
  74. package/dist/lib/initiatives-worker.js +13 -0
  75. package/dist/lib/login.d.ts +7 -0
  76. package/dist/lib/login.js +5 -0
  77. package/dist/lib/planOutcome.d.ts +51 -0
  78. package/dist/lib/planOutcome.js +88 -0
  79. package/dist/lib/proactive-audit.d.ts +52 -0
  80. package/dist/lib/proactive-audit.js +67 -0
  81. package/dist/lib/proactiveApi.d.ts +71 -0
  82. package/dist/lib/proactiveApi.js +10 -1
  83. package/dist/lib/refresh.d.ts +20 -6
  84. package/dist/lib/refresh.js +27 -9
  85. package/dist/lib/roles.d.ts +1 -1
  86. package/dist/lib/schedule.d.ts +214 -10
  87. package/dist/lib/schedule.js +317 -21
  88. package/dist/lib/triggers.d.ts +139 -3
  89. package/dist/lib/triggers.js +382 -18
  90. package/dist/lib/workflow-node-control.js +8 -0
  91. package/dist/lib/workflow-run-view.js +9 -0
  92. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +1 -1
  93. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +2 -0
  94. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
  95. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
  96. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +1 -1
  97. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +1 -1
  98. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
  99. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
  100. package/dist/node_modules/@skrr-ai/data-provider/index.js +5252 -5211
  101. package/oclif.manifest.json +526 -29
  102. package/package.json +1 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.displayWidth = displayWidth;
4
4
  exports.pad = pad;
5
5
  exports.truncate = truncate;
6
+ exports.truncateMiddle = truncateMiddle;
6
7
  exports.truncateAtWord = truncateAtWord;
7
8
  exports.formatCell = formatCell;
8
9
  exports.collapseWhitespace = collapseWhitespace;
@@ -10,6 +11,9 @@ exports.renderTable = renderTable;
10
11
  exports.localStamp = localStamp;
11
12
  exports.localTime = localTime;
12
13
  exports.localZone = localZone;
14
+ exports.zoneAbbreviation = zoneAbbreviation;
15
+ exports.zonedTime = zonedTime;
16
+ exports.localizeIsoInstants = localizeIsoInstants;
13
17
  exports.formatWhen = formatWhen;
14
18
  /**
15
19
  * Code points that occupy TWO terminal columns (Unicode East Asian Wide and
@@ -106,6 +110,46 @@ function truncate(s, max) {
106
110
  }
107
111
  return `${out}…`;
108
112
  }
113
+ /**
114
+ * Truncate in the MIDDLE, keeping both ends: `[df-261102-trig…tion-tc01] text-out`.
115
+ *
116
+ * For a cell whose two ends both carry meaning. A trigger label starts with a run tag and the tag's
117
+ * last characters are what tell two runs apart, so cutting the tail (`truncate`) kept the part they
118
+ * share and dropped the part that differs (OSK-22493).
119
+ */
120
+ function truncateMiddle(s, max) {
121
+ if (displayWidth(s) <= max)
122
+ return s;
123
+ if (max <= 3)
124
+ return truncate(s, max);
125
+ const budget = max - 1; // room for the ellipsis
126
+ const tailBudget = Math.floor(budget / 2);
127
+ const headBudget = budget - tailBudget;
128
+ const widthOf = (ch) => {
129
+ const cp = ch.codePointAt(0) ?? 0;
130
+ return inRanges(cp, ZERO_RANGES) ? 0 : inRanges(cp, WIDE_RANGES) ? 2 : 1;
131
+ };
132
+ let head = '';
133
+ let used = 0;
134
+ for (const ch of s) {
135
+ const w = widthOf(ch);
136
+ if (used + w > headBudget)
137
+ break;
138
+ head += ch;
139
+ used += w;
140
+ }
141
+ const chars = Array.from(s);
142
+ let tail = '';
143
+ used = 0;
144
+ for (let i = chars.length - 1; i >= 0; i -= 1) {
145
+ const w = widthOf(chars[i]);
146
+ if (used + w > tailBudget)
147
+ break;
148
+ tail = chars[i] + tail;
149
+ used += w;
150
+ }
151
+ return `${head}…${tail}`;
152
+ }
109
153
  /**
110
154
  * `truncate`, but never in the middle of a word.
111
155
  *
@@ -216,7 +260,8 @@ function renderTable(rows, columns, log) {
216
260
  const key = String(col.key);
217
261
  const raw = row[key];
218
262
  const width = widths[key];
219
- return pad(col.verbatim ? raw : truncate(raw, width), width);
263
+ const clip = col.truncate === 'middle' ? truncateMiddle : truncate;
264
+ return pad(col.verbatim ? raw : clip(raw, width), width);
220
265
  })
221
266
  .join(' ');
222
267
  log(line);
@@ -289,6 +334,96 @@ function localZone(at = new Date()) {
289
334
  const abs = Math.abs(offset);
290
335
  return `UTC${sign}${`${Math.floor(abs / 60)}`.padStart(2, '0')}:${`${abs % 60}`.padStart(2, '0')}`;
291
336
  }
337
+ /**
338
+ * `PST` / `PDT` / `GMT+8` — the short name of `timeZone` at `at`, or an empty
339
+ * string when the runtime cannot name it. Used to label a time that is shown in
340
+ * a zone the reader did not necessarily choose (a plan's own zone).
341
+ */
342
+ function zoneAbbreviation(timeZone, at = new Date()) {
343
+ try {
344
+ const parts = new Intl.DateTimeFormat('en-US', {
345
+ timeZone,
346
+ timeZoneName: 'short',
347
+ }).formatToParts(at);
348
+ return parts.find((part) => part.type === 'timeZoneName')?.value ?? '';
349
+ }
350
+ catch {
351
+ return '';
352
+ }
353
+ }
354
+ /**
355
+ * One instant rendered in an EXPLICIT IANA zone, with the zone named:
356
+ * `2026-11-02 17:13:40 PST`.
357
+ *
358
+ * `localTime` renders in the machine's zone. A Smart Schedule plan has its own
359
+ * zone, and the instants a plan prints (expiry at the plan day's local midnight,
360
+ * the suggested next run, a trace row) are only readable in THAT zone: printed as
361
+ * raw UTC, `Expires: 2026-11-03T08:00:00.000Z` makes the reader work out that
362
+ * 08:00Z is local midnight, and a trace row at 01:13 UTC reads as an event from
363
+ * tomorrow under a header naming today (OSK-22397). `--json` keeps the raw UTC
364
+ * instant; this is for text only. Never throws: an unparseable value comes back
365
+ * as given, and an unknown zone falls back to UTC, labelled.
366
+ */
367
+ function zonedTime(value, timeZone, options = {}) {
368
+ if (value === null || value === undefined || value === '')
369
+ return '-';
370
+ const date = value instanceof Date ? value : new Date(typeof value === 'number' ? value : String(value));
371
+ if (Number.isNaN(date.getTime()))
372
+ return String(value);
373
+ const seconds = options.seconds !== false;
374
+ const render = (zone) => {
375
+ const parts = new Intl.DateTimeFormat('en-CA', {
376
+ timeZone: zone,
377
+ year: 'numeric',
378
+ month: '2-digit',
379
+ day: '2-digit',
380
+ hour: '2-digit',
381
+ minute: '2-digit',
382
+ second: '2-digit',
383
+ hourCycle: 'h23',
384
+ }).formatToParts(date);
385
+ const get = (type) => parts.find((part) => part.type === type)?.value ?? '00';
386
+ const label = zoneAbbreviation(zone, date) || zone;
387
+ return (`${get('year')}-${get('month')}-${get('day')} ${get('hour')}:${get('minute')}` +
388
+ `${seconds ? `:${get('second')}` : ''} ${label}`);
389
+ };
390
+ try {
391
+ return render(timeZone);
392
+ }
393
+ catch {
394
+ return render('UTC');
395
+ }
396
+ }
397
+ /**
398
+ * A full ISO-8601 instant: date, time and an explicit UTC designator or offset
399
+ * (`2026-11-04T08:00:00.000Z`, `2026-11-04T08:00+00:00`). A date alone, or a time
400
+ * with no zone, names no instant and is deliberately not matched.
401
+ */
402
+ const ISO_INSTANT = /\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}(?::?\d{2})?)(?![\w])/g;
403
+ /**
404
+ * Rewrite the full ISO-8601 instants inside a sentence into `timeZone`, named:
405
+ * `Next planning run scheduled for 2026-11-04T08:00:00.000Z` becomes
406
+ * `... for 2026-11-04 00:00 PST`.
407
+ *
408
+ * The server writes its own summary strings, and some of them embed an instant
409
+ * (a scheduled run, a prompt that quotes a time). Printed as they arrive, the
410
+ * rest of the output is in the plan's zone while these stay in UTC, so the same
411
+ * moment reads two ways on one screen (OSK-22588). This touches ONLY a complete
412
+ * instant with an explicit zone, never a bare date, a time of day or an ID that
413
+ * merely looks like one, so it cannot reword a sentence it does not understand.
414
+ * Seconds are shown only when the instant has them. Text only: `--json` keeps
415
+ * the server's string untouched. Never throws.
416
+ */
417
+ function localizeIsoInstants(text, timeZone) {
418
+ if (!text || !text.includes('T'))
419
+ return text;
420
+ return text.replace(ISO_INSTANT, (match) => {
421
+ const date = new Date(match);
422
+ if (Number.isNaN(date.getTime()))
423
+ return match;
424
+ return zonedTime(date, timeZone, { seconds: date.getUTCSeconds() !== 0 });
425
+ });
426
+ }
292
427
  function zonedParts(date, timeZone) {
293
428
  const parts = new Intl.DateTimeFormat('en-CA', {
294
429
  timeZone,
@@ -0,0 +1,25 @@
1
+ export interface WorkerDeactivateResult {
2
+ agentId: string;
3
+ enabled: false;
4
+ /** One entry per worker watcher kind; `skipped` when the agent has none of that kind. */
5
+ schedules: Array<{
6
+ kind: string;
7
+ skipped?: boolean;
8
+ schedule?: {
9
+ triggerId?: string;
10
+ enabled?: boolean;
11
+ } | null;
12
+ }>;
13
+ initiativeClosure?: {
14
+ skipped?: boolean;
15
+ matched?: number;
16
+ modified?: number;
17
+ };
18
+ }
19
+ export declare const initiativesWorkerApi: {
20
+ deactivate: (input: {
21
+ agentId: string;
22
+ reason?: string;
23
+ closeOpenInitiatives?: boolean;
24
+ }) => Promise<WorkerDeactivateResult>;
25
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initiativesWorkerApi = void 0;
4
+ /**
5
+ * initiatives-worker.ts — client for the worker-wide controls under `/api/initiatives/workers`.
6
+ *
7
+ * The web Control Center had a way to pause an agent's worker; the CLI had none, so a refusal that
8
+ * told a person "change the object that owns it" had no command to point at (OSK-22423).
9
+ */
10
+ const data_provider_1 = require("@skrr-ai/data-provider");
11
+ exports.initiativesWorkerApi = {
12
+ deactivate: (input) => data_provider_1.request.post('/api/initiatives/workers/deactivate', input),
13
+ };
@@ -18,6 +18,13 @@ export interface CliLoginResult {
18
18
  refreshExpiresAt?: number;
19
19
  /** The flow that produced the token; for diagnostics / telemetry. */
20
20
  flow: 'localhost' | 'device-code' | 'refresh-token' | 'daemon-broker';
21
+ /**
22
+ * With `flow: 'daemon-broker'`: the profile of the daemon that brokered it,
23
+ * when its descriptor names one. The broker borrows whichever daemon is
24
+ * running, so after `skrr login --profile work` this is usually `default`, and
25
+ * `work`'s own daemon still needs a credential (OSK-22309).
26
+ */
27
+ brokerProfile?: string;
21
28
  }
22
29
  export interface CliLoginWithRefreshTokenOptions {
23
30
  /** Server base URL. Defaults to config. */
package/dist/lib/login.js CHANGED
@@ -37,6 +37,7 @@ const device_code_1 = require("./device-code");
37
37
  const device_identity_1 = require("./device-identity");
38
38
  const oauthLogin_1 = require("./oauthLogin");
39
39
  const daemonBroker_1 = require("./daemonBroker");
40
+ const daemonIslandProfile_1 = require("./daemonIslandProfile");
40
41
  const dedicated_guest_1 = require("./dedicated-guest");
41
42
  const daemonBrokerRefusal_1 = require("./daemonBrokerRefusal");
42
43
  /**
@@ -122,6 +123,8 @@ async function cliLogin(opts = {}) {
122
123
  baseURL: serverUrl,
123
124
  });
124
125
  if (brokerResult.ok) {
126
+ const brokerProfile = (0, daemonIslandProfile_1.bootstrapDescriptorProfile)(brokerResult.descriptorPath);
127
+ const brokeredBy = brokerProfile ? { brokerProfile } : {};
125
128
  if (brokerResult.brokered) {
126
129
  // Broker-mode hand-off: the daemon served a short-lived access token
127
130
  // from a family IT owns. Nothing credential-shaped is persisted here
@@ -144,6 +147,7 @@ async function cliLogin(opts = {}) {
144
147
  ? { expiresAt: brokerResult.accessExpiresAt }
145
148
  : {}),
146
149
  flow: 'daemon-broker',
150
+ ...brokeredBy,
147
151
  };
148
152
  }
149
153
  console.log('');
@@ -163,6 +167,7 @@ async function cliLogin(opts = {}) {
163
167
  ? { refreshExpiresAt: Date.parse(brokerResult.refreshExpiresAt) }
164
168
  : {}),
165
169
  flow: 'daemon-broker',
170
+ ...brokeredBy,
166
171
  };
167
172
  }
168
173
  // `ci_token_refused` is the one broker failure we surface rather
@@ -0,0 +1,51 @@
1
+ /**
2
+ * planOutcome.ts — read a Smart Schedule planning fire's recorded outcome.
3
+ *
4
+ * A watcher or planning-run fire that "completed" may have drafted nothing: it was watch-only,
5
+ * nothing changed, One Voice held it, quiet hours lowered auto to review, the planner proposed no
6
+ * blocks or failed. The API records which one on the fire (`metadata.builtinAction.planOutcome`) and
7
+ * the schedule trace carries it on the event (`detail.planOutcome`). These helpers only read and
8
+ * word that record; the vocabulary is owned by `@skrr-ai/data-provider` and the sentence by the API.
9
+ */
10
+ import { type SmartSchedulePlanOutcome } from '@skrr-ai/data-provider';
11
+ /** The recorded outcome in `value`, or null when it is absent or not a known outcome. */
12
+ export declare function readPlanOutcome(value: unknown): SmartSchedulePlanOutcome | null;
13
+ interface TraceEventLike {
14
+ id?: string;
15
+ summary?: string;
16
+ occurredAt?: string;
17
+ detail?: unknown;
18
+ }
19
+ /**
20
+ * Under the trace table: for every planning fire, WHY it did or did not leave a plan. The table's
21
+ * summary column says what ran; this says what it decided.
22
+ */
23
+ export declare function renderPlanOutcomeTraceDetails(events: TraceEventLike[], log: (line: string) => void, formatWhen?: (at: string) => string): void;
24
+ /**
25
+ * The answer to "why no plan today?" from the newest planning fire in this trace, or null when no
26
+ * fire in it recorded an outcome. Events arrive newest first.
27
+ */
28
+ export declare function latestPlanOutcomeLine(events: TraceEventLike[]): string | null;
29
+ /**
30
+ * The REASON column of a fire-audit row: the planning outcome's sentence when the fire recorded
31
+ * one, else undefined so the caller falls back to the fire's own reason.
32
+ */
33
+ export declare function fireAuditPlanOutcomeSummary(fire: {
34
+ metadata?: {
35
+ builtinAction?: {
36
+ planOutcome?: unknown;
37
+ };
38
+ };
39
+ }): string | undefined;
40
+ /** A trigger the Always-On control fence withholds, as `/api/upcoming` reports it. */
41
+ interface WithheldLike {
42
+ reason?: string;
43
+ }
44
+ /**
45
+ * The line under "withheld" in the upcoming view when the cause is Always-On. A trigger that is
46
+ * listed under Upcoming has passed the same fence the withheld ones failed, so it is not gated by
47
+ * Always-On: it still fires. Without this the two lists sit side by side and read as one rule
48
+ * (OSK-22406). Null when nothing is withheld for Always-On or nothing is listed.
49
+ */
50
+ export declare function alwaysOnUpcomingNote(withheld: WithheldLike[], listedCount: number): string | null;
51
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readPlanOutcome = readPlanOutcome;
4
+ exports.renderPlanOutcomeTraceDetails = renderPlanOutcomeTraceDetails;
5
+ exports.latestPlanOutcomeLine = latestPlanOutcomeLine;
6
+ exports.fireAuditPlanOutcomeSummary = fireAuditPlanOutcomeSummary;
7
+ exports.alwaysOnUpcomingNote = alwaysOnUpcomingNote;
8
+ /**
9
+ * planOutcome.ts — read a Smart Schedule planning fire's recorded outcome.
10
+ *
11
+ * A watcher or planning-run fire that "completed" may have drafted nothing: it was watch-only,
12
+ * nothing changed, One Voice held it, quiet hours lowered auto to review, the planner proposed no
13
+ * blocks or failed. The API records which one on the fire (`metadata.builtinAction.planOutcome`) and
14
+ * the schedule trace carries it on the event (`detail.planOutcome`). These helpers only read and
15
+ * word that record; the vocabulary is owned by `@skrr-ai/data-provider` and the sentence by the API.
16
+ */
17
+ const data_provider_1 = require("@skrr-ai/data-provider");
18
+ /** The recorded outcome in `value`, or null when it is absent or not a known outcome. */
19
+ function readPlanOutcome(value) {
20
+ if (!value || typeof value !== 'object')
21
+ return null;
22
+ const candidate = value;
23
+ if (!(0, data_provider_1.isSmartSchedulePlanOutcomeCode)(candidate.outcome))
24
+ return null;
25
+ if (typeof candidate.reason !== 'string' || !candidate.reason)
26
+ return null;
27
+ return candidate;
28
+ }
29
+ function eventOutcome(event) {
30
+ const detail = event.detail;
31
+ if (!detail || typeof detail !== 'object')
32
+ return null;
33
+ return readPlanOutcome(detail.planOutcome);
34
+ }
35
+ /**
36
+ * Under the trace table: for every planning fire, WHY it did or did not leave a plan. The table's
37
+ * summary column says what ran; this says what it decided.
38
+ */
39
+ function renderPlanOutcomeTraceDetails(events, log,
40
+ // The caller's own clock, so these lines agree with the table above them.
41
+ formatWhen = (at) => at.slice(0, 19).replace('T', ' ')) {
42
+ const rows = events
43
+ .map((event) => ({ event, outcome: eventOutcome(event) }))
44
+ .filter((row) => Boolean(row.outcome));
45
+ if (rows.length === 0)
46
+ return;
47
+ log('');
48
+ log('Planning outcomes:');
49
+ for (const { event, outcome } of rows) {
50
+ const when = event.occurredAt ? formatWhen(String(event.occurredAt)) : '-';
51
+ log(` ${when} ${outcome.outcome}${outcome.reasonCode ? ` (${outcome.reasonCode})` : ''}`);
52
+ log(` ${outcome.reason}`);
53
+ }
54
+ }
55
+ /**
56
+ * The answer to "why no plan today?" from the newest planning fire in this trace, or null when no
57
+ * fire in it recorded an outcome. Events arrive newest first.
58
+ */
59
+ function latestPlanOutcomeLine(events) {
60
+ for (const event of events) {
61
+ const outcome = eventOutcome(event);
62
+ if (outcome)
63
+ return outcome.reason;
64
+ }
65
+ return null;
66
+ }
67
+ /**
68
+ * The REASON column of a fire-audit row: the planning outcome's sentence when the fire recorded
69
+ * one, else undefined so the caller falls back to the fire's own reason.
70
+ */
71
+ function fireAuditPlanOutcomeSummary(fire) {
72
+ return readPlanOutcome(fire.metadata?.builtinAction?.planOutcome)?.reason;
73
+ }
74
+ const ALWAYS_ON_REASONS = new Set(['disabled', 'always_on_disabled']);
75
+ /**
76
+ * The line under "withheld" in the upcoming view when the cause is Always-On. A trigger that is
77
+ * listed under Upcoming has passed the same fence the withheld ones failed, so it is not gated by
78
+ * Always-On: it still fires. Without this the two lists sit side by side and read as one rule
79
+ * (OSK-22406). Null when nothing is withheld for Always-On or nothing is listed.
80
+ */
81
+ function alwaysOnUpcomingNote(withheld, listedCount) {
82
+ if (listedCount === 0)
83
+ return null;
84
+ if (!withheld.some((trigger) => ALWAYS_ON_REASONS.has(String(trigger.reason ?? ''))))
85
+ return null;
86
+ return ('Always-On is off for this agent. The withheld triggers wait for it; the triggers listed under ' +
87
+ 'Upcoming are not gated by Always-On, so they still fire.');
88
+ }
@@ -0,0 +1,52 @@
1
+ export type ProactiveAuditDomain = 'agent_compass' | 'agent_initiatives' | 'smart_schedule' | 'goal_planner';
2
+ export interface ProactiveAuditEvent {
3
+ id: string;
4
+ domain: string;
5
+ changeType?: string | null;
6
+ actorType?: string | null;
7
+ actorUserId?: string | null;
8
+ actorAgentId?: string | null;
9
+ reason?: string | null;
10
+ summary?: string | null;
11
+ occurredAt?: string | null;
12
+ }
13
+ /** One watcher switch as the run reads it. `default` = the trigger names no value. */
14
+ export interface WatcherSettingValue {
15
+ value: boolean;
16
+ source: 'trigger' | 'default';
17
+ }
18
+ export interface TaskGoalWatcherTrigger {
19
+ triggerId: string;
20
+ label: string | null;
21
+ enabled: boolean;
22
+ taskGoalDeltaMode: WatcherSettingValue;
23
+ crossDomainDedupe: WatcherSettingValue;
24
+ }
25
+ export interface TaskGoalWatcherSettings {
26
+ settings: Record<string, {
27
+ default: boolean;
28
+ meaning: string;
29
+ }>;
30
+ triggers: TaskGoalWatcherTrigger[];
31
+ }
32
+ export interface ProactiveAuditResponse {
33
+ events: ProactiveAuditEvent[];
34
+ taskGoalWatcher?: TaskGoalWatcherSettings;
35
+ }
36
+ export declare function proactiveAuditPath(params: {
37
+ agentId: string;
38
+ domain?: ProactiveAuditDomain;
39
+ limit?: number;
40
+ }): string;
41
+ export declare const proactiveAuditApi: {
42
+ read: (params: {
43
+ agentId: string;
44
+ domain?: ProactiveAuditDomain;
45
+ limit?: number;
46
+ }) => Promise<ProactiveAuditResponse>;
47
+ };
48
+ /**
49
+ * The text form of the watcher block: for each switch, its effective value, where it comes from, and
50
+ * what it does. Pure, so what a reader is told is pinned by a spec rather than by a run.
51
+ */
52
+ export declare function renderTaskGoalWatcherSettings(watcher: TaskGoalWatcherSettings | undefined, log: (line: string) => void): void;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.proactiveAuditApi = void 0;
4
+ exports.proactiveAuditPath = proactiveAuditPath;
5
+ exports.renderTaskGoalWatcherSettings = renderTaskGoalWatcherSettings;
6
+ /**
7
+ * proactive-audit.ts — client for `GET /api/todos/proactive-audit`: the cross-domain
8
+ * "who changed this agent's proactivity boundary, when, why" ledger, plus the two switches the
9
+ * agent's task/goal watcher runs with.
10
+ *
11
+ * The route shipped with the web client's types only, so a headless owner could read neither the
12
+ * ledger nor `crossDomainDedupe`, and a watcher run printing `"crossDomainDedupe": true` could not
13
+ * be told apart from a setting someone chose (OSK-22418).
14
+ */
15
+ const data_provider_1 = require("@skrr-ai/data-provider");
16
+ const triggers_1 = require("./triggers");
17
+ function proactiveAuditPath(params) {
18
+ return (0, triggers_1.withQuery)('/api/todos/proactive-audit', {
19
+ agentId: params.agentId,
20
+ domain: params.domain,
21
+ limit: params.limit,
22
+ });
23
+ }
24
+ exports.proactiveAuditApi = {
25
+ read: (params) => data_provider_1.request.get(proactiveAuditPath(params)),
26
+ };
27
+ const SETTING_LABELS = [
28
+ ['taskGoalDeltaMode', 'Only new pressure (delta mode)'],
29
+ ['crossDomainDedupe', 'One voice (cross-domain dedupe)'],
30
+ ];
31
+ function describeSetting(setting) {
32
+ const state = setting.value ? 'on' : 'off';
33
+ return setting.source === 'trigger'
34
+ ? `${state} (set on the watcher trigger)`
35
+ : `${state} (platform default; the watcher trigger sets no value)`;
36
+ }
37
+ /**
38
+ * The text form of the watcher block: for each switch, its effective value, where it comes from, and
39
+ * what it does. Pure, so what a reader is told is pinned by a spec rather than by a run.
40
+ */
41
+ function renderTaskGoalWatcherSettings(watcher, log) {
42
+ if (!watcher) {
43
+ log('Task/goal watcher settings were not returned (a read failure, or a server older than this field); the ledger above is unaffected.');
44
+ return;
45
+ }
46
+ if (watcher.triggers.length === 0) {
47
+ log('Task/goal watcher: none installed on this agent, so no run reads these switches.');
48
+ for (const [key, label] of SETTING_LABELS) {
49
+ const info = watcher.settings[key];
50
+ if (info)
51
+ log(` ${label}: ${info.default ? 'on' : 'off'} by default - ${info.meaning}`);
52
+ }
53
+ return;
54
+ }
55
+ for (const trigger of watcher.triggers) {
56
+ log(`Task/goal watcher ${trigger.triggerId}${trigger.label ? ` (${trigger.label})` : ''}` +
57
+ ` - ${trigger.enabled ? 'enabled' : 'disabled'}`);
58
+ for (const [key, label] of SETTING_LABELS) {
59
+ log(` ${label}: ${describeSetting(trigger[key])}`);
60
+ const meaning = watcher.settings[key]?.meaning;
61
+ if (meaning)
62
+ log(` ${meaning}`);
63
+ }
64
+ }
65
+ log('These are not settable from the CLI: a worker watcher belongs to the platform, and a run');
66
+ log('echoes the effective values in its counts (`skrr agents triggers runs <agent> <trigger>`).');
67
+ }
@@ -94,6 +94,30 @@ export interface PlanProactiveAgentResponse {
94
94
  outputTokens: number;
95
95
  };
96
96
  }
97
+ /** One object a spec will install (`POST /api/initiatives/spawn/preview`). */
98
+ export interface InstallPlanItem {
99
+ kind: string;
100
+ name: string;
101
+ label: string;
102
+ /** `requested` = the spec names it; `default` = the platform adds it, and `why` says why. */
103
+ origin: 'requested' | 'default';
104
+ why: string;
105
+ status: 'install' | 'declined' | 'will_be_blocked';
106
+ reason?: string;
107
+ detail?: string;
108
+ }
109
+ export interface InstallPreviewResponse {
110
+ items: InstallPlanItem[];
111
+ options: {
112
+ minimal: boolean;
113
+ without: string[];
114
+ };
115
+ runtime: {
116
+ commitments: 'can_run' | 'cannot_run' | 'unknown';
117
+ };
118
+ }
119
+ /** The defaults `--without` can decline; the server refuses any other name. */
120
+ export declare const DECLINABLE_DEFAULTS: readonly ["memory_watcher", "task_goal_watcher", "initiative_follow_through", "relationship_loops"];
97
121
  export interface ApplyWarning {
98
122
  step: string;
99
123
  code: string;
@@ -109,6 +133,9 @@ export interface ApplyProactiveAgentResponse {
109
133
  source: string;
110
134
  ok: boolean;
111
135
  code?: string;
136
+ /** The trigger the watcher became; absent on a failure or an older server. */
137
+ triggerId?: string;
138
+ enabled?: boolean;
112
139
  }>;
113
140
  };
114
141
  alwaysOn?: {
@@ -127,6 +154,12 @@ export interface ApplyProactiveAgentResponse {
127
154
  skipped?: string;
128
155
  code?: string;
129
156
  };
157
+ /** Where the apply put a new Agent, when it chose (the owner's own Codex machine). */
158
+ runsOn?: {
159
+ kind: string;
160
+ harnessId?: string;
161
+ label?: string;
162
+ };
130
163
  orchestrator?: {
131
164
  ok: boolean;
132
165
  status?: string;
@@ -163,6 +196,22 @@ export interface ApplyProactiveAgentResponse {
163
196
  /** The first attempt made this one; a retry reported it instead of creating it again. */
164
197
  existing?: boolean;
165
198
  }>;
199
+ /** Everything that exists on the Agent after the apply, read back; a list is null when unreadable. */
200
+ inventory?: {
201
+ triggers: Array<{
202
+ id: string;
203
+ label: string | null;
204
+ source: string | null;
205
+ enabled: boolean;
206
+ origin: 'requested' | 'default';
207
+ }> | null;
208
+ commitments: Array<{
209
+ id: string;
210
+ title: string | null;
211
+ status: string | null;
212
+ systemRole: string | null;
213
+ }> | null;
214
+ };
166
215
  initialize?: {
167
216
  goals: Array<{
168
217
  id?: string;
@@ -186,6 +235,15 @@ export interface ApplyProactiveAgentResponse {
186
235
  };
187
236
  };
188
237
  warnings: ApplyWarning[];
238
+ /**
239
+ * Present only when `--minimal` / `--without` were requested: the defaults the server declined.
240
+ * Its absence after such a request means the server ignored the options.
241
+ */
242
+ installOptions?: {
243
+ minimal: boolean;
244
+ without: string[];
245
+ declined: string[];
246
+ };
189
247
  }
190
248
  export type ProactiveAgentRecommendationStatus = 'proposed' | 'approved' | 'applied' | 'dismissed' | 'expired' | 'failed' | 'superseded';
191
249
  export type ProactiveAgentRecommendationSource = 'meta_agent' | 'onboarding' | 'manual' | 'system';
@@ -273,7 +331,20 @@ export declare const proactiveApi: {
273
331
  fromReviewedSpec?: boolean;
274
332
  recommendationId?: string;
275
333
  approvedSpecHash?: string;
334
+ /** Decline every default the platform would add beyond what the spec asks for. */
335
+ minimal?: boolean;
336
+ /** Decline one default by name (see `DECLINABLE_DEFAULTS`). */
337
+ without?: string[];
276
338
  }) => Promise<ApplyProactiveAgentResponse>;
339
+ /** Read-only: every object a spec will install, marked requested or default. Never writes. */
340
+ previewProactiveAgentSpec: (body: {
341
+ spec: ProactiveAgentSpec;
342
+ agentId?: string;
343
+ timezone?: string;
344
+ fromReviewedSpec?: boolean;
345
+ minimal?: boolean;
346
+ without?: string[];
347
+ }) => Promise<InstallPreviewResponse>;
277
348
  /** Meta-agent path: plan and persist a reviewable recommendation. */
278
349
  planProactiveAgentRecommendation: (body: {
279
350
  name?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.proactiveApi = void 0;
3
+ exports.proactiveApi = exports.DECLINABLE_DEFAULTS = void 0;
4
4
  /**
5
5
  * proactiveApi.ts — request-based client for the "spawn a proactive agent"
6
6
  * endpoints (`/api/initiatives/spawn/*`).
@@ -15,11 +15,20 @@ exports.proactiveApi = void 0;
15
15
  * → review → `apply` (creates the agent + installs the chosen system[s]).
16
16
  */
17
17
  const data_provider_1 = require("@skrr-ai/data-provider");
18
+ /** The defaults `--without` can decline; the server refuses any other name. */
19
+ exports.DECLINABLE_DEFAULTS = [
20
+ 'memory_watcher',
21
+ 'task_goal_watcher',
22
+ 'initiative_follow_through',
23
+ 'relationship_loops',
24
+ ];
18
25
  exports.proactiveApi = {
19
26
  /** Plan-only: turn a sentence into a spec draft. Never writes. */
20
27
  planProactiveAgent: (body) => data_provider_1.request.post('/api/initiatives/spawn/plan', body),
21
28
  /** Apply a (clamped, server-re-validated) spec: create + install. */
22
29
  applyProactiveAgentSpec: (body) => data_provider_1.request.post('/api/initiatives/spawn/apply', body),
30
+ /** Read-only: every object a spec will install, marked requested or default. Never writes. */
31
+ previewProactiveAgentSpec: (body) => data_provider_1.request.post('/api/initiatives/spawn/preview', body),
23
32
  /** Meta-agent path: plan and persist a reviewable recommendation. */
24
33
  planProactiveAgentRecommendation: (body) => data_provider_1.request.post('/api/initiatives/recommendations/plan', body),
25
34
  listProactiveAgentRecommendations: (params) => {