@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
package/src/session.ts
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
export * as Session from "./session.js"
|
|
2
|
-
|
|
3
|
-
import { Effect, Result, Schema, SchemaGetter, SchemaParser } from "effect"
|
|
4
|
-
import { Base64Url } from "effect/encoding"
|
|
5
|
-
import { Agent } from "./agent.js"
|
|
6
|
-
import { Location } from "./location.js"
|
|
7
|
-
import { Model } from "./model.js"
|
|
8
|
-
import { Project } from "./project.js"
|
|
9
|
-
import { AbsolutePath, DateTimeUtcFromMillis, optional, RelativePath, statics } from "./schema.js"
|
|
10
|
-
import { SessionEvent } from "./session-event.js"
|
|
11
|
-
import { SessionID } from "./session-id.js"
|
|
12
|
-
import { SessionMetadata } from "./session-metadata.js"
|
|
13
|
-
import { Money } from "./money.js"
|
|
14
|
-
import { Permission } from "./permission.js"
|
|
15
|
-
import { TokenUsage } from "./token-usage.js"
|
|
16
|
-
import { Revert } from "./session-revert.js"
|
|
17
|
-
import { SessionFork } from "./session-fork.js"
|
|
18
|
-
|
|
19
|
-
export const ID = SessionID
|
|
20
|
-
export type ID = SessionID
|
|
21
|
-
|
|
22
|
-
export const Metadata = SessionMetadata
|
|
23
|
-
export type Metadata = SessionMetadata
|
|
24
|
-
|
|
25
|
-
export const Event = SessionEvent
|
|
26
|
-
|
|
27
|
-
export { Revert }
|
|
28
|
-
export const ForkBoundary = SessionFork.Boundary
|
|
29
|
-
export type ForkBoundary = SessionFork.Boundary
|
|
30
|
-
|
|
31
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
32
|
-
export const Info = Schema.Struct({
|
|
33
|
-
id: ID,
|
|
34
|
-
parentID: ID.pipe(optional),
|
|
35
|
-
fork: Schema.Struct({
|
|
36
|
-
sessionID: ID,
|
|
37
|
-
boundary: ForkBoundary,
|
|
38
|
-
}).pipe(optional),
|
|
39
|
-
projectID: Project.ID,
|
|
40
|
-
agent: Agent.ID.pipe(optional),
|
|
41
|
-
model: Model.Ref.pipe(optional),
|
|
42
|
-
cost: Money.USD,
|
|
43
|
-
tokens: TokenUsage.Info,
|
|
44
|
-
/** Outcome of the last completed execution, recorded at `time.idle`. Absent until a run reaches a terminal transition. */
|
|
45
|
-
outcome: Schema.Literals(["succeeded", "failed", "interrupted"]).pipe(optional),
|
|
46
|
-
time: Schema.Struct({
|
|
47
|
-
created: DateTimeUtcFromMillis,
|
|
48
|
-
updated: DateTimeUtcFromMillis,
|
|
49
|
-
/** Start of the most recent execution. While it runs, `idle` still holds the previous execution's end. Resuming after a restart starts a new execution. */
|
|
50
|
-
busy: DateTimeUtcFromMillis.pipe(optional),
|
|
51
|
-
/** End of the most recent completed execution. */
|
|
52
|
-
idle: DateTimeUtcFromMillis.pipe(optional),
|
|
53
|
-
viewed: DateTimeUtcFromMillis.pipe(optional),
|
|
54
|
-
archived: DateTimeUtcFromMillis.pipe(optional),
|
|
55
|
-
}),
|
|
56
|
-
title: Schema.String.pipe(optional),
|
|
57
|
-
location: Location.Ref,
|
|
58
|
-
subpath: RelativePath.pipe(optional),
|
|
59
|
-
metadata: Metadata.pipe(optional),
|
|
60
|
-
/** Evaluated after the agent's rules; the last matching rule wins. */
|
|
61
|
-
permissions: Permission.Ruleset.pipe(optional),
|
|
62
|
-
revert: Revert.pipe(optional),
|
|
63
|
-
}).annotate({ identifier: "Session.Info" })
|
|
64
|
-
|
|
65
|
-
export const ListAnchor = Schema.Struct({
|
|
66
|
-
id: ID,
|
|
67
|
-
time: Schema.Finite,
|
|
68
|
-
direction: Schema.Literals(["previous", "next"]),
|
|
69
|
-
}).annotate({ identifier: "Session.ListAnchor" })
|
|
70
|
-
export interface ListAnchor extends Schema.Schema.Type<typeof ListAnchor> {}
|
|
71
|
-
|
|
72
|
-
// These fields are also the session.list HTTP query parameters. Raw Schema.optional keeps that
|
|
73
|
-
// endpoint's OpenAPI parameters unchanged.
|
|
74
|
-
const ListFilterFields = {
|
|
75
|
-
order: Schema.Literals(["asc", "desc"]).pipe(Schema.optional).annotate({
|
|
76
|
-
description: "Session order for the first page. Use desc for newest first or asc for oldest first.",
|
|
77
|
-
}),
|
|
78
|
-
search: Schema.String.pipe(Schema.optional),
|
|
79
|
-
parentID: Schema.Union([
|
|
80
|
-
ID,
|
|
81
|
-
Schema.Null.pipe(
|
|
82
|
-
Schema.encodeTo(Schema.Literal("null"), {
|
|
83
|
-
decode: SchemaGetter.transform(() => null),
|
|
84
|
-
encode: SchemaGetter.transform(() => "null" as const),
|
|
85
|
-
}),
|
|
86
|
-
),
|
|
87
|
-
])
|
|
88
|
-
.annotate({ description: "Filter by parent session. Use null to return only root sessions." })
|
|
89
|
-
.pipe(Schema.optional),
|
|
90
|
-
archived: Schema.Literals(["true", "false"])
|
|
91
|
-
.pipe(
|
|
92
|
-
Schema.decodeTo(Schema.Boolean, {
|
|
93
|
-
decode: SchemaGetter.transform((value) => value === "true"),
|
|
94
|
-
encode: SchemaGetter.transform((value): "true" | "false" => (value ? "true" : "false")),
|
|
95
|
-
}),
|
|
96
|
-
)
|
|
97
|
-
.annotate({
|
|
98
|
-
description:
|
|
99
|
-
"Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.",
|
|
100
|
-
})
|
|
101
|
-
.pipe(Schema.optional),
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const ListFilter = Schema.Struct({
|
|
105
|
-
...ListFilterFields,
|
|
106
|
-
directory: AbsolutePath.pipe(Schema.optional),
|
|
107
|
-
project: Project.ID.pipe(Schema.optional),
|
|
108
|
-
subpath: RelativePath.pipe(Schema.optional),
|
|
109
|
-
}).annotate({ identifier: "Session.ListFilter" })
|
|
110
|
-
export interface ListFilter extends Schema.Schema.Type<typeof ListFilter> {}
|
|
111
|
-
|
|
112
|
-
const ListCursorInput = Schema.Union([
|
|
113
|
-
Schema.Struct({ ...ListFilterFields, directory: AbsolutePath, anchor: ListAnchor }),
|
|
114
|
-
Schema.Struct({
|
|
115
|
-
...ListFilterFields,
|
|
116
|
-
project: Project.ID,
|
|
117
|
-
subpath: RelativePath.pipe(Schema.optional),
|
|
118
|
-
anchor: ListAnchor,
|
|
119
|
-
}),
|
|
120
|
-
Schema.Struct({ ...ListFilterFields, anchor: ListAnchor }),
|
|
121
|
-
])
|
|
122
|
-
const ListCursorJson = Schema.fromJsonString(ListCursorInput)
|
|
123
|
-
const encodeListCursor = Schema.encodeSync(ListCursorJson)
|
|
124
|
-
const decodeListCursor = Schema.decodeUnknownEffect(ListCursorJson)
|
|
125
|
-
|
|
126
|
-
export const ListCursor = Schema.String.pipe(
|
|
127
|
-
Schema.brand("SessionsCursor"),
|
|
128
|
-
Schema.annotate({
|
|
129
|
-
identifier: "SessionsCursor",
|
|
130
|
-
description: "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.",
|
|
131
|
-
}),
|
|
132
|
-
statics((schema) => {
|
|
133
|
-
// Read the default constructor without caching it on the schema, so `make` can be replaced.
|
|
134
|
-
const make = SchemaParser.make(schema)
|
|
135
|
-
return {
|
|
136
|
-
make: (input: typeof ListCursorInput.Type) => make(Base64Url.encode(encodeListCursor(input))),
|
|
137
|
-
parse: (input: string) =>
|
|
138
|
-
Effect.suspend(() => {
|
|
139
|
-
const result = Base64Url.decodeString(input)
|
|
140
|
-
return Result.isFailure(result)
|
|
141
|
-
? Effect.fail("Invalid cursor" as const)
|
|
142
|
-
: decodeListCursor(result.success).pipe(Effect.mapError(() => "Invalid cursor" as const))
|
|
143
|
-
}),
|
|
144
|
-
}
|
|
145
|
-
}),
|
|
146
|
-
)
|
|
147
|
-
export type ListCursor = typeof ListCursor.Type
|
|
1
|
+
export * as Session from "./session.js"
|
|
2
|
+
|
|
3
|
+
import { Effect, Result, Schema, SchemaGetter, SchemaParser } from "effect"
|
|
4
|
+
import { Base64Url } from "effect/encoding"
|
|
5
|
+
import { Agent } from "./agent.js"
|
|
6
|
+
import { Location } from "./location.js"
|
|
7
|
+
import { Model } from "./model.js"
|
|
8
|
+
import { Project } from "./project.js"
|
|
9
|
+
import { AbsolutePath, DateTimeUtcFromMillis, optional, RelativePath, statics } from "./schema.js"
|
|
10
|
+
import { SessionEvent } from "./session-event.js"
|
|
11
|
+
import { SessionID } from "./session-id.js"
|
|
12
|
+
import { SessionMetadata } from "./session-metadata.js"
|
|
13
|
+
import { Money } from "./money.js"
|
|
14
|
+
import { Permission } from "./permission.js"
|
|
15
|
+
import { TokenUsage } from "./token-usage.js"
|
|
16
|
+
import { Revert } from "./session-revert.js"
|
|
17
|
+
import { SessionFork } from "./session-fork.js"
|
|
18
|
+
|
|
19
|
+
export const ID = SessionID
|
|
20
|
+
export type ID = SessionID
|
|
21
|
+
|
|
22
|
+
export const Metadata = SessionMetadata
|
|
23
|
+
export type Metadata = SessionMetadata
|
|
24
|
+
|
|
25
|
+
export const Event = SessionEvent
|
|
26
|
+
|
|
27
|
+
export { Revert }
|
|
28
|
+
export const ForkBoundary = SessionFork.Boundary
|
|
29
|
+
export type ForkBoundary = SessionFork.Boundary
|
|
30
|
+
|
|
31
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
32
|
+
export const Info = Schema.Struct({
|
|
33
|
+
id: ID,
|
|
34
|
+
parentID: ID.pipe(optional),
|
|
35
|
+
fork: Schema.Struct({
|
|
36
|
+
sessionID: ID,
|
|
37
|
+
boundary: ForkBoundary,
|
|
38
|
+
}).pipe(optional),
|
|
39
|
+
projectID: Project.ID,
|
|
40
|
+
agent: Agent.ID.pipe(optional),
|
|
41
|
+
model: Model.Ref.pipe(optional),
|
|
42
|
+
cost: Money.USD,
|
|
43
|
+
tokens: TokenUsage.Info,
|
|
44
|
+
/** Outcome of the last completed execution, recorded at `time.idle`. Absent until a run reaches a terminal transition. */
|
|
45
|
+
outcome: Schema.Literals(["succeeded", "failed", "interrupted"]).pipe(optional),
|
|
46
|
+
time: Schema.Struct({
|
|
47
|
+
created: DateTimeUtcFromMillis,
|
|
48
|
+
updated: DateTimeUtcFromMillis,
|
|
49
|
+
/** Start of the most recent execution. While it runs, `idle` still holds the previous execution's end. Resuming after a restart starts a new execution. */
|
|
50
|
+
busy: DateTimeUtcFromMillis.pipe(optional),
|
|
51
|
+
/** End of the most recent completed execution. */
|
|
52
|
+
idle: DateTimeUtcFromMillis.pipe(optional),
|
|
53
|
+
viewed: DateTimeUtcFromMillis.pipe(optional),
|
|
54
|
+
archived: DateTimeUtcFromMillis.pipe(optional),
|
|
55
|
+
}),
|
|
56
|
+
title: Schema.String.pipe(optional),
|
|
57
|
+
location: Location.Ref,
|
|
58
|
+
subpath: RelativePath.pipe(optional),
|
|
59
|
+
metadata: Metadata.pipe(optional),
|
|
60
|
+
/** Evaluated after the agent's rules; the last matching rule wins. */
|
|
61
|
+
permissions: Permission.Ruleset.pipe(optional),
|
|
62
|
+
revert: Revert.pipe(optional),
|
|
63
|
+
}).annotate({ identifier: "Session.Info" })
|
|
64
|
+
|
|
65
|
+
export const ListAnchor = Schema.Struct({
|
|
66
|
+
id: ID,
|
|
67
|
+
time: Schema.Finite,
|
|
68
|
+
direction: Schema.Literals(["previous", "next"]),
|
|
69
|
+
}).annotate({ identifier: "Session.ListAnchor" })
|
|
70
|
+
export interface ListAnchor extends Schema.Schema.Type<typeof ListAnchor> {}
|
|
71
|
+
|
|
72
|
+
// These fields are also the session.list HTTP query parameters. Raw Schema.optional keeps that
|
|
73
|
+
// endpoint's OpenAPI parameters unchanged.
|
|
74
|
+
const ListFilterFields = {
|
|
75
|
+
order: Schema.Literals(["asc", "desc"]).pipe(Schema.optional).annotate({
|
|
76
|
+
description: "Session order for the first page. Use desc for newest first or asc for oldest first.",
|
|
77
|
+
}),
|
|
78
|
+
search: Schema.String.pipe(Schema.optional),
|
|
79
|
+
parentID: Schema.Union([
|
|
80
|
+
ID,
|
|
81
|
+
Schema.Null.pipe(
|
|
82
|
+
Schema.encodeTo(Schema.Literal("null"), {
|
|
83
|
+
decode: SchemaGetter.transform(() => null),
|
|
84
|
+
encode: SchemaGetter.transform(() => "null" as const),
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
])
|
|
88
|
+
.annotate({ description: "Filter by parent session. Use null to return only root sessions." })
|
|
89
|
+
.pipe(Schema.optional),
|
|
90
|
+
archived: Schema.Literals(["true", "false"])
|
|
91
|
+
.pipe(
|
|
92
|
+
Schema.decodeTo(Schema.Boolean, {
|
|
93
|
+
decode: SchemaGetter.transform((value) => value === "true"),
|
|
94
|
+
encode: SchemaGetter.transform((value): "true" | "false" => (value ? "true" : "false")),
|
|
95
|
+
}),
|
|
96
|
+
)
|
|
97
|
+
.annotate({
|
|
98
|
+
description:
|
|
99
|
+
"Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.",
|
|
100
|
+
})
|
|
101
|
+
.pipe(Schema.optional),
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const ListFilter = Schema.Struct({
|
|
105
|
+
...ListFilterFields,
|
|
106
|
+
directory: AbsolutePath.pipe(Schema.optional),
|
|
107
|
+
project: Project.ID.pipe(Schema.optional),
|
|
108
|
+
subpath: RelativePath.pipe(Schema.optional),
|
|
109
|
+
}).annotate({ identifier: "Session.ListFilter" })
|
|
110
|
+
export interface ListFilter extends Schema.Schema.Type<typeof ListFilter> {}
|
|
111
|
+
|
|
112
|
+
const ListCursorInput = Schema.Union([
|
|
113
|
+
Schema.Struct({ ...ListFilterFields, directory: AbsolutePath, anchor: ListAnchor }),
|
|
114
|
+
Schema.Struct({
|
|
115
|
+
...ListFilterFields,
|
|
116
|
+
project: Project.ID,
|
|
117
|
+
subpath: RelativePath.pipe(Schema.optional),
|
|
118
|
+
anchor: ListAnchor,
|
|
119
|
+
}),
|
|
120
|
+
Schema.Struct({ ...ListFilterFields, anchor: ListAnchor }),
|
|
121
|
+
])
|
|
122
|
+
const ListCursorJson = Schema.fromJsonString(ListCursorInput)
|
|
123
|
+
const encodeListCursor = Schema.encodeSync(ListCursorJson)
|
|
124
|
+
const decodeListCursor = Schema.decodeUnknownEffect(ListCursorJson)
|
|
125
|
+
|
|
126
|
+
export const ListCursor = Schema.String.pipe(
|
|
127
|
+
Schema.brand("SessionsCursor"),
|
|
128
|
+
Schema.annotate({
|
|
129
|
+
identifier: "SessionsCursor",
|
|
130
|
+
description: "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.",
|
|
131
|
+
}),
|
|
132
|
+
statics((schema) => {
|
|
133
|
+
// Read the default constructor without caching it on the schema, so `make` can be replaced.
|
|
134
|
+
const make = SchemaParser.make(schema)
|
|
135
|
+
return {
|
|
136
|
+
make: (input: typeof ListCursorInput.Type) => make(Base64Url.encode(encodeListCursor(input))),
|
|
137
|
+
parse: (input: string) =>
|
|
138
|
+
Effect.suspend(() => {
|
|
139
|
+
const result = Base64Url.decodeString(input)
|
|
140
|
+
return Result.isFailure(result)
|
|
141
|
+
? Effect.fail("Invalid cursor" as const)
|
|
142
|
+
: decodeListCursor(result.success).pipe(Effect.mapError(() => "Invalid cursor" as const))
|
|
143
|
+
}),
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
)
|
|
147
|
+
export type ListCursor = typeof ListCursor.Type
|
package/src/shell.ts
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
export * as Shell from "./shell.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { optional } from "./schema.js"
|
|
5
|
-
import { ephemeral, inventory } from "./event.js"
|
|
6
|
-
import { ascending } from "./identifier.js"
|
|
7
|
-
import { NonNegativeInt, statics } from "./schema.js"
|
|
8
|
-
|
|
9
|
-
const IDSchema = Schema.String.check(Schema.isStartingWith("sh_")).pipe(
|
|
10
|
-
Schema.brand("Shell.ID"),
|
|
11
|
-
Schema.annotate({ identifier: "Shell.ID" }),
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
export const ID = IDSchema.pipe(
|
|
15
|
-
statics((schema: typeof IDSchema) => {
|
|
16
|
-
const create = () => schema.make("sh_" + ascending())
|
|
17
|
-
return {
|
|
18
|
-
create,
|
|
19
|
-
ascending: (id?: string) => (id === undefined ? create() : schema.make(id)),
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
22
|
-
)
|
|
23
|
-
export type ID = typeof ID.Type
|
|
24
|
-
|
|
25
|
-
export const Status = Schema.Literals(["running", "exited", "timeout", "killed"])
|
|
26
|
-
export type Status = typeof Status.Type
|
|
27
|
-
|
|
28
|
-
export const Time = Schema.Struct({
|
|
29
|
-
started: Schema.Finite.annotate({ description: "Start time in milliseconds since the Unix epoch" }),
|
|
30
|
-
completed: optional(Schema.Finite).annotate({
|
|
31
|
-
description: "Completion time in milliseconds since the Unix epoch",
|
|
32
|
-
}),
|
|
33
|
-
})
|
|
34
|
-
export interface Time extends Schema.Schema.Type<typeof Time> {}
|
|
35
|
-
|
|
36
|
-
// Opaque caller-supplied tags echoed back on Info and events. The Shell service never interprets
|
|
37
|
-
// these; callers (e.g. ShellTool stores the originating session ID) use them to filter or correlate.
|
|
38
|
-
export const Metadata = Schema.Record(Schema.String, Schema.Unknown)
|
|
39
|
-
export type Metadata = typeof Metadata.Type
|
|
40
|
-
|
|
41
|
-
export const Info = Schema.Struct({
|
|
42
|
-
id: ID,
|
|
43
|
-
status: Status,
|
|
44
|
-
command: Schema.String,
|
|
45
|
-
cwd: Schema.String,
|
|
46
|
-
shell: Schema.String,
|
|
47
|
-
// Absolute path of the file capturing combined stdout/stderr. Page through it via `output`.
|
|
48
|
-
file: Schema.String,
|
|
49
|
-
pid: optional(NonNegativeInt),
|
|
50
|
-
exit: optional(Schema.Finite),
|
|
51
|
-
signal: optional(Schema.String),
|
|
52
|
-
// Always present; defaults to an empty object when the creator supplies no metadata.
|
|
53
|
-
metadata: Metadata,
|
|
54
|
-
time: Time,
|
|
55
|
-
}).annotate({ identifier: "Shell.Info" })
|
|
56
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
57
|
-
|
|
58
|
-
const Created = ephemeral({ type: "shell.created", schema: { info: Info } })
|
|
59
|
-
const Exited = ephemeral({ type: "shell.exited", schema: { id: ID, exit: optional(Schema.Finite), status: Status } })
|
|
60
|
-
const Deleted = ephemeral({ type: "shell.deleted", schema: { id: ID } })
|
|
61
|
-
export const Event = { Created, Exited, Deleted, Definitions: inventory(Created, Exited, Deleted) }
|
|
62
|
-
|
|
63
|
-
export const CreateInput = Schema.Struct({
|
|
64
|
-
command: Schema.String,
|
|
65
|
-
cwd: optional(Schema.String),
|
|
66
|
-
timeout: optional(NonNegativeInt),
|
|
67
|
-
metadata: optional(Metadata),
|
|
68
|
-
})
|
|
69
|
-
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
70
|
-
|
|
71
|
-
// Descriptions sit on the inner schema because the query string codec drops annotations on `optional` itself.
|
|
72
|
-
export const OutputInput = Schema.Struct({
|
|
73
|
-
cursor: optional(
|
|
74
|
-
NonNegativeInt.annotateKey({
|
|
75
|
-
description: "Byte offset to read from, such as the cursor of the previous page. Defaults to 0.",
|
|
76
|
-
}),
|
|
77
|
-
),
|
|
78
|
-
limit: optional(NonNegativeInt.annotateKey({ description: "Maximum number of bytes to return. Defaults to 65536." })),
|
|
79
|
-
})
|
|
80
|
-
export interface OutputInput extends Schema.Schema.Type<typeof OutputInput> {}
|
|
81
|
-
|
|
82
|
-
export const Output = Schema.Struct({
|
|
83
|
-
output: Schema.String,
|
|
84
|
-
// Absolute cursor after this page. Equals `size` once fully caught up.
|
|
85
|
-
cursor: NonNegativeInt,
|
|
86
|
-
// Total bytes captured so far. A consumer has more to page while `cursor < size`.
|
|
87
|
-
size: NonNegativeInt,
|
|
88
|
-
truncated: Schema.Boolean,
|
|
89
|
-
})
|
|
90
|
-
export interface Output extends Schema.Schema.Type<typeof Output> {}
|
|
1
|
+
export * as Shell from "./shell.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { optional } from "./schema.js"
|
|
5
|
+
import { ephemeral, inventory } from "./event.js"
|
|
6
|
+
import { ascending } from "./identifier.js"
|
|
7
|
+
import { NonNegativeInt, statics } from "./schema.js"
|
|
8
|
+
|
|
9
|
+
const IDSchema = Schema.String.check(Schema.isStartingWith("sh_")).pipe(
|
|
10
|
+
Schema.brand("Shell.ID"),
|
|
11
|
+
Schema.annotate({ identifier: "Shell.ID" }),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export const ID = IDSchema.pipe(
|
|
15
|
+
statics((schema: typeof IDSchema) => {
|
|
16
|
+
const create = () => schema.make("sh_" + ascending())
|
|
17
|
+
return {
|
|
18
|
+
create,
|
|
19
|
+
ascending: (id?: string) => (id === undefined ? create() : schema.make(id)),
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
23
|
+
export type ID = typeof ID.Type
|
|
24
|
+
|
|
25
|
+
export const Status = Schema.Literals(["running", "exited", "timeout", "killed"])
|
|
26
|
+
export type Status = typeof Status.Type
|
|
27
|
+
|
|
28
|
+
export const Time = Schema.Struct({
|
|
29
|
+
started: Schema.Finite.annotate({ description: "Start time in milliseconds since the Unix epoch" }),
|
|
30
|
+
completed: optional(Schema.Finite).annotate({
|
|
31
|
+
description: "Completion time in milliseconds since the Unix epoch",
|
|
32
|
+
}),
|
|
33
|
+
})
|
|
34
|
+
export interface Time extends Schema.Schema.Type<typeof Time> {}
|
|
35
|
+
|
|
36
|
+
// Opaque caller-supplied tags echoed back on Info and events. The Shell service never interprets
|
|
37
|
+
// these; callers (e.g. ShellTool stores the originating session ID) use them to filter or correlate.
|
|
38
|
+
export const Metadata = Schema.Record(Schema.String, Schema.Unknown)
|
|
39
|
+
export type Metadata = typeof Metadata.Type
|
|
40
|
+
|
|
41
|
+
export const Info = Schema.Struct({
|
|
42
|
+
id: ID,
|
|
43
|
+
status: Status,
|
|
44
|
+
command: Schema.String,
|
|
45
|
+
cwd: Schema.String,
|
|
46
|
+
shell: Schema.String,
|
|
47
|
+
// Absolute path of the file capturing combined stdout/stderr. Page through it via `output`.
|
|
48
|
+
file: Schema.String,
|
|
49
|
+
pid: optional(NonNegativeInt),
|
|
50
|
+
exit: optional(Schema.Finite),
|
|
51
|
+
signal: optional(Schema.String),
|
|
52
|
+
// Always present; defaults to an empty object when the creator supplies no metadata.
|
|
53
|
+
metadata: Metadata,
|
|
54
|
+
time: Time,
|
|
55
|
+
}).annotate({ identifier: "Shell.Info" })
|
|
56
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
57
|
+
|
|
58
|
+
const Created = ephemeral({ type: "shell.created", schema: { info: Info } })
|
|
59
|
+
const Exited = ephemeral({ type: "shell.exited", schema: { id: ID, exit: optional(Schema.Finite), status: Status } })
|
|
60
|
+
const Deleted = ephemeral({ type: "shell.deleted", schema: { id: ID } })
|
|
61
|
+
export const Event = { Created, Exited, Deleted, Definitions: inventory(Created, Exited, Deleted) }
|
|
62
|
+
|
|
63
|
+
export const CreateInput = Schema.Struct({
|
|
64
|
+
command: Schema.String,
|
|
65
|
+
cwd: optional(Schema.String),
|
|
66
|
+
timeout: optional(NonNegativeInt),
|
|
67
|
+
metadata: optional(Metadata),
|
|
68
|
+
})
|
|
69
|
+
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
70
|
+
|
|
71
|
+
// Descriptions sit on the inner schema because the query string codec drops annotations on `optional` itself.
|
|
72
|
+
export const OutputInput = Schema.Struct({
|
|
73
|
+
cursor: optional(
|
|
74
|
+
NonNegativeInt.annotateKey({
|
|
75
|
+
description: "Byte offset to read from, such as the cursor of the previous page. Defaults to 0.",
|
|
76
|
+
}),
|
|
77
|
+
),
|
|
78
|
+
limit: optional(NonNegativeInt.annotateKey({ description: "Maximum number of bytes to return. Defaults to 65536." })),
|
|
79
|
+
})
|
|
80
|
+
export interface OutputInput extends Schema.Schema.Type<typeof OutputInput> {}
|
|
81
|
+
|
|
82
|
+
export const Output = Schema.Struct({
|
|
83
|
+
output: Schema.String,
|
|
84
|
+
// Absolute cursor after this page. Equals `size` once fully caught up.
|
|
85
|
+
cursor: NonNegativeInt,
|
|
86
|
+
// Total bytes captured so far. A consumer has more to page while `cursor < size`.
|
|
87
|
+
size: NonNegativeInt,
|
|
88
|
+
truncated: Schema.Boolean,
|
|
89
|
+
})
|
|
90
|
+
export interface Output extends Schema.Schema.Type<typeof Output> {}
|
package/src/skill.ts
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
export * as Skill from "./skill.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { optional } from "./schema.js"
|
|
5
|
-
import { AbsolutePath } from "./schema.js"
|
|
6
|
-
import { ephemeral, inventory } from "./event.js"
|
|
7
|
-
|
|
8
|
-
export const ID = Schema.String.pipe(Schema.brand("Skill.ID"), Schema.annotate({ identifier: "Skill.ID" }))
|
|
9
|
-
export type ID = typeof ID.Type
|
|
10
|
-
|
|
11
|
-
export const Name = Schema.String.pipe(Schema.brand("Skill.Name"), Schema.annotate({ identifier: "Skill.Name" }))
|
|
12
|
-
export type Name = typeof Name.Type
|
|
13
|
-
|
|
14
|
-
export interface DirectorySource extends Schema.Schema.Type<typeof DirectorySource> {}
|
|
15
|
-
export const DirectorySource = Schema.Struct({
|
|
16
|
-
type: Schema.tag("directory"),
|
|
17
|
-
path: AbsolutePath,
|
|
18
|
-
}).annotate({ identifier: "Skill.DirectorySource" })
|
|
19
|
-
|
|
20
|
-
export interface UrlSource extends Schema.Schema.Type<typeof UrlSource> {}
|
|
21
|
-
export const UrlSource = Schema.Struct({
|
|
22
|
-
type: Schema.tag("url"),
|
|
23
|
-
url: Schema.String,
|
|
24
|
-
}).annotate({ identifier: "Skill.UrlSource" })
|
|
25
|
-
|
|
26
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
27
|
-
export const Info = Schema.Struct({
|
|
28
|
-
id: ID,
|
|
29
|
-
name: Name,
|
|
30
|
-
description: Schema.String.pipe(optional),
|
|
31
|
-
autoinvoke: Schema.Boolean.pipe(optional),
|
|
32
|
-
path: AbsolutePath,
|
|
33
|
-
content: Schema.String.annotate({
|
|
34
|
-
description: "The SKILL.md body. Empty for a skill whose body loads on demand, such as an MCP skill.",
|
|
35
|
-
}),
|
|
36
|
-
}).annotate({ identifier: "Skill.Info" })
|
|
37
|
-
|
|
38
|
-
const Updated = ephemeral({ type: "skill.updated", schema: {} })
|
|
39
|
-
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
40
|
-
|
|
41
|
-
export interface EmbeddedSource extends Schema.Schema.Type<typeof EmbeddedSource> {}
|
|
42
|
-
export const EmbeddedSource = Schema.Struct({
|
|
43
|
-
type: Schema.tag("embedded"),
|
|
44
|
-
skill: Schema.suspend(() => Info),
|
|
45
|
-
}).annotate({ identifier: "Skill.EmbeddedSource" })
|
|
46
|
-
|
|
47
|
-
export type Source = DirectorySource | UrlSource | EmbeddedSource
|
|
48
|
-
export const Source = Object.assign(
|
|
49
|
-
Schema.Union([DirectorySource, UrlSource, EmbeddedSource]).pipe(
|
|
50
|
-
Schema.toTaggedUnion("type"),
|
|
51
|
-
Schema.annotate({ identifier: "Skill.Source" }),
|
|
52
|
-
),
|
|
53
|
-
{
|
|
54
|
-
equals: (a: Source, b: Source) => {
|
|
55
|
-
if (a.type !== b.type) return false
|
|
56
|
-
if (a.type === "directory" && b.type === "directory") return a.path === b.path
|
|
57
|
-
if (a.type === "url" && b.type === "url") return a.url === b.url
|
|
58
|
-
if (a.type === "embedded" && b.type === "embedded") return a.skill.id === b.skill.id
|
|
59
|
-
return false
|
|
60
|
-
},
|
|
61
|
-
key: (source: Source) =>
|
|
62
|
-
source.type === "directory"
|
|
63
|
-
? `directory:${source.path}`
|
|
64
|
-
: source.type === "url"
|
|
65
|
-
? `url:${source.url}`
|
|
66
|
-
: `embedded:${source.skill.id}`,
|
|
67
|
-
},
|
|
68
|
-
)
|
|
1
|
+
export * as Skill from "./skill.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { optional } from "./schema.js"
|
|
5
|
+
import { AbsolutePath } from "./schema.js"
|
|
6
|
+
import { ephemeral, inventory } from "./event.js"
|
|
7
|
+
|
|
8
|
+
export const ID = Schema.String.pipe(Schema.brand("Skill.ID"), Schema.annotate({ identifier: "Skill.ID" }))
|
|
9
|
+
export type ID = typeof ID.Type
|
|
10
|
+
|
|
11
|
+
export const Name = Schema.String.pipe(Schema.brand("Skill.Name"), Schema.annotate({ identifier: "Skill.Name" }))
|
|
12
|
+
export type Name = typeof Name.Type
|
|
13
|
+
|
|
14
|
+
export interface DirectorySource extends Schema.Schema.Type<typeof DirectorySource> {}
|
|
15
|
+
export const DirectorySource = Schema.Struct({
|
|
16
|
+
type: Schema.tag("directory"),
|
|
17
|
+
path: AbsolutePath,
|
|
18
|
+
}).annotate({ identifier: "Skill.DirectorySource" })
|
|
19
|
+
|
|
20
|
+
export interface UrlSource extends Schema.Schema.Type<typeof UrlSource> {}
|
|
21
|
+
export const UrlSource = Schema.Struct({
|
|
22
|
+
type: Schema.tag("url"),
|
|
23
|
+
url: Schema.String,
|
|
24
|
+
}).annotate({ identifier: "Skill.UrlSource" })
|
|
25
|
+
|
|
26
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
27
|
+
export const Info = Schema.Struct({
|
|
28
|
+
id: ID,
|
|
29
|
+
name: Name,
|
|
30
|
+
description: Schema.String.pipe(optional),
|
|
31
|
+
autoinvoke: Schema.Boolean.pipe(optional),
|
|
32
|
+
path: AbsolutePath,
|
|
33
|
+
content: Schema.String.annotate({
|
|
34
|
+
description: "The SKILL.md body. Empty for a skill whose body loads on demand, such as an MCP skill.",
|
|
35
|
+
}),
|
|
36
|
+
}).annotate({ identifier: "Skill.Info" })
|
|
37
|
+
|
|
38
|
+
const Updated = ephemeral({ type: "skill.updated", schema: {} })
|
|
39
|
+
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
40
|
+
|
|
41
|
+
export interface EmbeddedSource extends Schema.Schema.Type<typeof EmbeddedSource> {}
|
|
42
|
+
export const EmbeddedSource = Schema.Struct({
|
|
43
|
+
type: Schema.tag("embedded"),
|
|
44
|
+
skill: Schema.suspend(() => Info),
|
|
45
|
+
}).annotate({ identifier: "Skill.EmbeddedSource" })
|
|
46
|
+
|
|
47
|
+
export type Source = DirectorySource | UrlSource | EmbeddedSource
|
|
48
|
+
export const Source = Object.assign(
|
|
49
|
+
Schema.Union([DirectorySource, UrlSource, EmbeddedSource]).pipe(
|
|
50
|
+
Schema.toTaggedUnion("type"),
|
|
51
|
+
Schema.annotate({ identifier: "Skill.Source" }),
|
|
52
|
+
),
|
|
53
|
+
{
|
|
54
|
+
equals: (a: Source, b: Source) => {
|
|
55
|
+
if (a.type !== b.type) return false
|
|
56
|
+
if (a.type === "directory" && b.type === "directory") return a.path === b.path
|
|
57
|
+
if (a.type === "url" && b.type === "url") return a.url === b.url
|
|
58
|
+
if (a.type === "embedded" && b.type === "embedded") return a.skill.id === b.skill.id
|
|
59
|
+
return false
|
|
60
|
+
},
|
|
61
|
+
key: (source: Source) =>
|
|
62
|
+
source.type === "directory"
|
|
63
|
+
? `directory:${source.path}`
|
|
64
|
+
: source.type === "url"
|
|
65
|
+
? `url:${source.url}`
|
|
66
|
+
: `embedded:${source.skill.id}`,
|
|
67
|
+
},
|
|
68
|
+
)
|
package/src/snapshot.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as Snapshot from "./snapshot.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
|
|
5
|
-
export const ID = Schema.String.pipe(Schema.brand("Snapshot.ID"), Schema.annotate({ identifier: "Snapshot.ID" }))
|
|
6
|
-
export type ID = typeof ID.Type
|
|
1
|
+
export * as Snapshot from "./snapshot.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
|
|
5
|
+
export const ID = Schema.String.pipe(Schema.brand("Snapshot.ID"), Schema.annotate({ identifier: "Snapshot.ID" }))
|
|
6
|
+
export type ID = typeof ID.Type
|