@downcity/agent 1.1.277 → 1.1.278

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.
Files changed (41) hide show
  1. package/bin/agent/Agent.d.ts.map +1 -1
  2. package/bin/agent/Agent.js +0 -1
  3. package/bin/agent/Agent.js.map +1 -1
  4. package/bin/agent/AgentSessions.d.ts +0 -4
  5. package/bin/agent/AgentSessions.d.ts.map +1 -1
  6. package/bin/agent/AgentSessions.js +2 -17
  7. package/bin/agent/AgentSessions.js.map +1 -1
  8. package/bin/session/Session.d.ts +11 -1
  9. package/bin/session/Session.d.ts.map +1 -1
  10. package/bin/session/Session.js +61 -24
  11. package/bin/session/Session.js.map +1 -1
  12. package/bin/session/storage/Instruction.d.ts +14 -0
  13. package/bin/session/storage/Instruction.d.ts.map +1 -0
  14. package/bin/session/storage/Instruction.js +44 -0
  15. package/bin/session/storage/Instruction.js.map +1 -0
  16. package/bin/session/storage/Paths.d.ts +8 -0
  17. package/bin/session/storage/Paths.d.ts.map +1 -1
  18. package/bin/session/storage/Paths.js +10 -0
  19. package/bin/session/storage/Paths.js.map +1 -1
  20. package/bin/types/agent/SessionActor.d.ts +2 -0
  21. package/bin/types/agent/SessionActor.d.ts.map +1 -1
  22. package/bin/types/session/SessionInstruction.d.ts +22 -0
  23. package/bin/types/session/SessionInstruction.d.ts.map +1 -0
  24. package/bin/types/session/SessionInstruction.js +9 -0
  25. package/bin/types/session/SessionInstruction.js.map +1 -0
  26. package/bin/types/session/SessionOptions.d.ts +6 -2
  27. package/bin/types/session/SessionOptions.d.ts.map +1 -1
  28. package/bin/types/session/SessionQueue.d.ts +2 -18
  29. package/bin/types/session/SessionQueue.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/scripts/session-config-turn-boundary.test.mjs +156 -5
  32. package/src/agent/Agent.ts +0 -1
  33. package/src/agent/AgentSessions.ts +2 -21
  34. package/src/session/Session.ts +68 -26
  35. package/src/session/storage/Instruction.ts +59 -0
  36. package/src/session/storage/Paths.ts +18 -0
  37. package/src/types/agent/SessionActor.ts +3 -0
  38. package/src/types/session/SessionInstruction.ts +24 -0
  39. package/src/types/session/SessionOptions.ts +6 -2
  40. package/src/types/session/SessionQueue.ts +9 -29
  41. package/tsconfig.tsbuildinfo +1 -1
@@ -125,6 +125,9 @@ export interface AgentSession extends AgentSessionActor {
125
125
  /** 写入当前 session 默认配置。 */
126
126
  set(input: AgentSessionSetInput): Promise<void>;
127
127
 
128
+ /** 把当前 Session 生效的自定义 instruction 显式固化到 instruction.md。 */
129
+ snapshot(): Promise<void>;
130
+
128
131
  /** 从当前 session 创建一个分叉会话。 */
129
132
  fork(input?: AgentSessionForkInput | string): Promise<AgentSession>;
130
133
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Session instruction 显式快照存储类型。
3
+ *
4
+ * 关键点(中文)
5
+ * - 这里只描述 instruction.md 的定位与写入输入。
6
+ * - 文件存在性本身用于表达 Session 是否启用显式 instruction 快照。
7
+ */
8
+
9
+ /** Session instruction.md 的稳定定位信息。 */
10
+ export interface SessionInstructionStorageLocation {
11
+ /** 当前项目根目录。 */
12
+ project_root: string;
13
+ /** 当前 Agent 稳定标识。 */
14
+ agent_id: string;
15
+ /** 当前 Session 稳定标识。 */
16
+ session_id: string;
17
+ }
18
+
19
+ /** 原子写入 Session instruction.md 使用的完整输入。 */
20
+ export interface WriteSessionInstructionInput
21
+ extends SessionInstructionStorageLocation {
22
+ /** 当前 Session 生效的自定义 instruction Markdown。 */
23
+ instruction: string;
24
+ }
@@ -74,9 +74,13 @@ export interface SessionOptions {
74
74
  logger: Logger;
75
75
 
76
76
  /**
77
- * 读取当前 SDK 调用方传入的 instruction system blocks。
77
+ * 当前 Session 创建时绑定的 instruction system blocks。
78
+ *
79
+ * 关键点(中文)
80
+ * - Session 创建后不再动态读取 Agent instruction。
81
+ * - `session.snapshot()` 只会把其中 `instruction` 来源的内容显式写入本地文件。
78
82
  */
79
- getInstructionSystemBlocks: () => AgentSessionSystemBlock[];
83
+ instruction_system_blocks: AgentSessionSystemBlock[];
80
84
 
81
85
  /**
82
86
  * 读取当前 Agent configured env。
@@ -4,7 +4,7 @@
4
4
  * 队列只保存明确的输入事实,不保存可执行闭包。SessionTurn 是这些输入的唯一解释者。
5
5
  */
6
6
 
7
- import type { AgentSessionConfigSnapshot, AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
7
+ import type { AgentSessionConfigSnapshot } from "@/types/agent/SessionTypes.js";
8
8
  import type { AgentPluginExecutionRuntime } from "@/types/plugin/PluginRuntime.js";
9
9
  import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
10
10
  import type { AgentSessionTurnHandle } from "@/types/sdk/AgentSessionTurn.js";
@@ -23,16 +23,6 @@ export interface SessionModelQueueCommand {
23
23
  action_title?: string;
24
24
  }
25
25
 
26
- /** Agent instruction 在 Session Step 检查点生效的命令。 */
27
- export interface SessionInstructionQueueCommand {
28
- /** 命令种类固定为 Agent instruction 更新。 */
29
- type: "agent_instruction";
30
- /** 当前命令的稳定唯一标识。 */
31
- command_id: string;
32
- /** 下一 Step 使用的完整 instruction blocks。 */
33
- instruction_blocks: AgentSessionSystemBlock[];
34
- }
35
-
36
26
  /** Agent env 在 Session Step 检查点生效的命令。 */
37
27
  export interface SessionEnvQueueCommand {
38
28
  /** 命令种类固定为 Agent env 更新。 */
@@ -66,29 +56,19 @@ export interface SessionCompactQueueCommand {
66
56
  /** Session FIFO 中允许出现的领域命令。 */
67
57
  export type SessionQueueCommand =
68
58
  | SessionModelQueueCommand
69
- | SessionInstructionQueueCommand
70
59
  | SessionEnvQueueCommand
71
60
  | SessionPluginsQueueCommand
72
61
  | SessionCompactQueueCommand;
73
62
 
74
63
  /** Agent configured state 广播给既有 Session 的输入。 */
75
- export type AgentSessionCommand =
76
- | {
77
- /** 当前修改固定为 instruction。 */
78
- type: "instruction";
79
- /** 当前命令唯一标识。 */
80
- command_id: string;
81
- /** 下一 Session Step 使用的 instruction blocks。 */
82
- instruction_blocks: AgentSessionSystemBlock[];
83
- }
84
- | {
85
- /** 当前修改固定为 env。 */
86
- type: "env";
87
- /** 当前命令唯一标识。 */
88
- command_id: string;
89
- /** 下一 Session Step 使用的完整 Agent env。 */
90
- env: Record<string, string>;
91
- }
64
+ export type AgentSessionCommand = {
65
+ /** 当前修改固定为 env。 */
66
+ type: "env";
67
+ /** 当前命令唯一标识。 */
68
+ command_id: string;
69
+ /** 下一 Session Step 使用的完整 Agent env。 */
70
+ env: Record<string, string>;
71
+ }
92
72
  | {
93
73
  /** 当前修改固定为 plugins。 */
94
74
  type: "plugins";