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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "name": "saeeol",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -50,8 +50,8 @@
50
50
  "@babel/core": "7.28.4",
51
51
  "@effect/language-service": "0.84.2",
52
52
  "@octokit/webhooks-types": "7.6.1",
53
- "@saeeol/script": "workspace:*",
54
- "@saeeol/core": "workspace:*",
53
+ "@saeeol/script": "7.3.1",
54
+ "@saeeol/core": "7.3.1",
55
55
  "@parcel/watcher-darwin-arm64": "2.5.1",
56
56
  "@parcel/watcher-darwin-x64": "2.5.1",
57
57
  "@parcel/watcher-linux-arm64-glibc": "2.5.1",
@@ -132,15 +132,15 @@
132
132
  "@opentui/solid": "0.2.2",
133
133
  "@parcel/watcher": "2.5.1",
134
134
  "@pierre/diffs": "1.1.0-beta.18",
135
- "@saeeol/boxes": "workspace:*",
136
- "@saeeol/core": "workspace:*",
137
- "@saeeol/gateway": "workspace:*",
138
- "@saeeol/i18n": "workspace:*",
139
- "@saeeol/indexing": "workspace:*",
140
- "@saeeol/plugin": "workspace:*",
141
- "@saeeol/script": "workspace:*",
142
- "@saeeol/sdk": "workspace:*",
143
- "@saeeol/telemetry": "workspace:*",
135
+ "@saeeol/boxes": "0.2.0",
136
+ "@saeeol/core": "7.3.1",
137
+ "@saeeol/gateway": "7.3.1",
138
+ "@saeeol/i18n": "7.3.1",
139
+ "@saeeol/indexing": "7.3.1",
140
+ "@saeeol/plugin": "7.3.1",
141
+ "@saeeol/script": "7.3.1",
142
+ "@saeeol/sdk": "7.3.1",
143
+ "@saeeol/telemetry": "7.3.1",
144
144
  "@solid-primitives/event-bus": "1.1.2",
145
145
  "@solid-primitives/scheduled": "1.5.2",
146
146
  "@standard-schema/spec": "1.0.0",
@@ -179,8 +179,8 @@
179
179
  "remeda": "2.26.0",
180
180
  "ripgrep": "0.3.1",
181
181
  "rotating-file-stream": "3.2.9",
182
- "saeeol-gitlab-auth": "workspace:*",
183
- "saeeol-poe-auth": "workspace:*",
182
+ "saeeol-gitlab-auth": "2.0.2",
183
+ "saeeol-poe-auth": "0.0.4",
184
184
  "semver": "^7.6.3",
185
185
  "simple-git": "3.36.0",
186
186
  "solid-js": "1.9.12",
@@ -1,169 +1 @@
1
- import { clamp } from "@saeeol/boxes/clamp"
2
- import { BusEvent } from "@/bus/bus-event"
3
- import { SessionID, MessageID } from "./schema"
4
- import { Provider } from "@/provider/provider"
5
- import { MessageV2 } from "./message-v2"
6
- import { Schema, Effect } from "effect"
7
- import { Config } from "@/config/config"
8
- import { usable } from "./overflow"
9
-
10
- export const PRUNE_MINIMUM = 20_000
11
- export const PRUNE_PROTECT = 40_000
12
- export const TOOL_OUTPUT_MAX_CHARS = 2_000
13
- export const PRUNE_PROTECTED_TOOLS = ["skill"]
14
- export const DEFAULT_TAIL_TURNS = 2
15
- export const MIN_PRESERVE_RECENT_TOKENS = 2_000
16
- export const MAX_PRESERVE_RECENT_TOKENS = 8_000
17
- export const SUMMARY_TEMPLATE = `Output exactly the Markdown structure shown inside <template> and keep the section order unchanged. Do not include the <template> tags in your response.
18
- <template>
19
- ## Goal
20
- - [single-sentence task summary]
21
-
22
- ## Constraints & Preferences
23
- - [user constraints, preferences, specs, or "(none)"]
24
-
25
- ## Progress
26
- ### Done
27
- - [completed work or "(none)"]
28
-
29
- ### In Progress
30
- - [current work or "(none)"]
31
-
32
- ### Blocked
33
- - [blockers or "(none)"]
34
-
35
- ## Key Decisions
36
- - [decision and why, or "(none)"]
37
-
38
- ## Next Steps
39
- - [ordered next actions or "(none)"]
40
-
41
- ## Critical Context
42
- - [important technical facts, errors, open questions, or "(none)"]
43
-
44
- ## Relevant Files
45
- - [file or directory path: why it matters, or "(none)"]
46
- </template>
47
-
48
- Rules:
49
- - Keep every section, even when empty.
50
- - Use terse bullets, not prose paragraphs.
51
- - Preserve exact file paths, commands, error strings, and identifiers when known.
52
- - Do not mention the summary process or that context was compacted.`
53
- export type Turn = {
54
- start: number
55
- end: number
56
- id: MessageID
57
- }
58
-
59
- export type Tail = {
60
- start: number
61
- id: MessageID
62
- }
63
-
64
- export type CompletedCompaction = {
65
- userIndex: number
66
- assistantIndex: number
67
- summary: string | undefined
68
- }
69
- export type PruneReason = "normal" | "post-compaction" | "payload-limit"
70
-
71
- export const Event = {
72
- Compacted: BusEvent.define(
73
- "session.compacted",
74
- Schema.Struct({
75
- sessionID: SessionID,
76
- }),
77
- ),
78
- }
79
-
80
- export function summaryText(message: MessageV2.WithParts) {
81
- const text = message.parts
82
- .filter((part): part is MessageV2.TextPart => part.type === "text")
83
- .map((part) => part.text.trim())
84
- .filter(Boolean)
85
- .join("\n\n")
86
- .trim()
87
- return text || undefined
88
- }
89
-
90
- export function completedCompactions(messages: MessageV2.WithParts[]) {
91
- const users = new Map<MessageID, number>()
92
- for (let i = 0; i < messages.length; i++) {
93
- const msg = messages[i]
94
- if (msg.info.role !== "user") continue
95
- if (!msg.parts.some((part) => part.type === "compaction")) continue
96
- users.set(msg.info.id, i)
97
- }
98
-
99
- return messages.flatMap((msg, assistantIndex): CompletedCompaction[] => {
100
- if (msg.info.role !== "assistant") return []
101
- if (!msg.info.summary || !msg.info.finish || msg.info.error) return []
102
- const userIndex = users.get(msg.info.parentID)
103
- if (userIndex === undefined) return []
104
- return [{ userIndex, assistantIndex, summary: summaryText(msg) }]
105
- })
106
- }
107
-
108
- export function buildPrompt(input: { previousSummary?: string; context: string[] }) {
109
- const anchor = input.previousSummary
110
- ? [
111
- "Update the anchored summary below using the conversation history above.",
112
- "Preserve still-true details, remove stale details, and merge in the new facts.",
113
- "<previous-summary>",
114
- input.previousSummary,
115
- "</previous-summary>",
116
- ].join("\n")
117
- : "Create a new anchored summary from the conversation history above."
118
- return [anchor, SUMMARY_TEMPLATE, ...input.context].join("\n\n")
119
- }
120
-
121
- export function preserveRecentBudget(input: { cfg: Config.Info; model: Provider.Model }) {
122
- return (
123
- input.cfg.compaction?.preserve_recent_tokens ??
124
- clamp(Math.floor(usable(input) * 0.25), MIN_PRESERVE_RECENT_TOKENS, MAX_PRESERVE_RECENT_TOKENS)
125
- )
126
- }
127
-
128
- export function turns(messages: MessageV2.WithParts[]) {
129
- const result: Turn[] = []
130
- for (let i = 0; i < messages.length; i++) {
131
- const msg = messages[i]
132
- if (msg.info.role !== "user") continue
133
- if (msg.parts.some((part) => part.type === "compaction")) continue
134
- result.push({
135
- start: i,
136
- end: messages.length,
137
- id: msg.info.id,
138
- })
139
- }
140
- for (let i = 0; i < result.length - 1; i++) {
141
- result[i].end = result[i + 1].start
142
- }
143
- return result
144
- }
145
-
146
- export function splitTurn(input: {
147
- messages: MessageV2.WithParts[]
148
- turn: Turn
149
- model: Provider.Model
150
- budget: number
151
- estimate: (input: { messages: MessageV2.WithParts[]; model: Provider.Model }) => Effect.Effect<number>
152
- }) {
153
- return Effect.gen(function* () {
154
- if (input.budget <= 0) return undefined
155
- if (input.turn.end - input.turn.start <= 1) return undefined
156
- for (let start = input.turn.start + 1; start < input.turn.end; start++) {
157
- const size = yield* input.estimate({
158
- messages: input.messages.slice(start, input.turn.end),
159
- model: input.model,
160
- })
161
- if (size > input.budget) continue
162
- return {
163
- start,
164
- id: input.messages[start]!.info.id,
165
- } satisfies Tail
166
- }
167
- return undefined
168
- })
169
- }
1
+ export * from "./core/compaction/compaction-helpers"