@skrr-ai/cli 0.1.221 → 0.1.223

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.
@@ -925,6 +925,7 @@ class AgentsChat extends base_command_1.BaseCommand {
925
925
  sessionId: next.sessionId,
926
926
  conversationId,
927
927
  responseMessageId: next.responseMessageId,
928
+ replayed: answer.idempotentReplay === true,
928
929
  };
929
930
  case 'delivered': {
930
931
  const handling = answer.delivery?.handling;
@@ -1006,6 +1007,7 @@ class AgentsChat extends base_command_1.BaseCommand {
1006
1007
  conversationId,
1007
1008
  responseMessageId: sent.responseMessageId,
1008
1009
  ...waited.turn,
1010
+ replayed: answer.idempotentReplay === true,
1009
1011
  };
1010
1012
  case 'held':
1011
1013
  return this.failWithCliError({
@@ -1272,6 +1274,7 @@ class AgentsChat extends base_command_1.BaseCommand {
1272
1274
  const startKey = suppliedStartKey ?? (0, agent_chat_start_1.newStartKey)();
1273
1275
  const turnText = contextParts ? `${contextParts}\n\n${prompt}` : prompt;
1274
1276
  let started;
1277
+ let replayedInbound = false;
1275
1278
  // Inbound messages: a message to an existing conversation goes to the ingress, which keeps it
1276
1279
  // and decides how the agent sees it. `--when-busy fail` asks for the older refusal instead.
1277
1280
  let viaIngress = false;
@@ -1306,6 +1309,7 @@ class AgentsChat extends base_command_1.BaseCommand {
1306
1309
  }
1307
1310
  else {
1308
1311
  started = sent;
1312
+ replayedInbound = sent.replayed === true;
1309
1313
  viaIngress = true;
1310
1314
  }
1311
1315
  }
@@ -1494,6 +1498,7 @@ class AgentsChat extends base_command_1.BaseCommand {
1494
1498
  quiet,
1495
1499
  approveTools: flags['approve-tools'],
1496
1500
  reconcileTerminal,
1501
+ resumeRecordedResponseId: replayedInbound ? started.responseMessageId : undefined,
1497
1502
  awaitHandover,
1498
1503
  replayEnvelopes: (from) => (0, api_fetch_1.apiFetch)(`/api/agentic/sessions/${encodeURIComponent(started.sessionId)}/envelopes?from=${from}&limit=500`, { credential: this.resolvedCredential, signal: AbortSignal.timeout(5000) }),
1499
1504
  });
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class DutiesInstallLookAround extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ agent: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
+ scope: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_command_1 = require("../../base-command");
5
+ const duties_1 = require("../../lib/duties");
6
+ const web_url_1 = require("../../lib/web-url");
7
+ class DutiesInstallLookAround extends base_command_1.BaseCommand {
8
+ static description = 'Install the platform’s Look Around exploration Duty as a draft';
9
+ static flags = {
10
+ agent: core_1.Flags.string({ required: true, description: 'Agent ID' }),
11
+ scope: core_1.Flags.string({ required: true, description: 'The already-authorized sources to explore' }),
12
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
13
+ };
14
+ async run() {
15
+ this.requireAuth();
16
+ const { flags } = await this.parse(DutiesInstallLookAround);
17
+ let result;
18
+ try {
19
+ result = await duties_1.dutyApi.installLookAround(flags.agent, flags.scope);
20
+ }
21
+ catch (error) {
22
+ this.handleApiError(error);
23
+ }
24
+ if (flags.json) {
25
+ this.log(JSON.stringify(result, null, 2));
26
+ return;
27
+ }
28
+ const { duty } = result;
29
+ this.log(`${duty.title} · ${duty.status} · ${duty.id}`);
30
+ const url = (0, web_url_1.dutyUrlFrom)(this.cliConfig.baseURL, { id: duty.id });
31
+ if (url)
32
+ this.log(url);
33
+ if (duty.status === 'draft') {
34
+ this.log(`Turn on with skrr duties resume ${duty.id}`);
35
+ }
36
+ }
37
+ }
38
+ exports.default = DutiesInstallLookAround;
@@ -4,7 +4,7 @@ import { BaseCommand } from '../../../base-command';
4
4
  * skill for every agent in the space.
5
5
  *
6
6
  * The procedure becomes a suggested lesson in the space's Memory and is listed
7
- * in its proposals inbox (`spaces proposals list`); a person promotes it there,
7
+ * in its proposals inbox (`spaces proposals list`); a person or the space's Agent promotes it there,
8
8
  * which compiles it into a space skill. From an agent's run the space's write
9
9
  * policy decides it (`skill_write`): it is refused only where the space refuses
10
10
  * skill changes from that agent.
@@ -10,13 +10,13 @@ const prompt_1 = require("../../../lib/prompt");
10
10
  * skill for every agent in the space.
11
11
  *
12
12
  * The procedure becomes a suggested lesson in the space's Memory and is listed
13
- * in its proposals inbox (`spaces proposals list`); a person promotes it there,
13
+ * in its proposals inbox (`spaces proposals list`); a person or the space's Agent promotes it there,
14
14
  * which compiles it into a space skill. From an agent's run the space's write
15
15
  * policy decides it (`skill_write`): it is refused only where the space refuses
16
16
  * skill changes from that agent.
17
17
  */
18
18
  class SpacesSkillsPropose extends base_command_1.BaseCommand {
19
- static description = "Propose a procedure as a space skill: a suggested lesson a person promotes from the space's proposals inbox";
19
+ static description = "Propose a procedure as a space skill: a suggested lesson a person or the space's Agent promotes from the space's proposals inbox";
20
20
  static examples = [
21
21
  '<%= config.bin %> spaces skills propose <space-id> --title "Weekly KR review" --content "How we review…" --procedure procedure.json',
22
22
  'cat procedure.json | <%= config.bin %> spaces skills propose <space-id> --title "Release checklist" --content "…" --procedure -',
@@ -81,7 +81,7 @@ class SpacesSkillsPropose extends base_command_1.BaseCommand {
81
81
  return;
82
82
  }
83
83
  this.log(`Proposed "${flags.title}" as a skill for space ${spaceRef}: ${result.proposal.itemId}. ` +
84
- 'A person promotes it from the space proposals inbox (`spaces proposals list`).');
84
+ "A person or the space's Agent promotes it from the space proposals inbox (`spaces proposals list`).");
85
85
  }
86
86
  }
87
87
  exports.default = SpacesSkillsPropose;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../base-command");
6
+ const http_error_1 = require("../../lib/http-error");
6
7
  const task_resolver_1 = require("../../lib/task-resolver");
7
8
  const task_transcript_1 = require("../../lib/task-transcript");
8
9
  class TasksTranscript extends base_command_1.BaseCommand {
@@ -63,7 +64,18 @@ class TasksTranscript extends base_command_1.BaseCommand {
63
64
  catch (err) {
64
65
  this.handleApiError(err);
65
66
  }
66
- const conversationId = task.conversationId ? String(task.conversationId) : null;
67
+ let conversationId = task.conversationId ? String(task.conversationId) : null;
68
+ if (!conversationId) {
69
+ try {
70
+ const chat = await data_provider_1.dataService.getTaskChat(taskRef);
71
+ conversationId = chat.activeConversationId;
72
+ }
73
+ catch (err) {
74
+ // Older servers may not expose the managed Task chat read.
75
+ if (!(0, http_error_1.isHttpNotFound)(err))
76
+ this.handleApiError(err);
77
+ }
78
+ }
67
79
  if (!conversationId) {
68
80
  // A task with no execution conversation has simply never been run by an
69
81
  // agent — a real state, not a lookup failure. Say which one it is.
@@ -221,6 +221,8 @@ export type AgenticStreamOptions = {
221
221
  * the stream alone.
222
222
  */
223
223
  reconcileTerminal?: () => Promise<ReconciledTerminal | null>;
224
+ /** Ingress returned this response for an idempotent retry. Its session may have expired. */
225
+ resumeRecordedResponseId?: string;
224
226
  /** Owner-authorized canonical envelopes, including events emitted before room admission. */
225
227
  replayEnvelopes?: (from: number) => Promise<EnvelopeReplayPage>;
226
228
  /** Bounded live catch-up cadence while a run is active. Default 2s. */
@@ -945,6 +945,12 @@ class AgenticStreamClient {
945
945
  this.resolve = resolve;
946
946
  this.reject = reject;
947
947
  });
948
+ if (this.options.resumeRecordedResponseId) {
949
+ this.responseMessageId = this.options.resumeRecordedResponseId;
950
+ const hasTerminal = await this.probeTerminal('inbound_replay');
951
+ if (hasTerminal || this.handover || this.closed)
952
+ return result;
953
+ }
948
954
  const wsURL = toWebSocketOrigin(this.options.baseURL);
949
955
  const extraHeaders = this.options.workspaceId
950
956
  ? { 'X-Workspace-Id': this.options.workspaceId }
@@ -1081,7 +1087,7 @@ class AgenticStreamClient {
1081
1087
  // recorded reason is exactly what "the surface shows nothing at all" cost
1082
1088
  // the reader (OSK-7595 — the CLI reported a transport error while the run's
1083
1089
  // own recorded failure said something else entirely).
1084
- this.finish(terminal.status, {
1090
+ const event = {
1085
1091
  type: 'run.reconciled',
1086
1092
  sessionId: this.options.sessionId,
1087
1093
  reconciledFrom: 'durable_record',
@@ -1089,7 +1095,11 @@ class AgenticStreamClient {
1089
1095
  ...(terminal.error ? { message: terminal.error, error: terminal.error } : {}),
1090
1096
  ...(typeof terminal.text === 'string' ? { result: terminal.text } : {}),
1091
1097
  ...(terminal.publicProjection ? { publicProjection: terminal.publicProjection } : {}),
1092
- });
1098
+ };
1099
+ if (reason === 'inbound_replay')
1100
+ this.finishAfterReplay(terminal.status, event);
1101
+ else
1102
+ this.finish(terminal.status, event);
1093
1103
  return true;
1094
1104
  }
1095
1105
  cancel(reason = 'Interrupted by user') {
@@ -2830,8 +2840,10 @@ class AgenticStreamClient {
2830
2840
  endsWithIgnoringWhitespace(this.accumulated, finalText) ||
2831
2841
  this.accumulated.startsWith(finalText) ||
2832
2842
  startsWithIgnoringWhitespace(this.accumulated, finalText));
2833
- if (event.publicProjection === 'lookback_answer_v1' && typeof event.result === 'string') {
2834
- this.accumulated = event.result;
2843
+ const hasRecordedResult = event.reconciledFrom === 'durable_record' && typeof event.result === 'string';
2844
+ if (hasRecordedResult ||
2845
+ (event.publicProjection === 'lookback_answer_v1' && typeof event.result === 'string')) {
2846
+ this.accumulated = finalText;
2835
2847
  }
2836
2848
  else if (finalText && finalText !== this.accumulated && !accumulationIsSuperset) {
2837
2849
  this.accumulated = finalText;
@@ -2841,7 +2853,8 @@ class AgenticStreamClient {
2841
2853
  // other way round).
2842
2854
  // (Compared as the reader sees it: the record holds a widget as its fallback sentence,
2843
2855
  // which is shorter than the block the stream carried, and the raw length would never lose.)
2844
- if (recorded &&
2856
+ if (!hasRecordedResult &&
2857
+ recorded &&
2845
2858
  (recorded.publicProjection === 'lookback_answer_v1' ||
2846
2859
  recorded.text.length > (0, widgetTerminalText_1.widgetsAsText)(this.accumulated, { final: true }).length)) {
2847
2860
  this.accumulated = recorded.text;
@@ -2849,15 +2862,17 @@ class AgenticStreamClient {
2849
2862
  }
2850
2863
  const confirmedReply = status === 'completed' &&
2851
2864
  (event.chatTurnReplyVersion === data_provider_1.CHAT_TURN_REPLY_VERSION || Boolean(this.chatReply));
2852
- if (status === 'completed' && event.chatTurnReplyVersion === data_provider_1.CHAT_TURN_REPLY_VERSION) {
2853
- this.accumulated = finalText;
2854
- }
2855
- else if (status === 'completed' && this.chatReply && !this.publicProjection) {
2856
- const { start, text, originalLength } = this.chatReply;
2857
- const full = originalLength === undefined
2858
- ? text
2859
- : [finalText, this.accumulated].find((candidate) => candidate.length === originalLength && candidate.startsWith(text));
2860
- this.accumulated = start === null ? '' : (full?.slice(start).trim() ?? '');
2865
+ if (status === 'completed' && !hasRecordedResult) {
2866
+ if (event.chatTurnReplyVersion === data_provider_1.CHAT_TURN_REPLY_VERSION) {
2867
+ this.accumulated = finalText;
2868
+ }
2869
+ else if (this.chatReply && !this.publicProjection) {
2870
+ const { start, text, originalLength } = this.chatReply;
2871
+ const full = originalLength === undefined
2872
+ ? text
2873
+ : [finalText, this.accumulated].find((candidate) => candidate.length === originalLength && candidate.startsWith(text));
2874
+ this.accumulated = start === null ? '' : (full?.slice(start).trim() ?? '');
2875
+ }
2861
2876
  }
2862
2877
  // The finished answer, as every other surface shows it: the web applies
2863
2878
  // this same sanitizer, so a scheduling JSON block or leaked function-call
@@ -2868,7 +2883,11 @@ class AgenticStreamClient {
2868
2883
  this.accumulated = (0, data_provider_1.sanitizeFinalText)((0, widgetTerminalText_1.widgetsAsText)(this.accumulated, { final: true }), this.publicProjection);
2869
2884
  if (!this.options.quiet && !this.options.jsonl && this.accumulated) {
2870
2885
  const output = this.options.output ?? process.stdout;
2871
- const { append, shown } = renderableDelta(this.renderedText, this.accumulated);
2886
+ // A confirmed formal reply may already be on screen after its streamed commentary.
2887
+ const shownText = confirmedReply && this.renderedText.trimEnd().endsWith(this.accumulated)
2888
+ ? this.accumulated
2889
+ : this.renderedText;
2890
+ const { append, shown } = renderableDelta(shownText, this.accumulated);
2872
2891
  this.renderedText = shown;
2873
2892
  if (append)
2874
2893
  output.write(append);
@@ -330,6 +330,14 @@ export type ObservationWindowQuery = {
330
330
  limit?: number;
331
331
  };
332
332
  export declare const dutyApi: {
333
+ installLookAround: (agentId: string, scope: string) => Promise<{
334
+ duty: {
335
+ id: string;
336
+ title: string;
337
+ status: string;
338
+ };
339
+ installation: string;
340
+ }>;
333
341
  /**
334
342
  * The lib owns every URL in this domain, and the parity spec depends on that:
335
343
  * a command that builds its own `/api/duties/...` string is invisible to
@@ -217,6 +217,7 @@ exports.dutyPackApi = {
217
217
  activate: (id) => data_provider_2.request.post(`${packBase(id)}/activate`, {}),
218
218
  };
219
219
  exports.dutyApi = {
220
+ installLookAround: (agentId, scope) => data_provider_2.request.post(`/api/duties/agents/${encodeURIComponent(agentId)}/look-around`, { scope }),
220
221
  /**
221
222
  * The lib owns every URL in this domain, and the parity spec depends on that:
222
223
  * a command that builds its own `/api/duties/...` string is invisible to
@@ -124,9 +124,11 @@ function createNodeAdapter(opts = {}) {
124
124
  // autonomous pair above: a hint, never trusted as given. The task API
125
125
  // verifies the claimed agent against the authenticated caller's own access
126
126
  // before stamping it, and rejects a claim that does not check out. The Duty
127
- // routes do the same when no Run pair rides beside it: they credit the Agent
128
- // when the credential is a person's or an Agent's and can edit it, and answer
129
- // 403 otherwise (OSK-33488). With the autonomous pair, the Run decides.
127
+ // routes, when no Run pair rides beside it, follow the credential: the
128
+ // Agent's delegated credential is credited to the Agent it can edit (OSK-33488),
129
+ // a person's own `skrr login` is the person whatever Agent it names (owner
130
+ // decision 2026-11-30, as at the Memory doors), and automation is 403. With
131
+ // the autonomous pair, the Run decides.
130
132
  const sessionAgentId = (process.env.OVERSKY_SESSION_AGENT_ID || process.env.OVERSKY_AGENT_ID)?.trim();
131
133
  if (sessionAgentId) {
132
134
  headers['X-Oversky-Agent-Id'] = sessionAgentId;
@@ -53,7 +53,7 @@ function writePolicyLines(view) {
53
53
  notes.push('a body edit or a new page becomes a suggestion a person accepts; other page changes are refused');
54
54
  // OSK-17998: a new skill is proposed as a lesson; nothing else about skills can be.
55
55
  if (row.mode === 'propose' && row.proposalPath === 'space_lesson')
56
- notes.push('a new skill is proposed as a lesson a person promotes; a removal or pin is refused');
56
+ notes.push("a new skill is proposed as a lesson a person or the space's Agent promotes; a removal or pin is refused");
57
57
  lines.push(` ${(WRITER_LABEL[row.writerClass] || row.writerClass).padEnd(52)} ${MODE_LABEL[row.mode] || row.mode} (${notes.join('; ')})`);
58
58
  }
59
59
  if (view.requireApprovalActionClasses.length) {
@@ -90,7 +90,8 @@ function textFromMessage(message) {
90
90
  return '';
91
91
  }
92
92
  function normalizeMessage(message) {
93
- const isUser = Boolean(message.isCreatedByUser);
93
+ const metadata = message.metadata;
94
+ const isUser = Boolean(message.isCreatedByUser || metadata?.managedWorkCommandId);
94
95
  return {
95
96
  id: String(message.messageId ?? message._id ?? message.id ?? '-'),
96
97
  role: isUser ? 'user' : 'assistant',