@opencode-ai/schema 0.0.0-next-15090 → 0.0.0-next-15092
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/dist/agent.d.ts +13 -9
- package/dist/agent.js +5 -2
- package/dist/command.d.ts +5 -5
- package/dist/command.js +3 -2
- package/dist/durable-event-manifest.d.ts +146 -96
- package/dist/event-manifest.d.ts +390 -282
- package/dist/event.d.ts +2 -1
- package/dist/event.js +12 -4
- package/dist/file-diff.d.ts +11 -1
- package/dist/file-diff.js +13 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/model.d.ts +46 -30
- package/dist/model.js +10 -9
- package/dist/money.d.ts +10 -0
- package/dist/money.js +5 -0
- package/dist/session-event.d.ts +748 -486
- package/dist/session-event.js +30 -27
- package/dist/session-input.d.ts +6 -6
- package/dist/session-input.js +3 -3
- package/dist/session-message.d.ts +238 -619
- package/dist/session-message.js +57 -44
- package/dist/session-revert.d.ts +479 -0
- package/dist/session-revert.js +63 -0
- package/dist/session.d.ts +26 -22
- package/dist/session.js +9 -13
- package/dist/shell.d.ts +42 -42
- package/dist/shell.js +1 -1
- package/dist/skill.d.ts +16 -9
- package/dist/skill.js +14 -11
- package/dist/snapshot.d.ts +4 -0
- package/dist/snapshot.js +3 -0
- package/dist/token-usage.d.ts +13 -0
- package/dist/token-usage.js +11 -0
- package/dist/v1/session.d.ts +62 -62
- package/dist/v1/session.js +5 -5
- package/package.json +1 -1
- package/dist/revert.d.ts +0 -35
- package/dist/revert.js +0 -19
package/dist/session-message.js
CHANGED
|
@@ -3,14 +3,18 @@ import { Schema } from "effect";
|
|
|
3
3
|
import { optional } from "./schema.js";
|
|
4
4
|
import { ToolContent } from "./llm.js";
|
|
5
5
|
import { Model } from "./model.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Prompt } from "./prompt.js";
|
|
7
7
|
import { DateTimeUtcFromMillis, PositiveInt, RelativePath, statics } from "./schema.js";
|
|
8
|
-
import { SessionID } from "./session-id.js";
|
|
9
8
|
import { ascending } from "./identifier.js";
|
|
10
9
|
import { Event } from "./event.js";
|
|
11
10
|
import { Shell as ShellSchema } from "./shell.js";
|
|
12
11
|
import { FinishReason } from "./llm.js";
|
|
13
12
|
import { SessionError } from "./session-error.js";
|
|
13
|
+
import { Agent } from "./agent.js";
|
|
14
|
+
import { Skill as SkillSchema } from "./skill.js";
|
|
15
|
+
import { Money } from "./money.js";
|
|
16
|
+
import { Snapshot } from "./snapshot.js";
|
|
17
|
+
import { TokenUsage } from "./token-usage.js";
|
|
14
18
|
export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(Schema.brand("Session.Message.ID"), statics((schema) => ({
|
|
15
19
|
create: () => schema.make("msg_" + ascending()),
|
|
16
20
|
fromEvent: (eventID) => schema.make(eventID.replace(/^evt_/, "msg_")),
|
|
@@ -25,12 +29,12 @@ export const ProviderState = Schema.Record(Schema.String, Schema.Unknown).annota
|
|
|
25
29
|
});
|
|
26
30
|
export const AgentSelected = Schema.Struct({
|
|
27
31
|
...Base,
|
|
28
|
-
type: Schema.
|
|
29
|
-
agent:
|
|
32
|
+
type: Schema.tag("agent-switched"),
|
|
33
|
+
agent: Agent.ID,
|
|
30
34
|
}).annotate({ identifier: "Session.Message.AgentSelected" });
|
|
31
35
|
export const ModelSelected = Schema.Struct({
|
|
32
36
|
...Base,
|
|
33
|
-
type: Schema.
|
|
37
|
+
type: Schema.tag("model-switched"),
|
|
34
38
|
model: Model.Ref,
|
|
35
39
|
previous: Model.Ref.pipe(optional),
|
|
36
40
|
}).annotate({ identifier: "Session.Message.ModelSelected" });
|
|
@@ -39,66 +43,67 @@ export const User = Schema.Struct({
|
|
|
39
43
|
text: Prompt.fields.text,
|
|
40
44
|
files: Prompt.fields.files,
|
|
41
45
|
agents: Prompt.fields.agents,
|
|
42
|
-
type: Schema.
|
|
46
|
+
type: Schema.tag("user"),
|
|
43
47
|
}).annotate({ identifier: "Session.Message.User" });
|
|
44
48
|
export const Synthetic = Schema.Struct({
|
|
45
49
|
...Base,
|
|
46
|
-
sessionID: SessionID,
|
|
47
50
|
text: Schema.String,
|
|
48
51
|
description: Schema.String.pipe(optional),
|
|
49
|
-
type: Schema.
|
|
52
|
+
type: Schema.tag("synthetic"),
|
|
50
53
|
}).annotate({ identifier: "Session.Message.Synthetic" });
|
|
51
54
|
export const System = Schema.Struct({
|
|
52
55
|
...Base,
|
|
53
|
-
type: Schema.
|
|
56
|
+
type: Schema.tag("system"),
|
|
54
57
|
text: Schema.String,
|
|
55
58
|
}).annotate({ identifier: "Session.Message.System" });
|
|
56
59
|
export const Skill = Schema.Struct({
|
|
57
60
|
...Base,
|
|
58
|
-
type: Schema.
|
|
59
|
-
|
|
61
|
+
type: Schema.tag("skill"),
|
|
62
|
+
skill: SkillSchema.ID,
|
|
63
|
+
name: SkillSchema.Name,
|
|
60
64
|
text: Schema.String,
|
|
61
65
|
}).annotate({ identifier: "Session.Message.Skill" });
|
|
62
66
|
export const Shell = Schema.Struct({
|
|
63
67
|
...Base,
|
|
64
|
-
type: Schema.
|
|
65
|
-
|
|
68
|
+
type: Schema.tag("shell"),
|
|
69
|
+
shellID: ShellSchema.ID,
|
|
70
|
+
command: Schema.String,
|
|
71
|
+
status: ShellSchema.Status,
|
|
72
|
+
exit: Schema.Number.pipe(optional),
|
|
66
73
|
output: ShellSchema.Output.pipe(optional),
|
|
67
74
|
time: Schema.Struct({
|
|
68
75
|
created: DateTimeUtcFromMillis,
|
|
69
76
|
completed: DateTimeUtcFromMillis.pipe(optional),
|
|
70
77
|
}),
|
|
71
78
|
}).annotate({ identifier: "Session.Message.Shell" });
|
|
72
|
-
export const
|
|
73
|
-
status: Schema.
|
|
79
|
+
export const ToolStateStreaming = Schema.Struct({
|
|
80
|
+
status: Schema.tag("streaming"),
|
|
74
81
|
input: Schema.String,
|
|
75
|
-
}).annotate({ identifier: "Session.Message.ToolState.
|
|
82
|
+
}).annotate({ identifier: "Session.Message.ToolState.Streaming" });
|
|
76
83
|
export const ToolStateRunning = Schema.Struct({
|
|
77
|
-
status: Schema.
|
|
84
|
+
status: Schema.tag("running"),
|
|
78
85
|
input: Schema.Record(Schema.String, Schema.Unknown),
|
|
79
86
|
structured: Schema.Record(Schema.String, Schema.Unknown),
|
|
80
87
|
content: ToolContent.pipe(Schema.Array),
|
|
81
88
|
}).annotate({ identifier: "Session.Message.ToolState.Running" });
|
|
82
89
|
export const ToolStateCompleted = Schema.Struct({
|
|
83
|
-
status: Schema.
|
|
90
|
+
status: Schema.tag("completed"),
|
|
84
91
|
input: Schema.Record(Schema.String, Schema.Unknown),
|
|
85
|
-
attachments: FileAttachment.pipe(Schema.Array, optional),
|
|
86
92
|
content: ToolContent.pipe(Schema.Array),
|
|
87
|
-
outputPaths: Schema.Array(Schema.String).pipe(optional),
|
|
88
93
|
structured: Schema.Record(Schema.String, Schema.Unknown),
|
|
89
94
|
result: Schema.Unknown.pipe(optional),
|
|
90
95
|
}).annotate({ identifier: "Session.Message.ToolState.Completed" });
|
|
91
96
|
export const ToolStateError = Schema.Struct({
|
|
92
|
-
status: Schema.
|
|
97
|
+
status: Schema.tag("error"),
|
|
93
98
|
input: Schema.Record(Schema.String, Schema.Unknown),
|
|
94
99
|
content: ToolContent.pipe(Schema.Array),
|
|
95
100
|
structured: Schema.Record(Schema.String, Schema.Unknown),
|
|
96
101
|
error: SessionError.Error,
|
|
97
102
|
result: Schema.Unknown.pipe(optional),
|
|
98
103
|
}).annotate({ identifier: "Session.Message.ToolState.Error" });
|
|
99
|
-
export const ToolState = Schema.Union([
|
|
104
|
+
export const ToolState = Schema.Union([ToolStateStreaming, ToolStateRunning, ToolStateCompleted, ToolStateError]).pipe(Schema.toTaggedUnion("status"));
|
|
100
105
|
export const AssistantTool = Schema.Struct({
|
|
101
|
-
type: Schema.
|
|
106
|
+
type: Schema.tag("tool"),
|
|
102
107
|
id: Schema.String,
|
|
103
108
|
name: Schema.String,
|
|
104
109
|
executed: Schema.Boolean.pipe(optional),
|
|
@@ -109,15 +114,14 @@ export const AssistantTool = Schema.Struct({
|
|
|
109
114
|
created: DateTimeUtcFromMillis,
|
|
110
115
|
ran: DateTimeUtcFromMillis.pipe(optional),
|
|
111
116
|
completed: DateTimeUtcFromMillis.pipe(optional),
|
|
112
|
-
pruned: DateTimeUtcFromMillis.pipe(optional),
|
|
113
117
|
}),
|
|
114
118
|
}).annotate({ identifier: "Session.Message.Assistant.Tool" });
|
|
115
119
|
export const AssistantText = Schema.Struct({
|
|
116
|
-
type: Schema.
|
|
120
|
+
type: Schema.tag("text"),
|
|
117
121
|
text: Schema.String,
|
|
118
122
|
}).annotate({ identifier: "Session.Message.Assistant.Text" });
|
|
119
123
|
export const AssistantReasoning = Schema.Struct({
|
|
120
|
-
type: Schema.
|
|
124
|
+
type: Schema.tag("reasoning"),
|
|
121
125
|
text: Schema.String,
|
|
122
126
|
state: ProviderState.pipe(optional),
|
|
123
127
|
time: Schema.Struct({
|
|
@@ -133,23 +137,18 @@ export const AssistantRetry = Schema.Struct({
|
|
|
133
137
|
}).annotate({ identifier: "Session.Message.Assistant.Retry" });
|
|
134
138
|
export const Assistant = Schema.Struct({
|
|
135
139
|
...Base,
|
|
136
|
-
type: Schema.
|
|
137
|
-
agent:
|
|
140
|
+
type: Schema.tag("assistant"),
|
|
141
|
+
agent: Agent.ID,
|
|
138
142
|
model: Model.Ref,
|
|
139
143
|
content: AssistantContent.pipe(Schema.Array),
|
|
140
144
|
snapshot: Schema.Struct({
|
|
141
|
-
start:
|
|
142
|
-
end:
|
|
145
|
+
start: Snapshot.ID.pipe(optional),
|
|
146
|
+
end: Snapshot.ID.pipe(optional),
|
|
143
147
|
files: Schema.Array(RelativePath).pipe(optional),
|
|
144
148
|
}).pipe(optional),
|
|
145
149
|
finish: FinishReason.pipe(optional),
|
|
146
|
-
cost:
|
|
147
|
-
tokens:
|
|
148
|
-
input: Schema.Finite,
|
|
149
|
-
output: Schema.Finite,
|
|
150
|
-
reasoning: Schema.Finite,
|
|
151
|
-
cache: Schema.Struct({ read: Schema.Finite, write: Schema.Finite }),
|
|
152
|
-
}).pipe(optional),
|
|
150
|
+
cost: Money.USD.pipe(optional),
|
|
151
|
+
tokens: TokenUsage.Info.pipe(optional),
|
|
153
152
|
error: SessionError.Error.pipe(optional),
|
|
154
153
|
retry: AssistantRetry.pipe(optional),
|
|
155
154
|
time: Schema.Struct({
|
|
@@ -157,15 +156,29 @@ export const Assistant = Schema.Struct({
|
|
|
157
156
|
completed: DateTimeUtcFromMillis.pipe(optional),
|
|
158
157
|
}),
|
|
159
158
|
}).annotate({ identifier: "Session.Message.Assistant" });
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
const CompactionBase = { type: Schema.tag("compaction"), ...Base };
|
|
160
|
+
export const CompactionRunning = Schema.Struct({
|
|
161
|
+
...CompactionBase,
|
|
162
|
+
status: Schema.tag("running"),
|
|
163
163
|
reason: Schema.Literals(["auto", "manual"]),
|
|
164
164
|
summary: Schema.String,
|
|
165
165
|
recent: Schema.String,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
}).annotate({ identifier: "Session.Message.Compaction.Running" });
|
|
167
|
+
export const CompactionCompleted = Schema.Struct({
|
|
168
|
+
...CompactionBase,
|
|
169
|
+
status: Schema.tag("completed"),
|
|
170
|
+
reason: Schema.Literals(["auto", "manual"]),
|
|
171
|
+
summary: Schema.String,
|
|
172
|
+
recent: Schema.String,
|
|
173
|
+
}).annotate({ identifier: "Session.Message.Compaction.Completed" });
|
|
174
|
+
export const CompactionFailed = Schema.Struct({
|
|
175
|
+
...CompactionBase,
|
|
176
|
+
status: Schema.tag("failed"),
|
|
177
|
+
reason: Schema.Literals(["auto", "manual"]),
|
|
178
|
+
error: SessionError.Error,
|
|
179
|
+
}).annotate({ identifier: "Session.Message.Compaction.Failed" });
|
|
180
|
+
export const Compaction = Schema.Union([CompactionRunning, CompactionCompleted, CompactionFailed]).pipe(Schema.toTaggedUnion("status"), Schema.annotate({ identifier: "Session.Message.Compaction" }));
|
|
181
|
+
export const Info = Schema.Union([
|
|
169
182
|
AgentSelected,
|
|
170
183
|
ModelSelected,
|
|
171
184
|
User,
|
|
@@ -177,4 +190,4 @@ export const Message = Schema.Union([
|
|
|
177
190
|
Compaction,
|
|
178
191
|
])
|
|
179
192
|
.pipe(Schema.toTaggedUnion("type"))
|
|
180
|
-
.annotate({ identifier: "Session.Message" });
|
|
193
|
+
.annotate({ identifier: "Session.Message.Info" });
|