@skrr-ai/cli 0.1.212 → 0.1.214

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 (29) hide show
  1. package/dist/commands/agents/relationship/clear.d.ts +12 -0
  2. package/dist/commands/agents/relationship/clear.js +26 -0
  3. package/dist/commands/agents/relationship/edit.d.ts +15 -0
  4. package/dist/commands/agents/relationship/edit.js +40 -0
  5. package/dist/commands/agents/relationship/show.d.ts +12 -0
  6. package/dist/commands/agents/relationship/show.js +35 -0
  7. package/dist/commands/duties/action-proposal.js +2 -1
  8. package/dist/commands/duties/action-proposals.d.ts +1 -0
  9. package/dist/commands/duties/action-proposals.js +8 -0
  10. package/dist/lib/duties.js +4 -2
  11. package/dist/lib/inbound-messages.js +7 -0
  12. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/managedWorkRuntime.d.ts +21 -3
  13. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/managedWorkRuntime.js +20 -5
  14. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/personAskWindow.d.ts +23 -0
  15. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/personAskWindow.js +28 -0
  16. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +41 -2
  17. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +282 -9
  18. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/runtime.d.ts +5 -0
  19. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/managedWorkRuntime.d.ts +21 -3
  20. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/managedWorkRuntime.js +26 -10
  21. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/personAskWindow.d.ts +23 -0
  22. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/personAskWindow.js +23 -0
  23. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +41 -2
  24. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +460 -18
  25. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/runtime.d.ts +5 -0
  26. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  27. package/dist/node_modules/@skrr-ai/data-provider/index.js +10735 -10724
  28. package/oclif.manifest.json +241 -1
  29. package/package.json +2 -2
@@ -32,6 +32,7 @@ __export(refresh_exports, {
32
32
  LOCK_SIGNAL_FALLBACK_EXIT_MS: () => LOCK_SIGNAL_FALLBACK_EXIT_MS,
33
33
  REAUTH_FLAG_PATH_FN: () => reauthFlagPath,
34
34
  UNKNOWN_401_BUDGET: () => UNKNOWN_401_BUDGET,
35
+ __authLockTesting: () => __authLockTesting,
35
36
  __refreshDiagnostics: () => __refreshDiagnostics,
36
37
  __resetUnknown401StreaksForTest: () => __resetUnknown401StreaksForTest,
37
38
  clearReauthState: () => clearReauthState,
@@ -58,6 +59,285 @@ const REVOKE_DAEMON_REFRESH_SESSION_REPORTED_RE = /\/+$/;
58
59
  const LOCK_STALE_MS = 5e3;
59
60
  const LOCK_RETRY_MS = 100;
60
61
  const LOCK_MAX_RETRIES = 50;
62
+ const LOCK_ACQUIRE_DEADLINE_MS = 6e4;
63
+ const LOCK_ASYNC_FS_PROBE_MS = 1e3;
64
+ const CALLS_UNSAFE_TO_OUTLIVE = /* @__PURE__ */ new Set(["rmdir", "utimes"]);
65
+ const MAX_PASSED_OVER = 1;
66
+ const lockPaths = /* @__PURE__ */ new Map();
67
+ const probeStats = /* @__PURE__ */ new Map();
68
+ const __authLockTesting = {
69
+ acquireDeadlineMs: LOCK_ACQUIRE_DEADLINE_MS,
70
+ asyncFsProbeMs: LOCK_ASYNC_FS_PROBE_MS,
71
+ fs: import_node_fs.default,
72
+ lockPaths,
73
+ probes: probeStats,
74
+ trackFs: (base, state, onPendingChange) => trackedLockFs(base, state, onPendingChange)
75
+ };
76
+ function abandonedError(op) {
77
+ return Object.assign(new Error(`The auth lock acquire was abandoned at its deadline (${op})`), {
78
+ code: "EABANDONED"
79
+ });
80
+ }
81
+ function trackedLockFs(base, state, onPendingChange) {
82
+ return new Proxy(base, {
83
+ get(target, prop, receiver) {
84
+ const value = Reflect.get(target, prop, receiver);
85
+ if (typeof value !== "function")
86
+ return value;
87
+ return (...args) => {
88
+ const callback = args[args.length - 1];
89
+ if (typeof callback !== "function")
90
+ return Reflect.apply(value, target, args);
91
+ const op = String(prop);
92
+ const answer = callback;
93
+ if (state.abandoned) {
94
+ process.nextTick(answer, abandonedError(op));
95
+ return void 0;
96
+ }
97
+ if (op === "mkdir")
98
+ state.mkdirCalls += 1;
99
+ const call = {
100
+ op,
101
+ ...typeof args[0] === "string" ? { path: args[0] } : {},
102
+ startedAt: Date.now()
103
+ };
104
+ state.pending.add(call);
105
+ const settle = () => {
106
+ state.pending.delete(call);
107
+ onPendingChange();
108
+ };
109
+ args[args.length - 1] = (...result) => {
110
+ settle();
111
+ if (state.abandoned) {
112
+ answer(abandonedError(op));
113
+ return;
114
+ }
115
+ answer(...result);
116
+ };
117
+ try {
118
+ return Reflect.apply(value, target, args);
119
+ } catch (err) {
120
+ settle();
121
+ throw err;
122
+ }
123
+ };
124
+ }
125
+ });
126
+ }
127
+ async function probeAsyncFs(base, dir, ms) {
128
+ let probe = probeStats.get(dir);
129
+ const reusedAfterMs = probe ? Date.now() - probe.startedAt : null;
130
+ if (!probe) {
131
+ const started = {
132
+ answer: base.promises.stat(dir).then(() => "answered", () => "failed"),
133
+ startedAt: Date.now()
134
+ };
135
+ probeStats.set(dir, started);
136
+ void started.answer.then(() => {
137
+ if (probeStats.get(dir) === started)
138
+ probeStats.delete(dir);
139
+ });
140
+ probe = started;
141
+ }
142
+ let timer;
143
+ const noAnswer = new Promise((resolve) => {
144
+ timer = setTimeout(() => resolve("no_answer"), ms);
145
+ });
146
+ try {
147
+ return { result: await Promise.race([probe.answer, noAnswer]), reusedAfterMs };
148
+ } finally {
149
+ clearTimeout(timer);
150
+ }
151
+ }
152
+ function asyncFsProbeText(probe, ms) {
153
+ if (probe.result === "answered")
154
+ return "an async stat of the auth config directory answered";
155
+ if (probe.result === "failed")
156
+ return "an async stat of the auth config directory failed";
157
+ return probe.reusedAfterMs === null ? `a fresh async stat of the auth config directory did not answer within ${ms} ms` : `an async stat of the auth config directory started ${formatLockWait(probe.reusedAfterMs)} ago has still not answered`;
158
+ }
159
+ function describePendingCalls(pending, now) {
160
+ const calls = [...pending].sort((a, b) => a.startedAt - b.startedAt).map((call) => ({
161
+ op: call.op,
162
+ ...call.path ? { file: import_node_path.default.basename(call.path) } : {},
163
+ pendingMs: now - call.startedAt
164
+ }));
165
+ const text = calls.map((call) => `${call.op}${call.file ? ` ${call.file}` : ""} (${call.pendingMs} ms)`).join(", ");
166
+ return { calls, text };
167
+ }
168
+ async function acquireAuthLock(lockPath, daemonId) {
169
+ const { acquireDeadlineMs, asyncFsProbeMs, fs: baseFs } = __authLockTesting;
170
+ (0, import_liveState.assertMayMutateLiveState)(`${lockPath}.lock`, "take the auth lock");
171
+ const arrivedAt = Date.now();
172
+ const probe = () => probeAsyncFs(baseFs, import_node_path.default.dirname(lockPath), asyncFsProbeMs);
173
+ const pathState = lockPaths.get(lockPath) ?? {
174
+ blockers: /* @__PURE__ */ new Set(),
175
+ passedOver: /* @__PURE__ */ new Set(),
176
+ waiters: /* @__PURE__ */ new Set()
177
+ };
178
+ lockPaths.set(lockPath, pathState);
179
+ if (pathState.blockers.size > 0) {
180
+ const outcome = await waitForBlockers(pathState, acquireDeadlineMs, probe);
181
+ if (outcome !== "clear") {
182
+ const waitedMs2 = Date.now() - arrivedAt;
183
+ throw lockAcquireTimeout({
184
+ lockPath,
185
+ daemonId,
186
+ waitedMs: waitedMs2,
187
+ queuedMs: waitedMs2,
188
+ mkdirCalls: 0,
189
+ pending: outcome.pending,
190
+ asyncFs: outcome.asyncFs,
191
+ passedOver: outcome.passedOver,
192
+ waitedBehindEarlier: true,
193
+ acquireDeadlineMs,
194
+ asyncFsProbeMs
195
+ });
196
+ }
197
+ }
198
+ const state = {
199
+ pending: /* @__PURE__ */ new Set(),
200
+ abandoned: false,
201
+ mkdirCalls: 0,
202
+ startedAt: Date.now()
203
+ };
204
+ const acquiring = import_proper_lockfile.default.lock(lockPath, {
205
+ stale: LOCK_STALE_MS,
206
+ retries: {
207
+ retries: LOCK_MAX_RETRIES,
208
+ minTimeout: LOCK_RETRY_MS,
209
+ maxTimeout: LOCK_RETRY_MS * 4,
210
+ factor: 1.5,
211
+ // The deadline timer keeps a waiting CLI alive. After the deadline, an
212
+ // abandoned acquire's remaining retries (each refused without a
213
+ // file-system call) must not.
214
+ unref: true
215
+ },
216
+ fs: trackedLockFs(baseFs, state, () => {
217
+ if (state.abandoned && state.pending.size === 0)
218
+ clearBlocker(pathState, state);
219
+ })
220
+ });
221
+ void acquiring.catch(() => void 0);
222
+ let timer;
223
+ const deadline = new Promise((resolve) => {
224
+ timer = setTimeout(() => resolve("deadline"), acquireDeadlineMs);
225
+ });
226
+ let result;
227
+ try {
228
+ result = await Promise.race([acquiring, deadline]);
229
+ } finally {
230
+ clearTimeout(timer);
231
+ }
232
+ if (result !== "deadline")
233
+ return result;
234
+ state.abandoned = true;
235
+ const waitedMs = Date.now() - arrivedAt;
236
+ const pending = describePendingCalls(state.pending, Date.now());
237
+ let asyncFs = null;
238
+ if (state.pending.size > 0) {
239
+ pathState.blockers.add(state);
240
+ asyncFs = await probe();
241
+ passOver(pathState, state, asyncFs.result);
242
+ }
243
+ throw lockAcquireTimeout({
244
+ lockPath,
245
+ daemonId,
246
+ waitedMs,
247
+ queuedMs: state.startedAt - arrivedAt,
248
+ mkdirCalls: state.mkdirCalls,
249
+ pending,
250
+ asyncFs,
251
+ passedOver: pathState.blockers.has(state) ? passedOverCalls(pathState) : null,
252
+ waitedBehindEarlier: false,
253
+ acquireDeadlineMs,
254
+ asyncFsProbeMs
255
+ });
256
+ }
257
+ function clearBlocker(pathState, state) {
258
+ pathState.passedOver.delete(state);
259
+ if (pathState.blockers.delete(state))
260
+ releaseWaitersIfClear(pathState);
261
+ }
262
+ function passOver(pathState, state, asyncFs) {
263
+ if (!pathState.blockers.has(state) || asyncFs === "no_answer")
264
+ return;
265
+ if ([...state.pending].some((call) => CALLS_UNSAFE_TO_OUTLIVE.has(call.op)))
266
+ return;
267
+ if (pathState.passedOver.size >= MAX_PASSED_OVER)
268
+ return;
269
+ pathState.blockers.delete(state);
270
+ pathState.passedOver.add(state);
271
+ releaseWaitersIfClear(pathState);
272
+ }
273
+ function passedOverCalls(pathState) {
274
+ const [held] = pathState.passedOver;
275
+ return held ? describePendingCalls(held.pending, Date.now()) : null;
276
+ }
277
+ function releaseWaitersIfClear(pathState) {
278
+ if (pathState.blockers.size > 0)
279
+ return;
280
+ const waiters = [...pathState.waiters];
281
+ pathState.waiters.clear();
282
+ for (const waiter of waiters)
283
+ waiter.release();
284
+ }
285
+ function waitForBlockers(pathState, deadlineMs, probe) {
286
+ return new Promise((resolve) => {
287
+ const giveUp = async () => {
288
+ const asyncFs = await probe();
289
+ for (const blocker of [...pathState.blockers])
290
+ passOver(pathState, blocker, asyncFs.result);
291
+ if (!pathState.waiters.has(waiter))
292
+ return;
293
+ pathState.waiters.delete(waiter);
294
+ const [oldest] = pathState.blockers;
295
+ resolve({
296
+ pending: describePendingCalls(oldest?.pending ?? /* @__PURE__ */ new Set(), Date.now()),
297
+ asyncFs,
298
+ passedOver: passedOverCalls(pathState)
299
+ });
300
+ };
301
+ const timer = setTimeout(() => void giveUp(), deadlineMs);
302
+ const waiter = {
303
+ release: () => {
304
+ clearTimeout(timer);
305
+ resolve("clear");
306
+ }
307
+ };
308
+ pathState.waiters.add(waiter);
309
+ });
310
+ }
311
+ function formatLockWait(ms) {
312
+ return ms < 1e3 ? `${ms} ms` : `${Math.round(ms / 1e3)} s`;
313
+ }
314
+ function lockAcquireTimeout(options) {
315
+ const { lockPath, daemonId, mkdirCalls, waitedBehindEarlier, asyncFs, passedOver } = options;
316
+ const { calls, text } = options.pending;
317
+ (0, import_runtime.emitAuthTelemetry)({
318
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
319
+ eventType: "auth",
320
+ success: false,
321
+ metadata: {
322
+ event: "refresh_lock_acquire_timeout",
323
+ waitedMs: options.waitedMs,
324
+ queuedMs: options.queuedMs,
325
+ mkdirCalls,
326
+ waitedBehindEarlier,
327
+ pendingFsCalls: calls,
328
+ asyncFsProbe: asyncFs?.result ?? "not_run",
329
+ asyncFsProbeReused: asyncFs ? asyncFs.reusedAfterMs !== null : false,
330
+ passedOverPendingFsCalls: passedOver?.calls ?? [],
331
+ ...daemonId ? { daemonId } : {}
332
+ }
333
+ });
334
+ const lockFile = import_node_path.default.basename(lockPath);
335
+ const probeText = asyncFs ? `; ${asyncFsProbeText(asyncFs, options.asyncFsProbeMs)}` : "";
336
+ const passedOverText = passedOver ? ` An acquire this process already passed over is still waiting on ${passedOver.text}, and no other is passed over while it waits, so new acquires wait until one of these calls answers or the process restarts.` : "";
337
+ const message = waitedBehindEarlier ? `The auth lock (${lockFile}) was not acquired: it waited ${formatLockWait(options.waitedMs)} behind an earlier acquire in this process, which is still waiting on ${text || "no file-system call"}${probeText}.${passedOverText}` : `The auth lock (${lockFile}) was not acquired within ${formatLockWait(options.acquireDeadlineMs)} (${mkdirCalls} mkdir call${mkdirCalls === 1 ? "" : "s"} on the lock directory). Pending file-system calls: ${calls.length ? text : "none (it was between retries)"}${probeText}.${passedOverText}`;
338
+ (0, import_runtime.getAuthLogger)().warn(`[auth/refresh] ${message}`);
339
+ return new import_types.TransientAuthFailure(message);
340
+ }
61
341
  let _exitHandlersInstalled = false;
62
342
  const _authLockHeld = new import_node_async_hooks.AsyncLocalStorage();
63
343
  function authLockPath() {
@@ -140,15 +420,7 @@ async function withAuthLock(body, daemonId) {
140
420
  success: true,
141
421
  metadata: { event: "refresh_lock_acquiring", ...daemonId ? { daemonId } : {} }
142
422
  });
143
- const release = await import_proper_lockfile.default.lock(lockPath, {
144
- stale: LOCK_STALE_MS,
145
- retries: {
146
- retries: LOCK_MAX_RETRIES,
147
- minTimeout: LOCK_RETRY_MS,
148
- maxTimeout: LOCK_RETRY_MS * 4,
149
- factor: 1.5
150
- }
151
- });
423
+ const release = await acquireAuthLock(lockPath, daemonId);
152
424
  const acquiredAt = Date.now();
153
425
  (0, import_runtime.emitAuthTelemetry)({
154
426
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -556,6 +828,7 @@ function clearReauthState() {
556
828
  LOCK_SIGNAL_FALLBACK_EXIT_MS,
557
829
  REAUTH_FLAG_PATH_FN,
558
830
  UNKNOWN_401_BUDGET,
831
+ __authLockTesting,
559
832
  __refreshDiagnostics,
560
833
  __resetUnknown401StreaksForTest,
561
834
  clearReauthState,
@@ -28,6 +28,11 @@ export interface AuthKillSwitches {
28
28
  * refresh_lock_acquired — {daemonId, waitedMs}
29
29
  * refresh_lock_retry — {daemonId, attempt, errorCode}
30
30
  * refresh_lock_released — {daemonId, heldForMs}
31
+ * refresh_lock_acquire_timeout — {daemonId, waitedMs, queuedMs, mkdirCalls,
32
+ * waitedBehindEarlier, pendingFsCalls: [{op, file?,
33
+ * pendingMs}], asyncFsProbe: answered|failed|no_answer|
34
+ * not_run, asyncFsProbeReused: boolean,
35
+ * passedOverPendingFsCalls: [{op, file?, pendingMs}]}
31
36
  * refresh_race_resolved — {daemonId, sourceTokenAdopted: boolean}
32
37
  */
33
38
  export interface AuthTelemetryEvent {
@@ -10,9 +10,23 @@ export declare const MANAGED_WORK_ACP_CAPABILITY: {
10
10
  export declare const MANAGED_WORK_ACP_MANAGER = "managed_work_acp_manager_v1";
11
11
  export declare const MANAGED_WORK_ACP_WORKER = "managed_work_acp_worker_v1";
12
12
  export declare const MANAGED_WORK_ACP_RECORDS = "managed_work_acp_task_records_v1";
13
+ /**
14
+ * The interaction roles in which the model is offered NO tool and answers once: a Task coordinator
15
+ * turn (`task_coordinator`) and a glance at a message beside running work (`chat_glance`). Neither
16
+ * is implied by the manager profile an adapter enforces, so each adapter names the ones it runs
17
+ * (`answerOnlyRoles`). An adapter that does not name a role is refused it by the server and by the
18
+ * daemon, and the caller falls back: a coordinator to the platform's template, a glance to a cloud
19
+ * reply when its owner allowed one, otherwise the message is held until the work ends.
20
+ *
21
+ * The first-party ACP engine names none. Its manager profile is a closed role enum, which in
22
+ * 0.1.0-rc.13 is `main_manager`, `task_reporter` and `task_discussion`, so it rejects both of these
23
+ * before its model runs. Add a role here only with an engine release whose enum holds it.
24
+ */
25
+ export declare const MANAGED_WORK_ANSWER_ONLY_ROLES: readonly ["task_coordinator", "chat_glance"];
26
+ export type ManagedWorkAnswerOnlyRole = (typeof MANAGED_WORK_ANSWER_ONLY_ROLES)[number];
13
27
  export declare function managedWorkAdapter(provider: unknown): {
14
28
  readonly engine: "sdk";
15
- readonly taskCoordinator: true;
29
+ readonly answerOnlyRoles: readonly ["task_coordinator", "chat_glance"];
16
30
  readonly manager: readonly ["native_interaction_profiles_v1", "sdk_pre_tool_use_exact_allowlist"];
17
31
  readonly worker: readonly ["native_task_work_controls_v1", "sdk_pre_tool_use_task_work_controls"];
18
32
  readonly taskRecords: readonly ["native_task_record_applicability_v1", "sdk_pre_tool_use_task_record_applicability"];
@@ -24,7 +38,7 @@ export declare function managedWorkAdapter(provider: unknown): {
24
38
  readonly taskRecords: readonly ["managed_work_acp_task_records_v1", "acp_task_record_applicability"];
25
39
  } | {
26
40
  readonly engine: "app-server";
27
- readonly taskCoordinator: true;
41
+ readonly answerOnlyRoles: readonly ["task_coordinator", "chat_glance"];
28
42
  readonly freshSession: true;
29
43
  readonly toolTransport: "daemon_rpc";
30
44
  readonly manager: readonly ["managed_work_codex_manager_v1", "app_server_scoped_dynamic_tools"];
@@ -32,14 +46,18 @@ export declare function managedWorkAdapter(provider: unknown): {
32
46
  readonly taskRecords: readonly ["managed_work_codex_task_records_v1", "app_server_canonical_task_records"];
33
47
  } | {
34
48
  readonly engine: "rpc";
35
- readonly taskCoordinator: true;
49
+ readonly answerOnlyRoles: readonly ["task_coordinator", "chat_glance"];
36
50
  readonly freshSession: true;
37
51
  readonly toolTransport: "daemon_rpc";
38
52
  readonly manager: readonly ["managed_work_pi_manager_v1", "pi_rpc_exact_tool_scope"];
39
53
  readonly worker: readonly ["managed_work_pi_worker_v1", "pi_rpc_governed_work_tools"];
40
54
  readonly taskRecords: readonly ["managed_work_pi_task_records_v1", "pi_rpc_canonical_task_records"];
41
55
  } | undefined;
56
+ /** Whether this harness can run `role`, one of the answer-only roles, with no tool offered to its model. */
57
+ export declare function managedWorkSupportsAnswerOnlyRole(provider: unknown, role: unknown): boolean;
42
58
  /** Whether this harness can run a Task coordinator turn with no tool offered to its model. */
43
59
  export declare function managedWorkSupportsTaskCoordinator(provider: unknown): boolean;
60
+ /** Whether this harness can run a glance (`chat_glance`) with no tool offered to its model. */
61
+ export declare function managedWorkSupportsChatGlance(provider: unknown): boolean;
44
62
  export declare function managedWorkCapabilities(provider: string): string[];
45
63
  export declare function advertisesManagedWorkAcp(value: unknown, worker: boolean, records: boolean): boolean;
@@ -12,16 +12,22 @@ export const MANAGED_WORK_ACP_MANAGER = 'managed_work_acp_manager_v1';
12
12
  export const MANAGED_WORK_ACP_WORKER = 'managed_work_acp_worker_v1';
13
13
  export const MANAGED_WORK_ACP_RECORDS = 'managed_work_acp_task_records_v1';
14
14
  /**
15
- * `taskCoordinator` marks an adapter that can run a Task coordinator turn: the `task_coordinator`
16
- * interaction role with NO tool offered to the model. An adapter without it is refused the role by
17
- * the server and by the daemon, and the caller sends the platform's template instead. The
18
- * first-party ACP engine accepts a closed list of manager roles that does not hold this one, so it
19
- * stays unmarked until a release of the engine does.
15
+ * The interaction roles in which the model is offered NO tool and answers once: a Task coordinator
16
+ * turn (`task_coordinator`) and a glance at a message beside running work (`chat_glance`). Neither
17
+ * is implied by the manager profile an adapter enforces, so each adapter names the ones it runs
18
+ * (`answerOnlyRoles`). An adapter that does not name a role is refused it by the server and by the
19
+ * daemon, and the caller falls back: a coordinator to the platform's template, a glance to a cloud
20
+ * reply when its owner allowed one, otherwise the message is held until the work ends.
21
+ *
22
+ * The first-party ACP engine names none. Its manager profile is a closed role enum, which in
23
+ * 0.1.0-rc.13 is `main_manager`, `task_reporter` and `task_discussion`, so it rejects both of these
24
+ * before its model runs. Add a role here only with an engine release whose enum holds it.
20
25
  */
26
+ export const MANAGED_WORK_ANSWER_ONLY_ROLES = ['task_coordinator', 'chat_glance'];
21
27
  const adapters = {
22
28
  claude: {
23
29
  engine: 'sdk',
24
- taskCoordinator: true,
30
+ answerOnlyRoles: MANAGED_WORK_ANSWER_ONLY_ROLES,
25
31
  manager: ['native_interaction_profiles_v1', 'sdk_pre_tool_use_exact_allowlist'],
26
32
  worker: ['native_task_work_controls_v1', 'sdk_pre_tool_use_task_work_controls'],
27
33
  taskRecords: [
@@ -38,7 +44,7 @@ const adapters = {
38
44
  },
39
45
  codex: {
40
46
  engine: 'app-server',
41
- taskCoordinator: true,
47
+ answerOnlyRoles: MANAGED_WORK_ANSWER_ONLY_ROLES,
42
48
  freshSession: true,
43
49
  toolTransport: 'daemon_rpc',
44
50
  manager: ['managed_work_codex_manager_v1', 'app_server_scoped_dynamic_tools'],
@@ -47,7 +53,7 @@ const adapters = {
47
53
  },
48
54
  pi: {
49
55
  engine: 'rpc',
50
- taskCoordinator: true,
56
+ answerOnlyRoles: MANAGED_WORK_ANSWER_ONLY_ROLES,
51
57
  freshSession: true,
52
58
  toolTransport: 'daemon_rpc',
53
59
  manager: ['managed_work_pi_manager_v1', 'pi_rpc_exact_tool_scope'],
@@ -63,10 +69,20 @@ export function managedWorkAdapter(provider) {
63
69
  : canonicalHarnessProvider(provider);
64
70
  return Object.hasOwn(adapters, name) ? adapters[name] : undefined;
65
71
  }
72
+ /** Whether this harness can run `role`, one of the answer-only roles, with no tool offered to its model. */
73
+ export function managedWorkSupportsAnswerOnlyRole(provider, role) {
74
+ const adapter = managedWorkAdapter(provider);
75
+ if (!adapter || !('answerOnlyRoles' in adapter))
76
+ return false;
77
+ return adapter.answerOnlyRoles.includes(role);
78
+ }
66
79
  /** Whether this harness can run a Task coordinator turn with no tool offered to its model. */
67
80
  export function managedWorkSupportsTaskCoordinator(provider) {
68
- const adapter = managedWorkAdapter(provider);
69
- return Boolean(adapter && 'taskCoordinator' in adapter);
81
+ return managedWorkSupportsAnswerOnlyRole(provider, 'task_coordinator');
82
+ }
83
+ /** Whether this harness can run a glance (`chat_glance`) with no tool offered to its model. */
84
+ export function managedWorkSupportsChatGlance(provider) {
85
+ return managedWorkSupportsAnswerOnlyRole(provider, 'chat_glance');
70
86
  }
71
87
  export function managedWorkCapabilities(provider) {
72
88
  const adapter = managedWorkAdapter(provider);
@@ -0,0 +1,23 @@
1
+ /**
2
+ * How long an agent's question or approval waits for its person (OSK-33439).
3
+ *
4
+ * ONE number for every place an agent asks a person and waits: a cloud turn's
5
+ * approval and question (the API's `AgentWorker/permissionWindow.js`) and a
6
+ * session that runs natively on the person's machine (the daemon's permissions
7
+ * bridge, `DEFAULT_PERMISSION_TIMEOUT_MS`). Before this the daemon kept its own
8
+ * copy, five minutes, under a comment saying it matched the server. The server
9
+ * had moved to ten minutes on 2026-10-22, so the same person got ten minutes when
10
+ * the agent ran in the cloud and five when it ran on their machine, and nothing
11
+ * on screen said why.
12
+ *
13
+ * Why ten minutes (owner decision 2026-10-22): answers arrive in under a second
14
+ * when someone is there, so the window is for a person who stepped away, and an
15
+ * open ask keeps its turn's spend reserved for as long as it waits. A 72-hour
16
+ * window once left three abandoned cards holding $9.9 of a $10 balance
17
+ * (OSK-17926). Expiry is an answer the run finishes with, not an error.
18
+ *
19
+ * A harness whose own runtime gives up on an ask sooner keeps that shorter bound,
20
+ * because a card that outlives the wait behind it would take an answer nothing
21
+ * reads (the daemon's ACP permission authority, `acp-permission/authority.ts`).
22
+ */
23
+ export declare const PERSON_ASK_WINDOW_MS: number;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * How long an agent's question or approval waits for its person (OSK-33439).
3
+ *
4
+ * ONE number for every place an agent asks a person and waits: a cloud turn's
5
+ * approval and question (the API's `AgentWorker/permissionWindow.js`) and a
6
+ * session that runs natively on the person's machine (the daemon's permissions
7
+ * bridge, `DEFAULT_PERMISSION_TIMEOUT_MS`). Before this the daemon kept its own
8
+ * copy, five minutes, under a comment saying it matched the server. The server
9
+ * had moved to ten minutes on 2026-10-22, so the same person got ten minutes when
10
+ * the agent ran in the cloud and five when it ran on their machine, and nothing
11
+ * on screen said why.
12
+ *
13
+ * Why ten minutes (owner decision 2026-10-22): answers arrive in under a second
14
+ * when someone is there, so the window is for a person who stepped away, and an
15
+ * open ask keeps its turn's spend reserved for as long as it waits. A 72-hour
16
+ * window once left three abandoned cards holding $9.9 of a $10 balance
17
+ * (OSK-17926). Expiry is an answer the run finishes with, not an error.
18
+ *
19
+ * A harness whose own runtime gives up on an ask sooner keeps that shorter bound,
20
+ * because a card that outlives the wait behind it would take an answer nothing
21
+ * reads (the daemon's ACP permission authority, `acp-permission/authority.ts`).
22
+ */
23
+ export const PERSON_ASK_WINDOW_MS = 10 * 60 * 1000;
@@ -1,4 +1,42 @@
1
+ import fs from 'node:fs';
1
2
  import { type ReauthState, type TokenPair } from './types.js';
3
+ interface PendingLockFsCall {
4
+ op: string;
5
+ path?: string;
6
+ startedAt: number;
7
+ }
8
+ interface LockAcquireState {
9
+ /** Callback-style calls proper-lockfile made whose callback has not run. */
10
+ pending: Set<PendingLockFsCall>;
11
+ /** Set when the deadline passes; from then on it makes no file-system call. */
12
+ abandoned: boolean;
13
+ /**
14
+ * mkdir calls of the lock directory: one per retry attempt, plus one more
15
+ * inside an attempt after a stale takeover or a stat that found no directory.
16
+ */
17
+ mkdirCalls: number;
18
+ /** When it started, which is when its deadline started. */
19
+ startedAt: number;
20
+ }
21
+ export declare const __authLockTesting: {
22
+ acquireDeadlineMs: number;
23
+ asyncFsProbeMs: number;
24
+ /**
25
+ * The `fs` proper-lockfile uses: Node's own. Its default, graceful-fs 4.2,
26
+ * retries EMFILE only for open, readFile, writeFile, appendFile, copyFile and
27
+ * readdir, none of which it calls; for realpath, mkdir, stat, utimes and
28
+ * rmdir graceful-fs changes only how `stat` reports a negative uid or gid.
29
+ */
30
+ fs: typeof fs;
31
+ lockPaths: Map<string, {
32
+ blockers: Set<unknown>;
33
+ passedOver: Set<unknown>;
34
+ waiters: Set<unknown>;
35
+ }>;
36
+ probes: Map<string, unknown>;
37
+ /** The wrapper every proper-lockfile call goes through (`trackedLockFs`). */
38
+ trackFs(base: typeof fs, state: LockAcquireState, onPendingChange: () => void): typeof fs;
39
+ };
2
40
  declare function authLockPath(): string;
3
41
  declare function reauthFlagPath(): string;
4
42
  /**
@@ -89,8 +127,9 @@ export interface LockExitHandlerOptions {
89
127
  export declare function installLockExitHandlers(options?: LockExitHandlerOptions): void;
90
128
  /**
91
129
  * Acquire the cross-process auth lock, run the body, release on `finally`.
92
- * Throws if the lock can't be acquired within
93
- * `LOCK_MAX_RETRIES × LOCK_RETRY_MS`.
130
+ * Throws ELOCKED once proper-lockfile's retries are spent (about 19 s), and a
131
+ * `TransientAuthFailure` if the acquire is still pending at
132
+ * `LOCK_ACQUIRE_DEADLINE_MS` (OSK-33422).
94
133
  *
95
134
  * We lock a sentinel file (auth.lock) that we create/touch if missing —
96
135
  * locking the real auth.json would race with atomic-rename writes.