@skrr-ai/cli 0.1.228 → 0.1.231

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.
@@ -35,7 +35,7 @@ export declare abstract class BaseCommand extends Command {
35
35
  * declares that policy locally, so its narrower actor does not depend on
36
36
  * acquiring unrelated account authority. Human invocations are unaffected.
37
37
  */
38
- static autonomousCredentialPolicy: 'delegated' | 'bound-session';
38
+ static autonomousCredentialPolicy: 'delegated' | 'bound-session' | 'scoped-task-operation';
39
39
  /**
40
40
  * What a managed command may do when the daemon cannot mint the delegated credential it asked for.
41
41
  * `none` fails, as always. `bound-session-when-daemon-brokered` keeps the bound session credential
@@ -438,8 +438,9 @@ class BaseCommand extends core_1.Command {
438
438
  kind: (0, auth_core_1.classifyTokenKind)(historySession.token),
439
439
  }
440
440
  : (0, credential_resolver_1.resolveTrustedAutonomousCredential)();
441
- const boundSessionCommand = Boolean(autonomousCredential &&
442
- this.constructor.autonomousCredentialPolicy === 'bound-session');
441
+ const credentialPolicy = this.constructor.autonomousCredentialPolicy;
442
+ const boundSessionCommand = Boolean(autonomousCredential && (credentialPolicy === 'bound-session' ||
443
+ (credentialPolicy === 'scoped-task-operation' && process.env.OVERSKY_SCOPED_TASK_OPERATIONS === '1')));
443
444
  if ((0, delegated_cli_1.isDelegatedCliSession)() && !boundSessionCommand) {
444
445
  // Only the fetch is inside the try. `failWithCliError` writes the envelope and then THROWS to
445
446
  // exit, so a call to it inside the try was caught by the catch below and reported a second
@@ -2025,6 +2026,7 @@ class BaseCommand extends core_1.Command {
2025
2026
  status: e.status,
2026
2027
  exit: 3,
2027
2028
  retryable: typeof body?.retryable === 'boolean' ? body.retryable : edgeRefusal,
2029
+ ...(body?.permissionDecision ? { details: envelopeDetails(body) } : {}),
2028
2030
  });
2029
2031
  }
2030
2032
  else if (e.status === 404) {
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class AgentsPermissionsPolicy extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ agentId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ class AgentsPermissionsPolicy extends base_command_1.BaseCommand {
7
+ static description = 'Show this Agent’s operation rules, revision and enforcement mode.';
8
+ static args = { agentId: core_1.Args.string({ required: true, ignoreStdin: true }) };
9
+ static flags = { json: core_1.Flags.boolean({ description: 'Output JSON' }) };
10
+ async run() {
11
+ this.requireAuth();
12
+ const { args, flags } = await this.parse(AgentsPermissionsPolicy);
13
+ try {
14
+ const policy = await data_provider_1.dataService.getAgentOperationPolicy(args.agentId);
15
+ if (flags.json)
16
+ return this.log(this.agentJson(args.agentId, policy));
17
+ this.log(`Agent ${args.agentId} permissions · ${policy.mode} · revision ${policy.revision}`);
18
+ if (!policy.rules.length)
19
+ this.log('No operation rules configured.');
20
+ for (const rule of policy.rules) {
21
+ this.log(`${rule.operation} ${rule.decision}${rule.taskId ? ` Task ${rule.taskId}` : ''}`);
22
+ }
23
+ }
24
+ catch (error) {
25
+ this.handleApiError(error);
26
+ }
27
+ }
28
+ }
29
+ exports.default = AgentsPermissionsPolicy;
@@ -313,7 +313,7 @@ class TasksComplete extends base_command_1.BaseCommand {
313
313
  // is its Agent's, proven by its Run, and sends none.
314
314
  ...(sessionWrite ? {} : (0, task_write_attribution_1.declaredToolSource)()),
315
315
  },
316
- headers: { 'X-Idempotency-Key': idempotencyKey },
316
+ headers: { ...sessionWrite?.headers, 'X-Idempotency-Key': idempotencyKey },
317
317
  });
318
318
  }
319
319
  catch (error) {
@@ -11,6 +11,7 @@ export { unowedReviewNotice };
11
11
  * may pass either a stable state id or its Space-local display name.
12
12
  */
13
13
  export default class TasksMove extends BaseCommand {
14
+ static autonomousCredentialPolicy: "scoped-task-operation";
14
15
  static description: string;
15
16
  static examples: string[];
16
17
  static args: {
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "unowedReviewNotice", { enumerable: true, get: fu
26
26
  * may pass either a stable state id or its Space-local display name.
27
27
  */
28
28
  class TasksMove extends base_command_1.BaseCommand {
29
+ static autonomousCredentialPolicy = 'scoped-task-operation';
29
30
  static description = "Change a task's status and/or project (the canonical status-transition endpoint)";
30
31
  static examples = [
31
32
  '<%= config.bin %> tasks move <task-id> --status in_progress',
@@ -137,7 +138,8 @@ class TasksMove extends base_command_1.BaseCommand {
137
138
  if (sessionWrite) {
138
139
  const res = (await (0, api_fetch_1.apiFetch)(sessionWrite.path, {
139
140
  credential: sessionWrite.credential,
140
- method: 'POST',
141
+ method: sessionWrite.addressed ? 'PATCH' : 'POST',
142
+ headers: sessionWrite.headers,
141
143
  body: {
142
144
  status: flags.status,
143
145
  ...(flags.reason ? { reason: flags.reason } : {}),
@@ -146,8 +148,15 @@ class TasksMove extends base_command_1.BaseCommand {
146
148
  ...(expectedVersion !== undefined ? { expectedVersion } : {}),
147
149
  },
148
150
  }));
149
- updated = res.task;
150
- carrierGuidance = res.carrierGuidance;
151
+ if (sessionWrite.addressed) {
152
+ updated = res;
153
+ carrierGuidance = updated
154
+ ._carrierGuidance;
155
+ }
156
+ else {
157
+ updated = res.task;
158
+ carrierGuidance = res.carrierGuidance;
159
+ }
151
160
  }
152
161
  else {
153
162
  updated = await data_provider_1.dataService.moveTask({
@@ -162,6 +162,7 @@ class TasksResultSubmit extends base_command_1.BaseCommand {
162
162
  ? await (0, api_fetch_1.apiFetch)(sessionWrite.path, {
163
163
  method: 'POST',
164
164
  credential: sessionWrite.credential,
165
+ headers: sessionWrite.headers,
165
166
  body: data,
166
167
  })
167
168
  : await data_provider_1.dataService.submitTaskResult({
@@ -10,6 +10,7 @@
10
10
  export type SessionTaskOperation = 'completion' | 'move' | 'comment' | 'event' | 'update' | 'result' | 'resume' | 'resumeRead' | 'deliverable' | 'review' | 'assessment' | 'attachment' | 'attachmentIntent' | 'attachmentComplete' | 'read';
11
11
  /** Path suffix per operation. Exported for the parity test, not for callers. */
12
12
  export declare const SESSION_TASK_PATH_SUFFIX: Record<SessionTaskOperation, string>;
13
+ export declare function addressedTaskEffectPath(operation: SessionTaskOperation, taskId: string): string | null;
13
14
  /**
14
15
  * The session-scoped path for `operation`, or `null` when this invocation
15
16
  * should use the generic task routes.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SESSION_TASK_PATH_SUFFIX = void 0;
4
+ exports.addressedTaskEffectPath = addressedTaskEffectPath;
4
5
  exports.sessionScopedTaskPath = sessionScopedTaskPath;
5
6
  exports.requestMatchesBoundTask = requestMatchesBoundTask;
6
7
  /**
@@ -52,6 +53,16 @@ exports.SESSION_TASK_PATH_SUFFIX = {
52
53
  attachmentComplete: 'task-attachments/complete',
53
54
  read: 'task',
54
55
  };
56
+ const ADDRESSED_TASK_EFFECT_SUFFIX = {
57
+ completion: 'complete',
58
+ move: 'move',
59
+ result: 'results',
60
+ };
61
+ function addressedTaskEffectPath(operation, taskId) {
62
+ if (operation !== 'completion' && operation !== 'move' && operation !== 'result')
63
+ return null;
64
+ return `/api/tasks/${encodeURIComponent(taskId)}/${ADDRESSED_TASK_EFFECT_SUFFIX[operation]}`;
65
+ }
55
66
  /**
56
67
  * The session-scoped path for `operation`, or `null` when this invocation
57
68
  * should use the generic task routes.
@@ -20,6 +20,14 @@ export declare function resetSessionTaskWriteCache(): void;
20
20
  * Human invocations continue through their ordinary Task endpoints.
21
21
  */
22
22
  export declare function sessionTaskWrite(operation: Exclude<SessionTaskOperation, 'read'>, requestedTask: string, env?: Record<string, string | undefined>): Promise<{
23
+ path: string;
24
+ credential: import("./credential-resolver").ResolvedCredential;
25
+ taskId: string;
26
+ addressed: true;
27
+ headers: {
28
+ 'X-Oversky-Session-Id': string;
29
+ };
30
+ } | {
23
31
  path: string;
24
32
  credential: import("./credential-resolver").ResolvedCredential;
25
33
  taskId: string;
@@ -28,4 +36,6 @@ export declare function sessionTaskWrite(operation: Exclude<SessionTaskOperation
28
36
  _id?: string;
29
37
  identifier?: string;
30
38
  } & Record<string, unknown>;
39
+ addressed: false;
40
+ headers: undefined;
31
41
  } | null>;
@@ -69,8 +69,22 @@ async function sessionTaskWrite(operation, requestedTask, env = process.env) {
69
69
  }
70
70
  // A run with no bound Task (e.g. a Duty run) has no session-scoped
71
71
  // Task surface; its writes take the generic routes (OSK-16124).
72
+ const addressedWrite = () => {
73
+ if (env.OVERSKY_SCOPED_TASK_OPERATIONS !== '1')
74
+ return null;
75
+ const path = (0, session_task_endpoints_1.addressedTaskEffectPath)(operation, requestedTask);
76
+ if (!path)
77
+ return null;
78
+ return {
79
+ path,
80
+ credential,
81
+ taskId: requestedTask,
82
+ addressed: true,
83
+ headers: { 'X-Oversky-Session-Id': sessionId },
84
+ };
85
+ };
72
86
  if (sessionsWithoutBoundTask.has(sessionId))
73
- return null;
87
+ return addressedWrite();
74
88
  const prefix = `/api/agentic/sessions/${encodeURIComponent(sessionId)}`;
75
89
  // A scoped endpoint derives its Task and ignores a caller's Task id. Check
76
90
  // the requested coordinate first, so naming a sibling cannot quietly finish
@@ -85,7 +99,7 @@ async function sessionTaskWrite(operation, requestedTask, env = process.env) {
85
99
  catch (err) {
86
100
  if (refusalReason(err) === exports.SESSION_HAS_NO_TASK) {
87
101
  sessionsWithoutBoundTask.add(sessionId);
88
- return null;
102
+ return addressedWrite();
89
103
  }
90
104
  throw err;
91
105
  }
@@ -99,5 +113,7 @@ async function sessionTaskWrite(operation, requestedTask, env = process.env) {
99
113
  credential,
100
114
  taskId: bound.id,
101
115
  task: bound,
116
+ addressed: false,
117
+ headers: undefined,
102
118
  };
103
119
  }
@@ -99,7 +99,7 @@ function storedText(value) {
99
99
  */
100
100
  async function readTaskForUpload(taskId) {
101
101
  const target = await (0, session_task_write_1.sessionTaskWrite)('attachment', taskId);
102
- if (target)
102
+ if (target?.addressed === false)
103
103
  return target.task;
104
104
  return (await data_provider_1.dataService.getTask(taskId, { enrich: false }));
105
105
  }
@@ -25,6 +25,7 @@ exports.readExactTaskResult = readExactTaskResult;
25
25
  const data_provider_1 = require("@skrr-ai/data-provider");
26
26
  const triggers_1 = require("./triggers");
27
27
  const api_fetch_1 = require("./api-fetch");
28
+ const session_task_endpoints_1 = require("./session-task-endpoints");
28
29
  const PARSE_EXECUTION_TARGET_REF_RE = /^hosted-machine:(.+)$/;
29
30
  const PARSE_EXECUTION_TARGET_REF_RE_2 = /^harness:(.+)$/;
30
31
  const MOUNT = '/api/tasks';
@@ -90,7 +91,7 @@ exports.taskSelfScheduleApi = {
90
91
  * parity check.
91
92
  */
92
93
  function taskCompletePath(taskId) {
93
- return `${base(taskId)}/complete`;
94
+ return (0, session_task_endpoints_1.addressedTaskEffectPath)('completion', taskId);
94
95
  }
95
96
  /**
96
97
  * `POST /api/tasks/:taskId/runs/:runId/handover` — the B1 admission path