@zyro-sec/schema 1.0.1 → 1.0.3
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/AGENTS.md +95 -95
- package/package.json +5 -1
- package/script/build.ts +9 -9
- package/script/config-schema.ts +86 -86
- package/script/config-v1.json +1311 -1311
- package/script/pack.ts +5 -5
- package/src/agent.ts +68 -68
- package/src/artifact.ts +81 -81
- package/src/automation.ts +224 -224
- package/src/blob-store.ts +25 -25
- package/src/command.ts +18 -18
- package/src/config/agent.ts +26 -26
- package/src/config/command.ts +14 -14
- package/src/config/compaction.ts +27 -27
- package/src/config/experimental.ts +72 -72
- package/src/config/flag.ts +39 -39
- package/src/config/formatter.ts +13 -13
- package/src/config/lsp.ts +19 -19
- package/src/config/mcp.ts +22 -22
- package/src/config/media.ts +15 -15
- package/src/config/model.ts +37 -37
- package/src/config/plugin.ts +14 -14
- package/src/config/policy.ts +57 -57
- package/src/config/provider.ts +122 -122
- package/src/config/reference.ts +23 -23
- package/src/config/shell.ts +10 -10
- package/src/config/tool-output.ts +9 -9
- package/src/config/warming.ts +21 -21
- package/src/config/watcher.ts +8 -8
- package/src/config/websearch.ts +17 -17
- package/src/config/worktree.ts +10 -10
- package/src/config.ts +149 -149
- package/src/connection.ts +38 -38
- package/src/credential-legacy.ts +29 -29
- package/src/credential.ts +78 -78
- package/src/durable-event-manifest.ts +7 -7
- package/src/event-log.ts +21 -21
- package/src/event-manifest.ts +108 -108
- package/src/event.ts +205 -205
- package/src/file-diff.ts +25 -25
- package/src/filesystem-v1.ts +1 -1
- package/src/filesystem.ts +48 -48
- package/src/form.ts +177 -177
- package/src/generate.ts +292 -292
- package/src/goal.ts +46 -46
- package/src/identifier.ts +32 -32
- package/src/index.ts +51 -51
- package/src/installation-event.ts +20 -20
- package/src/instruction-entry.ts +40 -40
- package/src/instruction.ts +25 -25
- package/src/integration-id.ts +13 -13
- package/src/integration.ts +129 -129
- package/src/job.ts +79 -79
- package/src/legacy-event.ts +1 -1
- package/src/llm.ts +6 -6
- package/src/location-event.ts +8 -8
- package/src/location.ts +36 -36
- package/src/lsp-event.ts +7 -7
- package/src/mcp-event.ts +63 -63
- package/src/mcp.ts +171 -171
- package/src/model-compatibility.ts +55 -55
- package/src/model.ts +176 -176
- package/src/models-dev.ts +9 -9
- package/src/money.ts +18 -18
- package/src/permission-saved.ts +25 -25
- package/src/permission-v1.ts +1 -1
- package/src/permission.ts +67 -67
- package/src/persistent-pty.ts +73 -73
- package/src/plugin.ts +62 -62
- package/src/project-id.ts +9 -9
- package/src/project.ts +62 -62
- package/src/prompt-input.ts +33 -33
- package/src/prompt.ts +117 -117
- package/src/provider.ts +136 -136
- package/src/pty-ticket.ts +10 -10
- package/src/pty.ts +61 -61
- package/src/push.ts +86 -86
- package/src/question.ts +22 -22
- package/src/reference.ts +40 -40
- package/src/rpc.ts +167 -167
- package/src/schema.ts +41 -41
- package/src/server-event.ts +8 -8
- package/src/session-error.ts +14 -14
- package/src/session-event.ts +739 -739
- package/src/session-fork.ts +10 -10
- package/src/session-id.ts +12 -12
- package/src/session-inbox.ts +102 -102
- package/src/session-legacy.ts +117 -117
- package/src/session-message.ts +352 -352
- package/src/session-metadata.ts +11 -11
- package/src/session-revert.ts +86 -86
- package/src/session-stats.ts +68 -68
- package/src/session-status-event.ts +53 -53
- package/src/session-transfer.ts +11 -11
- package/src/session-v1.ts +1 -1
- package/src/session.ts +147 -147
- package/src/shell.ts +90 -90
- package/src/skill.ts +68 -68
- package/src/snapshot.ts +6 -6
- package/src/token-usage.ts +18 -18
- package/src/tool.ts +143 -143
- package/src/tui-event.ts +59 -59
- package/src/usage-limits.ts +76 -76
- package/src/v1/filesystem.ts +11 -11
- package/src/v1/legacy-event.ts +18 -18
- package/src/v1/permission.ts +66 -66
- package/src/v1/session.ts +667 -667
- package/src/vcs-event.ts +14 -14
- package/src/vcs.ts +41 -41
- package/src/websearch.ts +44 -44
- package/src/workspace-event.ts +32 -32
- package/src/workspace-id.ts +19 -19
- package/src/workspace.ts +20 -20
- package/src/worktree-event.ts +22 -22
- package/src/worktree.ts +109 -109
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +14 -14
- package/test/agent.test.ts +0 -10
- package/test/automation.test.ts +0 -48
- package/test/compatibility.test.ts +0 -10
- package/test/config.test.ts +0 -194
- package/test/contract-hygiene.test.ts +0 -352
- package/test/credential-legacy.test.ts +0 -55
- package/test/event-manifest.test.ts +0 -228
- package/test/event.test.ts +0 -52
- package/test/legacy-event.test.ts +0 -46
- package/test/mcp.test.ts +0 -37
- package/test/model.test.ts +0 -104
- package/test/session-cursor.test.ts +0 -16
- package/test/session-error.test.ts +0 -51
- package/test/session-legacy.test.ts +0 -178
- package/test/session-terminal.test.ts +0 -50
- package/test/token-usage.test.ts +0 -18
- package/test/v1-isolation.test.ts +0 -26
- package/test/vcs.test.ts +0 -23
- package/test/worktree.test.ts +0 -45
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Schema } from "effect"
|
|
3
|
-
import { Credential } from "../src/credential.js"
|
|
4
|
-
import { CredentialLegacy } from "../src/credential-legacy.js"
|
|
5
|
-
|
|
6
|
-
const decode = Schema.decodeUnknownSync(CredentialLegacy.Value)
|
|
7
|
-
const legacy = {
|
|
8
|
-
type: "key",
|
|
9
|
-
key: "secret",
|
|
10
|
-
metadata: { imported: true, resourceName: "older" },
|
|
11
|
-
configuration: { resourceName: "answered", accountId: "account" },
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe("CredentialLegacy", () => {
|
|
15
|
-
test("decodes key form answers written to configuration before v2.1 into metadata, keeping answers first", () => {
|
|
16
|
-
expect(decode(legacy)).toEqual({
|
|
17
|
-
type: "key",
|
|
18
|
-
key: "secret",
|
|
19
|
-
metadata: { imported: true, resourceName: "answered", accountId: "account" },
|
|
20
|
-
})
|
|
21
|
-
expect(decode({ type: "key", key: "secret", configuration: { resourceName: "answered" } })).toEqual({
|
|
22
|
-
type: "key",
|
|
23
|
-
key: "secret",
|
|
24
|
-
metadata: { resourceName: "answered" },
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test("decodes current values and exported entries unchanged", () => {
|
|
29
|
-
const current = { type: "key", key: "secret", metadata: { resourceName: "answered" } } as const
|
|
30
|
-
expect(decode(current)).toEqual(current)
|
|
31
|
-
const external = { type: "external", methodID: "azure-cli", metadata: { resourceName: "answered" } } as const
|
|
32
|
-
expect(Schema.encodeSync(Credential.Value)(decode(external))).toEqual(external)
|
|
33
|
-
expect(
|
|
34
|
-
Schema.decodeUnknownSync(CredentialLegacy.Entry)({
|
|
35
|
-
id: "cred_legacy",
|
|
36
|
-
integrationID: "azure",
|
|
37
|
-
label: "Work",
|
|
38
|
-
active: true,
|
|
39
|
-
value: legacy,
|
|
40
|
-
}).value,
|
|
41
|
-
).toEqual(decode(legacy))
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test("rejects invalid legacy configuration", () => {
|
|
45
|
-
expect(() => decode({ type: "key", key: "secret", configuration: "answered" })).toThrow()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test("the public credential schema does not know configuration", () => {
|
|
49
|
-
expect(Schema.decodeUnknownSync(Credential.Value)(legacy)).toEqual({
|
|
50
|
-
type: "key",
|
|
51
|
-
key: "secret",
|
|
52
|
-
metadata: { imported: true, resourceName: "older" },
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
Agent,
|
|
4
|
-
Config,
|
|
5
|
-
Credential,
|
|
6
|
-
FileSystem,
|
|
7
|
-
Form,
|
|
8
|
-
Integration,
|
|
9
|
-
Permission,
|
|
10
|
-
PersistentPty,
|
|
11
|
-
Project,
|
|
12
|
-
Reference,
|
|
13
|
-
Session,
|
|
14
|
-
Workspace,
|
|
15
|
-
} from "../src/index.js"
|
|
16
|
-
import { EventManifest } from "../src/event-manifest.js"
|
|
17
|
-
import { FileSystemV1 } from "../src/filesystem-v1.js"
|
|
18
|
-
import { McpEvent } from "../src/mcp-event.js"
|
|
19
|
-
import { SessionEvent } from "../src/session-event.js"
|
|
20
|
-
import { SessionID } from "../src/session-id.js"
|
|
21
|
-
import { SessionMessage } from "../src/session-message.js"
|
|
22
|
-
import { WorkspaceEvent } from "../src/workspace-event.js"
|
|
23
|
-
|
|
24
|
-
describe("public event manifest", () => {
|
|
25
|
-
test("owns the complete public event surface", () => {
|
|
26
|
-
expect(EventManifest.ServerDefinitions).toContain(Agent.Event.Updated)
|
|
27
|
-
expect(EventManifest.ServerDefinitions.filter((definition) => definition.type === "agent.updated")).toEqual([
|
|
28
|
-
Agent.Event.Updated,
|
|
29
|
-
])
|
|
30
|
-
expect(EventManifest.Definitions).toContain(Agent.Event.Updated)
|
|
31
|
-
expect(EventManifest.Definitions.filter((definition) => definition.type === "agent.updated")).toEqual([
|
|
32
|
-
Agent.Event.Updated,
|
|
33
|
-
])
|
|
34
|
-
expect(Array.from(EventManifest.Latest.keys())).toEqual(
|
|
35
|
-
Array.from(new Set(EventManifest.Definitions.map((definition) => definition.type))),
|
|
36
|
-
)
|
|
37
|
-
expect(EventManifest.Latest.get("agent.updated")).toBe(Agent.Event.Updated)
|
|
38
|
-
expect(EventManifest.Server.get("mcp.status.changed")).toBe(McpEvent.StatusChanged)
|
|
39
|
-
expect(EventManifest.Server.get("mcp.resources.changed")).toBe(McpEvent.ResourcesChanged)
|
|
40
|
-
expect(EventManifest.Server.get("experimental.mcp.event")).toBe(McpEvent.ExperimentalEvent)
|
|
41
|
-
expect(EventManifest.Server.has("experimental.mcp.subscription.changed")).toBe(false)
|
|
42
|
-
expect(EventManifest.Server.get("session.created")).toBe(SessionEvent.Created)
|
|
43
|
-
expect(EventManifest.Server.get("session.deleted")).toBe(SessionEvent.Deleted)
|
|
44
|
-
expect(EventManifest.Server.get("project.updated")).toBe(Project.Event.Updated)
|
|
45
|
-
expect(EventManifest.Server.has("mcp.tools.changed")).toBe(false)
|
|
46
|
-
expect(Agent.Event.Updated.durable).toBeUndefined()
|
|
47
|
-
expect(EventManifest.Durable.has("agent.updated")).toBe(false)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test("uses canonical definitions for current public events", () => {
|
|
51
|
-
expect(Session.Event).toBe(SessionEvent)
|
|
52
|
-
expect(Session.Event.Definitions).toBe(SessionEvent.Definitions)
|
|
53
|
-
expect(Workspace.Event).toBe(WorkspaceEvent)
|
|
54
|
-
expect(Workspace.Event.Definitions).toBe(WorkspaceEvent.Definitions)
|
|
55
|
-
expect(EventManifest.Latest.get("session.step.ended")).toBe(SessionEvent.Step.Ended)
|
|
56
|
-
expect(EventManifest.Latest.get("agent.updated")).toBe(Agent.Event.Updated)
|
|
57
|
-
expect(EventManifest.Latest.get("project.updated")).toBe(Project.Event.Updated)
|
|
58
|
-
expect(Agent.Event.Definitions).toEqual([Agent.Event.Updated])
|
|
59
|
-
expect(Credential.Event.Definitions).toEqual([Credential.Event.Updated, Credential.Event.Switched])
|
|
60
|
-
expect(Project.Event.Definitions).toEqual([Project.Event.Updated])
|
|
61
|
-
expect(Config.Event.Definitions).toEqual([Config.Event.Updated])
|
|
62
|
-
expect(FileSystem.Event.Definitions).toEqual([FileSystem.Event.Changed])
|
|
63
|
-
expect(FileSystemV1.Event.Definitions).toEqual([FileSystemV1.Event.Edited])
|
|
64
|
-
expect(Integration.Event.Definitions).toEqual([Integration.Event.Updated])
|
|
65
|
-
expect(Permission.Event.Definitions).toEqual([Permission.Event.Asked, Permission.Event.Replied])
|
|
66
|
-
expect(PersistentPty.Event.Definitions).toEqual([
|
|
67
|
-
PersistentPty.Event.Added,
|
|
68
|
-
PersistentPty.Event.Removed,
|
|
69
|
-
PersistentPty.Event.Updated,
|
|
70
|
-
])
|
|
71
|
-
expect(Form.Event.Definitions).toEqual([Form.Event.Created, Form.Event.Replied, Form.Event.Cancelled])
|
|
72
|
-
expect(Reference.Event.Definitions).toEqual([Reference.Event.Updated])
|
|
73
|
-
expect(McpEvent.Definitions).toEqual([
|
|
74
|
-
McpEvent.ToolsChanged,
|
|
75
|
-
McpEvent.ResourcesChanged,
|
|
76
|
-
McpEvent.StatusChanged,
|
|
77
|
-
McpEvent.ExperimentalEvent,
|
|
78
|
-
McpEvent.ExperimentalSubscriptionChanged,
|
|
79
|
-
])
|
|
80
|
-
expect(EventManifest.Latest.has("mcp.browser.open.failed")).toBe(false)
|
|
81
|
-
expect(EventManifest.Durable.get("session.step.ended.1")).toBe(SessionEvent.Step.Ended)
|
|
82
|
-
expect(EventManifest.Durable.has("session.step.ended.2")).toBe(false)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test("keeps credential events public, canonical, and ephemeral", () => {
|
|
86
|
-
const credentialID = Credential.ID.make("cred_test")
|
|
87
|
-
const integrationID = Integration.ID.make("integration_test")
|
|
88
|
-
|
|
89
|
-
for (const definition of Credential.Event.Definitions) {
|
|
90
|
-
expect(EventManifest.ServerDefinitions).toContain(definition)
|
|
91
|
-
expect(EventManifest.Definitions).toContain(definition)
|
|
92
|
-
expect(EventManifest.Server.get(definition.type)).toBe(definition)
|
|
93
|
-
expect(EventManifest.Latest.get(definition.type)).toBe(definition)
|
|
94
|
-
expect(definition.durability).toBe("ephemeral")
|
|
95
|
-
expect(EventManifest.Durable.has(definition.type)).toBe(false)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
expect(Credential.Event.Updated.data.make({ integrationID, credentialID })).toEqual({ integrationID, credentialID })
|
|
99
|
-
expect(Credential.Event.Switched.data.make({ integrationID, credentialID })).toEqual({
|
|
100
|
-
integrationID,
|
|
101
|
-
credentialID,
|
|
102
|
-
})
|
|
103
|
-
expect(Credential.Event.Switched.data.make({ integrationID, credentialID: null })).toEqual({
|
|
104
|
-
integrationID,
|
|
105
|
-
credentialID: null,
|
|
106
|
-
})
|
|
107
|
-
expect(EventManifest.Server.has("credential.created")).toBe(false)
|
|
108
|
-
expect(EventManifest.Server.has("credential.activated")).toBe(false)
|
|
109
|
-
expect(EventManifest.Server.has("credential.deleted")).toBe(false)
|
|
110
|
-
expect(EventManifest.Server.has("integration.connection.updated")).toBe(false)
|
|
111
|
-
expect(EventManifest.Latest.has("integration.connection.updated")).toBe(false)
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test("derives durable definitions from explicit definition durability", () => {
|
|
115
|
-
expect(Array.from(EventManifest.Durable.keys()).toSorted()).toEqual(
|
|
116
|
-
[
|
|
117
|
-
"session.created.1",
|
|
118
|
-
"session.deleted.2",
|
|
119
|
-
"session.agent.selected.1",
|
|
120
|
-
"session.model.selected.1",
|
|
121
|
-
"session.moved.1",
|
|
122
|
-
"session.renamed.1",
|
|
123
|
-
"session.metadata.updated.1",
|
|
124
|
-
"session.permissions.1",
|
|
125
|
-
"session.viewed.1",
|
|
126
|
-
"session.archived.1",
|
|
127
|
-
"session.unarchived.1",
|
|
128
|
-
"session.message.content.updated.1",
|
|
129
|
-
"session.usage.recorded.1",
|
|
130
|
-
"session.forked.2",
|
|
131
|
-
"session.inbox.delivered.1",
|
|
132
|
-
"session.inbox.enqueued.1",
|
|
133
|
-
"session.inbox.cancelled.1",
|
|
134
|
-
"session.inbox.delivery.changed.1",
|
|
135
|
-
"session.execution.started.1",
|
|
136
|
-
"session.execution.succeeded.1",
|
|
137
|
-
"session.execution.failed.1",
|
|
138
|
-
"session.execution.interrupted.1",
|
|
139
|
-
"session.instructions.updated.2",
|
|
140
|
-
"session.synthetic.1",
|
|
141
|
-
"session.skill.activated.1",
|
|
142
|
-
"session.shell.started.1",
|
|
143
|
-
"session.shell.ended.1",
|
|
144
|
-
"session.step.started.1",
|
|
145
|
-
"session.step.first-token.1",
|
|
146
|
-
"session.step.streamed.1",
|
|
147
|
-
"session.step.ended.1",
|
|
148
|
-
"session.step.failed.1",
|
|
149
|
-
"session.text.started.1",
|
|
150
|
-
"session.text.ended.1",
|
|
151
|
-
"session.tool.input.started.1",
|
|
152
|
-
"session.tool.input.ended.1",
|
|
153
|
-
"session.tool.called.1",
|
|
154
|
-
"session.tool.success.2",
|
|
155
|
-
"session.tool.failed.2",
|
|
156
|
-
"session.reasoning.started.1",
|
|
157
|
-
"session.reasoning.ended.1",
|
|
158
|
-
"session.retry.scheduled.1",
|
|
159
|
-
"session.compaction.started.1",
|
|
160
|
-
"session.compaction.ended.1",
|
|
161
|
-
"session.compaction.failed.1",
|
|
162
|
-
"session.revert.staged.1",
|
|
163
|
-
"session.revert.cleared.1",
|
|
164
|
-
"session.revert.committed.1",
|
|
165
|
-
"worktree.resolved.1",
|
|
166
|
-
].toSorted(),
|
|
167
|
-
)
|
|
168
|
-
expect(SessionEvent.DurableDefinitions).toEqual([
|
|
169
|
-
...SessionEvent.Definitions.filter((definition) => definition.durability === "durable"),
|
|
170
|
-
SessionEvent.UsageRecorded,
|
|
171
|
-
SessionEvent.MessageContentUpdated,
|
|
172
|
-
])
|
|
173
|
-
expect(SessionEvent.UsageRecorded.durability).toBe("durable")
|
|
174
|
-
expect(EventManifest.Durable.get("session.usage.recorded.1")).toBe(SessionEvent.UsageRecorded)
|
|
175
|
-
expect(SessionEvent.Definitions).not.toContain(SessionEvent.UsageRecorded)
|
|
176
|
-
expect(EventManifest.Definitions).not.toContain(SessionEvent.UsageRecorded)
|
|
177
|
-
expect(EventManifest.ServerDefinitions).not.toContain(SessionEvent.UsageRecorded)
|
|
178
|
-
expect(EventManifest.Latest.has("session.usage.recorded")).toBe(false)
|
|
179
|
-
expect(SessionEvent.UsageUpdated.durability).toBe("ephemeral")
|
|
180
|
-
expect(SessionEvent.Compaction.Delta.durability).toBe("ephemeral")
|
|
181
|
-
expect(SessionEvent.Tool.Progress.durability).toBe("ephemeral")
|
|
182
|
-
expect(EventManifest.Server.get("session.tool.progress")).toBe(SessionEvent.Tool.Progress)
|
|
183
|
-
expect(EventManifest.Durable.has("session.compaction.delta.1")).toBe(false)
|
|
184
|
-
expect(EventManifest.ServerDefinitions).toContain(SessionEvent.UsageUpdated)
|
|
185
|
-
expect(EventManifest.Definitions.every((definition) => definition.durability !== undefined)).toBe(true)
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
test("uses the current Session skill event as durable version 1", () => {
|
|
189
|
-
expect(EventManifest.Durable.get("session.skill.activated.1")).toBe(SessionEvent.Skill.Activated)
|
|
190
|
-
expect(EventManifest.Latest.get("session.skill.activated")).toBe(SessionEvent.Skill.Activated)
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
test("keeps simplified session fragment and tool payloads on durable version 1", () => {
|
|
194
|
-
const sessionID = SessionID.make("ses_test")
|
|
195
|
-
const assistantMessageID = SessionMessage.ID.make("msg_test")
|
|
196
|
-
const text = SessionEvent.Text.Started.data.make({ sessionID, assistantMessageID, ordinal: 0 })
|
|
197
|
-
const reasoning = SessionEvent.Reasoning.Ended.data.make({
|
|
198
|
-
sessionID,
|
|
199
|
-
assistantMessageID,
|
|
200
|
-
ordinal: 0,
|
|
201
|
-
text: "thought",
|
|
202
|
-
native: { signature: "sig" },
|
|
203
|
-
})
|
|
204
|
-
const tool = SessionEvent.Tool.Called.data.make({
|
|
205
|
-
sessionID,
|
|
206
|
-
assistantMessageID,
|
|
207
|
-
id: "call_test",
|
|
208
|
-
input: {},
|
|
209
|
-
executed: true,
|
|
210
|
-
native: { itemId: "item_test" },
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
expect(text).not.toHaveProperty("textID")
|
|
214
|
-
expect(reasoning).not.toHaveProperty("reasoningID")
|
|
215
|
-
expect(reasoning).not.toHaveProperty("providerMetadata")
|
|
216
|
-
expect(tool).not.toHaveProperty("tool")
|
|
217
|
-
expect(tool).not.toHaveProperty("provider")
|
|
218
|
-
expect(SessionEvent.Text.Started.durable?.version).toBe(1)
|
|
219
|
-
expect(SessionEvent.Tool.Called.durable?.version).toBe(1)
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
test("keeps current session deletion minimal", () => {
|
|
223
|
-
const sessionID = SessionID.make("ses_test")
|
|
224
|
-
|
|
225
|
-
expect(SessionEvent.Deleted.data.make({ sessionID })).toEqual({ sessionID })
|
|
226
|
-
expect(SessionEvent.Deleted.durable?.version).toBe(2)
|
|
227
|
-
})
|
|
228
|
-
})
|
package/test/event.test.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Schema } from "effect"
|
|
3
|
-
import { Event } from "../src/event.js"
|
|
4
|
-
import { EventLog } from "../src/event-log.js"
|
|
5
|
-
|
|
6
|
-
describe("public event schemas", () => {
|
|
7
|
-
test("definition is pure", () => {
|
|
8
|
-
const definitions = Event.inventory()
|
|
9
|
-
Event.ephemeral({ type: "test.pure", schema: { value: Schema.String } })
|
|
10
|
-
expect(definitions).toEqual([])
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test("latest selection is independent of declaration order", () => {
|
|
14
|
-
const historical = Event.durable({
|
|
15
|
-
type: "test.versioned",
|
|
16
|
-
durable: { aggregate: "id", version: 1 },
|
|
17
|
-
schema: { id: Schema.String },
|
|
18
|
-
})
|
|
19
|
-
const current = Event.durable({
|
|
20
|
-
type: "test.versioned",
|
|
21
|
-
durable: { aggregate: "id", version: 2 },
|
|
22
|
-
schema: { id: Schema.String, value: Schema.String },
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
expect(Event.latest([historical, current]).get(current.type)).toBe(current)
|
|
26
|
-
expect(Event.latest([current, historical]).get(current.type)).toBe(current)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test("durable definitions are indexed by type and version", () => {
|
|
30
|
-
const definition = Event.durable({
|
|
31
|
-
type: "test.durable",
|
|
32
|
-
durable: { aggregate: "id", version: 1 },
|
|
33
|
-
schema: { id: Schema.String },
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
expect(Event.durableMap([definition]).get("test.durable.1")).toBe(definition)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test("synced marker encodes the captured watermark", () => {
|
|
40
|
-
expect(
|
|
41
|
-
Schema.encodeSync(EventLog.Synced)({
|
|
42
|
-
type: "log.synced",
|
|
43
|
-
aggregateID: "ses_test",
|
|
44
|
-
seq: Event.Seq.make(1),
|
|
45
|
-
}),
|
|
46
|
-
).toEqual({ type: "log.synced", aggregateID: "ses_test", seq: 1 })
|
|
47
|
-
expect(Schema.encodeSync(EventLog.Synced)({ type: "log.synced", aggregateID: "ses_test" })).toEqual({
|
|
48
|
-
type: "log.synced",
|
|
49
|
-
aggregateID: "ses_test",
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { LegacyEventV1 } from "../src/legacy-event.js"
|
|
3
|
-
import { PermissionV1 } from "../src/permission-v1.js"
|
|
4
|
-
import { Project } from "../src/project.js"
|
|
5
|
-
import { SessionV1 } from "../src/session-v1.js"
|
|
6
|
-
|
|
7
|
-
describe("legacy public event schemas", () => {
|
|
8
|
-
test("owns all SessionV1 definitions", () => {
|
|
9
|
-
expect(SessionV1.Event.Definitions.map((event) => event.type)).toEqual([
|
|
10
|
-
"session.created",
|
|
11
|
-
"session.updated",
|
|
12
|
-
"session.deleted",
|
|
13
|
-
"message.updated",
|
|
14
|
-
"message.removed",
|
|
15
|
-
"message.part.updated",
|
|
16
|
-
"message.part.removed",
|
|
17
|
-
"message.part.delta",
|
|
18
|
-
"session.diff",
|
|
19
|
-
"session.error",
|
|
20
|
-
])
|
|
21
|
-
const durable = SessionV1.Event.Definitions.filter((event) => event.durable !== undefined)
|
|
22
|
-
expect(durable).toHaveLength(7)
|
|
23
|
-
expect(durable.every((event) => event.durable?.aggregate === "sessionID")).toBe(true)
|
|
24
|
-
expect(durable.every((event) => event.durable?.version === 1)).toBe(true)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test("owns the legacy transient public definitions", () => {
|
|
28
|
-
expect([
|
|
29
|
-
SessionV1.PartDelta.type,
|
|
30
|
-
SessionV1.Diff.type,
|
|
31
|
-
SessionV1.Error.type,
|
|
32
|
-
PermissionV1.Event.Asked.type,
|
|
33
|
-
PermissionV1.Event.Replied.type,
|
|
34
|
-
Project.Event.Updated.type,
|
|
35
|
-
LegacyEventV1.CommandExecuted.type,
|
|
36
|
-
]).toEqual([
|
|
37
|
-
"message.part.delta",
|
|
38
|
-
"session.diff",
|
|
39
|
-
"session.error",
|
|
40
|
-
"permission.asked",
|
|
41
|
-
"permission.replied",
|
|
42
|
-
"project.updated",
|
|
43
|
-
"command.executed",
|
|
44
|
-
])
|
|
45
|
-
})
|
|
46
|
-
})
|
package/test/mcp.test.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Schema } from "effect"
|
|
3
|
-
import { Mcp } from "../src/mcp.js"
|
|
4
|
-
|
|
5
|
-
describe("Mcp resources", () => {
|
|
6
|
-
test("decodes resource catalogs and omits absent metadata", () => {
|
|
7
|
-
const value = Schema.decodeUnknownSync(Mcp.ResourceCatalog)({
|
|
8
|
-
resources: [{ server: "docs", name: "Readme", uri: "docs://readme" }],
|
|
9
|
-
templates: [{ server: "docs", name: "File", uriTemplate: "docs://{path}" }],
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
expect(Schema.encodeSync(Mcp.ResourceCatalog)(value)).toEqual({
|
|
13
|
-
resources: [{ server: "docs", name: "Readme", uri: "docs://readme" }],
|
|
14
|
-
templates: [{ server: "docs", name: "File", uriTemplate: "docs://{path}" }],
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test("preserves text and base64 blob contents", () => {
|
|
19
|
-
expect(
|
|
20
|
-
Schema.decodeUnknownSync(Mcp.ResourceContent)({
|
|
21
|
-
server: "docs",
|
|
22
|
-
uri: "docs://readme",
|
|
23
|
-
contents: [
|
|
24
|
-
{ type: "text", uri: "docs://readme", text: "hello", mimeType: "text/plain" },
|
|
25
|
-
{ type: "blob", uri: "docs://logo", blob: "aGVsbG8=", mimeType: "image/png" },
|
|
26
|
-
],
|
|
27
|
-
}),
|
|
28
|
-
).toEqual({
|
|
29
|
-
server: "docs",
|
|
30
|
-
uri: "docs://readme",
|
|
31
|
-
contents: [
|
|
32
|
-
{ type: "text", uri: "docs://readme", text: "hello", mimeType: "text/plain" },
|
|
33
|
-
{ type: "blob", uri: "docs://logo", blob: "aGVsbG8=", mimeType: "image/png" },
|
|
34
|
-
],
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
})
|
package/test/model.test.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Schema } from "effect"
|
|
3
|
-
import { Model } from "../src/model.js"
|
|
4
|
-
import { Provider } from "../src/provider.js"
|
|
5
|
-
|
|
6
|
-
describe("Model.Ref", () => {
|
|
7
|
-
test("parses model references with optional variants", () => {
|
|
8
|
-
const variant = Model.Ref.parse("openrouter/openai/gpt-5#high")
|
|
9
|
-
expect(String(variant.providerID)).toBe("openrouter")
|
|
10
|
-
expect(String(variant.id)).toBe("openai/gpt-5")
|
|
11
|
-
expect(String(variant.variant)).toBe("high")
|
|
12
|
-
|
|
13
|
-
const standard = Model.Ref.parse("anthropic/claude-sonnet")
|
|
14
|
-
expect(String(standard.providerID)).toBe("anthropic")
|
|
15
|
-
expect(String(standard.id)).toBe("claude-sonnet")
|
|
16
|
-
expect(standard.variant).toBeUndefined()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test("rejects malformed model references", () => {
|
|
20
|
-
expect(() => Model.Ref.parse("gpt-5")).toThrow()
|
|
21
|
-
expect(() => Model.Ref.parse("openai/gpt-5#")).toThrow()
|
|
22
|
-
expect(() => Model.Ref.parse("openai/gpt-5#high#extra")).toThrow()
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
describe("Model.ReasoningField", () => {
|
|
27
|
-
test("accepts suggested and custom fields", () => {
|
|
28
|
-
const decode = Schema.decodeUnknownSync(Model.ReasoningField)
|
|
29
|
-
|
|
30
|
-
for (const field of ["reasoning", "reasoning_content", "reasoning_text", "vendor_reasoning"])
|
|
31
|
-
expect(decode(field)).toBe(field)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe("Model.Compatibility", () => {
|
|
36
|
-
test("decodes model compatibility overrides", () => {
|
|
37
|
-
const decode = Schema.decodeUnknownSync(Model.Compatibility)
|
|
38
|
-
|
|
39
|
-
expect(decode({})).toEqual({})
|
|
40
|
-
expect(
|
|
41
|
-
decode({
|
|
42
|
-
reasoningField: "vendor_reasoning",
|
|
43
|
-
requireReasoning: true,
|
|
44
|
-
maxTokensField: "max_completion_tokens",
|
|
45
|
-
requireFinishReason: false,
|
|
46
|
-
requireAssistantAfterTool: true,
|
|
47
|
-
}),
|
|
48
|
-
).toEqual({
|
|
49
|
-
reasoningField: "vendor_reasoning",
|
|
50
|
-
requireReasoning: true,
|
|
51
|
-
maxTokensField: "max_completion_tokens",
|
|
52
|
-
requireFinishReason: false,
|
|
53
|
-
requireAssistantAfterTool: true,
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test("keeps capability overrides that gate protocol features", () => {
|
|
58
|
-
const decode = Schema.decodeUnknownSync(Model.Compatibility)
|
|
59
|
-
|
|
60
|
-
for (const supportsEffortUpdates of [false, true]) {
|
|
61
|
-
expect(decode({ supportsEffortUpdates, supportsThinkingBlockBinding: true })).toEqual({
|
|
62
|
-
supportsEffortUpdates,
|
|
63
|
-
supportsThinkingBlockBinding: true,
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test("omits undefined protocol capability overrides when encoded", () => {
|
|
69
|
-
expect(
|
|
70
|
-
Schema.encodeSync(Model.Compatibility)({
|
|
71
|
-
supportsEffortUpdates: undefined,
|
|
72
|
-
supportsThinkingBlockBinding: undefined,
|
|
73
|
-
}),
|
|
74
|
-
).toEqual({})
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
describe("Model.Info", () => {
|
|
79
|
-
test("provider compaction policy is a typed setting", () => {
|
|
80
|
-
const model = Model.Info.default(Provider.ID.openai, Model.ID.make("gpt-5.4-mini"))
|
|
81
|
-
expect(Schema.encodeSync(Model.Info)({ ...model, settings: { compaction: undefined } }).settings).toEqual({})
|
|
82
|
-
expect(
|
|
83
|
-
Schema.decodeUnknownSync(Model.Info)({ ...model, settings: { compaction: { type: "native" } } }).settings,
|
|
84
|
-
).toEqual({
|
|
85
|
-
compaction: { type: "native" },
|
|
86
|
-
})
|
|
87
|
-
expect(Schema.decodeUnknownSync(Provider.Compaction)({ type: "summary" })).toEqual({ type: "summary" })
|
|
88
|
-
expect(() => Schema.decodeUnknownSync(Provider.Compaction)({ type: "automatic" })).toThrow()
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test("uses practical token limits for unknown models", () => {
|
|
92
|
-
const model = Model.Info.default(Provider.ID.make("custom"), Model.ID.make("gpt-5.6"))
|
|
93
|
-
|
|
94
|
-
expect(model.limit).toEqual({ context: 200_000, output: 32_000 })
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
describe("Model.Settings", () => {
|
|
99
|
-
test("preserves provider-specific model options", () => {
|
|
100
|
-
expect(Schema.decodeUnknownSync(Model.Settings)({ providerOption: true })).toEqual({
|
|
101
|
-
providerOption: true,
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Effect } from "effect"
|
|
3
|
-
import { Session } from "../src/session.js"
|
|
4
|
-
|
|
5
|
-
describe("Session.ListCursor", () => {
|
|
6
|
-
test("round trips without Node globals", async () => {
|
|
7
|
-
const input = {
|
|
8
|
-
search: "protocol",
|
|
9
|
-
order: "desc" as const,
|
|
10
|
-
anchor: { id: Session.ID.make("ses_test"), time: 1, direction: "next" as const },
|
|
11
|
-
}
|
|
12
|
-
const cursor = Session.ListCursor.make(input)
|
|
13
|
-
|
|
14
|
-
expect(await Effect.runPromise(Session.ListCursor.parse(cursor))).toEqual(input)
|
|
15
|
-
})
|
|
16
|
-
})
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { Schema } from "effect"
|
|
3
|
-
import { LLM, SessionError } from "../src/index.js"
|
|
4
|
-
|
|
5
|
-
describe("SessionError", () => {
|
|
6
|
-
test("exports one identified open envelope", () => {
|
|
7
|
-
expect(SessionError.Error.ast.annotations?.identifier).toBe("Session.StructuredError")
|
|
8
|
-
expect(Object.keys(SessionError).filter((key) => key !== "SessionError")).toEqual(["Error"])
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
test("round trips current and future error types through JSON", () => {
|
|
12
|
-
const values: SessionError.Error[] = [
|
|
13
|
-
{ type: "provider.rate-limit", message: "Slow down" },
|
|
14
|
-
{ type: "provider.rate-limit", message: "Slow down", status: 429, response: { body: '{"error":{}}' } },
|
|
15
|
-
{ type: "provider.auth", message: "Authentication failed" },
|
|
16
|
-
{ type: "provider.free-limit", message: "Free usage limit reached", status: 429, retryAfterMs: 3_600_000 },
|
|
17
|
-
{ type: "provider.future-condition", message: "A future provider failure" },
|
|
18
|
-
{ type: "unknown", message: "Unexpected" },
|
|
19
|
-
]
|
|
20
|
-
const codec = Schema.fromJsonString(SessionError.Error)
|
|
21
|
-
|
|
22
|
-
for (const value of values) {
|
|
23
|
-
const encoded = Schema.encodeSync(codec)(value)
|
|
24
|
-
expect(Schema.decodeUnknownSync(codec)(encoded)).toEqual(value)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test("accepts future fields while exposing only the stable envelope", () => {
|
|
29
|
-
expect(
|
|
30
|
-
Schema.decodeUnknownSync(SessionError.Error)({
|
|
31
|
-
type: "provider.timeout",
|
|
32
|
-
message: "Timeout",
|
|
33
|
-
retryable: true,
|
|
34
|
-
}),
|
|
35
|
-
).toEqual({ type: "provider.timeout", message: "Timeout" })
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test("rejects missing envelope fields", () => {
|
|
39
|
-
expect(() => Schema.decodeUnknownSync(SessionError.Error)({ type: "provider.auth" })).toThrow()
|
|
40
|
-
expect(() => Schema.decodeUnknownSync(SessionError.Error)({ message: "Missing type" })).toThrow()
|
|
41
|
-
expect(() =>
|
|
42
|
-
Schema.decodeUnknownSync(SessionError.Error)({ type: "provider.auth", message: "Failed", response: {} }),
|
|
43
|
-
).toThrow()
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test("FinishReason is the closed normalized provider set", () => {
|
|
48
|
-
const reasons = ["stop", "length", "tool-calls", "content-filter", "error", "unknown"] as const
|
|
49
|
-
expect(reasons.map((reason) => Schema.decodeUnknownSync(LLM.FinishReason)(reason))).toEqual([...reasons])
|
|
50
|
-
expect(() => Schema.decodeUnknownSync(LLM.FinishReason)("other")).toThrow()
|
|
51
|
-
})
|