saeeol 1.2.0 → 1.2.1

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 (81) hide show
  1. package/package.json +14 -14
  2. package/src/session/compaction-helpers.ts +1 -169
  3. package/src/session/compaction.ts +1 -712
  4. package/src/session/core/compaction/compaction-helpers.ts +169 -0
  5. package/src/session/core/compaction/compaction.ts +712 -0
  6. package/src/session/core/compaction/overflow.ts +28 -0
  7. package/src/session/core/instruction.ts +234 -0
  8. package/src/session/core/llm.ts +504 -0
  9. package/src/session/core/network.ts +392 -0
  10. package/src/session/core/processor.ts +731 -0
  11. package/src/session/core/projectors.ts +139 -0
  12. package/src/session/core/resolve-tools.ts +241 -0
  13. package/src/session/core/retry.ts +149 -0
  14. package/src/session/core/revert.ts +173 -0
  15. package/src/session/core/run-state.ts +110 -0
  16. package/src/session/core/schema.ts +35 -0
  17. package/src/session/core/session-types.ts +160 -0
  18. package/src/session/core/session.sql.ts +124 -0
  19. package/src/session/core/session.ts +948 -0
  20. package/src/session/core/shell-exec.ts +205 -0
  21. package/src/session/core/status.ts +100 -0
  22. package/src/session/core/subtask.ts +268 -0
  23. package/src/session/core/summary.ts +173 -0
  24. package/src/session/core/system.ts +114 -0
  25. package/src/session/core/todo.ts +86 -0
  26. package/src/session/core/user-part.ts +293 -0
  27. package/src/session/instruction.ts +1 -234
  28. package/src/session/llm.ts +1 -504
  29. package/src/session/message/message-errors.ts +83 -0
  30. package/src/session/message/message-parts.ts +89 -0
  31. package/src/session/message/message-query.ts +107 -0
  32. package/src/session/message/message-transform.ts +156 -0
  33. package/src/session/message/message-types.ts +68 -0
  34. package/src/session/message/message-v2.ts +73 -0
  35. package/src/session/message/message.ts +192 -0
  36. package/src/session/message-errors.ts +1 -83
  37. package/src/session/message-parts.ts +1 -89
  38. package/src/session/message-query.ts +1 -107
  39. package/src/session/message-transform.ts +1 -156
  40. package/src/session/message-types.ts +1 -68
  41. package/src/session/message-v2.ts +1 -73
  42. package/src/session/message.ts +1 -192
  43. package/src/session/network.ts +1 -392
  44. package/src/session/overflow.ts +1 -28
  45. package/src/session/processor.ts +1 -731
  46. package/src/session/projectors.ts +2 -139
  47. package/src/session/prompt/prompt-command.ts +93 -0
  48. package/src/session/prompt/prompt-loop.ts +299 -0
  49. package/src/session/prompt/prompt-model.ts +44 -0
  50. package/src/session/prompt/prompt-reminders.ts +120 -0
  51. package/src/session/prompt/prompt-resolve.ts +42 -0
  52. package/src/session/prompt/prompt-schemas.ts +128 -0
  53. package/src/session/prompt/prompt-title.ts +55 -0
  54. package/src/session/prompt/prompt-types.ts +47 -0
  55. package/src/session/prompt/prompt-user-msg.ts +80 -0
  56. package/src/session/prompt/prompt.ts +211 -0
  57. package/src/session/prompt-command.ts +1 -93
  58. package/src/session/prompt-loop.ts +1 -299
  59. package/src/session/prompt-model.ts +1 -44
  60. package/src/session/prompt-reminders.ts +1 -120
  61. package/src/session/prompt-resolve.ts +1 -42
  62. package/src/session/prompt-schemas.ts +1 -128
  63. package/src/session/prompt-title.ts +1 -55
  64. package/src/session/prompt-types.ts +1 -47
  65. package/src/session/prompt-user-msg.ts +1 -80
  66. package/src/session/prompt.ts +1 -211
  67. package/src/session/resolve-tools.ts +1 -241
  68. package/src/session/retry.ts +1 -149
  69. package/src/session/revert.ts +1 -173
  70. package/src/session/run-state.ts +1 -110
  71. package/src/session/schema.ts +1 -35
  72. package/src/session/session-types.ts +1 -160
  73. package/src/session/session.sql.ts +1 -124
  74. package/src/session/session.ts +1 -948
  75. package/src/session/shell-exec.ts +1 -205
  76. package/src/session/status.ts +1 -100
  77. package/src/session/subtask.ts +1 -268
  78. package/src/session/summary.ts +1 -173
  79. package/src/session/system.ts +1 -114
  80. package/src/session/todo.ts +1 -86
  81. package/src/session/user-part.ts +1 -293
@@ -1,68 +1 @@
1
- /** User/Assistant 스키마 + Events + Cursor — message-v2.ts에서 분리 */
2
-
3
- import { SessionID, MessageID, PartID } from "./schema"
4
- import { Snapshot } from "@/snapshot"
5
- import { SyncEvent } from "../sync"
6
- import { BusEvent } from "@/bus/bus-event"
7
- import { Effect, Schema, Types } from "effect"
8
- import { zod } from "@/util/effect-zod"
9
- import { NonNegativeInt, withStatics } from "@/util/schema"
10
- import { ModelID, ProviderID } from "@/provider/schema"
11
- import { _Part } from "./message-parts"
12
- import { AssistantErrorSchema, AssistantErrorZod, _Format } from "./message-errors"
13
- export { AssistantErrorSchema, AssistantErrorZod, _Format, _Part as Part }
14
- export type { AssistantError } from "./message-errors"
15
- import z from "zod"
16
-
17
- const messageBase = { id: MessageID, sessionID: SessionID }
18
-
19
- export const EditorContext = Schema.Struct({
20
- visibleFiles: Schema.optional(Schema.Array(Schema.String)), openTabs: Schema.optional(Schema.Array(Schema.String)),
21
- activeFile: Schema.optional(Schema.String), shell: Schema.optional(Schema.String),
22
- })
23
- export type EditorContext = Types.DeepMutable<Schema.Schema.Type<typeof EditorContext>>
24
-
25
- export const User = Schema.Struct({
26
- ...messageBase, role: Schema.Literal("user"), time: Schema.Struct({ created: NonNegativeInt }), format: Schema.optional(_Format),
27
- summary: Schema.optional(Schema.Struct({ title: Schema.optional(Schema.String), body: Schema.optional(Schema.String), diffs: Schema.Array(Snapshot.FileDiff) })),
28
- agent: Schema.String, model: Schema.Struct({ providerID: ProviderID, modelID: ModelID, variant: Schema.optional(Schema.String) }),
29
- system: Schema.optional(Schema.String), tools: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)), editorContext: Schema.optional(EditorContext),
30
- }).annotate({ identifier: "UserMessage" }).pipe(withStatics((s) => ({ zod: zod(s) })))
31
- export type User = Types.DeepMutable<Schema.Schema.Type<typeof User>>
32
-
33
- export const Assistant = Schema.Struct({
34
- ...messageBase, role: Schema.Literal("assistant"), time: Schema.Struct({ created: NonNegativeInt, completed: Schema.optional(NonNegativeInt) }),
35
- error: Schema.optional(AssistantErrorSchema), parentID: MessageID, modelID: ModelID, providerID: ProviderID, mode: Schema.String, agent: Schema.String,
36
- path: Schema.Struct({ cwd: Schema.String, root: Schema.String }), summary: Schema.optional(Schema.Boolean), cost: Schema.Finite,
37
- tokens: Schema.Struct({ total: Schema.optional(NonNegativeInt), input: NonNegativeInt, output: NonNegativeInt, reasoning: NonNegativeInt, cache: Schema.Struct({ read: NonNegativeInt, write: NonNegativeInt }) }),
38
- structured: Schema.optional(Schema.Any), variant: Schema.optional(Schema.String), finish: Schema.optional(Schema.String),
39
- }).annotate({ identifier: "AssistantMessage" }).pipe(withStatics((s) => ({ zod: zod(s) })))
40
- export type Assistant = Omit<Types.DeepMutable<Schema.Schema.Type<typeof Assistant>>, "error"> & { error?: import("./message-errors").AssistantError }
41
-
42
- const _Info = Schema.Union([User, Assistant]).annotate({ discriminator: "role", identifier: "Message" })
43
- export const Info = Object.assign(_Info, { zod: zod(_Info) as unknown as z.ZodType<User | Assistant> })
44
- export type Info = User | Assistant
45
-
46
- export const WithParts = Schema.Struct({ info: _Info, parts: Schema.Array(_Part) }).pipe(withStatics((s) => ({ zod: zod(s) })))
47
- export type WithParts = { info: Info; parts: import("./message-parts").Part[] }
48
-
49
- const UpdatedEventSchema = Schema.Struct({ sessionID: SessionID, info: _Info })
50
- const RemovedEventSchema = Schema.Struct({ sessionID: SessionID, messageID: MessageID })
51
- const PartUpdatedEventSchema = Schema.Struct({ sessionID: SessionID, part: _Part, time: NonNegativeInt })
52
- const PartRemovedEventSchema = Schema.Struct({ sessionID: SessionID, messageID: MessageID, partID: PartID })
53
-
54
- export const Event = {
55
- Updated: SyncEvent.define({ type: "message.updated", version: 1, aggregate: "sessionID", schema: UpdatedEventSchema }),
56
- Removed: SyncEvent.define({ type: "message.removed", version: 1, aggregate: "sessionID", schema: RemovedEventSchema }),
57
- PartUpdated: SyncEvent.define({ type: "message.part.updated", version: 1, aggregate: "sessionID", schema: PartUpdatedEventSchema }),
58
- PartDelta: BusEvent.define("message.part.delta", Schema.Struct({ sessionID: SessionID, messageID: MessageID, partID: PartID, field: Schema.String, delta: Schema.String })),
59
- PartRemoved: SyncEvent.define({ type: "message.part.removed", version: 1, aggregate: "sessionID", schema: PartRemovedEventSchema }),
60
- }
61
-
62
- const Cursor = Schema.Struct({ id: MessageID, time: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)) })
63
- type Cursor = typeof Cursor.Type
64
- const decodeCursor = Schema.decodeUnknownSync(Cursor)
65
- export const cursor = {
66
- encode(input: Cursor) { return Buffer.from(JSON.stringify(input)).toString("base64url") },
67
- decode(input: string) { return decodeCursor(JSON.parse(Buffer.from(input, "base64url").toString("utf8"))) },
68
- }
1
+ export * from "./message/message-types"
@@ -1,73 +1 @@
1
- export {
2
- OutputLengthError,
3
- AbortedError,
4
- StructuredOutputError,
5
- AuthError,
6
- APIError,
7
- ContextOverflowError,
8
- OutputFormatText,
9
- OutputFormatJsonSchema,
10
- Format,
11
- fromError,
12
- } from "./message-errors"
13
- export type { OutputFormat } from "./message-errors"
14
-
15
- export {
16
- SnapshotPart,
17
- PatchPart,
18
- TextPart,
19
- ReasoningPart,
20
- FileSource,
21
- SymbolSource,
22
- ResourceSource,
23
- FilePartSource,
24
- FilePart,
25
- AgentPart,
26
- CompactionPart,
27
- SubtaskPart,
28
- RetryPart,
29
- StepStartPart,
30
- StepFinishPart,
31
- ToolStatePending,
32
- ToolStateRunning,
33
- ToolStateCompleted,
34
- ToolStateError,
35
- ToolState,
36
- ToolPart,
37
- truncateToolOutput,
38
- TextPartInput,
39
- FilePartInput,
40
- AgentPartInput,
41
- SubtaskPartInput,
42
- Part,
43
- } from "./message-parts"
44
-
45
- export {
46
- EditorContext,
47
- User,
48
- Assistant,
49
- Info,
50
- WithParts,
51
- Event,
52
- cursor,
53
- } from "./message-types"
54
-
55
- export {
56
- SYNTHETIC_ATTACHMENT_PROMPT,
57
- isMedia,
58
- stripPartMetadata,
59
- stripMessageMetadata,
60
- toModelMessagesEffect,
61
- toModelMessages,
62
- } from "./message-transform"
63
-
64
- export {
65
- page,
66
- stream,
67
- parts,
68
- get,
69
- filterCompacted,
70
- filterCompactedEffect,
71
- } from "./message-query"
72
-
73
- export * as MessageV2 from "./message-v2"
1
+ export * from "./message/message-v2"
@@ -1,192 +1 @@
1
- import { Schema } from "effect"
2
- import { SessionID } from "./schema"
3
- import { ModelID, ProviderID } from "../provider/schema"
4
- import { zod } from "@/util/effect-zod"
5
- import { NonNegativeInt, withStatics } from "@/util/schema"
6
- import { namedSchemaError } from "@/util/named-schema-error"
7
-
8
- export const OutputLengthError = namedSchemaError("MessageOutputLengthError", {})
9
- export const AuthError = namedSchemaError("ProviderAuthError", {
10
- providerID: Schema.String,
11
- message: Schema.String,
12
- })
13
-
14
- const AuthErrorEffect = Schema.Struct({
15
- name: Schema.Literal("ProviderAuthError"),
16
- data: Schema.Struct({
17
- providerID: Schema.String,
18
- message: Schema.String,
19
- }),
20
- })
21
-
22
- const OutputLengthErrorEffect = Schema.Struct({
23
- name: Schema.Literal("MessageOutputLengthError"),
24
- data: Schema.Struct({}),
25
- })
26
-
27
- const UnknownErrorEffect = Schema.Struct({
28
- name: Schema.Literal("UnknownError"),
29
- data: Schema.Struct({
30
- message: Schema.String,
31
- }),
32
- })
33
-
34
- export const ToolCall = Schema.Struct({
35
- state: Schema.Literal("call"),
36
- step: Schema.optional(NonNegativeInt),
37
- toolCallId: Schema.String,
38
- toolName: Schema.String,
39
- args: Schema.Unknown,
40
- })
41
- .annotate({ identifier: "ToolCall" })
42
- .pipe(withStatics((s) => ({ zod: zod(s) })))
43
- export type ToolCall = Schema.Schema.Type<typeof ToolCall>
44
-
45
- export const ToolPartialCall = Schema.Struct({
46
- state: Schema.Literal("partial-call"),
47
- step: Schema.optional(NonNegativeInt),
48
- toolCallId: Schema.String,
49
- toolName: Schema.String,
50
- args: Schema.Unknown,
51
- })
52
- .annotate({ identifier: "ToolPartialCall" })
53
- .pipe(withStatics((s) => ({ zod: zod(s) })))
54
- export type ToolPartialCall = Schema.Schema.Type<typeof ToolPartialCall>
55
-
56
- export const ToolResult = Schema.Struct({
57
- state: Schema.Literal("result"),
58
- step: Schema.optional(NonNegativeInt),
59
- toolCallId: Schema.String,
60
- toolName: Schema.String,
61
- args: Schema.Unknown,
62
- result: Schema.String,
63
- })
64
- .annotate({ identifier: "ToolResult" })
65
- .pipe(withStatics((s) => ({ zod: zod(s) })))
66
- export type ToolResult = Schema.Schema.Type<typeof ToolResult>
67
-
68
- export const ToolInvocation = Schema.Union([ToolCall, ToolPartialCall, ToolResult])
69
- .annotate({ identifier: "ToolInvocation", discriminator: "state" })
70
- .pipe(withStatics((s) => ({ zod: zod(s) })))
71
- export type ToolInvocation = Schema.Schema.Type<typeof ToolInvocation>
72
-
73
- export const TextPart = Schema.Struct({
74
- type: Schema.Literal("text"),
75
- text: Schema.String,
76
- })
77
- .annotate({ identifier: "TextPart" })
78
- .pipe(withStatics((s) => ({ zod: zod(s) })))
79
- export type TextPart = Schema.Schema.Type<typeof TextPart>
80
-
81
- export const ReasoningPart = Schema.Struct({
82
- type: Schema.Literal("reasoning"),
83
- text: Schema.String,
84
- providerMetadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
85
- })
86
- .annotate({ identifier: "ReasoningPart" })
87
- .pipe(withStatics((s) => ({ zod: zod(s) })))
88
- export type ReasoningPart = Schema.Schema.Type<typeof ReasoningPart>
89
-
90
- export const ToolInvocationPart = Schema.Struct({
91
- type: Schema.Literal("tool-invocation"),
92
- toolInvocation: ToolInvocation,
93
- })
94
- .annotate({ identifier: "ToolInvocationPart" })
95
- .pipe(withStatics((s) => ({ zod: zod(s) })))
96
- export type ToolInvocationPart = Schema.Schema.Type<typeof ToolInvocationPart>
97
-
98
- export const SourceUrlPart = Schema.Struct({
99
- type: Schema.Literal("source-url"),
100
- sourceId: Schema.String,
101
- url: Schema.String,
102
- title: Schema.optional(Schema.String),
103
- providerMetadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
104
- })
105
- .annotate({ identifier: "SourceUrlPart" })
106
- .pipe(withStatics((s) => ({ zod: zod(s) })))
107
- export type SourceUrlPart = Schema.Schema.Type<typeof SourceUrlPart>
108
-
109
- export const FilePart = Schema.Struct({
110
- type: Schema.Literal("file"),
111
- mediaType: Schema.String,
112
- filename: Schema.optional(Schema.String),
113
- url: Schema.String,
114
- })
115
- .annotate({ identifier: "FilePart" })
116
- .pipe(withStatics((s) => ({ zod: zod(s) })))
117
- export type FilePart = Schema.Schema.Type<typeof FilePart>
118
-
119
- export const StepStartPart = Schema.Struct({
120
- type: Schema.Literal("step-start"),
121
- })
122
- .annotate({ identifier: "StepStartPart" })
123
- .pipe(withStatics((s) => ({ zod: zod(s) })))
124
- export type StepStartPart = Schema.Schema.Type<typeof StepStartPart>
125
-
126
- export const MessagePart = Schema.Union([
127
- TextPart,
128
- ReasoningPart,
129
- ToolInvocationPart,
130
- SourceUrlPart,
131
- FilePart,
132
- StepStartPart,
133
- ])
134
- .annotate({ identifier: "MessagePart", discriminator: "type" })
135
- .pipe(withStatics((s) => ({ zod: zod(s) })))
136
- export type MessagePart = Schema.Schema.Type<typeof MessagePart>
137
-
138
- export const Info = Schema.Struct({
139
- id: Schema.String,
140
- role: Schema.Literals(["user", "assistant"]),
141
- parts: Schema.Array(MessagePart),
142
- metadata: Schema.Struct({
143
- time: Schema.Struct({
144
- created: NonNegativeInt,
145
- completed: Schema.optional(NonNegativeInt),
146
- }),
147
- error: Schema.optional(Schema.Union([AuthErrorEffect, UnknownErrorEffect, OutputLengthErrorEffect])),
148
- sessionID: SessionID,
149
- tool: Schema.Record(
150
- Schema.String,
151
- Schema.StructWithRest(
152
- Schema.Struct({
153
- title: Schema.String,
154
- snapshot: Schema.optional(Schema.String),
155
- time: Schema.Struct({
156
- start: NonNegativeInt,
157
- end: NonNegativeInt,
158
- }),
159
- }),
160
- [Schema.Record(Schema.String, Schema.Unknown)],
161
- ),
162
- ),
163
- assistant: Schema.optional(
164
- Schema.Struct({
165
- system: Schema.Array(Schema.String),
166
- modelID: ModelID,
167
- providerID: ProviderID,
168
- path: Schema.Struct({
169
- cwd: Schema.String,
170
- root: Schema.String,
171
- }),
172
- cost: Schema.Finite,
173
- summary: Schema.optional(Schema.Boolean),
174
- tokens: Schema.Struct({
175
- input: NonNegativeInt,
176
- output: NonNegativeInt,
177
- reasoning: NonNegativeInt,
178
- cache: Schema.Struct({
179
- read: NonNegativeInt,
180
- write: NonNegativeInt,
181
- }),
182
- }),
183
- }),
184
- ),
185
- snapshot: Schema.optional(Schema.String),
186
- }).annotate({ identifier: "MessageMetadata" }),
187
- })
188
- .annotate({ identifier: "Message" })
189
- .pipe(withStatics((s) => ({ zod: zod(s) })))
190
- export type Info = Schema.Schema.Type<typeof Info>
191
-
192
- export * as Message from "./message"
1
+ export * from "./message/message"