@llblab/pi-kit 0.6.0 → 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 +4 -0
- package/README.md +4 -4
- 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-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 +13 -8
- package/node_modules/@llblab/pi-telegram/BACKLOG.md +20 -3
- package/node_modules/@llblab/pi-telegram/CHANGELOG.md +13 -0
- package/node_modules/@llblab/pi-telegram/README.md +12 -8
- 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 +6 -6
- package/node_modules/@llblab/pi-telegram/docs/public-api.md +12 -5
- package/node_modules/@llblab/pi-telegram/docs/ui-style.md +3 -1
- package/node_modules/@llblab/pi-telegram/index.ts +4 -1418
- package/node_modules/@llblab/pi-telegram/lib/agent-messages.ts +6 -3
- package/node_modules/@llblab/pi-telegram/lib/bindings.ts +28 -1
- 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 +177 -24
- 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/locks.ts +38 -1
- package/node_modules/@llblab/pi-telegram/lib/menu-settings.ts +152 -13
- package/node_modules/@llblab/pi-telegram/lib/outbound-attachments.ts +51 -10
- 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/prompts.ts +5 -2
- package/node_modules/@llblab/pi-telegram/lib/queue.ts +52 -18
- package/node_modules/@llblab/pi-telegram/lib/replies.ts +2 -2
- 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 +279 -4
- 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/package.json +2 -3
- package/package.json +6 -5
|
@@ -18,6 +18,7 @@ export interface TelegramAgentMessageRuntimeDeps<TContext, TUpdate> {
|
|
|
18
18
|
getAllowedChatId: () => number | undefined;
|
|
19
19
|
getLeaderTarget: () => TelegramTarget | undefined;
|
|
20
20
|
getLeaderThreadName: () => string | undefined;
|
|
21
|
+
getDisplayTitle?: (target: TelegramTarget) => string | undefined;
|
|
21
22
|
followerRegistry: TelegramBusFollowerRegistry;
|
|
22
23
|
getContext: () => TContext | undefined;
|
|
23
24
|
handleUpdate: (update: TUpdate, ctx: TContext) => Promise<void>;
|
|
@@ -39,7 +40,7 @@ export function createTelegramAgentMessageRuntime<TContext, TUpdate>(
|
|
|
39
40
|
if (leaderTarget?.threadId) {
|
|
40
41
|
targets.push({
|
|
41
42
|
target: { chatId: leaderTarget.chatId, threadId: leaderTarget.threadId },
|
|
42
|
-
threadName: deps.getLeaderThreadName(),
|
|
43
|
+
threadName: deps.getDisplayTitle?.(leaderTarget) ?? deps.getLeaderThreadName(),
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
for (const follower of deps.followerRegistry.list()) {
|
|
@@ -49,7 +50,7 @@ export function createTelegramAgentMessageRuntime<TContext, TUpdate>(
|
|
|
49
50
|
chatId: follower.target.chatId,
|
|
50
51
|
threadId: follower.target.threadId,
|
|
51
52
|
},
|
|
52
|
-
threadName: follower.threadName,
|
|
53
|
+
threadName: deps.getDisplayTitle?.(follower.target) ?? follower.threadName,
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
return targets;
|
|
@@ -98,8 +99,10 @@ export function createTelegramAgentMessageRuntime<TContext, TUpdate>(
|
|
|
98
99
|
if (allowedChatId === undefined || !ctx) {
|
|
99
100
|
throw new Error("Telegram agent turn routing is unavailable.");
|
|
100
101
|
}
|
|
102
|
+
const sourceTitle = (input.sourceTarget ? deps.getDisplayTitle?.(input.sourceTarget) : undefined)
|
|
103
|
+
?? input.sourceThreadName;
|
|
101
104
|
const sourceLabel =
|
|
102
|
-
|
|
105
|
+
sourceTitle
|
|
103
106
|
?.replace(/[\r\n\[\]]+/g, " ")
|
|
104
107
|
.trim()
|
|
105
108
|
.slice(0, 64) || "Pi";
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import * as Activity from "./activity.ts";
|
|
8
8
|
import * as ActivityVerbosity from "./activity-verbosity.ts";
|
|
9
|
+
import * as ChannelPosts from "./channel-posts.ts";
|
|
9
10
|
import * as CommandTemplates from "./command-templates.ts";
|
|
10
11
|
import * as Commands from "./commands.ts";
|
|
11
12
|
import * as Config from "./config.ts";
|
|
@@ -498,6 +499,10 @@ interface TelegramCommandsAndToolsBindingDeps {
|
|
|
498
499
|
stopPolling?: () => Promise<void | string>;
|
|
499
500
|
recoverPollingStart?: Commands.TelegramBridgeCommandRegistrationDeps["recoverPollingStart"];
|
|
500
501
|
getDisconnectThreadName?: () => string | undefined;
|
|
502
|
+
setRequestedThreadNameForPollingStart?: (
|
|
503
|
+
threadName: string | undefined,
|
|
504
|
+
) => void;
|
|
505
|
+
validateThreadName?: Commands.TelegramBridgeCommandRegistrationDeps["validateThreadName"];
|
|
501
506
|
onTransportChanged?: () => Promise<void> | void;
|
|
502
507
|
getStatusLines: (
|
|
503
508
|
options?: Status.TelegramBridgeStatusLineOptions,
|
|
@@ -512,6 +517,12 @@ interface TelegramCommandsAndToolsBindingDeps {
|
|
|
512
517
|
target?: { chatId: number; threadId?: number };
|
|
513
518
|
},
|
|
514
519
|
) => Promise<number | undefined>;
|
|
520
|
+
sendChannelMarkdownMessage: NonNullable<
|
|
521
|
+
OutboundAttachments.TelegramOutboundMessageToolRegistrationDeps["sendChannelMarkdownMessage"]
|
|
522
|
+
>;
|
|
523
|
+
listChannelPosts: ChannelPosts.TelegramChannelPostJournalStore["list"];
|
|
524
|
+
mutateChannelPost(input: { action: "edit" | "delete"; operationId: string;
|
|
525
|
+
mutationId: string; markdown?: string }): Promise<ChannelPosts.TelegramChannelPostRecord>;
|
|
515
526
|
callMultipart: OutboundHandlers.TelegramVoiceReplySenderDeps["sendMultipart"];
|
|
516
527
|
getDefaultChatId: () => number | undefined;
|
|
517
528
|
getDefaultTarget?: () => OutboundAttachments.TelegramQueuedOutboundAttachmentTurnView["target"];
|
|
@@ -533,10 +544,15 @@ export function registerTelegramCommandsAndTools({
|
|
|
533
544
|
stopPolling,
|
|
534
545
|
recoverPollingStart,
|
|
535
546
|
getDisconnectThreadName,
|
|
547
|
+
setRequestedThreadNameForPollingStart,
|
|
548
|
+
validateThreadName,
|
|
536
549
|
onTransportChanged,
|
|
537
550
|
getStatusLines,
|
|
538
551
|
buttonActionStore,
|
|
539
552
|
sendMarkdownReply,
|
|
553
|
+
sendChannelMarkdownMessage,
|
|
554
|
+
listChannelPosts,
|
|
555
|
+
mutateChannelPost,
|
|
540
556
|
callMultipart,
|
|
541
557
|
getDefaultChatId,
|
|
542
558
|
getDefaultTarget,
|
|
@@ -556,6 +572,8 @@ export function registerTelegramCommandsAndTools({
|
|
|
556
572
|
sendMarkdownReply,
|
|
557
573
|
recordRuntimeEvent,
|
|
558
574
|
});
|
|
575
|
+
ChannelPosts.registerTelegramChannelPostMutationTool(pi, { mutate: mutateChannelPost });
|
|
576
|
+
ChannelPosts.registerTelegramChannelPostListTool(pi, { list: listChannelPosts });
|
|
559
577
|
OutboundAttachments.registerTelegramOutboundAttachmentTool(pi, {
|
|
560
578
|
getActiveTurn: activeTurnRuntime.get,
|
|
561
579
|
getDefaultChatId,
|
|
@@ -578,6 +596,7 @@ export function registerTelegramCommandsAndTools({
|
|
|
578
596
|
),
|
|
579
597
|
sendMarkdownMessage: (chatId, markdown, options) =>
|
|
580
598
|
sendMarkdownReply(chatId, undefined, markdown, options),
|
|
599
|
+
sendChannelMarkdownMessage,
|
|
581
600
|
recordRuntimeEvent,
|
|
582
601
|
});
|
|
583
602
|
const queueAgentConnectionContext = (connected: boolean): void => {
|
|
@@ -636,7 +655,11 @@ export function registerTelegramCommandsAndTools({
|
|
|
636
655
|
);
|
|
637
656
|
}
|
|
638
657
|
await configStore.load();
|
|
639
|
-
configStore.
|
|
658
|
+
const latestProfile = configStore.getStoredConfig().profiles?.[profileName];
|
|
659
|
+
configStore.setProfile(profileName, {
|
|
660
|
+
...profile,
|
|
661
|
+
threadDisplayMode: latestProfile?.threadDisplayMode,
|
|
662
|
+
});
|
|
640
663
|
configStore.activateProfile(profileName);
|
|
641
664
|
await onTransportChanged?.();
|
|
642
665
|
await persistConfig(configStore.get());
|
|
@@ -670,16 +693,20 @@ export function registerTelegramCommandsAndTools({
|
|
|
670
693
|
reloadConfig: configStore.load,
|
|
671
694
|
hasBotToken: configStore.hasBotToken,
|
|
672
695
|
startPolling: async (ctx, options) => {
|
|
696
|
+
setRequestedThreadNameForPollingStart?.(options?.requestedThreadName);
|
|
673
697
|
try {
|
|
674
698
|
return await lockedPollingRuntime.start(ctx, options);
|
|
675
699
|
} catch (error) {
|
|
676
700
|
recordRuntimeEvent("recovery", error, { phase: "polling-start" });
|
|
677
701
|
throw error;
|
|
702
|
+
} finally {
|
|
703
|
+
setRequestedThreadNameForPollingStart?.(undefined);
|
|
678
704
|
}
|
|
679
705
|
},
|
|
680
706
|
stopPolling: stopPolling ?? lockedPollingRuntime.stop,
|
|
681
707
|
recoverPollingStart,
|
|
682
708
|
getDisconnectThreadName,
|
|
709
|
+
validateThreadName,
|
|
683
710
|
queueAgentConnectionContext,
|
|
684
711
|
updateStatus,
|
|
685
712
|
getProfileNames: () =>
|