@skrr-ai/cli 0.1.220 → 0.1.221

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.
@@ -26,6 +26,7 @@ export declare function queueAgentChatTurn(params: AgenticChatParams & {
26
26
  }): Promise<QueuedTurn>;
27
27
  export type QueuedTurnWait = {
28
28
  outcome: 'sent';
29
+ turn?: Pick<QueuedTurn, 'sessionId' | 'responseMessageId'>;
29
30
  } | {
30
31
  outcome: 'held';
31
32
  card: TConversationInputQueueCard;
@@ -107,11 +107,31 @@ async function waitForQueuedTurn(turn, { timeoutMs, onPaused, onPosition, deps =
107
107
  lastPosition = index;
108
108
  }
109
109
  else {
110
- if (snapshot.turn?.sessionId === turn.sessionId)
110
+ const currentTurn = snapshot.turn;
111
+ if (currentTurn?.sessionId === turn.sessionId)
111
112
  return { outcome: 'sent' };
113
+ if (currentTurn?.userMessageId === turn.clientInputId && currentTurn.responseMessageId) {
114
+ return {
115
+ outcome: 'sent',
116
+ turn: {
117
+ sessionId: currentTurn.sessionId,
118
+ responseMessageId: currentTurn.responseMessageId,
119
+ },
120
+ };
121
+ }
112
122
  const rows = await messages(turn.conversationId);
113
- if (Array.isArray(rows) && rows.some((m) => m.messageId === turn.responseMessageId)) {
114
- return { outcome: 'sent' };
123
+ if (Array.isArray(rows)) {
124
+ if (rows.some((m) => m.messageId === turn.responseMessageId)) {
125
+ return { outcome: 'sent' };
126
+ }
127
+ // A replay may be waiting under IDs reserved by an earlier invocation.
128
+ // The admitted input names its own session and reply once it starts.
129
+ const input = rows.find((m) => m.messageId === turn.clientInputId && m.isCreatedByUser === true);
130
+ const metadata = input?.metadata;
131
+ const { sessionId, responseMessageId } = metadata?.agentic ?? {};
132
+ if (typeof sessionId === 'string' && typeof responseMessageId === 'string') {
133
+ return { outcome: 'sent', turn: { sessionId, responseMessageId } };
134
+ }
115
135
  }
116
136
  goneFor += 1;
117
137
  if (goneFor >= SETTLE_POLLS)
@@ -76,7 +76,7 @@ export type AgenticStreamResult = {
76
76
  * question, supplied by the caller so this module keeps no API dependency.
77
77
  */
78
78
  export type ReconciledTerminal = {
79
- status: 'completed' | 'failed';
79
+ status: AgenticStreamResult['status'];
80
80
  publicProjection?: PublicProjection;
81
81
  /** The answer as persisted, when there is one. */
82
82
  text?: string;
@@ -646,6 +646,8 @@ export declare class AgenticStreamClient {
646
646
  private waitingTimer;
647
647
  private waitingStartedAt;
648
648
  private outputSeen;
649
+ /** Confirmed Codex reply for this turn. Execution text remains available in session.output. */
650
+ private chatReply?;
649
651
  /** The cumulative text of the last `text.delta` written as JSON, for `delta`/`replace`. */
650
652
  private lastJsonlText;
651
653
  private idleTimer;
@@ -904,6 +904,8 @@ class AgenticStreamClient {
904
904
  waitingTimer = null;
905
905
  waitingStartedAt = 0;
906
906
  outputSeen = false;
907
+ /** Confirmed Codex reply for this turn. Execution text remains available in session.output. */
908
+ chatReply;
907
909
  /** The cumulative text of the last `text.delta` written as JSON, for `delta`/`replace`. */
908
910
  lastJsonlText = '';
909
911
  idleTimer = null;
@@ -1079,7 +1081,7 @@ class AgenticStreamClient {
1079
1081
  // recorded reason is exactly what "the surface shows nothing at all" cost
1080
1082
  // the reader (OSK-7595 — the CLI reported a transport error while the run's
1081
1083
  // own recorded failure said something else entirely).
1082
- this.finish(terminal.status === 'failed' ? 'failed' : 'completed', {
1084
+ this.finish(terminal.status, {
1083
1085
  type: 'run.reconciled',
1084
1086
  sessionId: this.options.sessionId,
1085
1087
  reconciledFrom: 'durable_record',
@@ -1594,6 +1596,22 @@ class AgenticStreamClient {
1594
1596
  fresh.some((env) => env?.ev?.t === 'turn-end')) {
1595
1597
  this.requestHandoverRead();
1596
1598
  }
1599
+ for (const envelope of fresh) {
1600
+ const { ev, messageId, subagent } = envelope;
1601
+ if (ev?.t !== 'turn-end' ||
1602
+ ev.status !== 'completed' ||
1603
+ subagent ||
1604
+ (messageId && this.responseMessageId && messageId !== this.responseMessageId))
1605
+ continue;
1606
+ const start = ev.chatReplyStart;
1607
+ if (start === null || (typeof start === 'number' && Number.isSafeInteger(start) && start >= 0)) {
1608
+ this.chatReply = {
1609
+ start,
1610
+ text: ev.responseText ?? '',
1611
+ originalLength: ev.responseTextCut?.originalLength,
1612
+ };
1613
+ }
1614
+ }
1597
1615
  const envelopeText = envelopesText(scoped, this.textJoiner, this.accumulated);
1598
1616
  if (envelopeText) {
1599
1617
  this.accumulated += envelopeText;
@@ -1705,6 +1723,7 @@ class AgenticStreamClient {
1705
1723
  if (!match(event))
1706
1724
  return;
1707
1725
  this.accumulated = '';
1726
+ this.chatReply = undefined;
1708
1727
  this.publicProjection = undefined;
1709
1728
  this.textJoiner.reset();
1710
1729
  this.renderedText = '';
@@ -2828,6 +2847,18 @@ class AgenticStreamClient {
2828
2847
  this.accumulated = recorded.text;
2829
2848
  this.publicProjection = recorded.publicProjection;
2830
2849
  }
2850
+ const confirmedReply = status === 'completed' &&
2851
+ (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() ?? '');
2861
+ }
2831
2862
  // The finished answer, as every other surface shows it: the web applies
2832
2863
  // this same sanitizer, so a scheduling JSON block or leaked function-call
2833
2864
  // XML the model wrote into its reply is removed here too instead of being
@@ -2848,8 +2879,12 @@ class AgenticStreamClient {
2848
2879
  const failureMessage = status === 'failed' && !(typeof event.message === 'string' && event.message.trim())
2849
2880
  ? terminalFailureMessage(event)
2850
2881
  : undefined;
2882
+ const { responseText: _processText, ...terminalFields } = event;
2883
+ const terminalEvent = confirmedReply
2884
+ ? { ...terminalFields, result: this.accumulated }
2885
+ : event;
2851
2886
  this.emit({
2852
- ...event,
2887
+ ...terminalEvent,
2853
2888
  ...(failureMessage ? { message: failureMessage } : {}),
2854
2889
  type: `run.${status}`,
2855
2890
  });
@@ -2861,7 +2896,7 @@ class AgenticStreamClient {
2861
2896
  status,
2862
2897
  ...(status === 'completed' && event.repaired === true ? { repaired: true } : {}),
2863
2898
  ...(this.permissionDenials.length ? { permissionDenials: [...this.permissionDenials] } : {}),
2864
- lastEvent: event,
2899
+ lastEvent: terminalEvent,
2865
2900
  };
2866
2901
  this.resolve(this.terminalResult);
2867
2902
  }
@@ -857,10 +857,14 @@ export declare function ignoredCreateKeysWarning(keys: string[]): string | null;
857
857
  */
858
858
  export declare function normalizeCreateBody(input: Record<string, unknown>): Record<string, unknown>;
859
859
  export declare function parseDutyConcurrencyLimit(input: string | undefined): number | null | undefined;
860
- export declare function dutyConcurrencyEnvelopePatch({ rawValue, reason, autonomous, }: {
860
+ /**
861
+ * The concurrency fields a `--max-concurrent-runs` flag writes. An Agent's session sets a finite
862
+ * cap as its person does (OSK-33488, owner decision 2026-11-29: an Agent's credential has its
863
+ * person's power); the server records which credential decided and refuses an automated one.
864
+ */
865
+ export declare function dutyConcurrencyEnvelopePatch({ rawValue, reason, }: {
861
866
  rawValue?: string;
862
867
  reason?: string;
863
- autonomous?: boolean;
864
868
  }): Record<string, unknown> | undefined;
865
869
  /**
866
870
  * What `policy.evidenceGate.requireMaterialEvidenceForAutonomousRun` does to this Duty's
@@ -1073,9 +1077,11 @@ export declare function dutyWriteWarnings(response: unknown, fallback: {
1073
1077
  /** One `Warning:` line per authoring warning, after the write's own output. */
1074
1078
  export declare function renderDutyWriteWarnings(warnings: DutyAuthoringWarning[], warn: (line: string) => void): void;
1075
1079
  /**
1076
- * What became of a cadence change the server did not simply write (OSK-33445). An Agent's change
1077
- * to a non-draft Duty's cadence is a request for the owner: `awaiting_approval` until they decide,
1078
- * or `applied` when they allowed the Agent to tune within their limits.
1080
+ * What became of a cadence change the server did not simply write (OSK-33445). A server from before
1081
+ * OSK-33488 (owner decision 2026-11-29) answers an Agent's change to a non-draft Duty's cadence as
1082
+ * a request for the owner: `awaiting_approval` until they decide, or `applied` when they allowed the
1083
+ * Agent to tune within their limits. A current server writes the Agent's change as its person's and
1084
+ * sends no receipt; this reader stays so a newer CLI still reads an older server correctly.
1079
1085
  */
1080
1086
  export type DutyCadenceRequestReceipt = {
1081
1087
  status: 'awaiting_approval' | 'applied';
@@ -630,7 +630,12 @@ function parseDutyConcurrencyLimit(input) {
630
630
  }
631
631
  return value;
632
632
  }
633
- function dutyConcurrencyEnvelopePatch({ rawValue, reason, autonomous = process.env.OVERSKY_AUTONOMOUS_SESSION === '1', }) {
633
+ /**
634
+ * The concurrency fields a `--max-concurrent-runs` flag writes. An Agent's session sets a finite
635
+ * cap as its person does (OSK-33488, owner decision 2026-11-29: an Agent's credential has its
636
+ * person's power); the server records which credential decided and refuses an automated one.
637
+ */
638
+ function dutyConcurrencyEnvelopePatch({ rawValue, reason, }) {
634
639
  const value = parseDutyConcurrencyLimit(rawValue);
635
640
  const normalizedReason = reason?.trim();
636
641
  if (value === undefined) {
@@ -639,9 +644,6 @@ function dutyConcurrencyEnvelopePatch({ rawValue, reason, autonomous = process.e
639
644
  }
640
645
  return undefined;
641
646
  }
642
- if (autonomous && value !== null) {
643
- throw new Error('An autonomous Agent may suggest a finite Duty concurrency cap, but cannot activate owner policy. Omit the field or use unlimited; an owner can set the cap later.');
644
- }
645
647
  if (value !== null && !normalizedReason) {
646
648
  throw new Error('A finite --max-concurrent-runs value requires --concurrency-reason.');
647
649
  }
@@ -672,7 +674,11 @@ function describeDutyConcurrency(duty) {
672
674
  const authority = decision?.authority || 'unknown';
673
675
  const source = decision?.source || 'legacy';
674
676
  const review = authority === 'unknown' ? ' — review required' : '';
675
- return `${limit} (${authority}/${source}${review})`;
677
+ // An Agent's decision says so (OSK-33488), naming the Agent when the request named one.
678
+ const byAgent = decision?.actorKind === 'agent' || decision?.actorAgentId
679
+ ? `, by Agent${decision.actorAgentId ? ` ${decision.actorAgentId}` : ''}`
680
+ : '';
681
+ return `${limit} (${authority}/${source}${byAgent}${review})`;
676
682
  }
677
683
  /**
678
684
  * Parse a human interval ("15m", "6h", "1d", or a bare number of minutes) into
@@ -123,7 +123,10 @@ function createNodeAdapter(opts = {}) {
123
123
  // assignee list to remember that an agent filed it. Same contract as the
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
- // before stamping it, and rejects a claim that does not check out.
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
130
  const sessionAgentId = (process.env.OVERSKY_SESSION_AGENT_ID || process.env.OVERSKY_AGENT_ID)?.trim();
128
131
  if (sessionAgentId) {
129
132
  headers['X-Oversky-Agent-Id'] = sessionAgentId;