@zyro-sec/schema 1.0.2 → 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 +1 -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/goal.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export * as Goal from "./goal.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { Rpc } from "./rpc.js"
|
|
5
|
-
import { optional } from "./schema.js"
|
|
6
|
-
|
|
7
|
-
export const Status = Schema.Literals(["active", "paused", "complete"])
|
|
8
|
-
export type Status = typeof Status.Type
|
|
9
|
-
|
|
10
|
-
export interface State extends Schema.Schema.Type<typeof State> {}
|
|
11
|
-
export const State = Schema.Struct({
|
|
12
|
-
id: Schema.String,
|
|
13
|
-
objective: Schema.String,
|
|
14
|
-
status: Status,
|
|
15
|
-
/** Why the goal last changed: the reviewer's reason, or what paused it. */
|
|
16
|
-
reason: optional(Schema.String),
|
|
17
|
-
/** Continuations sent since the goal was set or last resumed. */
|
|
18
|
-
rounds: Schema.Number,
|
|
19
|
-
/** A backstop for loops that stall detection misses. */
|
|
20
|
-
maxRounds: Schema.Number,
|
|
21
|
-
/** Rounds in a row without progress: no tool calls, or the same reason as the round before. */
|
|
22
|
-
stalls: optional(Schema.Number),
|
|
23
|
-
/** The server process that armed the goal. */
|
|
24
|
-
boot: Schema.String,
|
|
25
|
-
updatedAt: Schema.Number,
|
|
26
|
-
}).annotate({ identifier: "Goal.State" })
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The `/goal` plugin's RPC. Clients read a Session's goal with `get` and keep it current from `changed`, which the
|
|
30
|
-
* plugin publishes in the Session's Location on every write. A Session's goal is its own: children and forks start
|
|
31
|
-
* without one. The schemas are Standard Schemas too, so Promise clients can call it.
|
|
32
|
-
*/
|
|
33
|
-
export const Definition = Rpc.define({
|
|
34
|
-
id: "opencode.goal",
|
|
35
|
-
methods: {
|
|
36
|
-
get: {
|
|
37
|
-
input: Schema.toStandardSchemaV1(Schema.Struct({ sessionID: Schema.String })),
|
|
38
|
-
output: Schema.toStandardSchemaV1(Schema.NullOr(State)),
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
events: {
|
|
42
|
-
changed: {
|
|
43
|
-
schema: Schema.toStandardSchemaV1(Schema.Struct({ sessionID: Schema.String, goal: Schema.NullOr(State) })),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
})
|
|
1
|
+
export * as Goal from "./goal.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { Rpc } from "./rpc.js"
|
|
5
|
+
import { optional } from "./schema.js"
|
|
6
|
+
|
|
7
|
+
export const Status = Schema.Literals(["active", "paused", "complete"])
|
|
8
|
+
export type Status = typeof Status.Type
|
|
9
|
+
|
|
10
|
+
export interface State extends Schema.Schema.Type<typeof State> {}
|
|
11
|
+
export const State = Schema.Struct({
|
|
12
|
+
id: Schema.String,
|
|
13
|
+
objective: Schema.String,
|
|
14
|
+
status: Status,
|
|
15
|
+
/** Why the goal last changed: the reviewer's reason, or what paused it. */
|
|
16
|
+
reason: optional(Schema.String),
|
|
17
|
+
/** Continuations sent since the goal was set or last resumed. */
|
|
18
|
+
rounds: Schema.Number,
|
|
19
|
+
/** A backstop for loops that stall detection misses. */
|
|
20
|
+
maxRounds: Schema.Number,
|
|
21
|
+
/** Rounds in a row without progress: no tool calls, or the same reason as the round before. */
|
|
22
|
+
stalls: optional(Schema.Number),
|
|
23
|
+
/** The server process that armed the goal. */
|
|
24
|
+
boot: Schema.String,
|
|
25
|
+
updatedAt: Schema.Number,
|
|
26
|
+
}).annotate({ identifier: "Goal.State" })
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The `/goal` plugin's RPC. Clients read a Session's goal with `get` and keep it current from `changed`, which the
|
|
30
|
+
* plugin publishes in the Session's Location on every write. A Session's goal is its own: children and forks start
|
|
31
|
+
* without one. The schemas are Standard Schemas too, so Promise clients can call it.
|
|
32
|
+
*/
|
|
33
|
+
export const Definition = Rpc.define({
|
|
34
|
+
id: "opencode.goal",
|
|
35
|
+
methods: {
|
|
36
|
+
get: {
|
|
37
|
+
input: Schema.toStandardSchemaV1(Schema.Struct({ sessionID: Schema.String })),
|
|
38
|
+
output: Schema.toStandardSchemaV1(Schema.NullOr(State)),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
events: {
|
|
42
|
+
changed: {
|
|
43
|
+
schema: Schema.toStandardSchemaV1(Schema.Struct({ sessionID: Schema.String, goal: Schema.NullOr(State) })),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
})
|
package/src/identifier.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
export * as Identifier from "./identifier.js"
|
|
2
|
-
|
|
3
|
-
const length = 26
|
|
4
|
-
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
5
|
-
let lastTimestamp = 0
|
|
6
|
-
let counter = 0
|
|
7
|
-
|
|
8
|
-
export function ascending() {
|
|
9
|
-
return create(false)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function descending() {
|
|
13
|
-
return create(true)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function create(descending: boolean, timestamp = Date.now()) {
|
|
17
|
-
if (timestamp !== lastTimestamp) {
|
|
18
|
-
lastTimestamp = timestamp
|
|
19
|
-
counter = 0
|
|
20
|
-
}
|
|
21
|
-
counter++
|
|
22
|
-
|
|
23
|
-
const current = BigInt(timestamp) * 0x1000n + BigInt(counter)
|
|
24
|
-
const value = descending ? ~current : current
|
|
25
|
-
const time = Array.from({ length: 6 }, (_, index) =>
|
|
26
|
-
Number((value >> BigInt(40 - 8 * index)) & 0xffn)
|
|
27
|
-
.toString(16)
|
|
28
|
-
.padStart(2, "0"),
|
|
29
|
-
).join("")
|
|
30
|
-
const bytes = crypto.getRandomValues(new Uint8Array(length - 12))
|
|
31
|
-
return time + Array.from(bytes, (byte) => chars[byte % 62]).join("")
|
|
32
|
-
}
|
|
1
|
+
export * as Identifier from "./identifier.js"
|
|
2
|
+
|
|
3
|
+
const length = 26
|
|
4
|
+
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
5
|
+
let lastTimestamp = 0
|
|
6
|
+
let counter = 0
|
|
7
|
+
|
|
8
|
+
export function ascending() {
|
|
9
|
+
return create(false)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function descending() {
|
|
13
|
+
return create(true)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function create(descending: boolean, timestamp = Date.now()) {
|
|
17
|
+
if (timestamp !== lastTimestamp) {
|
|
18
|
+
lastTimestamp = timestamp
|
|
19
|
+
counter = 0
|
|
20
|
+
}
|
|
21
|
+
counter++
|
|
22
|
+
|
|
23
|
+
const current = BigInt(timestamp) * 0x1000n + BigInt(counter)
|
|
24
|
+
const value = descending ? ~current : current
|
|
25
|
+
const time = Array.from({ length: 6 }, (_, index) =>
|
|
26
|
+
Number((value >> BigInt(40 - 8 * index)) & 0xffn)
|
|
27
|
+
.toString(16)
|
|
28
|
+
.padStart(2, "0"),
|
|
29
|
+
).join("")
|
|
30
|
+
const bytes = crypto.getRandomValues(new Uint8Array(length - 12))
|
|
31
|
+
return time + Array.from(bytes, (byte) => chars[byte % 62]).join("")
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
export { Agent } from "./agent.js"
|
|
2
|
-
export { Artifact } from "./artifact.js"
|
|
3
|
-
export { Command } from "./command.js"
|
|
4
|
-
export { Config } from "./config.js"
|
|
5
|
-
export { Connection } from "./connection.js"
|
|
6
|
-
export { Credential } from "./credential.js"
|
|
7
|
-
export { Event } from "./event.js"
|
|
8
|
-
export { FileSystem } from "./filesystem.js"
|
|
9
|
-
export { Form } from "./form.js"
|
|
10
|
-
export { Integration } from "./integration.js"
|
|
11
|
-
export { LLM } from "./llm.js"
|
|
12
|
-
export { Location } from "./location.js"
|
|
13
|
-
export { Mcp } from "./mcp.js"
|
|
14
|
-
export { Model } from "./model.js"
|
|
15
|
-
export { Money } from "./money.js"
|
|
16
|
-
export { Permission } from "./permission.js"
|
|
17
|
-
export { PermissionSaved } from "./permission-saved.js"
|
|
18
|
-
export { Project } from "./project.js"
|
|
19
|
-
export { Worktree } from "./worktree.js"
|
|
20
|
-
export { Provider } from "./provider.js"
|
|
21
|
-
export { Reference } from "./reference.js"
|
|
22
|
-
export { Rpc } from "./rpc.js"
|
|
23
|
-
export { WebSearch } from "./websearch.js"
|
|
24
|
-
export { Session } from "./session.js"
|
|
25
|
-
export { Vcs } from "./vcs.js"
|
|
26
|
-
export { SessionInbox } from "./session-inbox.js"
|
|
27
|
-
export { SessionError } from "./session-error.js"
|
|
28
|
-
export { SessionMessage } from "./session-message.js"
|
|
29
|
-
export { SessionStats } from "./session-stats.js"
|
|
30
|
-
export { SessionTransfer } from "./session-transfer.js"
|
|
31
|
-
export { Snapshot } from "./snapshot.js"
|
|
32
|
-
export { Shell } from "./shell.js"
|
|
33
|
-
export { Skill } from "./skill.js"
|
|
34
|
-
export { TokenUsage } from "./token-usage.js"
|
|
35
|
-
export { Pty } from "./pty.js"
|
|
36
|
-
export { PersistentPty } from "./persistent-pty.js"
|
|
37
|
-
export { PtyTicket } from "./pty-ticket.js"
|
|
38
|
-
export { Question } from "./question.js"
|
|
39
|
-
export { Workspace } from "./workspace.js"
|
|
40
|
-
export {
|
|
41
|
-
Prompt,
|
|
42
|
-
PromptMention,
|
|
43
|
-
FileSource,
|
|
44
|
-
FileAttachment,
|
|
45
|
-
MediaRef,
|
|
46
|
-
MediaFileAttachment,
|
|
47
|
-
Attachment,
|
|
48
|
-
AgentAttachment,
|
|
49
|
-
} from "./prompt.js"
|
|
50
|
-
export { PromptInput } from "./prompt-input.js"
|
|
51
|
-
export * from "./schema.js"
|
|
1
|
+
export { Agent } from "./agent.js"
|
|
2
|
+
export { Artifact } from "./artifact.js"
|
|
3
|
+
export { Command } from "./command.js"
|
|
4
|
+
export { Config } from "./config.js"
|
|
5
|
+
export { Connection } from "./connection.js"
|
|
6
|
+
export { Credential } from "./credential.js"
|
|
7
|
+
export { Event } from "./event.js"
|
|
8
|
+
export { FileSystem } from "./filesystem.js"
|
|
9
|
+
export { Form } from "./form.js"
|
|
10
|
+
export { Integration } from "./integration.js"
|
|
11
|
+
export { LLM } from "./llm.js"
|
|
12
|
+
export { Location } from "./location.js"
|
|
13
|
+
export { Mcp } from "./mcp.js"
|
|
14
|
+
export { Model } from "./model.js"
|
|
15
|
+
export { Money } from "./money.js"
|
|
16
|
+
export { Permission } from "./permission.js"
|
|
17
|
+
export { PermissionSaved } from "./permission-saved.js"
|
|
18
|
+
export { Project } from "./project.js"
|
|
19
|
+
export { Worktree } from "./worktree.js"
|
|
20
|
+
export { Provider } from "./provider.js"
|
|
21
|
+
export { Reference } from "./reference.js"
|
|
22
|
+
export { Rpc } from "./rpc.js"
|
|
23
|
+
export { WebSearch } from "./websearch.js"
|
|
24
|
+
export { Session } from "./session.js"
|
|
25
|
+
export { Vcs } from "./vcs.js"
|
|
26
|
+
export { SessionInbox } from "./session-inbox.js"
|
|
27
|
+
export { SessionError } from "./session-error.js"
|
|
28
|
+
export { SessionMessage } from "./session-message.js"
|
|
29
|
+
export { SessionStats } from "./session-stats.js"
|
|
30
|
+
export { SessionTransfer } from "./session-transfer.js"
|
|
31
|
+
export { Snapshot } from "./snapshot.js"
|
|
32
|
+
export { Shell } from "./shell.js"
|
|
33
|
+
export { Skill } from "./skill.js"
|
|
34
|
+
export { TokenUsage } from "./token-usage.js"
|
|
35
|
+
export { Pty } from "./pty.js"
|
|
36
|
+
export { PersistentPty } from "./persistent-pty.js"
|
|
37
|
+
export { PtyTicket } from "./pty-ticket.js"
|
|
38
|
+
export { Question } from "./question.js"
|
|
39
|
+
export { Workspace } from "./workspace.js"
|
|
40
|
+
export {
|
|
41
|
+
Prompt,
|
|
42
|
+
PromptMention,
|
|
43
|
+
FileSource,
|
|
44
|
+
FileAttachment,
|
|
45
|
+
MediaRef,
|
|
46
|
+
MediaFileAttachment,
|
|
47
|
+
Attachment,
|
|
48
|
+
AgentAttachment,
|
|
49
|
+
} from "./prompt.js"
|
|
50
|
+
export { PromptInput } from "./prompt-input.js"
|
|
51
|
+
export * from "./schema.js"
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export * as InstallationEvent from "./installation-event.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { Event } from "./event.js"
|
|
5
|
-
|
|
6
|
-
export const Updated = Event.ephemeral({
|
|
7
|
-
type: "installation.updated",
|
|
8
|
-
schema: {
|
|
9
|
-
version: Schema.String,
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export const UpdateAvailable = Event.ephemeral({
|
|
14
|
-
type: "installation.update-available",
|
|
15
|
-
schema: {
|
|
16
|
-
version: Schema.String,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
export const Definitions = Event.inventory(Updated, UpdateAvailable)
|
|
1
|
+
export * as InstallationEvent from "./installation-event.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { Event } from "./event.js"
|
|
5
|
+
|
|
6
|
+
export const Updated = Event.ephemeral({
|
|
7
|
+
type: "installation.updated",
|
|
8
|
+
schema: {
|
|
9
|
+
version: Schema.String,
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const UpdateAvailable = Event.ephemeral({
|
|
14
|
+
type: "installation.update-available",
|
|
15
|
+
schema: {
|
|
16
|
+
version: Schema.String,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const Definitions = Event.inventory(Updated, UpdateAvailable)
|
package/src/instruction-entry.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
export * as InstructionEntry from "./instruction-entry.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Slash-free client-facing key for one API-managed instruction entry. The server
|
|
7
|
-
* derives the namespaced Instructions key as `api/<key>`, keeping the
|
|
8
|
-
* `api/*` namespace enforced by construction.
|
|
9
|
-
*/
|
|
10
|
-
export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({
|
|
11
|
-
identifier: "InstructionEntry.Key",
|
|
12
|
-
description: "Instruction entry key (lowercase alphanumerics plus . _ -)",
|
|
13
|
-
})
|
|
14
|
-
export type Key = typeof Key.Type
|
|
15
|
-
|
|
16
|
-
export const Info = Schema.Struct({
|
|
17
|
-
key: Key,
|
|
18
|
-
value: Schema.Json.annotate({ description: "JSON value attached to the session's instructions" }),
|
|
19
|
-
}).annotate({ identifier: "InstructionEntry.Info" })
|
|
20
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
21
|
-
|
|
22
|
-
export const Snapshot = Schema.Array(
|
|
23
|
-
Schema.Struct({
|
|
24
|
-
...Info.fields,
|
|
25
|
-
removed: Schema.Boolean,
|
|
26
|
-
}),
|
|
27
|
-
).annotate({ identifier: "InstructionEntry.Snapshot" })
|
|
28
|
-
export type Snapshot = typeof Snapshot.Type
|
|
29
|
-
|
|
30
|
-
export const MaxValueBytes = 256 * 1024
|
|
31
|
-
|
|
32
|
-
export class ValueTooLargeError extends Schema.TaggedError<ValueTooLargeError>()(
|
|
33
|
-
"InstructionEntryValueTooLargeError",
|
|
34
|
-
{
|
|
35
|
-
actualBytes: Schema.Int,
|
|
36
|
-
maxBytes: Schema.Int,
|
|
37
|
-
message: Schema.String,
|
|
38
|
-
},
|
|
39
|
-
{ httpApiStatus: 413 },
|
|
40
|
-
) {}
|
|
1
|
+
export * as InstructionEntry from "./instruction-entry.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Slash-free client-facing key for one API-managed instruction entry. The server
|
|
7
|
+
* derives the namespaced Instructions key as `api/<key>`, keeping the
|
|
8
|
+
* `api/*` namespace enforced by construction.
|
|
9
|
+
*/
|
|
10
|
+
export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({
|
|
11
|
+
identifier: "InstructionEntry.Key",
|
|
12
|
+
description: "Instruction entry key (lowercase alphanumerics plus . _ -)",
|
|
13
|
+
})
|
|
14
|
+
export type Key = typeof Key.Type
|
|
15
|
+
|
|
16
|
+
export const Info = Schema.Struct({
|
|
17
|
+
key: Key,
|
|
18
|
+
value: Schema.Json.annotate({ description: "JSON value attached to the session's instructions" }),
|
|
19
|
+
}).annotate({ identifier: "InstructionEntry.Info" })
|
|
20
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
21
|
+
|
|
22
|
+
export const Snapshot = Schema.Array(
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
...Info.fields,
|
|
25
|
+
removed: Schema.Boolean,
|
|
26
|
+
}),
|
|
27
|
+
).annotate({ identifier: "InstructionEntry.Snapshot" })
|
|
28
|
+
export type Snapshot = typeof Snapshot.Type
|
|
29
|
+
|
|
30
|
+
export const MaxValueBytes = 256 * 1024
|
|
31
|
+
|
|
32
|
+
export class ValueTooLargeError extends Schema.TaggedError<ValueTooLargeError>()(
|
|
33
|
+
"InstructionEntryValueTooLargeError",
|
|
34
|
+
{
|
|
35
|
+
actualBytes: Schema.Int,
|
|
36
|
+
maxBytes: Schema.Int,
|
|
37
|
+
message: Schema.String,
|
|
38
|
+
},
|
|
39
|
+
{ httpApiStatus: 413 },
|
|
40
|
+
) {}
|
package/src/instruction.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * as Instruction from "./instruction.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
|
|
5
|
-
export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(
|
|
6
|
-
Schema.brand("Instruction.Key"),
|
|
7
|
-
Schema.annotate({ identifier: "Instruction.Key" }),
|
|
8
|
-
)
|
|
9
|
-
export type Key = typeof Key.Type
|
|
10
|
-
|
|
11
|
-
export const Hash = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/u)).pipe(
|
|
12
|
-
Schema.brand("Instruction.Hash"),
|
|
13
|
-
Schema.annotate({ identifier: "Instruction.Hash" }),
|
|
14
|
-
)
|
|
15
|
-
export type Hash = typeof Hash.Type
|
|
16
|
-
|
|
17
|
-
export const Values = Schema.Record(Key, Hash)
|
|
18
|
-
export type Values = Readonly<Record<string, Hash>>
|
|
19
|
-
|
|
20
|
-
export const Removed = Schema.Literal("removed")
|
|
21
|
-
export type Removed = typeof Removed.Type
|
|
22
|
-
export const removed = Removed.make("removed")
|
|
23
|
-
|
|
24
|
-
export const Delta = Schema.Record(Schema.String, Schema.Union([Hash, Removed]))
|
|
25
|
-
export type Delta = typeof Delta.Type
|
|
1
|
+
export * as Instruction from "./instruction.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
|
|
5
|
+
export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(
|
|
6
|
+
Schema.brand("Instruction.Key"),
|
|
7
|
+
Schema.annotate({ identifier: "Instruction.Key" }),
|
|
8
|
+
)
|
|
9
|
+
export type Key = typeof Key.Type
|
|
10
|
+
|
|
11
|
+
export const Hash = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/u)).pipe(
|
|
12
|
+
Schema.brand("Instruction.Hash"),
|
|
13
|
+
Schema.annotate({ identifier: "Instruction.Hash" }),
|
|
14
|
+
)
|
|
15
|
+
export type Hash = typeof Hash.Type
|
|
16
|
+
|
|
17
|
+
export const Values = Schema.Record(Key, Hash)
|
|
18
|
+
export type Values = Readonly<Record<string, Hash>>
|
|
19
|
+
|
|
20
|
+
export const Removed = Schema.Literal("removed")
|
|
21
|
+
export type Removed = typeof Removed.Type
|
|
22
|
+
export const removed = Removed.make("removed")
|
|
23
|
+
|
|
24
|
+
export const Delta = Schema.Record(Schema.String, Schema.Union([Hash, Removed]))
|
|
25
|
+
export type Delta = typeof Delta.Type
|
package/src/integration-id.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Schema } from "effect"
|
|
2
|
-
|
|
3
|
-
export const IntegrationID = Schema.String.pipe(
|
|
4
|
-
Schema.brand("Integration.ID"),
|
|
5
|
-
Schema.annotate({ identifier: "Integration.ID" }),
|
|
6
|
-
)
|
|
7
|
-
export type IntegrationID = typeof IntegrationID.Type
|
|
8
|
-
|
|
9
|
-
export const IntegrationMethodID = Schema.String.pipe(
|
|
10
|
-
Schema.brand("Integration.MethodID"),
|
|
11
|
-
Schema.annotate({ identifier: "Integration.MethodID" }),
|
|
12
|
-
)
|
|
13
|
-
export type IntegrationMethodID = typeof IntegrationMethodID.Type
|
|
1
|
+
import { Schema } from "effect"
|
|
2
|
+
|
|
3
|
+
export const IntegrationID = Schema.String.pipe(
|
|
4
|
+
Schema.brand("Integration.ID"),
|
|
5
|
+
Schema.annotate({ identifier: "Integration.ID" }),
|
|
6
|
+
)
|
|
7
|
+
export type IntegrationID = typeof IntegrationID.Type
|
|
8
|
+
|
|
9
|
+
export const IntegrationMethodID = Schema.String.pipe(
|
|
10
|
+
Schema.brand("Integration.MethodID"),
|
|
11
|
+
Schema.annotate({ identifier: "Integration.MethodID" }),
|
|
12
|
+
)
|
|
13
|
+
export type IntegrationMethodID = typeof IntegrationMethodID.Type
|