opencode-secrets-obfuscation 0.1.0 → 0.1.2
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/LICENSE +21 -21
- package/README.md +11 -21
- package/package.json +29 -23
- package/plugin.mjs +3847 -0
- package/.editorconfig +0 -12
- package/.github/workflows/ci.yml +0 -75
- package/.github/workflows/release.yml +0 -50
- package/.node-version +0 -1
- package/AGENTS.md +0 -23
- package/INSTALL.md +0 -104
- package/docs/checkpoint.md +0 -68
- package/docs/history/1-spec-review.md +0 -233
- package/docs/history/10-p0-launch-prerequisites-review.md +0 -186
- package/docs/history/11-p0-job-containment-review.md +0 -188
- package/docs/history/12-p0-api-client.md +0 -15
- package/docs/history/13-p0-status-review.md +0 -122
- package/docs/history/14-p0-containment-final-review.md +0 -84
- package/docs/history/15-config-source-implementation.md +0 -27
- package/docs/history/16-sanitizer-implementation.md +0 -65
- package/docs/history/17-store-policy-implementation.md +0 -36
- package/docs/history/18-pure-mvp-review.md +0 -182
- package/docs/history/19-pure-mvp-re-review.md +0 -142
- package/docs/history/2-p0-runtime-prerequisites.md +0 -163
- package/docs/history/20-pure-mvp-final-review.md +0 -116
- package/docs/history/21-pure-mvp-review-final.md +0 -109
- package/docs/history/22-pure-mvp-signoff-review.md +0 -113
- package/docs/history/23-pure-mvp-signoff-review.md +0 -75
- package/docs/history/24-owned-tools-implementation.md +0 -27
- package/docs/history/25-v2-plugin-integration.md +0 -53
- package/docs/history/26-owned-tools-review.md +0 -138
- package/docs/history/27-owned-tools-final-review.md +0 -93
- package/docs/history/28-owned-tools-signoff.md +0 -98
- package/docs/history/3-p0-harness-foundation.md +0 -105
- package/docs/history/4-p0-source-opening.md +0 -78
- package/docs/history/5-qualification-gate-review.md +0 -133
- package/docs/history/6-p0-infrastructure-review.md +0 -275
- package/docs/history/7-p0-job-containment.md +0 -29
- package/docs/history/8-p0-evidence-support.md +0 -52
- package/docs/history/9-p0-launch-plan.md +0 -88
- package/docs/spec/design.md +0 -111
- package/docs/spec/intent.md +0 -81
- package/docs/spec/plan.md +0 -78
- package/docs/testing.md +0 -157
- package/scripts/build-plugin.mjs +0 -84
- package/scripts/install-opencode-ci.ps1 +0 -39
- package/scripts/install-opencode-ci.sh +0 -27
- package/scripts/smoke.mjs +0 -105
- package/scripts/verify-package.mjs +0 -18
- package/src/README.md +0 -22
- package/src/budgets/index.ts +0 -49
- package/src/config/README.md +0 -4
- package/src/config/options.ts +0 -76
- package/src/diagnostics/README.md +0 -4
- package/src/opencode/v2/filter.ts +0 -350
- package/src/opencode/v2/index.ts +0 -86
- package/src/opencode/v2/runtime.ts +0 -207
- package/src/opencode/v2/transports/README.md +0 -5
- package/src/runtime/http-transport.ts +0 -20
- package/src/sanitize/README.md +0 -4
- package/src/sanitize/index.ts +0 -454
- package/src/sources/README.md +0 -5
- package/src/sources/dotenv.ts +0 -133
- package/src/sources/native/README.md +0 -5
- package/src/store/index.ts +0 -64
- package/tests/README.md +0 -26
- package/tests/contract/plugin-v2.test.ts +0 -29
- package/tests/fixtures/README.md +0 -9
- package/tests/fixtures/job-child.mjs +0 -18
- package/tests/fixtures/plugins/README.md +0 -8
- package/tests/fixtures/process-child.mjs +0 -20
- package/tests/fixtures/services/README.md +0 -10
- package/tests/integration/components.test.ts +0 -5
- package/tests/integration/transparent-runtime.test.ts +0 -97
- package/tests/integration/windows-job.test.ts +0 -71
- package/tests/p0-host/README.md +0 -24
- package/tests/p0-host/linux-job.sh +0 -61
- package/tests/p0-host/windows-job.ps1 +0 -51
- package/tests/p0-native/README.md +0 -33
- package/tests/p0-native/windows-handle-loader.tests.ps1 +0 -191
- package/tests/scaffold/repository.test.ts +0 -105
- package/tests/smoke/README.md +0 -37
- package/tests/smoke/cases.json +0 -17
- package/tests/smoke/qualification.json +0 -20
- package/tests/smoke/runtime-candidate.json +0 -111
- package/tests/support/README.md +0 -32
- package/tests/support/child-process.ts +0 -235
- package/tests/support/host-api.ts +0 -123
- package/tests/support/opencode-environment.ts +0 -239
- package/tests/support/qualification.ts +0 -154
- package/tests/support/recording-endpoint.ts +0 -242
- package/tests/support/run-directory.ts +0 -179
- package/tests/support/smoke-cases.ts +0 -289
- package/tests/unit/budgets.test.ts +0 -35
- package/tests/unit/config.test.ts +0 -40
- package/tests/unit/dotenv.test.ts +0 -72
- package/tests/unit/filter-size.test.ts +0 -132
- package/tests/unit/harness.test.ts +0 -228
- package/tests/unit/host-api.test.ts +0 -122
- package/tests/unit/opencode-environment.test.ts +0 -161
- package/tests/unit/qualification.test.ts +0 -128
- package/tests/unit/recording-endpoint.test.ts +0 -188
- package/tests/unit/sanitize.test.ts +0 -159
- package/tests/unit/smoke-cases.test.ts +0 -20
- package/tsconfig.json +0 -20
package/plugin.mjs
ADDED
|
@@ -0,0 +1,3847 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// node_modules/@opencode/plugin/dist/effect/plugin.js
|
|
8
|
+
var plugin_exports = {};
|
|
9
|
+
__export(plugin_exports, {
|
|
10
|
+
define: () => define
|
|
11
|
+
});
|
|
12
|
+
function define(plugin2) {
|
|
13
|
+
return plugin2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// node_modules/@opencode/schema/dist/agent.js
|
|
17
|
+
var agent_exports = {};
|
|
18
|
+
__export(agent_exports, {
|
|
19
|
+
Agent: () => agent_exports,
|
|
20
|
+
Color: () => Color,
|
|
21
|
+
Event: () => Event7,
|
|
22
|
+
ID: () => ID8,
|
|
23
|
+
Info: () => Info7,
|
|
24
|
+
Name: () => Name
|
|
25
|
+
});
|
|
26
|
+
import { Schema as Schema17 } from "effect";
|
|
27
|
+
|
|
28
|
+
// node_modules/@opencode/schema/dist/event.js
|
|
29
|
+
var event_exports = {};
|
|
30
|
+
__export(event_exports, {
|
|
31
|
+
Event: () => event_exports,
|
|
32
|
+
ID: () => ID,
|
|
33
|
+
Seq: () => Seq,
|
|
34
|
+
Version: () => Version,
|
|
35
|
+
durable: () => durable,
|
|
36
|
+
durableMap: () => durableMap,
|
|
37
|
+
ephemeral: () => ephemeral,
|
|
38
|
+
inventory: () => inventory,
|
|
39
|
+
latest: () => latest,
|
|
40
|
+
versionedType: () => versionedType
|
|
41
|
+
});
|
|
42
|
+
import { Schema as Schema5, SchemaTransformation } from "effect";
|
|
43
|
+
|
|
44
|
+
// node_modules/@opencode/schema/dist/schema.js
|
|
45
|
+
import { DateTime, Option, Schema, SchemaGetter } from "effect";
|
|
46
|
+
var PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));
|
|
47
|
+
var NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
48
|
+
var RelativePath = Schema.String.pipe(Schema.brand("RelativePath"), Schema.annotate({ identifier: "RelativePath" }));
|
|
49
|
+
var AbsolutePath = Schema.String.pipe(Schema.brand("AbsolutePath"), Schema.annotate({ identifier: "AbsolutePath" }));
|
|
50
|
+
var optional = (schema) => Schema.optionalKey(schema).pipe(Schema.decodeTo(Schema.optional(Schema.toType(schema)), {
|
|
51
|
+
decode: SchemaGetter.passthrough({ strict: false }),
|
|
52
|
+
encode: SchemaGetter.transformOptional(Option.filter((value) => value !== void 0))
|
|
53
|
+
}));
|
|
54
|
+
var withStatics = (schema, methods) => Object.defineProperties(schema, Object.getOwnPropertyDescriptors(methods));
|
|
55
|
+
var statics = (methods) => (schema) => withStatics(schema, methods(schema));
|
|
56
|
+
var DateTimeUtcFromMillis = Schema.Finite.pipe(Schema.decodeTo(Schema.DateTimeUtc, {
|
|
57
|
+
decode: SchemaGetter.transform((value) => DateTime.makeUnsafe(value)),
|
|
58
|
+
encode: SchemaGetter.transform((value) => DateTime.toEpochMillis(value))
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
// node_modules/@opencode/schema/dist/identifier.js
|
|
62
|
+
var length = 26;
|
|
63
|
+
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
64
|
+
var lastTimestamp = 0;
|
|
65
|
+
var counter = 0;
|
|
66
|
+
function ascending() {
|
|
67
|
+
return create(false);
|
|
68
|
+
}
|
|
69
|
+
function descending() {
|
|
70
|
+
return create(true);
|
|
71
|
+
}
|
|
72
|
+
function create(descending2, timestamp = Date.now()) {
|
|
73
|
+
if (timestamp !== lastTimestamp) {
|
|
74
|
+
lastTimestamp = timestamp;
|
|
75
|
+
counter = 0;
|
|
76
|
+
}
|
|
77
|
+
counter++;
|
|
78
|
+
const current = BigInt(timestamp) * 0x1000n + BigInt(counter);
|
|
79
|
+
const value = descending2 ? ~current : current;
|
|
80
|
+
const time = Array.from({ length: 6 }, (_, index) => Number(value >> BigInt(40 - 8 * index) & 0xffn).toString(16).padStart(2, "0")).join("");
|
|
81
|
+
const bytes2 = crypto.getRandomValues(new Uint8Array(length - 12));
|
|
82
|
+
return time + Array.from(bytes2, (byte) => chars[byte % 62]).join("");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// node_modules/@opencode/schema/dist/location.js
|
|
86
|
+
var location_exports = {};
|
|
87
|
+
__export(location_exports, {
|
|
88
|
+
Info: () => Info,
|
|
89
|
+
Location: () => location_exports,
|
|
90
|
+
PublicInfo: () => PublicInfo,
|
|
91
|
+
PublicRef: () => PublicRef,
|
|
92
|
+
Ref: () => Ref,
|
|
93
|
+
response: () => response
|
|
94
|
+
});
|
|
95
|
+
import { Schema as Schema4, Struct } from "effect";
|
|
96
|
+
|
|
97
|
+
// node_modules/@opencode/schema/dist/project-id.js
|
|
98
|
+
import { Schema as Schema2 } from "effect";
|
|
99
|
+
var ProjectID = Schema2.String.pipe(Schema2.brand("Project.ID"), Schema2.annotate({ identifier: "Project.ID" }), statics((schema) => ({ global: schema.make("global") })));
|
|
100
|
+
|
|
101
|
+
// node_modules/@opencode/schema/dist/workspace-id.js
|
|
102
|
+
import { Schema as Schema3 } from "effect";
|
|
103
|
+
var WorkspaceID = Schema3.String.check(Schema3.isStartingWith("wrk")).pipe(Schema3.brand("Workspace.ID"), Schema3.annotate({ identifier: "Workspace.ID" }), statics((schema) => {
|
|
104
|
+
const create2 = () => schema.make("wrk_" + ascending());
|
|
105
|
+
return {
|
|
106
|
+
ascending: (id) => {
|
|
107
|
+
if (!id)
|
|
108
|
+
return create2();
|
|
109
|
+
if (!id.startsWith("wrk"))
|
|
110
|
+
throw new Error(`ID ${id} does not start with wrk`);
|
|
111
|
+
return schema.make(id);
|
|
112
|
+
},
|
|
113
|
+
create: create2
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
// node_modules/@opencode/schema/dist/location.js
|
|
118
|
+
var Ref = Schema4.Struct({
|
|
119
|
+
directory: AbsolutePath,
|
|
120
|
+
workspaceID: optional(WorkspaceID)
|
|
121
|
+
}).annotate({ identifier: "Location.Ref" });
|
|
122
|
+
var PublicRef = Schema4.Struct(Struct.omit(Ref.fields, ["workspaceID"])).annotate({
|
|
123
|
+
identifier: "Location.PublicRef"
|
|
124
|
+
});
|
|
125
|
+
var Info = class extends Schema4.Class("Location.Info")({
|
|
126
|
+
directory: AbsolutePath,
|
|
127
|
+
workspaceID: optional(WorkspaceID),
|
|
128
|
+
project: Schema4.Struct({
|
|
129
|
+
id: ProjectID,
|
|
130
|
+
directory: AbsolutePath,
|
|
131
|
+
canonical: AbsolutePath
|
|
132
|
+
})
|
|
133
|
+
}) {
|
|
134
|
+
};
|
|
135
|
+
var PublicInfo = Schema4.Struct(Struct.omit(Info.fields, ["workspaceID"])).annotate({
|
|
136
|
+
identifier: "Location.PublicInfo"
|
|
137
|
+
});
|
|
138
|
+
function response(data) {
|
|
139
|
+
return Schema4.Struct({ location: PublicRef, data });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// node_modules/@opencode/schema/dist/event.js
|
|
143
|
+
var ID = Schema5.String.check(Schema5.isStartingWith("evt_")).pipe(Schema5.brand("Event.ID"), Schema5.annotate({ identifier: "Event.ID" }), statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })));
|
|
144
|
+
var Seq = Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(0)).pipe(Schema5.brand("Event.Seq"), Schema5.annotate({ identifier: "Event.Seq" }));
|
|
145
|
+
var Version = Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1)).pipe(Schema5.brand("Event.Version"), Schema5.annotate({ identifier: "Event.Version" }));
|
|
146
|
+
var DurableEnvelope = Schema5.Struct({ aggregateID: Schema5.String, seq: Seq, version: Version });
|
|
147
|
+
function durable(input) {
|
|
148
|
+
const data = Schema5.Struct(input.schema);
|
|
149
|
+
const durable2 = Schema5.Struct({
|
|
150
|
+
aggregateID: DurableEnvelope.fields.aggregateID,
|
|
151
|
+
seq: DurableEnvelope.fields.seq,
|
|
152
|
+
version: Schema5.Literal(input.durable.version).pipe(Schema5.decodeTo(Schema5.toType(Version), SchemaTransformation.transform({
|
|
153
|
+
decode: () => Version.make(input.durable.version),
|
|
154
|
+
encode: () => input.durable.version
|
|
155
|
+
})))
|
|
156
|
+
});
|
|
157
|
+
return Schema5.Struct({
|
|
158
|
+
id: ID,
|
|
159
|
+
created: Schema5.Finite,
|
|
160
|
+
metadata: optional(Schema5.Record(Schema5.String, Schema5.Unknown)),
|
|
161
|
+
type: Schema5.Literal(input.type),
|
|
162
|
+
durable: durable2,
|
|
163
|
+
location: optional(location_exports.Ref),
|
|
164
|
+
data
|
|
165
|
+
}).annotate({ identifier: input.identifier ?? input.type }).pipe(statics(() => ({
|
|
166
|
+
type: input.type,
|
|
167
|
+
durability: "durable",
|
|
168
|
+
durable: input.durable,
|
|
169
|
+
data
|
|
170
|
+
})));
|
|
171
|
+
}
|
|
172
|
+
function ephemeral(input) {
|
|
173
|
+
const data = Schema5.Struct(input.schema);
|
|
174
|
+
return Schema5.Struct({
|
|
175
|
+
id: ID,
|
|
176
|
+
created: Schema5.Finite,
|
|
177
|
+
metadata: optional(Schema5.Record(Schema5.String, Schema5.Unknown)),
|
|
178
|
+
type: Schema5.Literal(input.type),
|
|
179
|
+
location: optional(location_exports.Ref),
|
|
180
|
+
data
|
|
181
|
+
}).annotate({ identifier: input.identifier ?? input.type }).pipe(statics(() => ({
|
|
182
|
+
type: input.type,
|
|
183
|
+
durability: "ephemeral",
|
|
184
|
+
durable: void 0,
|
|
185
|
+
data
|
|
186
|
+
})));
|
|
187
|
+
}
|
|
188
|
+
function inventory(...definitions) {
|
|
189
|
+
return Object.freeze(definitions);
|
|
190
|
+
}
|
|
191
|
+
function latest(definitions) {
|
|
192
|
+
return readonlyMap(definitions.reduce((result, definition) => {
|
|
193
|
+
const existing = result.get(definition.type);
|
|
194
|
+
if (!existing) {
|
|
195
|
+
result.set(definition.type, definition);
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
if (definition.durable && existing.durable && definition.durable.version !== existing.durable.version) {
|
|
199
|
+
if (definition.durable.version > existing.durable.version)
|
|
200
|
+
result.set(definition.type, definition);
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
if (definition !== existing)
|
|
204
|
+
throw new Error(`Duplicate latest event definition for ${definition.type}`);
|
|
205
|
+
return result;
|
|
206
|
+
}, /* @__PURE__ */ new Map()));
|
|
207
|
+
}
|
|
208
|
+
function versionedType(type, version) {
|
|
209
|
+
return `${type}.${version}`;
|
|
210
|
+
}
|
|
211
|
+
function durableMap(definitions) {
|
|
212
|
+
return readonlyMap(definitions.reduce((result, definition) => {
|
|
213
|
+
if (definition.durability !== "durable")
|
|
214
|
+
return result;
|
|
215
|
+
const key = versionedType(definition.type, definition.durable.version);
|
|
216
|
+
if (result.has(key))
|
|
217
|
+
throw new Error(`Duplicate durable event definition for ${key}`);
|
|
218
|
+
result.set(key, definition);
|
|
219
|
+
return result;
|
|
220
|
+
}, /* @__PURE__ */ new Map()));
|
|
221
|
+
}
|
|
222
|
+
function readonlyMap(map) {
|
|
223
|
+
const result = Object.freeze({
|
|
224
|
+
get size() {
|
|
225
|
+
return map.size;
|
|
226
|
+
},
|
|
227
|
+
entries: () => map.entries(),
|
|
228
|
+
forEach: (callback, thisArg) => map.forEach((value, key) => callback.call(thisArg, value, key, result)),
|
|
229
|
+
get: (key) => map.get(key),
|
|
230
|
+
has: (key) => map.has(key),
|
|
231
|
+
keys: () => map.keys(),
|
|
232
|
+
values: () => map.values(),
|
|
233
|
+
[Symbol.iterator]: () => map[Symbol.iterator]()
|
|
234
|
+
});
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// node_modules/@opencode/schema/dist/model.js
|
|
239
|
+
var model_exports = {};
|
|
240
|
+
__export(model_exports, {
|
|
241
|
+
Capabilities: () => Capabilities,
|
|
242
|
+
Compatibility: () => Compatibility,
|
|
243
|
+
Cost: () => Cost,
|
|
244
|
+
Event: () => Event5,
|
|
245
|
+
Family: () => Family,
|
|
246
|
+
ID: () => ID6,
|
|
247
|
+
Info: () => Info6,
|
|
248
|
+
MaxTokensField: () => MaxTokensField,
|
|
249
|
+
Model: () => model_exports,
|
|
250
|
+
Overlays: () => Overlays2,
|
|
251
|
+
ReasoningField: () => ReasoningField,
|
|
252
|
+
Ref: () => Ref3,
|
|
253
|
+
Settings: () => Settings2,
|
|
254
|
+
Variant: () => Variant,
|
|
255
|
+
VariantID: () => VariantID
|
|
256
|
+
});
|
|
257
|
+
import { Schema as Schema14 } from "effect";
|
|
258
|
+
|
|
259
|
+
// node_modules/@opencode/schema/dist/provider.js
|
|
260
|
+
var provider_exports = {};
|
|
261
|
+
__export(provider_exports, {
|
|
262
|
+
Activation: () => Activation,
|
|
263
|
+
Compaction: () => Compaction,
|
|
264
|
+
Encoding: () => Encoding,
|
|
265
|
+
Event: () => Event4,
|
|
266
|
+
ID: () => ID5,
|
|
267
|
+
Info: () => Info5,
|
|
268
|
+
Overlays: () => Overlays,
|
|
269
|
+
Package: () => Package,
|
|
270
|
+
Provider: () => provider_exports,
|
|
271
|
+
Request: () => Request2,
|
|
272
|
+
Settings: () => Settings,
|
|
273
|
+
Transport: () => Transport
|
|
274
|
+
});
|
|
275
|
+
import { Effect, Schema as Schema12 } from "effect";
|
|
276
|
+
|
|
277
|
+
// node_modules/@opencode/schema/dist/integration.js
|
|
278
|
+
var integration_exports = {};
|
|
279
|
+
__export(integration_exports, {
|
|
280
|
+
Attempt: () => Attempt,
|
|
281
|
+
AttemptID: () => AttemptID,
|
|
282
|
+
AttemptStatus: () => AttemptStatus,
|
|
283
|
+
CommandAttempt: () => CommandAttempt,
|
|
284
|
+
CommandAttemptStatus: () => CommandAttemptStatus,
|
|
285
|
+
CommandMethod: () => CommandMethod,
|
|
286
|
+
EnvMethod: () => EnvMethod,
|
|
287
|
+
Event: () => Event3,
|
|
288
|
+
ExternalMethod: () => ExternalMethod,
|
|
289
|
+
ID: () => ID4,
|
|
290
|
+
Info: () => Info4,
|
|
291
|
+
Integration: () => integration_exports,
|
|
292
|
+
KeyMethod: () => KeyMethod,
|
|
293
|
+
Method: () => Method,
|
|
294
|
+
MethodID: () => MethodID,
|
|
295
|
+
OAuthMethod: () => OAuthMethod,
|
|
296
|
+
Ref: () => Ref2
|
|
297
|
+
});
|
|
298
|
+
import { Schema as Schema10 } from "effect";
|
|
299
|
+
|
|
300
|
+
// node_modules/@opencode/schema/dist/connection.js
|
|
301
|
+
var connection_exports = {};
|
|
302
|
+
__export(connection_exports, {
|
|
303
|
+
Connection: () => connection_exports,
|
|
304
|
+
CredentialInfo: () => CredentialInfo,
|
|
305
|
+
EnvInfo: () => EnvInfo,
|
|
306
|
+
Info: () => Info3,
|
|
307
|
+
Status: () => Status
|
|
308
|
+
});
|
|
309
|
+
import { Schema as Schema9 } from "effect";
|
|
310
|
+
|
|
311
|
+
// node_modules/@opencode/schema/dist/credential.js
|
|
312
|
+
var credential_exports = {};
|
|
313
|
+
__export(credential_exports, {
|
|
314
|
+
CreateInput: () => CreateInput,
|
|
315
|
+
Credential: () => credential_exports,
|
|
316
|
+
Entry: () => Entry,
|
|
317
|
+
Event: () => Event2,
|
|
318
|
+
External: () => External,
|
|
319
|
+
ID: () => ID3,
|
|
320
|
+
Key: () => Key,
|
|
321
|
+
OAuth: () => OAuth,
|
|
322
|
+
Value: () => Value2
|
|
323
|
+
});
|
|
324
|
+
import { Schema as Schema8 } from "effect";
|
|
325
|
+
|
|
326
|
+
// node_modules/@opencode/schema/dist/integration-id.js
|
|
327
|
+
import { Schema as Schema6 } from "effect";
|
|
328
|
+
var IntegrationID = Schema6.String.pipe(Schema6.brand("Integration.ID"), Schema6.annotate({ identifier: "Integration.ID" }));
|
|
329
|
+
var IntegrationMethodID = Schema6.String.pipe(Schema6.brand("Integration.MethodID"), Schema6.annotate({ identifier: "Integration.MethodID" }));
|
|
330
|
+
|
|
331
|
+
// node_modules/@opencode/schema/dist/form.js
|
|
332
|
+
var form_exports = {};
|
|
333
|
+
__export(form_exports, {
|
|
334
|
+
Answer: () => Answer,
|
|
335
|
+
BooleanField: () => BooleanField,
|
|
336
|
+
Detail: () => Detail,
|
|
337
|
+
Event: () => Event,
|
|
338
|
+
ExternalField: () => ExternalField,
|
|
339
|
+
Field: () => Field,
|
|
340
|
+
Fields: () => Fields,
|
|
341
|
+
Form: () => form_exports,
|
|
342
|
+
ID: () => ID2,
|
|
343
|
+
Info: () => Info2,
|
|
344
|
+
IntegerField: () => IntegerField,
|
|
345
|
+
Metadata: () => Metadata,
|
|
346
|
+
MultiselectField: () => MultiselectField,
|
|
347
|
+
NumberField: () => NumberField,
|
|
348
|
+
Option: () => Option2,
|
|
349
|
+
Reply: () => Reply,
|
|
350
|
+
State: () => State,
|
|
351
|
+
StringField: () => StringField,
|
|
352
|
+
Value: () => Value,
|
|
353
|
+
When: () => When
|
|
354
|
+
});
|
|
355
|
+
import { Schema as Schema7 } from "effect";
|
|
356
|
+
var IDSchema = Schema7.String.check(Schema7.isStartingWith("frm_")).pipe(Schema7.brand("Form.ID"), Schema7.annotate({ identifier: "Form.ID" }));
|
|
357
|
+
var ID2 = IDSchema.pipe(statics((schema) => ({ create: (id) => schema.make(id ?? "frm_" + ascending()) })));
|
|
358
|
+
var Metadata = Schema7.Record(Schema7.String, Schema7.Unknown).annotate({ identifier: "Form.Metadata" });
|
|
359
|
+
var Option2 = Schema7.Struct({
|
|
360
|
+
value: Schema7.String,
|
|
361
|
+
label: Schema7.String,
|
|
362
|
+
description: Schema7.String.pipe(optional)
|
|
363
|
+
}).annotate({ identifier: "Form.Option" });
|
|
364
|
+
var When = Schema7.Struct({
|
|
365
|
+
key: Schema7.String,
|
|
366
|
+
op: Schema7.Literals(["eq", "neq"]),
|
|
367
|
+
value: Schema7.Union([Schema7.String, Schema7.Number, Schema7.Boolean])
|
|
368
|
+
}).annotate({ identifier: "Form.When" });
|
|
369
|
+
var FieldBase = {
|
|
370
|
+
key: Schema7.String,
|
|
371
|
+
title: Schema7.String.pipe(optional),
|
|
372
|
+
description: Schema7.String.pipe(optional),
|
|
373
|
+
required: Schema7.Boolean.pipe(optional),
|
|
374
|
+
hidden: Schema7.Boolean.pipe(optional).annotate({
|
|
375
|
+
description: "Skip the interactive authentication prompt and use the default unless an answer is supplied"
|
|
376
|
+
}),
|
|
377
|
+
when: Schema7.Array(When).pipe(optional)
|
|
378
|
+
};
|
|
379
|
+
var StringField = Schema7.Struct({
|
|
380
|
+
...FieldBase,
|
|
381
|
+
type: Schema7.Literal("string"),
|
|
382
|
+
format: Schema7.Literals(["email", "uri", "date", "date-time"]).pipe(optional),
|
|
383
|
+
minLength: NonNegativeInt.pipe(optional),
|
|
384
|
+
maxLength: NonNegativeInt.pipe(optional),
|
|
385
|
+
pattern: Schema7.String.pipe(optional),
|
|
386
|
+
placeholder: Schema7.String.pipe(optional),
|
|
387
|
+
default: Schema7.String.pipe(optional),
|
|
388
|
+
options: Schema7.Array(Option2).pipe(optional),
|
|
389
|
+
custom: Schema7.Boolean.pipe(optional)
|
|
390
|
+
}).annotate({ identifier: "Form.StringField" });
|
|
391
|
+
var NumberField = Schema7.Struct({
|
|
392
|
+
...FieldBase,
|
|
393
|
+
type: Schema7.Literal("number"),
|
|
394
|
+
minimum: Schema7.Number.pipe(optional),
|
|
395
|
+
maximum: Schema7.Number.pipe(optional),
|
|
396
|
+
default: Schema7.Number.pipe(optional)
|
|
397
|
+
}).annotate({ identifier: "Form.NumberField" });
|
|
398
|
+
var IntegerField = Schema7.Struct({
|
|
399
|
+
...FieldBase,
|
|
400
|
+
type: Schema7.Literal("integer"),
|
|
401
|
+
minimum: Schema7.Number.pipe(optional),
|
|
402
|
+
maximum: Schema7.Number.pipe(optional),
|
|
403
|
+
default: Schema7.Number.pipe(optional)
|
|
404
|
+
}).annotate({ identifier: "Form.IntegerField" });
|
|
405
|
+
var BooleanField = Schema7.Struct({
|
|
406
|
+
...FieldBase,
|
|
407
|
+
type: Schema7.Literal("boolean"),
|
|
408
|
+
default: Schema7.Boolean.pipe(optional)
|
|
409
|
+
}).annotate({ identifier: "Form.BooleanField" });
|
|
410
|
+
var MultiselectField = Schema7.Struct({
|
|
411
|
+
...FieldBase,
|
|
412
|
+
type: Schema7.Literal("multiselect"),
|
|
413
|
+
options: Schema7.Array(Option2),
|
|
414
|
+
minItems: NonNegativeInt.pipe(optional),
|
|
415
|
+
maxItems: NonNegativeInt.pipe(optional),
|
|
416
|
+
custom: Schema7.Boolean.pipe(optional),
|
|
417
|
+
default: Schema7.Array(Schema7.String).pipe(optional)
|
|
418
|
+
}).annotate({ identifier: "Form.MultiselectField" });
|
|
419
|
+
var ExternalField = Schema7.Struct({
|
|
420
|
+
key: Schema7.String,
|
|
421
|
+
type: Schema7.Literal("external"),
|
|
422
|
+
url: Schema7.String,
|
|
423
|
+
title: Schema7.String.pipe(optional),
|
|
424
|
+
description: Schema7.String.pipe(optional)
|
|
425
|
+
}).annotate({ identifier: "Form.ExternalField" });
|
|
426
|
+
var Field = Schema7.Union([
|
|
427
|
+
StringField,
|
|
428
|
+
NumberField,
|
|
429
|
+
IntegerField,
|
|
430
|
+
BooleanField,
|
|
431
|
+
MultiselectField,
|
|
432
|
+
ExternalField
|
|
433
|
+
]).pipe(Schema7.toTaggedUnion("type"), Schema7.annotate({ identifier: "Form.Field" }));
|
|
434
|
+
var Fields = Schema7.NonEmptyArray(Field).annotate({ identifier: "Form.Fields" });
|
|
435
|
+
var InfoBase = {
|
|
436
|
+
id: ID2,
|
|
437
|
+
// This should be typed as SessionID. It is a plain string only because MCP elicitation
|
|
438
|
+
// temporarily needs the `"global"` sentinel owner, which is not a real session. Once
|
|
439
|
+
// elicitations can be attributed to real sessions, revert this to SessionID. Do not rely
|
|
440
|
+
// on non-session owners anywhere else.
|
|
441
|
+
sessionID: Schema7.String,
|
|
442
|
+
title: Schema7.String,
|
|
443
|
+
metadata: Metadata.pipe(optional)
|
|
444
|
+
};
|
|
445
|
+
var Info2 = Schema7.Struct({
|
|
446
|
+
...InfoBase,
|
|
447
|
+
fields: Fields
|
|
448
|
+
}).annotate({ identifier: "Form.Info" });
|
|
449
|
+
var Value = Schema7.Union([Schema7.String, Schema7.Number, Schema7.Boolean, Schema7.Array(Schema7.String)]).annotate({
|
|
450
|
+
identifier: "Form.Value"
|
|
451
|
+
});
|
|
452
|
+
var Answer = Schema7.Record(Schema7.String, Value).annotate({ identifier: "Form.Answer" });
|
|
453
|
+
var State = Schema7.Union([
|
|
454
|
+
Schema7.Struct({ status: Schema7.Literal("pending") }),
|
|
455
|
+
Schema7.Struct({ status: Schema7.Literal("answered"), answer: Answer }),
|
|
456
|
+
// A message tells the asker why nobody answered, e.g. a non-interactive client.
|
|
457
|
+
Schema7.Struct({ status: Schema7.Literal("cancelled"), message: Schema7.String.pipe(optional) })
|
|
458
|
+
]).pipe(Schema7.toTaggedUnion("status")).annotate({ identifier: "Form.State" });
|
|
459
|
+
var Detail = Schema7.Struct({
|
|
460
|
+
...Info2.fields,
|
|
461
|
+
state: State
|
|
462
|
+
}).annotate({ identifier: "Form.Detail" });
|
|
463
|
+
var Reply = Schema7.Struct({
|
|
464
|
+
answer: Answer
|
|
465
|
+
}).annotate({ identifier: "Form.Reply" });
|
|
466
|
+
var Created = ephemeral({ type: "form.created", schema: { form: Info2 } });
|
|
467
|
+
var Replied = ephemeral({ type: "form.replied", schema: { id: ID2, sessionID: Schema7.String, answer: Answer } });
|
|
468
|
+
var Cancelled = ephemeral({ type: "form.cancelled", schema: { id: ID2, sessionID: Schema7.String } });
|
|
469
|
+
var Event = { Created, Replied, Cancelled, Definitions: inventory(Created, Replied, Cancelled) };
|
|
470
|
+
|
|
471
|
+
// node_modules/@opencode/schema/dist/credential.js
|
|
472
|
+
var ID3 = Schema8.String.pipe(Schema8.brand("Credential.ID"), Schema8.annotate({ identifier: "Credential.ID" }), statics((schema) => ({ create: () => schema.make("cred_" + ascending()) })));
|
|
473
|
+
var Updated = ephemeral({
|
|
474
|
+
type: "credential.updated",
|
|
475
|
+
schema: {}
|
|
476
|
+
});
|
|
477
|
+
var Switched = ephemeral({
|
|
478
|
+
type: "credential.switched",
|
|
479
|
+
schema: { integrationID: IntegrationID, credentialID: Schema8.NullOr(ID3) }
|
|
480
|
+
});
|
|
481
|
+
var Event2 = {
|
|
482
|
+
Updated,
|
|
483
|
+
Switched,
|
|
484
|
+
Definitions: inventory(Updated, Switched)
|
|
485
|
+
};
|
|
486
|
+
var OAuth = Schema8.Struct({
|
|
487
|
+
type: Schema8.Literal("oauth"),
|
|
488
|
+
methodID: IntegrationMethodID,
|
|
489
|
+
refresh: Schema8.String,
|
|
490
|
+
access: Schema8.String,
|
|
491
|
+
expires: NonNegativeInt,
|
|
492
|
+
metadata: optional(Schema8.Record(Schema8.String, Schema8.Unknown))
|
|
493
|
+
}).annotate({ identifier: "Credential.OAuth" });
|
|
494
|
+
var Key = Schema8.Struct({
|
|
495
|
+
type: Schema8.Literal("key"),
|
|
496
|
+
key: Schema8.String,
|
|
497
|
+
metadata: optional(Schema8.Record(Schema8.String, Schema8.Unknown)),
|
|
498
|
+
configuration: optional(form_exports.Answer)
|
|
499
|
+
}).annotate({ identifier: "Credential.Key" });
|
|
500
|
+
var External = Schema8.Struct({
|
|
501
|
+
type: Schema8.Literal("external"),
|
|
502
|
+
methodID: IntegrationMethodID,
|
|
503
|
+
metadata: optional(Schema8.Record(Schema8.String, Schema8.Unknown))
|
|
504
|
+
}).annotate({ identifier: "Credential.External" });
|
|
505
|
+
var Value2 = Schema8.Union([OAuth, Key, External]).pipe(Schema8.toTaggedUnion("type")).annotate({ identifier: "Credential.Value" });
|
|
506
|
+
var Entry = Schema8.Struct({
|
|
507
|
+
id: ID3,
|
|
508
|
+
integrationID: IntegrationID,
|
|
509
|
+
label: Schema8.String,
|
|
510
|
+
active: Schema8.Boolean,
|
|
511
|
+
value: Value2
|
|
512
|
+
}).annotate({ identifier: "Credential.Entry" });
|
|
513
|
+
var CreateInput = Schema8.Struct({
|
|
514
|
+
id: optional(ID3),
|
|
515
|
+
integrationID: IntegrationID,
|
|
516
|
+
label: optional(Schema8.String),
|
|
517
|
+
value: Value2,
|
|
518
|
+
activate: optional(Schema8.Boolean)
|
|
519
|
+
}).annotate({ identifier: "Credential.CreateInput" });
|
|
520
|
+
|
|
521
|
+
// node_modules/@opencode/schema/dist/connection.js
|
|
522
|
+
var Status = Schema9.Struct({
|
|
523
|
+
status: Schema9.Literals(["needs_auth"]),
|
|
524
|
+
message: Schema9.String,
|
|
525
|
+
url: optional(Schema9.String)
|
|
526
|
+
}).annotate({ identifier: "Connection.Status" });
|
|
527
|
+
var CredentialInfo = Schema9.Struct({
|
|
528
|
+
type: Schema9.Literal("credential"),
|
|
529
|
+
id: credential_exports.ID,
|
|
530
|
+
label: Schema9.String,
|
|
531
|
+
/** Whether the connection stores a key, an OAuth grant, or an external credential-source reference. */
|
|
532
|
+
method: Schema9.Literals(["key", "oauth", "external"]),
|
|
533
|
+
status: optional(Status)
|
|
534
|
+
}).annotate({ identifier: "Connection.CredentialInfo" });
|
|
535
|
+
var EnvInfo = Schema9.Struct({
|
|
536
|
+
type: Schema9.Literal("env"),
|
|
537
|
+
name: Schema9.String,
|
|
538
|
+
status: optional(Status)
|
|
539
|
+
}).annotate({ identifier: "Connection.EnvInfo" });
|
|
540
|
+
var Info3 = Schema9.Union([CredentialInfo, EnvInfo]).pipe(Schema9.toTaggedUnion("type")).annotate({ identifier: "Connection.Info" });
|
|
541
|
+
|
|
542
|
+
// node_modules/@opencode/schema/dist/integration.js
|
|
543
|
+
var ID4 = IntegrationID;
|
|
544
|
+
var MethodID = IntegrationMethodID;
|
|
545
|
+
var OAuthMethod = Schema10.Struct({
|
|
546
|
+
id: MethodID,
|
|
547
|
+
type: Schema10.Literal("oauth"),
|
|
548
|
+
label: Schema10.String,
|
|
549
|
+
form: optional(form_exports.Fields)
|
|
550
|
+
}).annotate({ identifier: "Integration.OAuthMethod" });
|
|
551
|
+
var CommandMethod = Schema10.Struct({
|
|
552
|
+
id: MethodID,
|
|
553
|
+
type: Schema10.Literal("command"),
|
|
554
|
+
label: Schema10.String,
|
|
555
|
+
command: Schema10.Array(Schema10.String)
|
|
556
|
+
}).annotate({ identifier: "Integration.CommandMethod" });
|
|
557
|
+
var KeyMethod = Schema10.Struct({
|
|
558
|
+
type: Schema10.Literal("key"),
|
|
559
|
+
label: optional(Schema10.String),
|
|
560
|
+
form: optional(form_exports.Fields)
|
|
561
|
+
}).annotate({ identifier: "Integration.KeyMethod" });
|
|
562
|
+
var ExternalMethod = Schema10.Struct({
|
|
563
|
+
id: MethodID,
|
|
564
|
+
type: Schema10.Literal("external"),
|
|
565
|
+
label: Schema10.String,
|
|
566
|
+
form: optional(form_exports.Fields)
|
|
567
|
+
}).annotate({ identifier: "Integration.ExternalMethod" });
|
|
568
|
+
var EnvMethod = Schema10.Struct({
|
|
569
|
+
type: Schema10.Literal("env"),
|
|
570
|
+
names: Schema10.Array(Schema10.String)
|
|
571
|
+
}).annotate({ identifier: "Integration.EnvMethod" });
|
|
572
|
+
var Method = Schema10.Union([OAuthMethod, CommandMethod, KeyMethod, ExternalMethod, EnvMethod]).pipe(Schema10.toTaggedUnion("type")).annotate({ identifier: "Integration.Method" });
|
|
573
|
+
var Updated2 = ephemeral({
|
|
574
|
+
type: "integration.updated",
|
|
575
|
+
schema: {}
|
|
576
|
+
});
|
|
577
|
+
var Event3 = { Updated: Updated2, Definitions: inventory(Updated2) };
|
|
578
|
+
var Ref2 = Schema10.Struct({
|
|
579
|
+
id: ID4,
|
|
580
|
+
name: Schema10.String,
|
|
581
|
+
metadata: optional(Schema10.Record(Schema10.String, Schema10.Any))
|
|
582
|
+
}).annotate({ identifier: "Integration.Ref" });
|
|
583
|
+
var Info4 = Schema10.Struct({
|
|
584
|
+
id: ID4,
|
|
585
|
+
name: Schema10.String,
|
|
586
|
+
metadata: optional(Schema10.Record(Schema10.String, Schema10.Any)),
|
|
587
|
+
methods: Schema10.Array(Method),
|
|
588
|
+
connections: Schema10.Array(connection_exports.Info)
|
|
589
|
+
}).annotate({ identifier: "Integration.Info" });
|
|
590
|
+
var AttemptID = Schema10.String.pipe(Schema10.brand("Integration.AttemptID"), Schema10.annotate({ identifier: "Integration.AttemptID" }), statics((schema) => ({ create: () => schema.make("con_" + ascending()) })));
|
|
591
|
+
var AttemptTime = Schema10.Struct({
|
|
592
|
+
created: Schema10.Number,
|
|
593
|
+
expires: Schema10.Number
|
|
594
|
+
});
|
|
595
|
+
var Attempt = class extends Schema10.Class("Integration.Attempt")({
|
|
596
|
+
attemptID: AttemptID,
|
|
597
|
+
url: Schema10.String,
|
|
598
|
+
instructions: Schema10.String,
|
|
599
|
+
mode: Schema10.Literals(["auto", "code"]),
|
|
600
|
+
time: AttemptTime
|
|
601
|
+
}) {
|
|
602
|
+
};
|
|
603
|
+
var AttemptStatus = Schema10.Union([
|
|
604
|
+
Schema10.Struct({ status: Schema10.Literal("pending"), time: AttemptTime }),
|
|
605
|
+
Schema10.Struct({ status: Schema10.Literal("complete"), time: AttemptTime }),
|
|
606
|
+
Schema10.Struct({ status: Schema10.Literal("failed"), message: Schema10.String, time: AttemptTime }),
|
|
607
|
+
Schema10.Struct({ status: Schema10.Literal("expired"), time: AttemptTime })
|
|
608
|
+
]).pipe(Schema10.toTaggedUnion("status")).annotate({ identifier: "Integration.AttemptStatus" });
|
|
609
|
+
var CommandAttempt = Schema10.Struct({
|
|
610
|
+
attemptID: AttemptID,
|
|
611
|
+
time: AttemptTime
|
|
612
|
+
}).annotate({ identifier: "Integration.CommandAttempt" });
|
|
613
|
+
var CommandAttemptStatus = Schema10.Union([
|
|
614
|
+
Schema10.Struct({ status: Schema10.Literal("pending"), message: optional(Schema10.String), time: AttemptTime }),
|
|
615
|
+
Schema10.Struct({ status: Schema10.Literal("complete"), time: AttemptTime }),
|
|
616
|
+
Schema10.Struct({ status: Schema10.Literal("failed"), message: Schema10.String, time: AttemptTime }),
|
|
617
|
+
Schema10.Struct({ status: Schema10.Literal("expired"), time: AttemptTime })
|
|
618
|
+
]).pipe(Schema10.toTaggedUnion("status")).annotate({ identifier: "Integration.CommandAttemptStatus" });
|
|
619
|
+
|
|
620
|
+
// node_modules/@opencode/schema/dist/model-compatibility.js
|
|
621
|
+
import { Schema as Schema11, Struct as Struct2 } from "effect";
|
|
622
|
+
var ReasoningField = Schema11.Union([
|
|
623
|
+
Schema11.Literals(["reasoning", "reasoning_content", "reasoning_text"]),
|
|
624
|
+
Schema11.String
|
|
625
|
+
]).annotate({ identifier: "Model.ReasoningField" });
|
|
626
|
+
var MaxTokensField = Schema11.Literals(["max_completion_tokens", "max_tokens"]).annotate({
|
|
627
|
+
identifier: "Model.MaxTokensField"
|
|
628
|
+
});
|
|
629
|
+
var CacheFormat = Schema11.Literals(["anthropic", "alibaba"]).annotate({ identifier: "Model.CacheFormat" });
|
|
630
|
+
var Compatibility = Schema11.Struct({
|
|
631
|
+
reasoningField: ReasoningField.pipe(optional),
|
|
632
|
+
/** Require every assistant message to include its reasoning field, even when empty. */
|
|
633
|
+
requireReasoning: Schema11.Boolean.pipe(optional),
|
|
634
|
+
maxTokensField: MaxTokensField.pipe(optional),
|
|
635
|
+
requireFinishReason: Schema11.Boolean.pipe(optional),
|
|
636
|
+
requireAssistantAfterTool: Schema11.Boolean.pipe(optional),
|
|
637
|
+
supportsPromptCacheKey: Schema11.Boolean.pipe(optional),
|
|
638
|
+
/** Prompt-cache marker syntax the endpoint accepts. Overrides the route default; both send `cache_control`, and `alibaba` skips tool definitions. */
|
|
639
|
+
cacheFormat: CacheFormat.pipe(optional),
|
|
640
|
+
/** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
|
|
641
|
+
supportsThinkingBlockBinding: Schema11.Boolean.pipe(optional),
|
|
642
|
+
/** Supports per-message effort updates. Overrides model-ID detection. */
|
|
643
|
+
supportsEffortUpdates: Schema11.Boolean.pipe(optional)
|
|
644
|
+
}).annotate({ identifier: "Model.Compatibility" });
|
|
645
|
+
var ProviderCompatibility = Schema11.Struct(Struct2.omit(Compatibility.fields, ["supportsThinkingBlockBinding", "supportsEffortUpdates"])).annotate({ identifier: "Provider.Compatibility" });
|
|
646
|
+
|
|
647
|
+
// node_modules/@opencode/schema/dist/provider.js
|
|
648
|
+
var ID5 = Schema12.String.pipe(Schema12.brand("Provider.ID"), Schema12.annotate({ identifier: "Provider.ID" }), statics((schema) => ({
|
|
649
|
+
opencode: schema.make("opencode"),
|
|
650
|
+
anthropic: schema.make("anthropic"),
|
|
651
|
+
openai: schema.make("openai"),
|
|
652
|
+
google: schema.make("google"),
|
|
653
|
+
googleVertex: schema.make("google-vertex"),
|
|
654
|
+
githubCopilot: schema.make("github-copilot"),
|
|
655
|
+
amazonBedrock: schema.make("amazon-bedrock"),
|
|
656
|
+
azure: schema.make("azure"),
|
|
657
|
+
openrouter: schema.make("openrouter"),
|
|
658
|
+
mistral: schema.make("mistral"),
|
|
659
|
+
gitlab: schema.make("gitlab")
|
|
660
|
+
})));
|
|
661
|
+
var Updated3 = ephemeral({ type: "provider.updated", schema: {} });
|
|
662
|
+
var Event4 = { Updated: Updated3, Definitions: inventory(Updated3) };
|
|
663
|
+
var Package = Schema12.String;
|
|
664
|
+
var Activation = Schema12.Literals(["auto", "enabled", "disabled"]);
|
|
665
|
+
var Compaction = Schema12.Union([
|
|
666
|
+
Schema12.Struct({ type: Schema12.Literal("summary") }),
|
|
667
|
+
Schema12.Struct({ type: Schema12.Literal("native") })
|
|
668
|
+
]).pipe(Schema12.toTaggedUnion("type")).annotate({ identifier: "Provider.Compaction" });
|
|
669
|
+
var Transport = Schema12.Literals(["http", "websocket"]).annotate({ identifier: "Provider.Transport" });
|
|
670
|
+
var Encoding = Schema12.Literals(["zstd", "gzip", "none"]).annotate({ identifier: "Provider.Encoding" });
|
|
671
|
+
var Settings = Schema12.StructWithRest(Schema12.Struct({
|
|
672
|
+
timeout: Schema12.Union([Schema12.Finite, Schema12.Literal(false)]).pipe(optional),
|
|
673
|
+
headerTimeout: Schema12.Union([Schema12.Finite, Schema12.Literal(false)]).pipe(optional),
|
|
674
|
+
chunkTimeout: Schema12.Union([Schema12.Finite, Schema12.Literal(false)]).pipe(optional),
|
|
675
|
+
compaction: Compaction.pipe(optional),
|
|
676
|
+
transport: Transport.pipe(optional),
|
|
677
|
+
encoding: Encoding.pipe(optional)
|
|
678
|
+
}), [Schema12.Record(Schema12.String, Schema12.Any)]).annotate({ identifier: "Provider.Settings" });
|
|
679
|
+
var Overlays = {
|
|
680
|
+
settings: Settings.pipe(optional),
|
|
681
|
+
headers: Schema12.Record(Schema12.String, Schema12.String).pipe(optional),
|
|
682
|
+
body: Schema12.Record(Schema12.String, Schema12.Any).pipe(optional)
|
|
683
|
+
};
|
|
684
|
+
var Request2 = Schema12.Struct({
|
|
685
|
+
settings: Settings.pipe(Schema12.withConstructorDefault(Effect.succeed({}))),
|
|
686
|
+
headers: Schema12.Record(Schema12.String, Schema12.String),
|
|
687
|
+
body: Schema12.Record(Schema12.String, Schema12.Any)
|
|
688
|
+
}).annotate({ identifier: "Provider.Request" });
|
|
689
|
+
var Info5 = Schema12.Struct({
|
|
690
|
+
id: ID5,
|
|
691
|
+
canonical: ID5.pipe(optional),
|
|
692
|
+
integrationID: integration_exports.ID.pipe(optional),
|
|
693
|
+
name: Schema12.String,
|
|
694
|
+
activation: Activation,
|
|
695
|
+
package: Package,
|
|
696
|
+
/** Inherited by every model of this provider; model compatibility overrides individual fields. */
|
|
697
|
+
compatibility: ProviderCompatibility.pipe(optional),
|
|
698
|
+
...Overlays
|
|
699
|
+
}).annotate({ identifier: "Provider.Info" }).pipe(statics(() => ({
|
|
700
|
+
empty: (id) => ({ id, name: id, activation: "auto", package: "" })
|
|
701
|
+
})));
|
|
702
|
+
|
|
703
|
+
// node_modules/@opencode/schema/dist/money.js
|
|
704
|
+
var money_exports = {};
|
|
705
|
+
__export(money_exports, {
|
|
706
|
+
Money: () => money_exports,
|
|
707
|
+
USD: () => USD,
|
|
708
|
+
USDPerMillionTokens: () => USDPerMillionTokens
|
|
709
|
+
});
|
|
710
|
+
import { Schema as Schema13 } from "effect";
|
|
711
|
+
var USD = Schema13.Finite.pipe(Schema13.brand("Money.USD"), Schema13.annotate({ identifier: "Money.USD" }), statics((schema) => ({ zero: schema.make(0) })));
|
|
712
|
+
var USDPerMillionTokens = Schema13.Finite.pipe(Schema13.brand("Money.USDPerMillionTokens"), Schema13.annotate({ identifier: "Money.USDPerMillionTokens" }), statics((schema) => ({ zero: schema.make(0) })));
|
|
713
|
+
|
|
714
|
+
// node_modules/@opencode/schema/dist/model.js
|
|
715
|
+
var ID6 = Schema14.String.pipe(Schema14.brand("Model.ID"));
|
|
716
|
+
var Updated4 = ephemeral({ type: "model.updated", schema: {} });
|
|
717
|
+
var Event5 = { Updated: Updated4, Definitions: inventory(Updated4) };
|
|
718
|
+
var VariantID = Schema14.String.pipe(Schema14.brand("Model.VariantID"));
|
|
719
|
+
var Ref3 = Schema14.Struct({
|
|
720
|
+
id: ID6,
|
|
721
|
+
providerID: provider_exports.ID,
|
|
722
|
+
variant: VariantID.pipe(optional)
|
|
723
|
+
}).annotate({ identifier: "Model.Ref" }).pipe(statics((schema) => ({
|
|
724
|
+
parse: (input) => {
|
|
725
|
+
const providerEnd = input.indexOf("/");
|
|
726
|
+
if (providerEnd <= 0)
|
|
727
|
+
throw new Error(`Invalid model reference: ${input}`);
|
|
728
|
+
const providerID = input.slice(0, providerEnd);
|
|
729
|
+
const variantStart = input.indexOf("#", providerEnd + 1);
|
|
730
|
+
const id = input.slice(providerEnd + 1, variantStart === -1 ? void 0 : variantStart);
|
|
731
|
+
const variant = variantStart === -1 ? void 0 : input.slice(variantStart + 1);
|
|
732
|
+
if (!id || providerID.includes("#") || variant !== void 0 && (!variant || variant.includes("#")))
|
|
733
|
+
throw new Error(`Invalid model reference: ${input}`);
|
|
734
|
+
return schema.make({
|
|
735
|
+
providerID: provider_exports.ID.make(providerID),
|
|
736
|
+
id: ID6.make(id),
|
|
737
|
+
...variant ? { variant: VariantID.make(variant) } : {}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
})));
|
|
741
|
+
var Family = Schema14.String.pipe(Schema14.brand("Model.Family"));
|
|
742
|
+
var Settings2 = Schema14.StructWithRest(
|
|
743
|
+
Schema14.Struct({
|
|
744
|
+
compaction: provider_exports.Compaction.pipe(optional),
|
|
745
|
+
encoding: provider_exports.Encoding.pipe(optional)
|
|
746
|
+
}),
|
|
747
|
+
// Provider packages may define arbitrary model-level options beyond OpenCode's shared compaction policy.
|
|
748
|
+
[Schema14.Record(Schema14.String, Schema14.Any)]
|
|
749
|
+
).annotate({ identifier: "Model.Settings" });
|
|
750
|
+
var Overlays2 = {
|
|
751
|
+
settings: Settings2.pipe(optional),
|
|
752
|
+
headers: Schema14.Record(Schema14.String, Schema14.String).pipe(optional),
|
|
753
|
+
body: Schema14.Record(Schema14.String, Schema14.Any).pipe(optional)
|
|
754
|
+
};
|
|
755
|
+
var Capabilities = Schema14.Struct({
|
|
756
|
+
tools: Schema14.Boolean,
|
|
757
|
+
input: Schema14.Array(Schema14.String),
|
|
758
|
+
output: Schema14.Array(Schema14.String)
|
|
759
|
+
}).annotate({ identifier: "Model.Capabilities" }).pipe(statics(() => ({
|
|
760
|
+
default: () => ({ tools: true, input: ["text", "image"], output: ["text"] })
|
|
761
|
+
})));
|
|
762
|
+
var Cost = Schema14.Struct({
|
|
763
|
+
tier: Schema14.Struct({
|
|
764
|
+
type: Schema14.tag("context"),
|
|
765
|
+
size: Schema14.Int
|
|
766
|
+
}).pipe(optional),
|
|
767
|
+
input: money_exports.USDPerMillionTokens,
|
|
768
|
+
output: money_exports.USDPerMillionTokens,
|
|
769
|
+
cache: Schema14.Struct({
|
|
770
|
+
read: money_exports.USDPerMillionTokens,
|
|
771
|
+
write: money_exports.USDPerMillionTokens
|
|
772
|
+
})
|
|
773
|
+
}).annotate({ identifier: "Model.Cost" });
|
|
774
|
+
var Variant = Schema14.Struct({
|
|
775
|
+
id: VariantID,
|
|
776
|
+
...Overlays2
|
|
777
|
+
}).annotate({ identifier: "Model.Variant" });
|
|
778
|
+
var Info6 = Schema14.Struct({
|
|
779
|
+
id: ID6,
|
|
780
|
+
modelID: ID6,
|
|
781
|
+
providerID: provider_exports.ID,
|
|
782
|
+
canonical: provider_exports.ID.pipe(optional),
|
|
783
|
+
family: Family.pipe(optional),
|
|
784
|
+
name: Schema14.String,
|
|
785
|
+
compatibility: Compatibility.pipe(optional),
|
|
786
|
+
package: provider_exports.Package.pipe(optional),
|
|
787
|
+
...Overlays2,
|
|
788
|
+
capabilities: Capabilities,
|
|
789
|
+
variants: Schema14.Array(Variant),
|
|
790
|
+
time: Schema14.Struct({
|
|
791
|
+
released: Schema14.Finite
|
|
792
|
+
}),
|
|
793
|
+
cost: Schema14.Array(Cost),
|
|
794
|
+
status: Schema14.Literals(["alpha", "beta", "deprecated", "active"]),
|
|
795
|
+
enabled: Schema14.Boolean,
|
|
796
|
+
limit: Schema14.Struct({
|
|
797
|
+
context: Schema14.Int,
|
|
798
|
+
input: Schema14.Int.pipe(optional),
|
|
799
|
+
output: Schema14.Int
|
|
800
|
+
})
|
|
801
|
+
}).annotate({ identifier: "Model.Info" }).pipe(statics(() => ({
|
|
802
|
+
default: (providerID, id) => ({
|
|
803
|
+
id,
|
|
804
|
+
modelID: id,
|
|
805
|
+
providerID,
|
|
806
|
+
name: id,
|
|
807
|
+
capabilities: Capabilities.default(),
|
|
808
|
+
variants: [],
|
|
809
|
+
time: { released: 0 },
|
|
810
|
+
cost: [],
|
|
811
|
+
status: "active",
|
|
812
|
+
enabled: true,
|
|
813
|
+
limit: { context: 2e5, output: 32e3 }
|
|
814
|
+
})
|
|
815
|
+
})));
|
|
816
|
+
|
|
817
|
+
// node_modules/@opencode/schema/dist/permission.js
|
|
818
|
+
var permission_exports = {};
|
|
819
|
+
__export(permission_exports, {
|
|
820
|
+
Effect: () => Effect2,
|
|
821
|
+
Event: () => Event6,
|
|
822
|
+
ID: () => ID7,
|
|
823
|
+
Permission: () => permission_exports,
|
|
824
|
+
Reply: () => Reply2,
|
|
825
|
+
Request: () => Request3,
|
|
826
|
+
Rule: () => Rule,
|
|
827
|
+
Ruleset: () => Ruleset,
|
|
828
|
+
Source: () => Source
|
|
829
|
+
});
|
|
830
|
+
import { Schema as Schema16 } from "effect";
|
|
831
|
+
|
|
832
|
+
// node_modules/@opencode/schema/dist/session-id.js
|
|
833
|
+
import { Schema as Schema15 } from "effect";
|
|
834
|
+
var SessionID = Schema15.String.check(Schema15.isStartingWith("ses")).pipe(Schema15.brand("SessionID"), Schema15.annotate({ identifier: "Session.ID" }), statics((schema) => {
|
|
835
|
+
const create2 = () => schema.make("ses_" + descending());
|
|
836
|
+
return {
|
|
837
|
+
create: create2,
|
|
838
|
+
descending: (id) => id === void 0 ? create2() : schema.make(id)
|
|
839
|
+
};
|
|
840
|
+
}));
|
|
841
|
+
|
|
842
|
+
// node_modules/@opencode/schema/dist/permission.js
|
|
843
|
+
var ID7 = Schema16.String.check(Schema16.isStartingWith("per")).pipe(Schema16.brand("Permission.ID"), Schema16.annotate({ identifier: "Permission.ID" }), statics((schema) => ({ create: (id) => schema.make(id ?? "per_" + ascending()) })));
|
|
844
|
+
var Source = Schema16.Union([
|
|
845
|
+
Schema16.Struct({
|
|
846
|
+
type: Schema16.Literal("tool"),
|
|
847
|
+
messageID: Schema16.String,
|
|
848
|
+
id: Schema16.String
|
|
849
|
+
})
|
|
850
|
+
]).annotate({ identifier: "Permission.Source" });
|
|
851
|
+
var RequestFields = {
|
|
852
|
+
sessionID: SessionID,
|
|
853
|
+
action: Schema16.String,
|
|
854
|
+
resources: Schema16.Array(Schema16.String),
|
|
855
|
+
save: Schema16.Array(Schema16.String).pipe(optional),
|
|
856
|
+
metadata: Schema16.Record(Schema16.String, Schema16.Unknown).pipe(optional),
|
|
857
|
+
source: Source.pipe(optional),
|
|
858
|
+
message: Schema16.String.pipe(optional)
|
|
859
|
+
};
|
|
860
|
+
var Request3 = Schema16.Struct({
|
|
861
|
+
id: ID7,
|
|
862
|
+
...RequestFields
|
|
863
|
+
}).annotate({ identifier: "Permission.Request" });
|
|
864
|
+
var Reply2 = Schema16.Literals(["once", "always", "reject"]).annotate({ identifier: "Permission.Reply" });
|
|
865
|
+
var Asked = ephemeral({ type: "permission.asked", schema: Request3.fields });
|
|
866
|
+
var Replied2 = ephemeral({
|
|
867
|
+
type: "permission.replied",
|
|
868
|
+
schema: {
|
|
869
|
+
sessionID: SessionID,
|
|
870
|
+
requestID: ID7,
|
|
871
|
+
reply: Reply2
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
var Event6 = { Asked, Replied: Replied2, Definitions: inventory(Asked, Replied2) };
|
|
875
|
+
var Effect2 = Schema16.Literals(["allow", "deny", "ask"]).annotate({ identifier: "Permission.Effect" });
|
|
876
|
+
var Rule = Schema16.Struct({
|
|
877
|
+
action: Schema16.String,
|
|
878
|
+
resource: Schema16.String,
|
|
879
|
+
effect: Effect2
|
|
880
|
+
}).annotate({ identifier: "Permission.Rule" });
|
|
881
|
+
var Ruleset = Schema16.Array(Rule).annotate({ identifier: "Permission.Ruleset" });
|
|
882
|
+
|
|
883
|
+
// node_modules/@opencode/schema/dist/agent.js
|
|
884
|
+
var Updated5 = ephemeral({ type: "agent.updated", schema: {} });
|
|
885
|
+
var ID8 = Schema17.String.pipe(Schema17.brand("Agent.ID"), Schema17.annotate({ identifier: "Agent.ID" }));
|
|
886
|
+
var Name = Schema17.String.pipe(Schema17.brand("Agent.Name"));
|
|
887
|
+
var Color = Schema17.String.annotate({ identifier: "Agent.Color" });
|
|
888
|
+
var Info7 = Schema17.Struct({
|
|
889
|
+
id: ID8,
|
|
890
|
+
name: Name,
|
|
891
|
+
model: model_exports.Ref.pipe(optional),
|
|
892
|
+
request: provider_exports.Request,
|
|
893
|
+
system: Schema17.String.pipe(optional),
|
|
894
|
+
description: Schema17.String.pipe(optional),
|
|
895
|
+
mode: Schema17.Literals(["subagent", "primary", "all"]),
|
|
896
|
+
hidden: Schema17.Boolean,
|
|
897
|
+
color: Color.pipe(optional),
|
|
898
|
+
steps: PositiveInt.pipe(optional),
|
|
899
|
+
permissions: permission_exports.Ruleset
|
|
900
|
+
}).annotate({ identifier: "Agent.Info" }).pipe(statics(() => ({
|
|
901
|
+
default: (id) => ({
|
|
902
|
+
id,
|
|
903
|
+
name: Name.make(id),
|
|
904
|
+
request: { settings: {}, headers: {}, body: {} },
|
|
905
|
+
mode: "primary",
|
|
906
|
+
hidden: false,
|
|
907
|
+
permissions: [
|
|
908
|
+
{ action: "*", resource: "*", effect: "allow" },
|
|
909
|
+
{ action: "read", resource: "*.env", effect: "ask" },
|
|
910
|
+
{ action: "read", resource: "*.env.*", effect: "ask" },
|
|
911
|
+
{ action: "read", resource: "*.env.example", effect: "allow" }
|
|
912
|
+
]
|
|
913
|
+
})
|
|
914
|
+
})));
|
|
915
|
+
var Event7 = {
|
|
916
|
+
Updated: Updated5,
|
|
917
|
+
Definitions: inventory(Updated5)
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
// node_modules/@opencode/schema/dist/command.js
|
|
921
|
+
import { Schema as Schema18 } from "effect";
|
|
922
|
+
var Updated6 = ephemeral({ type: "command.updated", schema: {} });
|
|
923
|
+
var Info8 = Schema18.Struct({
|
|
924
|
+
name: Schema18.String,
|
|
925
|
+
description: Schema18.String.pipe(optional)
|
|
926
|
+
}).annotate({ identifier: "Command.Info" });
|
|
927
|
+
var Event8 = {
|
|
928
|
+
Updated: Updated6,
|
|
929
|
+
Definitions: inventory(Updated6)
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
// node_modules/@opencode/schema/dist/mcp.js
|
|
933
|
+
import { Schema as Schema19 } from "effect";
|
|
934
|
+
var TimeoutConfig = class extends Schema19.Class("Mcp.TimeoutConfig")({
|
|
935
|
+
startup: PositiveInt.pipe(optional).annotate({
|
|
936
|
+
description: "Maximum time in milliseconds to establish and initialize the MCP server."
|
|
937
|
+
}),
|
|
938
|
+
catalog: PositiveInt.pipe(optional).annotate({
|
|
939
|
+
description: "Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list."
|
|
940
|
+
}),
|
|
941
|
+
execution: PositiveInt.pipe(optional).annotate({
|
|
942
|
+
description: "Maximum time in milliseconds to wait for MCP tool and prompt execution."
|
|
943
|
+
})
|
|
944
|
+
}) {
|
|
945
|
+
};
|
|
946
|
+
var Protocol = Schema19.Literals(["legacy", "auto", "2026-07-28"]).annotate({
|
|
947
|
+
identifier: "Mcp.Protocol",
|
|
948
|
+
description: 'MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.'
|
|
949
|
+
});
|
|
950
|
+
var LocalConfig = class extends Schema19.Class("Mcp.LocalConfig")({
|
|
951
|
+
type: Schema19.Literal("local"),
|
|
952
|
+
command: Schema19.String.pipe(Schema19.Array),
|
|
953
|
+
cwd: Schema19.String.pipe(optional).annotate({
|
|
954
|
+
description: "Working directory for the MCP server process. Relative paths resolve from the workspace directory."
|
|
955
|
+
}),
|
|
956
|
+
environment: Schema19.Record(Schema19.String, Schema19.String).pipe(optional),
|
|
957
|
+
disabled: Schema19.Boolean.pipe(optional),
|
|
958
|
+
codemode: Schema19.Boolean.pipe(optional).annotate({
|
|
959
|
+
description: "Expose this server's tools through Code Mode. Defaults to true."
|
|
960
|
+
}),
|
|
961
|
+
timeout: TimeoutConfig.pipe(optional),
|
|
962
|
+
protocol: Protocol.pipe(optional)
|
|
963
|
+
}) {
|
|
964
|
+
};
|
|
965
|
+
var OAuthConfig = class extends Schema19.Class("Mcp.OAuthConfig")({
|
|
966
|
+
client_id: Schema19.String.pipe(optional),
|
|
967
|
+
client_secret: Schema19.String.pipe(optional),
|
|
968
|
+
scope: Schema19.String.pipe(optional),
|
|
969
|
+
callback_port: Schema19.Int.check(Schema19.isBetween({ minimum: 1, maximum: 65535 })).pipe(optional),
|
|
970
|
+
redirect_uri: Schema19.String.pipe(optional),
|
|
971
|
+
auth_server_metadata_url: Schema19.String.pipe(optional).annotate({
|
|
972
|
+
description: "URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server."
|
|
973
|
+
})
|
|
974
|
+
}) {
|
|
975
|
+
};
|
|
976
|
+
var RemoteConfig = class extends Schema19.Class("Mcp.RemoteConfig")({
|
|
977
|
+
type: Schema19.Literal("remote"),
|
|
978
|
+
url: Schema19.String,
|
|
979
|
+
headers: Schema19.Record(Schema19.String, Schema19.String).pipe(optional),
|
|
980
|
+
oauth: Schema19.Union([OAuthConfig, Schema19.Literal(false)]).pipe(optional),
|
|
981
|
+
disabled: Schema19.Boolean.pipe(optional),
|
|
982
|
+
codemode: Schema19.Boolean.pipe(optional).annotate({
|
|
983
|
+
description: "Expose this server's tools through Code Mode. Defaults to true."
|
|
984
|
+
}),
|
|
985
|
+
timeout: TimeoutConfig.pipe(optional),
|
|
986
|
+
protocol: Protocol.pipe(optional)
|
|
987
|
+
}) {
|
|
988
|
+
};
|
|
989
|
+
var ServerConfig = Schema19.Union([LocalConfig, RemoteConfig]).pipe(Schema19.toTaggedUnion("type"));
|
|
990
|
+
var Connected = Schema19.Struct({ status: Schema19.Literal("connected") }).annotate({
|
|
991
|
+
identifier: "Mcp.Status.Connected"
|
|
992
|
+
});
|
|
993
|
+
var Pending = Schema19.Struct({ status: Schema19.Literal("pending") }).annotate({
|
|
994
|
+
identifier: "Mcp.Status.Pending"
|
|
995
|
+
});
|
|
996
|
+
var Disabled = Schema19.Struct({ status: Schema19.Literal("disabled") }).annotate({
|
|
997
|
+
identifier: "Mcp.Status.Disabled"
|
|
998
|
+
});
|
|
999
|
+
var Failed = Schema19.Struct({ status: Schema19.Literal("failed"), error: Schema19.String }).annotate({
|
|
1000
|
+
identifier: "Mcp.Status.Failed"
|
|
1001
|
+
});
|
|
1002
|
+
var NeedsAuth = Schema19.Struct({ status: Schema19.Literal("needs_auth"), error: Schema19.String }).annotate({
|
|
1003
|
+
identifier: "Mcp.Status.NeedsAuth"
|
|
1004
|
+
});
|
|
1005
|
+
var Status2 = Schema19.Union([Connected, Pending, Disabled, Failed, NeedsAuth]).pipe(Schema19.toTaggedUnion("status"));
|
|
1006
|
+
var Server = Schema19.Struct({
|
|
1007
|
+
name: Schema19.String,
|
|
1008
|
+
status: Status2,
|
|
1009
|
+
// Set for remote servers registered as OAuth integrations; lets clients act on the right integration
|
|
1010
|
+
// without matching by name, which could collide with provider or plugin integrations.
|
|
1011
|
+
integrationID: optional(IntegrationID)
|
|
1012
|
+
}).annotate({ identifier: "Mcp.Server" });
|
|
1013
|
+
var Resource = Schema19.Struct({
|
|
1014
|
+
server: Schema19.String,
|
|
1015
|
+
name: Schema19.String,
|
|
1016
|
+
uri: Schema19.String,
|
|
1017
|
+
description: optional(Schema19.String),
|
|
1018
|
+
mimeType: optional(Schema19.String)
|
|
1019
|
+
}).annotate({ identifier: "Mcp.Resource" });
|
|
1020
|
+
var ResourceTemplate = Schema19.Struct({
|
|
1021
|
+
server: Schema19.String,
|
|
1022
|
+
name: Schema19.String,
|
|
1023
|
+
uriTemplate: Schema19.String,
|
|
1024
|
+
description: optional(Schema19.String),
|
|
1025
|
+
mimeType: optional(Schema19.String)
|
|
1026
|
+
}).annotate({ identifier: "Mcp.ResourceTemplate" });
|
|
1027
|
+
var ResourceCatalog = Schema19.Struct({
|
|
1028
|
+
resources: Schema19.Array(Resource),
|
|
1029
|
+
templates: Schema19.Array(ResourceTemplate)
|
|
1030
|
+
}).annotate({ identifier: "Mcp.ResourceCatalog" });
|
|
1031
|
+
var ResourceContentPart = Schema19.Union([
|
|
1032
|
+
Schema19.Struct({
|
|
1033
|
+
type: Schema19.Literal("text"),
|
|
1034
|
+
uri: Schema19.String,
|
|
1035
|
+
text: Schema19.String,
|
|
1036
|
+
mimeType: optional(Schema19.String)
|
|
1037
|
+
}),
|
|
1038
|
+
Schema19.Struct({
|
|
1039
|
+
type: Schema19.Literal("blob"),
|
|
1040
|
+
uri: Schema19.String,
|
|
1041
|
+
blob: Schema19.String,
|
|
1042
|
+
mimeType: optional(Schema19.String)
|
|
1043
|
+
})
|
|
1044
|
+
]).pipe(Schema19.toTaggedUnion("type"), Schema19.annotate({ identifier: "Mcp.ResourceContentPart" }));
|
|
1045
|
+
var ResourceContent = Schema19.Struct({
|
|
1046
|
+
server: Schema19.String,
|
|
1047
|
+
uri: Schema19.String,
|
|
1048
|
+
contents: Schema19.Array(ResourceContentPart)
|
|
1049
|
+
}).annotate({ identifier: "Mcp.ResourceContent" });
|
|
1050
|
+
|
|
1051
|
+
// node_modules/@opencode/schema/dist/persistent-pty.js
|
|
1052
|
+
import { Schema as Schema41 } from "effect";
|
|
1053
|
+
|
|
1054
|
+
// node_modules/@opencode/schema/dist/pty.js
|
|
1055
|
+
var pty_exports = {};
|
|
1056
|
+
__export(pty_exports, {
|
|
1057
|
+
CreateInput: () => CreateInput2,
|
|
1058
|
+
Event: () => Event9,
|
|
1059
|
+
ID: () => ID9,
|
|
1060
|
+
Info: () => Info9,
|
|
1061
|
+
Pty: () => pty_exports,
|
|
1062
|
+
UpdateInput: () => UpdateInput
|
|
1063
|
+
});
|
|
1064
|
+
import { Schema as Schema20 } from "effect";
|
|
1065
|
+
var IDSchema2 = Schema20.String.check(Schema20.isStartingWith("pty")).pipe(Schema20.brand("PtyID"), Schema20.annotate({ identifier: "Pty.ID" }));
|
|
1066
|
+
var ID9 = IDSchema2.pipe(statics((schema) => {
|
|
1067
|
+
const create2 = () => schema.make("pty_" + ascending());
|
|
1068
|
+
return {
|
|
1069
|
+
create: create2,
|
|
1070
|
+
ascending: (id) => id === void 0 ? create2() : schema.make(id)
|
|
1071
|
+
};
|
|
1072
|
+
}));
|
|
1073
|
+
var Info9 = Schema20.Struct({
|
|
1074
|
+
id: ID9,
|
|
1075
|
+
title: Schema20.String,
|
|
1076
|
+
command: Schema20.String,
|
|
1077
|
+
args: Schema20.Array(Schema20.String),
|
|
1078
|
+
cwd: Schema20.String,
|
|
1079
|
+
status: Schema20.Literals(["running", "exited"]),
|
|
1080
|
+
pid: NonNegativeInt,
|
|
1081
|
+
exitCode: optional(NonNegativeInt)
|
|
1082
|
+
}).annotate({ identifier: "Pty" });
|
|
1083
|
+
var Created2 = ephemeral({ type: "pty.created", schema: { info: Info9 } });
|
|
1084
|
+
var Updated7 = ephemeral({ type: "pty.updated", schema: { info: Info9 } });
|
|
1085
|
+
var Exited = ephemeral({ type: "pty.exited", schema: { id: ID9, exitCode: NonNegativeInt } });
|
|
1086
|
+
var Deleted = ephemeral({ type: "pty.deleted", schema: { id: ID9 } });
|
|
1087
|
+
var Event9 = { Created: Created2, Updated: Updated7, Exited, Deleted, Definitions: inventory(Created2, Updated7, Exited, Deleted) };
|
|
1088
|
+
var CreateInput2 = Schema20.Struct({
|
|
1089
|
+
command: optional(Schema20.String),
|
|
1090
|
+
args: optional(Schema20.Array(Schema20.String)),
|
|
1091
|
+
cwd: optional(Schema20.String),
|
|
1092
|
+
title: optional(Schema20.String),
|
|
1093
|
+
env: optional(Schema20.Record(Schema20.String, Schema20.String))
|
|
1094
|
+
});
|
|
1095
|
+
var UpdateInput = Schema20.Struct({
|
|
1096
|
+
title: optional(Schema20.String),
|
|
1097
|
+
size: optional(Schema20.Struct({
|
|
1098
|
+
rows: PositiveInt,
|
|
1099
|
+
cols: PositiveInt
|
|
1100
|
+
}))
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
// node_modules/@opencode/schema/dist/session.js
|
|
1104
|
+
var session_exports = {};
|
|
1105
|
+
__export(session_exports, {
|
|
1106
|
+
Event: () => Event13,
|
|
1107
|
+
ForkBoundary: () => ForkBoundary,
|
|
1108
|
+
ID: () => ID15,
|
|
1109
|
+
Info: () => Info19,
|
|
1110
|
+
ListAnchor: () => ListAnchor,
|
|
1111
|
+
Metadata: () => Metadata3,
|
|
1112
|
+
Revert: () => Revert,
|
|
1113
|
+
Session: () => session_exports
|
|
1114
|
+
});
|
|
1115
|
+
import { Schema as Schema40 } from "effect";
|
|
1116
|
+
|
|
1117
|
+
// node_modules/@opencode/schema/dist/project.js
|
|
1118
|
+
var project_exports = {};
|
|
1119
|
+
__export(project_exports, {
|
|
1120
|
+
Commands: () => Commands,
|
|
1121
|
+
Current: () => Current,
|
|
1122
|
+
Event: () => Event10,
|
|
1123
|
+
ID: () => ID10,
|
|
1124
|
+
Icon: () => Icon,
|
|
1125
|
+
Info: () => Info10,
|
|
1126
|
+
Project: () => project_exports,
|
|
1127
|
+
Time: () => Time,
|
|
1128
|
+
UpdateInput: () => UpdateInput2,
|
|
1129
|
+
Vcs: () => Vcs
|
|
1130
|
+
});
|
|
1131
|
+
import { Schema as Schema21 } from "effect";
|
|
1132
|
+
var ID10 = ProjectID;
|
|
1133
|
+
var Vcs = Schema21.String.check(Schema21.isPattern(/^[a-z][a-z0-9._-]*$/u)).annotate({
|
|
1134
|
+
identifier: "Project.Vcs"
|
|
1135
|
+
});
|
|
1136
|
+
var Current = Schema21.Struct({
|
|
1137
|
+
id: ID10,
|
|
1138
|
+
directory: AbsolutePath,
|
|
1139
|
+
canonical: AbsolutePath
|
|
1140
|
+
}).annotate({ identifier: "Project.Current" });
|
|
1141
|
+
var Icon = Schema21.Struct({
|
|
1142
|
+
url: optional(Schema21.String),
|
|
1143
|
+
override: optional(Schema21.String),
|
|
1144
|
+
color: optional(Schema21.String)
|
|
1145
|
+
}).annotate({ identifier: "Project.Icon" });
|
|
1146
|
+
var Commands = Schema21.Struct({
|
|
1147
|
+
start: optional(Schema21.String.annotate({ description: "Startup script to run when creating a new workspace (worktree)" }))
|
|
1148
|
+
}).annotate({ identifier: "Project.Commands" });
|
|
1149
|
+
var Time = Schema21.Struct({
|
|
1150
|
+
created: NonNegativeInt,
|
|
1151
|
+
updated: NonNegativeInt,
|
|
1152
|
+
active: NonNegativeInt,
|
|
1153
|
+
archived: optional(NonNegativeInt)
|
|
1154
|
+
}).annotate({ identifier: "Project.Time" });
|
|
1155
|
+
var Info10 = Schema21.Struct({
|
|
1156
|
+
id: ID10,
|
|
1157
|
+
canonical: AbsolutePath,
|
|
1158
|
+
vcs: optional(Vcs),
|
|
1159
|
+
name: optional(Schema21.String),
|
|
1160
|
+
icon: optional(Icon),
|
|
1161
|
+
commands: optional(Commands),
|
|
1162
|
+
time: Time,
|
|
1163
|
+
sandboxes: Schema21.Array(Schema21.String)
|
|
1164
|
+
}).annotate({ identifier: "Project" });
|
|
1165
|
+
var UpdateInput2 = Schema21.Struct({
|
|
1166
|
+
projectID: ID10,
|
|
1167
|
+
canonical: optional(AbsolutePath),
|
|
1168
|
+
name: optional(Schema21.String),
|
|
1169
|
+
icon: optional(Icon),
|
|
1170
|
+
commands: optional(Commands)
|
|
1171
|
+
}).annotate({ identifier: "Project.UpdateInput" });
|
|
1172
|
+
var Updated8 = ephemeral({ type: "project.updated", schema: Info10.fields });
|
|
1173
|
+
var Event10 = { Updated: Updated8, Definitions: inventory(Updated8) };
|
|
1174
|
+
|
|
1175
|
+
// node_modules/@opencode/schema/dist/session-event.js
|
|
1176
|
+
var session_event_exports = {};
|
|
1177
|
+
__export(session_event_exports, {
|
|
1178
|
+
AgentSelected: () => AgentSelected2,
|
|
1179
|
+
All: () => All,
|
|
1180
|
+
Compaction: () => Compaction4,
|
|
1181
|
+
Created: () => Created4,
|
|
1182
|
+
Definitions: () => Definitions,
|
|
1183
|
+
Deleted: () => Deleted3,
|
|
1184
|
+
Durable: () => Durable,
|
|
1185
|
+
DurableDefinitions: () => DurableDefinitions,
|
|
1186
|
+
EphemeralDefinitions: () => EphemeralDefinitions,
|
|
1187
|
+
Execution: () => Execution,
|
|
1188
|
+
Forked: () => Forked,
|
|
1189
|
+
InboxCancelled: () => InboxCancelled,
|
|
1190
|
+
InboxDelivered: () => InboxDelivered,
|
|
1191
|
+
InboxDeliveryChanged: () => InboxDeliveryChanged,
|
|
1192
|
+
InboxEnqueued: () => InboxEnqueued,
|
|
1193
|
+
InstructionsUpdated: () => InstructionsUpdated,
|
|
1194
|
+
MessageContentUpdated: () => MessageContentUpdated,
|
|
1195
|
+
MetadataUpdated: () => MetadataUpdated,
|
|
1196
|
+
ModelSelected: () => ModelSelected2,
|
|
1197
|
+
Moved: () => Moved,
|
|
1198
|
+
Permissions: () => Permissions,
|
|
1199
|
+
Reasoning: () => Reasoning,
|
|
1200
|
+
Renamed: () => Renamed,
|
|
1201
|
+
RetryScheduled: () => RetryScheduled,
|
|
1202
|
+
RevertEvent: () => RevertEvent,
|
|
1203
|
+
SessionEvent: () => session_event_exports,
|
|
1204
|
+
Shell: () => Shell2,
|
|
1205
|
+
Skill: () => Skill2,
|
|
1206
|
+
Source: () => Source3,
|
|
1207
|
+
Step: () => Step,
|
|
1208
|
+
Synthetic: () => Synthetic3,
|
|
1209
|
+
Text: () => Text,
|
|
1210
|
+
Tool: () => Tool,
|
|
1211
|
+
UsageRecorded: () => UsageRecorded,
|
|
1212
|
+
UsageUpdated: () => UsageUpdated,
|
|
1213
|
+
Viewed: () => Viewed
|
|
1214
|
+
});
|
|
1215
|
+
import { Schema as Schema39 } from "effect";
|
|
1216
|
+
|
|
1217
|
+
// node_modules/@opencode/schema/dist/llm.js
|
|
1218
|
+
import { Schema as Schema22 } from "effect";
|
|
1219
|
+
var FinishReason = Schema22.Literals(["stop", "length", "tool-calls", "content-filter", "error", "unknown"]);
|
|
1220
|
+
|
|
1221
|
+
// node_modules/@opencode/schema/dist/tool.js
|
|
1222
|
+
var tool_exports = {};
|
|
1223
|
+
__export(tool_exports, {
|
|
1224
|
+
CallID: () => CallID,
|
|
1225
|
+
Content: () => Content,
|
|
1226
|
+
Error: () => Error2,
|
|
1227
|
+
FileContent: () => FileContent,
|
|
1228
|
+
TextContent: () => TextContent,
|
|
1229
|
+
Tool: () => tool_exports
|
|
1230
|
+
});
|
|
1231
|
+
import { Effect as Effect3, JsonSchema, Schema as Schema23 } from "effect";
|
|
1232
|
+
var CallID = Schema23.String.pipe(Schema23.brand("Tool.CallID"));
|
|
1233
|
+
var Error2 = class extends Schema23.TaggedError()("Tool.Error", {
|
|
1234
|
+
message: Schema23.String,
|
|
1235
|
+
error: Schema23.optional(Schema23.Defect()),
|
|
1236
|
+
metadata: Schema23.optional(Schema23.Record(Schema23.String, Schema23.Unknown))
|
|
1237
|
+
}) {
|
|
1238
|
+
};
|
|
1239
|
+
var TextContent = Schema23.Struct({
|
|
1240
|
+
type: Schema23.Literal("text"),
|
|
1241
|
+
text: Schema23.String
|
|
1242
|
+
}).annotate({ identifier: "Tool.TextContent" });
|
|
1243
|
+
var FileContent = Schema23.Struct({
|
|
1244
|
+
type: Schema23.Literal("file"),
|
|
1245
|
+
uri: Schema23.String,
|
|
1246
|
+
mime: Schema23.String,
|
|
1247
|
+
name: Schema23.optional(Schema23.String)
|
|
1248
|
+
}).annotate({ identifier: "Tool.FileContent" });
|
|
1249
|
+
var Content = Schema23.Union([TextContent, FileContent]).pipe(Schema23.toTaggedUnion("type")).annotate({ identifier: "Tool.Content" });
|
|
1250
|
+
|
|
1251
|
+
// node_modules/@opencode/schema/dist/session-metadata.js
|
|
1252
|
+
import { Schema as Schema24 } from "effect";
|
|
1253
|
+
var SessionMetadata = Schema24.Record(Schema24.String, Schema24.Json).annotate({
|
|
1254
|
+
identifier: "Session.Metadata"
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
// node_modules/@opencode/schema/dist/session-message.js
|
|
1258
|
+
var session_message_exports = {};
|
|
1259
|
+
__export(session_message_exports, {
|
|
1260
|
+
AgentSelected: () => AgentSelected,
|
|
1261
|
+
Assistant: () => Assistant,
|
|
1262
|
+
AssistantContent: () => AssistantContent,
|
|
1263
|
+
AssistantContentEncoded: () => AssistantContentEncoded,
|
|
1264
|
+
AssistantReasoning: () => AssistantReasoning,
|
|
1265
|
+
AssistantRetry: () => AssistantRetry,
|
|
1266
|
+
AssistantText: () => AssistantText,
|
|
1267
|
+
AssistantTool: () => AssistantTool,
|
|
1268
|
+
Compaction: () => Compaction2,
|
|
1269
|
+
CompactionCompleted: () => CompactionCompleted,
|
|
1270
|
+
CompactionFailed: () => CompactionFailed,
|
|
1271
|
+
CompactionRunning: () => CompactionRunning,
|
|
1272
|
+
ID: () => ID14,
|
|
1273
|
+
Idle: () => Idle,
|
|
1274
|
+
Info: () => Info15,
|
|
1275
|
+
LocationSwitched: () => LocationSwitched,
|
|
1276
|
+
ModelSelected: () => ModelSelected,
|
|
1277
|
+
ProviderState: () => ProviderState,
|
|
1278
|
+
SessionMessage: () => session_message_exports,
|
|
1279
|
+
Shell: () => Shell,
|
|
1280
|
+
Skill: () => Skill,
|
|
1281
|
+
Synthetic: () => Synthetic,
|
|
1282
|
+
System: () => System,
|
|
1283
|
+
ToolState: () => ToolState,
|
|
1284
|
+
ToolStateCompleted: () => ToolStateCompleted,
|
|
1285
|
+
ToolStateError: () => ToolStateError,
|
|
1286
|
+
ToolStateRunning: () => ToolStateRunning,
|
|
1287
|
+
ToolStateStreaming: () => ToolStateStreaming,
|
|
1288
|
+
User: () => User
|
|
1289
|
+
});
|
|
1290
|
+
import { Schema as Schema32 } from "effect";
|
|
1291
|
+
|
|
1292
|
+
// node_modules/@opencode/schema/dist/session-provider-context.js
|
|
1293
|
+
var session_provider_context_exports = {};
|
|
1294
|
+
__export(session_provider_context_exports, {
|
|
1295
|
+
Info: () => Info11,
|
|
1296
|
+
Provenance: () => Provenance,
|
|
1297
|
+
SessionProviderContext: () => session_provider_context_exports
|
|
1298
|
+
});
|
|
1299
|
+
import { Schema as Schema25 } from "effect";
|
|
1300
|
+
var Provenance = Schema25.Struct({
|
|
1301
|
+
providerID: provider_exports.ID,
|
|
1302
|
+
provider: Schema25.String,
|
|
1303
|
+
modelID: Schema25.String,
|
|
1304
|
+
route: Schema25.String,
|
|
1305
|
+
protocol: Schema25.String,
|
|
1306
|
+
/** Digest of the configured endpoint; raw URLs and query values are not persisted. */
|
|
1307
|
+
endpoint: Schema25.String
|
|
1308
|
+
}).annotate({ identifier: "Session.ProviderContext.Provenance" });
|
|
1309
|
+
var Info11 = Schema25.Struct({
|
|
1310
|
+
version: Schema25.Literal(1),
|
|
1311
|
+
provenance: Provenance,
|
|
1312
|
+
messages: Schema25.Json
|
|
1313
|
+
}).annotate({ identifier: "Session.ProviderContext" });
|
|
1314
|
+
|
|
1315
|
+
// node_modules/@opencode/schema/dist/prompt.js
|
|
1316
|
+
import { Schema as Schema27 } from "effect";
|
|
1317
|
+
|
|
1318
|
+
// node_modules/@opencode/schema/dist/skill.js
|
|
1319
|
+
var skill_exports = {};
|
|
1320
|
+
__export(skill_exports, {
|
|
1321
|
+
DirectorySource: () => DirectorySource,
|
|
1322
|
+
EmbeddedSource: () => EmbeddedSource,
|
|
1323
|
+
Event: () => Event11,
|
|
1324
|
+
ID: () => ID11,
|
|
1325
|
+
Info: () => Info12,
|
|
1326
|
+
Name: () => Name2,
|
|
1327
|
+
Skill: () => skill_exports,
|
|
1328
|
+
Source: () => Source2,
|
|
1329
|
+
UrlSource: () => UrlSource
|
|
1330
|
+
});
|
|
1331
|
+
import { Schema as Schema26 } from "effect";
|
|
1332
|
+
var ID11 = Schema26.String.pipe(Schema26.brand("Skill.ID"), Schema26.annotate({ identifier: "Skill.ID" }));
|
|
1333
|
+
var Name2 = Schema26.String.pipe(Schema26.brand("Skill.Name"), Schema26.annotate({ identifier: "Skill.Name" }));
|
|
1334
|
+
var DirectorySource = Schema26.Struct({
|
|
1335
|
+
type: Schema26.tag("directory"),
|
|
1336
|
+
path: AbsolutePath
|
|
1337
|
+
}).annotate({ identifier: "Skill.DirectorySource" });
|
|
1338
|
+
var UrlSource = Schema26.Struct({
|
|
1339
|
+
type: Schema26.tag("url"),
|
|
1340
|
+
url: Schema26.String
|
|
1341
|
+
}).annotate({ identifier: "Skill.UrlSource" });
|
|
1342
|
+
var Info12 = Schema26.Struct({
|
|
1343
|
+
id: ID11,
|
|
1344
|
+
name: Name2,
|
|
1345
|
+
description: Schema26.String.pipe(optional),
|
|
1346
|
+
autoinvoke: Schema26.Boolean.pipe(optional),
|
|
1347
|
+
path: AbsolutePath,
|
|
1348
|
+
content: Schema26.String
|
|
1349
|
+
}).annotate({ identifier: "Skill.Info" });
|
|
1350
|
+
var Updated9 = ephemeral({ type: "skill.updated", schema: {} });
|
|
1351
|
+
var Event11 = { Updated: Updated9, Definitions: inventory(Updated9) };
|
|
1352
|
+
var EmbeddedSource = Schema26.Struct({
|
|
1353
|
+
type: Schema26.tag("embedded"),
|
|
1354
|
+
skill: Schema26.suspend(() => Info12)
|
|
1355
|
+
}).annotate({ identifier: "Skill.EmbeddedSource" });
|
|
1356
|
+
var Source2 = Object.assign(Schema26.Union([DirectorySource, UrlSource, EmbeddedSource]).pipe(Schema26.toTaggedUnion("type"), Schema26.annotate({ identifier: "Skill.Source" })), {
|
|
1357
|
+
equals: (a, b) => {
|
|
1358
|
+
if (a.type !== b.type)
|
|
1359
|
+
return false;
|
|
1360
|
+
if (a.type === "directory" && b.type === "directory")
|
|
1361
|
+
return a.path === b.path;
|
|
1362
|
+
if (a.type === "url" && b.type === "url")
|
|
1363
|
+
return a.url === b.url;
|
|
1364
|
+
if (a.type === "embedded" && b.type === "embedded")
|
|
1365
|
+
return a.skill.id === b.skill.id;
|
|
1366
|
+
return false;
|
|
1367
|
+
},
|
|
1368
|
+
key: (source) => source.type === "directory" ? `directory:${source.path}` : source.type === "url" ? `url:${source.url}` : `embedded:${source.skill.id}`
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
// node_modules/@opencode/schema/dist/prompt.js
|
|
1372
|
+
var PromptMention = Schema27.Struct({
|
|
1373
|
+
start: Schema27.Finite,
|
|
1374
|
+
end: Schema27.Finite,
|
|
1375
|
+
text: Schema27.String
|
|
1376
|
+
}).annotate({ identifier: "Prompt.Mention" });
|
|
1377
|
+
var FileSource = Schema27.Union([
|
|
1378
|
+
Schema27.Struct({ type: Schema27.Literal("inline") }),
|
|
1379
|
+
Schema27.Struct({ type: Schema27.Literal("uri"), uri: Schema27.String })
|
|
1380
|
+
]).pipe(Schema27.toTaggedUnion("type")).annotate({ identifier: "Prompt.FileSource" });
|
|
1381
|
+
var Base64 = Schema27.String.check(Schema27.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u)).annotate({ identifier: "Prompt.Base64" });
|
|
1382
|
+
var FileAttachment = Schema27.Struct({
|
|
1383
|
+
data: Base64,
|
|
1384
|
+
mime: Schema27.String,
|
|
1385
|
+
source: FileSource,
|
|
1386
|
+
name: Schema27.String.pipe(optional),
|
|
1387
|
+
description: Schema27.String.pipe(optional),
|
|
1388
|
+
mention: PromptMention.pipe(optional)
|
|
1389
|
+
}).annotate({ identifier: "Prompt.FileAttachment" }).pipe(statics((schema) => ({
|
|
1390
|
+
create: (input) => schema.make({
|
|
1391
|
+
data: input.data,
|
|
1392
|
+
mime: input.mime,
|
|
1393
|
+
source: input.source,
|
|
1394
|
+
name: input.name,
|
|
1395
|
+
description: input.description,
|
|
1396
|
+
mention: input.mention
|
|
1397
|
+
})
|
|
1398
|
+
})));
|
|
1399
|
+
var AgentAttachment = Schema27.Struct({
|
|
1400
|
+
name: Schema27.String,
|
|
1401
|
+
mention: PromptMention.pipe(optional)
|
|
1402
|
+
}).annotate({ identifier: "Prompt.AgentAttachment" });
|
|
1403
|
+
var SkillAttachment = Schema27.Struct({
|
|
1404
|
+
id: skill_exports.ID,
|
|
1405
|
+
name: skill_exports.Name,
|
|
1406
|
+
text: Schema27.String.pipe(optional),
|
|
1407
|
+
mention: PromptMention.pipe(optional)
|
|
1408
|
+
}).annotate({ identifier: "Prompt.SkillAttachment" });
|
|
1409
|
+
var Prompt = Schema27.Struct({
|
|
1410
|
+
text: Schema27.String,
|
|
1411
|
+
files: Schema27.Array(FileAttachment).pipe(optional),
|
|
1412
|
+
agents: Schema27.Array(AgentAttachment).pipe(optional),
|
|
1413
|
+
skills: Schema27.Array(SkillAttachment).pipe(optional)
|
|
1414
|
+
}).annotate({ identifier: "Prompt" }).pipe(statics((schema) => ({
|
|
1415
|
+
equivalence: Schema27.toEquivalence(schema),
|
|
1416
|
+
fromUserMessage: (input) => schema.make({
|
|
1417
|
+
text: input.text,
|
|
1418
|
+
...input.files === void 0 ? {} : { files: input.files },
|
|
1419
|
+
...input.agents === void 0 ? {} : { agents: input.agents },
|
|
1420
|
+
...input.skills === void 0 ? {} : { skills: input.skills }
|
|
1421
|
+
})
|
|
1422
|
+
})));
|
|
1423
|
+
|
|
1424
|
+
// node_modules/@opencode/schema/dist/shell.js
|
|
1425
|
+
var shell_exports = {};
|
|
1426
|
+
__export(shell_exports, {
|
|
1427
|
+
CreateInput: () => CreateInput3,
|
|
1428
|
+
Event: () => Event12,
|
|
1429
|
+
ID: () => ID12,
|
|
1430
|
+
Info: () => Info13,
|
|
1431
|
+
Metadata: () => Metadata2,
|
|
1432
|
+
Output: () => Output,
|
|
1433
|
+
OutputInput: () => OutputInput,
|
|
1434
|
+
Shell: () => shell_exports,
|
|
1435
|
+
Status: () => Status3,
|
|
1436
|
+
Time: () => Time2
|
|
1437
|
+
});
|
|
1438
|
+
import { Schema as Schema28 } from "effect";
|
|
1439
|
+
var IDSchema3 = Schema28.String.check(Schema28.isStartingWith("sh_")).pipe(Schema28.brand("Shell.ID"), Schema28.annotate({ identifier: "Shell.ID" }));
|
|
1440
|
+
var ID12 = IDSchema3.pipe(statics((schema) => {
|
|
1441
|
+
const create2 = () => schema.make("sh_" + ascending());
|
|
1442
|
+
return {
|
|
1443
|
+
create: create2,
|
|
1444
|
+
ascending: (id) => id === void 0 ? create2() : schema.make(id)
|
|
1445
|
+
};
|
|
1446
|
+
}));
|
|
1447
|
+
var Status3 = Schema28.Literals(["running", "exited", "timeout", "killed"]);
|
|
1448
|
+
var Time2 = Schema28.Struct({
|
|
1449
|
+
started: Schema28.Finite.annotate({ description: "Start time in milliseconds since the Unix epoch" }),
|
|
1450
|
+
completed: optional(Schema28.Finite).annotate({
|
|
1451
|
+
description: "Completion time in milliseconds since the Unix epoch"
|
|
1452
|
+
})
|
|
1453
|
+
});
|
|
1454
|
+
var Metadata2 = Schema28.Record(Schema28.String, Schema28.Unknown);
|
|
1455
|
+
var Info13 = Schema28.Struct({
|
|
1456
|
+
id: ID12,
|
|
1457
|
+
status: Status3,
|
|
1458
|
+
command: Schema28.String,
|
|
1459
|
+
cwd: Schema28.String,
|
|
1460
|
+
shell: Schema28.String,
|
|
1461
|
+
// Absolute path of the file capturing combined stdout/stderr. Page through it via `output`.
|
|
1462
|
+
file: Schema28.String,
|
|
1463
|
+
pid: optional(NonNegativeInt),
|
|
1464
|
+
exit: optional(Schema28.Finite),
|
|
1465
|
+
signal: optional(Schema28.String),
|
|
1466
|
+
// Always present; defaults to an empty object when the creator supplies no metadata.
|
|
1467
|
+
metadata: Metadata2,
|
|
1468
|
+
time: Time2
|
|
1469
|
+
}).annotate({ identifier: "Shell.Info" });
|
|
1470
|
+
var Created3 = ephemeral({ type: "shell.created", schema: { info: Info13 } });
|
|
1471
|
+
var Exited2 = ephemeral({ type: "shell.exited", schema: { id: ID12, exit: optional(Schema28.Finite), status: Status3 } });
|
|
1472
|
+
var Deleted2 = ephemeral({ type: "shell.deleted", schema: { id: ID12 } });
|
|
1473
|
+
var Event12 = { Created: Created3, Exited: Exited2, Deleted: Deleted2, Definitions: inventory(Created3, Exited2, Deleted2) };
|
|
1474
|
+
var CreateInput3 = Schema28.Struct({
|
|
1475
|
+
command: Schema28.String,
|
|
1476
|
+
cwd: optional(Schema28.String),
|
|
1477
|
+
timeout: optional(NonNegativeInt),
|
|
1478
|
+
metadata: optional(Metadata2)
|
|
1479
|
+
});
|
|
1480
|
+
var OutputInput = Schema28.Struct({
|
|
1481
|
+
cursor: optional(NonNegativeInt),
|
|
1482
|
+
limit: optional(NonNegativeInt)
|
|
1483
|
+
});
|
|
1484
|
+
var Output = Schema28.Struct({
|
|
1485
|
+
output: Schema28.String,
|
|
1486
|
+
// Absolute cursor after this page. Equals `size` once fully caught up.
|
|
1487
|
+
cursor: NonNegativeInt,
|
|
1488
|
+
// Total bytes captured so far. A consumer has more to page while `cursor < size`.
|
|
1489
|
+
size: NonNegativeInt,
|
|
1490
|
+
truncated: Schema28.Boolean
|
|
1491
|
+
});
|
|
1492
|
+
|
|
1493
|
+
// node_modules/@opencode/schema/dist/session-error.js
|
|
1494
|
+
var session_error_exports = {};
|
|
1495
|
+
__export(session_error_exports, {
|
|
1496
|
+
Error: () => Error3,
|
|
1497
|
+
SessionError: () => session_error_exports
|
|
1498
|
+
});
|
|
1499
|
+
import { Schema as Schema29 } from "effect";
|
|
1500
|
+
var Error3 = Schema29.Struct({
|
|
1501
|
+
type: Schema29.String,
|
|
1502
|
+
message: Schema29.String,
|
|
1503
|
+
status: Schema29.Int.check(Schema29.isBetween({ minimum: 100, maximum: 599 })).pipe(optional),
|
|
1504
|
+
response: Schema29.Struct({ body: Schema29.String }).pipe(optional)
|
|
1505
|
+
}).annotate({ identifier: "Session.StructuredError" });
|
|
1506
|
+
|
|
1507
|
+
// node_modules/@opencode/schema/dist/snapshot.js
|
|
1508
|
+
var snapshot_exports = {};
|
|
1509
|
+
__export(snapshot_exports, {
|
|
1510
|
+
ID: () => ID13,
|
|
1511
|
+
Snapshot: () => snapshot_exports
|
|
1512
|
+
});
|
|
1513
|
+
import { Schema as Schema30 } from "effect";
|
|
1514
|
+
var ID13 = Schema30.String.pipe(Schema30.brand("Snapshot.ID"), Schema30.annotate({ identifier: "Snapshot.ID" }));
|
|
1515
|
+
|
|
1516
|
+
// node_modules/@opencode/schema/dist/token-usage.js
|
|
1517
|
+
var token_usage_exports = {};
|
|
1518
|
+
__export(token_usage_exports, {
|
|
1519
|
+
Info: () => Info14,
|
|
1520
|
+
TokenUsage: () => token_usage_exports,
|
|
1521
|
+
total: () => total
|
|
1522
|
+
});
|
|
1523
|
+
import { Schema as Schema31 } from "effect";
|
|
1524
|
+
var Info14 = Schema31.Struct({
|
|
1525
|
+
input: Schema31.Finite,
|
|
1526
|
+
output: Schema31.Finite,
|
|
1527
|
+
reasoning: Schema31.Finite,
|
|
1528
|
+
cache: Schema31.Struct({
|
|
1529
|
+
read: Schema31.Finite,
|
|
1530
|
+
write: Schema31.Finite
|
|
1531
|
+
})
|
|
1532
|
+
}).annotate({ identifier: "TokenUsage.Info" });
|
|
1533
|
+
function total(tokens) {
|
|
1534
|
+
return tokens.input + tokens.output + tokens.reasoning + tokens.cache.read + tokens.cache.write;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// node_modules/@opencode/schema/dist/session-message.js
|
|
1538
|
+
var ID14 = Schema32.String.check(Schema32.isStartingWith("msg_")).pipe(Schema32.brand("Session.Message.ID"), Schema32.annotate({ identifier: "Session.Message.ID" }), statics((schema) => ({
|
|
1539
|
+
create: () => schema.make("msg_" + ascending()),
|
|
1540
|
+
fromEvent: (eventID) => schema.make(eventID.replace(/^evt_/, "msg_"))
|
|
1541
|
+
})));
|
|
1542
|
+
var Base = {
|
|
1543
|
+
id: ID14,
|
|
1544
|
+
metadata: Schema32.Record(Schema32.String, Schema32.Unknown).pipe(optional),
|
|
1545
|
+
time: Schema32.Struct({ created: DateTimeUtcFromMillis })
|
|
1546
|
+
};
|
|
1547
|
+
var ProviderState = Schema32.Record(Schema32.String, Schema32.Unknown).annotate({
|
|
1548
|
+
identifier: "Session.Message.ProviderState"
|
|
1549
|
+
});
|
|
1550
|
+
var AgentSelected = Schema32.Struct({
|
|
1551
|
+
...Base,
|
|
1552
|
+
type: Schema32.tag("agent-switched"),
|
|
1553
|
+
agent: agent_exports.ID,
|
|
1554
|
+
previous: agent_exports.ID.pipe(optional)
|
|
1555
|
+
}).annotate({ identifier: "Session.Message.AgentSelected" });
|
|
1556
|
+
var ModelSelected = Schema32.Struct({
|
|
1557
|
+
...Base,
|
|
1558
|
+
type: Schema32.tag("model-switched"),
|
|
1559
|
+
model: model_exports.Ref,
|
|
1560
|
+
previous: model_exports.Ref.pipe(optional)
|
|
1561
|
+
}).annotate({ identifier: "Session.Message.ModelSelected" });
|
|
1562
|
+
var LocationSwitched = Schema32.Struct({
|
|
1563
|
+
...Base,
|
|
1564
|
+
type: Schema32.tag("location-switched"),
|
|
1565
|
+
location: location_exports.Ref,
|
|
1566
|
+
projectID: project_exports.ID.pipe(optional),
|
|
1567
|
+
subpath: RelativePath.pipe(optional),
|
|
1568
|
+
previous: Schema32.Struct({
|
|
1569
|
+
location: location_exports.Ref,
|
|
1570
|
+
projectID: project_exports.ID.pipe(optional),
|
|
1571
|
+
subpath: RelativePath.pipe(optional)
|
|
1572
|
+
}).pipe(optional)
|
|
1573
|
+
}).annotate({ identifier: "Session.Message.LocationSwitched" });
|
|
1574
|
+
var User = Schema32.Struct({
|
|
1575
|
+
...Base,
|
|
1576
|
+
text: Prompt.fields.text,
|
|
1577
|
+
files: Prompt.fields.files,
|
|
1578
|
+
agents: Prompt.fields.agents,
|
|
1579
|
+
skills: Prompt.fields.skills,
|
|
1580
|
+
type: Schema32.tag("user")
|
|
1581
|
+
}).annotate({ identifier: "Session.Message.User" });
|
|
1582
|
+
var Synthetic = Schema32.Struct({
|
|
1583
|
+
...Base,
|
|
1584
|
+
text: Schema32.String,
|
|
1585
|
+
description: Schema32.String.pipe(optional),
|
|
1586
|
+
type: Schema32.tag("synthetic")
|
|
1587
|
+
}).annotate({ identifier: "Session.Message.Synthetic" });
|
|
1588
|
+
var System = Schema32.Struct({
|
|
1589
|
+
...Base,
|
|
1590
|
+
type: Schema32.tag("system"),
|
|
1591
|
+
/** The model-facing update text, frozen at emit time. */
|
|
1592
|
+
text: Schema32.String,
|
|
1593
|
+
/** A short human-readable summary for transcript display. */
|
|
1594
|
+
description: Schema32.String.pipe(optional)
|
|
1595
|
+
}).annotate({ identifier: "Session.Message.System" });
|
|
1596
|
+
var Skill = Schema32.Struct({
|
|
1597
|
+
...Base,
|
|
1598
|
+
type: Schema32.tag("skill"),
|
|
1599
|
+
skill: skill_exports.ID,
|
|
1600
|
+
name: skill_exports.Name,
|
|
1601
|
+
text: Schema32.String
|
|
1602
|
+
}).annotate({ identifier: "Session.Message.Skill" });
|
|
1603
|
+
var Shell = Schema32.Struct({
|
|
1604
|
+
...Base,
|
|
1605
|
+
type: Schema32.tag("shell"),
|
|
1606
|
+
shellID: shell_exports.ID,
|
|
1607
|
+
command: Schema32.String,
|
|
1608
|
+
status: shell_exports.Status,
|
|
1609
|
+
exit: Schema32.Number.pipe(optional),
|
|
1610
|
+
output: shell_exports.Output.pipe(optional),
|
|
1611
|
+
time: Schema32.Struct({
|
|
1612
|
+
created: DateTimeUtcFromMillis,
|
|
1613
|
+
completed: DateTimeUtcFromMillis.pipe(optional)
|
|
1614
|
+
})
|
|
1615
|
+
}).annotate({ identifier: "Session.Message.Shell" });
|
|
1616
|
+
var ToolStateStreaming = Schema32.Struct({
|
|
1617
|
+
status: Schema32.tag("streaming"),
|
|
1618
|
+
input: Schema32.String
|
|
1619
|
+
}).annotate({ identifier: "Session.Message.ToolState.Streaming" });
|
|
1620
|
+
var ToolStateRunning = Schema32.Struct({
|
|
1621
|
+
status: Schema32.tag("running"),
|
|
1622
|
+
input: Schema32.Record(Schema32.String, Schema32.Unknown),
|
|
1623
|
+
metadata: Schema32.Record(Schema32.String, Schema32.Json)
|
|
1624
|
+
}).annotate({ identifier: "Session.Message.ToolState.Running" });
|
|
1625
|
+
var ToolStateCompleted = Schema32.Struct({
|
|
1626
|
+
status: Schema32.tag("completed"),
|
|
1627
|
+
input: Schema32.Record(Schema32.String, Schema32.Unknown),
|
|
1628
|
+
content: Schema32.NonEmptyArray(Content),
|
|
1629
|
+
metadata: Schema32.Record(Schema32.String, Schema32.Json).pipe(optional)
|
|
1630
|
+
}).annotate({ identifier: "Session.Message.ToolState.Completed" });
|
|
1631
|
+
var ToolStateError = Schema32.Struct({
|
|
1632
|
+
status: Schema32.tag("error"),
|
|
1633
|
+
input: Schema32.Record(Schema32.String, Schema32.Unknown),
|
|
1634
|
+
error: session_error_exports.Error,
|
|
1635
|
+
content: Schema32.NonEmptyArray(Content).pipe(optional),
|
|
1636
|
+
metadata: Schema32.Record(Schema32.String, Schema32.Json).pipe(optional)
|
|
1637
|
+
}).annotate({ identifier: "Session.Message.ToolState.Error" });
|
|
1638
|
+
var ToolState = Schema32.Union([ToolStateStreaming, ToolStateRunning, ToolStateCompleted, ToolStateError]).pipe(Schema32.toTaggedUnion("status"));
|
|
1639
|
+
var AssistantTool = Schema32.Struct({
|
|
1640
|
+
type: Schema32.tag("tool"),
|
|
1641
|
+
id: Schema32.String,
|
|
1642
|
+
name: Schema32.String,
|
|
1643
|
+
executed: Schema32.Boolean.pipe(optional),
|
|
1644
|
+
providerState: ProviderState.pipe(optional),
|
|
1645
|
+
providerResultState: ProviderState.pipe(optional),
|
|
1646
|
+
state: ToolState,
|
|
1647
|
+
time: Schema32.Struct({
|
|
1648
|
+
created: DateTimeUtcFromMillis,
|
|
1649
|
+
ran: DateTimeUtcFromMillis.pipe(optional),
|
|
1650
|
+
completed: DateTimeUtcFromMillis.pipe(optional)
|
|
1651
|
+
})
|
|
1652
|
+
}).annotate({ identifier: "Session.Message.Assistant.Tool" });
|
|
1653
|
+
var AssistantText = Schema32.Struct({
|
|
1654
|
+
type: Schema32.tag("text"),
|
|
1655
|
+
text: Schema32.String,
|
|
1656
|
+
state: ProviderState.pipe(optional)
|
|
1657
|
+
}).annotate({ identifier: "Session.Message.Assistant.Text" });
|
|
1658
|
+
var AssistantReasoning = Schema32.Struct({
|
|
1659
|
+
type: Schema32.tag("reasoning"),
|
|
1660
|
+
text: Schema32.String,
|
|
1661
|
+
state: ProviderState.pipe(optional),
|
|
1662
|
+
time: Schema32.Struct({
|
|
1663
|
+
created: DateTimeUtcFromMillis,
|
|
1664
|
+
completed: DateTimeUtcFromMillis.pipe(optional)
|
|
1665
|
+
}).pipe(optional)
|
|
1666
|
+
}).annotate({ identifier: "Session.Message.Assistant.Reasoning" });
|
|
1667
|
+
var AssistantContent = Schema32.Union([AssistantText, AssistantReasoning, AssistantTool]).pipe(Schema32.toTaggedUnion("type"));
|
|
1668
|
+
var AssistantContentEncoded = Schema32.toEncoded(AssistantContent).annotate({
|
|
1669
|
+
identifier: "Session.Message.AssistantContent.Encoded"
|
|
1670
|
+
});
|
|
1671
|
+
var AssistantRetry = Schema32.Struct({
|
|
1672
|
+
attempt: PositiveInt,
|
|
1673
|
+
at: DateTimeUtcFromMillis,
|
|
1674
|
+
error: session_error_exports.Error
|
|
1675
|
+
}).annotate({ identifier: "Session.Message.Assistant.Retry" });
|
|
1676
|
+
var Assistant = Schema32.Struct({
|
|
1677
|
+
...Base,
|
|
1678
|
+
type: Schema32.tag("assistant"),
|
|
1679
|
+
agent: agent_exports.ID,
|
|
1680
|
+
model: model_exports.Ref,
|
|
1681
|
+
content: AssistantContent.pipe(Schema32.Array),
|
|
1682
|
+
snapshot: Schema32.Struct({
|
|
1683
|
+
start: snapshot_exports.ID.pipe(optional),
|
|
1684
|
+
end: snapshot_exports.ID.pipe(optional),
|
|
1685
|
+
files: Schema32.Array(RelativePath).pipe(optional)
|
|
1686
|
+
}).pipe(optional),
|
|
1687
|
+
finish: FinishReason.pipe(optional),
|
|
1688
|
+
rawFinish: Schema32.String.pipe(optional),
|
|
1689
|
+
providerState: ProviderState.pipe(optional),
|
|
1690
|
+
cost: money_exports.USD.pipe(optional),
|
|
1691
|
+
tokens: token_usage_exports.Info.pipe(optional),
|
|
1692
|
+
error: session_error_exports.Error.pipe(optional),
|
|
1693
|
+
retry: AssistantRetry.pipe(optional),
|
|
1694
|
+
time: Schema32.Struct({
|
|
1695
|
+
created: DateTimeUtcFromMillis,
|
|
1696
|
+
/** When the provider response body ended, before tool settlement. */
|
|
1697
|
+
streamed: DateTimeUtcFromMillis.pipe(optional),
|
|
1698
|
+
completed: DateTimeUtcFromMillis.pipe(optional)
|
|
1699
|
+
})
|
|
1700
|
+
}).annotate({ identifier: "Session.Message.Assistant" });
|
|
1701
|
+
var CompactionBase = { type: Schema32.tag("compaction"), ...Base };
|
|
1702
|
+
var CompactionUsage = {
|
|
1703
|
+
cost: money_exports.USD.pipe(optional),
|
|
1704
|
+
tokens: token_usage_exports.Info.pipe(optional)
|
|
1705
|
+
};
|
|
1706
|
+
var CompactionRunning = Schema32.Struct({
|
|
1707
|
+
...CompactionBase,
|
|
1708
|
+
status: Schema32.tag("running"),
|
|
1709
|
+
reason: Schema32.Literals(["auto", "manual"]),
|
|
1710
|
+
summary: Schema32.String,
|
|
1711
|
+
recent: Schema32.String
|
|
1712
|
+
}).annotate({ identifier: "Session.Message.Compaction.Running" });
|
|
1713
|
+
var CompactionCompleted = Schema32.Struct({
|
|
1714
|
+
...CompactionBase,
|
|
1715
|
+
status: Schema32.tag("completed"),
|
|
1716
|
+
reason: Schema32.Literals(["auto", "manual"]),
|
|
1717
|
+
model: model_exports.Ref.pipe(optional),
|
|
1718
|
+
providerState: ProviderState.pipe(optional),
|
|
1719
|
+
summary: Schema32.String,
|
|
1720
|
+
recent: Schema32.String,
|
|
1721
|
+
providerContext: session_provider_context_exports.Info.pipe(optional),
|
|
1722
|
+
...CompactionUsage
|
|
1723
|
+
}).annotate({ identifier: "Session.Message.Compaction.Completed" });
|
|
1724
|
+
var CompactionFailed = Schema32.Struct({
|
|
1725
|
+
...CompactionBase,
|
|
1726
|
+
status: Schema32.tag("failed"),
|
|
1727
|
+
reason: Schema32.Literals(["auto", "manual"]),
|
|
1728
|
+
error: session_error_exports.Error,
|
|
1729
|
+
...CompactionUsage
|
|
1730
|
+
}).annotate({ identifier: "Session.Message.Compaction.Failed" });
|
|
1731
|
+
var Compaction2 = Schema32.Union([CompactionRunning, CompactionCompleted, CompactionFailed]).pipe(Schema32.toTaggedUnion("status"), Schema32.annotate({ identifier: "Session.Message.Compaction" }));
|
|
1732
|
+
var Idle = Schema32.Struct({
|
|
1733
|
+
...Base,
|
|
1734
|
+
type: Schema32.tag("idle"),
|
|
1735
|
+
outcome: Schema32.Literals(["succeeded", "failed", "interrupted"]),
|
|
1736
|
+
error: session_error_exports.Error.pipe(optional)
|
|
1737
|
+
}).annotate({ identifier: "Session.Message.Idle" });
|
|
1738
|
+
var Info15 = Schema32.Union([
|
|
1739
|
+
AgentSelected,
|
|
1740
|
+
ModelSelected,
|
|
1741
|
+
LocationSwitched,
|
|
1742
|
+
User,
|
|
1743
|
+
Synthetic,
|
|
1744
|
+
System,
|
|
1745
|
+
Skill,
|
|
1746
|
+
Shell,
|
|
1747
|
+
Assistant,
|
|
1748
|
+
Compaction2,
|
|
1749
|
+
Idle
|
|
1750
|
+
]).annotate({ identifier: "Session.Message.Info" });
|
|
1751
|
+
|
|
1752
|
+
// node_modules/@opencode/schema/dist/session-revert.js
|
|
1753
|
+
import { Schema as Schema34, SchemaTransformation as SchemaTransformation2 } from "effect";
|
|
1754
|
+
|
|
1755
|
+
// node_modules/@opencode/schema/dist/file-diff.js
|
|
1756
|
+
var file_diff_exports = {};
|
|
1757
|
+
__export(file_diff_exports, {
|
|
1758
|
+
FileDiff: () => file_diff_exports,
|
|
1759
|
+
Info: () => Info16,
|
|
1760
|
+
LegacyInfo: () => LegacyInfo
|
|
1761
|
+
});
|
|
1762
|
+
import { Schema as Schema33 } from "effect";
|
|
1763
|
+
var Info16 = Schema33.Struct({
|
|
1764
|
+
file: Schema33.String,
|
|
1765
|
+
patch: Schema33.String,
|
|
1766
|
+
additions: NonNegativeInt,
|
|
1767
|
+
deletions: NonNegativeInt,
|
|
1768
|
+
status: Schema33.Literals(["added", "deleted", "modified"])
|
|
1769
|
+
}).annotate({ identifier: "FileDiff.Info" });
|
|
1770
|
+
var LegacyInfo = Schema33.Struct({
|
|
1771
|
+
file: Schema33.String.pipe(optional),
|
|
1772
|
+
patch: Schema33.String.pipe(optional),
|
|
1773
|
+
additions: Schema33.Finite,
|
|
1774
|
+
deletions: Schema33.Finite,
|
|
1775
|
+
status: Schema33.Literals(["added", "deleted", "modified"]).pipe(optional)
|
|
1776
|
+
}).annotate({ identifier: "FileDiff.LegacyInfo" });
|
|
1777
|
+
|
|
1778
|
+
// node_modules/@opencode/schema/dist/session-revert.js
|
|
1779
|
+
var Revert = Schema34.Struct({
|
|
1780
|
+
messageID: session_message_exports.ID,
|
|
1781
|
+
/** Legacy V1 compatibility state. */
|
|
1782
|
+
partID: Schema34.String.pipe(optional),
|
|
1783
|
+
snapshot: snapshot_exports.ID.pipe(optional),
|
|
1784
|
+
files: Schema34.Array(file_diff_exports.Info).pipe(optional)
|
|
1785
|
+
}).annotate({ identifier: "Session.Revert" });
|
|
1786
|
+
var FileDiffV1 = Schema34.Struct({
|
|
1787
|
+
path: Schema34.String,
|
|
1788
|
+
status: Schema34.Literals(["added", "modified", "deleted"]),
|
|
1789
|
+
additions: Schema34.Finite,
|
|
1790
|
+
deletions: Schema34.Finite,
|
|
1791
|
+
patch: Schema34.String
|
|
1792
|
+
});
|
|
1793
|
+
var RevertV1 = Schema34.Struct({
|
|
1794
|
+
messageID: session_message_exports.ID,
|
|
1795
|
+
partID: Schema34.String.pipe(optional),
|
|
1796
|
+
snapshot: Schema34.String.pipe(optional),
|
|
1797
|
+
diff: Schema34.String.pipe(optional),
|
|
1798
|
+
files: Schema34.Array(FileDiffV1).pipe(optional)
|
|
1799
|
+
}).annotate({ identifier: "Session.RevertV1" });
|
|
1800
|
+
var PersistedCurrent = Revert.pipe(Schema34.decodeTo(Schema34.Struct({ source: Schema34.tag("current"), revert: Schema34.toType(Revert) }), SchemaTransformation2.transform({
|
|
1801
|
+
decode: (revert) => ({
|
|
1802
|
+
source: "current",
|
|
1803
|
+
revert
|
|
1804
|
+
}),
|
|
1805
|
+
encode: (value) => value.revert
|
|
1806
|
+
})));
|
|
1807
|
+
var PersistedLegacy = RevertV1.pipe(Schema34.decodeTo(Schema34.Struct({ source: Schema34.tag("legacy"), revert: Schema34.toType(RevertV1) }), SchemaTransformation2.transform({
|
|
1808
|
+
decode: (revert) => ({
|
|
1809
|
+
source: "legacy",
|
|
1810
|
+
revert
|
|
1811
|
+
}),
|
|
1812
|
+
encode: (value) => value.revert
|
|
1813
|
+
})));
|
|
1814
|
+
var PersistedRevert = Schema34.Union([PersistedCurrent, PersistedLegacy]).pipe(Schema34.toTaggedUnion("source"), Schema34.decodeTo(Schema34.toType(Revert), SchemaTransformation2.transform({
|
|
1815
|
+
decode: (persisted) => {
|
|
1816
|
+
if (persisted.source === "current")
|
|
1817
|
+
return persisted.revert;
|
|
1818
|
+
return Revert.make({
|
|
1819
|
+
messageID: persisted.revert.messageID,
|
|
1820
|
+
partID: persisted.revert.partID,
|
|
1821
|
+
snapshot: persisted.revert.snapshot ? snapshot_exports.ID.make(persisted.revert.snapshot) : void 0,
|
|
1822
|
+
files: persisted.revert.files?.map((file) => ({
|
|
1823
|
+
file: file.path,
|
|
1824
|
+
status: file.status,
|
|
1825
|
+
additions: file.additions,
|
|
1826
|
+
deletions: file.deletions,
|
|
1827
|
+
patch: file.patch
|
|
1828
|
+
}))
|
|
1829
|
+
});
|
|
1830
|
+
},
|
|
1831
|
+
encode: (revert) => ({
|
|
1832
|
+
source: "current",
|
|
1833
|
+
revert
|
|
1834
|
+
})
|
|
1835
|
+
})), Schema34.annotate({ identifier: "Session.Revert.Persisted" }));
|
|
1836
|
+
|
|
1837
|
+
// node_modules/@opencode/schema/dist/instruction.js
|
|
1838
|
+
var instruction_exports = {};
|
|
1839
|
+
__export(instruction_exports, {
|
|
1840
|
+
Delta: () => Delta,
|
|
1841
|
+
Hash: () => Hash,
|
|
1842
|
+
Instruction: () => instruction_exports,
|
|
1843
|
+
Key: () => Key2,
|
|
1844
|
+
Removed: () => Removed,
|
|
1845
|
+
Values: () => Values,
|
|
1846
|
+
removed: () => removed
|
|
1847
|
+
});
|
|
1848
|
+
import { Schema as Schema35 } from "effect";
|
|
1849
|
+
var Key2 = Schema35.String.check(Schema35.isPattern(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(Schema35.brand("Instruction.Key"), Schema35.annotate({ identifier: "Instruction.Key" }));
|
|
1850
|
+
var Hash = Schema35.String.check(Schema35.isPattern(/^[a-f0-9]{64}$/u)).pipe(Schema35.brand("Instruction.Hash"), Schema35.annotate({ identifier: "Instruction.Hash" }));
|
|
1851
|
+
var Values = Schema35.Record(Key2, Hash);
|
|
1852
|
+
var Removed = Schema35.Literal("removed");
|
|
1853
|
+
var removed = Removed.make("removed");
|
|
1854
|
+
var Delta = Schema35.Record(Schema35.String, Schema35.Union([Hash, Removed]));
|
|
1855
|
+
|
|
1856
|
+
// node_modules/@opencode/schema/dist/instruction-entry.js
|
|
1857
|
+
var instruction_entry_exports = {};
|
|
1858
|
+
__export(instruction_entry_exports, {
|
|
1859
|
+
Info: () => Info17,
|
|
1860
|
+
InstructionEntry: () => instruction_entry_exports,
|
|
1861
|
+
Key: () => Key3,
|
|
1862
|
+
MaxValueBytes: () => MaxValueBytes,
|
|
1863
|
+
Snapshot: () => Snapshot,
|
|
1864
|
+
ValueTooLargeError: () => ValueTooLargeError
|
|
1865
|
+
});
|
|
1866
|
+
import { Schema as Schema36 } from "effect";
|
|
1867
|
+
var Key3 = Schema36.String.check(Schema36.isPattern(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({
|
|
1868
|
+
identifier: "InstructionEntry.Key",
|
|
1869
|
+
description: "Instruction entry key (lowercase alphanumerics plus . _ -)"
|
|
1870
|
+
});
|
|
1871
|
+
var Info17 = Schema36.Struct({
|
|
1872
|
+
key: Key3,
|
|
1873
|
+
value: Schema36.Json.annotate({ description: "JSON value attached to the session's instructions" })
|
|
1874
|
+
}).annotate({ identifier: "InstructionEntry.Info" });
|
|
1875
|
+
var Snapshot = Schema36.Array(Schema36.Struct({
|
|
1876
|
+
...Info17.fields,
|
|
1877
|
+
removed: Schema36.Boolean
|
|
1878
|
+
})).annotate({ identifier: "InstructionEntry.Snapshot" });
|
|
1879
|
+
var MaxValueBytes = 256 * 1024;
|
|
1880
|
+
var ValueTooLargeError = class extends Schema36.TaggedError()("InstructionEntryValueTooLargeError", {
|
|
1881
|
+
actualBytes: Schema36.Int,
|
|
1882
|
+
maxBytes: Schema36.Int,
|
|
1883
|
+
message: Schema36.String
|
|
1884
|
+
}, { httpApiStatus: 413 }) {
|
|
1885
|
+
};
|
|
1886
|
+
|
|
1887
|
+
// node_modules/@opencode/schema/dist/session-inbox.js
|
|
1888
|
+
var session_inbox_exports = {};
|
|
1889
|
+
__export(session_inbox_exports, {
|
|
1890
|
+
Compaction: () => Compaction3,
|
|
1891
|
+
CompactionPayload: () => CompactionPayload,
|
|
1892
|
+
Delivery: () => Delivery,
|
|
1893
|
+
Info: () => Info18,
|
|
1894
|
+
Item: () => Item,
|
|
1895
|
+
Move: () => Move,
|
|
1896
|
+
MovePayload: () => MovePayload,
|
|
1897
|
+
SessionInbox: () => session_inbox_exports,
|
|
1898
|
+
Synthetic: () => Synthetic2,
|
|
1899
|
+
SyntheticPayload: () => SyntheticPayload,
|
|
1900
|
+
User: () => User2,
|
|
1901
|
+
UserPayload: () => UserPayload
|
|
1902
|
+
});
|
|
1903
|
+
import { Schema as Schema37 } from "effect";
|
|
1904
|
+
var Delivery = Schema37.Literals(["steer", "queue"]).annotate({ identifier: "Session.Inbox.Delivery" });
|
|
1905
|
+
var UserPayload = Schema37.Struct({
|
|
1906
|
+
...Prompt.fields,
|
|
1907
|
+
metadata: Schema37.Record(Schema37.String, Schema37.Unknown).pipe(optional)
|
|
1908
|
+
}).annotate({ identifier: "Session.Inbox.UserPayload" });
|
|
1909
|
+
var SyntheticPayload = Schema37.Struct({
|
|
1910
|
+
text: Schema37.String,
|
|
1911
|
+
description: Schema37.String.pipe(optional),
|
|
1912
|
+
metadata: Schema37.Record(Schema37.String, Schema37.Unknown).pipe(optional)
|
|
1913
|
+
}).annotate({ identifier: "Session.Inbox.SyntheticPayload" });
|
|
1914
|
+
var CompactionPayload = Schema37.Struct({}).annotate({ identifier: "Session.Inbox.CompactionPayload" });
|
|
1915
|
+
var MovePayload = Schema37.Struct({
|
|
1916
|
+
location: location_exports.Ref,
|
|
1917
|
+
projectID: project_exports.ID,
|
|
1918
|
+
subpath: RelativePath.pipe(optional)
|
|
1919
|
+
}).annotate({ identifier: "Session.Inbox.MovePayload" });
|
|
1920
|
+
var UserItem = Schema37.Struct({ type: Schema37.tag("user"), payload: UserPayload, delivery: Delivery });
|
|
1921
|
+
var SyntheticItem = Schema37.Struct({ type: Schema37.tag("synthetic"), payload: SyntheticPayload, delivery: Delivery });
|
|
1922
|
+
var CompactionItem = Schema37.Struct({
|
|
1923
|
+
type: Schema37.tag("compaction"),
|
|
1924
|
+
payload: CompactionPayload,
|
|
1925
|
+
delivery: Delivery
|
|
1926
|
+
});
|
|
1927
|
+
var MoveItem = Schema37.Struct({ type: Schema37.tag("move"), payload: MovePayload, delivery: Delivery });
|
|
1928
|
+
var Item = Schema37.Union([UserItem, SyntheticItem, CompactionItem, MoveItem]).pipe(Schema37.toTaggedUnion("type"), Schema37.annotate({ identifier: "Session.Inbox.Item" }));
|
|
1929
|
+
var Enqueued = {
|
|
1930
|
+
id: session_message_exports.ID,
|
|
1931
|
+
sessionID: SessionID,
|
|
1932
|
+
time: Schema37.Struct({ created: DateTimeUtcFromMillis })
|
|
1933
|
+
};
|
|
1934
|
+
var User2 = Schema37.Struct({ ...Enqueued, ...UserItem.fields }).annotate({ identifier: "Session.Inbox.User" });
|
|
1935
|
+
var Synthetic2 = Schema37.Struct({ ...Enqueued, ...SyntheticItem.fields }).annotate({
|
|
1936
|
+
identifier: "Session.Inbox.Synthetic"
|
|
1937
|
+
});
|
|
1938
|
+
var Compaction3 = Schema37.Struct({ ...Enqueued, ...CompactionItem.fields }).annotate({
|
|
1939
|
+
identifier: "Session.Inbox.Compaction"
|
|
1940
|
+
});
|
|
1941
|
+
var Move = Schema37.Struct({ ...Enqueued, ...MoveItem.fields }).annotate({ identifier: "Session.Inbox.Move" });
|
|
1942
|
+
var Info18 = Schema37.Union([User2, Synthetic2, Compaction3, Move]).pipe(Schema37.toTaggedUnion("type"), Schema37.annotate({ identifier: "Session.Inbox.Info" }));
|
|
1943
|
+
|
|
1944
|
+
// node_modules/@opencode/schema/dist/session-fork.js
|
|
1945
|
+
var session_fork_exports = {};
|
|
1946
|
+
__export(session_fork_exports, {
|
|
1947
|
+
Boundary: () => Boundary,
|
|
1948
|
+
SessionFork: () => session_fork_exports
|
|
1949
|
+
});
|
|
1950
|
+
import { Schema as Schema38 } from "effect";
|
|
1951
|
+
var Boundary = Schema38.Union([
|
|
1952
|
+
Schema38.Struct({ type: Schema38.Literal("before"), messageID: session_message_exports.ID }),
|
|
1953
|
+
Schema38.Struct({ type: Schema38.Literal("through"), messageID: session_message_exports.ID })
|
|
1954
|
+
]).annotate({ identifier: "Session.ForkBoundary" });
|
|
1955
|
+
|
|
1956
|
+
// node_modules/@opencode/schema/dist/session-event.js
|
|
1957
|
+
var Source3 = Schema39.Struct({
|
|
1958
|
+
start: NonNegativeInt,
|
|
1959
|
+
end: NonNegativeInt,
|
|
1960
|
+
text: Schema39.String
|
|
1961
|
+
}).annotate({
|
|
1962
|
+
identifier: "Session.Event.Source"
|
|
1963
|
+
});
|
|
1964
|
+
var Base2 = {
|
|
1965
|
+
sessionID: SessionID
|
|
1966
|
+
};
|
|
1967
|
+
var options = {
|
|
1968
|
+
durable: {
|
|
1969
|
+
aggregate: "sessionID",
|
|
1970
|
+
version: 1
|
|
1971
|
+
}
|
|
1972
|
+
};
|
|
1973
|
+
var Created4 = event_exports.durable({
|
|
1974
|
+
type: "session.created",
|
|
1975
|
+
...options,
|
|
1976
|
+
schema: {
|
|
1977
|
+
...Base2,
|
|
1978
|
+
projectID: project_exports.ID,
|
|
1979
|
+
location: location_exports.Ref,
|
|
1980
|
+
subpath: RelativePath.pipe(optional),
|
|
1981
|
+
parentID: SessionID.pipe(optional),
|
|
1982
|
+
slug: Schema39.String,
|
|
1983
|
+
title: Schema39.String.pipe(optional),
|
|
1984
|
+
agent: agent_exports.ID.pipe(optional),
|
|
1985
|
+
model: model_exports.Ref.pipe(optional),
|
|
1986
|
+
/** Host-supplied annotations resolved at creation, including any inherited from a parent. */
|
|
1987
|
+
metadata: SessionMetadata.pipe(optional),
|
|
1988
|
+
permissions: permission_exports.Ruleset.pipe(optional),
|
|
1989
|
+
version: Schema39.String
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
var AgentSelected2 = event_exports.durable({
|
|
1993
|
+
type: "session.agent.selected",
|
|
1994
|
+
...options,
|
|
1995
|
+
schema: {
|
|
1996
|
+
...Base2,
|
|
1997
|
+
agent: agent_exports.ID,
|
|
1998
|
+
previous: agent_exports.ID.pipe(optional)
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
var ModelSelected2 = event_exports.durable({
|
|
2002
|
+
type: "session.model.selected",
|
|
2003
|
+
...options,
|
|
2004
|
+
schema: {
|
|
2005
|
+
...Base2,
|
|
2006
|
+
model: model_exports.Ref,
|
|
2007
|
+
previous: model_exports.Ref.pipe(optional)
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
var Moved = event_exports.durable({
|
|
2011
|
+
type: "session.moved",
|
|
2012
|
+
...options,
|
|
2013
|
+
schema: {
|
|
2014
|
+
...Base2,
|
|
2015
|
+
...session_inbox_exports.MovePayload.fields
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
var Renamed = event_exports.durable({
|
|
2019
|
+
type: "session.renamed",
|
|
2020
|
+
...options,
|
|
2021
|
+
schema: {
|
|
2022
|
+
...Base2,
|
|
2023
|
+
title: Schema39.String
|
|
2024
|
+
}
|
|
2025
|
+
});
|
|
2026
|
+
var MetadataUpdated = event_exports.durable({
|
|
2027
|
+
type: "session.metadata.updated",
|
|
2028
|
+
...options,
|
|
2029
|
+
schema: {
|
|
2030
|
+
...Base2,
|
|
2031
|
+
metadata: SessionMetadata
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
var Permissions = event_exports.durable({
|
|
2035
|
+
type: "session.permissions",
|
|
2036
|
+
...options,
|
|
2037
|
+
schema: {
|
|
2038
|
+
...Base2,
|
|
2039
|
+
permissions: permission_exports.Ruleset
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
var Viewed = event_exports.durable({
|
|
2043
|
+
type: "session.viewed",
|
|
2044
|
+
...options,
|
|
2045
|
+
schema: {
|
|
2046
|
+
...Base2,
|
|
2047
|
+
/** Epoch-millisecond idle watermark the viewer observed; projection never marks a newer idle transition viewed. */
|
|
2048
|
+
idle: Schema39.Finite
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
var MessageContentUpdated = event_exports.durable({
|
|
2052
|
+
type: "session.message.content.updated",
|
|
2053
|
+
...options,
|
|
2054
|
+
schema: {
|
|
2055
|
+
...Base2,
|
|
2056
|
+
messageID: session_message_exports.ID,
|
|
2057
|
+
// Public events are framed directly, so timestamps must already be encoded.
|
|
2058
|
+
content: Schema39.Array(session_message_exports.AssistantContentEncoded)
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
var UsageRecorded = event_exports.durable({
|
|
2062
|
+
type: "session.usage.recorded",
|
|
2063
|
+
...options,
|
|
2064
|
+
schema: {
|
|
2065
|
+
...Base2,
|
|
2066
|
+
source: Schema39.Literals(["title", "compaction"]),
|
|
2067
|
+
cost: money_exports.USD,
|
|
2068
|
+
tokens: token_usage_exports.Info
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
var UsageUpdated = event_exports.ephemeral({
|
|
2072
|
+
type: "session.usage.updated",
|
|
2073
|
+
schema: {
|
|
2074
|
+
...Base2,
|
|
2075
|
+
cost: money_exports.USD,
|
|
2076
|
+
tokens: token_usage_exports.Info
|
|
2077
|
+
}
|
|
2078
|
+
});
|
|
2079
|
+
var Deleted3 = event_exports.durable({
|
|
2080
|
+
type: "session.deleted",
|
|
2081
|
+
durable: {
|
|
2082
|
+
aggregate: "sessionID",
|
|
2083
|
+
version: 2
|
|
2084
|
+
},
|
|
2085
|
+
schema: Base2
|
|
2086
|
+
});
|
|
2087
|
+
var Forked = event_exports.durable({
|
|
2088
|
+
type: "session.forked",
|
|
2089
|
+
durable: {
|
|
2090
|
+
aggregate: "sessionID",
|
|
2091
|
+
version: 2
|
|
2092
|
+
},
|
|
2093
|
+
schema: {
|
|
2094
|
+
...Base2,
|
|
2095
|
+
parentID: SessionID,
|
|
2096
|
+
boundary: session_fork_exports.Boundary,
|
|
2097
|
+
instructions: instruction_exports.Values.pipe(optional),
|
|
2098
|
+
instructionEntries: instruction_entry_exports.Snapshot.pipe(optional)
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2101
|
+
var InboxRef = {
|
|
2102
|
+
...Base2,
|
|
2103
|
+
inboxID: session_message_exports.ID
|
|
2104
|
+
};
|
|
2105
|
+
var InboxDelivered = event_exports.durable({
|
|
2106
|
+
type: "session.inbox.delivered",
|
|
2107
|
+
...options,
|
|
2108
|
+
schema: InboxRef
|
|
2109
|
+
});
|
|
2110
|
+
var InboxEnqueued = event_exports.durable({
|
|
2111
|
+
type: "session.inbox.enqueued",
|
|
2112
|
+
...options,
|
|
2113
|
+
schema: {
|
|
2114
|
+
...InboxRef,
|
|
2115
|
+
item: session_inbox_exports.Item
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
var InboxCancelled = event_exports.durable({
|
|
2119
|
+
type: "session.inbox.cancelled",
|
|
2120
|
+
...options,
|
|
2121
|
+
schema: InboxRef
|
|
2122
|
+
});
|
|
2123
|
+
var InboxDeliveryChanged = event_exports.durable({
|
|
2124
|
+
type: "session.inbox.delivery.changed",
|
|
2125
|
+
...options,
|
|
2126
|
+
schema: { ...InboxRef, delivery: session_inbox_exports.Delivery }
|
|
2127
|
+
});
|
|
2128
|
+
var Execution;
|
|
2129
|
+
(function(Execution2) {
|
|
2130
|
+
Execution2.Started = event_exports.durable({ type: "session.execution.started", ...options, schema: Base2 });
|
|
2131
|
+
Execution2.Succeeded = event_exports.durable({ type: "session.execution.succeeded", ...options, schema: Base2 });
|
|
2132
|
+
Execution2.Failed = event_exports.durable({
|
|
2133
|
+
type: "session.execution.failed",
|
|
2134
|
+
...options,
|
|
2135
|
+
schema: { ...Base2, error: session_error_exports.Error }
|
|
2136
|
+
});
|
|
2137
|
+
Execution2.Interrupted = event_exports.durable({
|
|
2138
|
+
type: "session.execution.interrupted",
|
|
2139
|
+
...options,
|
|
2140
|
+
schema: { ...Base2, reason: Schema39.Literals(["user", "shutdown", "superseded", "inactivity"]) }
|
|
2141
|
+
});
|
|
2142
|
+
})(Execution || (Execution = {}));
|
|
2143
|
+
var InstructionsUpdated = event_exports.durable({
|
|
2144
|
+
type: "session.instructions.updated",
|
|
2145
|
+
durable: {
|
|
2146
|
+
aggregate: "sessionID",
|
|
2147
|
+
version: 2
|
|
2148
|
+
},
|
|
2149
|
+
schema: {
|
|
2150
|
+
...Base2,
|
|
2151
|
+
delta: instruction_exports.Delta,
|
|
2152
|
+
/**
|
|
2153
|
+
* The rendered chronological update shown to the model, frozen at emit time.
|
|
2154
|
+
* Absent for the initial baseline observation and for deltas that render empty.
|
|
2155
|
+
*/
|
|
2156
|
+
text: Schema39.String.pipe(optional)
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
var Synthetic3 = event_exports.durable({
|
|
2160
|
+
type: "session.synthetic",
|
|
2161
|
+
...options,
|
|
2162
|
+
schema: {
|
|
2163
|
+
...Base2,
|
|
2164
|
+
text: Schema39.String,
|
|
2165
|
+
description: Schema39.String.pipe(optional),
|
|
2166
|
+
metadata: Schema39.Record(Schema39.String, Schema39.Unknown).pipe(optional)
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2169
|
+
var Skill2;
|
|
2170
|
+
(function(Skill3) {
|
|
2171
|
+
Skill3.Activated = event_exports.durable({
|
|
2172
|
+
type: "session.skill.activated",
|
|
2173
|
+
...options,
|
|
2174
|
+
schema: {
|
|
2175
|
+
...Base2,
|
|
2176
|
+
id: skill_exports.ID,
|
|
2177
|
+
name: skill_exports.Name,
|
|
2178
|
+
text: Schema39.String
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
})(Skill2 || (Skill2 = {}));
|
|
2182
|
+
var Shell2;
|
|
2183
|
+
(function(Shell3) {
|
|
2184
|
+
Shell3.Started = event_exports.durable({
|
|
2185
|
+
type: "session.shell.started",
|
|
2186
|
+
...options,
|
|
2187
|
+
schema: {
|
|
2188
|
+
...Base2,
|
|
2189
|
+
shell: shell_exports.Info
|
|
2190
|
+
}
|
|
2191
|
+
});
|
|
2192
|
+
Shell3.Ended = event_exports.durable({
|
|
2193
|
+
type: "session.shell.ended",
|
|
2194
|
+
...options,
|
|
2195
|
+
schema: {
|
|
2196
|
+
...Base2,
|
|
2197
|
+
shell: shell_exports.Info,
|
|
2198
|
+
output: shell_exports.Output
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
})(Shell2 || (Shell2 = {}));
|
|
2202
|
+
var Step;
|
|
2203
|
+
(function(Step2) {
|
|
2204
|
+
Step2.Started = event_exports.durable({
|
|
2205
|
+
type: "session.step.started",
|
|
2206
|
+
...options,
|
|
2207
|
+
schema: {
|
|
2208
|
+
...Base2,
|
|
2209
|
+
assistantMessageID: session_message_exports.ID,
|
|
2210
|
+
agent: agent_exports.ID,
|
|
2211
|
+
model: model_exports.Ref,
|
|
2212
|
+
snapshot: snapshot_exports.ID.pipe(optional),
|
|
2213
|
+
/** Request dispatch time, before waiting for provider output. */
|
|
2214
|
+
started: NonNegativeInt
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
Step2.Streamed = event_exports.durable({
|
|
2218
|
+
type: "session.step.streamed",
|
|
2219
|
+
...options,
|
|
2220
|
+
schema: {
|
|
2221
|
+
...Base2,
|
|
2222
|
+
assistantMessageID: session_message_exports.ID
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
Step2.Ended = event_exports.durable({
|
|
2226
|
+
type: "session.step.ended",
|
|
2227
|
+
...options,
|
|
2228
|
+
schema: {
|
|
2229
|
+
...Base2,
|
|
2230
|
+
assistantMessageID: session_message_exports.ID,
|
|
2231
|
+
finish: FinishReason,
|
|
2232
|
+
rawFinish: Schema39.String.pipe(optional),
|
|
2233
|
+
providerState: session_message_exports.ProviderState.pipe(optional),
|
|
2234
|
+
cost: money_exports.USD,
|
|
2235
|
+
tokens: token_usage_exports.Info,
|
|
2236
|
+
snapshot: snapshot_exports.ID.pipe(optional),
|
|
2237
|
+
files: Schema39.Array(RelativePath).pipe(optional)
|
|
2238
|
+
}
|
|
2239
|
+
});
|
|
2240
|
+
Step2.Failed = event_exports.durable({
|
|
2241
|
+
type: "session.step.failed",
|
|
2242
|
+
...options,
|
|
2243
|
+
schema: {
|
|
2244
|
+
...Base2,
|
|
2245
|
+
assistantMessageID: session_message_exports.ID,
|
|
2246
|
+
error: session_error_exports.Error,
|
|
2247
|
+
finish: Schema39.Literals(["content-filter"]).pipe(optional),
|
|
2248
|
+
rawFinish: Schema39.String.pipe(optional),
|
|
2249
|
+
providerState: session_message_exports.ProviderState.pipe(optional),
|
|
2250
|
+
cost: money_exports.USD.pipe(optional),
|
|
2251
|
+
tokens: token_usage_exports.Info.pipe(optional),
|
|
2252
|
+
snapshot: snapshot_exports.ID.pipe(optional),
|
|
2253
|
+
files: Schema39.Array(RelativePath).pipe(optional)
|
|
2254
|
+
}
|
|
2255
|
+
});
|
|
2256
|
+
})(Step || (Step = {}));
|
|
2257
|
+
var Text;
|
|
2258
|
+
(function(Text2) {
|
|
2259
|
+
Text2.Started = event_exports.durable({
|
|
2260
|
+
type: "session.text.started",
|
|
2261
|
+
...options,
|
|
2262
|
+
schema: {
|
|
2263
|
+
...Base2,
|
|
2264
|
+
assistantMessageID: session_message_exports.ID,
|
|
2265
|
+
ordinal: NonNegativeInt
|
|
2266
|
+
}
|
|
2267
|
+
});
|
|
2268
|
+
Text2.Delta = event_exports.ephemeral({
|
|
2269
|
+
type: "session.text.delta",
|
|
2270
|
+
schema: {
|
|
2271
|
+
...Base2,
|
|
2272
|
+
assistantMessageID: session_message_exports.ID,
|
|
2273
|
+
ordinal: NonNegativeInt,
|
|
2274
|
+
delta: Schema39.String
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
Text2.Ended = event_exports.durable({
|
|
2278
|
+
type: "session.text.ended",
|
|
2279
|
+
...options,
|
|
2280
|
+
schema: {
|
|
2281
|
+
...Base2,
|
|
2282
|
+
assistantMessageID: session_message_exports.ID,
|
|
2283
|
+
ordinal: NonNegativeInt,
|
|
2284
|
+
text: Schema39.String,
|
|
2285
|
+
state: session_message_exports.ProviderState.pipe(optional)
|
|
2286
|
+
}
|
|
2287
|
+
});
|
|
2288
|
+
})(Text || (Text = {}));
|
|
2289
|
+
var Reasoning;
|
|
2290
|
+
(function(Reasoning2) {
|
|
2291
|
+
Reasoning2.Started = event_exports.durable({
|
|
2292
|
+
type: "session.reasoning.started",
|
|
2293
|
+
...options,
|
|
2294
|
+
schema: {
|
|
2295
|
+
...Base2,
|
|
2296
|
+
assistantMessageID: session_message_exports.ID,
|
|
2297
|
+
ordinal: NonNegativeInt,
|
|
2298
|
+
state: session_message_exports.ProviderState.pipe(optional)
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
Reasoning2.Delta = event_exports.ephemeral({
|
|
2302
|
+
type: "session.reasoning.delta",
|
|
2303
|
+
schema: {
|
|
2304
|
+
...Base2,
|
|
2305
|
+
assistantMessageID: session_message_exports.ID,
|
|
2306
|
+
ordinal: NonNegativeInt,
|
|
2307
|
+
delta: Schema39.String
|
|
2308
|
+
}
|
|
2309
|
+
});
|
|
2310
|
+
Reasoning2.Ended = event_exports.durable({
|
|
2311
|
+
type: "session.reasoning.ended",
|
|
2312
|
+
...options,
|
|
2313
|
+
schema: {
|
|
2314
|
+
...Base2,
|
|
2315
|
+
assistantMessageID: session_message_exports.ID,
|
|
2316
|
+
ordinal: NonNegativeInt,
|
|
2317
|
+
text: Schema39.String,
|
|
2318
|
+
state: session_message_exports.ProviderState.pipe(optional)
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
})(Reasoning || (Reasoning = {}));
|
|
2322
|
+
var Tool;
|
|
2323
|
+
(function(Tool3) {
|
|
2324
|
+
const ToolBase = {
|
|
2325
|
+
...Base2,
|
|
2326
|
+
assistantMessageID: session_message_exports.ID,
|
|
2327
|
+
id: Schema39.String
|
|
2328
|
+
};
|
|
2329
|
+
let Input2;
|
|
2330
|
+
(function(Input3) {
|
|
2331
|
+
Input3.Started = event_exports.durable({
|
|
2332
|
+
type: "session.tool.input.started",
|
|
2333
|
+
...options,
|
|
2334
|
+
schema: {
|
|
2335
|
+
...ToolBase,
|
|
2336
|
+
name: Schema39.String
|
|
2337
|
+
}
|
|
2338
|
+
});
|
|
2339
|
+
Input3.Delta = event_exports.ephemeral({
|
|
2340
|
+
type: "session.tool.input.delta",
|
|
2341
|
+
schema: {
|
|
2342
|
+
...ToolBase,
|
|
2343
|
+
delta: Schema39.String
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
Input3.Ended = event_exports.durable({
|
|
2347
|
+
type: "session.tool.input.ended",
|
|
2348
|
+
...options,
|
|
2349
|
+
schema: {
|
|
2350
|
+
...ToolBase,
|
|
2351
|
+
text: Schema39.String
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
})(Input2 = Tool3.Input || (Tool3.Input = {}));
|
|
2355
|
+
Tool3.Called = event_exports.durable({
|
|
2356
|
+
type: "session.tool.called",
|
|
2357
|
+
...options,
|
|
2358
|
+
schema: {
|
|
2359
|
+
...ToolBase,
|
|
2360
|
+
input: Schema39.Record(Schema39.String, Schema39.Unknown),
|
|
2361
|
+
executed: Schema39.Boolean,
|
|
2362
|
+
state: session_message_exports.ProviderState.pipe(optional)
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
Tool3.Progress = event_exports.ephemeral({
|
|
2366
|
+
type: "session.tool.progress",
|
|
2367
|
+
schema: {
|
|
2368
|
+
...ToolBase,
|
|
2369
|
+
metadata: Schema39.Record(Schema39.String, Schema39.Json)
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
Tool3.Success = event_exports.durable({
|
|
2373
|
+
type: "session.tool.success",
|
|
2374
|
+
durable: {
|
|
2375
|
+
aggregate: "sessionID",
|
|
2376
|
+
version: 2
|
|
2377
|
+
},
|
|
2378
|
+
schema: {
|
|
2379
|
+
...ToolBase,
|
|
2380
|
+
content: Schema39.NonEmptyArray(Content),
|
|
2381
|
+
metadata: Schema39.Record(Schema39.String, Schema39.Json).pipe(optional),
|
|
2382
|
+
executed: Schema39.Boolean,
|
|
2383
|
+
resultState: session_message_exports.ProviderState.pipe(optional)
|
|
2384
|
+
}
|
|
2385
|
+
});
|
|
2386
|
+
Tool3.Failed = event_exports.durable({
|
|
2387
|
+
type: "session.tool.failed",
|
|
2388
|
+
durable: {
|
|
2389
|
+
aggregate: "sessionID",
|
|
2390
|
+
version: 2
|
|
2391
|
+
},
|
|
2392
|
+
schema: {
|
|
2393
|
+
...ToolBase,
|
|
2394
|
+
error: session_error_exports.Error,
|
|
2395
|
+
content: Schema39.NonEmptyArray(Content).pipe(optional),
|
|
2396
|
+
metadata: Schema39.Record(Schema39.String, Schema39.Json).pipe(optional),
|
|
2397
|
+
executed: Schema39.Boolean,
|
|
2398
|
+
resultState: session_message_exports.ProviderState.pipe(optional)
|
|
2399
|
+
}
|
|
2400
|
+
});
|
|
2401
|
+
})(Tool || (Tool = {}));
|
|
2402
|
+
var RetryScheduled = event_exports.durable({
|
|
2403
|
+
type: "session.retry.scheduled",
|
|
2404
|
+
...options,
|
|
2405
|
+
schema: {
|
|
2406
|
+
...Base2,
|
|
2407
|
+
assistantMessageID: session_message_exports.ID,
|
|
2408
|
+
attempt: PositiveInt,
|
|
2409
|
+
at: NonNegativeInt,
|
|
2410
|
+
error: session_error_exports.Error
|
|
2411
|
+
}
|
|
2412
|
+
});
|
|
2413
|
+
var Compaction4;
|
|
2414
|
+
(function(Compaction5) {
|
|
2415
|
+
Compaction5.Started = event_exports.durable({
|
|
2416
|
+
type: "session.compaction.started",
|
|
2417
|
+
...options,
|
|
2418
|
+
schema: {
|
|
2419
|
+
...Base2,
|
|
2420
|
+
reason: Schema39.Literals(["auto", "manual"]),
|
|
2421
|
+
recent: Schema39.String,
|
|
2422
|
+
inputID: session_message_exports.ID.pipe(optional)
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
Compaction5.Delta = event_exports.ephemeral({
|
|
2426
|
+
type: "session.compaction.delta",
|
|
2427
|
+
schema: {
|
|
2428
|
+
...Base2,
|
|
2429
|
+
text: Schema39.String
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
Compaction5.Ended = event_exports.durable({
|
|
2433
|
+
type: "session.compaction.ended",
|
|
2434
|
+
...options,
|
|
2435
|
+
schema: {
|
|
2436
|
+
...Base2,
|
|
2437
|
+
reason: Compaction5.Started.data.fields.reason,
|
|
2438
|
+
model: session_message_exports.CompactionCompleted.fields.model,
|
|
2439
|
+
providerState: session_message_exports.CompactionCompleted.fields.providerState,
|
|
2440
|
+
providerContext: session_message_exports.CompactionCompleted.fields.providerContext,
|
|
2441
|
+
text: Schema39.String,
|
|
2442
|
+
recent: Schema39.String,
|
|
2443
|
+
// Repeats the internal `session.usage.recorded` figures: that event never reaches clients, and it
|
|
2444
|
+
// stays the accounting source for session totals and stats.
|
|
2445
|
+
cost: session_message_exports.CompactionCompleted.fields.cost,
|
|
2446
|
+
tokens: session_message_exports.CompactionCompleted.fields.tokens
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
Compaction5.Failed = event_exports.durable({
|
|
2450
|
+
type: "session.compaction.failed",
|
|
2451
|
+
...options,
|
|
2452
|
+
schema: {
|
|
2453
|
+
...Base2,
|
|
2454
|
+
reason: Compaction5.Started.data.fields.reason,
|
|
2455
|
+
error: session_error_exports.Error,
|
|
2456
|
+
inputID: session_message_exports.ID.pipe(optional),
|
|
2457
|
+
cost: session_message_exports.CompactionFailed.fields.cost,
|
|
2458
|
+
tokens: session_message_exports.CompactionFailed.fields.tokens
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
})(Compaction4 || (Compaction4 = {}));
|
|
2462
|
+
var RevertEvent;
|
|
2463
|
+
(function(RevertEvent2) {
|
|
2464
|
+
RevertEvent2.Staged = event_exports.durable({
|
|
2465
|
+
type: "session.revert.staged",
|
|
2466
|
+
...options,
|
|
2467
|
+
schema: { ...Base2, revert: Revert }
|
|
2468
|
+
});
|
|
2469
|
+
RevertEvent2.Cleared = event_exports.durable({ type: "session.revert.cleared", ...options, schema: Base2 });
|
|
2470
|
+
RevertEvent2.Committed = event_exports.durable({
|
|
2471
|
+
type: "session.revert.committed",
|
|
2472
|
+
...options,
|
|
2473
|
+
schema: { ...Base2, to: session_message_exports.ID }
|
|
2474
|
+
});
|
|
2475
|
+
})(RevertEvent || (RevertEvent = {}));
|
|
2476
|
+
var Definitions = event_exports.inventory(Created4, AgentSelected2, ModelSelected2, Moved, Renamed, MetadataUpdated, Permissions, Viewed, UsageUpdated, Deleted3, Forked, InboxDelivered, InboxEnqueued, InboxCancelled, InboxDeliveryChanged, Execution.Started, Execution.Succeeded, Execution.Failed, Execution.Interrupted, InstructionsUpdated, Synthetic3, Skill2.Activated, Shell2.Started, Shell2.Ended, Step.Started, Step.Streamed, Step.Ended, Step.Failed, Text.Started, Text.Delta, Text.Ended, Reasoning.Started, Reasoning.Delta, Reasoning.Ended, Tool.Input.Started, Tool.Input.Delta, Tool.Input.Ended, Tool.Called, Tool.Progress, Tool.Success, Tool.Failed, RetryScheduled, Compaction4.Started, Compaction4.Delta, Compaction4.Ended, Compaction4.Failed, RevertEvent.Staged, RevertEvent.Cleared, RevertEvent.Committed);
|
|
2477
|
+
var DurableDefinitions = event_exports.inventory(...Definitions.filter((definition) => definition.durability === "durable"), UsageRecorded, MessageContentUpdated);
|
|
2478
|
+
var EphemeralDefinitions = event_exports.inventory(...Definitions.filter((definition) => definition.durability === "ephemeral"));
|
|
2479
|
+
var Durable = Schema39.Union(DurableDefinitions, { mode: "oneOf" }).pipe(Schema39.toTaggedUnion("type")).annotate({ identifier: "Session.Event.Durable" });
|
|
2480
|
+
var All = Schema39.Union([Durable, ...EphemeralDefinitions], { mode: "oneOf" }).pipe(Schema39.toTaggedUnion("type"));
|
|
2481
|
+
|
|
2482
|
+
// node_modules/@opencode/schema/dist/session.js
|
|
2483
|
+
var ID15 = SessionID;
|
|
2484
|
+
var Metadata3 = SessionMetadata;
|
|
2485
|
+
var Event13 = session_event_exports;
|
|
2486
|
+
var ForkBoundary = session_fork_exports.Boundary;
|
|
2487
|
+
var Info19 = Schema40.Struct({
|
|
2488
|
+
id: ID15,
|
|
2489
|
+
parentID: ID15.pipe(optional),
|
|
2490
|
+
fork: Schema40.Struct({
|
|
2491
|
+
sessionID: ID15,
|
|
2492
|
+
boundary: ForkBoundary
|
|
2493
|
+
}).pipe(optional),
|
|
2494
|
+
projectID: project_exports.ID,
|
|
2495
|
+
agent: agent_exports.ID.pipe(optional),
|
|
2496
|
+
model: model_exports.Ref.pipe(optional),
|
|
2497
|
+
cost: money_exports.USD,
|
|
2498
|
+
tokens: token_usage_exports.Info,
|
|
2499
|
+
/** Outcome of the last completed execution, recorded at `time.idle`. Absent until a run reaches a terminal transition. */
|
|
2500
|
+
outcome: Schema40.Literals(["succeeded", "failed", "interrupted"]).pipe(optional),
|
|
2501
|
+
time: Schema40.Struct({
|
|
2502
|
+
created: DateTimeUtcFromMillis,
|
|
2503
|
+
updated: DateTimeUtcFromMillis,
|
|
2504
|
+
idle: DateTimeUtcFromMillis.pipe(optional),
|
|
2505
|
+
viewed: DateTimeUtcFromMillis.pipe(optional),
|
|
2506
|
+
archived: DateTimeUtcFromMillis.pipe(optional)
|
|
2507
|
+
}),
|
|
2508
|
+
title: Schema40.String.pipe(optional),
|
|
2509
|
+
location: location_exports.Ref,
|
|
2510
|
+
subpath: RelativePath.pipe(optional),
|
|
2511
|
+
metadata: Metadata3.pipe(optional),
|
|
2512
|
+
/** Evaluated after the agent's rules; the last matching rule wins. */
|
|
2513
|
+
permissions: permission_exports.Ruleset.pipe(optional),
|
|
2514
|
+
revert: Revert.pipe(optional)
|
|
2515
|
+
}).annotate({ identifier: "Session.Info" });
|
|
2516
|
+
var ListAnchor = Schema40.Struct({
|
|
2517
|
+
id: ID15,
|
|
2518
|
+
time: Schema40.Finite,
|
|
2519
|
+
direction: Schema40.Literals(["previous", "next"])
|
|
2520
|
+
}).annotate({ identifier: "Session.ListAnchor" });
|
|
2521
|
+
|
|
2522
|
+
// node_modules/@opencode/schema/dist/persistent-pty.js
|
|
2523
|
+
var Info20 = Schema41.Struct({
|
|
2524
|
+
...pty_exports.Info.fields,
|
|
2525
|
+
sessionID: session_exports.ID,
|
|
2526
|
+
foregroundProcess: Schema41.NullOr(Schema41.String),
|
|
2527
|
+
size: Schema41.Struct({ cols: PositiveInt, rows: PositiveInt }),
|
|
2528
|
+
output: Schema41.Struct({ head: NonNegativeInt, tail: NonNegativeInt })
|
|
2529
|
+
}).annotate({ identifier: "PersistentPty.Info" });
|
|
2530
|
+
var Handoff = Schema41.Struct({
|
|
2531
|
+
directory: Schema41.String,
|
|
2532
|
+
instanceID: Schema41.String,
|
|
2533
|
+
ticket: Schema41.String,
|
|
2534
|
+
expiresAt: Schema41.Number
|
|
2535
|
+
}).annotate({ identifier: "PersistentPty.Handoff" });
|
|
2536
|
+
var CreateInput4 = Schema41.Struct({
|
|
2537
|
+
command: optional(Schema41.String),
|
|
2538
|
+
args: Schema41.Array(Schema41.String),
|
|
2539
|
+
cwd: optional(Schema41.String),
|
|
2540
|
+
title: Schema41.String,
|
|
2541
|
+
env: Schema41.Record(Schema41.String, Schema41.String),
|
|
2542
|
+
size: optional(Schema41.Struct({ cols: PositiveInt, rows: PositiveInt }))
|
|
2543
|
+
}).annotate({ identifier: "PersistentPty.CreateInput" });
|
|
2544
|
+
var UpdateInput3 = Schema41.Struct({
|
|
2545
|
+
attachmentID: optional(Schema41.String),
|
|
2546
|
+
size: Schema41.Struct({ cols: PositiveInt, rows: PositiveInt })
|
|
2547
|
+
}).annotate({ identifier: "PersistentPty.UpdateInput" });
|
|
2548
|
+
var Snapshot2 = Schema41.Struct({
|
|
2549
|
+
info: Info20,
|
|
2550
|
+
text: Schema41.String,
|
|
2551
|
+
checkpoint: Schema41.Uint8Array,
|
|
2552
|
+
cursor: Schema41.Struct({ x: NonNegativeInt, y: NonNegativeInt })
|
|
2553
|
+
}).annotate({ identifier: "PersistentPty.Snapshot" });
|
|
2554
|
+
var ReadLines = PositiveInt.check(Schema41.isLessThanOrEqualTo(65535)).annotate({
|
|
2555
|
+
identifier: "PersistentPty.ReadLines"
|
|
2556
|
+
});
|
|
2557
|
+
var ReadResult = Schema41.Struct({
|
|
2558
|
+
ptyID: pty_exports.ID,
|
|
2559
|
+
title: Schema41.String,
|
|
2560
|
+
cwd: Schema41.String,
|
|
2561
|
+
foregroundProcess: Schema41.NullOr(Schema41.String),
|
|
2562
|
+
screen: Schema41.Struct({
|
|
2563
|
+
text: Schema41.String,
|
|
2564
|
+
cols: PositiveInt,
|
|
2565
|
+
rows: PositiveInt,
|
|
2566
|
+
cursor: Snapshot2.fields.cursor
|
|
2567
|
+
})
|
|
2568
|
+
}).annotate({ identifier: "PersistentPty.ReadResult" });
|
|
2569
|
+
var Added = ephemeral({ type: "persistent-pty.added", schema: { sessionID: session_exports.ID, terminal: Info20 } });
|
|
2570
|
+
var Removed2 = ephemeral({ type: "persistent-pty.removed", schema: { sessionID: session_exports.ID, ptyID: pty_exports.ID } });
|
|
2571
|
+
var Event14 = { Added, Removed: Removed2, Definitions: inventory(Added, Removed2) };
|
|
2572
|
+
|
|
2573
|
+
// node_modules/@opencode/schema/dist/reference.js
|
|
2574
|
+
import { Schema as Schema42 } from "effect";
|
|
2575
|
+
var Updated10 = ephemeral({ type: "reference.updated", schema: {} });
|
|
2576
|
+
var Event15 = { Updated: Updated10, Definitions: inventory(Updated10) };
|
|
2577
|
+
var LocalSource = Schema42.Struct({
|
|
2578
|
+
type: Schema42.Literal("local"),
|
|
2579
|
+
path: AbsolutePath,
|
|
2580
|
+
description: Schema42.String.pipe(optional),
|
|
2581
|
+
hidden: Schema42.Boolean.pipe(optional)
|
|
2582
|
+
}).annotate({ identifier: "Reference.LocalSource" });
|
|
2583
|
+
var GitSource = Schema42.Struct({
|
|
2584
|
+
type: Schema42.Literal("git"),
|
|
2585
|
+
repository: Schema42.String,
|
|
2586
|
+
branch: Schema42.String.pipe(optional),
|
|
2587
|
+
description: Schema42.String.pipe(optional),
|
|
2588
|
+
hidden: Schema42.Boolean.pipe(optional)
|
|
2589
|
+
}).annotate({ identifier: "Reference.GitSource" });
|
|
2590
|
+
var Source4 = Schema42.Union([LocalSource, GitSource]).pipe(Schema42.toTaggedUnion("type")).annotate({ identifier: "Reference.Source" });
|
|
2591
|
+
var Info21 = Schema42.Struct({
|
|
2592
|
+
name: Schema42.String,
|
|
2593
|
+
path: AbsolutePath,
|
|
2594
|
+
description: Schema42.String.pipe(optional),
|
|
2595
|
+
hidden: Schema42.Boolean.pipe(optional),
|
|
2596
|
+
source: Source4
|
|
2597
|
+
}).annotate({ identifier: "Reference.Info" });
|
|
2598
|
+
|
|
2599
|
+
// node_modules/@opencode/schema/dist/vcs.js
|
|
2600
|
+
import { Schema as Schema43 } from "effect";
|
|
2601
|
+
var Branch = Schema43.Struct({
|
|
2602
|
+
current: optional(Schema43.String),
|
|
2603
|
+
default: optional(Schema43.String)
|
|
2604
|
+
}).annotate({ identifier: "Vcs.Branch" });
|
|
2605
|
+
var Info22 = Schema43.Struct({
|
|
2606
|
+
provider: optional(Schema43.String),
|
|
2607
|
+
branch: Branch
|
|
2608
|
+
}).annotate({ identifier: "Vcs.Info" });
|
|
2609
|
+
var BranchList = Schema43.Array(Schema43.String).annotate({ identifier: "Vcs.BranchList" });
|
|
2610
|
+
var Base3 = Schema43.Struct({
|
|
2611
|
+
name: Schema43.String,
|
|
2612
|
+
ref: Schema43.String,
|
|
2613
|
+
source: Schema43.Literals(["reflog", "default"])
|
|
2614
|
+
}).annotate({ identifier: "Vcs.Base" });
|
|
2615
|
+
var Mode = Schema43.Literals(["working", "branch", "committed"]).annotate({ identifier: "Vcs.Mode" });
|
|
2616
|
+
var FileStatus = Schema43.Struct({
|
|
2617
|
+
file: Schema43.String,
|
|
2618
|
+
additions: NonNegativeInt,
|
|
2619
|
+
deletions: NonNegativeInt,
|
|
2620
|
+
status: Schema43.Literals(["added", "deleted", "modified"])
|
|
2621
|
+
}).annotate({ identifier: "Vcs.FileStatus" });
|
|
2622
|
+
|
|
2623
|
+
// node_modules/@opencode/schema/dist/websearch.js
|
|
2624
|
+
import { Schema as Schema44 } from "effect";
|
|
2625
|
+
var ID16 = Schema44.String.pipe(Schema44.brand("WebSearch.ID"), Schema44.annotate({ identifier: "WebSearch.ID" }));
|
|
2626
|
+
var Provider = Schema44.Struct({
|
|
2627
|
+
id: ID16,
|
|
2628
|
+
name: Schema44.String
|
|
2629
|
+
}).annotate({ identifier: "WebSearch.Provider" });
|
|
2630
|
+
var Input = Schema44.Struct({
|
|
2631
|
+
query: Schema44.String,
|
|
2632
|
+
providerID: ID16.pipe(optional)
|
|
2633
|
+
}).annotate({ identifier: "WebSearch.Input" });
|
|
2634
|
+
var Result = Schema44.Struct({
|
|
2635
|
+
url: Schema44.String,
|
|
2636
|
+
title: Schema44.String.pipe(optional),
|
|
2637
|
+
content: Schema44.String.pipe(optional),
|
|
2638
|
+
time: Schema44.Struct({
|
|
2639
|
+
published: Schema44.Finite.pipe(optional).annotate({
|
|
2640
|
+
description: "Publication time in milliseconds since the Unix epoch"
|
|
2641
|
+
})
|
|
2642
|
+
})
|
|
2643
|
+
}).annotate({ identifier: "WebSearch.Result" });
|
|
2644
|
+
var Response2 = class extends Schema44.Class("WebSearch.Response")({
|
|
2645
|
+
providerID: ID16,
|
|
2646
|
+
results: Schema44.Array(Result)
|
|
2647
|
+
}) {
|
|
2648
|
+
};
|
|
2649
|
+
var Updated11 = ephemeral({
|
|
2650
|
+
type: "websearch.updated",
|
|
2651
|
+
schema: {}
|
|
2652
|
+
});
|
|
2653
|
+
var Event16 = { Updated: Updated11, Definitions: inventory(Updated11) };
|
|
2654
|
+
|
|
2655
|
+
// node_modules/@opencode/schema/dist/worktree.js
|
|
2656
|
+
import { Schema as Schema45 } from "effect";
|
|
2657
|
+
var StrategyID = Schema45.Trim.pipe(Schema45.check(Schema45.isNonEmpty()), Schema45.brand("Worktree.StrategyID"));
|
|
2658
|
+
var CreateInput5 = Schema45.Struct({
|
|
2659
|
+
projectID: project_exports.ID,
|
|
2660
|
+
from: optional(AbsolutePath),
|
|
2661
|
+
branch: optional(Schema45.Trim.pipe(Schema45.check(Schema45.isNonEmpty()))),
|
|
2662
|
+
directory: optional(AbsolutePath).annotate({
|
|
2663
|
+
description: "Parent directory for the new worktree. Uses the project's canonical configuration, then defaults to the server's data directory under worktree/<first six project ID characters>."
|
|
2664
|
+
}),
|
|
2665
|
+
name: optional(Schema45.String)
|
|
2666
|
+
}).annotate({ identifier: "Worktree.CreateInput" });
|
|
2667
|
+
var RemoveInput = Schema45.Struct({
|
|
2668
|
+
projectID: project_exports.ID,
|
|
2669
|
+
directory: AbsolutePath,
|
|
2670
|
+
force: Schema45.Boolean
|
|
2671
|
+
}).annotate({ identifier: "Worktree.RemoveInput" });
|
|
2672
|
+
var Info23 = Schema45.Struct({
|
|
2673
|
+
directory: AbsolutePath
|
|
2674
|
+
}).annotate({ identifier: "Worktree.Info" });
|
|
2675
|
+
var Directory = Schema45.Struct({
|
|
2676
|
+
directory: AbsolutePath,
|
|
2677
|
+
strategy: optional(Schema45.String)
|
|
2678
|
+
}).annotate({ identifier: "Worktree.Directory" });
|
|
2679
|
+
var ListEntry = Schema45.Struct({
|
|
2680
|
+
directory: AbsolutePath,
|
|
2681
|
+
type: Schema45.Literals(["root", "worktree"])
|
|
2682
|
+
}).annotate({ identifier: "Worktree.ListEntry" });
|
|
2683
|
+
var OperationError = class extends Schema45.TaggedError()("Worktree.OperationError", {
|
|
2684
|
+
message: Schema45.String,
|
|
2685
|
+
forceRequired: optional(Schema45.Boolean)
|
|
2686
|
+
}) {
|
|
2687
|
+
};
|
|
2688
|
+
var List = Schema45.Array(Directory).annotate({ identifier: "Worktree.List" });
|
|
2689
|
+
var Updated12 = ephemeral({
|
|
2690
|
+
type: "worktree.updated",
|
|
2691
|
+
schema: { projectID: project_exports.ID }
|
|
2692
|
+
});
|
|
2693
|
+
var Resolved = durable({
|
|
2694
|
+
type: "worktree.resolved",
|
|
2695
|
+
durable: { aggregate: "projectID", version: 1 },
|
|
2696
|
+
schema: {
|
|
2697
|
+
projectID: project_exports.ID,
|
|
2698
|
+
directory: AbsolutePath,
|
|
2699
|
+
previous: project_exports.ID,
|
|
2700
|
+
adopted: optional(Schema45.Array(project_exports.ID))
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
var Event17 = { Updated: Updated12, Resolved, Definitions: inventory(Updated12, Resolved) };
|
|
2704
|
+
|
|
2705
|
+
// src/opencode/v2/index.ts
|
|
2706
|
+
import { Effect as Effect5 } from "effect";
|
|
2707
|
+
|
|
2708
|
+
// src/config/options.ts
|
|
2709
|
+
var OptionsError = class extends Error {
|
|
2710
|
+
code = "CONFIG_INVALID";
|
|
2711
|
+
path;
|
|
2712
|
+
constructor(path3 = "options") {
|
|
2713
|
+
super("CONFIG_INVALID");
|
|
2714
|
+
this.name = "OptionsError";
|
|
2715
|
+
this.path = path3;
|
|
2716
|
+
}
|
|
2717
|
+
};
|
|
2718
|
+
var ceilings = {
|
|
2719
|
+
sourceBytes: 1048576,
|
|
2720
|
+
totalSourceBytes: 2097152,
|
|
2721
|
+
sourceCount: 4,
|
|
2722
|
+
secretCount: 1e3,
|
|
2723
|
+
secretBytes: 16384,
|
|
2724
|
+
indexBytes: 8388608,
|
|
2725
|
+
inputBytes: 1048576,
|
|
2726
|
+
outputBytes: 2097152,
|
|
2727
|
+
traversalDepth: 32,
|
|
2728
|
+
traversalNodes: 5e4,
|
|
2729
|
+
workingBytes: 33554432
|
|
2730
|
+
};
|
|
2731
|
+
var DEFAULT_LIMITS = {
|
|
2732
|
+
sourceBytes: 65536,
|
|
2733
|
+
totalSourceBytes: 131072,
|
|
2734
|
+
sourceCount: 2,
|
|
2735
|
+
secretCount: 50,
|
|
2736
|
+
secretBytes: 4096,
|
|
2737
|
+
indexBytes: 1048576,
|
|
2738
|
+
inputBytes: 32768,
|
|
2739
|
+
outputBytes: 65536,
|
|
2740
|
+
traversalDepth: 8,
|
|
2741
|
+
traversalNodes: 1e3,
|
|
2742
|
+
workingBytes: 1048576
|
|
2743
|
+
};
|
|
2744
|
+
var keys = (value, allowed, path3) => {
|
|
2745
|
+
for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new OptionsError(`${path3}.${key}`);
|
|
2746
|
+
};
|
|
2747
|
+
function checked(value, path3, seen) {
|
|
2748
|
+
if (typeof value !== "object" || value === null || !Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype || Array.isArray(value) && Object.getPrototypeOf(value) !== Array.prototype) throw new OptionsError(path3);
|
|
2749
|
+
if (seen.has(value)) throw new OptionsError(path3);
|
|
2750
|
+
seen.add(value);
|
|
2751
|
+
for (const key of Object.keys(value)) {
|
|
2752
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
2753
|
+
if (!descriptor || !("value" in descriptor)) throw new OptionsError(`${path3}.${key}`);
|
|
2754
|
+
if (typeof descriptor.value === "object" && descriptor.value !== null) checked(descriptor.value, `${path3}.${key}`, seen);
|
|
2755
|
+
}
|
|
2756
|
+
seen.delete(value);
|
|
2757
|
+
return value;
|
|
2758
|
+
}
|
|
2759
|
+
var string = (value, path3, pattern) => {
|
|
2760
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 256 || pattern && !pattern.test(value) || /\$\{(?:env|file):/i.test(value)) throw new OptionsError(path3);
|
|
2761
|
+
return value;
|
|
2762
|
+
};
|
|
2763
|
+
var list = (value, path3) => {
|
|
2764
|
+
if (!Array.isArray(value)) throw new OptionsError(path3);
|
|
2765
|
+
return value;
|
|
2766
|
+
};
|
|
2767
|
+
function parseOptionsUnsafe(input) {
|
|
2768
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2769
|
+
const options2 = checked(input, "options", seen);
|
|
2770
|
+
keys(options2, ["version", "sources", "limits"], "options");
|
|
2771
|
+
if (options2.version !== 1) throw new OptionsError("options.version");
|
|
2772
|
+
const sources = list(options2.sources, "options.sources").map((raw, i) => {
|
|
2773
|
+
const source = checked(raw, `sources[${i}]`, seen);
|
|
2774
|
+
keys(source, ["id", "type", "format", "path", "required", "keys"], `sources[${i}]`);
|
|
2775
|
+
const path3 = string(source.path, `sources[${i}].path`);
|
|
2776
|
+
if (path3.includes("\0") || path3.startsWith("/") || path3.startsWith("\\") || /^[A-Za-z]:/.test(path3) || path3.split(/[\\/]/).some((segment) => segment === "." || segment === "..")) throw new OptionsError(`sources[${i}].path`);
|
|
2777
|
+
if (source.type !== "file" || source.format !== "dotenv" || typeof source.required !== "boolean") throw new OptionsError(`sources[${i}]`);
|
|
2778
|
+
const sourceKeys = list(source.keys, `sources[${i}].keys`).map((key, keyIndex) => string(key, `sources[${i}].keys[${keyIndex}]`, /^[A-Za-z_][A-Za-z0-9_]*$/));
|
|
2779
|
+
if (sourceKeys.length === 0 || new Set(sourceKeys).size !== sourceKeys.length) throw new OptionsError(`sources[${i}].keys`);
|
|
2780
|
+
return { id: string(source.id, `sources[${i}].id`, /^[A-Za-z][A-Za-z0-9._-]*$/), type: "file", format: "dotenv", path: path3, required: source.required, keys: sourceKeys };
|
|
2781
|
+
});
|
|
2782
|
+
if (sources.length === 0 || sources.length > ceilings.sourceCount || new Set(sources.map((s) => s.id)).size !== sources.length) throw new OptionsError("sources");
|
|
2783
|
+
const configuredLimits = checked(options2.limits === void 0 ? DEFAULT_LIMITS : options2.limits, "options.limits", seen);
|
|
2784
|
+
keys(configuredLimits, Object.keys(ceilings), "limits");
|
|
2785
|
+
const limits = {};
|
|
2786
|
+
for (const key of Object.keys(ceilings)) {
|
|
2787
|
+
const value = configuredLimits[key];
|
|
2788
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0 || value > ceilings[key]) throw new OptionsError(`limits.${key}`);
|
|
2789
|
+
limits[key] = value;
|
|
2790
|
+
}
|
|
2791
|
+
return { version: 1, sources, limits };
|
|
2792
|
+
}
|
|
2793
|
+
function parseOptions(input) {
|
|
2794
|
+
try {
|
|
2795
|
+
return parseOptionsUnsafe(input);
|
|
2796
|
+
} catch (error) {
|
|
2797
|
+
if (error instanceof OptionsError) throw error;
|
|
2798
|
+
throw new OptionsError();
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
// src/opencode/v2/runtime.ts
|
|
2803
|
+
import { Effect as Effect4 } from "effect";
|
|
2804
|
+
import { randomBytes } from "node:crypto";
|
|
2805
|
+
import * as fs2 from "node:fs";
|
|
2806
|
+
import * as path2 from "node:path";
|
|
2807
|
+
|
|
2808
|
+
// src/store/index.ts
|
|
2809
|
+
import { randomBytes as systemRandomBytes } from "node:crypto";
|
|
2810
|
+
|
|
2811
|
+
// src/budgets/index.ts
|
|
2812
|
+
var dimensions = /* @__PURE__ */ new Set(["sourceCount", "sourceBytes", "totalSourceBytes", "secretCount", "secretBytes", "indexBytes", "inputBytes", "outputBytes", "traversalDepth", "traversalNodes", "workingBytes", "calls", "nodes", "depth", "sessions", "handles"]);
|
|
2813
|
+
var BudgetLedger = class {
|
|
2814
|
+
used = /* @__PURE__ */ new Map();
|
|
2815
|
+
limits;
|
|
2816
|
+
constructor(limits) {
|
|
2817
|
+
const values = inspect(limits);
|
|
2818
|
+
if (!values) throw new Error("invalid");
|
|
2819
|
+
for (const [key, value] of values) if (!dimensions.has(key) || typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) throw new Error("invalid");
|
|
2820
|
+
this.limits = Object.fromEntries(values);
|
|
2821
|
+
}
|
|
2822
|
+
reserve(request) {
|
|
2823
|
+
try {
|
|
2824
|
+
const values = inspect(request);
|
|
2825
|
+
if (!values) return { ok: false };
|
|
2826
|
+
for (const [key, value] of values) {
|
|
2827
|
+
if (!dimensions.has(key) || typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) return { ok: false };
|
|
2828
|
+
const limit = this.limits[key];
|
|
2829
|
+
const current = this.used.get(key) ?? 0;
|
|
2830
|
+
if (value > Number.MAX_SAFE_INTEGER - current) return { ok: false };
|
|
2831
|
+
if (limit !== void 0 && current + value > limit) return { ok: false };
|
|
2832
|
+
}
|
|
2833
|
+
const committed = values;
|
|
2834
|
+
for (const [key, value] of committed) this.used.set(key, (this.used.get(key) ?? 0) + value);
|
|
2835
|
+
let disposed = false;
|
|
2836
|
+
return { ok: true, value: { dispose: () => {
|
|
2837
|
+
if (disposed) return;
|
|
2838
|
+
disposed = true;
|
|
2839
|
+
for (const [key, value] of committed) this.used.set(key, (this.used.get(key) ?? 0) - value);
|
|
2840
|
+
} } };
|
|
2841
|
+
} catch {
|
|
2842
|
+
return { ok: false };
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
};
|
|
2846
|
+
function inspect(value) {
|
|
2847
|
+
try {
|
|
2848
|
+
if (!value || typeof value !== "object") return void 0;
|
|
2849
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return void 0;
|
|
2850
|
+
const keys2 = Reflect.ownKeys(value);
|
|
2851
|
+
if (keys2.some((key) => typeof key !== "string")) return void 0;
|
|
2852
|
+
const result = [];
|
|
2853
|
+
for (const key of keys2) {
|
|
2854
|
+
if (typeof key !== "string") return void 0;
|
|
2855
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
2856
|
+
if (!descriptor || !descriptor.enumerable || !("value" in descriptor)) return void 0;
|
|
2857
|
+
result.push([key, descriptor.value]);
|
|
2858
|
+
}
|
|
2859
|
+
return result;
|
|
2860
|
+
} catch {
|
|
2861
|
+
return void 0;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
// src/store/index.ts
|
|
2866
|
+
var ActivationStore = class {
|
|
2867
|
+
entries = /* @__PURE__ */ new Map();
|
|
2868
|
+
redactions = /* @__PURE__ */ new Map();
|
|
2869
|
+
budget;
|
|
2870
|
+
random;
|
|
2871
|
+
active = true;
|
|
2872
|
+
constructor(options2) {
|
|
2873
|
+
if (!options2 || typeof options2.location?.directory !== "string" || !Number.isInteger(options2.generation) || options2.generation < 0) throw new Error("invalid");
|
|
2874
|
+
this.budget = options2.budget ?? new BudgetLedger({ handles: 65536, secretCount: 65536, secretBytes: 128 * 1024 * 1024, indexBytes: 128 * 1024 * 1024, workingBytes: 128 * 1024 * 1024 });
|
|
2875
|
+
this.random = options2.randomBytes ?? (() => new Uint8Array(systemRandomBytes(16)));
|
|
2876
|
+
}
|
|
2877
|
+
register(value) {
|
|
2878
|
+
if (!this.active || typeof value !== "string" || value.length === 0) throw new Error("denied");
|
|
2879
|
+
const existing = this.redactions.get(value);
|
|
2880
|
+
if (existing !== void 0) return existing;
|
|
2881
|
+
const reservation = this.reserve({ handles: 1, secretCount: 1, secretBytes: Buffer.byteLength(value), indexBytes: Buffer.byteLength(value), workingBytes: Buffer.byteLength(value) });
|
|
2882
|
+
if (reservation === void 0) throw new Error("denied");
|
|
2883
|
+
const handle = this.newHandle();
|
|
2884
|
+
this.entries.set(handle, reservation);
|
|
2885
|
+
this.redactions.set(value, handle);
|
|
2886
|
+
return handle;
|
|
2887
|
+
}
|
|
2888
|
+
teardown() {
|
|
2889
|
+
this.active = false;
|
|
2890
|
+
for (const reservation of this.entries.values()) reservation.dispose();
|
|
2891
|
+
this.entries.clear();
|
|
2892
|
+
this.redactions.clear();
|
|
2893
|
+
}
|
|
2894
|
+
reserve(request) {
|
|
2895
|
+
const result = this.budget.reserve(request);
|
|
2896
|
+
return result.ok ? result.value : void 0;
|
|
2897
|
+
}
|
|
2898
|
+
newHandle() {
|
|
2899
|
+
for (let attempt = 0; attempt < 32; attempt += 1) {
|
|
2900
|
+
const bytes2 = this.random();
|
|
2901
|
+
if (!(bytes2 instanceof Uint8Array) || bytes2.length !== 16) throw new Error("denied");
|
|
2902
|
+
const copy = new Uint8Array(bytes2);
|
|
2903
|
+
copy[6] = copy[6] & 15 | 64;
|
|
2904
|
+
copy[8] = copy[8] & 63 | 128;
|
|
2905
|
+
const hex = Buffer.from(copy).toString("hex");
|
|
2906
|
+
const handle = `secret-${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
2907
|
+
if (!this.entries.has(handle)) return handle;
|
|
2908
|
+
}
|
|
2909
|
+
throw new Error("denied");
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2913
|
+
// src/sources/dotenv.ts
|
|
2914
|
+
import * as fs from "node:fs";
|
|
2915
|
+
import * as path from "node:path";
|
|
2916
|
+
var SourceParseError = class extends Error {
|
|
2917
|
+
code = "SOURCE_INVALID";
|
|
2918
|
+
constructor() {
|
|
2919
|
+
super("SOURCE_INVALID");
|
|
2920
|
+
this.name = "SourceParseError";
|
|
2921
|
+
}
|
|
2922
|
+
};
|
|
2923
|
+
function parseDotenv(source, options2 = {}) {
|
|
2924
|
+
try {
|
|
2925
|
+
const limits = normalizeOptions(options2);
|
|
2926
|
+
if (typeof source !== "string") throw new SourceParseError();
|
|
2927
|
+
const bytes2 = Buffer.byteLength(source, "utf8");
|
|
2928
|
+
if (bytes2 > limits.maxBytes) throw new SourceParseError();
|
|
2929
|
+
const entries = [];
|
|
2930
|
+
const names = /* @__PURE__ */ new Set();
|
|
2931
|
+
let index = 0;
|
|
2932
|
+
while (index < source.length) {
|
|
2933
|
+
const lineStart = index;
|
|
2934
|
+
const end = source.indexOf("\n", index);
|
|
2935
|
+
const lineEnd = end < 0 ? source.length : end;
|
|
2936
|
+
let line = source.slice(index, lineEnd);
|
|
2937
|
+
if (line.endsWith("\r")) line = line.slice(0, -1);
|
|
2938
|
+
index = end < 0 ? source.length : end + 1;
|
|
2939
|
+
const trimmed = line.trim();
|
|
2940
|
+
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
2941
|
+
const assignment = /^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*/.exec(line);
|
|
2942
|
+
if (!assignment) throw new SourceParseError();
|
|
2943
|
+
const key = assignment[1];
|
|
2944
|
+
if (names.has(key)) throw new SourceParseError();
|
|
2945
|
+
names.add(key);
|
|
2946
|
+
let rest = line.slice(assignment[0].length);
|
|
2947
|
+
let lexical = rest;
|
|
2948
|
+
let value;
|
|
2949
|
+
if (rest.startsWith("'") || rest.startsWith('"')) {
|
|
2950
|
+
const quote = rest[0];
|
|
2951
|
+
let content = rest.slice(1);
|
|
2952
|
+
let close = quotedClose(content, quote);
|
|
2953
|
+
while (close < 0) {
|
|
2954
|
+
if (index >= source.length) throw new SourceParseError();
|
|
2955
|
+
const nextEnd = source.indexOf("\n", index);
|
|
2956
|
+
const nextLineEnd = nextEnd < 0 ? source.length : nextEnd;
|
|
2957
|
+
let next = source.slice(index, nextLineEnd);
|
|
2958
|
+
if (next.endsWith("\r")) next = next.slice(0, -1);
|
|
2959
|
+
content += "\n" + next;
|
|
2960
|
+
index = nextEnd < 0 ? source.length : nextEnd + 1;
|
|
2961
|
+
close = quotedClose(content, quote);
|
|
2962
|
+
}
|
|
2963
|
+
const body = content.slice(0, close);
|
|
2964
|
+
const after = content.slice(close + 1).trim();
|
|
2965
|
+
if (after !== "" && !after.startsWith("#")) throw new SourceParseError();
|
|
2966
|
+
value = quote === '"' ? decodeDouble(body) : body;
|
|
2967
|
+
lexical = quote + body + quote;
|
|
2968
|
+
} else {
|
|
2969
|
+
const comment = rest.indexOf("#");
|
|
2970
|
+
if (comment >= 0) rest = rest.slice(0, comment);
|
|
2971
|
+
value = rest.trimEnd();
|
|
2972
|
+
lexical = value;
|
|
2973
|
+
}
|
|
2974
|
+
if (Buffer.byteLength(value, "utf8") > limits.maxValueBytes || entries.length >= limits.maxEntries) throw new SourceParseError();
|
|
2975
|
+
entries.push(Object.freeze({ key, value, lexicalValue: lexical }));
|
|
2976
|
+
void lineStart;
|
|
2977
|
+
}
|
|
2978
|
+
return Object.freeze({ entries: Object.freeze(entries), bytes: bytes2 });
|
|
2979
|
+
} catch (error) {
|
|
2980
|
+
if (error instanceof SourceParseError) throw error;
|
|
2981
|
+
throw new SourceParseError();
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
function normalizeOptions(options2) {
|
|
2985
|
+
if (options2 === null || typeof options2 !== "object" || Array.isArray(options2)) throw new SourceParseError();
|
|
2986
|
+
const prototype = Object.getPrototypeOf(options2);
|
|
2987
|
+
if (prototype !== Object.prototype && prototype !== null) throw new SourceParseError();
|
|
2988
|
+
const names = Object.getOwnPropertyNames(options2);
|
|
2989
|
+
if (Object.getOwnPropertySymbols(options2).length !== 0 || names.some((name) => !["maxBytes", "maxEntries", "maxValueBytes"].includes(name))) throw new SourceParseError();
|
|
2990
|
+
const values = {};
|
|
2991
|
+
for (const name of names) {
|
|
2992
|
+
const descriptor = Object.getOwnPropertyDescriptor(options2, name);
|
|
2993
|
+
if (!descriptor || !("value" in descriptor)) throw new SourceParseError();
|
|
2994
|
+
values[name] = descriptor.value;
|
|
2995
|
+
}
|
|
2996
|
+
const result = {
|
|
2997
|
+
maxBytes: values.maxBytes === void 0 ? 1048576 : values.maxBytes,
|
|
2998
|
+
maxEntries: values.maxEntries === void 0 ? 1e3 : values.maxEntries,
|
|
2999
|
+
maxValueBytes: values.maxValueBytes === void 0 ? 16384 : values.maxValueBytes
|
|
3000
|
+
};
|
|
3001
|
+
if (![result.maxBytes, result.maxEntries, result.maxValueBytes].every((value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0)) throw new SourceParseError();
|
|
3002
|
+
return result;
|
|
3003
|
+
}
|
|
3004
|
+
function decodeDouble(value) {
|
|
3005
|
+
return value.replace(/\\([\\"nrt])/g, (_match, escaped) => ({ "\\": "\\", '"': '"', n: "\n", r: "\r", t: " " })[escaped] ?? escaped);
|
|
3006
|
+
}
|
|
3007
|
+
function quotedClose(value, quote) {
|
|
3008
|
+
for (let i = 0; i < value.length; i++) {
|
|
3009
|
+
if (value[i] === quote) return i;
|
|
3010
|
+
if (value[i] !== "\\") continue;
|
|
3011
|
+
const escaped = value[++i];
|
|
3012
|
+
if (escaped === void 0) throw new SourceParseError();
|
|
3013
|
+
const valid = quote === '"' ? '\\"nrt'.includes(escaped) : escaped === quote || escaped === "\\";
|
|
3014
|
+
if (!valid) throw new SourceParseError();
|
|
3015
|
+
}
|
|
3016
|
+
return -1;
|
|
3017
|
+
}
|
|
3018
|
+
function loadDotenvFile(filePath, options2 = {}) {
|
|
3019
|
+
try {
|
|
3020
|
+
const resolved = path.resolve(filePath);
|
|
3021
|
+
const stat = fs.lstatSync(resolved);
|
|
3022
|
+
if (!stat.isFile() || stat.isSymbolicLink()) throw new SourceParseError();
|
|
3023
|
+
const noFollow = fs.constants.O_NOFOLLOW ?? 0;
|
|
3024
|
+
const descriptor = fs.openSync(resolved, fs.constants.O_RDONLY | noFollow);
|
|
3025
|
+
try {
|
|
3026
|
+
const opened = fs.fstatSync(descriptor);
|
|
3027
|
+
if (!opened.isFile()) throw new SourceParseError();
|
|
3028
|
+
const raw = fs.readFileSync(descriptor, "utf8");
|
|
3029
|
+
return parseDotenv(raw, options2);
|
|
3030
|
+
} finally {
|
|
3031
|
+
fs.closeSync(descriptor);
|
|
3032
|
+
}
|
|
3033
|
+
} catch (e) {
|
|
3034
|
+
throw new SourceParseError();
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
// src/sanitize/index.ts
|
|
3039
|
+
var DEFAULT_MAX_OUTPUT_BYTES = 2 * 1024 * 1024;
|
|
3040
|
+
var DEFAULT_MAX_DEPTH = 32;
|
|
3041
|
+
var DEFAULT_MAX_NODES = 5e4;
|
|
3042
|
+
var DEFAULT_MAX_MATCHES = 5e4;
|
|
3043
|
+
var MAX_OUTPUT_BYTES = DEFAULT_MAX_OUTPUT_BYTES;
|
|
3044
|
+
var MAX_DEPTH = DEFAULT_MAX_DEPTH;
|
|
3045
|
+
var MAX_NODES = DEFAULT_MAX_NODES;
|
|
3046
|
+
var MAX_MATCHES = DEFAULT_MAX_MATCHES;
|
|
3047
|
+
var MAX_PATTERN_COUNT = 4096;
|
|
3048
|
+
var MAX_PATTERN_TEXT = 65536;
|
|
3049
|
+
var MAX_REPRESENTATIONS = 16;
|
|
3050
|
+
var MAX_INDEX_ENTRIES = 65536;
|
|
3051
|
+
var MAX_IDENTITY_ENTRIES = 5e4;
|
|
3052
|
+
var MAX_PATTERN_BYTES = 4 * 1024 * 1024;
|
|
3053
|
+
var MAX_TEMP_BYTES = 8 * 1024 * 1024;
|
|
3054
|
+
var reservedPatternBytes = 0;
|
|
3055
|
+
var reservedIndexEntries = 0;
|
|
3056
|
+
var reservedIdentityEntries = 0;
|
|
3057
|
+
var reservedTempBytes = 0;
|
|
3058
|
+
function reserveOperation(patterns, inputBytes) {
|
|
3059
|
+
try {
|
|
3060
|
+
if (patterns !== void 0 && !Array.isArray(patterns)) return null;
|
|
3061
|
+
const count = patterns?.length ?? 0;
|
|
3062
|
+
if (count > MAX_PATTERN_COUNT) return null;
|
|
3063
|
+
let patternBytes = 0;
|
|
3064
|
+
for (const item of patterns ?? []) {
|
|
3065
|
+
const text = typeof item === "string" ? item : (() => {
|
|
3066
|
+
if (item === null || typeof item !== "object") return null;
|
|
3067
|
+
const descriptor = Object.getOwnPropertyDescriptor(item, "text");
|
|
3068
|
+
return descriptor && "value" in descriptor && typeof descriptor.value === "string" ? descriptor.value : null;
|
|
3069
|
+
})();
|
|
3070
|
+
if (text === null) return null;
|
|
3071
|
+
patternBytes += encoder.encode(text).byteLength;
|
|
3072
|
+
if (patternBytes > MAX_PATTERN_BYTES) return null;
|
|
3073
|
+
}
|
|
3074
|
+
const indexEntries = count * MAX_REPRESENTATIONS;
|
|
3075
|
+
const identityEntries = count;
|
|
3076
|
+
const tempBytes = inputBytes + patternBytes;
|
|
3077
|
+
if (!Number.isSafeInteger(inputBytes) || inputBytes < 0 || indexEntries > MAX_INDEX_ENTRIES || identityEntries > MAX_IDENTITY_ENTRIES || tempBytes > MAX_TEMP_BYTES) return null;
|
|
3078
|
+
if (reservedPatternBytes > MAX_PATTERN_BYTES - patternBytes || reservedIndexEntries > MAX_INDEX_ENTRIES - indexEntries || reservedIdentityEntries > MAX_IDENTITY_ENTRIES - identityEntries || reservedTempBytes > MAX_TEMP_BYTES - tempBytes) return null;
|
|
3079
|
+
reservedPatternBytes += patternBytes;
|
|
3080
|
+
reservedIndexEntries += indexEntries;
|
|
3081
|
+
reservedIdentityEntries += identityEntries;
|
|
3082
|
+
reservedTempBytes += tempBytes;
|
|
3083
|
+
let released = false;
|
|
3084
|
+
return { release: () => {
|
|
3085
|
+
if (released) return;
|
|
3086
|
+
released = true;
|
|
3087
|
+
reservedPatternBytes -= patternBytes;
|
|
3088
|
+
reservedIndexEntries -= indexEntries;
|
|
3089
|
+
reservedIdentityEntries -= identityEntries;
|
|
3090
|
+
reservedTempBytes -= tempBytes;
|
|
3091
|
+
} };
|
|
3092
|
+
} catch {
|
|
3093
|
+
return null;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
var RESERVED_OUTPUT_INVENTORY = Object.freeze([
|
|
3097
|
+
"true",
|
|
3098
|
+
"false",
|
|
3099
|
+
"null",
|
|
3100
|
+
"REDACTED",
|
|
3101
|
+
"SANITIZATION_UNAVAILABLE",
|
|
3102
|
+
"INVALID_CREDENTIAL",
|
|
3103
|
+
"ACCESS_DENIED",
|
|
3104
|
+
"UNAVAILABLE",
|
|
3105
|
+
"error",
|
|
3106
|
+
"content",
|
|
3107
|
+
"text"
|
|
3108
|
+
]);
|
|
3109
|
+
function base64(bytes2) {
|
|
3110
|
+
let binary = "";
|
|
3111
|
+
for (const byte of bytes2) binary += String.fromCharCode(byte);
|
|
3112
|
+
return Buffer.from(binary, "binary").toString("base64");
|
|
3113
|
+
}
|
|
3114
|
+
function representationsFor(value) {
|
|
3115
|
+
const reservation = typeof value === "string" ? reserveOperation(void 0, encoder.encode(value).byteLength) : null;
|
|
3116
|
+
try {
|
|
3117
|
+
if (typeof value !== "string" || value.length > MAX_PATTERN_TEXT) return null;
|
|
3118
|
+
const bytes2 = encoder.encode(value);
|
|
3119
|
+
if (bytes2.byteLength > MAX_PATTERN_TEXT * 3) return null;
|
|
3120
|
+
const encoded = Array.from(bytes2, (byte) => {
|
|
3121
|
+
const character = String.fromCharCode(byte);
|
|
3122
|
+
return /[A-Za-z0-9\-_.!~*'()]/u.test(character) ? character : `%${byte.toString(16).padStart(2, "0")}`;
|
|
3123
|
+
}).join("");
|
|
3124
|
+
const percentUpper = encoded.replace(/%[0-9a-f]{2}/g, (part) => part.toUpperCase());
|
|
3125
|
+
const padded = base64(bytes2);
|
|
3126
|
+
const url = padded.replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
3127
|
+
const doubleQuoted = `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"').replaceAll("\n", "\\n").replaceAll("\r", "\\r").replaceAll(" ", "\\t")}"`;
|
|
3128
|
+
const singleQuoted = `'${value}'`;
|
|
3129
|
+
const dotenv = [doubleQuoted, singleQuoted];
|
|
3130
|
+
if (/^[^\s#'"\\\r\n]+$/u.test(value)) dotenv.push(value);
|
|
3131
|
+
const result = {
|
|
3132
|
+
semantic: value,
|
|
3133
|
+
dotenv,
|
|
3134
|
+
json: JSON.stringify(value).slice(1, -1),
|
|
3135
|
+
percent: [encoded, percentUpper],
|
|
3136
|
+
base64: [padded, padded.replace(/=+$/u, ""), url]
|
|
3137
|
+
};
|
|
3138
|
+
return result.dotenv.length + result.percent.length + result.base64.length > MAX_REPRESENTATIONS ? null : result;
|
|
3139
|
+
} catch {
|
|
3140
|
+
return null;
|
|
3141
|
+
} finally {
|
|
3142
|
+
reservation?.release();
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
function patternRepresentations(pattern) {
|
|
3146
|
+
const reservation = reserveOperation([pattern], 0);
|
|
3147
|
+
try {
|
|
3148
|
+
if (typeof pattern?.text !== "string") return null;
|
|
3149
|
+
const derived = representationsFor(pattern.text);
|
|
3150
|
+
if (derived === null) return null;
|
|
3151
|
+
const result = [.../* @__PURE__ */ new Set([pattern.text, ...derived.dotenv, derived.json, ...derived.percent, ...derived.base64])];
|
|
3152
|
+
return result.length > MAX_REPRESENTATIONS ? null : result;
|
|
3153
|
+
} catch {
|
|
3154
|
+
return null;
|
|
3155
|
+
} finally {
|
|
3156
|
+
reservation?.release();
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
var encoder = new TextEncoder();
|
|
3160
|
+
var REDACTION = "[REDACTED]";
|
|
3161
|
+
var UUID_TEMPLATE = [
|
|
3162
|
+
..."secret-",
|
|
3163
|
+
...Array.from({ length: 8 }, () => "h"),
|
|
3164
|
+
"-",
|
|
3165
|
+
...Array.from({ length: 4 }, () => "h"),
|
|
3166
|
+
"-",
|
|
3167
|
+
"4",
|
|
3168
|
+
...Array.from({ length: 3 }, () => "h"),
|
|
3169
|
+
"-",
|
|
3170
|
+
"v",
|
|
3171
|
+
...Array.from({ length: 3 }, () => "h"),
|
|
3172
|
+
"-",
|
|
3173
|
+
...Array.from({ length: 12 }, () => "h")
|
|
3174
|
+
];
|
|
3175
|
+
function uuidLanguageContains(value) {
|
|
3176
|
+
if (value.length === 0 || value.length > UUID_TEMPLATE.length) return false;
|
|
3177
|
+
const hex = /^[0-9a-f]$/i;
|
|
3178
|
+
for (let start = 0; start <= UUID_TEMPLATE.length - value.length; start++) {
|
|
3179
|
+
let fits = true;
|
|
3180
|
+
for (let i = 0; i < value.length; i++) {
|
|
3181
|
+
const slot = UUID_TEMPLATE[start + i];
|
|
3182
|
+
const character = value[i];
|
|
3183
|
+
const slotMatches = slot === "h" ? hex.test(character ?? "") : slot === "v" ? /^[89ab]$/i.test(character ?? "") : slot === character;
|
|
3184
|
+
if (slot === void 0 || character === void 0 || !slotMatches) {
|
|
3185
|
+
fits = false;
|
|
3186
|
+
break;
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
if (fits) return true;
|
|
3190
|
+
}
|
|
3191
|
+
return false;
|
|
3192
|
+
}
|
|
3193
|
+
function admitPatterns(patterns) {
|
|
3194
|
+
const reservation = reserveOperation(patterns, 0);
|
|
3195
|
+
if (reservation === null) return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3196
|
+
try {
|
|
3197
|
+
for (const pattern of patterns) {
|
|
3198
|
+
if (pattern === null || typeof pattern !== "object" || Array.isArray(pattern)) return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3199
|
+
const prototype = Object.getPrototypeOf(pattern);
|
|
3200
|
+
if (prototype !== Object.prototype && prototype !== null) return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3201
|
+
const names = Object.getOwnPropertyNames(pattern);
|
|
3202
|
+
if (Object.getOwnPropertySymbols(pattern).length !== 0 || names.some((name) => !["text", "replacement", "entry", "representations"].includes(name))) return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3203
|
+
for (const name of names) {
|
|
3204
|
+
const descriptor = Object.getOwnPropertyDescriptor(pattern, name);
|
|
3205
|
+
if (descriptor === void 0 || !("value" in descriptor)) return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3206
|
+
}
|
|
3207
|
+
const representations = patternRepresentations(pattern);
|
|
3208
|
+
if (representations === null) return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3209
|
+
for (const representation of representations) {
|
|
3210
|
+
if (representation.length === 0 || uuidLanguageContains(representation) || RESERVED_OUTPUT_INVENTORY.some((item) => item.includes(representation))) {
|
|
3211
|
+
return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
return { ok: true };
|
|
3216
|
+
} catch {
|
|
3217
|
+
return { ok: false, code: "SANITIZATION_UNAVAILABLE" };
|
|
3218
|
+
} finally {
|
|
3219
|
+
reservation.release();
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
function normalizedBudget(budget) {
|
|
3223
|
+
try {
|
|
3224
|
+
if (budget === null || typeof budget !== "object" || Array.isArray(budget)) return null;
|
|
3225
|
+
const prototype = Object.getPrototypeOf(budget);
|
|
3226
|
+
if (prototype !== Object.prototype && prototype !== null) return null;
|
|
3227
|
+
const names = Object.getOwnPropertyNames(budget);
|
|
3228
|
+
if (Object.getOwnPropertySymbols(budget).length !== 0 || names.some((name) => !["maxOutputBytes", "maxDepth", "maxNodes", "maxMatches"].includes(name))) return null;
|
|
3229
|
+
const data = {};
|
|
3230
|
+
for (const name of names) {
|
|
3231
|
+
const descriptor = Object.getOwnPropertyDescriptor(budget, name);
|
|
3232
|
+
if (descriptor === void 0 || !("value" in descriptor)) return null;
|
|
3233
|
+
data[name] = descriptor.value;
|
|
3234
|
+
}
|
|
3235
|
+
const values = {
|
|
3236
|
+
maxOutputBytes: data.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
3237
|
+
maxDepth: data.maxDepth ?? DEFAULT_MAX_DEPTH,
|
|
3238
|
+
maxNodes: data.maxNodes ?? DEFAULT_MAX_NODES,
|
|
3239
|
+
maxMatches: data.maxMatches ?? DEFAULT_MAX_MATCHES
|
|
3240
|
+
};
|
|
3241
|
+
const valid = typeof values.maxOutputBytes === "number" && Number.isSafeInteger(values.maxOutputBytes) && values.maxOutputBytes >= 0 && values.maxOutputBytes <= MAX_OUTPUT_BYTES && typeof values.maxDepth === "number" && Number.isSafeInteger(values.maxDepth) && values.maxDepth >= 0 && values.maxDepth <= MAX_DEPTH && typeof values.maxNodes === "number" && Number.isSafeInteger(values.maxNodes) && values.maxNodes >= 0 && values.maxNodes <= MAX_NODES && typeof values.maxMatches === "number" && Number.isSafeInteger(values.maxMatches) && values.maxMatches >= 0 && values.maxMatches <= MAX_MATCHES;
|
|
3242
|
+
return valid ? values : null;
|
|
3243
|
+
} catch {
|
|
3244
|
+
return null;
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
function collectIntervalsBounded(input, patterns, budget) {
|
|
3248
|
+
if (typeof input !== "string" || !Array.isArray(patterns) || patterns.length > MAX_PATTERN_COUNT) return null;
|
|
3249
|
+
const found = [];
|
|
3250
|
+
let matchCount = 0;
|
|
3251
|
+
for (const item of patterns) {
|
|
3252
|
+
const texts = typeof item === "string" ? [item] : patternRepresentations(item);
|
|
3253
|
+
if (texts === null) return null;
|
|
3254
|
+
for (const text of texts) {
|
|
3255
|
+
if (text.length === 0) continue;
|
|
3256
|
+
let at = input.indexOf(text);
|
|
3257
|
+
while (at !== -1) {
|
|
3258
|
+
matchCount++;
|
|
3259
|
+
if (matchCount > budget.maxMatches) return null;
|
|
3260
|
+
found.push({ start: at, end: at + text.length, pattern: text });
|
|
3261
|
+
at = input.indexOf(text, at + 1);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
found.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
3266
|
+
const result = [];
|
|
3267
|
+
for (const match of found) {
|
|
3268
|
+
const previous = result[result.length - 1];
|
|
3269
|
+
if (previous !== void 0 && match.start <= previous.end) {
|
|
3270
|
+
previous.end = Math.max(previous.end, match.end);
|
|
3271
|
+
if (!previous.patterns.includes(match.pattern)) previous.patterns.push(match.pattern);
|
|
3272
|
+
} else {
|
|
3273
|
+
result.push({ start: match.start, end: match.end, patterns: [match.pattern] });
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
return result;
|
|
3277
|
+
}
|
|
3278
|
+
function withinBytes(value, budget) {
|
|
3279
|
+
return encoder.encode(value).byteLength <= budget.maxOutputBytes;
|
|
3280
|
+
}
|
|
3281
|
+
function bytes(value) {
|
|
3282
|
+
return encoder.encode(value).byteLength;
|
|
3283
|
+
}
|
|
3284
|
+
function sanitizeText(input, patterns, budget = {}) {
|
|
3285
|
+
const reservation = typeof input === "string" ? reserveOperation(patterns, encoder.encode(input).byteLength) : null;
|
|
3286
|
+
if (reservation === null) return null;
|
|
3287
|
+
try {
|
|
3288
|
+
if (typeof input !== "string") return null;
|
|
3289
|
+
const normalized = normalizedBudget(budget);
|
|
3290
|
+
if (normalized === null || !withinBytes(input, normalized)) return null;
|
|
3291
|
+
const intervals = collectIntervalsBounded(input, patterns, normalized);
|
|
3292
|
+
if (intervals === null) return null;
|
|
3293
|
+
let output = "";
|
|
3294
|
+
let cursor = 0;
|
|
3295
|
+
for (const interval of intervals) {
|
|
3296
|
+
const prefix = input.slice(cursor, interval.start);
|
|
3297
|
+
const matches = patterns.filter((pattern) => {
|
|
3298
|
+
const representations = patternRepresentations(pattern);
|
|
3299
|
+
return representations !== null && representations.some((text) => interval.patterns.includes(text));
|
|
3300
|
+
});
|
|
3301
|
+
const entries = new Set(matches.map((pattern) => pattern.entry ?? pattern.text));
|
|
3302
|
+
const replacement = entries.size === 1 && matches[0]?.replacement !== void 0 ? matches[0].replacement : REDACTION;
|
|
3303
|
+
if (bytes(output) + bytes(prefix) + bytes(replacement) > normalized.maxOutputBytes) return null;
|
|
3304
|
+
const next = output + prefix + replacement;
|
|
3305
|
+
if (!withinBytes(next, normalized)) return null;
|
|
3306
|
+
output = next;
|
|
3307
|
+
cursor = interval.end;
|
|
3308
|
+
}
|
|
3309
|
+
const suffix = input.slice(cursor);
|
|
3310
|
+
if (bytes(output) + bytes(suffix) > normalized.maxOutputBytes) return null;
|
|
3311
|
+
const final = output + suffix;
|
|
3312
|
+
if (!withinBytes(final, normalized) || collectIntervalsBounded(final, patterns, normalized)?.length !== 0) return null;
|
|
3313
|
+
return final;
|
|
3314
|
+
} catch {
|
|
3315
|
+
return null;
|
|
3316
|
+
} finally {
|
|
3317
|
+
reservation.release();
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
function scanForSecrets(input, patterns, budget = {}) {
|
|
3321
|
+
try {
|
|
3322
|
+
if (typeof input !== "string" || input.length > MAX_TEMP_BYTES) return "unverifiable";
|
|
3323
|
+
const reservation = reserveOperation(patterns, encoder.encode(input).byteLength);
|
|
3324
|
+
if (reservation === null) return "unverifiable";
|
|
3325
|
+
try {
|
|
3326
|
+
const normalized = normalizedBudget(budget);
|
|
3327
|
+
if (normalized === null || !Array.isArray(patterns) || patterns.length > MAX_PATTERN_COUNT) return "unverifiable";
|
|
3328
|
+
for (const item of patterns) {
|
|
3329
|
+
const texts = patternRepresentations(item);
|
|
3330
|
+
if (texts === null) return "unverifiable";
|
|
3331
|
+
for (const text of texts) {
|
|
3332
|
+
if (text.length > 0 && input.indexOf(text) !== -1) return "match";
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
return "clean";
|
|
3336
|
+
} finally {
|
|
3337
|
+
reservation.release();
|
|
3338
|
+
}
|
|
3339
|
+
} catch {
|
|
3340
|
+
return "unverifiable";
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
function verifyCeilingBytes(patterns) {
|
|
3344
|
+
try {
|
|
3345
|
+
if (!Array.isArray(patterns)) return 0;
|
|
3346
|
+
let patternBytes = 0;
|
|
3347
|
+
for (const item of patterns) {
|
|
3348
|
+
if (item === null || typeof item !== "object" || typeof item.text !== "string") return 0;
|
|
3349
|
+
patternBytes += encoder.encode(item.text).byteLength;
|
|
3350
|
+
if (patternBytes > MAX_PATTERN_BYTES) return 0;
|
|
3351
|
+
}
|
|
3352
|
+
return MAX_TEMP_BYTES - patternBytes;
|
|
3353
|
+
} catch {
|
|
3354
|
+
return 0;
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
// src/opencode/v2/filter.ts
|
|
3359
|
+
var WITHHELD = "SANITIZATION_UNAVAILABLE";
|
|
3360
|
+
var encoder2 = new TextEncoder();
|
|
3361
|
+
var decoder = new TextDecoder();
|
|
3362
|
+
var AUTH_CHANNEL = /* @__PURE__ */ new Set(["authorization", "api-key", "x-api-key", "proxy-authorization"]);
|
|
3363
|
+
var NULL_BODY_STATUS = /* @__PURE__ */ new Set([101, 204, 205, 304]);
|
|
3364
|
+
var hasSecrets = (state) => state.patterns.length > 0;
|
|
3365
|
+
function redactNode(current, depth, state, counters) {
|
|
3366
|
+
counters.nodes++;
|
|
3367
|
+
if (counters.nodes > state.budget.maxNodes || depth > state.budget.maxDepth) return { value: WITHHELD, changed: true };
|
|
3368
|
+
if (typeof current === "string") {
|
|
3369
|
+
if (current.length === 0) return { value: current, changed: false };
|
|
3370
|
+
const safe = sanitizeText(current, state.patterns, state.budget);
|
|
3371
|
+
if (safe === null) return { value: WITHHELD, changed: true };
|
|
3372
|
+
return { value: safe, changed: safe !== current };
|
|
3373
|
+
}
|
|
3374
|
+
if (current === null || typeof current !== "object") return { value: current, changed: false };
|
|
3375
|
+
if (Array.isArray(current)) {
|
|
3376
|
+
let changed2 = false;
|
|
3377
|
+
for (let index = 0; index < current.length; index++) {
|
|
3378
|
+
const result = redactNode(current[index], depth + 1, state, counters);
|
|
3379
|
+
if (result.changed) {
|
|
3380
|
+
current[index] = result.value;
|
|
3381
|
+
changed2 = true;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
return { value: current, changed: changed2 };
|
|
3385
|
+
}
|
|
3386
|
+
const prototype = Object.getPrototypeOf(current);
|
|
3387
|
+
if (prototype !== Object.prototype && prototype !== null) return { value: current, changed: false };
|
|
3388
|
+
const record = current;
|
|
3389
|
+
let changed = false;
|
|
3390
|
+
for (const key of Object.keys(record)) {
|
|
3391
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
3392
|
+
if (!descriptor || !("value" in descriptor)) continue;
|
|
3393
|
+
const safeKey = redactString(key, state);
|
|
3394
|
+
if (safeKey === null) return { value: WITHHELD, changed: true };
|
|
3395
|
+
const result = redactNode(descriptor.value, depth + 1, state, counters);
|
|
3396
|
+
if (result.changed || safeKey !== key) {
|
|
3397
|
+
if (safeKey !== key) {
|
|
3398
|
+
if (Object.prototype.hasOwnProperty.call(record, safeKey)) return { value: WITHHELD, changed: true };
|
|
3399
|
+
delete record[key];
|
|
3400
|
+
record[safeKey] = result.value;
|
|
3401
|
+
} else {
|
|
3402
|
+
record[key] = result.value;
|
|
3403
|
+
}
|
|
3404
|
+
changed = true;
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
return { value: current, changed };
|
|
3408
|
+
}
|
|
3409
|
+
function redactTree(root, state) {
|
|
3410
|
+
if (!hasSecrets(state)) return false;
|
|
3411
|
+
return redactNode(root, 0, state, { nodes: 0 }).changed;
|
|
3412
|
+
}
|
|
3413
|
+
function redactString(value, state) {
|
|
3414
|
+
if (!hasSecrets(state)) return value;
|
|
3415
|
+
if (encoder2.encode(value).byteLength > state.maxInputBytes) return null;
|
|
3416
|
+
return sanitizeText(value, state.patterns, state.budget);
|
|
3417
|
+
}
|
|
3418
|
+
function containsSecret(value, state) {
|
|
3419
|
+
if (!hasSecrets(state)) return false;
|
|
3420
|
+
return scanForSecrets(value, state.patterns, state.budget) !== "clean";
|
|
3421
|
+
}
|
|
3422
|
+
function redactHeaders(headers, state, options2) {
|
|
3423
|
+
if (!hasSecrets(state)) return;
|
|
3424
|
+
for (const name of Object.keys(headers)) {
|
|
3425
|
+
if (options2.skipAuth && AUTH_CHANNEL.has(name.toLowerCase())) continue;
|
|
3426
|
+
const value = headers[name];
|
|
3427
|
+
if (typeof value !== "string") {
|
|
3428
|
+
if (options2.strict) return "withheld";
|
|
3429
|
+
delete headers[name];
|
|
3430
|
+
continue;
|
|
3431
|
+
}
|
|
3432
|
+
const safeValue = redactString(value, state);
|
|
3433
|
+
const safeName = redactString(name, state);
|
|
3434
|
+
if (safeValue === null || safeName === null) {
|
|
3435
|
+
if (options2.strict) return "withheld";
|
|
3436
|
+
delete headers[name];
|
|
3437
|
+
continue;
|
|
3438
|
+
}
|
|
3439
|
+
if (safeValue !== value) headers[name] = safeValue;
|
|
3440
|
+
if (safeName !== name) {
|
|
3441
|
+
delete headers[name];
|
|
3442
|
+
headers[safeName] = safeValue;
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
function redactBody(text, state) {
|
|
3447
|
+
if (!hasSecrets(state)) return text;
|
|
3448
|
+
const trimmed = text.trimStart();
|
|
3449
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
3450
|
+
try {
|
|
3451
|
+
const parsed = JSON.parse(text);
|
|
3452
|
+
const result = redactNode(parsed, 0, state, { nodes: 0 });
|
|
3453
|
+
if (!result.changed) return text;
|
|
3454
|
+
const serialized = JSON.stringify(result.value);
|
|
3455
|
+
if (serialized === void 0) return null;
|
|
3456
|
+
if (encoder2.encode(serialized).byteLength > state.maxInputBytes) return null;
|
|
3457
|
+
if (containsSecret(serialized, state)) return null;
|
|
3458
|
+
return serialized;
|
|
3459
|
+
} catch {
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
return redactString(text, state);
|
|
3463
|
+
}
|
|
3464
|
+
function redactEventStream(text, state) {
|
|
3465
|
+
const lines = text.split(/(\r?\n)/u);
|
|
3466
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
3467
|
+
const line = lines[index];
|
|
3468
|
+
if (!line.startsWith("data:") || line.endsWith("\n") || line.endsWith("\r")) continue;
|
|
3469
|
+
const payload = line.slice(5).trimStart();
|
|
3470
|
+
if (payload === "[DONE]" || payload.length === 0) continue;
|
|
3471
|
+
try {
|
|
3472
|
+
const parsed = JSON.parse(payload);
|
|
3473
|
+
if (!redactTree(parsed, state)) continue;
|
|
3474
|
+
const serialized = JSON.stringify(parsed);
|
|
3475
|
+
if (serialized === void 0 || containsSecret(serialized, state)) return null;
|
|
3476
|
+
lines[index] = `data: ${serialized}`;
|
|
3477
|
+
} catch {
|
|
3478
|
+
return null;
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
return lines.join("");
|
|
3482
|
+
}
|
|
3483
|
+
async function readBoundedBody(body, limit) {
|
|
3484
|
+
if (body === null) return { text: "", bytes: 0 };
|
|
3485
|
+
try {
|
|
3486
|
+
const reader = body.getReader();
|
|
3487
|
+
const chunks = [];
|
|
3488
|
+
let total2 = 0;
|
|
3489
|
+
for (; ; ) {
|
|
3490
|
+
const { done, value } = await reader.read();
|
|
3491
|
+
if (done) break;
|
|
3492
|
+
if (value === void 0 || value.byteLength === 0) continue;
|
|
3493
|
+
total2 += value.byteLength;
|
|
3494
|
+
if (total2 > limit) return null;
|
|
3495
|
+
chunks.push(value);
|
|
3496
|
+
}
|
|
3497
|
+
const merged = new Uint8Array(total2);
|
|
3498
|
+
let offset = 0;
|
|
3499
|
+
for (const chunk of chunks) {
|
|
3500
|
+
merged.set(chunk, offset);
|
|
3501
|
+
offset += chunk.byteLength;
|
|
3502
|
+
}
|
|
3503
|
+
return { text: decoder.decode(merged), bytes: total2 };
|
|
3504
|
+
} catch {
|
|
3505
|
+
return null;
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
async function redactRequest(request, state) {
|
|
3509
|
+
if (!hasSecrets(state)) return request;
|
|
3510
|
+
const verifyCeiling = verifyCeilingBytes(state.patterns);
|
|
3511
|
+
const declared = Number(request.headers.get("content-length") ?? Number.NaN);
|
|
3512
|
+
if (Number.isFinite(declared) && declared > verifyCeiling) return "withheld";
|
|
3513
|
+
const record = {};
|
|
3514
|
+
request.headers.forEach((value, name) => {
|
|
3515
|
+
record[name] = value;
|
|
3516
|
+
});
|
|
3517
|
+
if (redactHeaders(record, state, { skipAuth: true, strict: true }) === "withheld") return "withheld";
|
|
3518
|
+
delete record["content-length"];
|
|
3519
|
+
let body;
|
|
3520
|
+
if (request.body !== null) {
|
|
3521
|
+
const read = await readBoundedBody(request.clone().body, verifyCeiling);
|
|
3522
|
+
if (read === null) return "withheld";
|
|
3523
|
+
if (read.bytes > state.maxInputBytes) {
|
|
3524
|
+
if (scanForSecrets(read.text, state.patterns, state.budget) !== "clean") return "withheld";
|
|
3525
|
+
} else {
|
|
3526
|
+
const safe = redactBody(read.text, state);
|
|
3527
|
+
if (safe === null) return "withheld";
|
|
3528
|
+
if (safe !== read.text) body = safe;
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
try {
|
|
3532
|
+
return new Request(request, {
|
|
3533
|
+
headers: record,
|
|
3534
|
+
...body === void 0 ? {} : { body },
|
|
3535
|
+
signal: request.signal
|
|
3536
|
+
});
|
|
3537
|
+
} catch {
|
|
3538
|
+
return "withheld";
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
async function redactResponse(response2, state) {
|
|
3542
|
+
if (!hasSecrets(state)) return response2;
|
|
3543
|
+
const headers = {};
|
|
3544
|
+
response2.headers.forEach((value, name) => {
|
|
3545
|
+
headers[name] = value;
|
|
3546
|
+
});
|
|
3547
|
+
redactHeaders(headers, state, { skipAuth: false, strict: false });
|
|
3548
|
+
const status = response2.status;
|
|
3549
|
+
const nullBody = NULL_BODY_STATUS.has(status);
|
|
3550
|
+
if (nullBody) {
|
|
3551
|
+
try {
|
|
3552
|
+
return new Response(null, { status, headers });
|
|
3553
|
+
} catch {
|
|
3554
|
+
return new Response(null, { status: 502 });
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
const verifyCeiling = verifyCeilingBytes(state.patterns);
|
|
3558
|
+
const declared = Number(response2.headers.get("content-length") ?? Number.NaN);
|
|
3559
|
+
if (Number.isFinite(declared) && declared > verifyCeiling) {
|
|
3560
|
+
try {
|
|
3561
|
+
return new Response(null, { status, headers });
|
|
3562
|
+
} catch {
|
|
3563
|
+
return new Response(null, { status: 502 });
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
const read = await readBoundedBody(response2.clone().body, verifyCeiling);
|
|
3567
|
+
if (read === null) {
|
|
3568
|
+
try {
|
|
3569
|
+
return new Response(null, { status, headers });
|
|
3570
|
+
} catch {
|
|
3571
|
+
return new Response(null, { status: 502 });
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
let body;
|
|
3575
|
+
if (read.bytes > state.maxInputBytes) {
|
|
3576
|
+
body = scanForSecrets(read.text, state.patterns, state.budget) === "clean" ? read.text : "";
|
|
3577
|
+
} else if ((headers["content-type"] ?? "").toLowerCase().includes("text/event-stream")) {
|
|
3578
|
+
body = redactEventStream(read.text, state) ?? "";
|
|
3579
|
+
} else {
|
|
3580
|
+
const safe = redactBody(read.text, state);
|
|
3581
|
+
body = safe === null ? "" : safe;
|
|
3582
|
+
}
|
|
3583
|
+
try {
|
|
3584
|
+
return new Response(body, { status, headers });
|
|
3585
|
+
} catch {
|
|
3586
|
+
return new Response(null, { status: 502 });
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
function dropMentions(root) {
|
|
3590
|
+
const walk = (node, depth, counters) => {
|
|
3591
|
+
counters.nodes++;
|
|
3592
|
+
if (counters.nodes > 1e4 || depth > 32) return;
|
|
3593
|
+
if (Array.isArray(node)) {
|
|
3594
|
+
for (const item of node) walk(item, depth + 1, counters);
|
|
3595
|
+
return;
|
|
3596
|
+
}
|
|
3597
|
+
if (!node || typeof node !== "object") return;
|
|
3598
|
+
const prototype = Object.getPrototypeOf(node);
|
|
3599
|
+
if (prototype !== Object.prototype && prototype !== null) return;
|
|
3600
|
+
const record = node;
|
|
3601
|
+
for (const key of Object.keys(record)) {
|
|
3602
|
+
if (key === "mention" && record[key] && typeof record[key] === "object") {
|
|
3603
|
+
delete record[key];
|
|
3604
|
+
continue;
|
|
3605
|
+
}
|
|
3606
|
+
walk(record[key], depth + 1, counters);
|
|
3607
|
+
}
|
|
3608
|
+
};
|
|
3609
|
+
walk(root, 0, { nodes: 0 });
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3612
|
+
// src/opencode/v2/runtime.ts
|
|
3613
|
+
var GENERATION = 1;
|
|
3614
|
+
var SOURCE_TOOLS = /* @__PURE__ */ new Set(["read", "write", "edit", "patch"]);
|
|
3615
|
+
var PATH_KEYS = ["filePath", "file_path", "path"];
|
|
3616
|
+
var realRuntimeFactory = (options2, location) => {
|
|
3617
|
+
const locationDir = location.directory;
|
|
3618
|
+
let locationReal;
|
|
3619
|
+
try {
|
|
3620
|
+
locationReal = fs2.realpathSync(locationDir);
|
|
3621
|
+
} catch {
|
|
3622
|
+
throw new Error("SOURCE_INVALID");
|
|
3623
|
+
}
|
|
3624
|
+
const entries = [];
|
|
3625
|
+
let totalBytes = 0;
|
|
3626
|
+
for (const descriptor of options2.sources) {
|
|
3627
|
+
const resolved = path2.resolve(locationDir, descriptor.path);
|
|
3628
|
+
let sourceReal;
|
|
3629
|
+
try {
|
|
3630
|
+
sourceReal = fs2.realpathSync(resolved);
|
|
3631
|
+
} catch {
|
|
3632
|
+
if (descriptor.required) throw new Error("SOURCE_INVALID");
|
|
3633
|
+
continue;
|
|
3634
|
+
}
|
|
3635
|
+
const relativeSource = path2.relative(locationReal, sourceReal);
|
|
3636
|
+
if (relativeSource === ".." || relativeSource.startsWith(`..${path2.sep}`) || path2.isAbsolute(relativeSource)) {
|
|
3637
|
+
if (descriptor.required) throw new Error("SOURCE_INVALID");
|
|
3638
|
+
continue;
|
|
3639
|
+
}
|
|
3640
|
+
let snapshot;
|
|
3641
|
+
try {
|
|
3642
|
+
snapshot = loadDotenvFile(resolved, {
|
|
3643
|
+
maxBytes: options2.limits.sourceBytes,
|
|
3644
|
+
maxEntries: options2.limits.secretCount,
|
|
3645
|
+
maxValueBytes: options2.limits.secretBytes
|
|
3646
|
+
});
|
|
3647
|
+
} catch {
|
|
3648
|
+
if (descriptor.required) throw new Error("SOURCE_INVALID");
|
|
3649
|
+
continue;
|
|
3650
|
+
}
|
|
3651
|
+
for (const entry of snapshot.entries) {
|
|
3652
|
+
if (!descriptor.keys.includes(entry.key) || entry.value.length === 0) continue;
|
|
3653
|
+
totalBytes += Buffer.byteLength(entry.value, "utf8");
|
|
3654
|
+
if (totalBytes > options2.limits.totalSourceBytes || entries.length >= options2.limits.secretCount) throw new Error("SOURCE_INVALID");
|
|
3655
|
+
entries.push({ sourceId: descriptor.id, key: entry.key, value: entry.value });
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
const budget = new BudgetLedger({
|
|
3659
|
+
handles: options2.limits.secretCount,
|
|
3660
|
+
secretCount: options2.limits.secretCount,
|
|
3661
|
+
secretBytes: options2.limits.secretBytes,
|
|
3662
|
+
indexBytes: options2.limits.indexBytes,
|
|
3663
|
+
workingBytes: options2.limits.workingBytes
|
|
3664
|
+
});
|
|
3665
|
+
const store = new ActivationStore({
|
|
3666
|
+
location: { directory: locationDir },
|
|
3667
|
+
generation: GENERATION,
|
|
3668
|
+
budget,
|
|
3669
|
+
randomBytes: () => new Uint8Array(randomBytes(16))
|
|
3670
|
+
});
|
|
3671
|
+
const handles = /* @__PURE__ */ new Map();
|
|
3672
|
+
for (const entry of entries) if (!handles.has(entry.value)) handles.set(entry.value, store.register(entry.value));
|
|
3673
|
+
const patterns = [];
|
|
3674
|
+
for (const entry of entries) {
|
|
3675
|
+
if (patterns.some((pattern) => pattern.text === entry.value)) continue;
|
|
3676
|
+
const replacement = handles.get(entry.value);
|
|
3677
|
+
if (replacement === void 0) throw new Error("SANITIZATION_UNAVAILABLE");
|
|
3678
|
+
patterns.push({ text: entry.value, replacement, entry: entry.value });
|
|
3679
|
+
}
|
|
3680
|
+
if (!admitPatterns(patterns).ok) throw new Error("SANITIZATION_UNAVAILABLE");
|
|
3681
|
+
const filter = {
|
|
3682
|
+
patterns,
|
|
3683
|
+
budget: {
|
|
3684
|
+
maxOutputBytes: Math.min(options2.limits.outputBytes, 2 * 1024 * 1024),
|
|
3685
|
+
maxDepth: Math.min(options2.limits.traversalDepth, 32),
|
|
3686
|
+
maxNodes: Math.min(options2.limits.traversalNodes, 5e4),
|
|
3687
|
+
maxMatches: Math.min(options2.limits.traversalNodes, 5e4)
|
|
3688
|
+
},
|
|
3689
|
+
maxInputBytes: options2.limits.inputBytes
|
|
3690
|
+
};
|
|
3691
|
+
const scanCeiling = Math.min(filter.maxInputBytes, filter.budget.maxOutputBytes);
|
|
3692
|
+
const sourcePaths = new Set(options2.sources.map((descriptor) => {
|
|
3693
|
+
const resolved = path2.resolve(locationDir, descriptor.path);
|
|
3694
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
3695
|
+
}));
|
|
3696
|
+
const pathInput = (input) => {
|
|
3697
|
+
if (!input || typeof input !== "object") return void 0;
|
|
3698
|
+
const record = input;
|
|
3699
|
+
for (const key of PATH_KEYS) {
|
|
3700
|
+
const value = record[key];
|
|
3701
|
+
if (typeof value === "string" && value.length > 0 && value.length <= 4096) return value;
|
|
3702
|
+
}
|
|
3703
|
+
return void 0;
|
|
3704
|
+
};
|
|
3705
|
+
const isSourcePath = (candidate) => {
|
|
3706
|
+
const resolved = path2.resolve(locationDir, candidate);
|
|
3707
|
+
return sourcePaths.has(process.platform === "win32" ? resolved.toLowerCase() : resolved);
|
|
3708
|
+
};
|
|
3709
|
+
const inputHasSecret = (input) => {
|
|
3710
|
+
if (!hasSecrets(filter) || input === void 0 || input === null) return false;
|
|
3711
|
+
let serialized;
|
|
3712
|
+
try {
|
|
3713
|
+
serialized = JSON.stringify(input);
|
|
3714
|
+
} catch {
|
|
3715
|
+
return false;
|
|
3716
|
+
}
|
|
3717
|
+
return serialized !== void 0 && Buffer.byteLength(serialized, "utf8") <= scanCeiling && containsSecret(serialized, filter);
|
|
3718
|
+
};
|
|
3719
|
+
const redactToolError = (event) => {
|
|
3720
|
+
const original = event.error;
|
|
3721
|
+
const message = typeof original.message === "string" ? redactString(original.message, filter) : null;
|
|
3722
|
+
event.error = new tool_exports.Error({ message: message ?? WITHHELD });
|
|
3723
|
+
};
|
|
3724
|
+
const sanitizeValue = (value) => {
|
|
3725
|
+
if (typeof value === "string") return redactString(value, filter) ?? WITHHELD;
|
|
3726
|
+
redactTree(value, filter);
|
|
3727
|
+
return value;
|
|
3728
|
+
};
|
|
3729
|
+
const sanitizeRequestContext = (event) => {
|
|
3730
|
+
event.system = sanitizeValue(event.system);
|
|
3731
|
+
redactTree(event.messages, filter);
|
|
3732
|
+
event.options = sanitizeValue(event.options);
|
|
3733
|
+
if (event.tools !== void 0) event.tools = sanitizeValue(event.tools);
|
|
3734
|
+
};
|
|
3735
|
+
const runtime = {
|
|
3736
|
+
close: () => Effect4.sync(() => store.teardown()),
|
|
3737
|
+
session: {
|
|
3738
|
+
prompt: (event) => Effect4.sync(() => {
|
|
3739
|
+
if (!hasSecrets(filter)) return;
|
|
3740
|
+
let changed = redactTree(event.prompt, filter);
|
|
3741
|
+
if (event.metadata !== void 0) changed = redactTree(event.metadata, filter) || changed;
|
|
3742
|
+
if (changed) dropMentions(event.prompt);
|
|
3743
|
+
}),
|
|
3744
|
+
context: (event) => Effect4.sync(() => {
|
|
3745
|
+
if (hasSecrets(filter)) sanitizeRequestContext(event);
|
|
3746
|
+
}),
|
|
3747
|
+
compaction: (event) => Effect4.sync(() => {
|
|
3748
|
+
if (!hasSecrets(filter)) return;
|
|
3749
|
+
sanitizeRequestContext(event);
|
|
3750
|
+
if (event.result !== void 0) event.result = sanitizeValue(event.result);
|
|
3751
|
+
}),
|
|
3752
|
+
generate: (event) => Effect4.sync(() => {
|
|
3753
|
+
if (hasSecrets(filter)) sanitizeRequestContext(event);
|
|
3754
|
+
}),
|
|
3755
|
+
title: (event) => Effect4.sync(() => {
|
|
3756
|
+
if (!hasSecrets(filter)) return;
|
|
3757
|
+
sanitizeRequestContext(event);
|
|
3758
|
+
if (event.result !== void 0) event.result = redactString(event.result, filter) ?? WITHHELD;
|
|
3759
|
+
}),
|
|
3760
|
+
modelRequest: (event) => Effect4.gen(function* () {
|
|
3761
|
+
if (!hasSecrets(filter)) return;
|
|
3762
|
+
if (redactHeaders(event.headers, filter, { skipAuth: true, strict: true }) === "withheld") yield* Effect4.die(new Error(WITHHELD));
|
|
3763
|
+
if (event.baseURL !== void 0) event.baseURL = redactString(event.baseURL, filter) ?? WITHHELD;
|
|
3764
|
+
}),
|
|
3765
|
+
httpRequest: (event) => Effect4.promise(async () => {
|
|
3766
|
+
if (!hasSecrets(filter)) return;
|
|
3767
|
+
const replacement = await redactRequest(event.request, filter).catch(() => "withheld");
|
|
3768
|
+
if (replacement === "withheld") throw new Error(WITHHELD);
|
|
3769
|
+
event.request = replacement;
|
|
3770
|
+
}),
|
|
3771
|
+
httpResponse: (event) => Effect4.promise(async () => {
|
|
3772
|
+
if (!hasSecrets(filter)) return;
|
|
3773
|
+
try {
|
|
3774
|
+
event.response = await redactResponse(event.response, filter);
|
|
3775
|
+
} catch {
|
|
3776
|
+
event.response = new Response(null, { status: 502 });
|
|
3777
|
+
}
|
|
3778
|
+
})
|
|
3779
|
+
},
|
|
3780
|
+
tool: {
|
|
3781
|
+
before: (event) => Effect4.gen(function* () {
|
|
3782
|
+
if (SOURCE_TOOLS.has(event.tool)) {
|
|
3783
|
+
const candidate = pathInput(event.input);
|
|
3784
|
+
if (candidate !== void 0 && isSourcePath(candidate)) yield* Effect4.fail(new tool_exports.Error({ message: "ACCESS_DENIED" }));
|
|
3785
|
+
}
|
|
3786
|
+
if (inputHasSecret(event.input)) yield* Effect4.fail(new tool_exports.Error({ message: "ACCESS_DENIED" }));
|
|
3787
|
+
}),
|
|
3788
|
+
after: (event) => Effect4.sync(() => {
|
|
3789
|
+
if (!hasSecrets(filter)) return;
|
|
3790
|
+
if (event.status === "completed") event.result = sanitizeValue(event.result);
|
|
3791
|
+
else redactToolError(event);
|
|
3792
|
+
})
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
return Effect4.succeed(runtime);
|
|
3796
|
+
};
|
|
3797
|
+
|
|
3798
|
+
// src/opencode/v2/index.ts
|
|
3799
|
+
var unavailableRuntime = {
|
|
3800
|
+
close: () => Effect5.void,
|
|
3801
|
+
session: {
|
|
3802
|
+
prompt: () => Effect5.void,
|
|
3803
|
+
context: () => Effect5.void,
|
|
3804
|
+
compaction: () => Effect5.void,
|
|
3805
|
+
generate: () => Effect5.void,
|
|
3806
|
+
title: () => Effect5.void,
|
|
3807
|
+
modelRequest: () => Effect5.void,
|
|
3808
|
+
httpRequest: () => Effect5.void,
|
|
3809
|
+
httpResponse: () => Effect5.void
|
|
3810
|
+
},
|
|
3811
|
+
tool: {
|
|
3812
|
+
before: () => Effect5.void,
|
|
3813
|
+
after: () => Effect5.void
|
|
3814
|
+
}
|
|
3815
|
+
};
|
|
3816
|
+
var unavailableRuntimeFactory = () => Effect5.succeed(unavailableRuntime);
|
|
3817
|
+
var makeEffect = (factory = unavailableRuntimeFactory) => (ctx) => Effect5.gen(function* () {
|
|
3818
|
+
const runtime = yield* Effect5.suspend(() => {
|
|
3819
|
+
try {
|
|
3820
|
+
return factory(parseOptions(ctx.options), ctx.location);
|
|
3821
|
+
} catch {
|
|
3822
|
+
return Effect5.succeed(unavailableRuntime);
|
|
3823
|
+
}
|
|
3824
|
+
});
|
|
3825
|
+
yield* Effect5.addFinalizer(() => runtime.close());
|
|
3826
|
+
yield* ctx.session.hook("prompt", (event) => runtime.session.prompt(event));
|
|
3827
|
+
yield* ctx.session.hook("context", (event) => runtime.session.context(event));
|
|
3828
|
+
yield* ctx.session.hook("compaction", (event) => runtime.session.compaction(event));
|
|
3829
|
+
yield* ctx.session.hook("generate", (event) => runtime.session.generate(event));
|
|
3830
|
+
yield* ctx.session.hook("title", (event) => runtime.session.title(event));
|
|
3831
|
+
yield* ctx.session.hook("model.request", (event) => runtime.session.modelRequest(event));
|
|
3832
|
+
yield* ctx.session.hook("http.request", (event) => runtime.session.httpRequest(event));
|
|
3833
|
+
yield* ctx.session.hook("http.response", (event) => runtime.session.httpResponse(event));
|
|
3834
|
+
yield* ctx.tool.hook("execute.before", (event) => runtime.tool.before(event));
|
|
3835
|
+
yield* ctx.tool.hook("execute.after", (event) => runtime.tool.after(event));
|
|
3836
|
+
});
|
|
3837
|
+
var plugin = plugin_exports.define({
|
|
3838
|
+
id: "opencode-secrets-obfuscation",
|
|
3839
|
+
effect: makeEffect(realRuntimeFactory)
|
|
3840
|
+
});
|
|
3841
|
+
var index_default = plugin;
|
|
3842
|
+
export {
|
|
3843
|
+
index_default as default,
|
|
3844
|
+
makeEffect,
|
|
3845
|
+
unavailableRuntime,
|
|
3846
|
+
unavailableRuntimeFactory
|
|
3847
|
+
};
|