@parall/agent-core 1.42.0 → 1.43.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.
- package/dist/bin/channel-exec.d.ts +4 -0
- package/dist/bin/channel-exec.d.ts.map +1 -0
- package/dist/bin/channel-exec.js +246 -0
- package/dist/channel-capability.d.ts +16 -0
- package/dist/channel-capability.d.ts.map +1 -0
- package/dist/channel-capability.js +155 -0
- package/dist/channel-token.d.ts +19 -0
- package/dist/channel-token.d.ts.map +1 -0
- package/dist/channel-token.js +73 -0
- package/dist/event-format.d.ts.map +1 -1
- package/dist/event-format.js +21 -16
- package/dist/gateway-base.d.ts +15 -0
- package/dist/gateway-base.d.ts.map +1 -1
- package/dist/gateway-base.js +113 -38
- package/dist/gateway-lane-flow.d.ts +20 -1
- package/dist/gateway-lane-flow.d.ts.map +1 -1
- package/dist/gateway-lane-flow.js +78 -6
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/platform-config.d.ts +15 -0
- package/dist/platform-config.d.ts.map +1 -1
- package/dist/platform-config.js +28 -0
- package/dist/prompt-fragments.d.ts +1 -1
- package/dist/prompt-fragments.d.ts.map +1 -1
- package/dist/prompt-fragments.js +29 -7
- package/dist/skills/index.js +1 -1
- package/dist/skills/parall-platform.d.ts +1 -1
- package/dist/skills/parall-platform.d.ts.map +1 -1
- package/dist/skills/parall-platform.js +23 -4
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/bin/channel-exec.ts +262 -0
- package/src/channel-capability.ts +187 -0
- package/src/channel-token.ts +92 -0
- package/src/event-format.ts +21 -16
- package/src/gateway-base.ts +137 -39
- package/src/gateway-lane-flow.ts +92 -4
- package/src/index.ts +3 -0
- package/src/platform-config.ts +44 -0
- package/src/prompt-fragments.ts +29 -7
- package/src/skills/index.ts +1 -1
- package/src/skills/parall-platform.ts +23 -4
- package/src/types.ts +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message).
|
|
126
126
|
channelConnectionProviders = new Map();
|
|
127
127
|
dispatchedMessages = new Set();
|
|
128
|
+
// Per-WorkItem failure backoff for typed dispatch consumption — see
|
|
129
|
+
// LaneFlowHost.typedRedriveBackoff in gateway-lane-flow.ts.
|
|
130
|
+
typedRedriveBackoff = new Map();
|
|
128
131
|
forkStates = new Map();
|
|
129
132
|
dispatchState = {
|
|
130
133
|
mainDispatching: false,
|
|
@@ -255,17 +258,23 @@ export class ParallAgentGateway {
|
|
|
255
258
|
? { dispatchEventId: data.dispatch_event_id }
|
|
256
259
|
: { sourceType: 'task_activity', sourceId: data.id }, (dispatchEventId) => this.handleTaskAssignment(data, data.id, dispatchEventId), (dispatchEventId) => {
|
|
257
260
|
if (dispatchEventId) {
|
|
258
|
-
this.
|
|
259
|
-
.
|
|
260
|
-
|
|
261
|
-
return;
|
|
261
|
+
return this.ackDispatchEvent(dispatchEventId, () => {
|
|
262
|
+
this.dispatchedTasks.delete(`${data.id}:${data.updated_at}`);
|
|
263
|
+
});
|
|
262
264
|
}
|
|
263
|
-
this.opts.client
|
|
265
|
+
return this.opts.client
|
|
264
266
|
.ackDispatch(this.opts.config.org_id, {
|
|
265
267
|
source_type: 'task_activity',
|
|
266
268
|
source_id: data.id,
|
|
267
269
|
})
|
|
268
|
-
.
|
|
270
|
+
.then(() => true, (err) => {
|
|
271
|
+
// Same contract as ackDispatchEvent: a failed ack is a
|
|
272
|
+
// failed consume (arms backoff) and must free the hot-path
|
|
273
|
+
// dedupe so the re-drive isn't rejected by this pod forever.
|
|
274
|
+
this.dispatchedTasks.delete(`${data.id}:${data.updated_at}`);
|
|
275
|
+
this.opts.log?.warn(`dispatch ack failed for task ${data.id}, releasing for re-drive: ${String(err)}`);
|
|
276
|
+
return false;
|
|
277
|
+
});
|
|
269
278
|
});
|
|
270
279
|
}
|
|
271
280
|
catch (err) {
|
|
@@ -273,13 +282,21 @@ export class ParallAgentGateway {
|
|
|
273
282
|
}
|
|
274
283
|
});
|
|
275
284
|
ws.on('dispatch.new', async (data) => {
|
|
276
|
-
if (data.event_type === '
|
|
285
|
+
if (data.event_type === 'task_assign') {
|
|
286
|
+
if (!data.task_id)
|
|
287
|
+
return;
|
|
288
|
+
try {
|
|
289
|
+
await this.handleTaskAssignmentRedrive(data);
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
this.opts.log?.error(`task assignment re-drive failed for ${data.task_id}: ${String(err)}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (data.event_type === 'task_comment') {
|
|
277
296
|
if (!data.source_id || !data.task_id)
|
|
278
297
|
return;
|
|
279
298
|
try {
|
|
280
|
-
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.handleTaskComment(data.source_id, data.task_id ?? '', data.actor_id, data.delivery_reason), () =>
|
|
281
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
282
|
-
});
|
|
299
|
+
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.handleTaskComment(data.source_id, data.task_id ?? '', data.actor_id, data.delivery_reason), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
283
300
|
}
|
|
284
301
|
catch (err) {
|
|
285
302
|
this.opts.log?.error(`task comment dispatch failed for ${data.source_id}: ${String(err)}`);
|
|
@@ -289,9 +306,7 @@ export class ParallAgentGateway {
|
|
|
289
306
|
if (!data.source_id)
|
|
290
307
|
return;
|
|
291
308
|
try {
|
|
292
|
-
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.handleWikiComment(data.source_id, data.actor_id, data.delivery_reason), () =>
|
|
293
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
294
|
-
});
|
|
309
|
+
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.handleWikiComment(data.source_id, data.actor_id, data.delivery_reason), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
295
310
|
}
|
|
296
311
|
catch (err) {
|
|
297
312
|
this.opts.log?.error(`wiki comment dispatch failed for ${data.source_id}: ${String(err)}`);
|
|
@@ -304,9 +319,7 @@ export class ParallAgentGateway {
|
|
|
304
319
|
await this.consumeTypedDispatch({ dispatchEventId: data.id }, (dispatchEventId) => this.handleTaskDispatch(data.task_id ?? '', data.source_id ?? data.task_id ?? '', {
|
|
305
320
|
allowCreator: true,
|
|
306
321
|
dispatchEventId,
|
|
307
|
-
}), () =>
|
|
308
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
309
|
-
});
|
|
322
|
+
}), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
310
323
|
}
|
|
311
324
|
catch (err) {
|
|
312
325
|
this.opts.log?.error(`task update dispatch failed for ${data.task_id}: ${String(err)}`);
|
|
@@ -316,9 +329,7 @@ export class ParallAgentGateway {
|
|
|
316
329
|
if (!data.source_id)
|
|
317
330
|
return;
|
|
318
331
|
try {
|
|
319
|
-
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleScheduleFire(data.source_id, data.actor_id), () =>
|
|
320
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
321
|
-
});
|
|
332
|
+
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleScheduleFire(data.source_id, data.actor_id), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
322
333
|
}
|
|
323
334
|
catch (err) {
|
|
324
335
|
this.opts.log?.error(`schedule fire dispatch failed for ${data.source_id}: ${String(err)}`);
|
|
@@ -328,9 +339,7 @@ export class ParallAgentGateway {
|
|
|
328
339
|
if (!data.source_id)
|
|
329
340
|
return;
|
|
330
341
|
try {
|
|
331
|
-
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleExternalTriggerRun(data.source_id), () =>
|
|
332
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
333
|
-
});
|
|
342
|
+
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleExternalTriggerRun(data.source_id), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
334
343
|
}
|
|
335
344
|
catch (err) {
|
|
336
345
|
this.opts.log?.error(`external trigger dispatch failed for ${data.source_id}: ${String(err)}`);
|
|
@@ -340,9 +349,7 @@ export class ParallAgentGateway {
|
|
|
340
349
|
if (!data.source_id)
|
|
341
350
|
return;
|
|
342
351
|
try {
|
|
343
|
-
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleChannelMessage(data.source_id), () =>
|
|
344
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
345
|
-
});
|
|
352
|
+
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleChannelMessage(data.source_id), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
346
353
|
}
|
|
347
354
|
catch (err) {
|
|
348
355
|
this.opts.log?.error(`channel message dispatch failed for ${data.source_id}: ${String(err)}`);
|
|
@@ -352,9 +359,7 @@ export class ParallAgentGateway {
|
|
|
352
359
|
if (!data.source_id)
|
|
353
360
|
return;
|
|
354
361
|
try {
|
|
355
|
-
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleApprovalDecided(data.source_id, data.actor_id, data.chat_id ?? null), () =>
|
|
356
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, data.id).catch(() => { });
|
|
357
|
-
});
|
|
362
|
+
await this.consumeTypedDispatch({ dispatchEventId: data.id }, () => this.fetchAndHandleApprovalDecided(data.source_id, data.actor_id, data.chat_id ?? null), () => this.ackDispatchEvent(data.id, () => this.clearTypedDispatchDedupe(data)));
|
|
358
363
|
}
|
|
359
364
|
catch (err) {
|
|
360
365
|
this.opts.log?.error(`approval decided dispatch failed for ${data.source_id}: ${String(err)}`);
|
|
@@ -374,14 +379,11 @@ export class ParallAgentGateway {
|
|
|
374
379
|
this.opts.log?.error(`message re-drive failed for ${data.source_id}: ${String(err)}`);
|
|
375
380
|
}
|
|
376
381
|
}
|
|
377
|
-
else if (data.event_type !== 'message'
|
|
382
|
+
else if (data.event_type !== 'message') {
|
|
378
383
|
// Truly unknown event_type — log so a newly-added dispatch type
|
|
379
|
-
// not yet wired here surfaces during runtime testing. "message"
|
|
380
|
-
//
|
|
381
|
-
//
|
|
382
|
-
// (message.new, task.assigned) above and would otherwise spam
|
|
383
|
-
// info-level logs for every inbound chat message / task
|
|
384
|
-
// assignment on a busy agent.
|
|
384
|
+
// not yet wired here surfaces during runtime testing. "message" is
|
|
385
|
+
// deliberately excluded because its first delivery is owned by the
|
|
386
|
+
// message.new handler; recovered task_assign rows are handled above.
|
|
385
387
|
this.opts.log?.info(`dispatch.new with unhandled event_type=${String(data.event_type)} (id=${data.id}) — no-op`);
|
|
386
388
|
}
|
|
387
389
|
});
|
|
@@ -453,6 +455,57 @@ export class ParallAgentGateway {
|
|
|
453
455
|
consumeTypedDispatch(ref, run, ack) {
|
|
454
456
|
return consumeTypedDispatch(this.laneFlowHost(), ref, run, ack);
|
|
455
457
|
}
|
|
458
|
+
// Typed completion must wait until the administrative ack has either
|
|
459
|
+
// committed or failed. Errors stay best-effort: a failed ack leaves the row
|
|
460
|
+
// received, so Complete releases and re-drives it safely. The boolean
|
|
461
|
+
// outcome feeds the typed-consume backoff — an ack that failed must count
|
|
462
|
+
// as a failed consume, or an ack outage would clear the backoff entry and
|
|
463
|
+
// let the release re-drive spin at wire speed.
|
|
464
|
+
ackDispatchEvent(dispatchEventId, onFailure) {
|
|
465
|
+
return this.opts.client.ackDispatchByID(this.opts.config.org_id, dispatchEventId).then(() => true, (err) => {
|
|
466
|
+
// Complete will return the still-received item to pending and publish
|
|
467
|
+
// an immediate hint. Free its hot-path claim first, otherwise that
|
|
468
|
+
// same-process re-drive is rejected forever by the local dedupe set.
|
|
469
|
+
onFailure?.();
|
|
470
|
+
this.opts.log?.warn(`dispatch ack failed for ${dispatchEventId}, releasing for re-drive: ${String(err)}`);
|
|
471
|
+
return false;
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
clearTypedDispatchDedupe(item) {
|
|
475
|
+
switch (item.event_type) {
|
|
476
|
+
case 'task_assign':
|
|
477
|
+
case 'task_update':
|
|
478
|
+
if (item.task_id) {
|
|
479
|
+
const prefix = `${item.task_id}:`;
|
|
480
|
+
for (const key of this.dispatchedTasks) {
|
|
481
|
+
if (key.startsWith(prefix))
|
|
482
|
+
this.dispatchedTasks.delete(key);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
case 'task_comment':
|
|
487
|
+
case 'wiki_comment':
|
|
488
|
+
if (item.source_id)
|
|
489
|
+
this.dispatchedTasks.delete(`comment:${item.source_id}`);
|
|
490
|
+
break;
|
|
491
|
+
case 'schedule.fire':
|
|
492
|
+
if (item.source_id)
|
|
493
|
+
this.dispatchedTasks.delete(`schedule_run:${item.source_id}`);
|
|
494
|
+
break;
|
|
495
|
+
case 'external_trigger':
|
|
496
|
+
if (item.source_id)
|
|
497
|
+
this.dispatchedTasks.delete(`external_trigger_run:${item.source_id}`);
|
|
498
|
+
break;
|
|
499
|
+
case 'channel_message':
|
|
500
|
+
if (item.source_id)
|
|
501
|
+
this.dispatchedMessages.delete(`channel_message:${item.source_id}`);
|
|
502
|
+
break;
|
|
503
|
+
case 'approval_decided':
|
|
504
|
+
if (item.source_id)
|
|
505
|
+
this.dispatchedTasks.delete(`approval:${item.source_id}`);
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
456
509
|
buildDispatchContext(event, sessionKey) {
|
|
457
510
|
const binding = this.sessionBindings.get(sessionKey);
|
|
458
511
|
return {
|
|
@@ -1605,6 +1658,17 @@ export class ParallAgentGateway {
|
|
|
1605
1658
|
chat_id: item.chat_id,
|
|
1606
1659
|
});
|
|
1607
1660
|
}
|
|
1661
|
+
// A task assignment's first delivery rides task.assigned, but a typed lane
|
|
1662
|
+
// released without an effect is re-driven as dispatch.new. Reuse the exact
|
|
1663
|
+
// typed claim path used by catch-up so that recovery does not require a
|
|
1664
|
+
// runtime reconnect.
|
|
1665
|
+
async handleTaskAssignmentRedrive(item) {
|
|
1666
|
+
if (!item.task_id)
|
|
1667
|
+
return;
|
|
1668
|
+
await this.consumeTypedDispatch({ dispatchEventId: item.id }, (dispatchEventId) => this.handleTaskDispatch(item.task_id ?? '', item.source_id ?? item.task_id ?? '', {
|
|
1669
|
+
dispatchEventId,
|
|
1670
|
+
}), (dispatchEventId) => this.ackDispatchEvent(dispatchEventId ?? item.id, () => this.clearTypedDispatchDedupe(item)));
|
|
1671
|
+
}
|
|
1608
1672
|
consumeMessageWorkItem(item) {
|
|
1609
1673
|
return consumeMessageWorkItem(this.laneFlowHost(), item);
|
|
1610
1674
|
}
|
|
@@ -1947,6 +2011,18 @@ export class ParallAgentGateway {
|
|
|
1947
2011
|
provider = undefined; // label degrades; reply hint still names the clip generically
|
|
1948
2012
|
}
|
|
1949
2013
|
}
|
|
2014
|
+
// The reply hint routes on the live capability grant: `<provider>-cli`
|
|
2015
|
+
// present → the vendor CLI is on PATH (broker shim) and is THE reply
|
|
2016
|
+
// path; absent → outbound is disabled for this org (flag/connection off)
|
|
2017
|
+
// and the hint must say so instead of pointing at a retired clip. The
|
|
2018
|
+
// provider label lookup above is best-effort/cosmetic — when it fails,
|
|
2019
|
+
// ANY granted `*-cli` capability keeps the hint on the CLI path: a
|
|
2020
|
+
// transient metadata miss must not flip an actively granted agent's
|
|
2021
|
+
// hint to "outbound disabled" and strand a valid external message.
|
|
2022
|
+
const keys = this.opts.getCapabilityKeys?.() ?? [];
|
|
2023
|
+
const cliCapable = provider
|
|
2024
|
+
? keys.includes(`${provider}-cli`)
|
|
2025
|
+
: keys.some((k) => k.endsWith('-cli'));
|
|
1950
2026
|
const event = {
|
|
1951
2027
|
type: 'channel_message',
|
|
1952
2028
|
targetId: conv.id,
|
|
@@ -1961,6 +2037,7 @@ export class ParallAgentGateway {
|
|
|
1961
2037
|
channelConversationType: conv.conversation_type || undefined,
|
|
1962
2038
|
channelExternalConversationId: conv.external_conversation_id,
|
|
1963
2039
|
channelExternalMessageId: msg.external_message_id,
|
|
2040
|
+
channelCliCapable: cliCapable,
|
|
1964
2041
|
ackSourceType: 'channel_message',
|
|
1965
2042
|
ackSourceId: msg.id,
|
|
1966
2043
|
};
|
|
@@ -2116,9 +2193,7 @@ export class ParallAgentGateway {
|
|
|
2116
2193
|
}
|
|
2117
2194
|
processed++;
|
|
2118
2195
|
try {
|
|
2119
|
-
const ackItem = () =>
|
|
2120
|
-
this.opts.client.ackDispatchByID(this.opts.config.org_id, item.id).catch(() => { });
|
|
2121
|
-
};
|
|
2196
|
+
const ackItem = () => this.ackDispatchEvent(item.id, () => this.clearTypedDispatchDedupe(item));
|
|
2122
2197
|
if (item.event_type === 'task_assign' && item.task_id) {
|
|
2123
2198
|
try {
|
|
2124
2199
|
await this.consumeTypedDispatch({ dispatchEventId: item.id }, (dispatchEventId) => this.handleTaskDispatch(item.task_id ?? '', item.source_id ?? item.task_id ?? '', {
|
|
@@ -15,6 +15,18 @@ export interface LaneFlowHost {
|
|
|
15
15
|
ledgerDisabled: boolean;
|
|
16
16
|
shuttingDown: boolean;
|
|
17
17
|
dispatchedMessages: Set<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Per-WorkItem failure backoff for typed dispatch consumption. A consume
|
|
20
|
+
* that ends without an ack re-arms the entry; the next attempt for the
|
|
21
|
+
* same WorkItem is delayed (not skipped — a skipped attempt would strand
|
|
22
|
+
* the pending row until reconnect catch-up) so a claim→fail→complete
|
|
23
|
+
* tight loop is throttled to exponential intervals instead of spinning at
|
|
24
|
+
* wire speed against the server's immediate re-drive (2026-07-11 OOM).
|
|
25
|
+
*/
|
|
26
|
+
typedRedriveBackoff: Map<string, {
|
|
27
|
+
failures: number;
|
|
28
|
+
until: number;
|
|
29
|
+
}>;
|
|
18
30
|
opts: {
|
|
19
31
|
client: ParallClient;
|
|
20
32
|
log?: GatewayLogger;
|
|
@@ -52,12 +64,19 @@ export declare function dispatchLaneGroup(host: LaneFlowHost, opts: {
|
|
|
52
64
|
* pod holds it or the WorkItem is already resolved), run the handler, ack on
|
|
53
65
|
* success (the doc's option (b): notification delivered, tracked elsewhere),
|
|
54
66
|
* then release the lane. Legacy run+ack flow when the ledger is unavailable.
|
|
67
|
+
*
|
|
68
|
+
* Repeated failures back off: a consume that ends un-acked re-arms the
|
|
69
|
+
* WorkItem's backoff entry, and the next attempt sleeps out the remaining
|
|
70
|
+
* window before claiming. Without this, complete's release re-drives the
|
|
71
|
+
* item instantly and a persistently-failing consume (e.g. buffered behind a
|
|
72
|
+
* saturated fork pool) spins at wire speed — the client half of the
|
|
73
|
+
* 2026-07-11 poison loop (the server half is the redrive budget).
|
|
55
74
|
*/
|
|
56
75
|
export declare function consumeTypedDispatch(host: LaneFlowHost, ref: {
|
|
57
76
|
dispatchEventId?: string;
|
|
58
77
|
sourceType?: string;
|
|
59
78
|
sourceId?: string;
|
|
60
|
-
}, run: (dispatchEventId?: string) => Promise<boolean>, ack: (dispatchEventId?: string) => void): Promise<void>;
|
|
79
|
+
}, run: (dispatchEventId?: string) => Promise<boolean>, ack: (dispatchEventId?: string) => boolean | void | Promise<boolean | void>): Promise<void>;
|
|
61
80
|
/**
|
|
62
81
|
* Shared consumption of a message WorkItem referenced by id — the ONE
|
|
63
82
|
* protocol for dispatch catch-up pages and post-complete re-drive hints
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-lane-flow.d.ts","sourceRoot":"","sources":["../src/gateway-lane-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OA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EAAE,MAAM,CAAA;CAAE,EACzE,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EACnD,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAC1E,OAAO,CAAC,IAAI,CAAC,CAiGf;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACvD,OAAO,CAAC,IAAI,CAAC,CAuDf"}
|
|
@@ -58,17 +58,82 @@ export async function dispatchLaneGroup(host, opts) {
|
|
|
58
58
|
await ledger.completeIfIdle(lane.laneKey, pendingInjections || opts.hasMoreLocal());
|
|
59
59
|
return 'dispatched';
|
|
60
60
|
}
|
|
61
|
+
/** Failure backoff pacing for typed dispatch retries (base 2s, cap 5min). */
|
|
62
|
+
const TYPED_BACKOFF_BASE_MS = 2_000;
|
|
63
|
+
const TYPED_BACKOFF_CAP_MS = 5 * 60_000;
|
|
64
|
+
const TYPED_BACKOFF_MAP_CAP = 512;
|
|
61
65
|
/**
|
|
62
66
|
* Consume one typed dispatch (task/comment/schedule/trigger/approval) under
|
|
63
67
|
* its typed-lane occupancy guard: claim the dsp:<id> lane (skip when another
|
|
64
68
|
* pod holds it or the WorkItem is already resolved), run the handler, ack on
|
|
65
69
|
* success (the doc's option (b): notification delivered, tracked elsewhere),
|
|
66
70
|
* then release the lane. Legacy run+ack flow when the ledger is unavailable.
|
|
71
|
+
*
|
|
72
|
+
* Repeated failures back off: a consume that ends un-acked re-arms the
|
|
73
|
+
* WorkItem's backoff entry, and the next attempt sleeps out the remaining
|
|
74
|
+
* window before claiming. Without this, complete's release re-drives the
|
|
75
|
+
* item instantly and a persistently-failing consume (e.g. buffered behind a
|
|
76
|
+
* saturated fork pool) spins at wire speed — the client half of the
|
|
77
|
+
* 2026-07-11 poison loop (the server half is the redrive budget).
|
|
67
78
|
*/
|
|
68
79
|
export async function consumeTypedDispatch(host, ref, run, ack) {
|
|
80
|
+
const backoffKey = ref.dispatchEventId ?? `${ref.sourceType}:${ref.sourceId}`;
|
|
81
|
+
const armed = host.typedRedriveBackoff.get(backoffKey);
|
|
82
|
+
if (armed) {
|
|
83
|
+
const waitMs = armed.until - Date.now();
|
|
84
|
+
if (waitMs > 0) {
|
|
85
|
+
host.opts.log?.info(`typed dispatch ${backoffKey} backing off ${Math.ceil(waitMs / 1000)}s after ${armed.failures} failed consume(s)`);
|
|
86
|
+
// unref: the wait must never be what keeps the process alive — on
|
|
87
|
+
// SIGTERM the gateway drains and exits while this timer is pending
|
|
88
|
+
// (the re-drive/renotify path re-delivers on the next pod).
|
|
89
|
+
await new Promise((resolve) => {
|
|
90
|
+
const timer = setTimeout(resolve, waitMs);
|
|
91
|
+
timer.unref?.();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (host.shuttingDown)
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// An ack callback that returns void (legacy custom acks) counts as success;
|
|
98
|
+
// an explicit false (ackDispatchEvent's failed HTTP ack) is a failed
|
|
99
|
+
// consume — clearing backoff there would let an ack outage re-create the
|
|
100
|
+
// wire-speed release/re-drive loop against a pre-budget server.
|
|
101
|
+
const settleAck = (ackResult) => ackResult !== false;
|
|
102
|
+
const settle = (acked) => {
|
|
103
|
+
if (acked) {
|
|
104
|
+
host.typedRedriveBackoff.delete(backoffKey);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const failures = (host.typedRedriveBackoff.get(backoffKey)?.failures ?? 0) + 1;
|
|
108
|
+
const backoffMs = Math.min(TYPED_BACKOFF_CAP_MS, TYPED_BACKOFF_BASE_MS * 2 ** (failures - 1));
|
|
109
|
+
// True LRU: delete-then-set moves an updated key to the tail of the
|
|
110
|
+
// Map's insertion order, so capacity eviction always removes the
|
|
111
|
+
// least-recently-FAILING key — an actively-failing old key must not be
|
|
112
|
+
// evicted ahead of a quieter newer one. Evict only when inserting a new
|
|
113
|
+
// key at capacity (an in-place update never shrinks the map).
|
|
114
|
+
if (host.typedRedriveBackoff.delete(backoffKey) === false &&
|
|
115
|
+
host.typedRedriveBackoff.size >= TYPED_BACKOFF_MAP_CAP) {
|
|
116
|
+
const oldest = host.typedRedriveBackoff.keys().next().value;
|
|
117
|
+
if (oldest !== undefined)
|
|
118
|
+
host.typedRedriveBackoff.delete(oldest);
|
|
119
|
+
}
|
|
120
|
+
host.typedRedriveBackoff.set(backoffKey, { failures, until: Date.now() + backoffMs });
|
|
121
|
+
};
|
|
122
|
+
// Legacy run+ack (no ledger): same settle-in-finally contract as the lane
|
|
123
|
+
// path — a thrown run/ack must arm backoff, not skip it.
|
|
124
|
+
const runLegacy = async () => {
|
|
125
|
+
let acked = false;
|
|
126
|
+
try {
|
|
127
|
+
if (await run(ref.dispatchEventId)) {
|
|
128
|
+
acked = settleAck(await ack(ref.dispatchEventId));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
settle(acked);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
69
135
|
if (!host.laneLedger || host.ledgerDisabled) {
|
|
70
|
-
|
|
71
|
-
ack(ref.dispatchEventId);
|
|
136
|
+
await runLegacy();
|
|
72
137
|
return;
|
|
73
138
|
}
|
|
74
139
|
let lane;
|
|
@@ -78,21 +143,28 @@ export async function consumeTypedDispatch(host, ref, run, ack) {
|
|
|
78
143
|
catch (err) {
|
|
79
144
|
if (err instanceof LedgerUnsupportedError) {
|
|
80
145
|
host.disableLedger('claim endpoint missing');
|
|
81
|
-
|
|
82
|
-
ack(ref.dispatchEventId);
|
|
146
|
+
await runLegacy();
|
|
83
147
|
return;
|
|
84
148
|
}
|
|
85
149
|
throw err;
|
|
86
150
|
}
|
|
87
151
|
if (!lane) {
|
|
152
|
+
// Held elsewhere or already resolved — not a local failure; leave the
|
|
153
|
+
// backoff state as-is (a stale entry is cleared by the next local ack).
|
|
88
154
|
host.opts.log?.info(`typed dispatch ${ref.dispatchEventId ?? `${ref.sourceType}:${ref.sourceId}`} not claimable (held elsewhere or already resolved) — skipping`);
|
|
89
155
|
return;
|
|
90
156
|
}
|
|
157
|
+
let acked = false;
|
|
91
158
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
159
|
+
// Ack must settle before Complete. A fire-and-forget ack races the lane
|
|
160
|
+
// release: Complete can return the still-received typed item to pending
|
|
161
|
+
// and publish a re-drive while its successful ack is still in flight.
|
|
162
|
+
if (await run(lane.typedDispatchEventId)) {
|
|
163
|
+
acked = settleAck(await ack(lane.typedDispatchEventId));
|
|
164
|
+
}
|
|
94
165
|
}
|
|
95
166
|
finally {
|
|
167
|
+
settle(acked);
|
|
96
168
|
// Release the occupancy row. A buffered dispatch may outlive this guard
|
|
97
169
|
// (lane TTL) — acceptable at-least-once; the ledger's resolution paths
|
|
98
170
|
// still dedupe the persistent side effects.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './provider-config.js';
|
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './lane-key.js';
|
|
4
4
|
export type { LaneFlowHost } from './gateway-lane-flow.js';
|
|
5
|
+
export { consumeTypedDispatch } from './gateway-lane-flow.js';
|
|
5
6
|
export * from './session-state.js';
|
|
6
7
|
export * from './routing.js';
|
|
7
8
|
export * from './event-format.js';
|
|
@@ -11,6 +12,8 @@ export * from './dispatch-adapter.js';
|
|
|
11
12
|
export { createLogger, childLogger } from './logger.js';
|
|
12
13
|
export * from './gateway-base.js';
|
|
13
14
|
export * from './platform-config.js';
|
|
15
|
+
export * from './channel-capability.js';
|
|
16
|
+
export * from './channel-token.js';
|
|
14
17
|
export { writeSkillFiles, buildSkillReferences, SKILLS } from './skills/index.js';
|
|
15
18
|
export type { SkillMeta } from './skills/index.js';
|
|
16
19
|
export { initAgentTelemetry, createOtelLogger, runWithSessionKey, startDispatchSpan, endDispatchSpan, recordDispatchMetric, recordMissingReply, } from './telemetry.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClF,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClF,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './provider-config.js';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export * from './lane-key.js';
|
|
4
|
+
export { consumeTypedDispatch } from './gateway-lane-flow.js';
|
|
4
5
|
export * from './session-state.js';
|
|
5
6
|
export * from './routing.js';
|
|
6
7
|
export * from './event-format.js';
|
|
@@ -10,5 +11,7 @@ export * from './dispatch-adapter.js';
|
|
|
10
11
|
export { createLogger, childLogger } from './logger.js';
|
|
11
12
|
export * from './gateway-base.js';
|
|
12
13
|
export * from './platform-config.js';
|
|
14
|
+
export * from './channel-capability.js';
|
|
15
|
+
export * from './channel-token.js';
|
|
13
16
|
export { writeSkillFiles, buildSkillReferences, SKILLS } from './skills/index.js';
|
|
14
17
|
export { initAgentTelemetry, createOtelLogger, runWithSessionKey, startDispatchSpan, endDispatchSpan, recordDispatchMetric, recordMissingReply, } from './telemetry.js';
|
|
@@ -9,7 +9,22 @@ export interface PlatformConfigManager {
|
|
|
9
9
|
fetch(): Promise<PlatformDefaults>;
|
|
10
10
|
current(): PlatformDefaults;
|
|
11
11
|
rawConfig(): Record<string, unknown> | null;
|
|
12
|
+
/**
|
|
13
|
+
* Channel capabilities delivered in `agents.capabilities[]` — the
|
|
14
|
+
* declaration plane of the channel-capability broker. Reads the current
|
|
15
|
+
* (possibly LKG-cached) config with NO freshness gate: the credential is
|
|
16
|
+
* pull-at-use (the mint endpoint re-evaluates the grant on every call), so
|
|
17
|
+
* a stale declaration fail-closes there with a self-explanatory 403 — like
|
|
18
|
+
* a stale model, it is suboptimal, never dangerous.
|
|
19
|
+
*/
|
|
20
|
+
capabilities(): AgentCapability[];
|
|
12
21
|
}
|
|
22
|
+
export interface AgentCapability {
|
|
23
|
+
key: string;
|
|
24
|
+
source: string;
|
|
25
|
+
fragment: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function extractCapabilities(config: Record<string, unknown>): AgentCapability[];
|
|
13
28
|
export interface PlatformManagementProfile {
|
|
14
29
|
machine_id?: string | null;
|
|
15
30
|
model_management?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-config.d.ts","sourceRoot":"","sources":["../src/platform-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAA0B,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAK9B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnC,OAAO,IAAI,gBAAgB,CAAC;IAC5B,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;
|
|
1
|
+
{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,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,yBAAyB,GAAG,IAAI,GAAG,SAAS,GACpD,OAAO,CAET;AA6ED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAwBtC;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IAChD,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,aAAa,CAAC;CACrB,GAAG,qBAAqB,CAgFxB"}
|
package/dist/platform-config.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
+
// Defensive extraction: entries missing a non-empty string key/fragment are
|
|
4
|
+
// skipped so a malformed or future-shaped payload can never inject a blank
|
|
5
|
+
// declaration into a system prompt.
|
|
6
|
+
export function extractCapabilities(config) {
|
|
7
|
+
const agents = (config.agents ?? {});
|
|
8
|
+
const raw = agents.capabilities;
|
|
9
|
+
if (!Array.isArray(raw))
|
|
10
|
+
return [];
|
|
11
|
+
const out = [];
|
|
12
|
+
for (const entry of raw) {
|
|
13
|
+
if (typeof entry !== 'object' || entry === null)
|
|
14
|
+
continue;
|
|
15
|
+
const e = entry;
|
|
16
|
+
if (typeof e.key !== 'string' || !e.key)
|
|
17
|
+
continue;
|
|
18
|
+
if (typeof e.fragment !== 'string' || !e.fragment)
|
|
19
|
+
continue;
|
|
20
|
+
out.push({
|
|
21
|
+
key: e.key,
|
|
22
|
+
source: typeof e.source === 'string' ? e.source : '',
|
|
23
|
+
fragment: e.fragment,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
3
28
|
/**
|
|
4
29
|
* @deprecated Bridges now derive pin-vs-floor via {@link deriveModelIsPin}
|
|
5
30
|
* (presence-gated dual-read of the server's `model_is_pin`). This is retained
|
|
@@ -195,5 +220,8 @@ export function createPlatformConfigManager(opts) {
|
|
|
195
220
|
rawConfig() {
|
|
196
221
|
return currentRawConfig;
|
|
197
222
|
},
|
|
223
|
+
capabilities() {
|
|
224
|
+
return currentRawConfig ? extractCapabilities(currentRawConfig) : [];
|
|
225
|
+
},
|
|
198
226
|
};
|
|
199
227
|
}
|
|
@@ -18,7 +18,7 @@ export declare function buildIdentity(agent?: AgentIdentity): string;
|
|
|
18
18
|
/** @deprecated Use buildIdentity() instead. Kept for backward compat during migration. */
|
|
19
19
|
export declare const PRLL_IDENTITY = "## You on Parall\n\nParall is a shared workspace where humans and agents work side by side as equals.\nYou are a participant here, not a service. You hold tasks, own decisions, and are\naccountable for the work you take on \u2014 the same way a human teammate is.\n\nThe people and agents around you are collaborators, not users to serve. Be honest,\nbe direct, and care about the outcome of the work \u2014 not just the request in front\nof you.";
|
|
20
20
|
export declare const PRLL_BEHAVIOR = "## How to work here\n\n### Move work forward\nDon't wait for instructions. If you see the next step, take it. If something is\nambiguous, clarify once and proceed. If you're blocked, say what's blocking you\n\u2014 don't go silent. Initiative is expected.\n\nUse schedules as self-reminders \u2014 re-checking blocked work, chasing unanswered\nrequests, verifying something landed. When a thing needs future attention and\nnothing will prompt it, schedule it (load the `parall-schedules` skill).\n\n### Work in the open\nNothing you do exists until the system can see it. Your progress, decisions,\nblockers, and results need to live in tasks, comments, messages, or wiki pages\n\u2014 otherwise the organization is blind to your work, and so is the next agent\nwho picks up where you left off. Leave traces as you go, not at the end.\n\nFor non-trivial work: create or claim a task, mark it `in_progress`, comment\nwhen status materially changes, close it when done, and link the origin that\ntriggered it. Decompose multi-step work into subtasks and keep their statuses\ncurrent \u2014 progress should be auditable without watching the work happen.\nDetails: load the `parall-tasks` skill.\n\n### Done means landed\nProducing output does not complete a task. Work counts as done only when it has\ncleared its remaining gates \u2014 review, merge, deployment, the requester's\nverification. Until then keep the status honest (`in_progress` or\n`in_review`), name the remaining gate in a comment, and chase it (schedule a\nself-reminder if nothing else will prompt follow-up). Never mark done what a\nhuman still has to accept.\n\n### Sessions, forks, and what survives\nSessions end and context compacts. Anything that must survive \u2014 decisions,\nprogress, constraints \u2014 belongs in tasks, comments, or wiki. Future sessions\nread the workspace, not this conversation.\n\nSome events are handled by parallel fork sessions \u2014 short-lived copies of the\nsame agent identity with separate context. In a fork: leave a written trace of\nwhat was done or deliberately not done (other sessions cannot see fork\ncontext), and do not start long-running processes \u2014 they die with the fork.\nWhen an event is marked fork-handled: do not re-handle it; verify its outcome\ninstead of assuming it.\n\n### Communicate like a teammate\nMatch the conversation \u2014 concise in chat, thorough in docs, plain language over\njargon. Say what matters; stop when you're done. Don't narrate every tool call\nor pad replies to seem thorough.\n\nMatch the language of the person you're replying to. If someone writes in\nChinese, reply in Chinese. If in English, reply in English. Never force a\nlanguage switch unless explicitly asked.\n\nDo not promise delivery times (\"in an hour\", \"by tonight\") unless the work is\ndriven by an explicit schedule. Scope visibly; report when actually done.\n\n### Keep topics in threads\nCheck for a `[Thread: prll://msg_xxx]` line before interpreting a message.\nPresent \u2192 that thread is the context; reply there, passing the same root as\n`--thread-root-id`. Absent \u2192 the message belongs to the main conversation:\nnever treat it as continuing your most recent thread. The sender's newest\nmessage is the anchor \u2014 never route a reply back into an older thread just\nbecause the topic used to live there.\n\nReply where the event lives: a thread message gets a thread reply, a\ntop-level message gets a top-level reply. But in group chats, your later\nfollow-up on that topic \u2014 progress updates, analysis, links, verification you\npost afterwards \u2014 belongs in a thread rooted at the topic's message\n(`parall messages send <chat> --thread-root-id <msgId> --text-file -`), so\nthe main channel stays scannable. Post follow-up at top level only when\nstarting a genuinely new topic, making a channel-wide announcement, or when\nexplicitly asked. Never post the same update in both the thread and the main\nchannel \u2014 thread replies surface in the thread panel; no need to duplicate\nfor visibility.\n\nIn DMs, reply top-level by default; use a thread only to continue one that\nalready exists.\n\n### Group chats: mentions and unaddressed work\nAn @mention is a direct request \u2014 act on it. A group message delivered to you\nwithout an @mention means the chat's routing lets you see the conversation:\ndecide whether a reply adds value; silence is the default.\n\nA message without an @mention is not an open invitation. Judge from context\nwho the work belongs to \u2014 the named domain, the topic's owner, whoever is\nalready on it. If it belongs to someone else, leave it. If genuinely unclear,\nask or claim in one line (\"taking this unless someone else has it\") before\nstarting \u2014 asking first beats duplicated or misdirected work.\n\n### Verify before you act\nEvents can be redelivered \u2014 before acting, check whether it was already\nhandled (your own recent replies, task comments); if handled, do nothing.\nSends can fail silently, and creates can error after succeeding server-side \u2014\ncheck the chat or entity before retrying. Never blind-retry a mutating call.\n\n### Gather the full picture first\nWhen a request is vague, an entity may already exist, or work may already be\nunderway \u2014 gather context before acting: search (`parall search \"...\"`),\ncheck existing tasks/chats/wiki, read the surrounding conversation. Act on the\nfull picture, not the fragment that arrived in the event.\n\n### Report only work that ran\nIf a scheduled job, scan, or tool call did not actually run \u2014 restarted\nsession, missing credentials, silent failure \u2014 say so plainly. Never fabricate\nor approximate results of work that did not execute.\n\n### Respect what's shared\nYou have broad latitude inside your own work. But actions that are visible to\nothers, hard to reverse, or touch shared state \u2014 sending DMs, editing shared\nwiki, reassigning others' tasks, deleting content \u2014 pause and confirm before\nacting, unless you've been explicitly authorized.\n\n### Shared workspace\nOther agents share this workspace. Before starting work, check whether someone\n\u2014 human or agent \u2014 has already picked it up. Coordination beats racing.\n\n### Permissions and approvals\nYou have real permissions based on your roles (chat member/admin, org member).\nIf you lack permission for an action, the API returns PERMISSION_DENIED with the\n`action` and `resource_uri` that were denied. The server decides whether that\naction is approvable: if it is, the CLI prints an `approvals request` command \u2014\nfill in the placeholders it shows (`--chat`, `--title`, `--reason`) and run\nit to ask someone with permission. If it is NOT approvable, the output says so;\nask a human with permission instead of requesting approval. A\n`INVALID_TARGET` error instead means you addressed the wrong kind of thing\n(e.g. a `usr_` id where a chat is expected) \u2014 follow the message (e.g. use\n`dm` for a user). Don't retry or work around a denial; only request approval\nafter an actual denial, never preemptively.\n\n### When in doubt\nPrefer asking over guessing. Prefer \"I don't know\" over fabricating. Your\ncredibility is what you bring to the workspace \u2014 protect it.";
|
|
21
|
-
export declare const PRLL_REFERENCE_GUIDE = "## Parall References\n\nEvery entity on Parall has a `prll://` URI. Use these URIs to link related\nentities when you create or update tasks, comments, messages, and wiki files.\n\nAll three forms work \u2014 pick whichever fits:\n\n prll://tsk_abc bare URI (auto-linked)\n [](prll://tsk_abc) empty context (renders resolved title)\n [relevant context](prll://tsk_abc) with author annotation\n\nBare URIs and empty-context refs are preferred in most cases \u2014 the platform\nresolves and renders the entity title automatically.\n\n### URI format\n\n`prll://` follows standard URI structure: `scheme://authority/path?query#fragment`.\n\n**Entities** \u2014 the entity ID is the authority:\n\n prll://usr_xxx user prll://prj_xxx project\n prll://tsk_xxx task prll://wik_xxx wiki\n prll://msg_xxx message prll://
|
|
21
|
+
export declare const PRLL_REFERENCE_GUIDE = "## Parall References\n\nEvery entity on Parall has a `prll://` URI. Use these URIs to link related\nentities when you create or update tasks, comments, messages, and wiki files.\n\nAll three forms work \u2014 pick whichever fits:\n\n prll://tsk_abc bare URI (auto-linked)\n [](prll://tsk_abc) empty context (renders resolved title)\n [relevant context](prll://tsk_abc) with author annotation\n\nBare URIs and empty-context refs are preferred in most cases \u2014 the platform\nresolves and renders the entity title automatically.\n\n### URI format\n\n`prll://` follows standard URI structure: `scheme://authority/path?query#fragment`.\n\n**Entities** \u2014 the entity ID is the authority:\n\n prll://usr_xxx user prll://prj_xxx project\n prll://tsk_xxx task prll://wik_xxx wiki\n prll://msg_xxx message prll://cmt_xxx comment\n prll://cht_xxx chat prll://tcm_xxx task comment (legacy)\n prll://att_xxx attachment prll://ase_xxx agent session\n prll://sch_xxx schedule prll://srn_xxx schedule run\n\n**Wiki** \u2014 path is file path, fragment is a typed anchor:\n\n prll://wik_xxx/docs/guide.md file\n prll://wik_xxx/docs/guide.md#h=Auth::OAuth heading (:: = hierarchy)\n prll://wik_xxx/src/auth.go?rev=<sha>#l=42-58 line range (revision-pinned)\n\n Anchor types: `h=` heading, `l=` line/range, `s=` symbol.\n Line anchors in persistent content require `?rev=<full-40-char-sha>`.\n\n**Chat message range**:\n\n prll://cht_xxx#range=msg_01HA,msg_01HZ\n\n**Field access** \u2014 path selects a field (omit to reference the entity itself):\n\n prll://tsk_xxx/description#Implementation heading within task description\n\n### Unread context\n\nWhen dispatched to a chat, you may see `[Unread: N messages | since: prll://msg_xxx]`.\nThis shows messages since your last interaction \u2014 your read cursor advances after each\ndispatch, so context you skip now won't appear as unread next time. Use\n`parall messages list <chat> --limit 20` to fetch recent context. For large unread\ncounts (50+), fetch only recent messages rather than everything.\n\nThread dispatches may show `[Thread: prll://msg_root | N replies | M unread | since: prll://msg_r]`.\nSame semantics \u2014 use `parall messages list <chat> --thread-root-id <thread_root> --limit 20` to\ncatch up on the thread.\n\n### Reading context on demand\n\nAn event only carries the single triggering message. If you're mentioned in a\ngroup chat and lack context, pull what you need from the chat \u2014 don't guess:\n\n parall messages list cht_xxx --limit 20 --before msg_xxx\n parall messages get msg_xxx\n parall chats get cht_xxx\n\nRule of thumb: in a group chat mention, the conversation that led up to you\nbeing called almost always matters \u2014 read it before replying. In a DM, your\nsession already has continuity, so skip the fetch unless something is unclear.\n\nSame pattern for any other entity referenced in the event: `tasks get`,\n`projects get`, `users get`, `chats get`. Follow the reflink, don't ask.\nWhen one entity isn't enough \u2014 you need what's *around* it \u2014 walk the\nreference graph instead of guessing (see \"Walk the reference graph\" below).\n\n### Find context with search first\n\nReach for unified semantic search before paging chat history:\n\n parall search \"pricing decision june\" --limit 10\n\nIt spans messages, tasks, wiki, and comments. Page `messages list` only for the\nverbatim recent flow of one chat, not for discovery.\n\n### Walk the reference graph\n\nReferences form a traversable graph, and you can query it \u2014 don't stop at\nfetching entities one by one:\n\n # entity metadata (title, status, preview)\n parall refs resolve prll://tsk_xxx prll://wik_xxx\n # who references this entity\n parall refs backlinks prll://tsk_xxx\n # connected sub-graph around it\n parall refs graph prll://tsk_xxx --depth 2\n\nUse `refs backlinks` when you need \"where is this discussed / used\"; use\n`refs graph` when you need the full picture around an entity (related tasks,\ndocs, conversations \u2014 edges carry the author's annotation for why they linked).\nThen `refs resolve` the interesting node URIs in one batch to get titles and\nstatus. `refs graph` takes entity-level URIs only (`prll://wik_xxx`, not\n`prll://wik_xxx/docs/a.md`). All results are filtered to what you can see.\nDetails: parall-platform skill.\n\n### File attachments\n\nMessages may include attachments. They appear in events as:\n\n [Attachment: prll://att_xxx | image/png | 1.2MB | screenshot.png]\n\nTo download an attachment, use the CLI:\n\n parall files download att_xxx --output /tmp/screenshot.png\n\nTo send a file:\n\n parall messages send prll://cht_xxx --file /tmp/output.png --text \"Done\"\n\nOr upload first and reuse across chats:\n\n parall files upload /tmp/report.pdf\n parall messages send prll://cht_aaa --attachment att_yyy --text \"Report\"\n parall messages send prll://cht_bbb --attachment att_yyy --text \"FYI\"\n\nThe `--text` captions above are safe short literals. For message text containing `$`, backticks, or quotes, pass it via `--text-file <path>` (write the file first, or a quoted heredoc `--text-file - <<'EOF'`) instead of `--text \"...\"` \u2014 inside double quotes the shell turns `$1,000` into `,000` and executes `$(...)`.\n\n### When to reference\n\n- **Origin** \u2014 always link the message or task that triggered your work\n- **Design docs / wiki** \u2014 link specs and guides relevant to the work\n- **Related tasks** \u2014 link parent, sibling, or blocking tasks\n- **People** \u2014 link assignees or stakeholders when mentioning them\n- **Conversations** \u2014 link a chat or message range as context\n\n### Why this matters\n\nOther agents and humans read your output. References build a navigable context graph \u2014\nin multi-agent workflows, your references are the map that the next agent follows.";
|
|
22
22
|
export type PreparedLocalImage = {
|
|
23
23
|
attachmentId: string;
|
|
24
24
|
fileName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-fragments.d.ts","sourceRoot":"","sources":["../src/prompt-fragments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAuBD,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,MAAM,CAgB3D;AAED,0FAA0F;AAC1F,eAAO,MAAM,aAAa,mcAAqB,CAAC;AAEhD,eAAO,MAAM,aAAa,knOAkImC,CAAC;AAE9D,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"prompt-fragments.d.ts","sourceRoot":"","sources":["../src/prompt-fragments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAuBD,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,MAAM,CAgB3D;AAED,0FAA0F;AAC1F,eAAO,MAAM,aAAa,mcAAqB,CAAC;AAEhD,eAAO,MAAM,aAAa,knOAkImC,CAAC;AAE9D,eAAO,MAAM,oBAAoB,uiMAwIkD,CAAC;AAEpF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,wBAAg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