@capybara-hq/kernel 0.1.0-rc.24 → 0.1.0-rc.26
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/admin/admin.module.js +2 -0
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +6 -2
- package/dist/admin/outbox-dead.service.d.ts +7 -3
- package/dist/admin/outbox-dead.service.js +17 -6
- package/dist/admin/overview.service.d.ts +6 -6
- package/dist/admin/overview.service.js +7 -7
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.service.d.ts +6 -1
- package/dist/agents/agents.service.js +11 -2
- package/dist/background/wake-rules.d.ts +5 -0
- package/dist/background/wake-rules.js +16 -5
- package/dist/catalog/catalog-import.module.js +0 -4
- package/dist/catalog/catalog-scope.service.d.ts +63 -26
- package/dist/catalog/catalog-scope.service.js +146 -71
- package/dist/catalog/catalog.module.js +4 -3
- package/dist/catalog/catalog.service.d.ts +11 -4
- package/dist/catalog/catalog.service.js +21 -5
- package/dist/catalog/cli.d.ts +4 -3
- package/dist/catalog/cli.js +8 -13
- package/dist/catalog/job-ids.d.ts +8 -20
- package/dist/catalog/job-ids.js +11 -16
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-plugin-uploads.d.ts +11 -4
- package/dist/catalog/org-plugin-uploads.js +21 -6
- package/dist/catalog/owned-items.d.ts +6 -13
- package/dist/catalog/owned-items.js +11 -29
- package/dist/catalog/owned-plugin-cleanup.d.ts +8 -17
- package/dist/catalog/owned-plugin-cleanup.js +12 -66
- package/dist/catalog/platform-components.d.ts +56 -34
- package/dist/catalog/platform-components.js +68 -78
- package/dist/catalog/plugin-import.d.ts +28 -25
- package/dist/catalog/plugin-import.js +90 -76
- package/dist/catalog/plugin-upgrade.d.ts +4 -4
- package/dist/catalog/plugin-upgrade.js +7 -19
- package/dist/catalog/scope-jobs.d.ts +59 -0
- package/dist/catalog/scope-jobs.js +65 -0
- package/dist/catalog/scope-sync-workers.d.ts +22 -0
- package/dist/catalog/scope-sync-workers.js +58 -2
- package/dist/catalog/scope-sync.d.ts +40 -65
- package/dist/catalog/scope-sync.js +114 -122
- package/dist/channels/channels.module.d.ts +9 -8
- package/dist/channels/channels.module.js +11 -10
- package/dist/channels/connections.service.d.ts +3 -3
- package/dist/channels/connections.service.js +6 -6
- package/dist/channels/deliver-job.d.ts +10 -3
- package/dist/channels/deliver-job.js +7 -3
- package/dist/channels/inbound.js +2 -2
- package/dist/channels/jobs.d.ts +11 -4
- package/dist/channels/jobs.js +18 -3
- package/dist/channels/outbound.d.ts +5 -2
- package/dist/channels/outbound.js +9 -2
- package/dist/channels/threads.d.ts +4 -3
- package/dist/channels/threads.js +4 -3
- package/dist/conversations/conversations.controller.d.ts +4 -2
- package/dist/conversations/conversations.controller.js +8 -4
- package/dist/conversations/conversations.service.d.ts +54 -9
- package/dist/conversations/conversations.service.js +94 -25
- package/dist/conversations/events.d.ts +27 -0
- package/dist/conversations/events.js +30 -1
- package/dist/conversations/source.d.ts +10 -0
- package/dist/conversations/source.js +17 -0
- package/dist/conversations/tree.d.ts +10 -0
- package/dist/conversations/tree.js +35 -0
- package/dist/db/kernel-schema.d.ts +19 -15
- package/dist/devices/devices.service.d.ts +25 -14
- package/dist/devices/devices.service.js +36 -30
- package/dist/evals/evals.module.js +5 -1
- package/dist/evals/jobs.d.ts +14 -6
- package/dist/evals/jobs.js +21 -19
- package/dist/evals/run-replay.d.ts +13 -2
- package/dist/evals/run-replay.js +28 -1
- package/dist/evals/runs.service.d.ts +5 -6
- package/dist/evals/runs.service.js +11 -33
- package/dist/evals/snapshot.d.ts +7 -1
- package/dist/evals/snapshot.js +2 -1
- package/dist/extensions/hooks.d.ts +22 -3
- package/dist/extensions/hooks.js +15 -1
- package/dist/extensions/lifecycle-hooks.d.ts +99 -0
- package/dist/extensions/lifecycle-hooks.js +273 -0
- package/dist/extensions/org-config.d.ts +13 -1
- package/dist/extensions/org-config.js +19 -2
- package/dist/extensions/permission-view.d.ts +9 -5
- package/dist/extensions/permission-view.js +9 -4
- package/dist/extensions/point-defaults.d.ts +28 -1
- package/dist/extensions/point-defaults.js +44 -13
- package/dist/inbox/inbox.service.d.ts +6 -20
- package/dist/inbox/inbox.service.js +0 -3
- package/dist/inbox/org-notices.d.ts +1 -1
- package/dist/inbox/platform-inbox.service.d.ts +3 -32
- package/dist/inbox/platform-inbox.service.js +5 -54
- package/dist/infra/outbox/outbox.service.d.ts +6 -0
- package/dist/infra/outbox/outbox.service.js +51 -17
- package/dist/infra/outbox/registry.d.ts +176 -0
- package/dist/infra/outbox/registry.js +183 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -0
- package/dist/local-devices/device-policy.service.d.ts +131 -26
- package/dist/local-devices/device-policy.service.js +341 -145
- package/dist/local-devices/machines.d.ts +17 -2
- package/dist/local-devices/machines.js +66 -5
- package/dist/local-devices/policy-op-jobs.d.ts +15 -0
- package/dist/local-devices/policy-op-jobs.js +12 -0
- package/dist/local-devices/policy-summary.d.ts +36 -3
- package/dist/local-devices/policy-summary.js +47 -1
- package/dist/orgs/directory-sync.js +1 -1
- package/dist/orgs/members.service.js +1 -1
- package/dist/orgs/offboarding.d.ts +50 -57
- package/dist/orgs/offboarding.js +117 -162
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.service.d.ts +11 -5
- package/dist/orgs/orgs.service.js +19 -7
- package/dist/overrides.d.ts +7 -0
- package/dist/overrides.js +4 -0
- package/dist/platform/ops/conversations.ops.js +1 -1
- package/dist/platform/ops/inbox.ops.js +4 -20
- package/dist/platform/ops/platform.ops.d.ts +1 -0
- package/dist/platform/ops/platform.ops.js +6 -3
- package/dist/roles/worker-role.d.ts +10 -5
- package/dist/roles/worker-role.js +19 -9
- package/dist/roles/worker.module.js +2 -4
- package/dist/runtime/context/build.d.ts +3 -0
- package/dist/runtime/context/build.js +15 -0
- package/dist/runtime/context/plugin-context.d.ts +20 -0
- package/dist/runtime/context/plugin-context.js +30 -0
- package/dist/runtime/langgraph-loop.js +4 -0
- package/dist/runtime/loop.d.ts +8 -0
- package/dist/runtime/maintenance.d.ts +9 -4
- package/dist/runtime/maintenance.js +52 -13
- package/dist/runtime/model-call.d.ts +6 -1
- package/dist/runtime/model-call.js +1 -0
- package/dist/runtime/plugin-context.service.d.ts +75 -0
- package/dist/runtime/plugin-context.service.js +220 -0
- package/dist/runtime/run-context.service.d.ts +7 -3
- package/dist/runtime/run-context.service.js +12 -2
- package/dist/runtime/run-control.d.ts +6 -1
- package/dist/runtime/run-control.js +13 -0
- package/dist/runtime/run-finish.d.ts +2 -2
- package/dist/runtime/run-finish.js +11 -6
- package/dist/runtime/run-jobs.d.ts +21 -4
- package/dist/runtime/run-jobs.js +29 -6
- package/dist/runtime/run-orphan-check.job.d.ts +14 -11
- package/dist/runtime/run-orphan-check.job.js +16 -11
- package/dist/runtime/run-queue.d.ts +29 -24
- package/dist/runtime/run-queue.js +118 -57
- package/dist/runtime/run-status.d.ts +12 -0
- package/dist/runtime/run-status.js +21 -0
- package/dist/runtime/run-worker.d.ts +32 -3
- package/dist/runtime/run-worker.js +143 -21
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/step-log.d.ts +6 -5
- package/dist/runtime/step-log.js +6 -5
- package/dist/runtime/subagents/dispatch.js +1 -0
- package/dist/runtime/subagents/skill-fork.js +3 -0
- package/dist/runtime/usage-report.d.ts +3 -1
- package/dist/runtime/usage-report.js +4 -2
- package/dist/runtime/waits.d.ts +16 -6
- package/dist/runtime/waits.js +37 -15
- package/dist/sandbox/jobs.d.ts +20 -10
- package/dist/sandbox/jobs.js +23 -17
- package/dist/schedules/fire.d.ts +25 -4
- package/dist/schedules/fire.js +87 -13
- package/dist/schedules/job-ids.d.ts +66 -17
- package/dist/schedules/job-ids.js +81 -13
- package/dist/schedules/run-tracker.js +2 -1
- package/dist/schedules/scan.job.d.ts +16 -35
- package/dist/schedules/scan.job.js +38 -147
- package/dist/schedules/scheduled-tasks.service.d.ts +6 -6
- package/dist/schedules/scheduled-tasks.service.js +17 -14
- package/dist/schedules/schedules.module.js +0 -4
- package/dist/skills/catalog.d.ts +7 -3
- package/dist/skills/catalog.js +12 -2
- package/dist/skills/changes.controller.d.ts +1 -1
- package/dist/skills/changes.controller.js +1 -1
- package/dist/tools/approvals.service.d.ts +111 -23
- package/dist/tools/approvals.service.js +326 -77
- package/dist/tools/builtins/sandbox/task-output.js +21 -6
- package/dist/tools/device-op-resolver.d.ts +40 -0
- package/dist/tools/device-op-resolver.js +121 -0
- package/dist/tools/network-asks.d.ts +1 -1
- package/dist/tools/network-asks.js +4 -3
- package/dist/tools/pipeline.d.ts +11 -2
- package/dist/tools/pipeline.js +5 -0
- package/dist/tools/questions.service.d.ts +15 -4
- package/dist/tools/questions.service.js +21 -19
- package/dist/tools/registry.d.ts +8 -1
- package/dist/tools/registry.js +9 -0
- package/dist/tools/tools.module.js +4 -0
- package/package.json +3 -3
- package/src/migrations/0121_drop_platform_migration_runs.sql +12 -0
- package/src/migrations/0122_drop_scheduled_task_runs_rechecked_at.sql +5 -0
- package/src/migrations/0123_pgvector.sql +27 -0
- package/src/migrations/0124_conversation_source.sql +36 -0
- package/src/migrations/0125_conversation_tree_stopped_at.sql +5 -0
- package/dist/catalog/platform-migration.d.ts +0 -115
- package/dist/catalog/platform-migration.js +0 -583
- package/dist/infra/queue/add-job-once.d.ts +0 -14
- package/dist/infra/queue/add-job-once.js +0 -16
|
@@ -6,7 +6,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
6
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
7
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
8
8
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
9
|
-
import { DevicePolicyService } from "../local-devices/device-policy.service.js";
|
|
9
|
+
import { DevicePolicyService, type PolicyOpResult } from "../local-devices/device-policy.service.js";
|
|
10
10
|
import { type OrgRole } from "../orgs/roles.js";
|
|
11
11
|
import { RunResume } from "../runtime/run-jobs.js";
|
|
12
12
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
@@ -47,7 +47,6 @@ export interface NetworkAskDetail {
|
|
|
47
47
|
};
|
|
48
48
|
/** The hosts the decision allowed (every approved decision writes them; none: nothing). */
|
|
49
49
|
grantedHosts?: string[];
|
|
50
|
-
/** What took effect: a run grant, the device's policy, or a run grant because the device did not apply it. */
|
|
51
50
|
/**
|
|
52
51
|
* What took effect: a run grant (`once`), the device's policy (`always`), a run grant because
|
|
53
52
|
* the device could not be reached or lacks the feature (`once_fallback`), or nothing because the
|
|
@@ -56,6 +55,22 @@ export interface NetworkAskDetail {
|
|
|
56
55
|
outcome?: "once" | "always" | "once_fallback" | "refused";
|
|
57
56
|
/** Why 「一直允许」 did not reach the device's policy. */
|
|
58
57
|
fallback?: "offline" | "refused" | "unsupported";
|
|
58
|
+
/**
|
|
59
|
+
* Set while the ask is still pending: the last 「一直允许」 whose device change was recorded only
|
|
60
|
+
* after a crash (transactional outbox spec §7.4) and did not take effect: `failed` (the device
|
|
61
|
+
* refused it, never received it or stopped while applying it) or `unknown` (the device did not
|
|
62
|
+
* answer; its next connection tells), with the reason. The owner may decide again.
|
|
63
|
+
*/
|
|
64
|
+
attempt?: NetworkAskAttempt;
|
|
65
|
+
}
|
|
66
|
+
/** Why a pending network ask's last 「一直允许」 did not decide it ({@link NetworkAskDetail.attempt}). */
|
|
67
|
+
export interface NetworkAskAttempt {
|
|
68
|
+
/**
|
|
69
|
+
* `applied_undecided`: the device applied the change, but the account that chose it can no
|
|
70
|
+
* longer decide this ask (someone else must).
|
|
71
|
+
*/
|
|
72
|
+
outcome: "failed" | "unknown" | "applied_undecided";
|
|
73
|
+
message: string;
|
|
59
74
|
}
|
|
60
75
|
/** A network ask's detail as the API shows it: without the kept command result. */
|
|
61
76
|
export type NetworkAskView = Omit<NetworkAskDetail, "result">;
|
|
@@ -189,7 +204,7 @@ export interface NetworkAskInput {
|
|
|
189
204
|
callId: string;
|
|
190
205
|
/** The device owner: the only person who may decide. */
|
|
191
206
|
requestedFor: string;
|
|
192
|
-
detail: Omit<NetworkAskDetail, "grantedHosts" | "outcome" | "fallback">;
|
|
207
|
+
detail: Omit<NetworkAskDetail, "grantedHosts" | "outcome" | "fallback" | "attempt">;
|
|
193
208
|
/** `["once", "always"]`, or `["once"]` when the device takes no remote grants. */
|
|
194
209
|
scopes: ("once" | "always")[];
|
|
195
210
|
}
|
|
@@ -223,7 +238,10 @@ export declare class ApprovalsService {
|
|
|
223
238
|
private readonly schedules;
|
|
224
239
|
/** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
|
|
225
240
|
private readonly registry;
|
|
226
|
-
/**
|
|
241
|
+
/**
|
|
242
|
+
* 「这台设备一直允许」 records the device change's intent, sends the `policy` op, then records
|
|
243
|
+
* its outcome with the decision.
|
|
244
|
+
*/
|
|
227
245
|
private readonly policies;
|
|
228
246
|
/** One decision of a network ask at a time, across replicas (the op is sent before the transaction). */
|
|
229
247
|
readonly lockService: LockService;
|
|
@@ -234,8 +252,11 @@ export declare class ApprovalsService {
|
|
|
234
252
|
constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, eventLog: Pick<EventLog, "appendIn" | "notify">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost, schedules: Pick<ScheduledTaskStore, "addGrant">,
|
|
235
253
|
/** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
|
|
236
254
|
registry: Pick<ToolRegistry, "forAgent">,
|
|
237
|
-
/**
|
|
238
|
-
|
|
255
|
+
/**
|
|
256
|
+
* 「这台设备一直允许」 records the device change's intent, sends the `policy` op, then records
|
|
257
|
+
* its outcome with the decision.
|
|
258
|
+
*/
|
|
259
|
+
policies: Pick<DevicePolicyService, "begin" | "send" | "settleIn" | "summary">,
|
|
239
260
|
/** One decision of a network ask at a time, across replicas (the op is sent before the transaction). */
|
|
240
261
|
lockService: LockService,
|
|
241
262
|
/** A trial run's 「这次允许」 becomes a task grant only within the org's egress. */
|
|
@@ -272,28 +293,84 @@ export declare class ApprovalsService {
|
|
|
272
293
|
* A network ask's decision (network ask-to-allow spec §5.2), one at a time per ask across
|
|
273
294
|
* replicas: only the device owner (`requested_for`) decides, in a signed-in session (a personal
|
|
274
295
|
* access token is refused; the route already refuses service and embed tokens); the allowed
|
|
275
|
-
* hosts are a subset of those asked. 「这台设备一直允许」
|
|
276
|
-
*
|
|
277
|
-
* as a run grant with the reason, and when the device refuses (its owner takes no
|
|
278
|
-
* as `always` with outcome `refused` and nothing granted
|
|
279
|
-
*
|
|
280
|
-
*
|
|
296
|
+
* hosts are a subset of those asked. 「这台设备一直允许」 goes through the device change's intent
|
|
297
|
+
* ({@link decideAlways}): when the device cannot be reached or lacks the feature the decision is
|
|
298
|
+
* recorded as a run grant with the reason, and when the device refuses (its owner takes no
|
|
299
|
+
* remote grants) as `always` with outcome `refused` and nothing granted; the decision and the
|
|
300
|
+
* op's outcome are one transaction. Every decision resumes the run in its transaction and is
|
|
301
|
+
* announced after the commit; a change the device applied after the ask closed is audited
|
|
302
|
+
* (`late`) and answered with a 409 that says so.
|
|
281
303
|
*/
|
|
282
304
|
private decideNetwork;
|
|
283
|
-
/** `device.network_allowed` of a policy change that reached the device after the ask closed. */
|
|
284
|
-
private auditLateAllow;
|
|
285
|
-
/** The owner of a live device of the org (null: none, deleted, or of another org). */
|
|
286
|
-
private deviceOwnerOf;
|
|
287
305
|
/**
|
|
288
|
-
*
|
|
289
|
-
*
|
|
306
|
+
* 「这台设备一直允许」 (transactional outbox spec §7): the intent of the device change (naming the
|
|
307
|
+
* ask) is recorded, the `policy` op sent (no transaction open), then {@link settleNetworkOp}
|
|
308
|
+
* decides the ask and records the op's outcome in one transaction. When nothing could be sent
|
|
309
|
+
* (the device is offline, deleted, or its program lacks the feature) the decision is a run
|
|
310
|
+
* grant with the reason. The device's answer decides: applied → `always`; refused → `always`
|
|
311
|
+
* with outcome `refused`, nothing granted; no answer → a run grant (`once_fallback`, `offline`)
|
|
312
|
+
* while the op stays `unknown` for the machine's next hello or the resolver. A device that
|
|
313
|
+
* reconnects during the call and reports the op applied lets the resolver approve the ask as
|
|
314
|
+
* this owner first: that decision is returned (`toSeq` null: already announced), never a 409;
|
|
315
|
+
* when it granted other hosts than this call's (another of the owner's changes) and this call's
|
|
316
|
+
* change was not confirmed, `approval.already_decided` says so. A device deleted during the
|
|
317
|
+
* call is `device.not_found` (the op recorded unknown).
|
|
318
|
+
*/
|
|
319
|
+
private decideAlways;
|
|
320
|
+
/** Records only the op's outcome, in its own transaction (the ask is left as it is). */
|
|
321
|
+
private settleOpOnly;
|
|
322
|
+
/**
|
|
323
|
+
* The resolve transaction of a network ask's device change: the ask decided as `network` says
|
|
324
|
+
* ({@link decideTx}: lock order conversation → approval → run), then the op's outcome recorded
|
|
325
|
+
* (`DevicePolicyService.settleIn`: the machine's row). When the ask closed meanwhile (a reply,
|
|
326
|
+
* the expiry, a stop) only the op's outcome is recorded, and a change the device applied is
|
|
327
|
+
* audited `device.network_allowed` with `late: true` in the same transaction.
|
|
290
328
|
*/
|
|
291
|
-
private
|
|
329
|
+
private settleNetworkOp;
|
|
330
|
+
/**
|
|
331
|
+
* The op's outcome for an ask that is no longer pending (in the caller's transaction): recorded,
|
|
332
|
+
* and a change the device applied audited `device.network_allowed` `late` (the change stands:
|
|
333
|
+
* the owner chose it; no inverse change is sent). True when it was audited late. `undecided`:
|
|
334
|
+
* the ask is still pending but the op's account can no longer decide it; the allow is audited
|
|
335
|
+
* without `late` (it is not after the ask) and the caller gives the ask the reason.
|
|
336
|
+
*/
|
|
337
|
+
private settleClosedIn;
|
|
338
|
+
/** The live intent `opId` on machine `machineId` (null: settled already, or expired). */
|
|
339
|
+
private pendingOpOf;
|
|
340
|
+
/**
|
|
341
|
+
* The `device-op-resolve` job's outcome of an op that answers network ask `op.source.approvalId`
|
|
342
|
+
* (transactional outbox spec §7.4), in the resolver's transaction: under the ask's locks
|
|
343
|
+
* (conversation, then the approval) the op is read again (settled meanwhile: nothing to do).
|
|
344
|
+
* Applied, and the ask still pending → approved `always` by the op's account (`via` as it
|
|
345
|
+
* asked), the run resumed in this transaction as every decision does; the ask closed → audited
|
|
346
|
+
* `late`; still pending but the op's account can no longer decide it → the allow audited (not
|
|
347
|
+
* late) and the ask left pending with `applied_undecided`. Not applied (refused, never received,
|
|
348
|
+
* interrupted) or still unknown → the op's outcome recorded and the ask left pending with the
|
|
349
|
+
* reason (`detail.attempt`) and an `approval_updated` event so the card shows it: no person is
|
|
350
|
+
* there to fall back to a run grant (D2).
|
|
351
|
+
*/
|
|
352
|
+
settleFromResolver(ref: {
|
|
353
|
+
machineId: string;
|
|
354
|
+
opId: string;
|
|
355
|
+
approvalId: string;
|
|
356
|
+
}, result: PolicyOpResult): Promise<void>;
|
|
357
|
+
/**
|
|
358
|
+
* A pending network ask's reason (`detail.attempt`) and its `approval_updated` event (one per
|
|
359
|
+
* op and outcome), in the caller's transaction with the ask locked; notified after the commit.
|
|
360
|
+
*/
|
|
361
|
+
private attemptIn;
|
|
362
|
+
/** The owner of a live device of the org (null: none, deleted, or of another org). */
|
|
363
|
+
private deviceOwnerOf;
|
|
292
364
|
/** After the commit: the decision's events reach the page, the run's waits and IM delivery. */
|
|
293
365
|
private announceDecided;
|
|
294
366
|
/** An account's display name (null when unknown). */
|
|
295
367
|
private displayNameOf;
|
|
296
368
|
private decideIn;
|
|
369
|
+
/**
|
|
370
|
+
* A decision in the caller's transaction: lock order conversation → approval → run (the resume).
|
|
371
|
+
* Refuses (`approval.already_decided`, `approval.not_found`, …) before any write.
|
|
372
|
+
*/
|
|
373
|
+
private decideTx;
|
|
297
374
|
/**
|
|
298
375
|
* A trial run of a scheduled task (scheduled tasks spec §7): an approval its creator granted, in
|
|
299
376
|
* any scope, is also added to the task's grants with the approved definition's hash, so its
|
|
@@ -338,11 +415,22 @@ export declare class ApprovalsService {
|
|
|
338
415
|
*/
|
|
339
416
|
cancelPendingIn(runId: string): Promise<ApprovalRecord[]>;
|
|
340
417
|
/**
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
418
|
+
* The conversations of `orgId` holding a pending approval `accountId` is asked to decide
|
|
419
|
+
* (`requested_for`), read without locks: offboarding locks them, by tree root first
|
|
420
|
+
* (`lockConversationTrees`), before {@link cancelPendingFor}.
|
|
421
|
+
*/
|
|
422
|
+
pendingConversationsFor(orgId: string, accountId: string): Promise<string[]>;
|
|
423
|
+
/**
|
|
424
|
+
* In the caller's transaction (`mandatory`; offboarding): cancels every pending approval of
|
|
425
|
+
* `orgId` that `accountId` is asked to decide (`requested_for`) in `conversationIds`, the
|
|
426
|
+
* conversations the caller already locked (by tree root first, `lockConversationTrees`; lock
|
|
427
|
+
* order: conversations, then approval rows), along the same path as {@link cancelPendingIn}:
|
|
428
|
+
* `cancelled`, `approval_decided{cancelled}` with no decider. An approval asked meanwhile in
|
|
429
|
+
* another conversation is left to its run's stop, so no conversation is locked after a row.
|
|
430
|
+
* Returns the cancelled records and the highest seq written per conversation; the caller
|
|
431
|
+
* publishes after the commit.
|
|
344
432
|
*/
|
|
345
|
-
cancelPendingFor(orgId: string, accountId: string): Promise<{
|
|
433
|
+
cancelPendingFor(orgId: string, accountId: string, conversationIds: readonly string[]): Promise<{
|
|
346
434
|
records: ApprovalRecord[];
|
|
347
435
|
seqs: Map<string, number>;
|
|
348
436
|
}>;
|