@capybara-hq/kernel 0.1.0-rc.34 → 0.1.0-rc.35
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/outbox-dead.service.d.ts +2 -0
- package/dist/admin/outbox-dead.service.js +34 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/conversations/conversations.service.d.ts +3 -3
- package/dist/conversations/conversations.service.js +58 -29
- package/dist/db/kernel-schema.d.ts +8 -0
- package/dist/infra/database/transaction-host.d.ts +1 -0
- package/dist/infra/database/transaction-host.js +13 -2
- package/dist/infra/outbox/registry.d.ts +17 -0
- package/dist/infra/outbox/registry.js +11 -0
- package/dist/local-devices/local-device-gateway.d.ts +1 -1
- package/dist/local-devices/local-device-gateway.js +1 -1
- package/dist/local-devices/local-device-provider.d.ts +2 -2
- package/dist/local-devices/local-device-provider.js +7 -5
- package/dist/orgs/offboarding.d.ts +2 -0
- package/dist/orgs/offboarding.js +4 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +23 -10
- package/dist/runtime/checkpointer.js +3 -0
- package/dist/runtime/context/compaction.js +5 -5
- package/dist/runtime/conversation-lock.d.ts +4 -11
- package/dist/runtime/conversation-lock.js +14 -18
- package/dist/runtime/maintenance.d.ts +3 -1
- package/dist/runtime/maintenance.js +17 -10
- package/dist/runtime/project/knowledge.service.js +2 -2
- package/dist/runtime/run-deletion.d.ts +23 -0
- package/dist/runtime/run-deletion.js +130 -0
- package/dist/runtime/run-execution.d.ts +23 -0
- package/dist/runtime/run-execution.js +105 -0
- package/dist/runtime/run-finish.js +17 -4
- package/dist/runtime/run-jobs.js +11 -0
- package/dist/runtime/run-orphan-check.job.d.ts +12 -12
- package/dist/runtime/run-orphan-check.job.js +94 -26
- package/dist/runtime/run-queue.js +14 -0
- package/dist/runtime/run-worker.d.ts +9 -5
- package/dist/runtime/run-worker.js +90 -44
- package/dist/runtime/runtime.module.js +6 -0
- package/dist/runtime/stream.js +8 -2
- package/dist/runtime/subagents/tree-jobs.d.ts +4 -3
- package/dist/runtime/subagents/tree-jobs.js +4 -4
- package/dist/tools/pipeline.js +7 -1
- package/package.json +3 -3
- package/src/migrations/0135_run_execution_claim.sql +2 -0
- package/src/migrations/0136_run_recovery_cursor.sql +6 -0
package/dist/runtime/stream.js
CHANGED
|
@@ -287,10 +287,11 @@ class Connection {
|
|
|
287
287
|
});
|
|
288
288
|
this.close("abort");
|
|
289
289
|
});
|
|
290
|
+
return this.chain;
|
|
290
291
|
}
|
|
291
292
|
/** 读 lastSeq 之后的全部事件并发送(按 seq 去重:只发大于已发送值的)。 */
|
|
292
|
-
async catchUp() {
|
|
293
|
-
for (
|
|
293
|
+
async catchUp(maxPages = Number.POSITIVE_INFINITY) {
|
|
294
|
+
for (let page = 0; page < maxPages; page++) {
|
|
294
295
|
const evs = await this.d.eventLog.readAfter(this.p.conversationId, this.lastSeq, PAGE);
|
|
295
296
|
for (const e of evs) {
|
|
296
297
|
if (this.closed)
|
|
@@ -357,6 +358,11 @@ class Connection {
|
|
|
357
358
|
const denied = await authorize(this.d, this.p);
|
|
358
359
|
if (denied !== null)
|
|
359
360
|
this.fail(denied);
|
|
361
|
+
else {
|
|
362
|
+
// Pub/sub is a hint: a lost final notification must not leave an open stream stale.
|
|
363
|
+
// One page per authorized recheck bounds PG work; the shared chain deduplicates hints.
|
|
364
|
+
await this.enqueue(() => this.catchUp(1));
|
|
365
|
+
}
|
|
360
366
|
}
|
|
361
367
|
catch (err) {
|
|
362
368
|
this.d.log.warn("conversation stream access re-check failed; closing", {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OutboxService } from "../../infra/outbox/outbox.service.js";
|
|
2
|
+
import type { RunDeletion } from "../run-deletion.js";
|
|
2
3
|
import type { Waits } from "../waits.js";
|
|
3
4
|
/**
|
|
4
5
|
* The stops a transaction owes a sub-agent tree (transactional outbox spec §6 "Sub-agents"), on
|
|
@@ -6,8 +7,8 @@ import type { Waits } from "../waits.js";
|
|
|
6
7
|
* - `{ runId }`: what a run's terminal transaction owes its children: its active fork invocation
|
|
7
8
|
* child stops (`Waits.stopChildren`, sub-agents spec §12), and a sub-agent run a person stopped
|
|
8
9
|
* stops its descendants (`Waits.stopDescendantsOfStopped`, agent map spec §6);
|
|
9
|
-
* - `{ conversationId, byAccountId }`: a deleted root's whole tree
|
|
10
|
-
* (`Waits.stopTree`
|
|
10
|
+
* - `{ conversationId, byAccountId }`: a deleted root's whole tree including the root stops
|
|
11
|
+
* (`Waits.stopTree` including the root, agent map spec §10).
|
|
11
12
|
*
|
|
12
13
|
* The caller still stops them right after its commit; the job is the backstop for a process that
|
|
13
14
|
* died in between, {@link TREE_JOB_BACKSTOP_MS} later.
|
|
@@ -53,7 +54,7 @@ export declare function oweDeliverToParent(outbox: Pick<OutboxService, "add">, c
|
|
|
53
54
|
* The `stop-tree` job (`MaintenanceProcessor`): every stop reads the active runs and stops only
|
|
54
55
|
* those, so a run the direct call already stopped is not stopped again.
|
|
55
56
|
*/
|
|
56
|
-
export declare function processStopTree(waits: Pick<Waits, "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, data: StopTreeJobData): Promise<void>;
|
|
57
|
+
export declare function processStopTree(waits: Pick<Waits, "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, data: StopTreeJobData, deletion: Pick<RunDeletion, "stopTree">): Promise<void>;
|
|
57
58
|
/**
|
|
58
59
|
* The `deliver-to-parent` job (`MaintenanceProcessor`): `Waits.childFinished` writes the delivery
|
|
59
60
|
* once by the child run (idempotency keys under the parent conversation's row lock).
|
|
@@ -5,8 +5,8 @@ import { MAINTENANCE_QUEUE_NAME } from "../maintenance-queue.js";
|
|
|
5
5
|
* - `{ runId }`: what a run's terminal transaction owes its children: its active fork invocation
|
|
6
6
|
* child stops (`Waits.stopChildren`, sub-agents spec §12), and a sub-agent run a person stopped
|
|
7
7
|
* stops its descendants (`Waits.stopDescendantsOfStopped`, agent map spec §6);
|
|
8
|
-
* - `{ conversationId, byAccountId }`: a deleted root's whole tree
|
|
9
|
-
* (`Waits.stopTree`
|
|
8
|
+
* - `{ conversationId, byAccountId }`: a deleted root's whole tree including the root stops
|
|
9
|
+
* (`Waits.stopTree` including the root, agent map spec §10).
|
|
10
10
|
*
|
|
11
11
|
* The caller still stops them right after its commit; the job is the backstop for a process that
|
|
12
12
|
* died in between, {@link TREE_JOB_BACKSTOP_MS} later.
|
|
@@ -69,13 +69,13 @@ export function oweDeliverToParent(outbox, childRunId, orgId) {
|
|
|
69
69
|
* The `stop-tree` job (`MaintenanceProcessor`): every stop reads the active runs and stops only
|
|
70
70
|
* those, so a run the direct call already stopped is not stopped again.
|
|
71
71
|
*/
|
|
72
|
-
export async function processStopTree(waits, data) {
|
|
72
|
+
export async function processStopTree(waits, data, deletion) {
|
|
73
73
|
if ("runId" in data) {
|
|
74
74
|
await waits.stopChildren(data.runId, null);
|
|
75
75
|
await waits.stopDescendantsOfStopped(data.runId);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
await
|
|
78
|
+
await deletion.stopTree(data.conversationId, data.byAccountId);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* The `deliver-to-parent` job (`MaintenanceProcessor`): `Waits.childFinished` writes the delivery
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -1430,7 +1430,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
config = { config: effective.config };
|
|
1432
1432
|
}
|
|
1433
|
-
const r = await this.bounded(ctx.signal, (signal) =>
|
|
1433
|
+
const r = await this.bounded(ctx.signal, async (signal) => {
|
|
1434
|
+
await this.txHost.run(async () => { });
|
|
1435
|
+
signal.throwIfAborted();
|
|
1436
|
+
return handler(input, { ...base, ...config, signal });
|
|
1437
|
+
}, undefined, timeoutMs);
|
|
1434
1438
|
if (r === "timeout") {
|
|
1435
1439
|
return { kind: "error", message: timeoutText(tool.key, timeoutMs) };
|
|
1436
1440
|
}
|
|
@@ -1575,6 +1579,8 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1575
1579
|
},
|
|
1576
1580
|
});
|
|
1577
1581
|
const session = await opened;
|
|
1582
|
+
await this.txHost.run(async () => { });
|
|
1583
|
+
signal.throwIfAborted();
|
|
1578
1584
|
return source.resources
|
|
1579
1585
|
? runResourceTool(session, source.name, input)
|
|
1580
1586
|
: // 交回已复核的定义(connector_tools.spec,含 connectorData):连接器按它路由,远端变化须先经漂移复核
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.35",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"yaml": "^2.9.1",
|
|
66
66
|
"yauzl": "3.4.0",
|
|
67
67
|
"zod": "^4.6.7",
|
|
68
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
68
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.25"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/ws": "^8.18.2",
|
|
75
75
|
"@types/yauzl": "3.4.0",
|
|
76
76
|
"ws": "^8.22.0",
|
|
77
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
77
|
+
"@capybara-hq/testing": "0.1.0-rc.20"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "tsc -b"
|