stitchkit 0.100.2 → 0.100.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/README.md +2 -1
- package/dist/entrypoints/agent-runtime/browser.js +119 -119
- package/dist/entrypoints/agent-runtime/coding-tools.js +15 -20
- package/dist/entrypoints/agent-runtime/harness.js +55 -63
- package/dist/entrypoints/agent-runtime/openrouter.js +6 -6
- package/dist/entrypoints/agent-runtime/sandbox.js +20 -25
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +11 -13
- package/dist/entrypoints/agent-runtime/sqlite/node.js +11 -13
- package/dist/entrypoints/agent-runtime/testing.js +32 -34
- package/dist/entrypoints/agent-runtime.js +395 -402
- package/dist/entrypoints/application/diagnostic-journal.js +26 -27
- package/dist/entrypoints/application/directory-inbox.js +16 -17
- package/dist/entrypoints/application/grammy.js +13 -13
- package/dist/entrypoints/application/opentelemetry.js +13 -13
- package/dist/entrypoints/application/schemas.js +24 -24
- package/dist/entrypoints/application.js +208 -210
- package/dist/entrypoints/bin/upgrade-cli.js +2 -2
- package/dist/entrypoints/cli.js +81 -84
- package/dist/entrypoints/contract.js +54 -57
- package/dist/entrypoints/declaration.js +22 -22
- package/dist/entrypoints/files.js +18 -21
- package/dist/entrypoints/geo.js +7 -8
- package/dist/entrypoints/google.js +2 -2
- package/dist/entrypoints/index.js +150 -154
- package/dist/entrypoints/live.js +45 -47
- package/dist/entrypoints/node.js +68 -74
- package/dist/entrypoints/oauth.js +6 -6
- package/dist/entrypoints/observability.d.ts +1 -0
- package/dist/entrypoints/observability.d.ts.map +1 -1
- package/dist/entrypoints/observability.js +115 -87
- package/dist/entrypoints/primitives.js +35 -35
- package/dist/entrypoints/react/keyboard.d.ts +4 -0
- package/dist/entrypoints/react/keyboard.d.ts.map +1 -0
- package/dist/entrypoints/react/keyboard.js +397 -0
- package/dist/entrypoints/react.js +10 -10
- package/dist/entrypoints/release.js +7 -7
- package/dist/entrypoints/remote.js +15 -17
- package/dist/entrypoints/server.js +198 -200
- package/dist/entrypoints/telegram/html.d.ts +5 -0
- package/dist/entrypoints/telegram/html.d.ts.map +1 -0
- package/dist/entrypoints/telegram/html.js +26 -0
- package/dist/entrypoints/telegram/screens.d.ts +14 -0
- package/dist/entrypoints/telegram/screens.d.ts.map +1 -0
- package/dist/entrypoints/telegram/screens.js +2028 -0
- package/dist/entrypoints/telegram.d.ts +5 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +548 -156
- package/dist/entrypoints/testing.js +75 -79
- package/dist/entrypoints/tools/connections.js +30 -32
- package/dist/entrypoints/tools/contract.js +18 -20
- package/dist/entrypoints/tools/invoker.js +12 -17
- package/dist/entrypoints/tools.js +223 -229
- package/dist/entrypoints/tracking/server.js +6 -6
- package/dist/entrypoints/tracking.js +40 -42
- package/dist/entrypoints/voice.js +3 -3
- package/dist/{index-eaysmdtq.js → index-0ndk4555.js} +56 -56
- package/dist/{index-2bxbyab0.js → index-1bx1xv1k.js} +1 -1
- package/dist/{index-p5r7qpdd.js → index-1eeqpadm.js} +4 -4
- package/dist/{index-hadmp193.js → index-3ct7hhq6.js} +210 -210
- package/dist/{index-e01r054k.js → index-45tdvqa3.js} +26 -26
- package/dist/{index-dce5wxcq.js → index-4s0fep5q.js} +8 -8
- package/dist/index-50ejfz75.js +9 -0
- package/dist/{index-m9zn6cpq.js → index-5107q189.js} +12 -12
- package/dist/{index-sbdmyz75.js → index-5cc6r990.js} +3 -3
- package/dist/index-6k1svmjh.js +141 -0
- package/dist/{index-c6bxbsnc.js → index-7kxw1awn.js} +2 -2
- package/dist/{index-0r0fbk7z.js → index-7z9ym7t8.js} +28 -28
- package/dist/{index-p7hgdyhb.js → index-814xpr6d.js} +2 -2
- package/dist/{index-gtj3zc53.js → index-8kzct1d6.js} +99 -99
- package/dist/{index-1zbbzgfh.js → index-9pw0a51a.js} +4 -4
- package/dist/{index-79z7m7dt.js → index-a9pd417t.js} +35 -35
- package/dist/{index-ham5sz8m.js → index-aaj97r4y.js} +45 -45
- package/dist/{index-s812ycat.js → index-aan6hqb9.js} +3 -3
- package/dist/{index-10x2hbx0.js → index-adhgd4pe.js} +44 -44
- package/dist/{index-2gxzjvyr.js → index-afjvjyck.js} +23 -23
- package/dist/{index-qmy6zq75.js → index-ahvsksw5.js} +16 -16
- package/dist/{index-hr4tzbwq.js → index-ap3gqe56.js} +3 -3
- package/dist/{index-znfs20ss.js → index-b2bz0kdm.js} +16 -16
- package/dist/{index-r066jx76.js → index-c6aagrbd.js} +148 -120
- package/dist/{index-k30h66yd.js → index-ck71tbcf.js} +9 -9
- package/dist/{index-eqqvgdb3.js → index-ct75c3at.js} +2 -2
- package/dist/{index-gw8bmyaj.js → index-djjhhgjk.js} +41 -41
- package/dist/{index-8qt2m66q.js → index-dvwj1f43.js} +43 -43
- package/dist/{index-fhwqwxe0.js → index-ej331hah.js} +1 -1
- package/dist/{index-9t3dffv2.js → index-ewbaywk5.js} +5 -5
- package/dist/{index-7p1f0vp2.js → index-fyphpknh.js} +25 -25
- package/dist/{index-83bdg97s.js → index-g149e9pk.js} +1 -1
- package/dist/{index-ngfhvfpd.js → index-g6a3na27.js} +4 -4
- package/dist/{index-qwhynv6x.js → index-h124epcf.js} +20 -20
- package/dist/{index-h6eeys1v.js → index-h97tqqp1.js} +9 -9
- package/dist/{index-zcgf3gqf.js → index-hby4qhax.js} +10 -10
- package/dist/{index-5jrd0yng.js → index-j8aw2c0e.js} +4 -4
- package/dist/{index-d8m8zpd8.js → index-jzczzcsb.js} +14 -14
- package/dist/index-kqnd6a85.js +26 -0
- package/dist/{index-35mh5bhj.js → index-kw1ws0cs.js} +12 -12
- package/dist/{index-yw4fzmdz.js → index-kzz6rq0w.js} +28 -17
- package/dist/{index-4gcnakhx.js → index-m38ej7e5.js} +2 -2
- package/dist/{index-ndddxtyx.js → index-m79yr938.js} +19 -19
- package/dist/{index-5p2m7we1.js → index-m9fndta6.js} +11 -11
- package/dist/index-mnkk1ffz.js +150 -0
- package/dist/index-n15jny5b.js +4 -0
- package/dist/{index-2vtcmrj9.js → index-n53mswt3.js} +20 -20
- package/dist/{index-bt14acb5.js → index-n5yqxd3d.js} +21 -21
- package/dist/{index-bm5rx7n6.js → index-n9tyz8z3.js} +12 -12
- package/dist/index-nmaqxdx7.js +463 -0
- package/dist/{index-mqv3b5rh.js → index-nx6eazt0.js} +30 -30
- package/dist/{index-3z73fh2c.js → index-q0th8q0z.js} +9 -9
- package/dist/{index-v260df89.js → index-qjeggp8w.js} +20 -20
- package/dist/{index-zfrhfn82.js → index-r1z0rd9c.js} +20 -20
- package/dist/{index-wqgjfstn.js → index-r5c4fedv.js} +3 -3
- package/dist/{index-cyktc4bp.js → index-r5hsgkz5.js} +118 -118
- package/dist/{index-0b1ess5e.js → index-r7a7r7ha.js} +1 -1
- package/dist/{index-1j8pm5t0.js → index-rfkh44ss.js} +15 -15
- package/dist/index-rz3z13e9.js +47 -0
- package/dist/{index-k6gpggb9.js → index-s80awwsw.js} +35 -35
- package/dist/{index-vqr7f7v8.js → index-ssmd41kh.js} +124 -124
- package/dist/{index-ensd0r74.js → index-v14qqmys.js} +41 -41
- package/dist/{index-paz6sgdp.js → index-v4a2fjtk.js} +36 -36
- package/dist/{index-d9pk3td4.js → index-w0eqdhyd.js} +14 -14
- package/dist/{index-5qn1kx34.js → index-w575evhq.js} +29 -29
- package/dist/{index-3gye9wzb.js → index-w5s3xftz.js} +26 -26
- package/dist/{index-tm88avnj.js → index-wykebpn9.js} +3 -3
- package/dist/{index-sh3s86na.js → index-xkhk5d6g.js} +17 -17
- package/dist/{index-6k1937bx.js → index-xqhede6x.js} +4 -4
- package/dist/{index-f4fx2tza.js → index-zs4ms3th.js} +181 -181
- package/dist/{index-k5hsfc3j.js → index-zsvzhjtk.js} +1 -1
- package/dist/observability/bounded-logger.d.ts +2 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/sanitize.d.ts +6 -0
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/observability/secret-values.d.ts +25 -0
- package/dist/observability/secret-values.d.ts.map +1 -0
- package/dist/react/keyboard/hooks.d.ts +71 -0
- package/dist/react/keyboard/hooks.d.ts.map +1 -0
- package/dist/react/keyboard/layers.d.ts +98 -0
- package/dist/react/keyboard/layers.d.ts.map +1 -0
- package/dist/react/keyboard/zone.d.ts +139 -0
- package/dist/react/keyboard/zone.d.ts.map +1 -0
- package/dist/telegram/crypto.d.ts +16 -0
- package/dist/telegram/crypto.d.ts.map +1 -0
- package/dist/telegram/html/check.d.ts +26 -0
- package/dist/telegram/html/check.d.ts.map +1 -0
- package/dist/telegram/html/nodes.d.ts +70 -0
- package/dist/telegram/html/nodes.d.ts.map +1 -0
- package/dist/telegram/html/parse.d.ts +35 -0
- package/dist/telegram/html/parse.d.ts.map +1 -0
- package/dist/telegram/html/render.d.ts +39 -0
- package/dist/telegram/html/render.d.ts.map +1 -0
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts +36 -3
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/screens/callback-codec.d.ts +34 -0
- package/dist/telegram/screens/callback-codec.d.ts.map +1 -0
- package/dist/telegram/screens/dispatch.d.ts +22 -0
- package/dist/telegram/screens/dispatch.d.ts.map +1 -0
- package/dist/telegram/screens/display.d.ts +70 -0
- package/dist/telegram/screens/display.d.ts.map +1 -0
- package/dist/telegram/screens/execute.d.ts +57 -0
- package/dist/telegram/screens/execute.d.ts.map +1 -0
- package/dist/telegram/screens/html.d.ts +36 -0
- package/dist/telegram/screens/html.d.ts.map +1 -0
- package/dist/telegram/screens/outcome.d.ts +74 -0
- package/dist/telegram/screens/outcome.d.ts.map +1 -0
- package/dist/telegram/screens/path.d.ts +29 -0
- package/dist/telegram/screens/path.d.ts.map +1 -0
- package/dist/telegram/screens/reconcile.d.ts +67 -0
- package/dist/telegram/screens/reconcile.d.ts.map +1 -0
- package/dist/telegram/screens/registry.d.ts +23 -0
- package/dist/telegram/screens/registry.d.ts.map +1 -0
- package/dist/telegram/screens/render.d.ts +70 -0
- package/dist/telegram/screens/render.d.ts.map +1 -0
- package/dist/telegram/screens/runtime.d.ts +133 -0
- package/dist/telegram/screens/runtime.d.ts.map +1 -0
- package/dist/telegram/screens/screen-types.d.ts +130 -0
- package/dist/telegram/screens/screen-types.d.ts.map +1 -0
- package/dist/telegram/screens/screen.d.ts +138 -0
- package/dist/telegram/screens/screen.d.ts.map +1 -0
- package/dist/telegram/screens/state.d.ts +115 -0
- package/dist/telegram/screens/state.d.ts.map +1 -0
- package/dist/telegram/screens/telegram-screens.d.ts +18 -0
- package/dist/telegram/screens/telegram-screens.d.ts.map +1 -0
- package/dist/telegram/screens/test-chat-telegram.d.ts +47 -0
- package/dist/telegram/screens/test-chat-telegram.d.ts.map +1 -0
- package/dist/telegram/screens/test-chat.d.ts +66 -0
- package/dist/telegram/screens/test-chat.d.ts.map +1 -0
- package/dist/telegram/screens/view.d.ts +89 -0
- package/dist/telegram/screens/view.d.ts.map +1 -0
- package/dist/telegram/send-failure.d.ts +19 -0
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts +78 -0
- package/dist/telegram/update-intake.d.ts.map +1 -0
- package/dist/telegram/update-store-sqlite.d.ts +26 -0
- package/dist/telegram/update-store-sqlite.d.ts.map +1 -0
- package/dist/telegram/update-store.d.ts +67 -0
- package/dist/telegram/update-store.d.ts.map +1 -0
- package/dist/telegram/webhook.d.ts +105 -0
- package/dist/telegram/webhook.d.ts.map +1 -0
- package/dist/tools/cli/args-fields.d.ts +8 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/llms/cli.txt +8 -2
- package/llms/observability.txt +2 -1
- package/llms/react-keyboard.txt +193 -0
- package/llms/stitchkit.txt +7 -1
- package/llms/telegram-html.txt +35 -0
- package/llms/telegram-screens.txt +365 -0
- package/llms/telegram.txt +160 -4
- package/llms-full.txt +736 -8
- package/llms.txt +10 -5
- package/package.json +17 -2
- package/dist/index-2k4yrqkc.js +0 -9
- package/dist/index-crykmqkr.js +0 -26
- package/dist/index-y64k3s0h.js +0 -150
- package/dist/index-y91ry9h2.js +0 -4
- /package/dist/{index-hffjpmq9.js → index-9jfdm5tg.js} +0 -0
- /package/dist/{index-zjjyynm3.js → index-d4pa2bgs.js} +0 -0
- /package/dist/{index-rxfy4cq7.js → index-dwfv9a85.js} +0 -0
- /package/dist/{index-5jm36zv1.js → index-gfk7nrht.js} +0 -0
- /package/dist/{index-b9aefrqd.js → index-n1dqr7gf.js} +0 -0
- /package/dist/{index-q3pyb9n0.js → index-sykb5ag7.js} +0 -0
- /package/dist/{index-48ffdxgk.js → index-xhzq2qvj.js} +0 -0
- /package/dist/{index-kzfs85xp.js → index-zsarb5xp.js} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
createBoundedChannel2
|
|
3
|
+
} from "./index-w0eqdhyd.js";
|
|
4
4
|
import {
|
|
5
5
|
assertDrainBound,
|
|
6
6
|
withinBound
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-h97tqqp1.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./index-
|
|
9
|
+
ApplicationIdSchema2
|
|
10
|
+
} from "./index-w5s3xftz.js";
|
|
11
11
|
|
|
12
12
|
// src/application/latest-sink.ts
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
var SnapshotRevisionSchema = z.number().int().nonnegative();
|
|
15
|
-
var
|
|
15
|
+
var ApplicationSnapshotSinkStatusSchema2 = z.object({
|
|
16
16
|
accepting: z.boolean(),
|
|
17
17
|
received: z.number().int().nonnegative(),
|
|
18
18
|
accepted: z.number().int().nonnegative(),
|
|
@@ -25,7 +25,7 @@ var ApplicationSnapshotSinkStatusSchema = z.object({
|
|
|
25
25
|
lastAcceptedRevision: SnapshotRevisionSchema.optional(),
|
|
26
26
|
lastDeliveredRevision: SnapshotRevisionSchema.optional()
|
|
27
27
|
}).strict().readonly();
|
|
28
|
-
function
|
|
28
|
+
function createApplicationSnapshotSink2(config) {
|
|
29
29
|
let accepting = true;
|
|
30
30
|
let received = 0;
|
|
31
31
|
let accepted = 0;
|
|
@@ -38,13 +38,13 @@ function createApplicationSnapshotSink(config) {
|
|
|
38
38
|
let inFlight;
|
|
39
39
|
let closePromise;
|
|
40
40
|
let resolveClose;
|
|
41
|
-
const pending =
|
|
41
|
+
const pending = createBoundedChannel2({
|
|
42
42
|
policy: "latest",
|
|
43
43
|
maxItems: 1,
|
|
44
44
|
maxBytes: 1,
|
|
45
45
|
sizeOf: () => 1
|
|
46
46
|
});
|
|
47
|
-
const getStatus = () =>
|
|
47
|
+
const getStatus = () => ApplicationSnapshotSinkStatusSchema2.parse({
|
|
48
48
|
accepting,
|
|
49
49
|
received,
|
|
50
50
|
accepted,
|
|
@@ -134,10 +134,10 @@ function createApplicationSnapshotSink(config) {
|
|
|
134
134
|
import { z as z2 } from "zod";
|
|
135
135
|
var BoundedOperationalIdSchema = z2.string().min(1).max(64).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/);
|
|
136
136
|
var NonNegativeIntegerSchema = z2.number().int().nonnegative();
|
|
137
|
-
var
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
id:
|
|
137
|
+
var ActivityIdSchema2 = BoundedOperationalIdSchema;
|
|
138
|
+
var ActivityStageIdSchema2 = BoundedOperationalIdSchema;
|
|
139
|
+
var ActivityStageSnapshotSchema2 = z2.object({
|
|
140
|
+
id: ActivityStageIdSchema2,
|
|
141
141
|
active: NonNegativeIntegerSchema,
|
|
142
142
|
queued: NonNegativeIntegerSchema,
|
|
143
143
|
completed: NonNegativeIntegerSchema,
|
|
@@ -149,17 +149,17 @@ var ActivityTotalsSchema = z2.object({
|
|
|
149
149
|
completed: NonNegativeIntegerSchema,
|
|
150
150
|
failed: NonNegativeIntegerSchema
|
|
151
151
|
}).strict().readonly();
|
|
152
|
-
var
|
|
153
|
-
id:
|
|
152
|
+
var ActivitySnapshotSchema2 = z2.object({
|
|
153
|
+
id: ActivityIdSchema2,
|
|
154
154
|
epoch: z2.string().uuid(),
|
|
155
155
|
revision: NonNegativeIntegerSchema,
|
|
156
156
|
capturedAt: z2.string().datetime({ offset: true }),
|
|
157
157
|
changedAt: z2.string().datetime({ offset: true }),
|
|
158
|
-
stages: z2.array(
|
|
158
|
+
stages: z2.array(ActivityStageSnapshotSchema2).min(1).max(64).readonly(),
|
|
159
159
|
totals: ActivityTotalsSchema
|
|
160
160
|
}).strict().readonly();
|
|
161
|
-
var
|
|
162
|
-
var
|
|
161
|
+
var ActivityLiveStateSchema2 = z2.enum(["active", "queued"]);
|
|
162
|
+
var ActivityTokenBrand2 = Symbol("stitchkit.application.activity");
|
|
163
163
|
function emptyCounters() {
|
|
164
164
|
return { active: 0, queued: 0, completed: 0, failed: 0 };
|
|
165
165
|
}
|
|
@@ -171,9 +171,9 @@ function totalsOf(stages) {
|
|
|
171
171
|
failed: totals.failed + stage.failed
|
|
172
172
|
}), emptyCounters());
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
const id =
|
|
176
|
-
const declaredStages = z2.array(
|
|
174
|
+
function createActivityProjection2(config) {
|
|
175
|
+
const id = ActivityIdSchema2.parse(config.id);
|
|
176
|
+
const declaredStages = z2.array(ActivityStageIdSchema2).min(1).max(64).parse(config.stages);
|
|
177
177
|
const uniqueStages = new Set(declaredStages);
|
|
178
178
|
if (uniqueStages.size !== declaredStages.length) {
|
|
179
179
|
throw new Error("[stitchkit] createActivityProjection: stage ids must be unique");
|
|
@@ -194,7 +194,7 @@ function createActivityProjection(config) {
|
|
|
194
194
|
};
|
|
195
195
|
const getSnapshot = () => {
|
|
196
196
|
const stages = declaredStages.map((stage) => ({ id: stage, ...countersFor(stage) }));
|
|
197
|
-
return
|
|
197
|
+
return ActivitySnapshotSchema2.parse({
|
|
198
198
|
id,
|
|
199
199
|
epoch,
|
|
200
200
|
revision,
|
|
@@ -235,11 +235,11 @@ function createActivityProjection(config) {
|
|
|
235
235
|
};
|
|
236
236
|
return {
|
|
237
237
|
open(stage, rawState = "active") {
|
|
238
|
-
const parsedStage =
|
|
239
|
-
const state =
|
|
238
|
+
const parsedStage = ActivityStageIdSchema2.parse(stage);
|
|
239
|
+
const state = ActivityLiveStateSchema2.parse(rawState);
|
|
240
240
|
countersFor(parsedStage)[state] += 1;
|
|
241
241
|
const token = Object.freeze({
|
|
242
|
-
get [
|
|
242
|
+
get [ActivityTokenBrand2]() {
|
|
243
243
|
return true;
|
|
244
244
|
}
|
|
245
245
|
});
|
|
@@ -252,8 +252,8 @@ function createActivityProjection(config) {
|
|
|
252
252
|
if (activity.state === "completed" || activity.state === "failed") {
|
|
253
253
|
throw new Error("[stitchkit] cannot transition a terminal activity");
|
|
254
254
|
}
|
|
255
|
-
const stage =
|
|
256
|
-
const state =
|
|
255
|
+
const stage = ActivityStageIdSchema2.parse(input.stage);
|
|
256
|
+
const state = ActivityLiveStateSchema2.parse(input.state);
|
|
257
257
|
countersFor(stage);
|
|
258
258
|
if (activity.stage === stage && activity.state === state)
|
|
259
259
|
return false;
|
|
@@ -268,7 +268,7 @@ function createActivityProjection(config) {
|
|
|
268
268
|
fail: (token) => settle(token, "failed"),
|
|
269
269
|
getSnapshot,
|
|
270
270
|
subscribe(listener) {
|
|
271
|
-
const sink =
|
|
271
|
+
const sink = createApplicationSnapshotSink2({
|
|
272
272
|
write: listener,
|
|
273
273
|
...config.onSubscriberError && { onSinkError: config.onSubscriberError }
|
|
274
274
|
});
|
|
@@ -286,7 +286,7 @@ function createActivityProjection(config) {
|
|
|
286
286
|
import { z as z3 } from "zod";
|
|
287
287
|
var NonNegativeSafeIntegerSchema = z3.number().int().nonnegative().refine(Number.isSafeInteger, "Expected a safe integer");
|
|
288
288
|
var PositiveSafeIntegerSchema = NonNegativeSafeIntegerSchema.refine((value) => value > 0, "Expected a positive integer");
|
|
289
|
-
var
|
|
289
|
+
var ManagedScheduleOverlapSchema2 = z3.discriminatedUnion("mode", [
|
|
290
290
|
z3.object({ mode: z3.literal("skip") }).readonly(),
|
|
291
291
|
z3.object({ mode: z3.literal("queue-one") }).readonly(),
|
|
292
292
|
z3.object({
|
|
@@ -294,16 +294,16 @@ var ManagedScheduleOverlapSchema = z3.discriminatedUnion("mode", [
|
|
|
294
294
|
maxConcurrent: PositiveSafeIntegerSchema
|
|
295
295
|
}).readonly()
|
|
296
296
|
]);
|
|
297
|
-
var
|
|
298
|
-
var
|
|
299
|
-
id:
|
|
297
|
+
var ManagedScheduleErrorPolicySchema2 = z3.enum(["continue", "stop-schedule"]);
|
|
298
|
+
var ManagedScheduleDescriptorSchema2 = z3.object({
|
|
299
|
+
id: ApplicationIdSchema2,
|
|
300
300
|
everyMs: PositiveSafeIntegerSchema,
|
|
301
301
|
startAfterMs: NonNegativeSafeIntegerSchema,
|
|
302
|
-
overlap:
|
|
303
|
-
errorPolicy:
|
|
302
|
+
overlap: ManagedScheduleOverlapSchema2,
|
|
303
|
+
errorPolicy: ManagedScheduleErrorPolicySchema2
|
|
304
304
|
}).readonly();
|
|
305
|
-
var
|
|
306
|
-
descriptor:
|
|
305
|
+
var ManagedScheduleStatusSchema2 = z3.object({
|
|
306
|
+
descriptor: ManagedScheduleDescriptorSchema2,
|
|
307
307
|
state: z3.enum(["inactive", "scheduled", "running", "draining", "stopped"]),
|
|
308
308
|
revision: NonNegativeSafeIntegerSchema,
|
|
309
309
|
capturedAt: z3.string().datetime({ offset: true }),
|
|
@@ -413,15 +413,15 @@ async function executeRun(deps, scheduledAt) {
|
|
|
413
413
|
function elapsedIntervals(scheduledAt, observedAt, everyMs) {
|
|
414
414
|
return Math.max(1, Math.floor((observedAt - scheduledAt) / everyMs) + 1);
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
const descriptor =
|
|
416
|
+
function createManagedSchedule2(config) {
|
|
417
|
+
const descriptor = ManagedScheduleDescriptorSchema2.parse({
|
|
418
418
|
id: config.id,
|
|
419
419
|
everyMs: config.everyMs,
|
|
420
420
|
startAfterMs: config.startAfterMs ?? config.everyMs,
|
|
421
421
|
overlap: config.overlap ?? DEFAULT_OVERLAP,
|
|
422
422
|
errorPolicy: config.errorPolicy ?? "continue"
|
|
423
423
|
});
|
|
424
|
-
const dependsOn = config.dependsOn?.map((id) =>
|
|
424
|
+
const dependsOn = config.dependsOn?.map((id) => ApplicationIdSchema2.parse(id));
|
|
425
425
|
const clock = config.clock ?? systemClock;
|
|
426
426
|
let revision = 0;
|
|
427
427
|
let accepting = false;
|
|
@@ -463,7 +463,7 @@ function createManagedSchedule(config) {
|
|
|
463
463
|
const status = () => {
|
|
464
464
|
const captured = clock.wallNow();
|
|
465
465
|
const anchor = { monotonicNow: clock.now(), wallNow: captured.getTime() };
|
|
466
|
-
return
|
|
466
|
+
return ManagedScheduleStatusSchema2.parse({
|
|
467
467
|
descriptor,
|
|
468
468
|
state: scheduleState(activated, stopped, accepting, active.size),
|
|
469
469
|
revision,
|
|
@@ -592,4 +592,4 @@ function createManagedSchedule(config) {
|
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
594
|
|
|
595
|
-
export {
|
|
595
|
+
export { ApplicationSnapshotSinkStatusSchema2, createApplicationSnapshotSink2, ActivityIdSchema2, ActivityStageIdSchema2, ActivityStageSnapshotSchema2, ActivitySnapshotSchema2, ActivityLiveStateSchema2, ActivityTokenBrand2, createActivityProjection2, ManagedScheduleOverlapSchema2, ManagedScheduleErrorPolicySchema2, ManagedScheduleDescriptorSchema2, ManagedScheduleStatusSchema2, createManagedSchedule2 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "./index-
|
|
2
|
+
ManagedFilePathSchema2,
|
|
3
|
+
ManagedFileRefSchema2
|
|
4
|
+
} from "./index-xqhede6x.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./index-
|
|
6
|
+
isWithinDir2
|
|
7
|
+
} from "./index-5cc6r990.js";
|
|
8
8
|
|
|
9
9
|
// src/files/boundary.ts
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
@@ -13,7 +13,7 @@ import { link, mkdir, open, realpath, rename, stat, unlink } from "node:fs/promi
|
|
|
13
13
|
import { basename, dirname, resolve } from "node:path";
|
|
14
14
|
|
|
15
15
|
// src/files/file-io.ts
|
|
16
|
-
var ManagedFileInspectionSchema =
|
|
16
|
+
var ManagedFileInspectionSchema = ManagedFileRefSchema2.pick({
|
|
17
17
|
mediaType: true,
|
|
18
18
|
name: true
|
|
19
19
|
});
|
|
@@ -50,20 +50,20 @@ async function inspectFile(inspector, input, timeoutMs, outerSignal) {
|
|
|
50
50
|
} catch (error) {
|
|
51
51
|
if (outerSignal?.aborted)
|
|
52
52
|
throw abortReason(outerSignal);
|
|
53
|
-
throw new
|
|
53
|
+
throw new ManagedFileError2("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: error });
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
function inspectedRef(path, size, inspection, fallback = {}) {
|
|
57
57
|
const mediaType = inspection.mediaType ?? fallback.mediaType;
|
|
58
58
|
const name = inspection.name ?? fallback.name;
|
|
59
|
-
const parsed =
|
|
59
|
+
const parsed = ManagedFileRefSchema2.safeParse({
|
|
60
60
|
path,
|
|
61
61
|
size,
|
|
62
62
|
...mediaType ? { mediaType } : {},
|
|
63
63
|
...name ? { name } : {}
|
|
64
64
|
});
|
|
65
65
|
if (!parsed.success) {
|
|
66
|
-
throw new
|
|
66
|
+
throw new ManagedFileError2("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: parsed.error });
|
|
67
67
|
}
|
|
68
68
|
return parsed.data;
|
|
69
69
|
}
|
|
@@ -74,7 +74,7 @@ async function readHandle(handle, maxBytes, signal) {
|
|
|
74
74
|
signal?.throwIfAborted();
|
|
75
75
|
const capacity = Math.min(64 * 1024, maxBytes + 1 - total);
|
|
76
76
|
if (capacity <= 0) {
|
|
77
|
-
throw new
|
|
77
|
+
throw new ManagedFileError2("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
|
|
78
78
|
}
|
|
79
79
|
const chunk = new Uint8Array(capacity);
|
|
80
80
|
const { bytesRead } = await handle.read(chunk, 0, capacity);
|
|
@@ -82,7 +82,7 @@ async function readHandle(handle, maxBytes, signal) {
|
|
|
82
82
|
break;
|
|
83
83
|
total += bytesRead;
|
|
84
84
|
if (total > maxBytes) {
|
|
85
|
-
throw new
|
|
85
|
+
throw new ManagedFileError2("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
|
|
86
86
|
}
|
|
87
87
|
chunks.push(chunk.subarray(0, bytesRead));
|
|
88
88
|
}
|
|
@@ -111,7 +111,7 @@ async function writeSource(handle, source, maxBytes, inspectionBytes, signal) {
|
|
|
111
111
|
signal?.throwIfAborted();
|
|
112
112
|
size += chunk.byteLength;
|
|
113
113
|
if (size > maxBytes) {
|
|
114
|
-
throw new
|
|
114
|
+
throw new ManagedFileError2("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
|
|
115
115
|
}
|
|
116
116
|
if (prefixSize < inspectionBytes) {
|
|
117
117
|
const kept = chunk.subarray(0, inspectionBytes - prefixSize);
|
|
@@ -159,7 +159,7 @@ var noFollow = () => {
|
|
|
159
159
|
return nofollowFlag;
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
class
|
|
162
|
+
class ManagedFileError2 extends Error {
|
|
163
163
|
code;
|
|
164
164
|
constructor(code, message, options) {
|
|
165
165
|
super(message, options);
|
|
@@ -175,9 +175,9 @@ function positiveLimit(value, fallback, name) {
|
|
|
175
175
|
return resolved;
|
|
176
176
|
}
|
|
177
177
|
function filePath(path) {
|
|
178
|
-
const parsed =
|
|
178
|
+
const parsed = ManagedFilePathSchema2.safeParse(path);
|
|
179
179
|
if (!parsed.success) {
|
|
180
|
-
throw new
|
|
180
|
+
throw new ManagedFileError2("FILE_INVALID_PATH", "invalid managed-file path");
|
|
181
181
|
}
|
|
182
182
|
return parsed.data;
|
|
183
183
|
}
|
|
@@ -187,9 +187,9 @@ function errorCode(error) {
|
|
|
187
187
|
return typeof error.code === "string" ? error.code : undefined;
|
|
188
188
|
}
|
|
189
189
|
function ioError(message, error) {
|
|
190
|
-
if (error instanceof
|
|
190
|
+
if (error instanceof ManagedFileError2)
|
|
191
191
|
return error;
|
|
192
|
-
return new
|
|
192
|
+
return new ManagedFileError2("FILE_IO_ERROR", message, { cause: error });
|
|
193
193
|
}
|
|
194
194
|
async function realpathOrNull(path, message) {
|
|
195
195
|
try {
|
|
@@ -206,20 +206,20 @@ async function bindRoot(config) {
|
|
|
206
206
|
if (canonical === null && config.createRoot) {
|
|
207
207
|
const parent = await realpathOrNull(dirname(requested), "failed to resolve managed-file root parent");
|
|
208
208
|
if (parent === null) {
|
|
209
|
-
throw new
|
|
209
|
+
throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file root parent must exist");
|
|
210
210
|
}
|
|
211
211
|
const parentInfo = await stat(parent).catch((error) => {
|
|
212
212
|
throw ioError("failed to inspect managed-file root parent", error);
|
|
213
213
|
});
|
|
214
214
|
if (!parentInfo.isDirectory()) {
|
|
215
|
-
throw new
|
|
215
|
+
throw new ManagedFileError2("FILE_NOT_REGULAR", "managed-file root parent must be a directory");
|
|
216
216
|
}
|
|
217
217
|
try {
|
|
218
218
|
await mkdir(requested, { mode: 448 });
|
|
219
219
|
} catch (error) {
|
|
220
220
|
if (errorCode(error) !== "EEXIST") {
|
|
221
221
|
if (errorCode(error) === "ENOENT") {
|
|
222
|
-
throw new
|
|
222
|
+
throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file root parent must exist");
|
|
223
223
|
}
|
|
224
224
|
throw ioError("failed to create managed-file root", error);
|
|
225
225
|
}
|
|
@@ -227,33 +227,33 @@ async function bindRoot(config) {
|
|
|
227
227
|
canonical = await realpathOrNull(requested, "failed to resolve managed-file root");
|
|
228
228
|
}
|
|
229
229
|
if (canonical === null) {
|
|
230
|
-
throw new
|
|
230
|
+
throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file root must exist");
|
|
231
231
|
}
|
|
232
232
|
const info = await stat(canonical).catch((error) => {
|
|
233
233
|
throw ioError("failed to inspect managed-file root", error);
|
|
234
234
|
});
|
|
235
235
|
if (!info.isDirectory()) {
|
|
236
|
-
throw new
|
|
236
|
+
throw new ManagedFileError2("FILE_NOT_REGULAR", "managed-file root must be a directory");
|
|
237
237
|
}
|
|
238
238
|
return canonical;
|
|
239
239
|
}
|
|
240
240
|
async function existingParent(root, target) {
|
|
241
241
|
const parent = await realpathOrNull(dirname(target), "failed to resolve managed-file parent directory");
|
|
242
242
|
if (parent === null) {
|
|
243
|
-
throw new
|
|
243
|
+
throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file parent directory not found");
|
|
244
244
|
}
|
|
245
|
-
if (!
|
|
246
|
-
throw new
|
|
245
|
+
if (!isWithinDir2(root, parent)) {
|
|
246
|
+
throw new ManagedFileError2("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
|
|
247
247
|
}
|
|
248
248
|
const info = await stat(parent).catch((error) => {
|
|
249
249
|
throw ioError("failed to inspect managed-file parent directory", error);
|
|
250
250
|
});
|
|
251
251
|
if (!info.isDirectory()) {
|
|
252
|
-
throw new
|
|
252
|
+
throw new ManagedFileError2("FILE_NOT_REGULAR", "managed-file parent is not a directory");
|
|
253
253
|
}
|
|
254
254
|
return parent;
|
|
255
255
|
}
|
|
256
|
-
async function
|
|
256
|
+
async function createManagedFileBoundary2(config) {
|
|
257
257
|
const root = await bindRoot(config);
|
|
258
258
|
const maxReadBytes = positiveLimit(config.maxReadBytes, DEFAULT_MAX_BYTES, "maxReadBytes");
|
|
259
259
|
const maxWriteBytes = positiveLimit(config.maxWriteBytes, DEFAULT_MAX_BYTES, "maxWriteBytes");
|
|
@@ -262,8 +262,8 @@ async function createManagedFileBoundary(config) {
|
|
|
262
262
|
const targetFor = (path) => {
|
|
263
263
|
const relative = filePath(path);
|
|
264
264
|
const target = resolve(root, ...relative.split("/"));
|
|
265
|
-
if (!
|
|
266
|
-
throw new
|
|
265
|
+
if (!isWithinDir2(root, target)) {
|
|
266
|
+
throw new ManagedFileError2("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
|
|
267
267
|
}
|
|
268
268
|
return { path: relative, target };
|
|
269
269
|
};
|
|
@@ -273,10 +273,10 @@ async function createManagedFileBoundary(config) {
|
|
|
273
273
|
options.signal?.throwIfAborted();
|
|
274
274
|
const realTarget = await realpathOrNull(resolved.target, "failed to resolve managed file");
|
|
275
275
|
if (realTarget === null) {
|
|
276
|
-
throw new
|
|
276
|
+
throw new ManagedFileError2("FILE_NOT_FOUND", "managed file not found");
|
|
277
277
|
}
|
|
278
|
-
if (!
|
|
279
|
-
throw new
|
|
278
|
+
if (!isWithinDir2(root, realTarget)) {
|
|
279
|
+
throw new ManagedFileError2("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
|
|
280
280
|
}
|
|
281
281
|
const maxBytes = positiveLimit(options.maxBytes, maxReadBytes, "maxBytes");
|
|
282
282
|
let handle;
|
|
@@ -284,7 +284,7 @@ async function createManagedFileBoundary(config) {
|
|
|
284
284
|
handle = await open(realTarget, constants.O_RDONLY | noFollow());
|
|
285
285
|
const info = await handle.stat();
|
|
286
286
|
if (!info.isFile()) {
|
|
287
|
-
throw new
|
|
287
|
+
throw new ManagedFileError2("FILE_NOT_REGULAR", "managed path is not a regular file");
|
|
288
288
|
}
|
|
289
289
|
const bytes = await readHandle(handle, maxBytes, options.signal);
|
|
290
290
|
const inspection = await inspectFile(config.inspect, {
|
|
@@ -299,7 +299,7 @@ async function createManagedFileBoundary(config) {
|
|
|
299
299
|
if (options.signal?.aborted && error === options.signal.reason)
|
|
300
300
|
throw error;
|
|
301
301
|
if (errorCode(error) === "ENOENT") {
|
|
302
|
-
throw new
|
|
302
|
+
throw new ManagedFileError2("FILE_NOT_FOUND", "managed file not found");
|
|
303
303
|
}
|
|
304
304
|
throw ioError("failed to read managed file", error);
|
|
305
305
|
} finally {
|
|
@@ -340,7 +340,7 @@ async function createManagedFileBoundary(config) {
|
|
|
340
340
|
committed = true;
|
|
341
341
|
} catch (error) {
|
|
342
342
|
if (errorCode(error) === "EEXIST") {
|
|
343
|
-
throw new
|
|
343
|
+
throw new ManagedFileError2("FILE_EXISTS", "managed file already exists");
|
|
344
344
|
}
|
|
345
345
|
throw error;
|
|
346
346
|
}
|
|
@@ -368,4 +368,4 @@ async function createManagedFileBoundary(config) {
|
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
export {
|
|
371
|
+
export { ManagedFileError2, createManagedFileBoundary2 };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/internal/channel.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
var PositiveSafeIntegerSchema = z.number().int().positive().safe();
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
state:
|
|
8
|
-
policy:
|
|
4
|
+
var BoundedChannelPolicySchema2 = z.enum(["ordered", "latest"]);
|
|
5
|
+
var BoundedChannelStateSchema2 = z.enum(["open", "draining", "closed", "failed"]);
|
|
6
|
+
var BoundedChannelSnapshotSchema2 = z.object({
|
|
7
|
+
state: BoundedChannelStateSchema2,
|
|
8
|
+
policy: BoundedChannelPolicySchema2,
|
|
9
9
|
queuedItems: z.number().int().nonnegative(),
|
|
10
10
|
queuedBytes: z.number().int().nonnegative(),
|
|
11
11
|
waitingReader: z.boolean(),
|
|
@@ -17,14 +17,14 @@ var BoundedChannelSnapshotSchema = z.object({
|
|
|
17
17
|
discarded: z.number().int().nonnegative()
|
|
18
18
|
}).strict().readonly();
|
|
19
19
|
|
|
20
|
-
class
|
|
20
|
+
class BoundedChannelReaderError2 extends Error {
|
|
21
21
|
constructor() {
|
|
22
22
|
super("A bounded channel permits only one pending next() call");
|
|
23
23
|
this.name = "BoundedChannelReaderError";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
const policy =
|
|
26
|
+
function createBoundedChannel2(config) {
|
|
27
|
+
const policy = BoundedChannelPolicySchema2.parse(config.policy);
|
|
28
28
|
const maxItems = PositiveSafeIntegerSchema.parse(config.maxItems);
|
|
29
29
|
const maxBytes = PositiveSafeIntegerSchema.parse(config.maxBytes);
|
|
30
30
|
const queue = [];
|
|
@@ -42,7 +42,7 @@ function createBoundedChannel(config) {
|
|
|
42
42
|
const removeAbortListener = () => {
|
|
43
43
|
config.signal?.removeEventListener("abort", abortChannel);
|
|
44
44
|
};
|
|
45
|
-
const snapshot = () =>
|
|
45
|
+
const snapshot = () => BoundedChannelSnapshotSchema2.parse({
|
|
46
46
|
state,
|
|
47
47
|
policy,
|
|
48
48
|
queuedItems: queue.length,
|
|
@@ -154,7 +154,7 @@ function createBoundedChannel(config) {
|
|
|
154
154
|
return Promise.resolve({ done: true, value: undefined });
|
|
155
155
|
}
|
|
156
156
|
if (waiting)
|
|
157
|
-
return Promise.reject(new
|
|
157
|
+
return Promise.reject(new BoundedChannelReaderError2);
|
|
158
158
|
return new Promise((resolve, reject) => {
|
|
159
159
|
waiting = { resolve, reject };
|
|
160
160
|
});
|
|
@@ -189,7 +189,7 @@ function createBoundedChannel(config) {
|
|
|
189
189
|
config.signal?.addEventListener("abort", abortChannel, { once: true });
|
|
190
190
|
return channel;
|
|
191
191
|
}
|
|
192
|
-
var
|
|
192
|
+
var CreditWindowSnapshotSchema2 = z.object({
|
|
193
193
|
state: z.enum(["open", "closed"]),
|
|
194
194
|
capacityBytes: PositiveSafeIntegerSchema,
|
|
195
195
|
availableBytes: z.number().int().nonnegative(),
|
|
@@ -199,7 +199,7 @@ var CreditWindowSnapshotSchema = z.object({
|
|
|
199
199
|
replenishedBytes: z.number().int().nonnegative(),
|
|
200
200
|
waiting: z.number().int().nonnegative()
|
|
201
201
|
}).strict().readonly();
|
|
202
|
-
function
|
|
202
|
+
function createCreditWindow2(config) {
|
|
203
203
|
const capacityBytes = PositiveSafeIntegerSchema.parse(config.capacityBytes);
|
|
204
204
|
let availableBytes = capacityBytes;
|
|
205
205
|
let state = "open";
|
|
@@ -207,7 +207,7 @@ function createCreditWindow(config) {
|
|
|
207
207
|
let refused = 0;
|
|
208
208
|
let replenishedBytes = 0;
|
|
209
209
|
const waiters = new Set;
|
|
210
|
-
const snapshot = () =>
|
|
210
|
+
const snapshot = () => CreditWindowSnapshotSchema2.parse({
|
|
211
211
|
state,
|
|
212
212
|
capacityBytes,
|
|
213
213
|
availableBytes,
|
|
@@ -323,4 +323,4 @@ function createCreditWindow(config) {
|
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
export {
|
|
326
|
+
export { BoundedChannelPolicySchema2, BoundedChannelStateSchema2, BoundedChannelSnapshotSchema2, BoundedChannelReaderError2, createBoundedChannel2, CreditWindowSnapshotSchema2, createCreditWindow2 };
|