@skrr-ai/cli 0.1.139 → 0.1.140

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.
@@ -1826,7 +1826,10 @@ class BaseCommand extends core_1.Command {
1826
1826
  e.message.includes('ECONNREFUSED') ||
1827
1827
  e.message.includes('fetch failed')) {
1828
1828
  this.failWithCliError({
1829
- message: say(`Could not connect to ${this.cliConfig.baseURL}. Is the API server running?`),
1829
+ message: say(e.code === 'ECONNREFUSED' || e.message.includes('ECONNREFUSED')
1830
+ ? `Could not connect to ${this.cliConfig.baseURL}. Is the API server running?`
1831
+ : `The request to ${this.cliConfig.baseURL} failed before its outcome could be confirmed. ` +
1832
+ 'It may have reached the server. Check the result before retrying.'),
1830
1833
  code: e.code || 'NETWORK_ERROR',
1831
1834
  exit: 5,
1832
1835
  retryable: true,
@@ -73,6 +73,17 @@ export type CanonicalIntentEnvelope = {
73
73
  * a compromised producer cannot elevate itself into a session principal.
74
74
  */
75
75
  export default class AgentMessageSend extends BaseCommand {
76
+ private attemptedMessageKey?;
77
+ private partialSequence?;
78
+ protected failWithCliError(input: {
79
+ message: string;
80
+ code: string;
81
+ status?: number;
82
+ exit: number;
83
+ retryable: boolean;
84
+ details?: unknown;
85
+ requestId?: string;
86
+ }): never;
76
87
  static description: string;
77
88
  static examples: string[];
78
89
  static args: {
@@ -75,6 +75,40 @@ const PROTOCOL_VERSION = 1;
75
75
  * a compromised producer cannot elevate itself into a session principal.
76
76
  */
77
77
  class AgentMessageSend extends base_command_1.BaseCommand {
78
+ attemptedMessageKey;
79
+ partialSequence;
80
+ failWithCliError(input) {
81
+ const partial = this.partialSequence;
82
+ const retry = this.attemptedMessageKey && input.exit === 5 && input.retryable && !input.status
83
+ ? {
84
+ idempotencyKey: partial?.sequenceId || this.attemptedMessageKey,
85
+ ...(partial ? { attemptedPartKey: this.attemptedMessageKey } : {}),
86
+ }
87
+ : undefined;
88
+ if (!partial && !retry)
89
+ return super.failWithCliError(input);
90
+ const originalDetails = input.details;
91
+ const extra = { ...(partial ? { partialSequence: partial } : {}), ...(retry ? { messageRetry: retry } : {}) };
92
+ const details = originalDetails && typeof originalDetails === 'object' && !Array.isArray(originalDetails)
93
+ ? {
94
+ ...originalDetails,
95
+ ...(Object.keys(extra).some((key) => Object.hasOwn(originalDetails, key)) ? { originalDetails } : {}),
96
+ ...extra,
97
+ }
98
+ : { ...(originalDetails === undefined ? {} : { originalDetails }), ...extra };
99
+ const outcomes = partial?.parts.map((part, index) => `${index + 1}: ${part.intent.status}`).join(', ');
100
+ const sequenceNote = partial ? `\nEarlier part outcomes: ${outcomes || 'none'}. ` +
101
+ `Part ${partial.attemptedPart} was attempted; ${partial.unattemptedParts} later part(s) were not sent.` : '';
102
+ const json = this.wantsJsonOutput();
103
+ if (retry && !json) {
104
+ // oclif wraps error text and inserts prefixes into long generated keys.
105
+ // Write the key as a single stderr line so it remains copyable.
106
+ process.stderr.write(`Retry idempotency key: ${retry.idempotencyKey}\n`);
107
+ }
108
+ const retryNote = retry ? '\nIf you retry the same message, reuse the retry key shown above.' : '';
109
+ const message = json ? input.message : input.message + sequenceNote + retryNote;
110
+ return super.failWithCliError({ ...input, message, details });
111
+ }
78
112
  static description = 'Submit a channel-neutral agent message intent through the ProactiveMessageGateway';
79
113
  static examples = [
80
114
  '<%= config.bin %> agent message send --from-json payload.json --json',
@@ -314,6 +348,14 @@ class AgentMessageSend extends base_command_1.BaseCommand {
314
348
  const envelopes = [];
315
349
  let halt;
316
350
  for (const [index, requestPart] of requests.entries()) {
351
+ this.attemptedMessageKey = requestPart.idempotencyKey;
352
+ this.partialSequence = requests.length > 1 ? {
353
+ sequenceId: idempotencyKey,
354
+ parts: [...envelopes],
355
+ attemptedPart: index + 1,
356
+ totalParts: requests.length,
357
+ unattemptedParts: requests.length - index - 1,
358
+ } : undefined;
317
359
  const envelope = sessionContext
318
360
  ? await this.submitAsSession({
319
361
  sessionContext,
@@ -326,6 +368,8 @@ class AgentMessageSend extends base_command_1.BaseCommand {
326
368
  agentIdentity: agentIdentity,
327
369
  principalSource,
328
370
  });
371
+ this.partialSequence = undefined;
372
+ this.attemptedMessageKey = undefined;
329
373
  envelopes.push(envelope);
330
374
  // A part that did not reach the user must stop the sequence. Continuing
331
375
  // would deliver thought 3 while thought 2 sits held for approval, and the
@@ -288,7 +288,9 @@ class AgentsCreate extends base_command_1.BaseCommand {
288
288
  'support-contact': core_1.Flags.string({
289
289
  description: 'Support contact JSON object: {"name","email","security_email"}. The Store listing shows the email and security_email of the published release.',
290
290
  }),
291
- 'install-first-contact': core_1.Flags.string({ description: 'First-contact config JSON value' }),
291
+ 'install-first-contact': core_1.Flags.string({
292
+ description: 'First-contact config JSON value; notificationPolicy is normal or silent (legacy quiet is also accepted)',
293
+ }),
292
294
  'end-after-tools': core_1.Flags.boolean({ description: 'End turn after tools' }),
293
295
  'hide-sequential-outputs': core_1.Flags.boolean({ description: 'Hide sequential outputs' }),
294
296
  'is-collaborative': core_1.Flags.boolean({ description: 'Enable collaboration' }),
@@ -53,6 +53,21 @@ function proactiveInstallReadiness(result, bin) {
53
53
  if (result.warnings.length === 0) {
54
54
  return { status: 'ready', message: 'All requested setup steps completed.' };
55
55
  }
56
+ if (result.warnings.some((warning) => warning.step.startsWith('commitment.'))) {
57
+ const affected = (result.installed.commitments || []).filter((commitment) => commitment.status !== 'active' || result.warnings.some((warning) => warning.step === `commitment.${commitment.title}`));
58
+ const ids = [...new Set(affected.map((commitment) => commitment.id))]
59
+ .filter((id) => typeof id === 'string' && /^[A-Za-z0-9_-]+$/.test(id));
60
+ const safeAgentId = /^[A-Za-z0-9_-]+$/.test(result.agentId) ? result.agentId : null;
61
+ return {
62
+ status: 'degraded',
63
+ message: ids.length
64
+ ? `Review the existing Commitment${ids.length === 1 ? '' : 's'} ${ids.join(', ')} and resolve the reported issues. Review any other setup warnings as well.`
65
+ : 'A requested Commitment needs attention. Review the setup warnings and inspect the Agent’s existing Commitments before deciding what to do next.',
66
+ ...(ids.length === 1
67
+ ? { repairCommand: `${bin} commitments preflight ${ids[0]}` }
68
+ : safeAgentId ? { repairCommand: `${bin} commitments list --agent ${safeAgentId}` } : {}),
69
+ };
70
+ }
56
71
  if (result.warnings.some((warning) => warning.code === 'always_on_off')) {
57
72
  return {
58
73
  status: 'degraded',
@@ -84,10 +99,11 @@ function proactiveInstallReadiness(result, bin) {
84
99
  };
85
100
  }
86
101
  const repairCommand = `${bin} agents spawn --agent-id ${result.agentId} --from-spec <spec.json> --approve`;
102
+ const watcherFailed = result.warnings.some((warning) => warning.step.startsWith('watcher.'));
87
103
  return {
88
104
  status: 'degraded',
89
- message: 'The Agent was created, but one or more requested setup steps did not install. ' +
90
- 'Do not assume failed watchers are active until their warning is resolved and the install is re-run.',
105
+ message: 'Some requested setup steps need attention. Review the warnings.' +
106
+ (watcherFailed ? ' Do not assume failed watchers are active.' : ''),
91
107
  repairCommand,
92
108
  };
93
109
  }
@@ -129,7 +145,7 @@ class AgentsSpawn extends base_command_1.BaseCommand {
129
145
  description: 'Create the agent and install the proactive system(s) (otherwise plan-only)',
130
146
  }),
131
147
  recommend: core_1.Flags.boolean({
132
- description: 'Persist a reviewable recommendation instead of creating directly',
148
+ description: 'Persist a reviewable recommendation from a sentence (cannot be combined with --from-spec)',
133
149
  }),
134
150
  'approve-recommendation': core_1.Flags.string({
135
151
  description: 'Approve an existing proactive-agent recommendation id',
@@ -158,6 +174,9 @@ class AgentsSpawn extends base_command_1.BaseCommand {
158
174
  async run() {
159
175
  this.requireAuth();
160
176
  const { args, flags } = await this.parse(AgentsSpawn);
177
+ if (flags.recommend && flags['from-spec']) {
178
+ this.error('--recommend cannot be combined with --from-spec. Use a sentence with --recommend, or review the spec and apply it with --from-spec and --approve.', { exit: 1 });
179
+ }
161
180
  try {
162
181
  if (flags['approve-recommendation'] || flags['apply-recommendation']) {
163
182
  await this.runRecommendationAction(flags);
@@ -197,7 +216,7 @@ class AgentsSpawn extends base_command_1.BaseCommand {
197
216
  ...(flags.timezone ? { timezone: flags.timezone } : {}),
198
217
  fromReviewedSpec: true,
199
218
  });
200
- this.renderApplyResult(result, flags.json);
219
+ this.renderApplyResult(result, flags.json, Boolean(flags['agent-id']));
201
220
  }
202
221
  async runFromSentence(sentence, flags) {
203
222
  const history = (flags.message ?? []).map((content) => ({
@@ -256,7 +275,7 @@ class AgentsSpawn extends base_command_1.BaseCommand {
256
275
  ...(flags.timezone ? { timezone: flags.timezone } : {}),
257
276
  fromReviewedSpec: false,
258
277
  });
259
- this.renderApplyResult(result, flags.json);
278
+ this.renderApplyResult(result, flags.json, Boolean(flags['agent-id']));
260
279
  }
261
280
  async runRecommendationAction(flags) {
262
281
  if (flags['apply-recommendation'] && !flags['spec-hash']?.trim()) {
@@ -286,7 +305,7 @@ class AgentsSpawn extends base_command_1.BaseCommand {
286
305
  ...(flags.timezone ? { timezone: flags.timezone } : {}),
287
306
  ...(flags['spec-hash'] ? { specHash: flags['spec-hash'] } : {}),
288
307
  });
289
- this.renderApplyResult(result, flags.json);
308
+ this.renderApplyResult(result, flags.json, Boolean(flags['agent-id']));
290
309
  }
291
310
  renderSpec(spec) {
292
311
  const id = spec.identity;
@@ -314,8 +333,13 @@ class AgentsSpawn extends base_command_1.BaseCommand {
314
333
  `hours: ${o.workingHours.start}–${o.workingHours.end}` +
315
334
  `${o.workingHours.timezone ? ` ${o.workingHours.timezone}` : ''}`);
316
335
  }
336
+ if (Array.isArray(spec.commitments) && spec.commitments.length > 0) {
337
+ this.log('');
338
+ this.log('Commitments (as provided; subject to validation):');
339
+ this.log(JSON.stringify(spec.commitments, null, 2));
340
+ }
317
341
  }
318
- renderApplyResult(result, json) {
342
+ renderApplyResult(result, json, existingAgent) {
319
343
  const readiness = proactiveInstallReadiness(result, this.config.bin);
320
344
  if (json) {
321
345
  this.log(JSON.stringify({
@@ -325,7 +349,7 @@ class AgentsSpawn extends base_command_1.BaseCommand {
325
349
  }, null, 2));
326
350
  return;
327
351
  }
328
- this.log(`Spawned agent ${result.agentId}`);
352
+ this.log(`${existingAgent ? 'Existing agent' : 'Spawned agent'} ${result.agentId}`);
329
353
  this.log(`URL: ${(0, web_url_1.agentUrlFrom)(this.cliConfig.baseURL, { id: result.agentId }) ?? '-'}`);
330
354
  this.log(`Status: ${readiness.status.toUpperCase()} — ${readiness.message}`);
331
355
  const w = result.installed.worker;
@@ -1,6 +1,6 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
2
  /**
3
- * `skrr commitments endpoints list` — the delivery targets commitments may report to.
3
+ * `skrr commitments endpoints list --agent <id>` — delivery targets for an Agent.
4
4
  *
5
5
  * The `USABLE` column is the one that matters: it is the field the commitment
6
6
  * invocation actually reads when deciding whether a report target can be used.
@@ -12,7 +12,7 @@ export default class CommitmentsEndpointsList extends BaseCommand {
12
12
  static examples: string[];
13
13
  static flags: {
14
14
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
- agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ agent: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
16
16
  };
17
17
  run(): Promise<void>;
18
18
  }
@@ -5,7 +5,7 @@ const core_1 = require("@oclif/core");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  const commitment_endpoints_1 = require("../../../lib/commitment-endpoints");
7
7
  /**
8
- * `skrr commitments endpoints list` — the delivery targets commitments may report to.
8
+ * `skrr commitments endpoints list --agent <id>` — delivery targets for an Agent.
9
9
  *
10
10
  * The `USABLE` column is the one that matters: it is the field the commitment
11
11
  * invocation actually reads when deciding whether a report target can be used.
@@ -15,12 +15,12 @@ const commitment_endpoints_1 = require("../../../lib/commitment-endpoints");
15
15
  class CommitmentsEndpointsList extends base_command_1.BaseCommand {
16
16
  static description = 'List commitment delivery endpoints';
17
17
  static examples = [
18
- '<%= config.bin %> commitments endpoints list',
18
+ '<%= config.bin %> commitments endpoints list --agent agent_abc',
19
19
  '<%= config.bin %> commitments endpoints list --agent agent_abc --json',
20
20
  ];
21
21
  static flags = {
22
22
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
23
- agent: core_1.Flags.string({ description: 'Filter by agent ID' }),
23
+ agent: core_1.Flags.string({ description: 'Agent ID whose delivery endpoints to list', required: true }),
24
24
  };
25
25
  async run() {
26
26
  this.requireAuth();
@@ -197,6 +197,25 @@ class StoreInstall extends base_command_1.BaseCommand {
197
197
  }
198
198
  const installedId = response?.installedAgentId;
199
199
  this.log(`Installed as ${installedId ?? '-'}.`);
200
+ if (response?.proactive?.armed === false) {
201
+ this.log('This Agent starts in standby (Always-On is off).');
202
+ if (response.proactive.enable?.cli) {
203
+ this.log(`To let it work on its own: ${response.proactive.enable.cli}`);
204
+ }
205
+ }
206
+ const firstContact = response?.installFirstContact;
207
+ if (firstContact?.scheduled === true) {
208
+ const rawRunAt = firstContact.runAt ?? firstContact.scheduledFor;
209
+ const date = rawRunAt instanceof Date ? rawRunAt : rawRunAt ? new Date(rawRunAt) : undefined;
210
+ const when = date && Number.isFinite(date.getTime()) ? ` for ${date.toISOString()}` : '';
211
+ this.log(`A one-time first-contact greeting is scheduled${when}.`);
212
+ }
213
+ else if (firstContact?.duplicate === true || firstContact?.reason === 'already_scheduled') {
214
+ this.log('A first-contact trigger already exists; check its status to see whether it is still pending.');
215
+ }
216
+ else if (firstContact?.scheduled === false) {
217
+ this.log('No first-contact greeting was scheduled by this install.');
218
+ }
200
219
  // Report only what the server says it wrote. A server that does not echo a
201
220
  // placement predates it and wrote none, so naming one here would be a claim
202
221
  // about a copy this CLI cannot see.
@@ -48,6 +48,7 @@ export interface ProactiveAgentSpec {
48
48
  mode: OrchestratorMode;
49
49
  executePlan: boolean;
50
50
  };
51
+ commitments?: Array<Record<string, unknown>>;
51
52
  initialize?: {
52
53
  goals?: Array<{
53
54
  title: string;
@@ -121,6 +122,16 @@ export interface ApplyProactiveAgentResponse {
121
122
  status?: string;
122
123
  code?: string;
123
124
  };
125
+ commitments?: Array<{
126
+ id: string;
127
+ title?: string;
128
+ status?: string;
129
+ activated?: boolean;
130
+ blockedBy?: Array<{
131
+ gate?: string;
132
+ reason?: string;
133
+ }>;
134
+ }>;
124
135
  initialize?: {
125
136
  goals: Array<{
126
137
  id?: string;