@skrr-ai/cli 0.1.231 → 0.1.233

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 (161) hide show
  1. package/README.md +42 -4
  2. package/bin/dev.cjs +4 -1
  3. package/bin/run.js +0 -15
  4. package/dist/base-command.d.ts +6 -11
  5. package/dist/base-command.js +34 -43
  6. package/dist/commands/agenda/plan.d.ts +2 -1
  7. package/dist/commands/agenda/plan.js +18 -4
  8. package/dist/commands/agent/message/context.d.ts +2 -0
  9. package/dist/commands/agent/message/context.js +18 -3
  10. package/dist/commands/agent/message/list.d.ts +22 -0
  11. package/dist/commands/agent/message/list.js +66 -0
  12. package/dist/commands/agent/message/send.d.ts +1 -1
  13. package/dist/commands/agent/message/send.js +1 -3
  14. package/dist/commands/agent/message/show.d.ts +14 -0
  15. package/dist/commands/agent/message/show.js +39 -0
  16. package/dist/commands/agents/chat.d.ts +4 -0
  17. package/dist/commands/agents/chat.js +79 -17
  18. package/dist/commands/agents/eval/list.d.ts +4 -0
  19. package/dist/commands/agents/eval/list.js +33 -0
  20. package/dist/commands/agents/eval/show.d.ts +1 -0
  21. package/dist/commands/agents/eval/show.js +19 -0
  22. package/dist/commands/agents/intuitions/generate.js +1 -1
  23. package/dist/commands/agents/intuitions/list.js +1 -1
  24. package/dist/commands/agents/permissions/policy.js +25 -2
  25. package/dist/commands/agents/spawn.js +61 -24
  26. package/dist/commands/agents/triggers/fire.js +1 -1
  27. package/dist/commands/agents/triggers/runs.js +3 -0
  28. package/dist/commands/code/acp.js +1 -1
  29. package/dist/commands/code/handover.d.ts +3 -3
  30. package/dist/commands/code/handover.js +12 -12
  31. package/dist/commands/code/index.d.ts +3 -8
  32. package/dist/commands/code/index.js +15 -21
  33. package/dist/commands/code/jobs/approve.d.ts +1 -11
  34. package/dist/commands/code/jobs/approve.js +3 -15
  35. package/dist/commands/code/jobs/cancel.js +3 -2
  36. package/dist/commands/code/jobs/index.js +1 -1
  37. package/dist/commands/code/jobs/list.js +4 -11
  38. package/dist/commands/code/jobs/run.js +13 -7
  39. package/dist/commands/code/jobs/show.js +52 -6
  40. package/dist/commands/code/run.js +1 -1
  41. package/dist/commands/commands.d.ts +1 -0
  42. package/dist/commands/commands.js +5 -1
  43. package/dist/commands/context.d.ts +1 -0
  44. package/dist/commands/context.js +1 -0
  45. package/dist/commands/duties/catalog/add.d.ts +18 -0
  46. package/dist/commands/duties/catalog/add.js +52 -0
  47. package/dist/commands/duties/catalog/index.d.ts +18 -0
  48. package/dist/commands/duties/catalog/index.js +88 -0
  49. package/dist/commands/duties/receipt.js +56 -1
  50. package/dist/commands/goals/plan-now.d.ts +5 -3
  51. package/dist/commands/goals/plan-now.js +21 -16
  52. package/dist/commands/goals/planner-compare.js +5 -3
  53. package/dist/commands/instructions/discovery.d.ts +10 -0
  54. package/dist/commands/instructions/discovery.js +74 -0
  55. package/dist/commands/runs/admission.d.ts +12 -0
  56. package/dist/commands/runs/admission.js +66 -0
  57. package/dist/commands/runs/events.d.ts +16 -0
  58. package/dist/commands/runs/events.js +89 -0
  59. package/dist/commands/runs/list.d.ts +27 -0
  60. package/dist/commands/runs/list.js +151 -0
  61. package/dist/commands/runs/show.d.ts +14 -0
  62. package/dist/commands/runs/show.js +273 -0
  63. package/dist/commands/runs/stop.d.ts +15 -0
  64. package/dist/commands/runs/stop.js +105 -0
  65. package/dist/commands/runs/transcript.d.ts +19 -0
  66. package/dist/commands/runs/transcript.js +178 -0
  67. package/dist/commands/tasks/attachments/download.d.ts +1 -0
  68. package/dist/commands/tasks/attachments/download.js +6 -4
  69. package/dist/commands/tasks/attachments/source.d.ts +6 -0
  70. package/dist/commands/tasks/attachments/source.js +18 -0
  71. package/dist/commands/tasks/chat/exchange.d.ts +0 -14
  72. package/dist/commands/tasks/chat/exchange.js +8 -39
  73. package/dist/commands/tasks/chat/reply-run.d.ts +15 -0
  74. package/dist/commands/tasks/chat/reply-run.js +69 -0
  75. package/dist/commands/tasks/complete.js +1 -1
  76. package/dist/commands/tasks/lifecycle/transition.d.ts +1 -0
  77. package/dist/commands/tasks/lifecycle/transition.js +51 -13
  78. package/dist/commands/tasks/operations/show.js +5 -0
  79. package/dist/commands/tasks/result/submit.js +4 -2
  80. package/dist/commands/tasks/retry.js +25 -16
  81. package/dist/commands/tasks/runs.js +7 -0
  82. package/dist/commands/tasks/start-receipt.js +8 -8
  83. package/dist/commands/tasks/start.js +12 -1
  84. package/dist/commands/triggers/audit.js +3 -1
  85. package/dist/commands/triggers/fire-detail.js +4 -1
  86. package/dist/commands/triggers/fire.js +1 -1
  87. package/dist/commands/usage.d.ts +1 -0
  88. package/dist/commands/usage.js +1 -0
  89. package/dist/generated/agent-guides.json +350 -777
  90. package/dist/help.d.ts +2 -7
  91. package/dist/help.js +13 -7
  92. package/dist/hooks/init.js +10 -0
  93. package/dist/lib/agent-chat-queue.d.ts +2 -1
  94. package/dist/lib/agent-chat-queue.js +26 -21
  95. package/dist/lib/agent-evals.d.ts +1 -1
  96. package/dist/lib/agent-evals.js +13 -3
  97. package/dist/lib/agent-guides.d.ts +3 -5
  98. package/dist/lib/agent-guides.js +12 -13
  99. package/dist/lib/agent-runs.d.ts +101 -0
  100. package/dist/lib/agent-runs.js +350 -0
  101. package/dist/lib/agentic-stream.d.ts +13 -1
  102. package/dist/lib/agentic-stream.js +165 -81
  103. package/dist/lib/api-fetch.d.ts +4 -2
  104. package/dist/lib/api-fetch.js +11 -5
  105. package/dist/lib/code-handover.d.ts +2 -3
  106. package/dist/lib/code-handover.js +4 -6
  107. package/dist/lib/command-manifest.d.ts +1 -6
  108. package/dist/lib/command-manifest.js +86 -13
  109. package/dist/lib/communication-history.d.ts +27 -0
  110. package/dist/lib/communication-history.js +45 -0
  111. package/dist/lib/config.d.ts +2 -3
  112. package/dist/lib/config.js +2 -3
  113. package/dist/lib/duties.d.ts +5 -1
  114. package/dist/lib/duties.js +4 -0
  115. package/dist/lib/execution-history.d.ts +34 -0
  116. package/dist/lib/execution-history.js +7 -0
  117. package/dist/lib/first-party-harness-broker.d.ts +1 -1
  118. package/dist/lib/first-party-harness-broker.js +3 -5
  119. package/dist/lib/format.d.ts +1 -0
  120. package/dist/lib/format.js +18 -0
  121. package/dist/lib/guide-pointer.d.ts +5 -1
  122. package/dist/lib/guide-pointer.js +21 -2
  123. package/dist/lib/hosted-job-status.d.ts +4 -0
  124. package/dist/lib/hosted-job-status.js +19 -0
  125. package/dist/lib/inbound-messages.d.ts +2 -0
  126. package/dist/lib/inbound-messages.js +5 -0
  127. package/dist/lib/intuition-look.js +20 -4
  128. package/dist/lib/memory-history-session.d.ts +8 -4
  129. package/dist/lib/memory-history-session.js +30 -23
  130. package/dist/lib/roles.d.ts +2 -2
  131. package/dist/lib/schedule.d.ts +4 -0
  132. package/dist/lib/schedule.js +4 -3
  133. package/dist/lib/task-agent-run.d.ts +4 -0
  134. package/dist/lib/task-agent-run.js +15 -0
  135. package/dist/lib/task-execution.d.ts +1 -1
  136. package/dist/lib/task-execution.js +3 -19
  137. package/dist/lib/task-extras.d.ts +11 -1
  138. package/dist/lib/task-extras.js +15 -1
  139. package/dist/lib/task-transcript.js +3 -8
  140. package/dist/lib/triggers.d.ts +5 -36
  141. package/dist/lib/triggers.js +48 -33
  142. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.d.ts +9 -0
  143. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +40 -3
  144. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.d.ts +37 -0
  145. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.js +59 -0
  146. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.d.ts +62 -0
  147. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +56 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.d.ts +9 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +34 -3
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.d.ts +37 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.js +57 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.d.ts +62 -0
  153. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +51 -0
  154. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  155. package/dist/node_modules/@skrr-ai/data-provider/index.js +12259 -12160
  156. package/docs/v1/quickstart.md +18 -0
  157. package/oclif.manifest.json +3405 -2112
  158. package/package.json +6 -2
  159. package/skills/skrr/SKILL.md +14 -0
  160. package/dist/commands/triggers/runs.d.ts +0 -22
  161. package/dist/commands/triggers/runs.js +0 -58
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.historyTimeFlags = void 0;
4
+ exports.resolveHistorySession = resolveHistorySession;
5
+ exports.readBoundAgentHistory = readBoundAgentHistory;
6
+ exports.readCommunicationHistory = readCommunicationHistory;
7
+ exports.formatCommunicationHistoryItem = formatCommunicationHistoryItem;
8
+ const node_util_1 = require("node:util");
9
+ const core_1 = require("@oclif/core");
10
+ const api_fetch_1 = require("./api-fetch");
11
+ const memory_history_session_1 = require("./memory-history-session");
12
+ function resolveHistorySession(requireHumanAuth) {
13
+ if ((0, memory_history_session_1.hasBoundHistoryRuntime)())
14
+ return (0, memory_history_session_1.boundHistorySession)(process.env, 'agent-history-v1');
15
+ requireHumanAuth();
16
+ return null;
17
+ }
18
+ function readBoundAgentHistory(sessionId, path, query) {
19
+ return (0, api_fetch_1.apiFetch)(`/api/agentic/sessions/${encodeURIComponent(sessionId)}/${path}${queryString(query)}`, { sessionRead: 'agent-history-v1' });
20
+ }
21
+ function queryString(query) {
22
+ const params = new URLSearchParams();
23
+ for (const [key, value] of Object.entries(query)) {
24
+ if (value !== undefined)
25
+ params.set(key, String(value));
26
+ }
27
+ return params.size ? `?${params}` : '';
28
+ }
29
+ exports.historyTimeFlags = {
30
+ from: core_1.Flags.string({ description: 'Inclusive ISO 8601 timestamp with an offset', exclusive: ['since'] }),
31
+ to: core_1.Flags.string({ description: 'Exclusive ISO 8601 timestamp with an offset', exclusive: ['since'] }),
32
+ since: core_1.Flags.string({ description: 'Today in the owner’s timezone, or an elapsed duration such as 7d', exclusive: ['from', 'to'] }),
33
+ timezone: core_1.Flags.string({ description: 'IANA timezone for --since today', dependsOn: ['since'] }),
34
+ };
35
+ function readCommunicationHistory(operation, agentId, session, query) {
36
+ if (session)
37
+ return readBoundAgentHistory(session.sessionId, `communication-history/${operation}`, query);
38
+ return (0, api_fetch_1.apiFetch)(`/api/agent-communications/history/${encodeURIComponent(agentId)}/${operation}${queryString(query)}`);
39
+ }
40
+ function formatCommunicationHistoryItem(item) {
41
+ const sender = item.side === 'user' ? item.ownerAuthored ? 'owner' : 'inbound' : item.kind ?? item.source;
42
+ const excerpt = item.retracted ? 'Withdrawn' : (0, node_util_1.stripVTControlCharacters)(item.excerpt ?? '')
43
+ .replace(/[\x00-\x1f\x7f-\x9f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, ' ');
44
+ return [item.messageId, item.at, sender, excerpt].filter(Boolean).join(' · ');
45
+ }
@@ -246,9 +246,8 @@ export declare function clearSelectedWorkspaceCache(): void;
246
246
  /**
247
247
  * Publish the durable selection as `OVERSKY_WORKSPACE_ID`, once, at startup.
248
248
  *
249
- * Called from `bin/run.js` before oclif dispatches, so every later reader sees
250
- * one variable and none of them needs to know a config file exists — the header
251
- * builder, the offline outbox, and `runtime-context` all already read it.
249
+ * The oclif init hook calls this after selecting the Profile so the header
250
+ * builder, offline outbox and runtime context all see its saved workspace.
252
251
  *
253
252
  * Only when NOTHING already set it. An explicit `OVERSKY_WORKSPACE_ID=… sky …`
254
253
  * outranks a stored preference, and a daemon-spawned child inherits its
@@ -697,9 +697,8 @@ function clearSelectedWorkspaceCache() {
697
697
  /**
698
698
  * Publish the durable selection as `OVERSKY_WORKSPACE_ID`, once, at startup.
699
699
  *
700
- * Called from `bin/run.js` before oclif dispatches, so every later reader sees
701
- * one variable and none of them needs to know a config file exists — the header
702
- * builder, the offline outbox, and `runtime-context` all already read it.
700
+ * The oclif init hook calls this after selecting the Profile so the header
701
+ * builder, offline outbox and runtime context all see its saved workspace.
703
702
  *
704
703
  * Only when NOTHING already set it. An explicit `OVERSKY_WORKSPACE_ID=… sky …`
705
704
  * outranks a stored preference, and a daemon-spawned child inherits its
@@ -1,4 +1,4 @@
1
- import { type DutyAuthoringSnapshot, type DutyAuthoringWarning, type DutyObservationsQuery, type DutyObservationsResponse } from '@skrr-ai/data-provider';
1
+ import { type DutyAuthoringSnapshot, type DutyAuthoringWarning, type DutyObservationsQuery, type DutyObservationsResponse, type AddAgentDutyCatalogEntryResponse, type AgentDutyCatalogResponse } from '@skrr-ai/data-provider';
2
2
  /**
3
3
  * duties.ts — request-based client for the Duties subsystem
4
4
  * (`/api/duties/*`).
@@ -350,6 +350,10 @@ export declare const dutyApi: {
350
350
  * swept, how stale that is, and the tally it last persisted. Aggregate only.
351
351
  */
352
352
  livenessSweep: () => Promise<Record<string, unknown>>;
353
+ /** One Agent's Duty catalog: each preconfigured Duty and whether it is on (OSK-33996). */
354
+ catalog: (agentId: string) => Promise<AgentDutyCatalogResponse>;
355
+ /** Add a catalog system role the Agent does not have. Idempotent. */
356
+ addCatalogEntry: (agentId: string, entryId: string) => Promise<AddAgentDutyCatalogEntryResponse>;
353
357
  /** One agent's Duties, system roles included, each with its loop status. */
354
358
  roster: (agentId: string) => Promise<DutyRoster>;
355
359
  /** Is this Duty's loop installed and working. */
@@ -230,6 +230,10 @@ exports.dutyApi = {
230
230
  * swept, how stale that is, and the tally it last persisted. Aggregate only.
231
231
  */
232
232
  livenessSweep: () => data_provider_2.request.get('/api/duties/liveness/sweep'),
233
+ /** One Agent's Duty catalog: each preconfigured Duty and whether it is on (OSK-33996). */
234
+ catalog: (agentId) => data_provider_2.request.get(`/api/duties/agents/${encodeURIComponent(agentId)}/catalog`),
235
+ /** Add a catalog system role the Agent does not have. Idempotent. */
236
+ addCatalogEntry: (agentId, entryId) => data_provider_2.request.post(`/api/duties/agents/${encodeURIComponent(agentId)}/catalog/${encodeURIComponent(entryId)}`, {}),
233
237
  /** One agent's Duties, system roles included, each with its loop status. */
234
238
  roster: (agentId) => data_provider_2.request.get((0, triggers_1.withQuery)('/api/duties/roster', {
235
239
  agentId,
@@ -0,0 +1,34 @@
1
+ import type { AgentRunAttemptLifecycle, AgentRunRuntimeWait } from '@skrr-ai/data-provider';
2
+ export type ExecutionRun = {
3
+ id: string;
4
+ source: string;
5
+ status: string;
6
+ acceptedAt: string;
7
+ transcriptAvailability: string;
8
+ title?: string;
9
+ };
10
+ export type ExecutionRunDetail = ExecutionRun & {
11
+ coverage: 'complete' | 'partial';
12
+ runtimeWait?: Pick<AgentRunRuntimeWait, 'reason' | 'deadlineAt'>;
13
+ attempts: Array<{
14
+ id: string;
15
+ number: number;
16
+ executor: string;
17
+ grantedAt?: string;
18
+ lifecycle?: AgentRunAttemptLifecycle;
19
+ }>;
20
+ };
21
+ export type ExecutionPage<T> = {
22
+ items: T[];
23
+ nextCursor: string | null;
24
+ coverage: 'complete' | 'partial';
25
+ };
26
+ export type ExecutionExcerpt = {
27
+ sequence: number;
28
+ at?: string;
29
+ kind: string;
30
+ name?: string;
31
+ text?: string;
32
+ outcome?: string;
33
+ };
34
+ export declare function readExecutionHistory<T>(sessionId: string, operation: 'list' | 'show' | 'transcript', query: Record<string, string | number | undefined>): Promise<T>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readExecutionHistory = readExecutionHistory;
4
+ const communication_history_1 = require("./communication-history");
5
+ function readExecutionHistory(sessionId, operation, query) {
6
+ return (0, communication_history_1.readBoundAgentHistory)(sessionId, `execution-history/${operation}`, query);
7
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OSK-3892 — the ACQUISITION half: turn a logged-in CLI into a managed session.
2
+ * OSK-3892 — give a user-started CLI an inference lease for its local engine process.
3
3
  *
4
4
  * Four steps, in this order, none of which may be reordered:
5
5
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * OSK-3892 — the ACQUISITION half: turn a logged-in CLI into a managed session.
3
+ * OSK-3892 — give a user-started CLI an inference lease for its local engine process.
4
4
  *
5
5
  * Four steps, in this order, none of which may be reordered:
6
6
  *
@@ -268,9 +268,7 @@ async function acquireManagedSession(input = {}, deps = {}) {
268
268
  throw new ManagedAcquisitionError('not-signed-in', 'no skrr session on this machine — run `skrr login`');
269
269
  }
270
270
  const sessionId = newId();
271
- // The interactive `attemptId` surrogate is derived from this server-side. Two
272
- // concurrent turns in one session therefore need two process starts to be
273
- // distinguishable, which is exactly what one CLI process is.
271
+ // The relay keys the lease to this process. These IDs have accounting scope.
274
272
  const processStartId = newId();
275
273
  // ONE deadline for the whole handshake, armed here and disarmed once the last
276
274
  // round trip has answered. Everything the acquisition does over the network is
@@ -1083,7 +1081,7 @@ function managedLeaseClockLine(clocks, now = Date.now()) {
1083
1081
  else {
1084
1082
  parts.push('this server reports no ceiling');
1085
1083
  }
1086
- return `Managed session: ${parts.join(' \u00b7 ')}.`;
1084
+ return `Managed inference lease (${parts.join(' \u00b7 ')}).`;
1087
1085
  }
1088
1086
  function localClock(atMs) {
1089
1087
  const at = new Date(atMs);
@@ -110,6 +110,7 @@ export declare function localStamp(value: unknown): string;
110
110
  * activity, monitor) order events seconds apart. Never throws.
111
111
  */
112
112
  export declare function localTime(value: unknown): string;
113
+ export declare function formatDurationMs(value: unknown): string;
113
114
  /**
114
115
  * `PDT` — the zone `localStamp` renders in, to be named once per command
115
116
  * rather than repeated on every row.
@@ -10,6 +10,7 @@ exports.collapseWhitespace = collapseWhitespace;
10
10
  exports.renderTable = renderTable;
11
11
  exports.localStamp = localStamp;
12
12
  exports.localTime = localTime;
13
+ exports.formatDurationMs = formatDurationMs;
13
14
  exports.localZone = localZone;
14
15
  exports.zoneAbbreviation = zoneAbbreviation;
15
16
  exports.zonedTime = zonedTime;
@@ -313,6 +314,23 @@ function localTime(value) {
313
314
  const seconds = `${date.getSeconds()}`.padStart(2, '0');
314
315
  return `${localStamp(date)}:${seconds}${zone ? ` ${zone}` : ''}`;
315
316
  }
317
+ function formatDurationMs(value) {
318
+ const ms = Number(value);
319
+ if (!Number.isFinite(ms) || ms < 0)
320
+ return '-';
321
+ if (ms < 1000)
322
+ return `${Math.floor(ms)}ms`;
323
+ const seconds = Math.floor(ms / 1000);
324
+ if (seconds < 60)
325
+ return `${seconds}s`;
326
+ const minutes = Math.floor(seconds / 60);
327
+ if (minutes < 60)
328
+ return `${minutes}m${seconds % 60 ? `${seconds % 60}s` : ''}`;
329
+ const hours = Math.floor(minutes / 60);
330
+ if (hours < 48)
331
+ return `${hours}h${minutes % 60 ? `${minutes % 60}m` : ''}`;
332
+ return `${Math.floor(hours / 24)}d`;
333
+ }
316
334
  /**
317
335
  * `PDT` — the zone `localStamp` renders in, to be named once per command
318
336
  * rather than repeated on every row.
@@ -5,11 +5,15 @@ export interface AgentGuidePointer {
5
5
  /** `skrr guide <id> <section>` — what the `Guide:` line and `error.guide.command` carry. */
6
6
  command: string;
7
7
  }
8
+ /** Published in command help and JSON schema so agents can read before writing. */
9
+ export declare function agentGuidePointerForCommand(commandId: string): (AgentGuidePointer & {
10
+ readWhen: string;
11
+ }) | null;
8
12
  /**
9
13
  * The pointer for a refusal code: `{id, section, command}`, or `null` when no
10
14
  * section explains it, the error carries no code, or the bundled vocabulary is
11
15
  * unavailable. Never throws.
12
16
  */
13
17
  export declare function agentGuidePointerFor(code: string | null | undefined): AgentGuidePointer | null;
14
- /** The `Guide:` line a refusal's human text ends with. */
18
+ /** The `Guide:` line used by help and refusals. */
15
19
  export declare function agentGuidePointerLine(pointer: AgentGuidePointer): string;
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.agentGuidePointerForCommand = agentGuidePointerForCommand;
6
7
  exports.agentGuidePointerFor = agentGuidePointerFor;
7
8
  exports.agentGuidePointerLine = agentGuidePointerLine;
8
9
  /**
9
- * Agent guides — the pointer a refusal carries (OSK-17977).
10
+ * Agent guide pointers for command discovery and refusals.
10
11
  *
11
12
  * The cheapest moment to teach is the moment something goes wrong. A section's
12
13
  * manifest entry declares the refusal codes it `explains`; the server registry
@@ -23,6 +24,24 @@ exports.agentGuidePointerLine = agentGuidePointerLine;
23
24
  const data_provider_1 = require("@skrr-ai/data-provider");
24
25
  const agent_guides_json_1 = __importDefault(require("../generated/agent-guides.json"));
25
26
  const catalog = agent_guides_json_1.default.index?.guides ?? [];
27
+ const commandGuideSections = new Map([
28
+ ['tasks:complete', 'closure'],
29
+ ['tasks:result:submit', 'result-review'],
30
+ ['tasks:review', 'result-review'],
31
+ ['tasks:updates:add', 'updates'],
32
+ ]);
33
+ /** Published in command help and JSON schema so agents can read before writing. */
34
+ function agentGuidePointerForCommand(commandId) {
35
+ const sectionId = commandGuideSections.get(commandId);
36
+ if (!sectionId)
37
+ return null;
38
+ const guide = catalog.find(({ id }) => id === 'tasks');
39
+ const section = guide?.sections.find(({ id }) => id === sectionId);
40
+ if (!guide || !section)
41
+ return null;
42
+ const address = { id: guide.id, section: section.id };
43
+ return { ...address, command: (0, data_provider_1.agentGuideReadCommand)(address, 'cli'), readWhen: section.readWhen };
44
+ }
26
45
  /**
27
46
  * The pointer for a refusal code: `{id, section, command}`, or `null` when no
28
47
  * section explains it, the error carries no code, or the bundled vocabulary is
@@ -45,7 +64,7 @@ function agentGuidePointerFor(code) {
45
64
  return null;
46
65
  }
47
66
  }
48
- /** The `Guide:` line a refusal's human text ends with. */
67
+ /** The `Guide:` line used by help and refusals. */
49
68
  function agentGuidePointerLine(pointer) {
50
69
  return `Guide: ${pointer.command}`;
51
70
  }
@@ -0,0 +1,4 @@
1
+ import type { TCloudCodingTask } from '@skrr-ai/data-provider';
2
+ /** Whether the job is progressing without a new human approval. */
3
+ export declare function isHostedJobInProgress(status: string): boolean;
4
+ export declare function hostedJobDisplayStatus(task?: TCloudCodingTask): string | undefined;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHostedJobInProgress = isHostedJobInProgress;
4
+ exports.hostedJobDisplayStatus = hostedJobDisplayStatus;
5
+ const IN_PROGRESS = new Set([
6
+ 'queued', 'provisioning', 'cloning', 'running', 'checkpointing', 'pushing', 'pr_opening', 'pr_open',
7
+ ]);
8
+ /** Whether the job is progressing without a new human approval. */
9
+ function isHostedJobInProgress(status) {
10
+ return IN_PROGRESS.has(status);
11
+ }
12
+ function hostedJobDisplayStatus(task) {
13
+ if (task?.status !== 'cancelled' || !task.runId)
14
+ return task?.status;
15
+ const receipt = task.stopReceipt;
16
+ if (receipt?.runId === task.runId)
17
+ return receipt.status;
18
+ return task.cancelRequestedAt && task.jobOnlyCancellation !== true ? 'stop_requested' : task.status;
19
+ }
@@ -97,6 +97,8 @@ export type InboundNext = {
97
97
  kind: 'turn';
98
98
  sessionId: string;
99
99
  responseMessageId: string;
100
+ runId?: string;
101
+ runHistoryWorkspaceId?: string | null;
100
102
  } | {
101
103
  kind: 'wait';
102
104
  } | {
@@ -30,6 +30,7 @@ exports.readMessageDelivery = readMessageDelivery;
30
30
  */
31
31
  const node_crypto_1 = require("node:crypto");
32
32
  const data_provider_1 = require("@skrr-ai/data-provider");
33
+ const agent_runs_1 = require("./agent-runs");
33
34
  const agent_chat_start_1 = require("./agent-chat-start");
34
35
  const cloud_reply_1 = require("./cloud-reply");
35
36
  const http_error_1 = require("./http-error");
@@ -315,10 +316,14 @@ function nextAfterSend(answer) {
315
316
  case 'new_turn':
316
317
  case 'merged':
317
318
  if (turn?.sessionId && turn.responseMessageId) {
319
+ const runId = (0, agent_runs_1.canonicalRunId)(turn.runId);
318
320
  return {
319
321
  kind: 'turn',
320
322
  sessionId: turn.sessionId,
321
323
  responseMessageId: turn.responseMessageId,
324
+ ...(runId ? { runId } : {}),
325
+ ...(runId && turn.runHistoryWorkspaceId !== undefined
326
+ ? { runHistoryWorkspaceId: turn.runHistoryWorkspaceId } : {}),
322
327
  };
323
328
  }
324
329
  // A merge whose reply row is not known yet is answered by that turn; a new turn that did
@@ -7,6 +7,7 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.SET_ASIDE_SENTENCES = exports.LOOK_SKIP_SENTENCES = void 0;
9
9
  exports.describeLookAround = describeLookAround;
10
+ const agent_runs_1 = require("./agent-runs");
10
11
  exports.LOOK_SKIP_SENTENCES = {
11
12
  owner_inactive: 'you have not chatted with it lately; it looks again once you do',
12
13
  billing_refused: 'your balance did not cover a look',
@@ -30,14 +31,25 @@ exports.SET_ASIDE_SENTENCES = {
30
31
  function describeLookAround(lookAround, agentId) {
31
32
  if (!lookAround)
32
33
  return [];
34
+ const active = lookAround.state === 'looking';
35
+ const runId = (0, agent_runs_1.canonicalRunId)(active ? lookAround.activeRunId : lookAround.lastLook?.agentRunId);
36
+ if (active) {
37
+ if (!runId)
38
+ return ['Look requested. Check again for its Run or outcome.'];
39
+ return [
40
+ 'Look in progress.',
41
+ `View Run: skrr runs show ${runId}`,
42
+ `Request Stop: skrr runs stop ${runId}`,
43
+ ];
44
+ }
45
+ const history = runId ? [`View Run: skrr runs show ${runId}`] : [];
33
46
  if (lookAround.state === 'paused') {
34
47
  return [
35
48
  `Looking around is paused: the last ${lookAround.consecutiveFailures} looks did not finish.`,
36
49
  `Resume it with: skrr agents intuitions resume ${agentId}`,
50
+ ...history,
37
51
  ];
38
52
  }
39
- if (lookAround.state === 'looking')
40
- return ['Looking around now.'];
41
53
  const lines = [];
42
54
  const last = lookAround.lastLook;
43
55
  if (last) {
@@ -46,8 +58,12 @@ function describeLookAround(lookAround, agentId) {
46
58
  else if (last.outcome === 'nothing_to_suggest') {
47
59
  lines.push(`Last look (${last.at}) found nothing worth suggesting.`);
48
60
  }
49
- else if (last.outcome === 'failed')
61
+ else if (last.outcome === 'failed') {
50
62
  lines.push(`Last look (${last.at}) did not finish.`);
63
+ }
64
+ else if (last.outcome === 'interrupted') {
65
+ lines.push(`Stop was requested for the look (${last.at}).`);
66
+ }
51
67
  else if (last.skipReason) {
52
68
  lines.push(`Last look (${last.at}) skipped: ${exports.LOOK_SKIP_SENTENCES[last.skipReason] ?? last.skipReason}.`);
53
69
  }
@@ -60,5 +76,5 @@ function describeLookAround(lookAround, agentId) {
60
76
  lines.push('Next look waits for quiet hours to end.');
61
77
  else if (lookAround.nextLookAt)
62
78
  lines.push(`Next look: ${lookAround.nextLookAt}.`);
63
- return lines;
79
+ return [...lines, ...history];
64
80
  }
@@ -1,14 +1,18 @@
1
1
  type RuntimeEnv = Record<string, string | undefined>;
2
- export declare function hasMemoryHistoryRuntime(env?: RuntimeEnv): boolean;
3
- /** Only this explicit read contract may select a primary session credential. */
4
- export declare function bindMemoryHistoryRead(pathOrUrl: string, method: string, env?: RuntimeEnv): {
2
+ type HistoryReader = 'memory-history-v1' | 'agent-history-v1';
3
+ export declare function hasBoundHistoryRuntime(env?: RuntimeEnv): boolean;
4
+ export declare const hasMemoryHistoryRuntime: typeof hasBoundHistoryRuntime;
5
+ /** Each reader binds its exact GET route to the primary session credential. */
6
+ export declare function bindHistoryRead(pathOrUrl: string, method: string, env?: RuntimeEnv, reader?: HistoryReader): {
5
7
  url: string;
6
8
  origin: string;
7
9
  token: string;
8
10
  };
9
- export declare function memoryHistorySession(env?: RuntimeEnv): {
11
+ export declare const bindMemoryHistoryRead: typeof bindHistoryRead;
12
+ export declare function boundHistorySession(env?: RuntimeEnv, reader?: HistoryReader): {
10
13
  sessionId: string;
11
14
  token: string;
12
15
  server: URL;
13
16
  };
17
+ export declare const memoryHistorySession: typeof boundHistorySession;
14
18
  export {};
@@ -1,61 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasMemoryHistoryRuntime = hasMemoryHistoryRuntime;
4
- exports.bindMemoryHistoryRead = bindMemoryHistoryRead;
5
- exports.memoryHistorySession = memoryHistorySession;
3
+ exports.memoryHistorySession = exports.bindMemoryHistoryRead = exports.hasMemoryHistoryRuntime = void 0;
4
+ exports.hasBoundHistoryRuntime = hasBoundHistoryRuntime;
5
+ exports.bindHistoryRead = bindHistoryRead;
6
+ exports.boundHistorySession = boundHistorySession;
6
7
  const BIND_MEMORY_HISTORY_READ_RE = /^\/api\/agentic\/sessions\/([^/]+)\/memory\/agents\/([^/]+)\/versions(?:\/([^/]+))?$/;
7
- function hasMemoryHistoryRuntime(env = process.env) {
8
- // Interactive SDK children can carry the daemon's session tuple without an
9
- // AutonomousRun or the wrapper's autonomous marker. Partial tuples must not
10
- // silently turn a managed history read into an owner-account read.
8
+ const BIND_AGENT_HISTORY_READ_RE = /^\/api\/agentic\/sessions\/([^/]+)\/(?:communication-history\/(?:list|show|outreach)|execution-history\/(?:list|show|transcript))$/;
9
+ function hasBoundHistoryRuntime(env = process.env) {
10
+ // A partial tuple must not change an Agent read into an owner-account read.
11
11
  return env.OVERSKY_AUTONOMOUS_SESSION === '1' ||
12
12
  Boolean(env.OVERSKY_SESSION_ID?.trim() || env.OVERSKY_SESSION_TOKEN?.trim());
13
13
  }
14
+ exports.hasMemoryHistoryRuntime = hasBoundHistoryRuntime;
14
15
  function refusal(message, code, status) {
15
16
  return Object.assign(new Error(message), { code, status });
16
17
  }
17
- /** Only this explicit read contract may select a primary session credential. */
18
- function bindMemoryHistoryRead(pathOrUrl, method, env = process.env) {
19
- const { sessionId, token, server } = memoryHistorySession(env);
18
+ function historyReaderLabel(reader) {
19
+ return reader === 'memory-history-v1' ? 'Memory' : 'Agent';
20
+ }
21
+ /** Each reader binds its exact GET route to the primary session credential. */
22
+ function bindHistoryRead(pathOrUrl, method, env = process.env, reader = 'memory-history-v1') {
23
+ const memory = reader === 'memory-history-v1';
24
+ const label = historyReaderLabel(reader);
25
+ const { sessionId, token, server } = boundHistorySession(env, reader);
20
26
  let target;
21
27
  try {
22
28
  target = new URL(pathOrUrl, server);
23
29
  }
24
30
  catch {
25
- throw refusal('Memory history requires the bound session server. Start a new managed Agent session.', 'MEMORY_RUNTIME_ORIGIN_MISMATCH', 403);
31
+ throw refusal(label + ' history requires the bound session server. Start a new managed Agent session.', label.toUpperCase() + '_RUNTIME_ORIGIN_MISMATCH', 403);
26
32
  }
27
33
  if (target.origin !== server.origin || target.username || target.password) {
28
- throw refusal('Memory history cannot send its session credential to another server.', 'MEMORY_RUNTIME_ORIGIN_MISMATCH', 403);
34
+ throw refusal(label + ' history cannot send its session credential to another server.', label.toUpperCase() + '_RUNTIME_ORIGIN_MISMATCH', 403);
29
35
  }
30
- const route = BIND_MEMORY_HISTORY_READ_RE.exec(target.pathname);
36
+ const route = (memory ? BIND_MEMORY_HISTORY_READ_RE : BIND_AGENT_HISTORY_READ_RE).exec(target.pathname);
31
37
  let selectedSession;
32
38
  let selectedAgent;
33
39
  try {
34
40
  selectedSession = route ? decodeURIComponent(route[1]) : undefined;
35
- selectedAgent = route ? decodeURIComponent(route[2]) : undefined;
41
+ selectedAgent = route?.[2] ? decodeURIComponent(route[2]) : undefined;
36
42
  }
37
43
  catch { /* malformed encoded selectors are refused below */ }
38
44
  if (method.toUpperCase() !== 'GET' || !route || selectedSession !== sessionId ||
39
- (env.OVERSKY_SESSION_AGENT_ID?.trim() && selectedAgent !== env.OVERSKY_SESSION_AGENT_ID.trim())) {
40
- throw refusal('Memory history must target this admitted Agent session. Start a session for the selected Agent.', 'MEMORY_RUNTIME_SCOPE_MISMATCH', 403);
45
+ (memory && env.OVERSKY_SESSION_AGENT_ID?.trim() && selectedAgent !== env.OVERSKY_SESSION_AGENT_ID.trim())) {
46
+ throw refusal(label + ' history must target this admitted Agent session. Start a session for the selected Agent.', label.toUpperCase() + '_RUNTIME_SCOPE_MISMATCH', 403);
41
47
  }
42
48
  return { url: target.toString(), origin: server.origin, token };
43
49
  }
44
- function memoryHistorySession(env = process.env) {
50
+ exports.bindMemoryHistoryRead = bindHistoryRead;
51
+ function boundHistorySession(env = process.env, reader = 'memory-history-v1') {
52
+ const label = historyReaderLabel(reader);
45
53
  const sessionId = env.OVERSKY_SESSION_ID?.trim();
46
54
  const token = env.OVERSKY_SESSION_TOKEN?.trim();
47
55
  if (!sessionId || !token?.startsWith('agst_')) {
48
- throw refusal('Memory history requires the bound Agent session credential. Start a managed Agent session; owner credentials cannot replace it.', 'MEMORY_RUNTIME_CREDENTIAL_MISSING', 401);
56
+ throw refusal(label + ' history requires the bound Agent session credential. Start a managed Agent session; owner credentials cannot replace it.', label.toUpperCase() + '_RUNTIME_CREDENTIAL_MISSING', 401);
49
57
  }
50
58
  let trusted;
51
59
  try {
52
60
  trusted = new URL(env.OVERSKY_SERVER_URL || '');
53
61
  }
54
- catch {
55
- throw refusal('Memory history requires the bound session server. Start a new managed Agent session.', 'MEMORY_RUNTIME_ORIGIN_MISMATCH', 403);
56
- }
57
- if (!['https:', 'http:'].includes(trusted.protocol) || trusted.username || trusted.password) {
58
- throw refusal('Memory history cannot send its session credential to another server.', 'MEMORY_RUNTIME_ORIGIN_MISMATCH', 403);
62
+ catch { /* checked below */ }
63
+ if (!trusted || !['https:', 'http:'].includes(trusted.protocol) || trusted.username || trusted.password) {
64
+ throw refusal(label + ' history requires the bound session server. Start a new managed Agent session.', label.toUpperCase() + '_RUNTIME_ORIGIN_MISMATCH', 403);
59
65
  }
60
66
  return { sessionId, token, server: trusted };
61
67
  }
68
+ exports.memoryHistorySession = boundHistorySession;
@@ -53,7 +53,7 @@ export declare const roleApi: {
53
53
  config?: Record<string, unknown> | undefined;
54
54
  }[];
55
55
  sources: {
56
- source: "space" | "docs" | "tasks" | "memory" | "daemon" | "email" | "goal" | "files" | "local" | "browser" | "metrics" | "monitor" | "github" | "conversations" | "agent_initiatives" | "messages" | "documents" | "slack" | "calendar" | "product_metrics" | "business_metrics" | "state_monitor" | "agent_run" | "chat_execution";
56
+ source: "space" | "docs" | "tasks" | "memory" | "daemon" | "email" | "local" | "goal" | "files" | "browser" | "metrics" | "monitor" | "github" | "conversations" | "agent_initiatives" | "messages" | "documents" | "slack" | "calendar" | "product_metrics" | "business_metrics" | "state_monitor" | "agent_run" | "chat_execution";
57
57
  enabled: boolean;
58
58
  config?: Record<string, unknown> | undefined;
59
59
  }[];
@@ -78,7 +78,7 @@ export declare const roleApi: {
78
78
  }[];
79
79
  contexts: {
80
80
  key: string;
81
- roles: ("home" | "delivery" | "watch" | "advance")[];
81
+ roles: ("delivery" | "home" | "watch" | "advance")[];
82
82
  }[];
83
83
  directive?: string | undefined;
84
84
  subject?: {
@@ -161,6 +161,10 @@ export interface SmartSchedulePlanRequest {
161
161
  code: string;
162
162
  message: string;
163
163
  };
164
+ runReference?: {
165
+ runId: string;
166
+ workspaceId?: string;
167
+ };
164
168
  }
165
169
  /**
166
170
  * The `202` answer to a propose that sent `Prefer: respond-async`: the plan day was
@@ -221,17 +221,18 @@ function describePlanRequest(request, now = new Date()) {
221
221
  if (!request)
222
222
  return null;
223
223
  const kind = request.origin === 'automatic' ? 'automatic planning run' : 'planning request';
224
+ const run = request.runReference ? `\nRun ${request.runReference.runId}` : '';
224
225
  switch (request.state) {
225
226
  case 'running':
226
227
  return (`A plan for ${request.planDate} is being generated (started ${clockTime(request.startedAt)}` +
227
- `${minutesSince(request.startedAt, now)}). Approve, dismiss and regenerate are paused until it finishes.`);
228
+ `${minutesSince(request.startedAt, now)}). Approve, dismiss and regenerate are paused until it finishes.${run}`);
228
229
  case 'unknown':
229
230
  return (`The last ${kind} for ${request.planDate} (started ${clockTime(request.startedAt)}) never reported a result ` +
230
- 'and may have been interrupted. You can plan again; if it was still running, a second draft may appear.');
231
+ `and may have been interrupted. You can plan again; if it was still running, a second draft may appear.${run}`);
231
232
  case 'failed':
232
233
  return (`The last ${kind} for ${request.planDate} failed` +
233
234
  `${request.finishedAt ? ` at ${clockTime(request.finishedAt)}` : ''}: ` +
234
- `${request.failure?.message ?? 'no reason was recorded'}`);
235
+ `${request.failure?.message ?? 'no reason was recorded'}${run}`);
235
236
  default:
236
237
  return null;
237
238
  }
@@ -0,0 +1,4 @@
1
+ export declare function taskAgentRunCommand(reference: {
2
+ agentRunId?: unknown;
3
+ agentRunWorkspaceId?: unknown;
4
+ } | undefined, bin: string): string | undefined;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.taskAgentRunCommand = taskAgentRunCommand;
4
+ const agent_runs_1 = require("./agent-runs");
5
+ function taskAgentRunCommand(reference, bin) {
6
+ const id = (0, agent_runs_1.canonicalRunId)(reference?.agentRunId);
7
+ if (!id)
8
+ return undefined;
9
+ const workspace = reference?.agentRunWorkspaceId;
10
+ if (workspace === undefined)
11
+ return `${bin} runs show ${id}`;
12
+ return typeof workspace === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(workspace)
13
+ ? `${bin} runs show ${id} --workspace ${workspace}`
14
+ : undefined;
15
+ }
@@ -1,4 +1,5 @@
1
1
  import { type TaskRecord } from './tasks';
2
+ export { formatDurationMs } from './format';
2
3
  /**
3
4
  * Statuses at which an execution is OVER — nothing further will move the task
4
5
  * without new input.
@@ -100,6 +101,5 @@ export declare function dependencyKeys(task: TaskRecord): string[];
100
101
  export declare function blockingDependencies(task: TaskRecord, candidates: TaskRecord[]): TaskRecord[];
101
102
  export declare function formatTaskLine(task: TaskRecord): string;
102
103
  export declare function formatAgeSince(value: string): string;
103
- export declare function formatDurationMs(value: unknown): string;
104
104
  export declare function sleep(ms: number): Promise<void>;
105
105
  export declare function compactSnapshotSignature(snapshot: TaskSnapshot): string;