@parall/cli 1.62.0 → 1.64.0

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.
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ export declare function browserHelp(action?: string): string;
3
+ export declare function registerBrowserCommands(program: Command): void;
4
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/commands/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAuCnD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyC9D"}
@@ -0,0 +1,80 @@
1
+ import { BROWSER_USE_ACTIONS, BROWSER_USE_ACTION_SCHEMAS, BrowserUseValidationError, } from '@parall/sdk';
2
+ import { resolveCredentials } from '../lib/client.js';
3
+ import { parseBrowserCommand } from '../lib/browser-arguments.js';
4
+ import { browserError, renderBrowserOutcome, runBrowserOperation, } from '../lib/browser-operation.js';
5
+ export function browserHelp(action) {
6
+ const actions = action && Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, action)
7
+ ? BROWSER_USE_ACTIONS.filter((a) => a === action)
8
+ : BROWSER_USE_ACTIONS;
9
+ return [
10
+ 'Usage: parall browser <action> [options] [--json]',
11
+ 'Read or operate a webpage with an authorized Browser Profile. To run a published Clip, use parall clip exec.',
12
+ 'Start with: parall browser profiles --json. Choose the intended account; use its ID with --profile.',
13
+ 'Hosted: $0.01 per definitively executed operation (including tabs/reads). BYOC is free.',
14
+ "Use the fewest actions within the user's budget. profiles and operation get are free.",
15
+ 'profiles [--profile <ebp_id>] Find accessible BYOC/cloud accounts; access does not guarantee website login or permission for every action.',
16
+ 'operation get <buo_id> --profile <ebp_id> Check an existing operation without running it again. accepted/started means keep checking.',
17
+ 'PROFILE_NOT_ALLOWED: ask an org admin for Profile access. BROWSER_USE_DISABLED: ask them to enable Browser Use.',
18
+ 'UNKNOWN_OUTCOME / OUTCOME_UNKNOWN: do not retry. Check the original operation with operation get; without an operation ID, retain the request ID and ask a person to inspect the page.',
19
+ 'Open a page: parall browser open --url https://example.com --profile <ebp_id> --json',
20
+ 'Read its title from the successful result. To read it again, copy data.tab_id and data.browser_generation into:',
21
+ 'parall browser get --prop title --profile <ebp_id> --tab <btab_id> --browser-generation <n> --json',
22
+ 'Keep the page for the user by leaving it open. Result-cache expiry is not page closure; do not promise a retention time.',
23
+ 'Action syntax (use returned target values; there is no default account or page):',
24
+ ...actions.map((a) => {
25
+ const schema = BROWSER_USE_ACTION_SCHEMAS[a];
26
+ const params = Object.keys(schema.params.properties).flatMap((k) => k === 'viewport'
27
+ ? ['[--width <n> --height <n>]']
28
+ : [
29
+ `${schema.params.required.includes(k) ? '' : '['}--${k.replaceAll('_', '-')} <value>${schema.params.required.includes(k) ? '' : ']'}`,
30
+ ]);
31
+ return `${a} --profile <ebp_id> ${schema.target === 'none' ? '' : schema.target === 'optional_tab' ? '[--tab <btab_id> --browser-generation <n>]' : '--tab <btab_id> --browser-generation <n>'} ${params.join(' ')}`;
32
+ }),
33
+ 'Use --selector or complete --document-generation <n> --snapshot-id <bsn_id> --ref <ref>; never both.',
34
+ 'read: exactly one of --url or a tab target. get: --prop title/url need no locator; text/html/value/attr require one; attr also needs --name.',
35
+ 'wait: --selector, or --state load (no selector). Boolean values are explicit true/false.',
36
+ 'open <url> and eval <javascript> also accept positional values. eval is bounded, not streaming.',
37
+ '--json prints the result on stdout or the error and next step on stderr. Save the operation ID for later checks.',
38
+ 'read --url uses a temporary page that closes after reading; use open to keep a page for the user.',
39
+ 'Decode screenshot PNG base64 into a file before viewing it. Expired result data cannot be recovered by checking again; do not rerun an action to recover old data.',
40
+ ].join('\n');
41
+ }
42
+ export function registerBrowserCommands(program) {
43
+ program
44
+ .command('browser')
45
+ .description('Use an explicit Browser Profile without publishing a Clip')
46
+ .helpOption(false)
47
+ .allowUnknownOption(true)
48
+ .allowExcessArguments(true)
49
+ .argument('[args...]')
50
+ .action(async (_args, _opts, command) => {
51
+ const args = command.args;
52
+ if (!args.length || args.includes('--help') || args.includes('-h')) {
53
+ console.log(browserHelp(args[0]));
54
+ return;
55
+ }
56
+ let json = args.includes('--json');
57
+ try {
58
+ const parsed = parseBrowserCommand(args);
59
+ json = parsed.json;
60
+ if (!process.env.PRLL_API_URL || !process.env.PRLL_API_KEY || !process.env.PRLL_ORG_ID)
61
+ throw new BrowserUseValidationError('Set PRLL_API_URL, PRLL_API_KEY, and PRLL_ORG_ID.', 'AUTH_REQUIRED');
62
+ const { client, orgId } = resolveCredentials();
63
+ if (parsed.kind === 'profiles') {
64
+ const response = await client.listBrowserUseProfiles(orgId, parsed.profileId);
65
+ if (json)
66
+ console.log(JSON.stringify({ ok: true, ...response }));
67
+ else if (!response.data.length)
68
+ console.log('No accessible Browser Profiles. Ask an org admin to grant access.');
69
+ else
70
+ for (const row of response.data)
71
+ console.log(`${row.profile_id} ${row.device_name} / ${row.name} ${row.placement} accessible ${row.lifecycle_state} ${row.availability}`);
72
+ return;
73
+ }
74
+ renderBrowserOutcome(await runBrowserOperation(client, orgId, parsed), json);
75
+ }
76
+ catch (err) {
77
+ renderBrowserOutcome(browserError(err), json);
78
+ }
79
+ });
80
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerClipConnectionCommands(clip: Command): void;
3
+ //# sourceMappingURL=clip-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip-connection.d.ts","sourceRoot":"","sources":["../../src/commands/clip-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAgC5C,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAsClE"}
@@ -0,0 +1,59 @@
1
+ import { Option } from 'commander';
2
+ import { ApiError } from '@parall/sdk';
3
+ import { resolveCredentials } from '../lib/client.js';
4
+ import { printError, printJson } from '../lib/output.js';
5
+ async function resolveConnection(client, orgId, ref) {
6
+ if (ref.startsWith('ccn_'))
7
+ return ref;
8
+ const clips = await client.listInstalledRegistryClips(orgId);
9
+ const matches = new Set();
10
+ // Aliases are unique within a clip, not the org. Read every visible list
11
+ // before writing; a failed list cannot establish an unambiguous match.
12
+ for (const clip of clips) {
13
+ const { data } = await client.listClipConnections(orgId, clip.id);
14
+ for (const connection of data ?? []) {
15
+ if (connection.alias === ref)
16
+ matches.add(connection.id);
17
+ }
18
+ }
19
+ if (matches.size === 0) {
20
+ throw new ApiError(404, 'connection not found', 'CONNECTION_NOT_FOUND');
21
+ }
22
+ if (matches.size > 1) {
23
+ throw new Error(`Connection alias "${ref}" is ambiguous. Use a ccn_ id: ${[...matches].join(', ')}`);
24
+ }
25
+ return [...matches][0];
26
+ }
27
+ export function registerClipConnectionCommands(clip) {
28
+ let makePublic = false;
29
+ let makePrivate = false;
30
+ clip
31
+ .command('connection')
32
+ .description('Manage a clip connection')
33
+ .command('share')
34
+ .description('Set organization-public access (human org owner/admin; personal key supported). When public, all humans and agents in this organization can use the connection regardless of the clip access list.')
35
+ .argument('<connection>', 'Connection ccn_ id (ccn_ prefix always means ID), or unique alias across installed clips')
36
+ .addOption(new Option('--public', 'Make the connection public to the organization'))
37
+ .addOption(new Option('--no-public', 'Stop public access; the clip access list applies'))
38
+ .on('option:public', () => {
39
+ makePublic = true;
40
+ })
41
+ .on('option:no-public', () => {
42
+ makePrivate = true;
43
+ })
44
+ .action(async (ref, opts) => {
45
+ try {
46
+ // Both spellings share Commander's public attribute. Track explicit
47
+ // occurrences so neither missing flags nor conflicting flags can write.
48
+ if (makePublic === makePrivate) {
49
+ throw new Error('Specify exactly one of --public or --no-public');
50
+ }
51
+ const { client, orgId } = resolveCredentials();
52
+ const connId = await resolveConnection(client, orgId, ref);
53
+ printJson(await client.putClipConnectionAccess(orgId, connId, { org_public: opts.public }));
54
+ }
55
+ catch (err) {
56
+ printError(err);
57
+ }
58
+ });
59
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../src/commands/clip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqMpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QA+iBpD"}
1
+ {"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../src/commands/clip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsMpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAkjBpD"}
@@ -1,3 +1,4 @@
1
+ import { registerClipConnectionCommands } from './clip-connection.js';
1
2
  import { resolveCredentials } from '../lib/client.js';
2
3
  import { execEdgeClipWithBoundedWait } from '../lib/edge-exec.js';
3
4
  import { getClipMCPConfigById, listClipMCPConnectionSummaries } from '../lib/mcp-connections.js';
@@ -146,6 +147,7 @@ export function registerClipCommands(program) {
146
147
  const clip = program
147
148
  .command('clip')
148
149
  .description('Discover, install and execute clips installed in the organization');
150
+ registerClipConnectionCommands(clip);
149
151
  clip
150
152
  .command('list')
151
153
  .description('List clips installed in the organization, each with its connections — the --connection refs `clip exec` takes')
@@ -339,7 +341,7 @@ export function registerClipCommands(program) {
339
341
  });
340
342
  clip
341
343
  .command('connections')
342
- .description("List a clip's connections in full — each row's ccn_ id or alias is what `clip exec --connection` takes")
344
+ .description("List the connections of a clip you can SEE, in full — each row's ccn_ id or alias is what `clip exec --connection` takes. org_public reports whether everyone in the organization can use the connection regardless of the clip access list. Members see public org-layer rows and those the clip's access list admits them to plus their own personal-device rows; an org admin sees the whole org layer as a management view, which does not by itself mean the admin may exec through every row (non-public rows still follow the access list)")
343
345
  .argument('<clip>', 'Registry clip id (crg_...) or name')
344
346
  .action(async (clip) => {
345
347
  try {
@@ -377,6 +379,7 @@ export function registerClipCommands(program) {
377
379
  const mcp = mcpByConnection.get(c.id);
378
380
  return {
379
381
  ...c,
382
+ org_public: c.org_public ?? false,
380
383
  ...connectionAnnotations(c, deviceById),
381
384
  ...(mcp
382
385
  ? {
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5C,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GACtD;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CASzC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QAuUvD"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5C,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GACtD;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CASzC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QAqUvD"}
@@ -194,15 +194,9 @@ export function registerMessageCommands(program) {
194
194
  req.thread_root_id = threadRootId;
195
195
  if (opts.reply === false)
196
196
  req.hints = { no_reply: true };
197
- // Dispatch lane binding (PRLL_CONTEXT_DIR contract): a send whose
198
- // exact (chat, thread) target has an active lane context rides the
199
- // server's dispatch ledger — the lane token authorizes the write,
200
- // and the FIRST conversational reply of the lane carries the
201
- // reply:<dispatch_event_id> effect key so it resolves the dispatched
202
- // work in the same transaction. Later sends in the same turn (and
203
- // cross-chat sends, which find no lane context) use a random
204
- // per-invocation idempotency key. All of this stays out of the
205
- // model's view.
197
+ // Receipt-mode sends have their own operation identity. Legacy
198
+ // lanes retain the first-reply Effect contract; subsequent sends
199
+ // use an independent key, reused by the SDK's HTTP retries.
206
200
  const laneCtx = resolveLaneDispatchContext(chatId, threadRootId);
207
201
  const attribution = resolveSendAttribution(ctx, laneCtx);
208
202
  if (attribution.stepId)
@@ -212,7 +206,9 @@ export function registerMessageCommands(program) {
212
206
  let usedReplyKey = false;
213
207
  if (laneCtx) {
214
208
  req.dispatch_lane = laneCtx.lane;
215
- if (laneCtx.dispatchEventId && !laneCtx.replyCommitted) {
209
+ if (laneCtx.settlementMode !== 'receipt' &&
210
+ laneCtx.dispatchEventId &&
211
+ !laneCtx.replyCommitted) {
216
212
  req.idempotency_key = `reply:${laneCtx.dispatchEventId}`;
217
213
  usedReplyKey = true;
218
214
  }
@@ -1 +1 @@
1
- {"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../src/commands/triggers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EAIlB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,KAAK,wBAAwB,GAAG;IAC9B,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC,MAA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sDF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAM1F;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAKf;AAQD,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAKvF;AAED,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,iBAAiB,EAC7B,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqBtD;AAkBD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QAsdvD"}
@@ -3,6 +3,7 @@ import { resolveCredentials } from '../lib/client.js';
3
3
  import { printError, printJson, printRefHint, stripPrllScheme } from '../lib/output.js';
4
4
  const connectionStatuses = ['active', 'disabled'];
5
5
  const triggerStatuses = ['active', 'paused'];
6
+ const triggerSourceKinds = ['webhook', 'platform_event'];
6
7
  export const TRIGGERS_FLAG = 'external-triggers';
7
8
  function stripUndefined(obj) {
8
9
  return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
@@ -233,10 +234,26 @@ export function registerTriggerCommands(program) {
233
234
  printError(err);
234
235
  }
235
236
  });
237
+ triggers
238
+ .command('platform-schema')
239
+ .description('Inspect subscribable platform event types and their CEL/template variables')
240
+ .option('--event-types <types>', 'Comma-separated event types to describe (default: all)')
241
+ .action(async (opts) => {
242
+ try {
243
+ const { client, orgId } = await resolveTriggerCommandContext();
244
+ const eventTypes = opts.eventTypes ? parseIds(opts.eventTypes, '--event-types') : undefined;
245
+ const result = await client.getPlatformTriggerSchema(orgId, eventTypes);
246
+ printJson(result);
247
+ }
248
+ catch (err) {
249
+ printError(err);
250
+ }
251
+ });
236
252
  triggers
237
253
  .command('list')
238
254
  .description('List Triggers in the organization')
239
255
  .option('--connection <connectionId>', 'Filter by Trigger Connection ID')
256
+ .option('--source-kind <kind>', 'Filter by source kind: webhook | platform_event')
240
257
  .option('--creator-id <id>', 'Filter by creator user ID')
241
258
  .option('--limit <n>', 'Maximum number of triggers to return', '50')
242
259
  .option('--cursor <cursor>', 'Pagination cursor')
@@ -245,6 +262,7 @@ export function registerTriggerCommands(program) {
245
262
  const { client, orgId } = await resolveTriggerCommandContext();
246
263
  const result = await client.listTriggers(orgId, stripUndefined({
247
264
  connection_id: opts.connection ? stripPrllScheme(opts.connection) : undefined,
265
+ source_kind: parseEnum(opts.sourceKind, triggerSourceKinds, '--source-kind'),
248
266
  creator_id: opts.creatorId ? stripPrllScheme(opts.creatorId) : undefined,
249
267
  limit: parsePositiveInt(opts.limit, '--limit'),
250
268
  cursor: opts.cursor,
@@ -258,7 +276,9 @@ export function registerTriggerCommands(program) {
258
276
  triggers
259
277
  .command('create')
260
278
  .description('Create a Trigger targeting one or more agents')
261
- .requiredOption('--connection <connectionId>', 'Trigger Connection ID')
279
+ .option('--connection <connectionId>', 'Trigger Connection ID (webhook triggers)')
280
+ .option('--source-kind <kind>', 'webhook | platform_event (default: webhook)')
281
+ .option('--event-types <types>', 'Comma-separated platform event types to subscribe to (platform_event triggers; see platform-schema)')
262
282
  .requiredOption('--name <name>', 'Trigger name')
263
283
  .requiredOption('--target-ids <ids>', 'Comma-separated target agent user IDs')
264
284
  .option('--description <text>', 'Human-facing trigger description')
@@ -274,8 +294,27 @@ export function registerTriggerCommands(program) {
274
294
  try {
275
295
  const { client, orgId } = await resolveTriggerCommandContext();
276
296
  const agentInputTemplate = await resolveTemplate({ ...opts, required: true });
297
+ const sourceKind = parseEnum(opts.sourceKind, triggerSourceKinds, '--source-kind') ??
298
+ 'webhook';
299
+ if (sourceKind === 'webhook' && !opts.connection) {
300
+ throw new Error('--connection is required for webhook triggers');
301
+ }
302
+ if (sourceKind === 'platform_event' && !opts.eventTypes) {
303
+ throw new Error('--event-types is required for platform_event triggers');
304
+ }
305
+ if (sourceKind === 'webhook' && opts.eventTypes) {
306
+ throw new Error('--event-types only applies to platform_event triggers');
307
+ }
308
+ if (sourceKind === 'platform_event' && opts.connection) {
309
+ throw new Error('--connection does not apply to platform_event triggers');
310
+ }
277
311
  const data = {
278
- connection_id: stripPrllScheme(opts.connection),
312
+ ...(sourceKind === 'platform_event'
313
+ ? {
314
+ source_kind: 'platform_event',
315
+ event_types: parseIds(opts.eventTypes, '--event-types'),
316
+ }
317
+ : { connection_id: stripPrllScheme(opts.connection) }),
279
318
  name: opts.name,
280
319
  target_agent_ids: parseIds(opts.targetIds, '--target-ids'),
281
320
  filter_expr: opts.filter,
@@ -318,6 +357,7 @@ export function registerTriggerCommands(program) {
318
357
  .option('--name <name>', 'Trigger name')
319
358
  .option('--description <text>', 'Human-facing trigger description')
320
359
  .option('--status <status>', 'active | paused')
360
+ .option('--event-types <types>', 'Replace a platform trigger subscription list (comma-separated)')
321
361
  .option('--target-ids <ids>', 'Comma-separated target agent user IDs')
322
362
  .option('--attached-to-uri <uri>', 'Attach to a prll:// resource URI')
323
363
  .option('--clear-attached-to', 'Explicitly clear attached_to_uri')
@@ -347,6 +387,7 @@ export function registerTriggerCommands(program) {
347
387
  const agentInputTemplate = await resolveTemplate(opts);
348
388
  const patch = stripUndefined({
349
389
  name: opts.name,
390
+ event_types: opts.eventTypes !== undefined ? parseIds(opts.eventTypes, '--event-types') : undefined,
350
391
  description: opts.description,
351
392
  status: parseEnum(opts.status, triggerStatuses, '--status'),
352
393
  target_agent_ids: opts.targetIds !== undefined ? parseIds(opts.targetIds, '--target-ids') : undefined,
@@ -422,6 +463,7 @@ export function registerTriggerCommands(program) {
422
463
  .command('runs')
423
464
  .description('List run history for a Trigger')
424
465
  .argument('<triggerId>', 'Trigger ID')
466
+ .option('--source-kind <kind>', 'Filter by source kind: webhook | platform_event')
425
467
  .option('--limit <n>', 'Maximum number of runs to return', '50')
426
468
  .option('--cursor <cursor>', 'Pagination cursor')
427
469
  .action(async (triggerId, opts) => {
@@ -429,6 +471,7 @@ export function registerTriggerCommands(program) {
429
471
  const { client, orgId } = await resolveTriggerCommandContext();
430
472
  const result = await client.listTriggerRuns(orgId, stripUndefined({
431
473
  trigger_id: stripPrllScheme(triggerId),
474
+ source_kind: parseEnum(opts.sourceKind, triggerSourceKinds, '--source-kind'),
432
475
  limit: parsePositiveInt(opts.limit, '--limit'),
433
476
  cursor: opts.cursor,
434
477
  }));
@@ -456,6 +499,7 @@ export function registerTriggerCommands(program) {
456
499
  .command('events')
457
500
  .description('List incoming events received by Trigger Connections')
458
501
  .option('--connection <connectionId>', 'Filter by Trigger Connection ID')
502
+ .option('--source-kind <kind>', 'Filter by source kind: webhook | platform_event')
459
503
  .option('--limit <n>', 'Maximum number of events to return', '50')
460
504
  .option('--cursor <cursor>', 'Pagination cursor')
461
505
  .action(async (opts) => {
@@ -463,6 +507,7 @@ export function registerTriggerCommands(program) {
463
507
  const { client, orgId } = await resolveTriggerCommandContext();
464
508
  const result = await client.listTriggerIngressEvents(orgId, stripUndefined({
465
509
  connection_id: opts.connection ? stripPrllScheme(opts.connection) : undefined,
510
+ source_kind: parseEnum(opts.sourceKind, triggerSourceKinds, '--source-kind'),
466
511
  limit: parsePositiveInt(opts.limit, '--limit'),
467
512
  cursor: opts.cursor,
468
513
  }));
package/dist/index.js CHANGED
@@ -22,18 +22,20 @@ import { registerRefCommands } from './commands/refs.js';
22
22
  import { registerSearchCommands } from './commands/search.js';
23
23
  import { registerFileCommands } from './commands/files.js';
24
24
  import { registerMachineCommands } from './commands/machines.js';
25
+ import { registerBrowserCommands } from './commands/browser.js';
25
26
  import { registerClipCommands } from './commands/clip.js';
26
27
  import { registerSlackCommands } from './commands/slack.js';
27
28
  import { registerWechatCommands } from './commands/wechat.js';
28
29
  import { registerWatchCommands } from './commands/watch.js';
29
30
  import { createUpdateNotifier } from './lib/update-check.js';
30
- const require = createRequire(import.meta.url);
31
- const pkg = require('../package.json');
31
+ const version = typeof __PARALL_CLI_VERSION__ === 'string'
32
+ ? __PARALL_CLI_VERSION__
33
+ : createRequire(import.meta.url)('../package.json').version;
32
34
  const program = new Command();
33
35
  program
34
36
  .name('parall')
35
37
  .description('CLI client for Parall — universal agent & human access to Parall API')
36
- .version(pkg.version);
38
+ .version(version);
37
39
  registerAgentCommands(program);
38
40
  registerApprovalCommands(program);
39
41
  registerChatCommands(program);
@@ -57,9 +59,10 @@ registerSearchCommands(program);
57
59
  registerFileCommands(program);
58
60
  registerMachineCommands(program);
59
61
  registerClipCommands(program);
62
+ registerBrowserCommands(program);
60
63
  registerSlackCommands(program);
61
64
  registerWechatCommands(program);
62
- const updateNotifier = createUpdateNotifier(pkg.version);
65
+ const updateNotifier = createUpdateNotifier(version);
63
66
  program.hook('postAction', () => {
64
67
  if (process.exitCode === undefined || process.exitCode === 0) {
65
68
  updateNotifier.afterSuccessfulCommand();
@@ -0,0 +1,18 @@
1
+ import type { BrowserUseActionRequest } from '@parall/sdk';
2
+ export type BrowserCommand = {
3
+ kind: 'profiles';
4
+ profileId?: string;
5
+ json: boolean;
6
+ } | {
7
+ kind: 'get';
8
+ profileId: string;
9
+ operationId: string;
10
+ json: boolean;
11
+ } | {
12
+ kind: 'execute';
13
+ profileId: string;
14
+ request: BrowserUseActionRequest;
15
+ json: boolean;
16
+ };
17
+ export declare function parseBrowserCommand(tokens: string[]): BrowserCommand;
18
+ //# sourceMappingURL=browser-arguments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-arguments.d.ts","sourceRoot":"","sources":["../../src/lib/browser-arguments.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAoB,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE7E,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,uBAAuB,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAU5F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAwFpE"}
@@ -0,0 +1,106 @@
1
+ import { BROWSER_USE_ACTION_SCHEMAS, BrowserUseValidationError, browserUseIdentifier, validateBrowserUseActionRequest, } from '@parall/sdk';
2
+ function fail(message, code = 'INVALID_ARGUMENT') {
3
+ throw new BrowserUseValidationError(message, code);
4
+ }
5
+ function integer(value) {
6
+ if (!/^(0|[1-9]\d*)$/.test(value) || !Number.isSafeInteger(Number(value)))
7
+ fail('Expected a nonnegative decimal integer.');
8
+ return Number(value);
9
+ }
10
+ export function parseBrowserCommand(tokens) {
11
+ const args = [...tokens];
12
+ let json = false;
13
+ while (args[0] === '--json') {
14
+ json = true;
15
+ args.shift();
16
+ }
17
+ const action = args.shift();
18
+ if (!action)
19
+ fail('Usage: parall browser <action> [options]');
20
+ let operationId;
21
+ if (action === 'operation') {
22
+ if (args.shift() !== 'get')
23
+ fail('Usage: parall browser operation get <buo_id> --profile <ebp_id>');
24
+ operationId = browserUseIdentifier(args.shift(), 'buo_');
25
+ }
26
+ else if (action !== 'profiles' && !Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, action))
27
+ fail(`Browser Use v1 does not support ${action}.`, 'UNSUPPORTED_ACTION');
28
+ const flags = new Map();
29
+ // Positional conveniences retain the same explicit value and wire contract.
30
+ if ((action === 'open' || action === 'eval') && args[0] && !args[0].startsWith('--'))
31
+ flags.set(action === 'open' ? 'url' : 'expression', args.shift());
32
+ while (args.length) {
33
+ const flag = args.shift();
34
+ if (flag === '--json') {
35
+ json = true;
36
+ continue;
37
+ }
38
+ if (!/^--[a-z][a-z0-9-]*$/.test(flag) || !args.length)
39
+ fail(`Invalid option: ${flag}`);
40
+ const key = flag.slice(2);
41
+ if (key === 'edge')
42
+ fail('Browser Use does not accept --edge. Specify --profile.', 'INVALID_OPTION');
43
+ if (flags.has(key))
44
+ fail(`Duplicate option: ${flag}`);
45
+ flags.set(key, args.shift());
46
+ }
47
+ const profileRaw = flags.get('profile');
48
+ flags.delete('profile');
49
+ const profileId = profileRaw === undefined && action === 'profiles'
50
+ ? undefined
51
+ : browserUseIdentifier(profileRaw, 'ebp_');
52
+ if (action === 'profiles' || action === 'operation') {
53
+ if (flags.size)
54
+ fail(`Unknown option: --${flags.keys().next().value}`);
55
+ return action === 'profiles'
56
+ ? { kind: 'profiles', profileId, json }
57
+ : { kind: 'get', profileId: profileId, operationId: operationId, json };
58
+ }
59
+ const schema = BROWSER_USE_ACTION_SCHEMAS[action];
60
+ const target = {};
61
+ for (const [flag, key] of [
62
+ ['tab', 'tab_id'],
63
+ ['browser-generation', 'browser_generation'],
64
+ ['document-generation', 'document_generation'],
65
+ ['snapshot-id', 'snapshot_id'],
66
+ ['ref', 'ref'],
67
+ ]) {
68
+ if (flags.has(flag)) {
69
+ const value = flags.get(flag);
70
+ flags.delete(flag);
71
+ target[key] = key.endsWith('_generation') ? integer(value) : value;
72
+ }
73
+ }
74
+ const params = {};
75
+ if (action === 'open' && (flags.has('width') || flags.has('height'))) {
76
+ if (!flags.has('width') || !flags.has('height'))
77
+ fail('open viewport requires both --width and --height.');
78
+ params.viewport = {
79
+ width: integer(flags.get('width')),
80
+ height: integer(flags.get('height')),
81
+ };
82
+ flags.delete('width');
83
+ flags.delete('height');
84
+ }
85
+ for (const [flag, value] of flags) {
86
+ const key = flag.replaceAll('-', '_');
87
+ if (!Object.hasOwn(schema.params.properties, key) || key === 'viewport')
88
+ fail(`Unknown option for ${action}: --${flag}`);
89
+ const field = schema.params.properties[key];
90
+ if (typeof field !== 'string' && field.type === 'integer')
91
+ params[key] = integer(value);
92
+ else if (typeof field !== 'string' && field.type === 'boolean') {
93
+ if (!['true', 'false'].includes(value))
94
+ fail(`--${flag} must be true or false.`);
95
+ params[key] = value === 'true';
96
+ }
97
+ else
98
+ params[key] = value;
99
+ }
100
+ const request = validateBrowserUseActionRequest({
101
+ action,
102
+ params,
103
+ ...(Object.keys(target).length ? { target } : {}),
104
+ });
105
+ return { kind: 'execute', profileId: profileId, request, json };
106
+ }
@@ -0,0 +1,35 @@
1
+ import type { BrowserUseOperationReceipt, ParallClient } from '@parall/sdk';
2
+ import type { BrowserCommand } from './browser-arguments.js';
3
+ type Anchor = {
4
+ request_id?: string;
5
+ operation_id?: string;
6
+ profile_id?: string;
7
+ action?: string;
8
+ };
9
+ export type BrowserOutcome = Anchor & {
10
+ ok: boolean;
11
+ phase?: string;
12
+ result_available?: boolean;
13
+ data?: unknown;
14
+ receipt?: BrowserUseOperationReceipt;
15
+ duration_ms?: number;
16
+ error?: {
17
+ code: string;
18
+ message: string;
19
+ hint?: string;
20
+ };
21
+ status?: number;
22
+ retry_after_seconds?: number;
23
+ };
24
+ export declare function browserError(err: unknown, anchor?: Anchor, acceptanceUnknown?: boolean): BrowserOutcome;
25
+ export declare function browserReceiptOutcome(receipt: BrowserUseOperationReceipt, waitExpired?: boolean): BrowserOutcome;
26
+ /** Exactly one POST; once accepted only bounded GETs. No hidden browser actions. */
27
+ export declare function runBrowserOperation(client: ParallClient, orgId: string, command: Exclude<BrowserCommand, {
28
+ kind: 'profiles';
29
+ }>, clock?: {
30
+ now: () => number;
31
+ sleep: (ms: number) => Promise<void>;
32
+ }): Promise<BrowserOutcome>;
33
+ export declare function renderBrowserOutcome(outcome: BrowserOutcome, json: boolean): void;
34
+ export {};
35
+ //# sourceMappingURL=browser-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-operation.d.ts","sourceRoot":"","sources":["../../src/lib/browser-operation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAG1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EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CA8BjF"}
@@ -0,0 +1,204 @@
1
+ import { randomBytes, webcrypto } from 'node:crypto';
2
+ import { ApiError, BrowserUseValidationError, validateBrowserUseReceipt } from '@parall/sdk';
3
+ const recovery = (operationId, profileId) => `Do not retry the action. Check the original operation without running it again: parall browser operation get ${operationId} --profile ${profileId} --json`;
4
+ const publicText = (value) => value.length <= 1024 &&
5
+ !/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/u.test(value) &&
6
+ !/\b(?:agk_|pk_|sk_|edg_)|dispatch[_ -]?claim|grant[_ -]?proof/iu.test(value)
7
+ ? value
8
+ : 'Browser Use request failed.';
9
+ export function browserError(err, anchor = {}, acceptanceUnknown = false) {
10
+ const code = acceptanceUnknown
11
+ ? 'UNKNOWN_OUTCOME'
12
+ : err instanceof ApiError
13
+ ? err.status === 401
14
+ ? 'AUTH_REQUIRED'
15
+ : (err.code ?? 'BROWSER_USE_FAILED')
16
+ : err instanceof BrowserUseValidationError
17
+ ? err.code
18
+ : 'BROWSER_USE_FAILED';
19
+ let hint = anchor.operation_id && anchor.profile_id
20
+ ? recovery(anchor.operation_id, anchor.profile_id)
21
+ : undefined;
22
+ if (acceptanceUnknown)
23
+ hint =
24
+ 'The action may already have run. Do not retry. Save the request ID and ask a person to inspect the page; no operation ID is available to query.';
25
+ if (code === 'PROFILE_NOT_ALLOWED')
26
+ hint =
27
+ 'Stop and ask an org admin to grant the needed access to this Browser Profile. Do not switch keys to bypass the refusal.';
28
+ if (code === 'BROWSER_USE_DISABLED')
29
+ hint = `${hint ? `${hint} ` : ''}Stop and ask an org admin to enable Browser Use for this organization.`;
30
+ if (code === 'EDGE_ACTIVATING')
31
+ hint =
32
+ "The cloud browser is starting; this action has not run. Wait for Retry-After, then decide whether to try again within the user's budget.";
33
+ if (code === 'INSUFFICIENT_CREDITS' || code === 'CREDIT_UNAVAILABLE')
34
+ hint = 'Stop and tell the user about the balance or billing problem before another action.';
35
+ if (!hint && (code === 'UNKNOWN_OUTCOME' || code === 'OUTCOME_UNKNOWN'))
36
+ hint =
37
+ 'Do not retry. Save the request ID and ask a person to inspect the page; no operation ID is available to query.';
38
+ return {
39
+ ok: false,
40
+ ...anchor,
41
+ error: {
42
+ code,
43
+ message: acceptanceUnknown
44
+ ? 'Browser Use acceptance could not be confirmed.'
45
+ : publicText(err instanceof Error ? err.message : 'Browser Use failed.'),
46
+ ...(hint ? { hint } : {}),
47
+ },
48
+ ...(err instanceof ApiError && err.status > 0 ? { status: err.status } : {}),
49
+ ...(err instanceof ApiError &&
50
+ Number.isFinite(err.retryAfterSeconds) &&
51
+ err.retryAfterSeconds > 0
52
+ ? { retry_after_seconds: err.retryAfterSeconds }
53
+ : {}),
54
+ };
55
+ }
56
+ export function browserReceiptOutcome(receipt, waitExpired = false) {
57
+ const anchor = {
58
+ request_id: receipt.request_id,
59
+ operation_id: receipt.operation_id,
60
+ profile_id: receipt.profile_id,
61
+ action: receipt.action,
62
+ };
63
+ const base = {
64
+ ...anchor,
65
+ phase: receipt.phase,
66
+ result_available: receipt.result_available,
67
+ receipt,
68
+ ...(receipt.duration_ms !== undefined ? { duration_ms: receipt.duration_ms } : {}),
69
+ };
70
+ if (waitExpired)
71
+ return {
72
+ ok: false,
73
+ ...base,
74
+ error: {
75
+ code: 'BROWSER_OPERATION_IN_PROGRESS',
76
+ message: 'The local wait ended before a terminal result.',
77
+ hint: recovery(receipt.operation_id, receipt.profile_id),
78
+ },
79
+ };
80
+ if (receipt.phase === 'failed' || receipt.phase === 'outcome_unknown')
81
+ return {
82
+ ok: false,
83
+ ...base,
84
+ error: {
85
+ code: receipt.error.code,
86
+ message: publicText(receipt.error.message ?? 'Browser Use did not succeed.'),
87
+ hint: receipt.error.code === 'CANCELLED'
88
+ ? 'Stop and report the cancellation to the user. Do not resume the task automatically.'
89
+ : recovery(receipt.operation_id, receipt.profile_id),
90
+ },
91
+ };
92
+ return { ok: true, ...base, ...(receipt.result_available ? { data: receipt.data } : {}) };
93
+ }
94
+ /** Exactly one POST; once accepted only bounded GETs. No hidden browser actions. */
95
+ export async function runBrowserOperation(client, orgId, command, clock = { now: Date.now, sleep: (ms) => new Promise((r) => setTimeout(r, ms)) }) {
96
+ if (command.kind === 'get') {
97
+ const anchor = { operation_id: command.operationId, profile_id: command.profileId };
98
+ try {
99
+ return browserReceiptOutcome(await validateBrowserUseReceipt(await client.getBrowserUseOperation(orgId, command.operationId), { profileId: command.profileId, operationId: command.operationId }, webcrypto.subtle));
100
+ }
101
+ catch (err) {
102
+ return browserError(err, anchor);
103
+ }
104
+ }
105
+ const request = {
106
+ contract_version: 'browser-use-operation-v1',
107
+ request_id: `burq_${randomBytes(16).toString('base64url')}`,
108
+ profile_id: command.profileId,
109
+ deadline: new Date(clock.now() + 90_000).toISOString(),
110
+ ...command.request,
111
+ };
112
+ const anchor = {
113
+ request_id: request.request_id,
114
+ profile_id: request.profile_id,
115
+ action: request.action,
116
+ };
117
+ const expected = {
118
+ requestId: request.request_id,
119
+ profileId: request.profile_id,
120
+ action: request.action,
121
+ target: request.target,
122
+ };
123
+ if (Buffer.byteLength(JSON.stringify(request), 'utf8') > 1 << 20)
124
+ return browserError(new BrowserUseValidationError('Browser Use request exceeds 1 MiB.'), anchor);
125
+ let receipt;
126
+ try {
127
+ receipt = await validateBrowserUseReceipt(await client.createBrowserUseOperation(orgId, request), expected, webcrypto.subtle);
128
+ }
129
+ catch (err) {
130
+ // Generic 5xx and request timeouts may follow a committed operation. Only
131
+ // explicit admission failures establish non-acceptance, even for reads.
132
+ const rejected = err instanceof ApiError &&
133
+ ((err.status >= 400 && err.status < 500 && err.status !== 408) ||
134
+ (err.status === 503 &&
135
+ [
136
+ 'EDGE_ACTIVATING',
137
+ 'EDGE_RUNTIME_UNAVAILABLE',
138
+ 'CREDIT_UNAVAILABLE',
139
+ 'EDGE_UNAVAILABLE',
140
+ 'EDGE_STATUS_UNAVAILABLE',
141
+ ].includes(err.code ?? '')));
142
+ return browserError(err, anchor, !rejected);
143
+ }
144
+ anchor.operation_id = receipt.operation_id;
145
+ expected.operationId = receipt.operation_id;
146
+ const expiresAt = Math.min(Date.parse(receipt.deadline), Date.parse(request.deadline)) + 5000;
147
+ let poll = 0;
148
+ while (receipt.phase === 'accepted' || receipt.phase === 'started') {
149
+ const remaining = expiresAt - clock.now();
150
+ if (remaining <= 0)
151
+ return browserReceiptOutcome(receipt, true);
152
+ await clock.sleep(Math.min([250, 500, 1000, 2000][Math.min(poll++, 3)], remaining));
153
+ const budget = expiresAt - clock.now();
154
+ if (budget <= 0)
155
+ return browserReceiptOutcome(receipt, true);
156
+ try {
157
+ receipt = await validateBrowserUseReceipt(await client.getBrowserUseOperation(orgId, receipt.operation_id, {
158
+ timeoutMs: Math.max(1, Math.min(15000, budget)),
159
+ }), expected, webcrypto.subtle);
160
+ }
161
+ catch (err) {
162
+ return browserError(err, anchor);
163
+ }
164
+ }
165
+ return browserReceiptOutcome(receipt);
166
+ }
167
+ export function renderBrowserOutcome(outcome, json) {
168
+ const output = outcome.ok ? console.log : console.error;
169
+ if (json)
170
+ output(JSON.stringify(outcome));
171
+ else if (!outcome.ok) {
172
+ output(`Error [${outcome.error.code}]: ${outcome.error.message}`);
173
+ if (outcome.request_id)
174
+ output(`Request: ${outcome.request_id}`);
175
+ if (outcome.operation_id)
176
+ output(`Operation: ${outcome.operation_id}`);
177
+ if (outcome.error?.hint)
178
+ output(outcome.error.hint);
179
+ if (outcome.retry_after_seconds)
180
+ output(`Retry-After: ${outcome.retry_after_seconds}s`);
181
+ }
182
+ else {
183
+ output(`Browser Use ${outcome.operation_id}: ${outcome.phase}`);
184
+ if (outcome.request_id)
185
+ output(`Request: ${outcome.request_id}`);
186
+ if (outcome.duration_ms !== undefined)
187
+ output(`Duration: ${outcome.duration_ms}ms`);
188
+ if (outcome.result_available)
189
+ output(JSON.stringify(outcome.data, null, 2));
190
+ else if (outcome.phase === 'succeeded')
191
+ output(`Result data expired. ${recovery(outcome.operation_id, outcome.profile_id)}`);
192
+ if (outcome.receipt?.result_expires_at)
193
+ output(`Result cache expires: ${outcome.receipt.result_expires_at} (this does not close the page).`);
194
+ }
195
+ if (!outcome.ok)
196
+ process.exitCode = [
197
+ 'AUTH_REQUIRED',
198
+ 'INVALID_ARGUMENT',
199
+ 'INVALID_OPTION',
200
+ 'UNSUPPORTED_ACTION',
201
+ ].includes(outcome.error.code)
202
+ ? 2
203
+ : 1;
204
+ }
@@ -79,6 +79,7 @@ export type TypedDispatchBinding = {
79
79
  export declare function resolveTypedDispatchBinding(taskId: string): TypedDispatchBinding | null;
80
80
  /** Per-lane dispatch context (PRLL_CONTEXT_DIR contract), keyed by send target. */
81
81
  export type LaneDispatchContext = {
82
+ settlementMode?: 'legacy' | 'receipt';
82
83
  lane: string;
83
84
  dispatchEventId?: string;
84
85
  targetUri: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oGAAoG;IACpG,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,g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MAAM,oBAAoB,GAAG;IACjC;iFAC6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CA0DvF;AAED,mFAAmF;AACnF,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,mBAAmB,GAAG,IAAI,CAgF5B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAYzE;AAED,wBAAgB,kBAAkB,IAAI,mBAAmB,CA8BxD"}
@@ -251,6 +251,7 @@ export function resolveLaneDispatchContext(chatId, threadRootId) {
251
251
  stepId: typeof ctx.step_id === 'string' && ctx.step_id ? ctx.step_id : undefined,
252
252
  replyCommitted,
253
253
  replyStatePath,
254
+ settlementMode: ctx.settlement_mode === 'receipt' ? 'receipt' : 'legacy',
254
255
  };
255
256
  }
256
257
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parall/cli",
3
- "version": "1.62.0",
3
+ "version": "1.64.0",
4
4
  "description": "CLI client for Parall — universal agent & human access to Parall API",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,18 +37,20 @@
37
37
  "js-yaml": "^4.1.0",
38
38
  "node-diff3": "3.2.1",
39
39
  "zod": "^4.3.6",
40
- "@parall/agent-core": "1.62.0",
41
- "@parall/sdk": "1.62.0"
40
+ "@parall/sdk": "1.64.0",
41
+ "@parall/agent-core": "1.64.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/js-yaml": "^4.0.9",
45
45
  "@types/node": "^22.0.0",
46
+ "esbuild": "^0.25.0",
46
47
  "typescript": "^5.7.0",
47
- "@parall/agent-core": "1.62.0"
48
+ "@parall/agent-core": "1.64.0"
48
49
  },
49
50
  "scripts": {
50
51
  "build": "tsc",
51
52
  "dev": "tsc --watch",
52
- "test": "pnpm run build && node --test test/*.test.mjs"
53
+ "test": "pnpm run build && node --test test/*.test.mjs",
54
+ "bundle": "node scripts/bundle.mjs"
53
55
  }
54
56
  }