@llblab/pi-kit 0.5.2 → 0.7.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/CHANGELOG.md +8 -0
- package/README.md +5 -5
- package/node_modules/@llblab/pi-actors/AGENTS.md +1 -1
- package/node_modules/@llblab/pi-actors/CHANGELOG.md +6 -0
- package/node_modules/@llblab/pi-actors/README.md +1 -1
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +14 -1
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +45 -3
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +1 -1
- package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +16 -3
- package/node_modules/@llblab/pi-actors/dist/lib/observability.js +92 -7
- package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +0 -1
- package/node_modules/@llblab/pi-actors/dist/lib/pi.js +15 -24
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery-lineage.d.ts +17 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery-lineage.js +44 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.d.ts +4 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.js +102 -4
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +58 -39
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +14 -6
- package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +1 -1
- package/node_modules/@llblab/pi-actors/docs/async-runs.md +1 -1
- package/node_modules/@llblab/pi-actors/docs/coordinator-delivery.md +18 -23
- package/node_modules/@llblab/pi-actors/lib/async-runs.ts +18 -1
- package/node_modules/@llblab/pi-actors/lib/command-templates.ts +41 -3
- package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +1 -1
- package/node_modules/@llblab/pi-actors/lib/observability.ts +119 -5
- package/node_modules/@llblab/pi-actors/lib/pi.ts +15 -28
- package/node_modules/@llblab/pi-actors/lib/run-delivery-lineage.ts +68 -0
- package/node_modules/@llblab/pi-actors/lib/run-delivery.ts +120 -4
- package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +69 -44
- package/node_modules/@llblab/pi-actors/lib/runtime.ts +17 -6
- package/node_modules/@llblab/pi-actors/package.json +1 -1
- package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +1 -1
- package/node_modules/@llblab/pi-grow-loop/AGENTS.md +2 -2
- package/node_modules/@llblab/pi-grow-loop/CHANGELOG.md +4 -0
- package/node_modules/@llblab/pi-grow-loop/README.md +6 -6
- package/node_modules/@llblab/pi-grow-loop/index.ts +6 -3
- package/node_modules/@llblab/pi-grow-loop/package.json +1 -1
- package/node_modules/@llblab/pi-state-flow/AGENTS.md +33 -12
- package/node_modules/@llblab/pi-state-flow/BACKLOG.md +125 -2
- package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +87 -45
- package/node_modules/@llblab/pi-state-flow/README.md +203 -107
- package/node_modules/@llblab/pi-state-flow/docs/README.md +4 -0
- package/node_modules/@llblab/pi-state-flow/docs/architecture.md +188 -0
- package/node_modules/@llblab/pi-state-flow/docs/temporal-acceptance.md +42 -0
- package/node_modules/@llblab/pi-state-flow/index.ts +164 -2
- package/node_modules/@llblab/pi-state-flow/lib/acquisition.ts +138 -0
- package/node_modules/@llblab/pi-state-flow/lib/artifact.ts +273 -0
- package/node_modules/@llblab/pi-state-flow/lib/config.ts +48 -0
- package/node_modules/@llblab/pi-state-flow/lib/context.ts +18 -5
- package/node_modules/@llblab/pi-state-flow/lib/continuation.ts +268 -0
- package/node_modules/@llblab/pi-state-flow/lib/discovery.ts +117 -0
- package/node_modules/@llblab/pi-state-flow/lib/durable.ts +562 -0
- package/node_modules/@llblab/pi-state-flow/lib/episode.ts +24 -12
- package/node_modules/@llblab/pi-state-flow/lib/extension.ts +606 -70
- package/node_modules/@llblab/pi-state-flow/lib/git.ts +666 -0
- package/node_modules/@llblab/pi-state-flow/lib/history.ts +95 -0
- package/node_modules/@llblab/pi-state-flow/lib/json.ts +24 -0
- package/node_modules/@llblab/pi-state-flow/lib/maintenance.ts +141 -0
- package/node_modules/@llblab/pi-state-flow/lib/memory.ts +52 -0
- package/node_modules/@llblab/pi-state-flow/lib/migration.ts +88 -0
- package/node_modules/@llblab/pi-state-flow/lib/publication.ts +296 -0
- package/node_modules/@llblab/pi-state-flow/lib/recovery.ts +23 -7
- package/node_modules/@llblab/pi-state-flow/lib/rehydration.ts +79 -0
- package/node_modules/@llblab/pi-state-flow/lib/runtime.ts +264 -0
- package/node_modules/@llblab/pi-state-flow/lib/session.ts +6 -0
- package/node_modules/@llblab/pi-state-flow/lib/skills.ts +99 -7
- package/node_modules/@llblab/pi-state-flow/lib/snapshot.ts +305 -48
- package/node_modules/@llblab/pi-state-flow/lib/state.ts +74 -7
- package/node_modules/@llblab/pi-state-flow/lib/status.ts +125 -6
- package/node_modules/@llblab/pi-state-flow/lib/storage.ts +196 -0
- package/node_modules/@llblab/pi-state-flow/lib/temporal.ts +233 -0
- package/node_modules/@llblab/pi-state-flow/lib/terminal.ts +70 -24
- package/node_modules/@llblab/pi-state-flow/lib/transition.ts +254 -29
- package/node_modules/@llblab/pi-state-flow/package.json +8 -2
- package/node_modules/@llblab/pi-state-flow/skills/state-flow-memory/SKILL.md +128 -0
- package/node_modules/@llblab/pi-telegram/AGENTS.md +14 -9
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +20 -4
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +22 -5
- package/node_modules/@llblab/pi-telegram/README.md +13 -9
- package/node_modules/@llblab/pi-telegram/docs/README.md +1 -0
- package/node_modules/@llblab/pi-telegram/docs/architecture.md +220 -18
- package/node_modules/@llblab/pi-telegram/docs/generative-apps.md +1 -1
- package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +70 -19
- package/node_modules/@llblab/pi-telegram/docs/outbound.md +13 -7
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +13 -5
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +3 -1
- package/node_modules/@llblab/pi-telegram/index.ts +4 -1415
- package/node_modules/@llblab/pi-telegram/lib/activity.ts +19 -5
- package/node_modules/@llblab/pi-telegram/lib/agent-messages.ts +6 -3
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +37 -2
- package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +600 -135
- package/node_modules/@llblab/pi-telegram/lib/bus-leader.ts +962 -55
- package/node_modules/@llblab/pi-telegram/lib/bus.ts +350 -26
- package/node_modules/@llblab/pi-telegram/lib/channel-posts.ts +544 -0
- package/node_modules/@llblab/pi-telegram/lib/commands.ts +234 -11
- package/node_modules/@llblab/pi-telegram/lib/config.ts +178 -25
- package/node_modules/@llblab/pi-telegram/lib/delivery.ts +18 -18
- package/node_modules/@llblab/pi-telegram/lib/extension.ts +1792 -0
- package/node_modules/@llblab/pi-telegram/lib/generative-apps.ts +20 -2
- package/node_modules/@llblab/pi-telegram/lib/journal.ts +2184 -126
- package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +7 -1
- package/node_modules/@llblab/pi-telegram/lib/locks.ts +38 -1
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +154 -15
- package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +74 -40
- package/node_modules/@llblab/pi-telegram/lib/outbound-voice.ts +28 -42
- package/node_modules/@llblab/pi-telegram/lib/outbound.ts +18 -14
- package/node_modules/@llblab/pi-telegram/lib/paths.ts +29 -0
- package/node_modules/@llblab/pi-telegram/lib/polling.ts +85 -17
- package/node_modules/@llblab/pi-telegram/lib/preview.ts +115 -70
- package/node_modules/@llblab/pi-telegram/lib/prompts.ts +5 -2
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +66 -22
- package/node_modules/@llblab/pi-telegram/lib/replies.ts +47 -39
- package/node_modules/@llblab/pi-telegram/lib/routing.ts +305 -112
- package/node_modules/@llblab/pi-telegram/lib/status.ts +10 -0
- package/node_modules/@llblab/pi-telegram/lib/sync.ts +308 -39
- package/node_modules/@llblab/pi-telegram/lib/telegram-api.ts +315 -7
- package/node_modules/@llblab/pi-telegram/lib/thread-cleanup-manager.ts +664 -0
- package/node_modules/@llblab/pi-telegram/lib/thread-display.ts +226 -0
- package/node_modules/@llblab/pi-telegram/lib/thread-naming.ts +118 -0
- package/node_modules/@llblab/pi-telegram/lib/threads.ts +1686 -129
- package/node_modules/@llblab/pi-telegram/lib/updates.ts +1319 -97
- package/node_modules/@llblab/pi-telegram/lib/workspace-admission.ts +1643 -0
- package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +968 -0
- package/node_modules/@llblab/pi-telegram/lib/workspace-slots.ts +84 -0
- package/node_modules/@llblab/pi-telegram/package.json +1 -1
- package/node_modules/@llblab/pi-telegram/screenshot.png +0 -0
- package/node_modules/@llblab/pi-telegram/scripts/measure-bus.mjs +83 -0
- package/node_modules/@llblab/pi-telegram/scripts/measure-workspace.mjs +101 -0
- package/node_modules/@llblab/{skills → pi-telegram/skills}/show-me/SKILL.md +28 -6
- package/node_modules/@llblab/pi-telegram/skills/show-me/references/telegram-surfaces.md +43 -0
- package/node_modules/@llblab/pi-telegram/skills/telegram-bridge/references/delivery-and-threads.md +1 -1
- package/node_modules/@llblab/skills/abcd-context/AGENTS.md +1 -0
- package/node_modules/@llblab/skills/abcd-context/CHANGELOG.md +6 -2
- package/node_modules/@llblab/skills/abcd-context/SKILL.md +1 -1
- package/node_modules/@llblab/skills/abcd-context/docs/validation-design.md +11 -5
- package/node_modules/@llblab/skills/abcd-context/scripts/_self-test.mjs +61 -0
- package/node_modules/@llblab/skills/abcd-context/scripts/validate-context.mjs +67 -0
- package/node_modules/@llblab/skills/package.json +2 -3
- package/node_modules/@llblab/skills/release-flow/SKILL.md +2 -4
- package/package.json +7 -6
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getTelegramTargetThreadParams,
|
|
10
10
|
type TelegramTarget,
|
|
11
11
|
} from "./target.ts";
|
|
12
|
+
import { isTelegramApiCommitUnknownError } from "./telegram-api.ts";
|
|
12
13
|
import type {
|
|
13
14
|
TelegramInputRichMessage,
|
|
14
15
|
TelegramReplyParameters,
|
|
@@ -67,6 +68,7 @@ export function createReplyDedupRuntime(): ReplyDedupRuntime {
|
|
|
67
68
|
// --- Transport-level dedup ---
|
|
68
69
|
|
|
69
70
|
const lastRepliedToMessageIdByTarget = new Map<string, number>();
|
|
71
|
+
let replyDedupGeneration = 0;
|
|
70
72
|
|
|
71
73
|
function getReplyDedupTargetKey(
|
|
72
74
|
chatId: number,
|
|
@@ -79,6 +81,7 @@ function getReplyDedupTargetKey(
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
export function resetTransportReplyDedup(): void {
|
|
84
|
+
replyDedupGeneration += 1;
|
|
82
85
|
lastRepliedToMessageIdByTarget.clear();
|
|
83
86
|
}
|
|
84
87
|
|
|
@@ -99,13 +102,29 @@ export function buildTelegramReplyParameters(
|
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
// Answer publications are caller-serialized. A rejected send releases its anchor;
|
|
106
|
+
// an uncertain ACK retains it because Telegram may already have delivered it.
|
|
107
|
+
export async function withTelegramReplyParameters<T>(
|
|
103
108
|
chatId: number,
|
|
104
109
|
messageId: number | undefined,
|
|
105
|
-
target
|
|
106
|
-
|
|
110
|
+
target: TelegramTarget | undefined,
|
|
111
|
+
send: (parameters: TelegramReplyParameters | undefined) => Promise<T>,
|
|
112
|
+
): Promise<T> {
|
|
113
|
+
const key = getReplyDedupTargetKey(chatId, target);
|
|
114
|
+
const generation = replyDedupGeneration;
|
|
115
|
+
const previous = lastRepliedToMessageIdByTarget.get(key);
|
|
107
116
|
const parameters = buildTelegramReplyParameters(chatId, messageId, target);
|
|
108
|
-
|
|
117
|
+
try {
|
|
118
|
+
return await send(parameters);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (parameters && !isTelegramApiCommitUnknownError(error)
|
|
121
|
+
&& generation === replyDedupGeneration
|
|
122
|
+
&& lastRepliedToMessageIdByTarget.get(key) === messageId) {
|
|
123
|
+
if (previous === undefined) lastRepliedToMessageIdByTarget.delete(key);
|
|
124
|
+
else lastRepliedToMessageIdByTarget.set(key, previous);
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
109
128
|
}
|
|
110
129
|
|
|
111
130
|
function getAgentMessageField(message: unknown, field: string): unknown {
|
|
@@ -239,24 +258,18 @@ export async function sendTelegramRenderedChunks<TReplyMarkup>(
|
|
|
239
258
|
assertTelegramInlineKeyboardCallbackData(options?.replyMarkup);
|
|
240
259
|
let lastMessageId: number | undefined;
|
|
241
260
|
for (const [index, chunk] of chunks.entries()) {
|
|
242
|
-
const
|
|
243
|
-
index === 0
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
reply_markup:
|
|
255
|
-
index === chunks.length - 1 ? options?.replyMarkup : undefined,
|
|
256
|
-
...(replyParameters ? { reply_parameters: replyParameters } : {}),
|
|
257
|
-
...(options?.target ? getTelegramTargetThreadParams(options.target) : {}),
|
|
258
|
-
};
|
|
259
|
-
const sent = await deps.sendMessage(body);
|
|
261
|
+
const sent = await withTelegramReplyParameters(
|
|
262
|
+
chatId, index === 0 ? options?.replyToMessageId : undefined, options?.target,
|
|
263
|
+
(replyParameters) => deps.sendMessage({
|
|
264
|
+
chat_id: chatId,
|
|
265
|
+
text: chunk.text,
|
|
266
|
+
parse_mode: chunk.parseMode,
|
|
267
|
+
reply_markup:
|
|
268
|
+
index === chunks.length - 1 ? options?.replyMarkup : undefined,
|
|
269
|
+
...(replyParameters ? { reply_parameters: replyParameters } : {}),
|
|
270
|
+
...(options?.target ? getTelegramTargetThreadParams(options.target) : {}),
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
260
273
|
lastMessageId = sent.message_id;
|
|
261
274
|
deps.recordOwnership?.({
|
|
262
275
|
chatId,
|
|
@@ -655,22 +668,17 @@ export async function sendTelegramNativeMarkdownReply<TReplyMarkup = unknown>(
|
|
|
655
668
|
let lastMessageId: number | undefined;
|
|
656
669
|
const chunks = splitTelegramNativeMarkdown(markdown);
|
|
657
670
|
for (const [index, chunk] of chunks.entries()) {
|
|
658
|
-
const
|
|
659
|
-
index === 0
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
:
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
reply_markup:
|
|
670
|
-
index === chunks.length - 1 ? options?.replyMarkup : undefined,
|
|
671
|
-
...(replyParameters ? { reply_parameters: replyParameters } : {}),
|
|
672
|
-
...(options?.target ? getTelegramTargetThreadParams(options.target) : {}),
|
|
673
|
-
});
|
|
671
|
+
const sent = await withTelegramReplyParameters(
|
|
672
|
+
chatId, index === 0 ? replyToMessageId : undefined, options?.target,
|
|
673
|
+
(replyParameters) => deps.sendRichMessage({
|
|
674
|
+
chat_id: chatId,
|
|
675
|
+
rich_message: { markdown: chunk },
|
|
676
|
+
reply_markup:
|
|
677
|
+
index === chunks.length - 1 ? options?.replyMarkup : undefined,
|
|
678
|
+
...(replyParameters ? { reply_parameters: replyParameters } : {}),
|
|
679
|
+
...(options?.target ? getTelegramTargetThreadParams(options.target) : {}),
|
|
680
|
+
}),
|
|
681
|
+
);
|
|
674
682
|
lastMessageId = sent.message_id;
|
|
675
683
|
deps.recordOwnership?.({
|
|
676
684
|
chatId,
|
|
@@ -886,7 +894,7 @@ export function createGuestMarkdownReplySender(deps: {
|
|
|
886
894
|
return async (guestQueryId: string, markdown: string) => {
|
|
887
895
|
const [richMarkdown = markdown] = splitTelegramNativeMarkdown(markdown);
|
|
888
896
|
await deps.answerGuestQuery(guestQueryId, undefined, {
|
|
889
|
-
richMessage: { markdown: richMarkdown
|
|
897
|
+
richMessage: { markdown: richMarkdown },
|
|
890
898
|
});
|
|
891
899
|
};
|
|
892
900
|
}
|