@opencode/schema 0.0.0-dev-256 → 0.0.0-dev-271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/experimental.d.ts +13 -5
- package/dist/config/policy.d.ts +18 -3
- package/dist/config/policy.js +41 -3
- package/dist/config.d.ts +13 -5
- package/dist/schedule.d.ts +87 -9
- package/dist/schedule.js +46 -13
- package/package.json +1 -1
|
@@ -45,15 +45,23 @@ declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
|
45
45
|
readonly schedules: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
46
46
|
readonly subagent_depth: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
47
47
|
readonly location_idle_timeout: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.DurationFromString, Schema.Literal<false>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.DurationFromString, Schema.Literal<false>]>>, never, never>;
|
|
48
|
-
readonly policies: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
49
|
-
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.use"]>;
|
|
48
|
+
readonly policies: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.decodeTo<Schema.toType<Schema.Struct<{
|
|
49
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
50
50
|
readonly resource: Schema.String;
|
|
51
51
|
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
52
|
-
}
|
|
53
|
-
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.use"]>;
|
|
52
|
+
}>>, Schema.Struct<{
|
|
53
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
54
54
|
readonly resource: Schema.String;
|
|
55
55
|
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
56
|
-
}
|
|
56
|
+
}>, never, never>>>>, Schema.optionalKey<Schema.$Array<Schema.decodeTo<Schema.toType<Schema.Struct<{
|
|
57
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
58
|
+
readonly resource: Schema.String;
|
|
59
|
+
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
60
|
+
}>>, Schema.Struct<{
|
|
61
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
62
|
+
readonly resource: Schema.String;
|
|
63
|
+
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
64
|
+
}>, never, never>>>, never, never>;
|
|
57
65
|
}>, {}>;
|
|
58
66
|
export declare class Info extends Info_base {
|
|
59
67
|
}
|
package/dist/config/policy.d.ts
CHANGED
|
@@ -2,9 +2,24 @@ export * as ConfigPolicy from "./policy.js";
|
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
export declare const Effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
4
4
|
export type Effect = typeof Effect.Type;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* - `provider.use`: resource is a provider ID.
|
|
7
|
+
* - `tool.use`: resource is `<tool>:<input>`, such as `shell:git *`.
|
|
8
|
+
* - `integration.connect`: resource is an integration ID; controls which integrations can be listed and connected.
|
|
9
|
+
* - `integration.use`: resource is `<integration>#<account>`, or the bare integration ID when the providers, models,
|
|
10
|
+
* web search, MCP servers, or config an integration supplies come from no account (env keys, local config, the
|
|
11
|
+
* signed-out free tier).
|
|
12
|
+
* - `mcp.use`, `skill.use`, `plugin.use`: resource is an MCP server name, skill ID, or plugin target.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
15
|
+
export type Action = typeof Action.Type;
|
|
16
|
+
export declare const Info: Schema.decodeTo<Schema.toType<Schema.Struct<{
|
|
17
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
7
18
|
readonly resource: Schema.String;
|
|
8
19
|
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
9
|
-
}
|
|
20
|
+
}>>, Schema.Struct<{
|
|
21
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
22
|
+
readonly resource: Schema.String;
|
|
23
|
+
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
24
|
+
}>, never, never>;
|
|
10
25
|
export type Info = typeof Info.Type;
|
package/dist/config/policy.js
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
export * as ConfigPolicy from "./policy.js";
|
|
2
|
-
import { Schema } from "effect";
|
|
2
|
+
import { Schema, SchemaGetter } from "effect";
|
|
3
3
|
export const Effect = Schema.Literals(["allow", "deny"]);
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* - `provider.use`: resource is a provider ID.
|
|
6
|
+
* - `tool.use`: resource is `<tool>:<input>`, such as `shell:git *`.
|
|
7
|
+
* - `integration.connect`: resource is an integration ID; controls which integrations can be listed and connected.
|
|
8
|
+
* - `integration.use`: resource is `<integration>#<account>`, or the bare integration ID when the providers, models,
|
|
9
|
+
* web search, MCP servers, or config an integration supplies come from no account (env keys, local config, the
|
|
10
|
+
* signed-out free tier).
|
|
11
|
+
* - `mcp.use`, `skill.use`, `plugin.use`: resource is an MCP server name, skill ID, or plugin target.
|
|
12
|
+
*/
|
|
13
|
+
export const Action = Schema.Literals([
|
|
14
|
+
"provider.use",
|
|
15
|
+
"tool.use",
|
|
16
|
+
"integration.connect",
|
|
17
|
+
"integration.use",
|
|
18
|
+
"mcp.use",
|
|
19
|
+
"skill.use",
|
|
20
|
+
"plugin.use",
|
|
21
|
+
]);
|
|
22
|
+
const Statement = Schema.Struct({
|
|
23
|
+
action: Action,
|
|
6
24
|
resource: Schema.String,
|
|
7
25
|
effect: Effect,
|
|
8
26
|
});
|
|
27
|
+
// Before `mcp.use`, `skill.use` and `plugin.use` existed, `integration.use` covered them with a resource prefix.
|
|
28
|
+
// Every policy source decodes through this schema, so this is the only place that knows the legacy form. Only prefixed
|
|
29
|
+
// resources convert: a bare `integration.use` `*` keeps its action and now covers providers and accounts.
|
|
30
|
+
const legacy = new Map([
|
|
31
|
+
["mcp", "mcp.use"],
|
|
32
|
+
["skill", "skill.use"],
|
|
33
|
+
["plugin", "plugin.use"],
|
|
34
|
+
]);
|
|
35
|
+
export const Info = Statement.pipe(Schema.decodeTo(Schema.toType(Statement), {
|
|
36
|
+
decode: SchemaGetter.transform((policy) => {
|
|
37
|
+
if (policy.action !== "integration.use")
|
|
38
|
+
return policy;
|
|
39
|
+
const separator = policy.resource.indexOf(":");
|
|
40
|
+
const action = separator === -1 ? undefined : legacy.get(policy.resource.slice(0, separator));
|
|
41
|
+
if (!action)
|
|
42
|
+
return policy;
|
|
43
|
+
return { ...policy, action, resource: policy.resource.slice(separator + 1) };
|
|
44
|
+
}),
|
|
45
|
+
encode: SchemaGetter.passthrough(),
|
|
46
|
+
}));
|
package/dist/config.d.ts
CHANGED
|
@@ -54,15 +54,23 @@ declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
|
54
54
|
readonly resource: Schema.String;
|
|
55
55
|
readonly effect: Schema.Literals<readonly ["allow", "deny", "ask"]>;
|
|
56
56
|
}>>>, never, never>;
|
|
57
|
-
readonly policies: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
58
|
-
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.use"]>;
|
|
57
|
+
readonly policies: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.decodeTo<Schema.toType<Schema.Struct<{
|
|
58
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
59
59
|
readonly resource: Schema.String;
|
|
60
60
|
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
61
|
-
}
|
|
62
|
-
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.use"]>;
|
|
61
|
+
}>>, Schema.Struct<{
|
|
62
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
63
63
|
readonly resource: Schema.String;
|
|
64
64
|
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
65
|
-
}
|
|
65
|
+
}>, never, never>>>>, Schema.optionalKey<Schema.$Array<Schema.decodeTo<Schema.toType<Schema.Struct<{
|
|
66
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
67
|
+
readonly resource: Schema.String;
|
|
68
|
+
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
69
|
+
}>>, Schema.Struct<{
|
|
70
|
+
readonly action: Schema.Literals<readonly ["provider.use", "tool.use", "integration.connect", "integration.use", "mcp.use", "skill.use", "plugin.use"]>;
|
|
71
|
+
readonly resource: Schema.String;
|
|
72
|
+
readonly effect: Schema.Literals<readonly ["allow", "deny"]>;
|
|
73
|
+
}>, never, never>>>, never, never>;
|
|
66
74
|
readonly agents: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, typeof ConfigAgent.Info>>>, Schema.optionalKey<Schema.$Record<Schema.String, typeof ConfigAgent.Info>>, never, never>;
|
|
67
75
|
readonly snapshots: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
68
76
|
readonly watcher: Schema.decodeTo<Schema.optional<Schema.toType<typeof ConfigWatcher.Info>>, Schema.optionalKey<typeof ConfigWatcher.Info>, never, never>;
|
package/dist/schedule.d.ts
CHANGED
|
@@ -78,6 +78,16 @@ export declare const ShellCondition: Schema.Struct<{
|
|
|
78
78
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
79
79
|
}>;
|
|
80
80
|
export type ShellCondition = typeof ShellCondition.Type;
|
|
81
|
+
/**
|
|
82
|
+
* Runs `code` in a confined Code Mode runtime before firing, with no model call and no `fetch`. Tools called statically
|
|
83
|
+
* as `tools.<path>(...)` are extracted from the AST and authorized at creation; the program receives `state` (initially
|
|
84
|
+
* `null`), `now` (epoch ms) and `runs` (completed checks), and returns a boolean or `{ wake, state?, message? }`.
|
|
85
|
+
*/
|
|
86
|
+
export declare const CodeCondition: Schema.Struct<{
|
|
87
|
+
readonly type: Schema.tag<"code">;
|
|
88
|
+
readonly code: Schema.String;
|
|
89
|
+
}>;
|
|
90
|
+
export type CodeCondition = typeof CodeCondition.Type;
|
|
81
91
|
/** Checked before firing; the schedule wakes the Session only when the condition passes. */
|
|
82
92
|
export declare const Condition: Schema.Union<readonly [Schema.Struct<{
|
|
83
93
|
readonly type: Schema.tag<"shell">;
|
|
@@ -85,6 +95,9 @@ export declare const Condition: Schema.Union<readonly [Schema.Struct<{
|
|
|
85
95
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
86
96
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
87
97
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
98
|
+
}>, Schema.Struct<{
|
|
99
|
+
readonly type: Schema.tag<"code">;
|
|
100
|
+
readonly code: Schema.String;
|
|
88
101
|
}>]>;
|
|
89
102
|
export type Condition = typeof Condition.Type;
|
|
90
103
|
export declare const CheckMode: Schema.Literals<readonly ["if", "until"]>;
|
|
@@ -97,6 +110,9 @@ export declare const StoredCheck: Schema.Struct<{
|
|
|
97
110
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
98
111
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
99
112
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
113
|
+
}>, Schema.Struct<{
|
|
114
|
+
readonly type: Schema.tag<"code">;
|
|
115
|
+
readonly code: Schema.String;
|
|
100
116
|
}>]>;
|
|
101
117
|
}>;
|
|
102
118
|
export type StoredCheck = typeof StoredCheck.Type;
|
|
@@ -138,12 +154,18 @@ export declare const Info: Schema.Struct<{
|
|
|
138
154
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
139
155
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
140
156
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
157
|
+
}>, Schema.Struct<{
|
|
158
|
+
readonly type: Schema.tag<"code">;
|
|
159
|
+
readonly code: Schema.String;
|
|
141
160
|
}>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
142
161
|
readonly type: Schema.tag<"shell">;
|
|
143
162
|
readonly run: Schema.String;
|
|
144
163
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
145
164
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
146
165
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
166
|
+
}>, Schema.Struct<{
|
|
167
|
+
readonly type: Schema.tag<"code">;
|
|
168
|
+
readonly code: Schema.String;
|
|
147
169
|
}>]>>, never, never>;
|
|
148
170
|
readonly until: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
|
|
149
171
|
readonly type: Schema.tag<"shell">;
|
|
@@ -151,12 +173,18 @@ export declare const Info: Schema.Struct<{
|
|
|
151
173
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
152
174
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
153
175
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
176
|
+
}>, Schema.Struct<{
|
|
177
|
+
readonly type: Schema.tag<"code">;
|
|
178
|
+
readonly code: Schema.String;
|
|
154
179
|
}>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
155
180
|
readonly type: Schema.tag<"shell">;
|
|
156
181
|
readonly run: Schema.String;
|
|
157
182
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
158
183
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
159
184
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
185
|
+
}>, Schema.Struct<{
|
|
186
|
+
readonly type: Schema.tag<"code">;
|
|
187
|
+
readonly code: Schema.String;
|
|
160
188
|
}>]>>, never, never>;
|
|
161
189
|
readonly action: Schema.Union<readonly [Schema.Struct<{
|
|
162
190
|
readonly type: Schema.tag<"prompt">;
|
|
@@ -220,12 +248,18 @@ export declare const CreateInput: Schema.Struct<{
|
|
|
220
248
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
221
249
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
222
250
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
251
|
+
}>, Schema.Struct<{
|
|
252
|
+
readonly type: Schema.tag<"code">;
|
|
253
|
+
readonly code: Schema.String;
|
|
223
254
|
}>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
224
255
|
readonly type: Schema.tag<"shell">;
|
|
225
256
|
readonly run: Schema.String;
|
|
226
257
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
227
258
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
228
259
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
260
|
+
}>, Schema.Struct<{
|
|
261
|
+
readonly type: Schema.tag<"code">;
|
|
262
|
+
readonly code: Schema.String;
|
|
229
263
|
}>]>>, never, never>;
|
|
230
264
|
readonly until: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
|
|
231
265
|
readonly type: Schema.tag<"shell">;
|
|
@@ -233,12 +267,18 @@ export declare const CreateInput: Schema.Struct<{
|
|
|
233
267
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
234
268
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
235
269
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
270
|
+
}>, Schema.Struct<{
|
|
271
|
+
readonly type: Schema.tag<"code">;
|
|
272
|
+
readonly code: Schema.String;
|
|
236
273
|
}>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
237
274
|
readonly type: Schema.tag<"shell">;
|
|
238
275
|
readonly run: Schema.String;
|
|
239
276
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
240
277
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
241
278
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
279
|
+
}>, Schema.Struct<{
|
|
280
|
+
readonly type: Schema.tag<"code">;
|
|
281
|
+
readonly code: Schema.String;
|
|
242
282
|
}>]>>, never, never>;
|
|
243
283
|
readonly ends: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
244
284
|
readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
@@ -288,13 +328,23 @@ export declare const ShellConditionInput: Schema.Struct<{
|
|
|
288
328
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
289
329
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
290
330
|
}>;
|
|
291
|
-
export
|
|
292
|
-
|
|
331
|
+
export declare const CodeConditionInput: Schema.Struct<{
|
|
332
|
+
readonly code: Schema.String;
|
|
333
|
+
}>;
|
|
334
|
+
export declare const ConditionInput: Schema.Union<readonly [Schema.Struct<{
|
|
293
335
|
readonly run: Schema.String;
|
|
294
336
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
295
337
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
296
338
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
297
|
-
|
|
339
|
+
readonly code: Schema.optionalKey<Schema.Never>;
|
|
340
|
+
}>, Schema.Struct<{
|
|
341
|
+
readonly code: Schema.String;
|
|
342
|
+
readonly run: Schema.optionalKey<Schema.Never>;
|
|
343
|
+
readonly is: Schema.optionalKey<Schema.Never>;
|
|
344
|
+
readonly matches: Schema.optionalKey<Schema.Never>;
|
|
345
|
+
readonly changes: Schema.optionalKey<Schema.Never>;
|
|
346
|
+
}>]>;
|
|
347
|
+
export type ConditionInput = typeof ConditionInput.Type;
|
|
298
348
|
/** A schedule as callers describe it: when it fires, optional condition, when it stops, and the prompt it sends. */
|
|
299
349
|
export declare const Request: Schema.Struct<{
|
|
300
350
|
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
@@ -347,28 +397,56 @@ export declare const Request: Schema.Struct<{
|
|
|
347
397
|
readonly at: Schema.optionalKey<Schema.Never>;
|
|
348
398
|
readonly every: Schema.optionalKey<Schema.Never>;
|
|
349
399
|
}>]>>, never, never>;
|
|
350
|
-
readonly if: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
400
|
+
readonly if: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
|
|
351
401
|
readonly run: Schema.String;
|
|
352
402
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
353
403
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
354
404
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
355
|
-
|
|
405
|
+
readonly code: Schema.optionalKey<Schema.Never>;
|
|
406
|
+
}>, Schema.Struct<{
|
|
407
|
+
readonly code: Schema.String;
|
|
408
|
+
readonly run: Schema.optionalKey<Schema.Never>;
|
|
409
|
+
readonly is: Schema.optionalKey<Schema.Never>;
|
|
410
|
+
readonly matches: Schema.optionalKey<Schema.Never>;
|
|
411
|
+
readonly changes: Schema.optionalKey<Schema.Never>;
|
|
412
|
+
}>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
356
413
|
readonly run: Schema.String;
|
|
357
414
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
358
415
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
359
416
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
360
|
-
|
|
361
|
-
|
|
417
|
+
readonly code: Schema.optionalKey<Schema.Never>;
|
|
418
|
+
}>, Schema.Struct<{
|
|
419
|
+
readonly code: Schema.String;
|
|
420
|
+
readonly run: Schema.optionalKey<Schema.Never>;
|
|
421
|
+
readonly is: Schema.optionalKey<Schema.Never>;
|
|
422
|
+
readonly matches: Schema.optionalKey<Schema.Never>;
|
|
423
|
+
readonly changes: Schema.optionalKey<Schema.Never>;
|
|
424
|
+
}>]>>, never, never>;
|
|
425
|
+
readonly until: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Union<readonly [Schema.Struct<{
|
|
362
426
|
readonly run: Schema.String;
|
|
363
427
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
364
428
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
365
429
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
366
|
-
|
|
430
|
+
readonly code: Schema.optionalKey<Schema.Never>;
|
|
431
|
+
}>, Schema.Struct<{
|
|
432
|
+
readonly code: Schema.String;
|
|
433
|
+
readonly run: Schema.optionalKey<Schema.Never>;
|
|
434
|
+
readonly is: Schema.optionalKey<Schema.Never>;
|
|
435
|
+
readonly matches: Schema.optionalKey<Schema.Never>;
|
|
436
|
+
readonly changes: Schema.optionalKey<Schema.Never>;
|
|
437
|
+
}>]>>>, Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
|
|
367
438
|
readonly run: Schema.String;
|
|
368
439
|
readonly is: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
369
440
|
readonly matches: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
370
441
|
readonly changes: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
371
|
-
|
|
442
|
+
readonly code: Schema.optionalKey<Schema.Never>;
|
|
443
|
+
}>, Schema.Struct<{
|
|
444
|
+
readonly code: Schema.String;
|
|
445
|
+
readonly run: Schema.optionalKey<Schema.Never>;
|
|
446
|
+
readonly is: Schema.optionalKey<Schema.Never>;
|
|
447
|
+
readonly matches: Schema.optionalKey<Schema.Never>;
|
|
448
|
+
readonly changes: Schema.optionalKey<Schema.Never>;
|
|
449
|
+
}>]>>, never, never>;
|
|
372
450
|
readonly ends: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
373
451
|
readonly after: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
374
452
|
readonly at: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
package/dist/schedule.js
CHANGED
|
@@ -56,8 +56,17 @@ export const ShellCondition = Schema.Struct({
|
|
|
56
56
|
matches: Schema.String.pipe(optional),
|
|
57
57
|
changes: Schema.Boolean.pipe(optional),
|
|
58
58
|
}).annotate({ identifier: "Schedule.Condition.Shell" });
|
|
59
|
+
/**
|
|
60
|
+
* Runs `code` in a confined Code Mode runtime before firing, with no model call and no `fetch`. Tools called statically
|
|
61
|
+
* as `tools.<path>(...)` are extracted from the AST and authorized at creation; the program receives `state` (initially
|
|
62
|
+
* `null`), `now` (epoch ms) and `runs` (completed checks), and returns a boolean or `{ wake, state?, message? }`.
|
|
63
|
+
*/
|
|
64
|
+
export const CodeCondition = Schema.Struct({
|
|
65
|
+
type: Schema.tag("code"),
|
|
66
|
+
code: Schema.String,
|
|
67
|
+
}).annotate({ identifier: "Schedule.Condition.Code" });
|
|
59
68
|
/** Checked before firing; the schedule wakes the Session only when the condition passes. */
|
|
60
|
-
export const Condition = Schema.Union([ShellCondition]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Schedule.Condition" }));
|
|
69
|
+
export const Condition = Schema.Union([ShellCondition, CodeCondition]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Schedule.Condition" }));
|
|
61
70
|
export const CheckMode = Schema.Literals(["if", "until"]).annotate({ identifier: "Schedule.CheckMode" });
|
|
62
71
|
export const StoredCheck = Schema.Struct({
|
|
63
72
|
mode: CheckMode,
|
|
@@ -103,7 +112,7 @@ export const CreateInput = Schema.Struct({
|
|
|
103
112
|
ends: Ends.pipe(optional),
|
|
104
113
|
action: Action,
|
|
105
114
|
}).annotate({ identifier: "Schedule.CreateInput" });
|
|
106
|
-
/** Declares a
|
|
115
|
+
/** Declares a variant field absent, so `{ in, every }` or `{ run, code }` fails instead of silently dropping one. */
|
|
107
116
|
const absent = Schema.optionalKey(Schema.Never);
|
|
108
117
|
/** The `when` callers write: exactly one of `in`, `at`, `every` or `cron`, with an optional `tz`. */
|
|
109
118
|
export const WhenInput = Schema.Union([
|
|
@@ -125,8 +134,28 @@ export const ShellConditionInput = Schema.Struct({
|
|
|
125
134
|
changes: Schema.Boolean.pipe(optional).annotate({
|
|
126
135
|
description: "Wake when exit is 0 and stdout differs from the previous check.",
|
|
127
136
|
}),
|
|
128
|
-
}).annotate({ identifier: "Schedule.
|
|
129
|
-
export const
|
|
137
|
+
}).annotate({ identifier: "Schedule.ShellConditionInput" });
|
|
138
|
+
export const CodeConditionInput = Schema.Struct({
|
|
139
|
+
code: Schema.String.check(Schema.isMinLength(1)).annotate({
|
|
140
|
+
description: [
|
|
141
|
+
"Code Mode JavaScript check (no fetch; 30s, 20 tool calls, 32 KB output cap).",
|
|
142
|
+
'Call tools statically as tools.<ns>.<tool>(...) or tools["ns-name"].tool(...); each is authorized once at creation to run unattended.',
|
|
143
|
+
"Runs once at creation with state = null (if baselines state without waking; until matches immediately if true), with globals state, now (epoch ms) and runs.",
|
|
144
|
+
"Return a boolean or { wake, state?, message? } (message is appended to prompt on wake), e.g.:",
|
|
145
|
+
'const t = await tools.slack.read_thread({ id }); return { wake: state !== null && t.count > state.count, state: { count: t.count }, message: "New reply" }',
|
|
146
|
+
].join(" "),
|
|
147
|
+
}),
|
|
148
|
+
}).annotate({ identifier: "Schedule.CodeConditionInput" });
|
|
149
|
+
export const ConditionInput = Schema.Union([
|
|
150
|
+
Schema.Struct({ ...ShellConditionInput.fields, code: absent }),
|
|
151
|
+
Schema.Struct({
|
|
152
|
+
...CodeConditionInput.fields,
|
|
153
|
+
run: absent,
|
|
154
|
+
is: absent,
|
|
155
|
+
matches: absent,
|
|
156
|
+
changes: absent,
|
|
157
|
+
}),
|
|
158
|
+
]).annotate({ identifier: "Schedule.ConditionInput" });
|
|
130
159
|
/** A schedule as callers describe it: when it fires, optional condition, when it stops, and the prompt it sends. */
|
|
131
160
|
export const Request = Schema.Struct({
|
|
132
161
|
name: Schema.String.pipe(optional).annotate({ description: "A short label for the schedule." }),
|
|
@@ -134,10 +163,10 @@ export const Request = Schema.Struct({
|
|
|
134
163
|
description: 'When it fires: { in: "20 minutes" }, { at: "2026-10-27T09:00" }, { every: "1 hour" } or { cron: "0 9 * * 1-5" }. Optional with `until` (defaults to { every: "30 seconds" }).',
|
|
135
164
|
}),
|
|
136
165
|
if: ConditionInput.pipe(optional).annotate({
|
|
137
|
-
description: "Recurring gate: check on each slot with no model call, and wake on every slot where it passes.",
|
|
166
|
+
description: "Recurring gate ({ run } shell command or { code } Code Mode script): check on each slot with no model call, and wake on every slot where it passes.",
|
|
138
167
|
}),
|
|
139
168
|
until: ConditionInput.pipe(optional).annotate({
|
|
140
|
-
description: 'One-shot gate: poll with no model call, wake once when it passes, and stop. Defaults ends.after to "24 hours".',
|
|
169
|
+
description: 'One-shot gate ({ run } shell command or { code } Code Mode script): poll with no model call, wake once when it passes, and stop. Defaults ends.after to "24 hours".',
|
|
141
170
|
}),
|
|
142
171
|
ends: Ends.pipe(optional).annotate({
|
|
143
172
|
description: 'Stops a repeating schedule at the first limit reached: { after: "8 hours" }, { at }, { times: 3 }.',
|
|
@@ -155,13 +184,17 @@ export const toCreateInput = (sessionID, request) => ({
|
|
|
155
184
|
ends: request.ends,
|
|
156
185
|
action: { type: "prompt", prompt: request.prompt },
|
|
157
186
|
});
|
|
158
|
-
const toCondition = (condition) =>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
187
|
+
const toCondition = (condition) => {
|
|
188
|
+
if (condition.code !== undefined)
|
|
189
|
+
return { type: "code", code: condition.code };
|
|
190
|
+
return {
|
|
191
|
+
type: "shell",
|
|
192
|
+
run: condition.run,
|
|
193
|
+
is: condition.is,
|
|
194
|
+
matches: condition.matches,
|
|
195
|
+
changes: condition.changes,
|
|
196
|
+
};
|
|
197
|
+
};
|
|
165
198
|
const toWhen = (when) => {
|
|
166
199
|
if (when.in !== undefined)
|
|
167
200
|
return { type: "in", in: when.in, tz: when.tz };
|