@llblab/pi-kit 0.24.0 → 0.25.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/AGENTS.md +1 -1
- package/CHANGELOG.md +10 -0
- package/README.md +6 -5
- package/node_modules/@llblab/pi-claude-usage/AGENTS.md +20 -0
- package/node_modules/@llblab/pi-claude-usage/BACKLOG.md +3 -0
- package/node_modules/@llblab/pi-claude-usage/CHANGELOG.md +13 -0
- package/node_modules/@llblab/pi-claude-usage/LICENSE +22 -0
- package/node_modules/@llblab/pi-claude-usage/README.md +110 -0
- package/node_modules/@llblab/pi-claude-usage/banner.jpg +0 -0
- package/node_modules/@llblab/pi-claude-usage/index.ts +1159 -0
- package/node_modules/@llblab/pi-claude-usage/package.json +60 -0
- package/node_modules/@llblab/pi-state-flow/AGENTS.md +42 -56
- package/node_modules/@llblab/pi-state-flow/BACKLOG.md +16 -3
- package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +19 -0
- package/node_modules/@llblab/pi-state-flow/README.md +15 -12
- package/node_modules/@llblab/pi-state-flow/dist/index.d.ts +2 -2
- package/node_modules/@llblab/pi-state-flow/dist/index.js +2 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/config.d.ts +7 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/config.js +16 -7
- package/node_modules/@llblab/pi-state-flow/dist/lib/context.d.ts +9 -9
- package/node_modules/@llblab/pi-state-flow/dist/lib/context.js +5 -4
- package/node_modules/@llblab/pi-state-flow/dist/lib/continuation.js +2 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/durable.d.ts +1 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/durable.js +7 -4
- package/node_modules/@llblab/pi-state-flow/dist/lib/episode.d.ts +3 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/episode.js +5 -5
- package/node_modules/@llblab/pi-state-flow/dist/lib/extension.d.ts +3 -5
- package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +275 -199
- package/node_modules/@llblab/pi-state-flow/dist/lib/history.d.ts +11 -4
- package/node_modules/@llblab/pi-state-flow/dist/lib/history.js +6 -7
- package/node_modules/@llblab/pi-state-flow/dist/lib/logging.d.ts +4 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/logging.js +1 -0
- package/node_modules/@llblab/pi-state-flow/dist/lib/query.d.ts +4 -5
- package/node_modules/@llblab/pi-state-flow/dist/lib/query.js +13 -13
- package/node_modules/@llblab/pi-state-flow/dist/lib/recovery.d.ts +7 -6
- package/node_modules/@llblab/pi-state-flow/dist/lib/recovery.js +9 -9
- package/node_modules/@llblab/pi-state-flow/dist/lib/runtime.d.ts +3 -2
- package/node_modules/@llblab/pi-state-flow/dist/lib/runtime.js +17 -12
- package/node_modules/@llblab/pi-state-flow/dist/lib/session.d.ts +4 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/session.js +2 -1
- package/node_modules/@llblab/pi-state-flow/dist/lib/snapshot.d.ts +17 -8
- package/node_modules/@llblab/pi-state-flow/dist/lib/snapshot.js +49 -20
- package/node_modules/@llblab/pi-state-flow/dist/lib/state.d.ts +22 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/state.js +30 -10
- package/node_modules/@llblab/pi-state-flow/dist/lib/status.d.ts +5 -3
- package/node_modules/@llblab/pi-state-flow/dist/lib/status.js +19 -28
- package/node_modules/@llblab/pi-state-flow/dist/lib/telegram.d.ts +17 -15
- package/node_modules/@llblab/pi-state-flow/dist/lib/telegram.js +52 -52
- package/node_modules/@llblab/pi-state-flow/dist/lib/temporal.d.ts +8 -4
- package/node_modules/@llblab/pi-state-flow/dist/lib/temporal.js +34 -18
- package/node_modules/@llblab/pi-state-flow/dist/lib/transition.d.ts +5 -5
- package/node_modules/@llblab/pi-state-flow/dist/lib/transition.js +13 -19
- package/node_modules/@llblab/pi-state-flow/dist/package.json +3 -3
- package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-guide/SKILL.md +2 -2
- package/node_modules/@llblab/pi-state-flow/docs/README.md +2 -1
- package/node_modules/@llblab/pi-state-flow/docs/agent-contract-relocation.md +72 -0
- package/node_modules/@llblab/pi-state-flow/docs/architecture.md +36 -32
- package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +12 -4
- package/node_modules/@llblab/pi-state-flow/docs/fork-contract.md +5 -5
- package/node_modules/@llblab/pi-state-flow/docs/lazy-state.md +6 -6
- package/node_modules/@llblab/pi-state-flow/docs/performance.md +1 -1
- package/node_modules/@llblab/pi-state-flow/docs/temporal-acceptance.md +13 -12
- package/node_modules/@llblab/pi-state-flow/docs/usage.md +32 -29
- package/node_modules/@llblab/pi-state-flow/index.ts +3 -2
- package/node_modules/@llblab/pi-state-flow/lib/config.ts +20 -10
- package/node_modules/@llblab/pi-state-flow/lib/context.ts +15 -14
- package/node_modules/@llblab/pi-state-flow/lib/continuation.ts +1 -1
- package/node_modules/@llblab/pi-state-flow/lib/durable.ts +8 -6
- package/node_modules/@llblab/pi-state-flow/lib/episode.ts +6 -6
- package/node_modules/@llblab/pi-state-flow/lib/extension.ts +274 -197
- package/node_modules/@llblab/pi-state-flow/lib/history.ts +16 -11
- package/node_modules/@llblab/pi-state-flow/lib/logging.ts +5 -1
- package/node_modules/@llblab/pi-state-flow/lib/query.ts +16 -16
- package/node_modules/@llblab/pi-state-flow/lib/recovery.ts +11 -11
- package/node_modules/@llblab/pi-state-flow/lib/runtime.ts +19 -13
- package/node_modules/@llblab/pi-state-flow/lib/session.ts +6 -3
- package/node_modules/@llblab/pi-state-flow/lib/snapshot.ts +55 -22
- package/node_modules/@llblab/pi-state-flow/lib/state.ts +46 -13
- package/node_modules/@llblab/pi-state-flow/lib/status.ts +23 -32
- package/node_modules/@llblab/pi-state-flow/lib/telegram.ts +66 -65
- package/node_modules/@llblab/pi-state-flow/lib/temporal.ts +39 -19
- package/node_modules/@llblab/pi-state-flow/lib/transition.ts +19 -27
- package/node_modules/@llblab/pi-state-flow/package.json +3 -3
- package/node_modules/@llblab/pi-state-flow/skills/state-flow-guide/SKILL.md +2 -2
- package/node_modules/@llblab/pi-telegram/AGENTS.md +1 -1
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +5 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +2 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +55 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.d.ts +21 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus-leader.js +144 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/bus.d.ts +9 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/bus.js +19 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +13 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +29 -6
- package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +16 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/locks.js +5 -1
- package/node_modules/@llblab/pi-telegram/dist/lib/polling.js +6 -2
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +7 -0
- package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +13 -5
- package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -2
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +1 -1
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +79 -1
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +197 -0
- package/node_modules/@llblab/pi-telegram/lib/bus.ts +33 -0
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +38 -6
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +15 -0
- package/node_modules/@llblab/pi-telegram/lib/locks.ts +6 -1
- package/node_modules/@llblab/pi-telegram/lib/polling.ts +10 -2
- package/node_modules/@llblab/pi-telegram/lib/threads.ts +19 -5
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/package.json +7 -3
|
@@ -371,6 +371,12 @@ export interface TelegramSessionReplacementIntent {
|
|
|
371
371
|
threadName?: string;
|
|
372
372
|
createdAtMs: number;
|
|
373
373
|
expiresAtMs: number;
|
|
374
|
+
/**
|
|
375
|
+
* Present only when the leader published the intent for a registered
|
|
376
|
+
* follower. Successor re-key and settlement must come from this exact
|
|
377
|
+
* follower runtime or its authenticated same-process session handoff.
|
|
378
|
+
*/
|
|
379
|
+
sourceInstanceId?: string;
|
|
374
380
|
}
|
|
375
381
|
|
|
376
382
|
export interface TelegramTopicTargetFile {
|
|
@@ -1329,7 +1335,7 @@ function cloneSessionReplacementIntent(
|
|
|
1329
1335
|
return { ...intent, target: { ...intent.target } };
|
|
1330
1336
|
}
|
|
1331
1337
|
|
|
1332
|
-
function
|
|
1338
|
+
export function normalizeTelegramSessionReplacementIntent(
|
|
1333
1339
|
value: unknown,
|
|
1334
1340
|
): TelegramSessionReplacementIntent | undefined {
|
|
1335
1341
|
if (!value || typeof value !== "object" || Array.isArray(value)) return undefined;
|
|
@@ -1346,7 +1352,10 @@ function normalizeSessionReplacementIntent(
|
|
|
1346
1352
|
typeof record.messageId !== "number" || !Number.isSafeInteger(record.messageId) ||
|
|
1347
1353
|
typeof record.createdAtMs !== "number" || !Number.isSafeInteger(record.createdAtMs) ||
|
|
1348
1354
|
typeof record.expiresAtMs !== "number" || !Number.isSafeInteger(record.expiresAtMs) ||
|
|
1349
|
-
record.expiresAtMs <= record.createdAtMs
|
|
1355
|
+
record.expiresAtMs <= record.createdAtMs ||
|
|
1356
|
+
(record.sourceInstanceId !== undefined &&
|
|
1357
|
+
(typeof record.sourceInstanceId !== "string" || !record.sourceInstanceId ||
|
|
1358
|
+
record.sourceInstanceId.length > 256))
|
|
1350
1359
|
) return undefined;
|
|
1351
1360
|
const continuity = record.continuity === "workspace-thread" ||
|
|
1352
1361
|
record.continuity === "classic-chat"
|
|
@@ -1370,6 +1379,8 @@ function normalizeSessionReplacementIntent(
|
|
|
1370
1379
|
...(typeof record.threadName === "string" ? { threadName: record.threadName } : {}),
|
|
1371
1380
|
createdAtMs: record.createdAtMs,
|
|
1372
1381
|
expiresAtMs: record.expiresAtMs,
|
|
1382
|
+
...(typeof record.sourceInstanceId === "string"
|
|
1383
|
+
? { sourceInstanceId: record.sourceInstanceId } : {}),
|
|
1373
1384
|
};
|
|
1374
1385
|
}
|
|
1375
1386
|
|
|
@@ -1680,7 +1691,7 @@ function parseTopicTargetFile(value: unknown): TelegramTopicTargetFile {
|
|
|
1680
1691
|
return normalized ? [normalized] : [];
|
|
1681
1692
|
})
|
|
1682
1693
|
: [],
|
|
1683
|
-
sessionReplacement:
|
|
1694
|
+
sessionReplacement: normalizeTelegramSessionReplacementIntent(file.sessionReplacement),
|
|
1684
1695
|
reservations: Array.isArray(file.reservations)
|
|
1685
1696
|
? file.reservations.flatMap((reservation) => {
|
|
1686
1697
|
const normalized = normalizeReservation(reservation);
|
|
@@ -2510,7 +2521,7 @@ export function createTelegramTopicTargetStore(
|
|
|
2510
2521
|
: undefined;
|
|
2511
2522
|
},
|
|
2512
2523
|
async commitSessionReplacementIntent(intent, isCurrent) {
|
|
2513
|
-
const next =
|
|
2524
|
+
const next = normalizeTelegramSessionReplacementIntent(intent);
|
|
2514
2525
|
if (!next || !isCurrent()) return false;
|
|
2515
2526
|
await loadFromDisk();
|
|
2516
2527
|
if (!isCurrent()) return false;
|
|
@@ -2925,7 +2936,10 @@ export function createTelegramTopicTargetStore(
|
|
|
2925
2936
|
replacement.expiresAtMs > getNowMs() &&
|
|
2926
2937
|
replacement.profileName === (getTelegramProfile() ?? "default") &&
|
|
2927
2938
|
replacement.cwd === normalizedCwd &&
|
|
2928
|
-
replacement.sourceSessionId !== normalizedSessionId
|
|
2939
|
+
replacement.sourceSessionId !== normalizedSessionId &&
|
|
2940
|
+
(replacement.sourceInstanceId === undefined ||
|
|
2941
|
+
replacement.sourceInstanceId === instanceId ||
|
|
2942
|
+
replacement.sourceInstanceId === previousInstanceId)
|
|
2929
2943
|
) {
|
|
2930
2944
|
const sourceEntry = Array.from(workspaceBindings.entries()).find(([, binding]) =>
|
|
2931
2945
|
binding.cwd === normalizedCwd &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,15 +42,17 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@llblab/pi-actors": "0.53.2",
|
|
45
|
+
"@llblab/pi-claude-usage": "0.1.1",
|
|
45
46
|
"@llblab/pi-clean-room": "0.2.0",
|
|
46
47
|
"@llblab/pi-codex-usage": "0.10.0",
|
|
47
48
|
"@llblab/pi-grow-loop": "0.8.2",
|
|
48
|
-
"@llblab/pi-state-flow": "0.
|
|
49
|
-
"@llblab/pi-telegram": "0.51.
|
|
49
|
+
"@llblab/pi-state-flow": "0.23.0",
|
|
50
|
+
"@llblab/pi-telegram": "0.51.5",
|
|
50
51
|
"@llblab/skills": "1.15.0"
|
|
51
52
|
},
|
|
52
53
|
"bundledDependencies": [
|
|
53
54
|
"@llblab/pi-actors",
|
|
55
|
+
"@llblab/pi-claude-usage",
|
|
54
56
|
"@llblab/pi-clean-room",
|
|
55
57
|
"@llblab/pi-codex-usage",
|
|
56
58
|
"@llblab/pi-grow-loop",
|
|
@@ -61,6 +63,7 @@
|
|
|
61
63
|
"pi": {
|
|
62
64
|
"extensions": [
|
|
63
65
|
"./node_modules/@llblab/pi-actors/dist/pi-actors/index.js",
|
|
66
|
+
"./node_modules/@llblab/pi-claude-usage/index.ts",
|
|
64
67
|
"./node_modules/@llblab/pi-clean-room/index.ts",
|
|
65
68
|
"./node_modules/@llblab/pi-codex-usage/index.ts",
|
|
66
69
|
"./node_modules/@llblab/pi-grow-loop/dist/pi-grow-loop/index.js",
|
|
@@ -78,6 +81,7 @@
|
|
|
78
81
|
},
|
|
79
82
|
"bundleDependencies": [
|
|
80
83
|
"@llblab/pi-actors",
|
|
84
|
+
"@llblab/pi-claude-usage",
|
|
81
85
|
"@llblab/pi-clean-room",
|
|
82
86
|
"@llblab/pi-codex-usage",
|
|
83
87
|
"@llblab/pi-grow-loop",
|