@markusylisiurunen/tau 0.3.43 → 0.3.45
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/README.md +8 -11
- package/dist/core/agent/agent_runtime.js +23 -8
- package/dist/core/agent/agent_runtime.js.map +1 -1
- package/dist/core/config/content_loader.js +1 -63
- package/dist/core/config/content_loader.js.map +1 -1
- package/dist/core/nook/client.js +11 -4
- package/dist/core/nook/client.js.map +1 -1
- package/dist/core/nook/setup.js +5 -2
- package/dist/core/nook/setup.js.map +1 -1
- package/dist/core/runtime/chat_runtime.js +4 -4
- package/dist/core/subagents/agent_supervisor.js +1 -1
- package/dist/core/subagents/agent_supervisor.js.map +1 -1
- package/dist/core/subagents/registry.js +5 -9
- package/dist/core/subagents/registry.js.map +1 -1
- package/dist/core/subagents/types.js.map +1 -1
- package/dist/core/telegram/adapter.js +38 -14
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/telegram/session_manager.js +404 -32
- package/dist/core/telegram/session_manager.js.map +1 -1
- package/dist/core/tools/catalog.js +2 -2
- package/dist/core/tools/spawn_agent.js +30 -40
- package/dist/core/tools/spawn_agent.js.map +1 -1
- package/dist/core/tools/web.js +5 -1
- package/dist/core/tools/web.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/host/execution_runtime.js +8 -18
- package/dist/host/execution_runtime.js.map +1 -1
- package/dist/host/local_session_host.js +140 -28
- package/dist/host/local_session_host.js.map +1 -1
- package/dist/host/session_host.js.map +1 -1
- package/dist/host/session_protocol_handler.js +2 -7
- package/dist/host/session_protocol_handler.js.map +1 -1
- package/dist/nook/README.md +3 -3
- package/dist/nook/worker/index.js +70 -1
- package/dist/nook/worker/index.js.map +1 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/session_protocol.d.ts +13 -1
- package/dist/protocol/session_protocol.js +57 -3
- package/dist/protocol/session_protocol.js.map +1 -1
- package/dist/sdk/index.d.ts +4 -2
- package/dist/sdk/index.js +9 -0
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/types.d.ts +2 -1
- package/dist/store/session_snapshot_migrations.js +21 -1
- package/dist/store/session_snapshot_migrations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssistantMessage, Message, TextContent, ThinkingContent, Tool, ToolCall } from "@earendil-works/pi-ai";
|
|
2
|
-
export declare const SESSION_PROTOCOL_VERSION:
|
|
2
|
+
export declare const SESSION_PROTOCOL_VERSION: 10;
|
|
3
3
|
export declare const SESSION_PROTOCOL_MAX_EXEC_CAPTURE_BYTES: number;
|
|
4
4
|
export declare const SESSION_PROTOCOL_MAX_EXEC_STDIN_BYTES: number;
|
|
5
5
|
export declare const SESSION_PROTOCOL_METHODS: readonly ["initialize", "session.create", "session.list", "session.observe", "session.unobserve", "session.record", "session.submit", "session.queue", "session.steer", "session.cancelPendingMessages", "session.retry", "session.exec", "session.cancelExec", "session.sample", "session.interrupt", "session.snapshot", "session.startGoal", "session.resumeGoal", "session.clearGoal", "session.setReasoning", "session.setPersona", "session.resolvePrompt", "session.autocompletePaths", "session.reload", "session.compact", "session.rewind", "session.interruptSubagent", "session.ephemeral.create", "session.ephemeral.submit", "session.ephemeral.close", "session.clientTool.ack", "session.clientTool.result"];
|
|
@@ -213,6 +213,14 @@ export type SessionProtocolTurnOutcome = {
|
|
|
213
213
|
reason: "auto-compaction-failed";
|
|
214
214
|
message: string;
|
|
215
215
|
};
|
|
216
|
+
export type SessionProtocolTurnRecord = {
|
|
217
|
+
userHistoryEntryId: string;
|
|
218
|
+
state: "running";
|
|
219
|
+
} | {
|
|
220
|
+
userHistoryEntryId: string;
|
|
221
|
+
state: "settled";
|
|
222
|
+
outcome: SessionProtocolTurnOutcome;
|
|
223
|
+
};
|
|
216
224
|
export type SessionProtocolTurnResult = {
|
|
217
225
|
turn: SessionProtocolTurnOutcome;
|
|
218
226
|
};
|
|
@@ -496,6 +504,7 @@ export type SessionProtocolSnapshot = {
|
|
|
496
504
|
catalog: SessionProtocolContentCatalogSnapshot;
|
|
497
505
|
executionEnvironment: SessionProtocolExecutionEnvironmentSnapshot;
|
|
498
506
|
messages: SessionProtocolMessage[];
|
|
507
|
+
turns: Record<string, SessionProtocolTurnRecord>;
|
|
499
508
|
timeline: SessionProtocolTimeline;
|
|
500
509
|
tools: Record<string, SessionProtocolToolRun>;
|
|
501
510
|
operations: Record<string, SessionProtocolOperation>;
|
|
@@ -743,6 +752,9 @@ export type SessionProtocolChange = {
|
|
|
743
752
|
} | {
|
|
744
753
|
type: "settings.set";
|
|
745
754
|
settings: SessionProtocolSettingsSnapshot;
|
|
755
|
+
} | {
|
|
756
|
+
type: "turn.set";
|
|
757
|
+
turn: SessionProtocolTurnRecord;
|
|
746
758
|
} | {
|
|
747
759
|
type: "message.append";
|
|
748
760
|
message: SessionProtocolMessage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const SESSION_PROTOCOL_VERSION =
|
|
2
|
+
export const SESSION_PROTOCOL_VERSION = 10;
|
|
3
3
|
export const SESSION_PROTOCOL_MAX_EXEC_CAPTURE_BYTES = 24 * 1024 * 1024;
|
|
4
4
|
export const SESSION_PROTOCOL_MAX_EXEC_STDIN_BYTES = 16 * 1024 * 1024;
|
|
5
5
|
const SESSION_PROTOCOL_NOTICE_TITLE_MAX_CHARS = 512;
|
|
@@ -105,6 +105,7 @@ const nonEmptyStringSchema = z
|
|
|
105
105
|
.string()
|
|
106
106
|
.min(1)
|
|
107
107
|
.refine((value) => value.trim().length > 0);
|
|
108
|
+
const historyEntryIdSchema = nonEmptyStringSchema.transform((value) => value.trim());
|
|
108
109
|
const noticeTitleSchema = nonEmptyStringSchema
|
|
109
110
|
.max(SESSION_PROTOCOL_NOTICE_TITLE_MAX_CHARS)
|
|
110
111
|
.refine((value) => !value.includes("\n") && !value.includes("\r"), "notice title must be one line");
|
|
@@ -370,7 +371,7 @@ const sessionProtocolUserMessageParamsSchema = z
|
|
|
370
371
|
.object({
|
|
371
372
|
sessionId: nonEmptyStringSchema,
|
|
372
373
|
text: nonEmptyStringSchema,
|
|
373
|
-
historyEntryId:
|
|
374
|
+
historyEntryId: historyEntryIdSchema.optional(),
|
|
374
375
|
})
|
|
375
376
|
.strip();
|
|
376
377
|
const sessionProtocolStartGoalParamsSchema = z
|
|
@@ -484,7 +485,7 @@ const sessionProtocolCompactParamsSchema = z
|
|
|
484
485
|
const sessionProtocolRewindParamsSchema = z
|
|
485
486
|
.object({
|
|
486
487
|
sessionId: nonEmptyStringSchema,
|
|
487
|
-
historyEntryId:
|
|
488
|
+
historyEntryId: historyEntryIdSchema,
|
|
488
489
|
})
|
|
489
490
|
.strip();
|
|
490
491
|
const sessionProtocolInterruptSubagentParamsSchema = z
|
|
@@ -1055,6 +1056,16 @@ const sessionProtocolAgentStateSnapshotSchema = z
|
|
|
1055
1056
|
.optional(),
|
|
1056
1057
|
})
|
|
1057
1058
|
.strip();
|
|
1059
|
+
const sessionProtocolTurnRecordSchema = z.discriminatedUnion("state", [
|
|
1060
|
+
z.object({ userHistoryEntryId: nonEmptyStringSchema, state: z.literal("running") }).strip(),
|
|
1061
|
+
z
|
|
1062
|
+
.object({
|
|
1063
|
+
userHistoryEntryId: nonEmptyStringSchema,
|
|
1064
|
+
state: z.literal("settled"),
|
|
1065
|
+
outcome: sessionProtocolTurnOutcomeSchema,
|
|
1066
|
+
})
|
|
1067
|
+
.strip(),
|
|
1068
|
+
]);
|
|
1058
1069
|
const sessionProtocolSnapshotSchema = z
|
|
1059
1070
|
.object({
|
|
1060
1071
|
sessionId: nonEmptyStringSchema,
|
|
@@ -1070,6 +1081,7 @@ const sessionProtocolSnapshotSchema = z
|
|
|
1070
1081
|
catalog: sessionProtocolContentCatalogSnapshotSchema,
|
|
1071
1082
|
executionEnvironment: sessionProtocolExecutionEnvironmentSnapshotSchema,
|
|
1072
1083
|
messages: z.array(sessionProtocolMessageSchema),
|
|
1084
|
+
turns: z.record(nonEmptyStringSchema, sessionProtocolTurnRecordSchema),
|
|
1073
1085
|
timeline: sessionProtocolTimelineSchema,
|
|
1074
1086
|
tools: z.record(nonEmptyStringSchema, sessionProtocolToolRunSchema),
|
|
1075
1087
|
operations: z.record(nonEmptyStringSchema, sessionProtocolOperationSchema),
|
|
@@ -1294,6 +1306,15 @@ const sessionProtocolSnapshotSchema = z
|
|
|
1294
1306
|
}
|
|
1295
1307
|
}
|
|
1296
1308
|
}
|
|
1309
|
+
for (const [id, turn] of Object.entries(snapshot.turns)) {
|
|
1310
|
+
if (id !== turn.userHistoryEntryId) {
|
|
1311
|
+
ctx.addIssue({
|
|
1312
|
+
code: "custom",
|
|
1313
|
+
path: ["turns", id],
|
|
1314
|
+
message: `turn map key '${id}' does not match embedded user history entry id '${turn.userHistoryEntryId}'`,
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1297
1318
|
for (const [id, agent] of Object.entries(snapshot.agents)) {
|
|
1298
1319
|
if (id !== agent.id) {
|
|
1299
1320
|
ctx.addIssue({
|
|
@@ -1387,6 +1408,12 @@ const sessionProtocolChangeSchema = z.discriminatedUnion("type", [
|
|
|
1387
1408
|
settings: sessionProtocolSettingsSnapshotSchema,
|
|
1388
1409
|
})
|
|
1389
1410
|
.strip(),
|
|
1411
|
+
z
|
|
1412
|
+
.object({
|
|
1413
|
+
type: z.literal("turn.set"),
|
|
1414
|
+
turn: sessionProtocolTurnRecordSchema,
|
|
1415
|
+
})
|
|
1416
|
+
.strip(),
|
|
1390
1417
|
z
|
|
1391
1418
|
.object({
|
|
1392
1419
|
type: z.literal("message.append"),
|
|
@@ -1937,6 +1964,9 @@ export function applySessionProtocolDelta(snapshot, message) {
|
|
|
1937
1964
|
case "settings.set":
|
|
1938
1965
|
next.settings = structuredClone(change.settings);
|
|
1939
1966
|
break;
|
|
1967
|
+
case "turn.set":
|
|
1968
|
+
setSessionProtocolTurn(next.turns, change.turn);
|
|
1969
|
+
break;
|
|
1940
1970
|
case "message.append":
|
|
1941
1971
|
next.messages.push(structuredClone(change.message));
|
|
1942
1972
|
break;
|
|
@@ -2017,6 +2047,7 @@ function changeCanInvalidateSnapshot(snapshot, change) {
|
|
|
2017
2047
|
case "goal.set":
|
|
2018
2048
|
case "cost.set":
|
|
2019
2049
|
case "settings.set":
|
|
2050
|
+
case "turn.set":
|
|
2020
2051
|
case "agent.set":
|
|
2021
2052
|
return false;
|
|
2022
2053
|
case "tool.set": {
|
|
@@ -2066,14 +2097,33 @@ function hasSameFacetSubject(previous, facet) {
|
|
|
2066
2097
|
(previous.subject.type === "session" ||
|
|
2067
2098
|
(facet.subject.type !== "session" && previous.subject.id === facet.subject.id)));
|
|
2068
2099
|
}
|
|
2100
|
+
function setSessionProtocolTurn(turns, turn) {
|
|
2101
|
+
const previous = Object.hasOwn(turns, turn.userHistoryEntryId)
|
|
2102
|
+
? turns[turn.userHistoryEntryId]
|
|
2103
|
+
: undefined;
|
|
2104
|
+
if (previous?.state === "settled" && JSON.stringify(previous) !== JSON.stringify(turn)) {
|
|
2105
|
+
throw new Error(`settled turn '${turn.userHistoryEntryId}' cannot be changed`);
|
|
2106
|
+
}
|
|
2107
|
+
Object.defineProperty(turns, turn.userHistoryEntryId, {
|
|
2108
|
+
configurable: true,
|
|
2109
|
+
enumerable: true,
|
|
2110
|
+
value: structuredClone(turn),
|
|
2111
|
+
writable: true,
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2069
2114
|
function applyKeyedRecordDelta(snapshot, message) {
|
|
2070
2115
|
if (message.delta.type !== "snapshot.patch") {
|
|
2071
2116
|
return undefined;
|
|
2072
2117
|
}
|
|
2118
|
+
let nextTurns;
|
|
2073
2119
|
let nextTools;
|
|
2074
2120
|
let nextOperations;
|
|
2075
2121
|
let nextAgents;
|
|
2076
2122
|
let nextFacets;
|
|
2123
|
+
const cloneTurns = () => {
|
|
2124
|
+
nextTurns ??= { ...snapshot.turns };
|
|
2125
|
+
return nextTurns;
|
|
2126
|
+
};
|
|
2077
2127
|
const cloneTools = () => {
|
|
2078
2128
|
nextTools ??= { ...snapshot.tools };
|
|
2079
2129
|
return nextTools;
|
|
@@ -2092,6 +2142,9 @@ function applyKeyedRecordDelta(snapshot, message) {
|
|
|
2092
2142
|
};
|
|
2093
2143
|
for (const change of message.delta.changes) {
|
|
2094
2144
|
switch (change.type) {
|
|
2145
|
+
case "turn.set":
|
|
2146
|
+
setSessionProtocolTurn(cloneTurns(), change.turn);
|
|
2147
|
+
break;
|
|
2095
2148
|
case "tool.set":
|
|
2096
2149
|
cloneTools()[change.tool.id] = structuredClone(change.tool);
|
|
2097
2150
|
break;
|
|
@@ -2123,6 +2176,7 @@ function applyKeyedRecordDelta(snapshot, message) {
|
|
|
2123
2176
|
return {
|
|
2124
2177
|
...snapshot,
|
|
2125
2178
|
revision: message.toRevision,
|
|
2179
|
+
...(nextTurns ? { turns: nextTurns } : {}),
|
|
2126
2180
|
...(nextTools ? { tools: nextTools } : {}),
|
|
2127
2181
|
...(nextOperations ? { operations: nextOperations } : {}),
|
|
2128
2182
|
...(nextAgents ? { agents: nextAgents } : {}),
|