@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/token-usage.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * as TokenUsage from "./token-usage.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
|
|
5
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
6
|
-
export const Info = Schema.Struct({
|
|
7
|
-
input: Schema.Finite,
|
|
8
|
-
output: Schema.Finite,
|
|
9
|
-
reasoning: Schema.Finite,
|
|
10
|
-
cache: Schema.Struct({
|
|
11
|
-
read: Schema.Finite,
|
|
12
|
-
write: Schema.Finite,
|
|
13
|
-
}),
|
|
14
|
-
}).annotate({ identifier: "TokenUsage.Info" })
|
|
15
|
-
|
|
16
|
-
export function total(tokens: Info) {
|
|
17
|
-
return tokens.input + tokens.output + tokens.reasoning + tokens.cache.read + tokens.cache.write
|
|
18
|
-
}
|
|
1
|
+
export * as TokenUsage from "./token-usage.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
|
|
5
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
6
|
+
export const Info = Schema.Struct({
|
|
7
|
+
input: Schema.Finite,
|
|
8
|
+
output: Schema.Finite,
|
|
9
|
+
reasoning: Schema.Finite,
|
|
10
|
+
cache: Schema.Struct({
|
|
11
|
+
read: Schema.Finite,
|
|
12
|
+
write: Schema.Finite,
|
|
13
|
+
}),
|
|
14
|
+
}).annotate({ identifier: "TokenUsage.Info" })
|
|
15
|
+
|
|
16
|
+
export function total(tokens: Info) {
|
|
17
|
+
return tokens.input + tokens.output + tokens.reasoning + tokens.cache.read + tokens.cache.write
|
|
18
|
+
}
|
package/src/tool.ts
CHANGED
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
export * as Tool from "./tool.js"
|
|
2
|
-
|
|
3
|
-
import { Effect, JsonSchema, Schema } from "effect"
|
|
4
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec"
|
|
5
|
-
import type { Agent } from "./agent.js"
|
|
6
|
-
import type { Automation } from "./automation.js"
|
|
7
|
-
import type { Session } from "./session.js"
|
|
8
|
-
import type { SessionMessage } from "./session-message.js"
|
|
9
|
-
|
|
10
|
-
export type Metadata = Readonly<Record<string, any>>
|
|
11
|
-
|
|
12
|
-
const field = Schema.optionalKey(Schema.String)
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Optional wire encoding of a tool's single required string field. Execution still receives the object.
|
|
16
|
-
*
|
|
17
|
-
* `field` names that required string field, so the tool can have other parameters. Models that take raw text then set
|
|
18
|
-
* those on an optional first line, which the AI package describes and parses; the format constrains the rest.
|
|
19
|
-
*/
|
|
20
|
-
export const Freeform = Schema.Union([
|
|
21
|
-
Schema.Struct({ type: Schema.Literal("text"), field }),
|
|
22
|
-
Schema.Struct({ type: Schema.Literal("regex"), pattern: Schema.String, field }),
|
|
23
|
-
Schema.Struct({ type: Schema.Literal("lark"), grammar: Schema.String, field }),
|
|
24
|
-
]).annotate({ identifier: "Tool.Freeform" })
|
|
25
|
-
export type Freeform = typeof Freeform.Type
|
|
26
|
-
|
|
27
|
-
export const FreeformFormat = Schema.Literals(Freeform.members.map((member) => member.fields.type.literal)).annotate({
|
|
28
|
-
identifier: "Tool.FreeformFormat",
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
export const CallID = Schema.String.pipe(Schema.brand("Tool.CallID"))
|
|
32
|
-
export type CallID = typeof CallID.Type
|
|
33
|
-
|
|
34
|
-
export interface Context {
|
|
35
|
-
readonly sessionID: Session.ID
|
|
36
|
-
readonly agent: Agent.ID
|
|
37
|
-
readonly messageID: SessionMessage.ID
|
|
38
|
-
readonly id: CallID
|
|
39
|
-
readonly progress: (update: Metadata) => Effect.Effect<void>
|
|
40
|
-
/**
|
|
41
|
-
* Completes when the user asks the call to stop. A tool that awaits it can stop its work and fail with what it
|
|
42
|
-
* has; a tool that does not is interrupted.
|
|
43
|
-
*/
|
|
44
|
-
readonly cancel?: Effect.Effect<void>
|
|
45
|
-
/** True when the tool is invoked from inside Code Mode (`execute`). */
|
|
46
|
-
readonly codemode?: boolean
|
|
47
|
-
/**
|
|
48
|
-
* Set when an automation's code makes the call. No model waits on it, and nobody hears about work it leaves
|
|
49
|
-
* running, so a tool must finish its work within the call.
|
|
50
|
-
*/
|
|
51
|
-
readonly automation?: { readonly id: Automation.ID }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface Namespace {
|
|
55
|
-
readonly name: string
|
|
56
|
-
readonly description: string
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface Options<
|
|
60
|
-
CMInput extends ValueSchema<any> = ValueSchema<any>,
|
|
61
|
-
CMOutput extends ValueSchema<any> | undefined = ValueSchema<any> | undefined,
|
|
62
|
-
> {
|
|
63
|
-
readonly namespace?: string
|
|
64
|
-
readonly permission?: string
|
|
65
|
-
readonly codemode?:
|
|
66
|
-
| boolean
|
|
67
|
-
| {
|
|
68
|
-
readonly pinned?: boolean
|
|
69
|
-
readonly description?: string
|
|
70
|
-
readonly input?: CMInput
|
|
71
|
-
readonly output?: CMOutput
|
|
72
|
-
}
|
|
73
|
-
/** @deprecated Use `codemode.pinned` instead. Removed in the next minor. */
|
|
74
|
-
readonly pinned?: boolean
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type ValueSchema<A = unknown> = Schema.Codec<A, any> | StandardSchemaV1<any, A> | JsonSchema.JsonSchema
|
|
78
|
-
|
|
79
|
-
type InputValue<S> = 0 extends 1 & S
|
|
80
|
-
? any
|
|
81
|
-
: S extends Schema.Codec<infer A, any>
|
|
82
|
-
? A
|
|
83
|
-
: S extends StandardSchemaV1<any, infer A>
|
|
84
|
-
? A
|
|
85
|
-
: unknown
|
|
86
|
-
type OutputValue<S> = 0 extends 1 & S
|
|
87
|
-
? any
|
|
88
|
-
: S extends undefined
|
|
89
|
-
? never
|
|
90
|
-
: S extends Schema.Codec<infer A, any>
|
|
91
|
-
? A
|
|
92
|
-
: S extends StandardSchemaV1<infer A, any>
|
|
93
|
-
? A
|
|
94
|
-
: any
|
|
95
|
-
|
|
96
|
-
export class Error extends Schema.TaggedError<Error>()("Tool.Error", {
|
|
97
|
-
message: Schema.String,
|
|
98
|
-
error: Schema.optional(Schema.Defect()),
|
|
99
|
-
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
100
|
-
}) {}
|
|
101
|
-
|
|
102
|
-
export interface TextContent extends Schema.Schema.Type<typeof TextContent> {}
|
|
103
|
-
export const TextContent = Schema.Struct({
|
|
104
|
-
type: Schema.Literal("text"),
|
|
105
|
-
text: Schema.String,
|
|
106
|
-
}).annotate({ identifier: "Tool.TextContent" })
|
|
107
|
-
|
|
108
|
-
export interface FileContent extends Schema.Schema.Type<typeof FileContent> {}
|
|
109
|
-
export const FileContent = Schema.Struct({
|
|
110
|
-
type: Schema.Literal("file"),
|
|
111
|
-
uri: Schema.String,
|
|
112
|
-
mime: Schema.String,
|
|
113
|
-
name: Schema.optional(Schema.String),
|
|
114
|
-
}).annotate({ identifier: "Tool.FileContent" })
|
|
115
|
-
|
|
116
|
-
export const Content = Schema.Union([TextContent, FileContent])
|
|
117
|
-
.pipe(Schema.toTaggedUnion("type"))
|
|
118
|
-
.annotate({ identifier: "Tool.Content" })
|
|
119
|
-
export type Content = Schema.Schema.Type<typeof Content>
|
|
120
|
-
|
|
121
|
-
export interface Result<Output extends ValueSchema<any> | undefined = ValueSchema<any> | undefined> {
|
|
122
|
-
readonly output?: OutputValue<Output>
|
|
123
|
-
readonly content?: string | ReadonlyArray<Content>
|
|
124
|
-
readonly metadata?: Metadata
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export type Info<
|
|
128
|
-
Input extends ValueSchema<any> = ValueSchema<any>,
|
|
129
|
-
Output extends ValueSchema<any> | undefined = ValueSchema<any> | undefined,
|
|
130
|
-
CMInput extends ValueSchema<any> = Input,
|
|
131
|
-
CMOutput extends ValueSchema<any> | undefined = Output,
|
|
132
|
-
> = {
|
|
133
|
-
readonly name: string
|
|
134
|
-
readonly input: Input
|
|
135
|
-
readonly freeform?: Freeform
|
|
136
|
-
readonly description: string
|
|
137
|
-
readonly execute: (
|
|
138
|
-
input: InputValue<Input> | InputValue<CMInput>,
|
|
139
|
-
context: Context,
|
|
140
|
-
) => Effect.Effect<Result<Output | CMOutput>, Error>
|
|
141
|
-
readonly output?: Output
|
|
142
|
-
readonly options?: Options<CMInput, CMOutput>
|
|
143
|
-
}
|
|
1
|
+
export * as Tool from "./tool.js"
|
|
2
|
+
|
|
3
|
+
import { Effect, JsonSchema, Schema } from "effect"
|
|
4
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec"
|
|
5
|
+
import type { Agent } from "./agent.js"
|
|
6
|
+
import type { Automation } from "./automation.js"
|
|
7
|
+
import type { Session } from "./session.js"
|
|
8
|
+
import type { SessionMessage } from "./session-message.js"
|
|
9
|
+
|
|
10
|
+
export type Metadata = Readonly<Record<string, any>>
|
|
11
|
+
|
|
12
|
+
const field = Schema.optionalKey(Schema.String)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Optional wire encoding of a tool's single required string field. Execution still receives the object.
|
|
16
|
+
*
|
|
17
|
+
* `field` names that required string field, so the tool can have other parameters. Models that take raw text then set
|
|
18
|
+
* those on an optional first line, which the AI package describes and parses; the format constrains the rest.
|
|
19
|
+
*/
|
|
20
|
+
export const Freeform = Schema.Union([
|
|
21
|
+
Schema.Struct({ type: Schema.Literal("text"), field }),
|
|
22
|
+
Schema.Struct({ type: Schema.Literal("regex"), pattern: Schema.String, field }),
|
|
23
|
+
Schema.Struct({ type: Schema.Literal("lark"), grammar: Schema.String, field }),
|
|
24
|
+
]).annotate({ identifier: "Tool.Freeform" })
|
|
25
|
+
export type Freeform = typeof Freeform.Type
|
|
26
|
+
|
|
27
|
+
export const FreeformFormat = Schema.Literals(Freeform.members.map((member) => member.fields.type.literal)).annotate({
|
|
28
|
+
identifier: "Tool.FreeformFormat",
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export const CallID = Schema.String.pipe(Schema.brand("Tool.CallID"))
|
|
32
|
+
export type CallID = typeof CallID.Type
|
|
33
|
+
|
|
34
|
+
export interface Context {
|
|
35
|
+
readonly sessionID: Session.ID
|
|
36
|
+
readonly agent: Agent.ID
|
|
37
|
+
readonly messageID: SessionMessage.ID
|
|
38
|
+
readonly id: CallID
|
|
39
|
+
readonly progress: (update: Metadata) => Effect.Effect<void>
|
|
40
|
+
/**
|
|
41
|
+
* Completes when the user asks the call to stop. A tool that awaits it can stop its work and fail with what it
|
|
42
|
+
* has; a tool that does not is interrupted.
|
|
43
|
+
*/
|
|
44
|
+
readonly cancel?: Effect.Effect<void>
|
|
45
|
+
/** True when the tool is invoked from inside Code Mode (`execute`). */
|
|
46
|
+
readonly codemode?: boolean
|
|
47
|
+
/**
|
|
48
|
+
* Set when an automation's code makes the call. No model waits on it, and nobody hears about work it leaves
|
|
49
|
+
* running, so a tool must finish its work within the call.
|
|
50
|
+
*/
|
|
51
|
+
readonly automation?: { readonly id: Automation.ID }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Namespace {
|
|
55
|
+
readonly name: string
|
|
56
|
+
readonly description: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Options<
|
|
60
|
+
CMInput extends ValueSchema<any> = ValueSchema<any>,
|
|
61
|
+
CMOutput extends ValueSchema<any> | undefined = ValueSchema<any> | undefined,
|
|
62
|
+
> {
|
|
63
|
+
readonly namespace?: string
|
|
64
|
+
readonly permission?: string
|
|
65
|
+
readonly codemode?:
|
|
66
|
+
| boolean
|
|
67
|
+
| {
|
|
68
|
+
readonly pinned?: boolean
|
|
69
|
+
readonly description?: string
|
|
70
|
+
readonly input?: CMInput
|
|
71
|
+
readonly output?: CMOutput
|
|
72
|
+
}
|
|
73
|
+
/** @deprecated Use `codemode.pinned` instead. Removed in the next minor. */
|
|
74
|
+
readonly pinned?: boolean
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type ValueSchema<A = unknown> = Schema.Codec<A, any> | StandardSchemaV1<any, A> | JsonSchema.JsonSchema
|
|
78
|
+
|
|
79
|
+
type InputValue<S> = 0 extends 1 & S
|
|
80
|
+
? any
|
|
81
|
+
: S extends Schema.Codec<infer A, any>
|
|
82
|
+
? A
|
|
83
|
+
: S extends StandardSchemaV1<any, infer A>
|
|
84
|
+
? A
|
|
85
|
+
: unknown
|
|
86
|
+
type OutputValue<S> = 0 extends 1 & S
|
|
87
|
+
? any
|
|
88
|
+
: S extends undefined
|
|
89
|
+
? never
|
|
90
|
+
: S extends Schema.Codec<infer A, any>
|
|
91
|
+
? A
|
|
92
|
+
: S extends StandardSchemaV1<infer A, any>
|
|
93
|
+
? A
|
|
94
|
+
: any
|
|
95
|
+
|
|
96
|
+
export class Error extends Schema.TaggedError<Error>()("Tool.Error", {
|
|
97
|
+
message: Schema.String,
|
|
98
|
+
error: Schema.optional(Schema.Defect()),
|
|
99
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
100
|
+
}) {}
|
|
101
|
+
|
|
102
|
+
export interface TextContent extends Schema.Schema.Type<typeof TextContent> {}
|
|
103
|
+
export const TextContent = Schema.Struct({
|
|
104
|
+
type: Schema.Literal("text"),
|
|
105
|
+
text: Schema.String,
|
|
106
|
+
}).annotate({ identifier: "Tool.TextContent" })
|
|
107
|
+
|
|
108
|
+
export interface FileContent extends Schema.Schema.Type<typeof FileContent> {}
|
|
109
|
+
export const FileContent = Schema.Struct({
|
|
110
|
+
type: Schema.Literal("file"),
|
|
111
|
+
uri: Schema.String,
|
|
112
|
+
mime: Schema.String,
|
|
113
|
+
name: Schema.optional(Schema.String),
|
|
114
|
+
}).annotate({ identifier: "Tool.FileContent" })
|
|
115
|
+
|
|
116
|
+
export const Content = Schema.Union([TextContent, FileContent])
|
|
117
|
+
.pipe(Schema.toTaggedUnion("type"))
|
|
118
|
+
.annotate({ identifier: "Tool.Content" })
|
|
119
|
+
export type Content = Schema.Schema.Type<typeof Content>
|
|
120
|
+
|
|
121
|
+
export interface Result<Output extends ValueSchema<any> | undefined = ValueSchema<any> | undefined> {
|
|
122
|
+
readonly output?: OutputValue<Output>
|
|
123
|
+
readonly content?: string | ReadonlyArray<Content>
|
|
124
|
+
readonly metadata?: Metadata
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type Info<
|
|
128
|
+
Input extends ValueSchema<any> = ValueSchema<any>,
|
|
129
|
+
Output extends ValueSchema<any> | undefined = ValueSchema<any> | undefined,
|
|
130
|
+
CMInput extends ValueSchema<any> = Input,
|
|
131
|
+
CMOutput extends ValueSchema<any> | undefined = Output,
|
|
132
|
+
> = {
|
|
133
|
+
readonly name: string
|
|
134
|
+
readonly input: Input
|
|
135
|
+
readonly freeform?: Freeform
|
|
136
|
+
readonly description: string
|
|
137
|
+
readonly execute: (
|
|
138
|
+
input: InputValue<Input> | InputValue<CMInput>,
|
|
139
|
+
context: Context,
|
|
140
|
+
) => Effect.Effect<Result<Output | CMOutput>, Error>
|
|
141
|
+
readonly output?: Output
|
|
142
|
+
readonly options?: Options<CMInput, CMOutput>
|
|
143
|
+
}
|
package/src/tui-event.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
export * as TuiEvent from "./tui-event.js"
|
|
2
|
-
|
|
3
|
-
import { Effect, Schema } from "effect"
|
|
4
|
-
import { optional } from "./schema.js"
|
|
5
|
-
import { Event } from "./event.js"
|
|
6
|
-
import { PositiveInt } from "./schema.js"
|
|
7
|
-
import { SessionID } from "./session-id.js"
|
|
8
|
-
|
|
9
|
-
const DEFAULT_TOAST_DURATION = 5000
|
|
10
|
-
|
|
11
|
-
export const PromptAppend = Event.ephemeral({ type: "tui.prompt.append", schema: { text: Schema.String } })
|
|
12
|
-
|
|
13
|
-
export const CommandExecute = Event.ephemeral({
|
|
14
|
-
type: "tui.command.execute",
|
|
15
|
-
schema: {
|
|
16
|
-
command: Schema.Union([
|
|
17
|
-
Schema.Literals([
|
|
18
|
-
"session.list",
|
|
19
|
-
"session.new",
|
|
20
|
-
"session.interrupt",
|
|
21
|
-
"session.background",
|
|
22
|
-
"session.compact",
|
|
23
|
-
"session.page.up",
|
|
24
|
-
"session.page.down",
|
|
25
|
-
"session.line.up",
|
|
26
|
-
"session.line.down",
|
|
27
|
-
"session.half.page.up",
|
|
28
|
-
"session.half.page.down",
|
|
29
|
-
"session.first",
|
|
30
|
-
"session.last",
|
|
31
|
-
"prompt.clear",
|
|
32
|
-
"prompt.submit",
|
|
33
|
-
"agent.cycle",
|
|
34
|
-
]),
|
|
35
|
-
Schema.String,
|
|
36
|
-
]),
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
export const ToastShow = Event.ephemeral({
|
|
41
|
-
type: "tui.toast.show",
|
|
42
|
-
schema: {
|
|
43
|
-
title: optional(Schema.String),
|
|
44
|
-
message: Schema.String,
|
|
45
|
-
variant: Schema.Literals(["info", "success", "warning", "error"]),
|
|
46
|
-
duration: PositiveInt.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_TOAST_DURATION))).annotate({
|
|
47
|
-
description: "Duration in milliseconds",
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
export const SessionSelect = Event.ephemeral({
|
|
53
|
-
type: "tui.session.select",
|
|
54
|
-
schema: {
|
|
55
|
-
sessionID: SessionID.annotateKey({ description: "Session ID to navigate to" }),
|
|
56
|
-
},
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
export const Definitions = Event.inventory(PromptAppend, CommandExecute, ToastShow, SessionSelect)
|
|
1
|
+
export * as TuiEvent from "./tui-event.js"
|
|
2
|
+
|
|
3
|
+
import { Effect, Schema } from "effect"
|
|
4
|
+
import { optional } from "./schema.js"
|
|
5
|
+
import { Event } from "./event.js"
|
|
6
|
+
import { PositiveInt } from "./schema.js"
|
|
7
|
+
import { SessionID } from "./session-id.js"
|
|
8
|
+
|
|
9
|
+
const DEFAULT_TOAST_DURATION = 5000
|
|
10
|
+
|
|
11
|
+
export const PromptAppend = Event.ephemeral({ type: "tui.prompt.append", schema: { text: Schema.String } })
|
|
12
|
+
|
|
13
|
+
export const CommandExecute = Event.ephemeral({
|
|
14
|
+
type: "tui.command.execute",
|
|
15
|
+
schema: {
|
|
16
|
+
command: Schema.Union([
|
|
17
|
+
Schema.Literals([
|
|
18
|
+
"session.list",
|
|
19
|
+
"session.new",
|
|
20
|
+
"session.interrupt",
|
|
21
|
+
"session.background",
|
|
22
|
+
"session.compact",
|
|
23
|
+
"session.page.up",
|
|
24
|
+
"session.page.down",
|
|
25
|
+
"session.line.up",
|
|
26
|
+
"session.line.down",
|
|
27
|
+
"session.half.page.up",
|
|
28
|
+
"session.half.page.down",
|
|
29
|
+
"session.first",
|
|
30
|
+
"session.last",
|
|
31
|
+
"prompt.clear",
|
|
32
|
+
"prompt.submit",
|
|
33
|
+
"agent.cycle",
|
|
34
|
+
]),
|
|
35
|
+
Schema.String,
|
|
36
|
+
]),
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const ToastShow = Event.ephemeral({
|
|
41
|
+
type: "tui.toast.show",
|
|
42
|
+
schema: {
|
|
43
|
+
title: optional(Schema.String),
|
|
44
|
+
message: Schema.String,
|
|
45
|
+
variant: Schema.Literals(["info", "success", "warning", "error"]),
|
|
46
|
+
duration: PositiveInt.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_TOAST_DURATION))).annotate({
|
|
47
|
+
description: "Duration in milliseconds",
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export const SessionSelect = Event.ephemeral({
|
|
53
|
+
type: "tui.session.select",
|
|
54
|
+
schema: {
|
|
55
|
+
sessionID: SessionID.annotateKey({ description: "Session ID to navigate to" }),
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
export const Definitions = Event.inventory(PromptAppend, CommandExecute, ToastShow, SessionSelect)
|
package/src/usage-limits.ts
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
export * as UsageLimits from "./usage-limits.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { Model } from "./model.js"
|
|
5
|
-
import { Money } from "./money.js"
|
|
6
|
-
import { Provider } from "./provider.js"
|
|
7
|
-
import { optional } from "./schema.js"
|
|
8
|
-
|
|
9
|
-
const Percent = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 100 }))
|
|
10
|
-
const Instant = Schema.Finite.annotate({ description: "Milliseconds since the Unix epoch" })
|
|
11
|
-
|
|
12
|
-
/** One window of the OpenCode Go allowance. */
|
|
13
|
-
export interface Meter extends Schema.Schema.Type<typeof Meter> {}
|
|
14
|
-
export const Meter = Schema.Struct({
|
|
15
|
-
/** How much of the window's allowance is used. */
|
|
16
|
-
percent: Percent,
|
|
17
|
-
/** Go refuses requests until the window resets. */
|
|
18
|
-
limited: Schema.Boolean,
|
|
19
|
-
resetsAt: Instant,
|
|
20
|
-
}).annotate({ identifier: "UsageLimits.Meter" })
|
|
21
|
-
|
|
22
|
-
/** The OpenCode Go allowance of a workspace the member subscribes to Go in. */
|
|
23
|
-
export interface Go extends Schema.Schema.Type<typeof Go> {}
|
|
24
|
-
export const Go = Schema.Struct({
|
|
25
|
-
rolling: Meter,
|
|
26
|
-
weekly: Meter,
|
|
27
|
-
monthly: Meter,
|
|
28
|
-
}).annotate({ identifier: "UsageLimits.Go" })
|
|
29
|
-
|
|
30
|
-
/** A model a budget covers, by the IDs OpenCode knows it by. */
|
|
31
|
-
export interface BudgetModel extends Schema.Schema.Type<typeof BudgetModel> {}
|
|
32
|
-
export const BudgetModel = Schema.Struct({
|
|
33
|
-
providerID: Provider.ID,
|
|
34
|
-
modelID: Model.ID,
|
|
35
|
-
name: Schema.String,
|
|
36
|
-
/** What a per-model budget's member has spent on this model this month. */
|
|
37
|
-
spent: Money.USD.pipe(optional),
|
|
38
|
-
}).annotate({ identifier: "UsageLimits.BudgetModel" })
|
|
39
|
-
|
|
40
|
-
/** A monthly spend limit the OpenCode Console workspace sets on the member. */
|
|
41
|
-
export interface Budget extends Schema.Schema.Type<typeof Budget> {}
|
|
42
|
-
export const Budget = Schema.Struct({
|
|
43
|
-
id: Schema.String,
|
|
44
|
-
limit: Money.USD,
|
|
45
|
-
/** The member's spend this month, or the pooled spend of a combined budget; per model, the most on one model. */
|
|
46
|
-
spent: Money.USD,
|
|
47
|
-
/** `each` limits every member separately; `combined` pools everyone's spend against one limit. */
|
|
48
|
-
scope: Schema.Literals(["each", "combined"]),
|
|
49
|
-
/** `set` counts spend across the budget's models; `model` limits each model separately. */
|
|
50
|
-
per: Schema.Literals(["set", "model"]),
|
|
51
|
-
/** `all` covers every model and billable service; `models` covers only `models`. */
|
|
52
|
-
coverage: Schema.Literals(["all", "models"]),
|
|
53
|
-
models: Schema.Array(BudgetModel),
|
|
54
|
-
/** The vendors whose models the budget counts, by name; empty when it doesn't count by vendor. */
|
|
55
|
-
vendors: Schema.Array(Schema.String),
|
|
56
|
-
/** The input price per 1M tokens from which the budget counts a model, when it sets one. */
|
|
57
|
-
inputPriceAtLeast: Money.USDPerMillionTokens.pipe(optional),
|
|
58
|
-
/** The budget counts models picked one by one, rather than by vendor or price. */
|
|
59
|
-
picked: Schema.Boolean,
|
|
60
|
-
/** Everyone in the workspace pools spend against it, so reaching it pauses model use for all of them. */
|
|
61
|
-
shared: Schema.Boolean,
|
|
62
|
-
resetsAt: Instant,
|
|
63
|
-
}).annotate({ identifier: "UsageLimits.Budget" })
|
|
64
|
-
|
|
65
|
-
/** The usage limits of the OpenCode Console workspace a location is signed in to. */
|
|
66
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
67
|
-
export const Info = Schema.Struct({
|
|
68
|
-
workspace: Schema.Struct({
|
|
69
|
-
id: Schema.String,
|
|
70
|
-
name: Schema.String.pipe(optional),
|
|
71
|
-
/** The member's usage page in OpenCode Console. */
|
|
72
|
-
usageURL: Schema.String,
|
|
73
|
-
}),
|
|
74
|
-
go: Go.pipe(optional),
|
|
75
|
-
budgets: Schema.Array(Budget),
|
|
76
|
-
}).annotate({ identifier: "UsageLimits.Info" })
|
|
1
|
+
export * as UsageLimits from "./usage-limits.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { Model } from "./model.js"
|
|
5
|
+
import { Money } from "./money.js"
|
|
6
|
+
import { Provider } from "./provider.js"
|
|
7
|
+
import { optional } from "./schema.js"
|
|
8
|
+
|
|
9
|
+
const Percent = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 100 }))
|
|
10
|
+
const Instant = Schema.Finite.annotate({ description: "Milliseconds since the Unix epoch" })
|
|
11
|
+
|
|
12
|
+
/** One window of the OpenCode Go allowance. */
|
|
13
|
+
export interface Meter extends Schema.Schema.Type<typeof Meter> {}
|
|
14
|
+
export const Meter = Schema.Struct({
|
|
15
|
+
/** How much of the window's allowance is used. */
|
|
16
|
+
percent: Percent,
|
|
17
|
+
/** Go refuses requests until the window resets. */
|
|
18
|
+
limited: Schema.Boolean,
|
|
19
|
+
resetsAt: Instant,
|
|
20
|
+
}).annotate({ identifier: "UsageLimits.Meter" })
|
|
21
|
+
|
|
22
|
+
/** The OpenCode Go allowance of a workspace the member subscribes to Go in. */
|
|
23
|
+
export interface Go extends Schema.Schema.Type<typeof Go> {}
|
|
24
|
+
export const Go = Schema.Struct({
|
|
25
|
+
rolling: Meter,
|
|
26
|
+
weekly: Meter,
|
|
27
|
+
monthly: Meter,
|
|
28
|
+
}).annotate({ identifier: "UsageLimits.Go" })
|
|
29
|
+
|
|
30
|
+
/** A model a budget covers, by the IDs OpenCode knows it by. */
|
|
31
|
+
export interface BudgetModel extends Schema.Schema.Type<typeof BudgetModel> {}
|
|
32
|
+
export const BudgetModel = Schema.Struct({
|
|
33
|
+
providerID: Provider.ID,
|
|
34
|
+
modelID: Model.ID,
|
|
35
|
+
name: Schema.String,
|
|
36
|
+
/** What a per-model budget's member has spent on this model this month. */
|
|
37
|
+
spent: Money.USD.pipe(optional),
|
|
38
|
+
}).annotate({ identifier: "UsageLimits.BudgetModel" })
|
|
39
|
+
|
|
40
|
+
/** A monthly spend limit the OpenCode Console workspace sets on the member. */
|
|
41
|
+
export interface Budget extends Schema.Schema.Type<typeof Budget> {}
|
|
42
|
+
export const Budget = Schema.Struct({
|
|
43
|
+
id: Schema.String,
|
|
44
|
+
limit: Money.USD,
|
|
45
|
+
/** The member's spend this month, or the pooled spend of a combined budget; per model, the most on one model. */
|
|
46
|
+
spent: Money.USD,
|
|
47
|
+
/** `each` limits every member separately; `combined` pools everyone's spend against one limit. */
|
|
48
|
+
scope: Schema.Literals(["each", "combined"]),
|
|
49
|
+
/** `set` counts spend across the budget's models; `model` limits each model separately. */
|
|
50
|
+
per: Schema.Literals(["set", "model"]),
|
|
51
|
+
/** `all` covers every model and billable service; `models` covers only `models`. */
|
|
52
|
+
coverage: Schema.Literals(["all", "models"]),
|
|
53
|
+
models: Schema.Array(BudgetModel),
|
|
54
|
+
/** The vendors whose models the budget counts, by name; empty when it doesn't count by vendor. */
|
|
55
|
+
vendors: Schema.Array(Schema.String),
|
|
56
|
+
/** The input price per 1M tokens from which the budget counts a model, when it sets one. */
|
|
57
|
+
inputPriceAtLeast: Money.USDPerMillionTokens.pipe(optional),
|
|
58
|
+
/** The budget counts models picked one by one, rather than by vendor or price. */
|
|
59
|
+
picked: Schema.Boolean,
|
|
60
|
+
/** Everyone in the workspace pools spend against it, so reaching it pauses model use for all of them. */
|
|
61
|
+
shared: Schema.Boolean,
|
|
62
|
+
resetsAt: Instant,
|
|
63
|
+
}).annotate({ identifier: "UsageLimits.Budget" })
|
|
64
|
+
|
|
65
|
+
/** The usage limits of the OpenCode Console workspace a location is signed in to. */
|
|
66
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
67
|
+
export const Info = Schema.Struct({
|
|
68
|
+
workspace: Schema.Struct({
|
|
69
|
+
id: Schema.String,
|
|
70
|
+
name: Schema.String.pipe(optional),
|
|
71
|
+
/** The member's usage page in OpenCode Console. */
|
|
72
|
+
usageURL: Schema.String,
|
|
73
|
+
}),
|
|
74
|
+
go: Go.pipe(optional),
|
|
75
|
+
budgets: Schema.Array(Budget),
|
|
76
|
+
}).annotate({ identifier: "UsageLimits.Info" })
|
package/src/v1/filesystem.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * as FileSystemV1 from "./filesystem.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { ephemeral, inventory } from "../event.js"
|
|
5
|
-
|
|
6
|
-
const Edited = ephemeral({
|
|
7
|
-
type: "file.edited",
|
|
8
|
-
schema: { file: Schema.String },
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
export const Event = { Edited, Definitions: inventory(Edited) }
|
|
1
|
+
export * as FileSystemV1 from "./filesystem.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { ephemeral, inventory } from "../event.js"
|
|
5
|
+
|
|
6
|
+
const Edited = ephemeral({
|
|
7
|
+
type: "file.edited",
|
|
8
|
+
schema: { file: Schema.String },
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export const Event = { Edited, Definitions: inventory(Edited) }
|
package/src/v1/legacy-event.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * as LegacyEventV1 from "./legacy-event.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { ephemeral, inventory } from "../event.js"
|
|
5
|
-
import { SessionID } from "../session-id.js"
|
|
6
|
-
import { SessionV1 } from "./session.js"
|
|
7
|
-
|
|
8
|
-
export const CommandExecuted = ephemeral({
|
|
9
|
-
type: "command.executed",
|
|
10
|
-
schema: {
|
|
11
|
-
name: Schema.String,
|
|
12
|
-
sessionID: SessionID,
|
|
13
|
-
arguments: Schema.String,
|
|
14
|
-
messageID: SessionV1.MessageID,
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export const Definitions = inventory(CommandExecuted)
|
|
1
|
+
export * as LegacyEventV1 from "./legacy-event.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { ephemeral, inventory } from "../event.js"
|
|
5
|
+
import { SessionID } from "../session-id.js"
|
|
6
|
+
import { SessionV1 } from "./session.js"
|
|
7
|
+
|
|
8
|
+
export const CommandExecuted = ephemeral({
|
|
9
|
+
type: "command.executed",
|
|
10
|
+
schema: {
|
|
11
|
+
name: Schema.String,
|
|
12
|
+
sessionID: SessionID,
|
|
13
|
+
arguments: Schema.String,
|
|
14
|
+
messageID: SessionV1.MessageID,
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export const Definitions = inventory(CommandExecuted)
|