@userreason/cli 0.2.0 → 0.2.1

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.
package/dist/setup.d.ts CHANGED
@@ -55,7 +55,14 @@ export declare function resumeBrowserSetup(origin: string, setupId: string, dire
55
55
  source_review: boolean;
56
56
  sample_read: boolean;
57
57
  } & {
58
+ onboarding_v2?: boolean | undefined;
58
59
  project_name?: string | undefined;
60
+ launcher?: ({
61
+ wizard_version: string;
62
+ api_origin: string;
63
+ } & {
64
+ registry?: string | undefined;
65
+ }) | undefined;
59
66
  terminal?: ({
60
67
  platform: string;
61
68
  app: string;
@@ -128,7 +135,18 @@ export declare function resumeBrowserSetup(origin: string, setupId: string, dire
128
135
  authorized_at: string | null;
129
136
  expires_at: string;
130
137
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
131
- } & {}) | null | undefined;
138
+ } & {
139
+ analysis_id?: string | undefined;
140
+ analysis_started_at?: string | undefined;
141
+ analysis_completed_at?: string | undefined;
142
+ deadline_at?: string | undefined;
143
+ timings?: ({} & {
144
+ extraction_ms?: number | undefined;
145
+ consolidation_ms?: number | undefined;
146
+ authoring_ms?: number | undefined;
147
+ total_ms?: number | undefined;
148
+ }) | undefined;
149
+ }) | null | undefined;
132
150
  recommendation_digest?: string | null | undefined;
133
151
  selected_candidates?: string[] | undefined;
134
152
  };
@@ -145,6 +163,8 @@ export declare class BrowserSetupClient {
145
163
  project_fingerprint: string;
146
164
  expires_at: string;
147
165
  };
166
+ /** Share the same saved capability while binding requests to one run's lifetime. */
167
+ withSignal(signal: AbortSignal): BrowserSetupClient;
148
168
  private call;
149
169
  private scoped;
150
170
  private view;
@@ -169,7 +189,14 @@ export declare class BrowserSetupClient {
169
189
  source_review: boolean;
170
190
  sample_read: boolean;
171
191
  } & {
192
+ onboarding_v2?: boolean | undefined;
172
193
  project_name?: string | undefined;
194
+ launcher?: ({
195
+ wizard_version: string;
196
+ api_origin: string;
197
+ } & {
198
+ registry?: string | undefined;
199
+ }) | undefined;
173
200
  terminal?: ({
174
201
  platform: string;
175
202
  app: string;
@@ -242,7 +269,18 @@ export declare class BrowserSetupClient {
242
269
  authorized_at: string | null;
243
270
  expires_at: string;
244
271
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
245
- } & {}) | null | undefined;
272
+ } & {
273
+ analysis_id?: string | undefined;
274
+ analysis_started_at?: string | undefined;
275
+ analysis_completed_at?: string | undefined;
276
+ deadline_at?: string | undefined;
277
+ timings?: ({} & {
278
+ extraction_ms?: number | undefined;
279
+ consolidation_ms?: number | undefined;
280
+ authoring_ms?: number | undefined;
281
+ total_ms?: number | undefined;
282
+ }) | undefined;
283
+ }) | null | undefined;
246
284
  recommendation_digest?: string | null | undefined;
247
285
  selected_candidates?: string[] | undefined;
248
286
  }>;
@@ -279,7 +317,14 @@ export declare class BrowserSetupClient {
279
317
  source_review: boolean;
280
318
  sample_read: boolean;
281
319
  } & {
320
+ onboarding_v2?: boolean | undefined;
282
321
  project_name?: string | undefined;
322
+ launcher?: ({
323
+ wizard_version: string;
324
+ api_origin: string;
325
+ } & {
326
+ registry?: string | undefined;
327
+ }) | undefined;
283
328
  terminal?: ({
284
329
  platform: string;
285
330
  app: string;
@@ -352,7 +397,18 @@ export declare class BrowserSetupClient {
352
397
  authorized_at: string | null;
353
398
  expires_at: string;
354
399
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
355
- } & {}) | null | undefined;
400
+ } & {
401
+ analysis_id?: string | undefined;
402
+ analysis_started_at?: string | undefined;
403
+ analysis_completed_at?: string | undefined;
404
+ deadline_at?: string | undefined;
405
+ timings?: ({} & {
406
+ extraction_ms?: number | undefined;
407
+ consolidation_ms?: number | undefined;
408
+ authoring_ms?: number | undefined;
409
+ total_ms?: number | undefined;
410
+ }) | undefined;
411
+ }) | null | undefined;
356
412
  recommendation_digest?: string | null | undefined;
357
413
  selected_candidates?: string[] | undefined;
358
414
  };
@@ -419,7 +475,14 @@ export declare class BrowserSetupClient {
419
475
  source_review: boolean;
420
476
  sample_read: boolean;
421
477
  } & {
478
+ onboarding_v2?: boolean | undefined;
422
479
  project_name?: string | undefined;
480
+ launcher?: ({
481
+ wizard_version: string;
482
+ api_origin: string;
483
+ } & {
484
+ registry?: string | undefined;
485
+ }) | undefined;
423
486
  terminal?: ({
424
487
  platform: string;
425
488
  app: string;
@@ -492,7 +555,18 @@ export declare class BrowserSetupClient {
492
555
  authorized_at: string | null;
493
556
  expires_at: string;
494
557
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
495
- } & {}) | null | undefined;
558
+ } & {
559
+ analysis_id?: string | undefined;
560
+ analysis_started_at?: string | undefined;
561
+ analysis_completed_at?: string | undefined;
562
+ deadline_at?: string | undefined;
563
+ timings?: ({} & {
564
+ extraction_ms?: number | undefined;
565
+ consolidation_ms?: number | undefined;
566
+ authoring_ms?: number | undefined;
567
+ total_ms?: number | undefined;
568
+ }) | undefined;
569
+ }) | null | undefined;
496
570
  recommendation_digest?: string | null | undefined;
497
571
  selected_candidates?: string[] | undefined;
498
572
  }>;
@@ -517,7 +591,14 @@ export declare class BrowserSetupClient {
517
591
  source_review: boolean;
518
592
  sample_read: boolean;
519
593
  } & {
594
+ onboarding_v2?: boolean | undefined;
520
595
  project_name?: string | undefined;
596
+ launcher?: ({
597
+ wizard_version: string;
598
+ api_origin: string;
599
+ } & {
600
+ registry?: string | undefined;
601
+ }) | undefined;
521
602
  terminal?: ({
522
603
  platform: string;
523
604
  app: string;
@@ -590,7 +671,18 @@ export declare class BrowserSetupClient {
590
671
  authorized_at: string | null;
591
672
  expires_at: string;
592
673
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
593
- } & {}) | null | undefined;
674
+ } & {
675
+ analysis_id?: string | undefined;
676
+ analysis_started_at?: string | undefined;
677
+ analysis_completed_at?: string | undefined;
678
+ deadline_at?: string | undefined;
679
+ timings?: ({} & {
680
+ extraction_ms?: number | undefined;
681
+ consolidation_ms?: number | undefined;
682
+ authoring_ms?: number | undefined;
683
+ total_ms?: number | undefined;
684
+ }) | undefined;
685
+ }) | null | undefined;
594
686
  recommendation_digest?: string | null | undefined;
595
687
  selected_candidates?: string[] | undefined;
596
688
  }>;
@@ -615,7 +707,14 @@ export declare class BrowserSetupClient {
615
707
  source_review: boolean;
616
708
  sample_read: boolean;
617
709
  } & {
710
+ onboarding_v2?: boolean | undefined;
618
711
  project_name?: string | undefined;
712
+ launcher?: ({
713
+ wizard_version: string;
714
+ api_origin: string;
715
+ } & {
716
+ registry?: string | undefined;
717
+ }) | undefined;
619
718
  terminal?: ({
620
719
  platform: string;
621
720
  app: string;
@@ -688,7 +787,18 @@ export declare class BrowserSetupClient {
688
787
  authorized_at: string | null;
689
788
  expires_at: string;
690
789
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
691
- } & {}) | null | undefined;
790
+ } & {
791
+ analysis_id?: string | undefined;
792
+ analysis_started_at?: string | undefined;
793
+ analysis_completed_at?: string | undefined;
794
+ deadline_at?: string | undefined;
795
+ timings?: ({} & {
796
+ extraction_ms?: number | undefined;
797
+ consolidation_ms?: number | undefined;
798
+ authoring_ms?: number | undefined;
799
+ total_ms?: number | undefined;
800
+ }) | undefined;
801
+ }) | null | undefined;
692
802
  recommendation_digest?: string | null | undefined;
693
803
  selected_candidates?: string[] | undefined;
694
804
  }>;
@@ -738,7 +848,14 @@ export declare class BrowserSetupClient {
738
848
  source_review: boolean;
739
849
  sample_read: boolean;
740
850
  } & {
851
+ onboarding_v2?: boolean | undefined;
741
852
  project_name?: string | undefined;
853
+ launcher?: ({
854
+ wizard_version: string;
855
+ api_origin: string;
856
+ } & {
857
+ registry?: string | undefined;
858
+ }) | undefined;
742
859
  terminal?: ({
743
860
  platform: string;
744
861
  app: string;
@@ -811,7 +928,18 @@ export declare class BrowserSetupClient {
811
928
  authorized_at: string | null;
812
929
  expires_at: string;
813
930
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
814
- } & {}) | null | undefined;
931
+ } & {
932
+ analysis_id?: string | undefined;
933
+ analysis_started_at?: string | undefined;
934
+ analysis_completed_at?: string | undefined;
935
+ deadline_at?: string | undefined;
936
+ timings?: ({} & {
937
+ extraction_ms?: number | undefined;
938
+ consolidation_ms?: number | undefined;
939
+ authoring_ms?: number | undefined;
940
+ total_ms?: number | undefined;
941
+ }) | undefined;
942
+ }) | null | undefined;
815
943
  recommendation_digest?: string | null | undefined;
816
944
  selected_candidates?: string[] | undefined;
817
945
  };
@@ -837,7 +965,14 @@ export declare class BrowserSetupClient {
837
965
  source_review: boolean;
838
966
  sample_read: boolean;
839
967
  } & {
968
+ onboarding_v2?: boolean | undefined;
840
969
  project_name?: string | undefined;
970
+ launcher?: ({
971
+ wizard_version: string;
972
+ api_origin: string;
973
+ } & {
974
+ registry?: string | undefined;
975
+ }) | undefined;
841
976
  terminal?: ({
842
977
  platform: string;
843
978
  app: string;
@@ -910,7 +1045,18 @@ export declare class BrowserSetupClient {
910
1045
  authorized_at: string | null;
911
1046
  expires_at: string;
912
1047
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
913
- } & {}) | null | undefined;
1048
+ } & {
1049
+ analysis_id?: string | undefined;
1050
+ analysis_started_at?: string | undefined;
1051
+ analysis_completed_at?: string | undefined;
1052
+ deadline_at?: string | undefined;
1053
+ timings?: ({} & {
1054
+ extraction_ms?: number | undefined;
1055
+ consolidation_ms?: number | undefined;
1056
+ authoring_ms?: number | undefined;
1057
+ total_ms?: number | undefined;
1058
+ }) | undefined;
1059
+ }) | null | undefined;
914
1060
  recommendation_digest?: string | null | undefined;
915
1061
  selected_candidates?: string[] | undefined;
916
1062
  }>;
@@ -935,7 +1081,14 @@ export declare class BrowserSetupClient {
935
1081
  source_review: boolean;
936
1082
  sample_read: boolean;
937
1083
  } & {
1084
+ onboarding_v2?: boolean | undefined;
938
1085
  project_name?: string | undefined;
1086
+ launcher?: ({
1087
+ wizard_version: string;
1088
+ api_origin: string;
1089
+ } & {
1090
+ registry?: string | undefined;
1091
+ }) | undefined;
939
1092
  terminal?: ({
940
1093
  platform: string;
941
1094
  app: string;
@@ -1008,7 +1161,18 @@ export declare class BrowserSetupClient {
1008
1161
  authorized_at: string | null;
1009
1162
  expires_at: string;
1010
1163
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
1011
- } & {}) | null | undefined;
1164
+ } & {
1165
+ analysis_id?: string | undefined;
1166
+ analysis_started_at?: string | undefined;
1167
+ analysis_completed_at?: string | undefined;
1168
+ deadline_at?: string | undefined;
1169
+ timings?: ({} & {
1170
+ extraction_ms?: number | undefined;
1171
+ consolidation_ms?: number | undefined;
1172
+ authoring_ms?: number | undefined;
1173
+ total_ms?: number | undefined;
1174
+ }) | undefined;
1175
+ }) | null | undefined;
1012
1176
  recommendation_digest?: string | null | undefined;
1013
1177
  selected_candidates?: string[] | undefined;
1014
1178
  }>;
@@ -1033,7 +1197,14 @@ export declare class BrowserSetupClient {
1033
1197
  source_review: boolean;
1034
1198
  sample_read: boolean;
1035
1199
  } & {
1200
+ onboarding_v2?: boolean | undefined;
1036
1201
  project_name?: string | undefined;
1202
+ launcher?: ({
1203
+ wizard_version: string;
1204
+ api_origin: string;
1205
+ } & {
1206
+ registry?: string | undefined;
1207
+ }) | undefined;
1037
1208
  terminal?: ({
1038
1209
  platform: string;
1039
1210
  app: string;
@@ -1106,7 +1277,18 @@ export declare class BrowserSetupClient {
1106
1277
  authorized_at: string | null;
1107
1278
  expires_at: string;
1108
1279
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
1109
- } & {}) | null | undefined;
1280
+ } & {
1281
+ analysis_id?: string | undefined;
1282
+ analysis_started_at?: string | undefined;
1283
+ analysis_completed_at?: string | undefined;
1284
+ deadline_at?: string | undefined;
1285
+ timings?: ({} & {
1286
+ extraction_ms?: number | undefined;
1287
+ consolidation_ms?: number | undefined;
1288
+ authoring_ms?: number | undefined;
1289
+ total_ms?: number | undefined;
1290
+ }) | undefined;
1291
+ }) | null | undefined;
1110
1292
  recommendation_digest?: string | null | undefined;
1111
1293
  selected_candidates?: string[] | undefined;
1112
1294
  }>;
@@ -1131,7 +1313,14 @@ export declare class BrowserSetupClient {
1131
1313
  source_review: boolean;
1132
1314
  sample_read: boolean;
1133
1315
  } & {
1316
+ onboarding_v2?: boolean | undefined;
1134
1317
  project_name?: string | undefined;
1318
+ launcher?: ({
1319
+ wizard_version: string;
1320
+ api_origin: string;
1321
+ } & {
1322
+ registry?: string | undefined;
1323
+ }) | undefined;
1135
1324
  terminal?: ({
1136
1325
  platform: string;
1137
1326
  app: string;
@@ -1204,7 +1393,18 @@ export declare class BrowserSetupClient {
1204
1393
  authorized_at: string | null;
1205
1394
  expires_at: string;
1206
1395
  error_code: "operation_failed" | "planning_unavailable" | "planning_paused" | "planning_daily_budget" | "planning_allowance_exhausted" | "planning_provider_unavailable" | "planning_policy_changed" | "planning_consent_expired" | "planning_input_budget" | "planning_invalid_output" | "planning_timeout" | "source_changed" | "source_unavailable" | "recommendations_no_source" | null;
1207
- } & {}) | null | undefined;
1396
+ } & {
1397
+ analysis_id?: string | undefined;
1398
+ analysis_started_at?: string | undefined;
1399
+ analysis_completed_at?: string | undefined;
1400
+ deadline_at?: string | undefined;
1401
+ timings?: ({} & {
1402
+ extraction_ms?: number | undefined;
1403
+ consolidation_ms?: number | undefined;
1404
+ authoring_ms?: number | undefined;
1405
+ total_ms?: number | undefined;
1406
+ }) | undefined;
1407
+ }) | null | undefined;
1208
1408
  recommendation_digest?: string | null | undefined;
1209
1409
  selected_candidates?: string[] | undefined;
1210
1410
  }>;
package/dist/setup.js CHANGED
@@ -67,7 +67,7 @@ async function request(origin, operation, body, token, options, retries = 0) {
67
67
  if (!['discovery', 'start', 'exchange', 'poll', 'plan', 'claim', 'start-command', 'report', 'heartbeat', 'reconcile', 'sample-read', 'source-info', 'source-plan', 'source-upload'].includes(operation))
68
68
  throw new SetupError('invalid_setup_operation', 'Unsupported setup operation.');
69
69
  const encoded = body === undefined ? undefined : JSON.stringify(body);
70
- if (encoded && Buffer.byteLength(encoded) > 65_536)
70
+ if (encoded && Buffer.byteLength(encoded) > (operation === 'source-upload' ? 300000 : 65_536))
71
71
  throw new SetupError('setup_request_too_large', 'Setup request exceeds 64 KiB.');
72
72
  const url = `${apiUrl(origin)}${operation === 'discovery' ? '/onboarding/v1/auth-config?setup=1' : `/onboarding/v1/setup/${operation}`}`;
73
73
  // Preference reads are optional and bounded. Any read failure suppresses
@@ -81,7 +81,7 @@ async function request(origin, operation, body, token, options, retries = 0) {
81
81
  method: encoded === undefined ? 'GET' : 'POST', redirect: 'error',
82
82
  headers: { Accept: 'application/json', ...(encoded === undefined ? {} : { 'Content-Type': 'application/json' }), ...(token ? { Authorization: `Bearer ${token}` } : {}), ...(measurementDisabled ? { 'x-ur-measurement-disabled': '1' } : {}) },
83
83
  ...(encoded === undefined ? {} : { body: encoded }),
84
- signal: AbortSignal.any([AbortSignal.timeout(operation === 'source-upload' ? 50_000 : 10_000), ...(options.signal ? [options.signal] : [])]),
84
+ signal: AbortSignal.any([AbortSignal.timeout(operation === 'source-upload' ? 250_000 : 10_000), ...(options.signal ? [options.signal] : [])]),
85
85
  });
86
86
  }
87
87
  catch (error) {
@@ -181,7 +181,9 @@ async function finishBrowserSetup(pending, options) {
181
181
  throw new SetupError('invalid_setup_response', 'The approved setup response does not match this project or active session.');
182
182
  const connected = { schema_version: 1, state: 'connected', setup_id: pending.setup_id, api_url: pending.api_url, project_fingerprint: pending.project_fingerprint, created_at: new Date(now()).toISOString(), expires_at: result.expires_at, access_token: result.access_token };
183
183
  await saveSetupSession(connected);
184
- return { client: new BrowserSetupClient(connected, options), session: result.session };
184
+ const client = new BrowserSetupClient(connected, options);
185
+ const session = await client.heartbeat({ schema_version: 1, setup_id: connected.setup_id, executor_generation: result.session.executor_generation, operation_id: null, lease_generation: null });
186
+ return { client, session };
185
187
  }
186
188
  options.onProgress?.('waiting');
187
189
  await delay(Math.max(0, Math.min(2_000, deadline - now())), options);
@@ -193,7 +195,9 @@ export async function resumeBrowserSetup(origin, setupId, directory, options = {
193
195
  if (saved.state === 'pending')
194
196
  return finishBrowserSetup(saved, options);
195
197
  const client = new BrowserSetupClient(saved, options);
196
- return { client, session: await client.poll() };
198
+ const current = await client.poll();
199
+ const session = terminal.has(current.phase) ? current : await client.heartbeat({ schema_version: 1, setup_id: saved.setup_id, executor_generation: current.executor_generation, operation_id: null, lease_generation: null });
200
+ return { client, session };
197
201
  }
198
202
  export class BrowserSetupClient {
199
203
  #stored;
@@ -207,6 +211,8 @@ export class BrowserSetupClient {
207
211
  }
208
212
  /** Nonsecret identity for the local executor journal; never exposes the bearer. */
209
213
  get identity() { const { setup_id, api_url, project_fingerprint, expires_at } = this.#stored; return { setup_id, api_url, project_fingerprint, expires_at }; }
214
+ /** Share the same saved capability while binding requests to one run's lifetime. */
215
+ withSignal(signal) { return new BrowserSetupClient(this.#stored, { ...this.#options, signal: AbortSignal.any([signal, ...(this.#options.signal ? [this.#options.signal] : [])]) }); }
210
216
  async call(operation, body, retries = 0) {
211
217
  if (Date.parse(this.#stored.expires_at) <= (this.#options.now ?? Date.now)())
212
218
  throw new SetupError('setup_expired', 'Setup access expired. Start a new setup; it cannot be refreshed into ordinary CLI access.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@userreason/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Authenticated UserReason onboarding and management CLI",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",