@r_masseater/masseater-utils 0.8.2 → 0.9.1

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.
Files changed (85) hide show
  1. package/README.md +46 -40
  2. package/dist/browser-test/vite.mjs +1 -29
  3. package/dist/browser-test-vite-DS3fTcyM.mjs +29 -0
  4. package/dist/browser-test-vite-DS3fTcyM.mjs.map +1 -0
  5. package/dist/button-980Op0uF.mjs +30 -0
  6. package/dist/button-980Op0uF.mjs.map +1 -0
  7. package/dist/desktop-shell/media-notes/protocol.d.mts +2 -0
  8. package/dist/desktop-shell/media-notes/protocol.mjs +1 -0
  9. package/dist/desktop-shell/media-notes.d.mts +125 -0
  10. package/dist/desktop-shell/media-notes.mjs +865 -0
  11. package/dist/desktop-shell/media-notes.mjs.map +1 -0
  12. package/dist/desktop-shell/release-cli.d.mts +1 -0
  13. package/dist/desktop-shell/release-cli.mjs +290 -0
  14. package/dist/desktop-shell/release-cli.mjs.map +1 -0
  15. package/dist/desktop-shell/telemetry.d.mts +5 -0
  16. package/dist/desktop-shell/telemetry.mjs +55 -0
  17. package/dist/desktop-shell/telemetry.mjs.map +1 -0
  18. package/dist/desktop-shell/vite.d.mts +24 -0
  19. package/dist/desktop-shell/vite.mjs +58 -0
  20. package/dist/desktop-shell/vite.mjs.map +1 -0
  21. package/dist/index-BtcxUsGh.d.mts +4 -0
  22. package/dist/index-CjUS4pmA.d.mts +59 -0
  23. package/dist/lapse.mjs +1 -1
  24. package/dist/media-protocol-CMyatw7A.mjs +32 -0
  25. package/dist/media-protocol-CMyatw7A.mjs.map +1 -0
  26. package/dist/node-main-Bwril94o.mjs +19 -0
  27. package/dist/node-main-Bwril94o.mjs.map +1 -0
  28. package/dist/node-main.mjs +1 -18
  29. package/dist/plugin-kit.mjs +22 -22
  30. package/dist/plugin-kit.mjs.map +1 -1
  31. package/dist/security-headers.d.mts +2 -1
  32. package/dist/ui/button.d.mts +1 -1
  33. package/dist/ui/button.mjs +1 -30
  34. package/dist/ui/next-page-trigger.mjs +1 -1
  35. package/dist/ui/page-footer.d.mts +1 -1
  36. package/dist/ui/page-header.d.mts +1 -1
  37. package/dist/ui/table.d.mts +1 -1
  38. package/dist/ui/web-analytics.d.mts +1 -0
  39. package/dist/vitest-otlp/workers.mjs +1 -1
  40. package/dist/workers-tracing/alchemy.d.mts +1 -1
  41. package/native/desktop-shell/Cargo.toml +38 -0
  42. package/native/desktop-shell/src/app/builder.rs +39 -0
  43. package/native/desktop-shell/src/app/mod.rs +3 -0
  44. package/native/desktop-shell/src/entities/access_token.rs +77 -0
  45. package/native/desktop-shell/src/entities/mod.rs +1 -0
  46. package/native/desktop-shell/src/features/mod.rs +4 -0
  47. package/native/desktop-shell/src/features/record_telemetry/appender.rs +127 -0
  48. package/native/desktop-shell/src/features/record_telemetry/forwarder.rs +183 -0
  49. package/native/desktop-shell/src/features/record_telemetry/invoke.rs +80 -0
  50. package/native/desktop-shell/src/features/record_telemetry/mod.rs +231 -0
  51. package/native/desktop-shell/src/features/serve_screen/mod.rs +135 -0
  52. package/native/desktop-shell/src/features/serve_tools/mod.rs +37 -0
  53. package/native/desktop-shell/src/features/update_app/mod.rs +53 -0
  54. package/native/desktop-shell/src/lib.rs +17 -0
  55. package/native/desktop-shell/src/shared/lib/bearer.rs +49 -0
  56. package/native/desktop-shell/src/shared/lib/host.rs +1 -0
  57. package/native/desktop-shell/src/shared/lib/mod.rs +5 -0
  58. package/native/desktop-shell/src/shared/mod.rs +2 -0
  59. package/native/desktop-shell/src/shared/ui/log.rs +15 -0
  60. package/native/desktop-shell/src/shared/ui/menu.rs +37 -0
  61. package/native/desktop-shell/src/shared/ui/mod.rs +7 -0
  62. package/native/desktop-shell/src/shared/ui/window.rs +49 -0
  63. package/native/media-notes/Cargo.toml +36 -0
  64. package/native/media-notes/src/entities/media_file.rs +89 -0
  65. package/native/media-notes/src/entities/media_notes.rs +31 -0
  66. package/native/media-notes/src/entities/mod.rs +3 -0
  67. package/native/media-notes/src/entities/source/credit.rs +129 -0
  68. package/native/media-notes/src/entities/source/link.rs +194 -0
  69. package/native/media-notes/src/entities/source/mod.rs +5 -0
  70. package/native/media-notes/src/features/mod.rs +2 -0
  71. package/native/media-notes/src/features/open_media/mod.rs +88 -0
  72. package/native/media-notes/src/features/share_mcp_access.rs +15 -0
  73. package/native/media-notes/src/lib.rs +12 -0
  74. package/native/media-notes/src/shared/db/mod.rs +3 -0
  75. package/native/media-notes/src/shared/db/store.rs +276 -0
  76. package/native/media-notes/src/shared/lib/failure.rs +55 -0
  77. package/native/media-notes/src/shared/lib/mcp.rs +34 -0
  78. package/native/media-notes/src/shared/lib/mod.rs +5 -0
  79. package/native/media-notes/src/shared/mod.rs +3 -0
  80. package/native/media-notes/src/shared/protocol.rs +69 -0
  81. package/package.json +129 -56
  82. package/skills/build-tauri-app/SKILL.md +58 -0
  83. package/dist/browser-test/vite.mjs.map +0 -1
  84. package/dist/node-main.mjs.map +0 -1
  85. package/dist/ui/button.mjs.map +0 -1
@@ -0,0 +1,58 @@
1
+ import { t as browserTest } from "../browser-test-vite-DS3fTcyM.mjs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { Array, Option, pipe } from "effect";
4
+ import tailwindcss from "@tailwindcss/vite";
5
+ import viteReact from "@vitejs/plugin-react";
6
+ // src/app/desktop-tauri-vite.ts
7
+ const GENERATED = [
8
+ "!src-tauri/gen/**",
9
+ "!src-tauri/target/**",
10
+ "!src-tauri/permissions/**"
11
+ ];
12
+ const tauriAppTasks = () => ({ screen: { command: "vp build" } });
13
+ const tauriCargoTest = ({ crate, input }) => ({
14
+ command: `cargo test -p ${crate} --locked`,
15
+ cache: {
16
+ input: [...input, ...GENERATED],
17
+ output: []
18
+ }
19
+ });
20
+ const RELEASE_CLI = fileURLToPath(import.meta.resolve("@r_masseater/masseater-utils/desktop-shell/release-cli"));
21
+ const release = (command) => `node ${RELEASE_CLI} ${command}`;
22
+ const bundleCollect = (kinds) => release(Array.join(["bundle-collect", ...kinds], " "));
23
+ const WINDOWS_INSTALLER = `tauri build --config src-tauri/tauri.release.conf.json --bundles nsis && ${bundleCollect(["nsis"])}`;
24
+ const tauriReleaseTasks = () => ({
25
+ "release:windows": {
26
+ command: WINDOWS_INSTALLER,
27
+ cache: false
28
+ },
29
+ "release:publish": {
30
+ command: release("updater-feed"),
31
+ cache: false
32
+ },
33
+ "updater-key": {
34
+ command: release("updater-key"),
35
+ cache: false
36
+ }
37
+ });
38
+ const tauriAppConfig = ({ devPort, viewport }) => {
39
+ const base = {
40
+ plugins: [tailwindcss(), viteReact()],
41
+ clearScreen: false,
42
+ server: {
43
+ port: devPort,
44
+ strictPort: true,
45
+ watch: { ignored: ["**/src-tauri/**"] }
46
+ }
47
+ };
48
+ return pipe(viewport, Option.match({
49
+ onNone: () => base,
50
+ onSome: (size) => ({
51
+ ...base,
52
+ ...browserTest(size)
53
+ })
54
+ }));
55
+ };
56
+ export { bundleCollect, tauriAppConfig, tauriAppTasks, tauriCargoTest, tauriReleaseTasks };
57
+
58
+ //# sourceMappingURL=vite.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.mjs","names":["Arr"],"sources":["../../src/app/desktop-tauri-vite.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nimport tailwindcss from \"@tailwindcss/vite\";\nimport viteReact from \"@vitejs/plugin-react\";\nimport { Array as Arr, Option, pipe } from \"effect\";\nimport type { UserConfig } from \"vite-plus\";\n\nimport { browserTest } from \"#/app/browser-test-vite.ts\";\n\nexport type CargoInput =\n | { readonly pattern: string; readonly base: \"workspace\" }\n | { readonly auto: true };\n\nconst GENERATED = [\"!src-tauri/gen/**\", \"!src-tauri/target/**\", \"!src-tauri/permissions/**\"];\n\nexport const tauriAppTasks = (): NonNullable<NonNullable<UserConfig[\"run\"]>[\"tasks\"]> => ({\n screen: { command: \"vp build\" },\n});\n\nexport type Task = NonNullable<NonNullable<UserConfig[\"run\"]>[\"tasks\"]>[string];\n\nexport const tauriCargoTest = ({\n crate,\n input,\n}: Readonly<{ crate: string; input: readonly CargoInput[] }>): Task => ({\n command: `cargo test -p ${crate} --locked`,\n cache: { input: [...input, ...GENERATED], output: [] },\n});\n\nconst RELEASE_CLI = fileURLToPath(\n import.meta.resolve(\"@r_masseater/masseater-utils/desktop-shell/release-cli\"),\n);\n\nconst release = (command: string): string => `node ${RELEASE_CLI} ${command}`;\n\nexport const bundleCollect = (kinds: readonly string[]): string =>\n release(Arr.join([\"bundle-collect\", ...kinds], \" \"));\n\nconst WINDOWS_INSTALLER = `tauri build --config src-tauri/tauri.release.conf.json --bundles nsis && ${bundleCollect([\"nsis\"])}`;\n\nexport const tauriReleaseTasks = (): NonNullable<NonNullable<UserConfig[\"run\"]>[\"tasks\"]> => ({\n \"release:windows\": { command: WINDOWS_INSTALLER, cache: false },\n \"release:publish\": { command: release(\"updater-feed\"), cache: false },\n \"updater-key\": { command: release(\"updater-key\"), cache: false },\n});\n\nexport const tauriAppConfig = ({\n devPort,\n viewport,\n}: Readonly<{\n devPort: number;\n viewport: Option.Option<Readonly<{ width: number; height: number }>>;\n}>): UserConfig => {\n const base: UserConfig = {\n plugins: [tailwindcss(), viteReact()],\n clearScreen: false,\n server: { port: devPort, strictPort: true, watch: { ignored: [\"**/src-tauri/**\"] } },\n };\n return pipe(\n viewport,\n Option.match({\n onNone: () => base,\n onSome: (size) => ({ ...base, ...browserTest(size) }),\n }),\n );\n};\n"],"mappings":";;;;;;AAaA,MAAM,YAAY;CAAC;CAAqB;CAAwB;AAA2B;AAE3F,MAAa,uBAA6E,EACxF,QAAQ,EAAE,SAAS,WAAW,EAChC;AAIA,MAAa,kBAAkB,EAC7B,OACA,aACsE;CACtE,SAAS,iBAAiB,MAAM;CAChC,OAAO;EAAE,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS;EAAG,QAAQ,CAAC;CAAE;AACvD;AAEA,MAAM,cAAc,cAClB,YAAY,QAAQ,wDAAwD,CAC9E;AAEA,MAAM,WAAW,YAA4B,QAAQ,YAAY,GAAG;AAEpE,MAAa,iBAAiB,UAC5B,QAAQA,MAAI,KAAK,CAAC,kBAAkB,GAAG,KAAK,GAAG,GAAG,CAAC;AAErD,MAAM,oBAAoB,4EAA4E,cAAc,CAAC,MAAM,CAAC;AAE5H,MAAa,2BAAiF;CAC5F,mBAAmB;EAAE,SAAS;EAAmB,OAAO;CAAM;CAC9D,mBAAmB;EAAE,SAAS,QAAQ,cAAc;EAAG,OAAO;CAAM;CACpE,eAAe;EAAE,SAAS,QAAQ,aAAa;EAAG,OAAO;CAAM;AACjE;AAEA,MAAa,kBAAkB,EAC7B,SACA,eAIiB;CACjB,MAAM,OAAmB;EACvB,SAAS,CAAC,YAAY,GAAG,UAAU,CAAC;EACpC,aAAa;EACb,QAAQ;GAAE,MAAM;GAAS,YAAY;GAAM,OAAO,EAAE,SAAS,CAAC,iBAAiB,EAAE;EAAE;CACrF;CACA,OAAO,KACL,UACA,OAAO,MAAM;EACX,cAAc;EACd,SAAS,UAAU;GAAE,GAAG;GAAM,GAAG,YAAY,IAAI;EAAE;CACrD,CAAC,CACH;AACF"}
@@ -0,0 +1,4 @@
1
+ import { f as Site } from "./index-CjUS4pmA.mjs";
2
+ declare const SITE_NAMES: Readonly<Record<Site, string>>;
3
+ export { SITE_NAMES as t };
4
+ //# sourceMappingURL=index-BtcxUsGh.d.mts.map
@@ -0,0 +1,59 @@
1
+ import { Effect, Option, Schema } from "effect";
2
+ declare const SiteSchema: Schema.Literals<readonly ["youtube", "niconico", "soundcloud", "file"]>;
3
+ declare const SourceSchema: Schema.Struct<{
4
+ readonly site: Schema.Literals<readonly ["youtube", "niconico", "soundcloud", "file"]>;
5
+ readonly id: Schema.NonEmptyString;
6
+ }>;
7
+ declare const MediaSchema: Schema.Struct<{
8
+ readonly source: Schema.Struct<{
9
+ readonly site: Schema.Literals<readonly ["youtube", "niconico", "soundcloud", "file"]>;
10
+ readonly id: Schema.NonEmptyString;
11
+ }>;
12
+ readonly title: Schema.String;
13
+ readonly artist: Schema.String;
14
+ }>;
15
+ declare const OpenedSchema: Schema.Struct<{
16
+ readonly media: Schema.Struct<{
17
+ readonly source: Schema.Struct<{
18
+ readonly site: Schema.Literals<readonly ["youtube", "niconico", "soundcloud", "file"]>;
19
+ readonly id: Schema.NonEmptyString;
20
+ }>;
21
+ readonly title: Schema.String;
22
+ readonly artist: Schema.String;
23
+ }>;
24
+ readonly location: Schema.String;
25
+ }>;
26
+ declare const SavedSchema: Schema.Struct<{
27
+ readonly id: Schema.String;
28
+ readonly at: Schema.Int;
29
+ }>;
30
+ declare const McpAccessSchema: Schema.Struct<{
31
+ readonly url: Schema.String;
32
+ readonly token: Schema.String;
33
+ }>;
34
+ type Site = typeof SiteSchema.Type;
35
+ type Source = typeof SourceSchema.Type;
36
+ type Media = typeof MediaSchema.Type;
37
+ type Opened = typeof OpenedSchema.Type;
38
+ type Saved = typeof SavedSchema.Type;
39
+ type McpAccess = typeof McpAccessSchema.Type;
40
+ declare const ApiFailed_base: Schema.Class<ApiFailed, Schema.TaggedStruct<"ApiFailed", {
41
+ readonly message: Schema.String;
42
+ }>, import("effect/Cause").YieldableError & {
43
+ readonly brand: unique symbol;
44
+ }>;
45
+ declare class ApiFailed extends ApiFailed_base {}
46
+ type Settled<Value> = Readonly<{
47
+ status: "ok";
48
+ data: Value;
49
+ }> | Readonly<{
50
+ status: "error";
51
+ error: Readonly<{
52
+ message: string;
53
+ }>;
54
+ }>;
55
+ declare const settled: <Value>(run: () => Promise<Settled<Value>>) => Effect.Effect<Value, ApiFailed>;
56
+ type Decode<Value> = (input: unknown) => Effect.Effect<Value, Schema.SchemaError>;
57
+ declare const settledAs: <Value>(decode: Decode<Value>) => (run: () => Promise<Settled<unknown>>) => Effect.Effect<Value, ApiFailed>;
58
+ export { McpAccessSchema as a, Opened as c, SavedSchema as d, Site as f, SourceSchema as h, McpAccess as i, OpenedSchema as l, Source as m, settledAs as n, Media as o, SiteSchema as p, ApiFailed as r, MediaSchema as s, settled as t, Saved as u };
59
+ //# sourceMappingURL=index-CjUS4pmA.d.mts.map
package/dist/lapse.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { Config, Effect, Option, Predicate } from "effect";
2
1
  import { fileURLToPath } from "node:url";
2
+ import { Config, Effect, Option, Predicate } from "effect";
3
3
  // src/app/lapse-config.ts
4
4
  const SDK = fileURLToPath(import.meta.resolve("@r_masseater/masseater-utils/lapse/sdk"));
5
5
  const OTEL_ENV = ["OTEL_*"];
@@ -0,0 +1,32 @@
1
+ import { Schema } from "effect";
2
+ // src/shared/api/media-notes/media-protocol.ts
3
+ const SiteSchema = Schema.Literals([
4
+ "youtube",
5
+ "niconico",
6
+ "soundcloud",
7
+ "file"
8
+ ]).annotate({ identifier: "Site" });
9
+ const SourceSchema = Schema.Struct({
10
+ site: SiteSchema,
11
+ id: Schema.NonEmptyString
12
+ }).annotate({ identifier: "Source" });
13
+ const MediaSchema = Schema.Struct({
14
+ source: SourceSchema,
15
+ title: Schema.String,
16
+ artist: Schema.String
17
+ }).annotate({ identifier: "Media" });
18
+ const OpenedSchema = Schema.Struct({
19
+ media: MediaSchema,
20
+ location: Schema.String
21
+ }).annotate({ identifier: "Opened" });
22
+ const SavedSchema = Schema.Struct({
23
+ id: Schema.String,
24
+ at: Schema.Int
25
+ }).annotate({ identifier: "Saved" });
26
+ const McpAccessSchema = Schema.Struct({
27
+ url: Schema.String,
28
+ token: Schema.String
29
+ }).annotate({ identifier: "McpAccess" });
30
+ export { SiteSchema as a, SavedSchema as i, MediaSchema as n, SourceSchema as o, OpenedSchema as r, McpAccessSchema as t };
31
+
32
+ //# sourceMappingURL=media-protocol-CMyatw7A.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-protocol-CMyatw7A.mjs","names":[],"sources":["../src/shared/api/media-notes/media-protocol.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport const SiteSchema = Schema.Literals([\"youtube\", \"niconico\", \"soundcloud\", \"file\"]).annotate({\n identifier: \"Site\",\n});\n\nexport const SourceSchema = Schema.Struct({ site: SiteSchema, id: Schema.NonEmptyString }).annotate(\n { identifier: \"Source\" },\n);\n\nexport const MediaSchema = Schema.Struct({\n source: SourceSchema,\n title: Schema.String,\n artist: Schema.String,\n}).annotate({ identifier: \"Media\" });\n\nexport const OpenedSchema = Schema.Struct({\n media: MediaSchema,\n location: Schema.String,\n}).annotate({ identifier: \"Opened\" });\n\nexport const SavedSchema = Schema.Struct({ id: Schema.String, at: Schema.Int }).annotate({\n identifier: \"Saved\",\n});\n\nexport const McpAccessSchema = Schema.Struct({ url: Schema.String, token: Schema.String }).annotate(\n { identifier: \"McpAccess\" },\n);\n\nexport type Site = typeof SiteSchema.Type;\n\nexport type Source = typeof SourceSchema.Type;\n\nexport type Media = typeof MediaSchema.Type;\n\nexport type Opened = typeof OpenedSchema.Type;\n\nexport type Saved = typeof SavedSchema.Type;\n\nexport type McpAccess = typeof McpAccessSchema.Type;\n"],"mappings":";;AAEA,MAAa,aAAa,OAAO,SAAS;CAAC;CAAW;CAAY;CAAc;AAAM,CAAC,CAAC,CAAC,SAAS,EAChG,YAAY,OACd,CAAC;AAED,MAAa,eAAe,OAAO,OAAO;CAAE,MAAM;CAAY,IAAI,OAAO;AAAe,CAAC,CAAC,CAAC,SACzF,EAAE,YAAY,SAAS,CACzB;AAEA,MAAa,cAAc,OAAO,OAAO;CACvC,QAAQ;CACR,OAAO,OAAO;CACd,QAAQ,OAAO;AACjB,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,QAAQ,CAAC;AAEnC,MAAa,eAAe,OAAO,OAAO;CACxC,OAAO;CACP,UAAU,OAAO;AACnB,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,SAAS,CAAC;AAEpC,MAAa,cAAc,OAAO,OAAO;CAAE,IAAI,OAAO;CAAQ,IAAI,OAAO;AAAI,CAAC,CAAC,CAAC,SAAS,EACvF,YAAY,QACd,CAAC;AAED,MAAa,kBAAkB,OAAO,OAAO;CAAE,KAAK,OAAO;CAAQ,OAAO,OAAO;AAAO,CAAC,CAAC,CAAC,SACzF,EAAE,YAAY,YAAY,CAC5B"}
@@ -0,0 +1,19 @@
1
+ import { Duration, Effect, Option, Schedule, pipe } from "effect";
2
+ // src/features/watch-parent/model/parent-process.ts
3
+ const PARENT_CHECK_INTERVAL = Duration.fromInputUnsafe("2 seconds");
4
+ const SIGNAL_PROBE = 0;
5
+ const isAlive = (pid) => {
6
+ try {
7
+ return globalThis.process.kill(pid, SIGNAL_PROBE);
8
+ } catch {
9
+ return false;
10
+ }
11
+ };
12
+ const untilExits = (pid) => Effect.sync(() => isAlive(pid)).pipe(Effect.repeat({
13
+ schedule: Schedule.spaced(PARENT_CHECK_INTERVAL),
14
+ while: (alive) => alive
15
+ }), Effect.asVoid);
16
+ const whileParentAlive = (parentPid) => (program) => Effect.raceFirst(Effect.asVoid(program), pipe(parentPid, Option.map((pid) => untilExits(globalThis.Number(pid))), Option.getOrElse(() => Effect.never)));
17
+ export { whileParentAlive as t };
18
+
19
+ //# sourceMappingURL=node-main-Bwril94o.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-main-Bwril94o.mjs","names":[],"sources":["../src/features/watch-parent/model/parent-process.ts"],"sourcesContent":["import { Duration, Effect, Option, Schedule, pipe } from \"effect\";\n\nconst PARENT_CHECK_INTERVAL = Duration.fromInputUnsafe(\"2 seconds\");\nconst SIGNAL_PROBE = 0;\n\nconst isAlive = (pid: number): boolean => {\n try {\n return globalThis.process.kill(pid, SIGNAL_PROBE);\n } catch {\n return false;\n }\n};\n\nconst untilExits = (pid: number): Effect.Effect<void> =>\n Effect.sync(() => isAlive(pid)).pipe(\n Effect.repeat({ schedule: Schedule.spaced(PARENT_CHECK_INTERVAL), while: (alive) => alive }),\n Effect.asVoid,\n );\n\nexport const whileParentAlive =\n (parentPid: Option.Option<string>) =>\n <Value, Failure, Requirements>(\n program: Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<void, Failure, Requirements> =>\n Effect.raceFirst(\n Effect.asVoid(program),\n pipe(\n parentPid,\n Option.map((pid) => untilExits(globalThis.Number(pid))),\n Option.getOrElse(() => Effect.never),\n ),\n );\n"],"mappings":";;AAEA,MAAM,wBAAwB,SAAS,gBAAgB,WAAW;AAClE,MAAM,eAAe;AAErB,MAAM,WAAW,QAAyB;CACxC,IAAI;EACF,OAAO,WAAW,QAAQ,KAAK,KAAK,YAAY;CAClD,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,cAAc,QAClB,OAAO,WAAW,QAAQ,GAAG,CAAC,CAAC,CAAC,KAC9B,OAAO,OAAO;CAAE,UAAU,SAAS,OAAO,qBAAqB;CAAG,QAAQ,UAAU;AAAM,CAAC,GAC3F,OAAO,MACT;AAEF,MAAa,oBACV,eAEC,YAEA,OAAO,UACL,OAAO,OAAO,OAAO,GACrB,KACE,WACA,OAAO,KAAK,QAAQ,WAAW,WAAW,OAAO,GAAG,CAAC,CAAC,GACtD,OAAO,gBAAgB,OAAO,KAAK,CACrC,CACF"}
@@ -1,20 +1,3 @@
1
+ import { t as whileParentAlive } from "./node-main-Bwril94o.mjs";
1
2
  import { n as runMainWith, t as runMain } from "./run-main-BD4uT8sr.mjs";
2
- import { Duration, Effect, Option, Schedule, pipe } from "effect";
3
- // src/features/watch-parent/model/parent-process.ts
4
- const PARENT_CHECK_INTERVAL = Duration.fromInputUnsafe("2 seconds");
5
- const SIGNAL_PROBE = 0;
6
- const isAlive = (pid) => {
7
- try {
8
- return globalThis.process.kill(pid, SIGNAL_PROBE);
9
- } catch {
10
- return false;
11
- }
12
- };
13
- const untilExits = (pid) => Effect.sync(() => isAlive(pid)).pipe(Effect.repeat({
14
- schedule: Schedule.spaced(PARENT_CHECK_INTERVAL),
15
- while: (alive) => alive
16
- }), Effect.asVoid);
17
- const whileParentAlive = (parentPid) => (program) => Effect.raceFirst(Effect.asVoid(program), pipe(parentPid, Option.map((pid) => untilExits(globalThis.Number(pid))), Option.getOrElse(() => Effect.never)));
18
3
  export { runMain, runMainWith, whileParentAlive };
19
-
20
- //# sourceMappingURL=node-main.mjs.map
@@ -1,31 +1,11 @@
1
1
  import { n as runMainWith } from "./run-main-BD4uT8sr.mjs";
2
2
  import { Array, Cause, Config, Effect, FileSystem, Layer, Number as Number$1, Option, Path, Predicate, Record, Result, Runtime, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
3
3
  import { Record as Record$1, String as String$2, Unknown, decodeOption, fromJsonString, is } from "effect/Schema";
4
- // src/shared/lib/cache.ts
5
- const taggedError$2 = Schema.TaggedError;
6
- var CacheRootError = class extends taggedError$2()("CacheRootError", { message: Schema.String }) {};
7
- const SEPARATOR = "/";
8
- const CACHE_DIRECTORY_NAME = ".cache";
9
- const variable = (name) => Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));
10
- const baseDirectory = Effect.gen(function* baseDirectory() {
11
- const cacheHome = yield* variable("XDG_CACHE_HOME");
12
- const home = yield* variable("HOME");
13
- const profile = yield* variable("USERPROFILE");
14
- return pipe(cacheHome, Option.orElse(() => pipe(Option.orElse(home, () => profile), Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`))));
15
- });
16
- const cacheRootEffect = (segments) => baseDirectory.pipe(Effect.flatMap(Option.match({
17
- onNone: () => Effect.fail(CacheRootError.make({ message: "set XDG_CACHE_HOME or HOME" })),
18
- onSome: (base) => Effect.succeed(pipe([base, ...segments], Array.join(SEPARATOR)))
19
- })));
20
- const cacheRootOf = (segments) => Effect.runPromise(cacheRootEffect(segments));
21
- // src/shared/lib/record.ts
22
- const isRecord = is(Record$1(String$2, Unknown));
23
- const parseJson = (text) => decodeOption(fromJsonString(Unknown))(text);
24
4
  // src/features/run-main/model/hook-io.ts
25
5
  const EXIT_BLOCKING = 2;
26
- const taggedError$1 = Schema.TaggedError;
6
+ const taggedError$2 = Schema.TaggedError;
27
7
  /** @internal */
28
- var HookBlocked = class extends taggedError$1()("HookBlocked", { reason: Schema.String }) {
8
+ var HookBlocked = class extends taggedError$2()("HookBlocked", { reason: Schema.String }) {
29
9
  [Runtime.errorExitCode] = EXIT_BLOCKING;
30
10
  [Runtime.errorReported] = false;
31
11
  };
@@ -73,6 +53,26 @@ const runHook = (serviceName) => runHookWith({
73
53
  serviceName,
74
54
  services: Layer.empty
75
55
  });
56
+ // src/shared/lib/cache.ts
57
+ const taggedError$1 = Schema.TaggedError;
58
+ var CacheRootError = class extends taggedError$1()("CacheRootError", { message: Schema.String }) {};
59
+ const SEPARATOR = "/";
60
+ const CACHE_DIRECTORY_NAME = ".cache";
61
+ const variable = (name) => Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));
62
+ const baseDirectory = Effect.gen(function* baseDirectory() {
63
+ const cacheHome = yield* variable("XDG_CACHE_HOME");
64
+ const home = yield* variable("HOME");
65
+ const profile = yield* variable("USERPROFILE");
66
+ return pipe(cacheHome, Option.orElse(() => pipe(Option.orElse(home, () => profile), Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`))));
67
+ });
68
+ const cacheRootEffect = (segments) => baseDirectory.pipe(Effect.flatMap(Option.match({
69
+ onNone: () => Effect.fail(CacheRootError.make({ message: "set XDG_CACHE_HOME or HOME" })),
70
+ onSome: (base) => Effect.succeed(pipe([base, ...segments], Array.join(SEPARATOR)))
71
+ })));
72
+ const cacheRootOf = (segments) => Effect.runPromise(cacheRootEffect(segments));
73
+ // src/shared/lib/record.ts
74
+ const isRecord = is(Record$1(String$2, Unknown));
75
+ const parseJson = (text) => decodeOption(fromJsonString(Unknown))(text);
76
76
  // src/features/fit-history/model/calls.ts
77
77
  const FIRST = 0;
78
78
  const ONE$3 = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-kit.mjs","names":["taggedError","Arr","RecordSchema","StringSchema","taggedError","ONE","encodeJson","Str","Arr","Rec","ONE","Str","Arr","Num","ONE","Arr","Num","Str","Arr","Rec","Arr","Str","Rec","Arr"],"sources":["../src/shared/lib/cache.ts","../src/shared/lib/record.ts","../src/features/run-main/model/hook-io.ts","../src/features/run-main/model/run-hook.ts","../src/features/fit-history/model/calls.ts","../src/shared/lib/tokens.ts","../src/features/fit-history/model/fitting.ts","../src/features/fit-history/model/state.ts","../src/shared/lib/installed-plugins.ts","../src/shared/lib/jev-backend.ts"],"sourcesContent":["import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n\nexport const cacheRootOf = (segments: readonly string[]): Promise<string> =>\n Effect.runPromise(cacheRootEffect(segments));\n","import type { Option } from \"effect/Option\";\nimport {\n Record as RecordSchema,\n String as StringSchema,\n Unknown,\n decodeOption,\n fromJsonString,\n is,\n} from \"effect/Schema\";\n\nexport const isRecord = is(RecordSchema(StringSchema, Unknown));\n\nexport const parseJson = (text: string): Option<unknown> =>\n decodeOption(fromJsonString(Unknown))(text);\n","import { Effect, Runtime, Schema, Stdio, Stream } from \"effect\";\n\nconst EXIT_BLOCKING = 2;\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class HookBlocked extends taggedError<HookBlocked, { readonly brand: unique symbol }>()(\n \"HookBlocked\",\n { reason: Schema.String },\n) {\n public override readonly [Runtime.errorExitCode] = EXIT_BLOCKING;\n public override readonly [Runtime.errorReported] = false;\n}\n\n/** @internal */\nexport const isHookBlocked = Schema.is(HookBlocked);\n\n/** @internal */\nexport const blockHook = (reason: string): Effect.Effect<never, HookBlocked> =>\n Effect.fail(HookBlocked.make({ reason }));\n\n/** @internal */\nexport const readStdin: Effect.Effect<string, never, Stdio.Stdio> = Effect.gen(\n function* readStdin() {\n const stdio = yield* Stdio.Stdio;\n return yield* stdio.stdin.pipe(Stream.decodeText, Stream.mkString, Effect.orDie);\n },\n);\n\n/** @internal */\nexport const readHookInput = <Codec extends Schema.Top>(\n schema: Codec,\n): Effect.Effect<Codec[\"Type\"], Schema.SchemaError, Stdio.Stdio | Codec[\"DecodingServices\"]> =>\n Effect.gen(function* read() {\n const text = yield* readStdin;\n const json = Schema.fromJsonString(schema);\n return yield* Schema.decodeEffect(json)(text);\n });\n\n/** @internal */\nexport const writeStdout = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStdout() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeStderr = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStderr() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeHookOutput =\n <Codec extends Schema.Top>(schema: Codec) =>\n (value: Codec[\"Type\"]): Effect.Effect<void, never, Stdio.Stdio | Codec[\"EncodingServices\"]> =>\n Schema.encodeEffect(Schema.fromJsonString(schema))(value).pipe(\n Effect.orDie,\n Effect.flatMap(writeStdout),\n );\n","import { Cause, Effect, Layer, Option } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { isHookBlocked, writeStderr } from \"./hook-io.ts\";\nimport type { HookBlocked } from \"./hook-io.ts\";\nimport { runMainWith } from \"./run-main.ts\";\nimport type { Platform, Run } from \"./run-main.ts\";\n\nconst blockedIn = <Failure>(cause: Cause.Cause<Failure>): Option.Option<HookBlocked> =>\n Cause.findErrorOption(cause).pipe(\n Option.filter((error): error is Failure & HookBlocked => isHookBlocked(error)),\n );\n\nconst reportBlocked = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Option.match(blockedIn(cause), {\n onNone: () => Effect.void,\n onSome: (blocked) => writeStderr(`${blocked.reason}\\n`),\n });\n\n/** @internal */\nexport const runHookWith =\n <Provided, LayerFailure>({\n serviceName,\n services,\n }: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>): Run<Provided> =>\n (program) => {\n runMainWith({ serviceName, services })(program.pipe(Effect.tapCause(reportBlocked)));\n };\n\n/** @internal */\nexport const runHook = (serviceName: string): Run<never> =>\n runHookWith({ serviceName, services: Layer.empty });\n","import { Array as Arr, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport type { HistoryEntry, HistoryToolCall, Message, ToolCall } from \"./types.ts\";\n\nconst FIRST = 0;\nconst ONE = 1;\nconst ELLIPSIS = \"…\";\nconst VALUE_CHARS = 200;\nconst COMPACT_INPUT_CHARS = 60;\nconst SPACES = /\\s+/gu;\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const jsonOf = (value: unknown): Option.Option<string> => encodeJson(value);\n\nexport const truncate = (text: string, limit: number): string => {\n if (Str.length(text) <= limit) {\n return text;\n }\n return `${Str.slice(FIRST, Math.max(FIRST, limit - ONE))(text)}${ELLIPSIS}`;\n};\n\nexport const isPinned = (index: number, total: number, preserveRecentMessages: number): boolean =>\n index === FIRST || index >= total - preserveRecentMessages;\n\ninterface Found {\n readonly index: number;\n readonly chars: number;\n readonly isError: boolean;\n}\n\nconst resultsOf = (messages: readonly Message[]): ReadonlyMap<string, Found> =>\n new Map(\n pipe(\n messages,\n Arr.flatMap((message, index) =>\n pipe(\n message.toolResults,\n Arr.map(\n (result) =>\n [\n result.tool_use_id,\n { index, chars: Str.length(result.text), isError: result.isError },\n ] as const,\n ),\n ),\n ),\n ),\n );\n\nexport const collectToolCalls = (\n messages: readonly Message[],\n preserveRecentMessages: number,\n): readonly ToolCall[] => {\n const results = resultsOf(messages);\n const pinned = (index: number): boolean =>\n isPinned(index, messages.length, preserveRecentMessages);\n return pipe(\n messages,\n Arr.flatMap((message, callIndex) =>\n pipe(\n message.toolUses,\n Arr.flatMap((tool) =>\n pipe(\n Option.fromUndefinedOr(results.get(tool.tool_use_id)),\n Option.map((found) => ({ tool, callIndex, found })),\n Option.toArray,\n ),\n ),\n ),\n ),\n Arr.map(({ tool, callIndex, found }, index) => ({\n id: `t${String(index + ONE)}`,\n tool_use_id: tool.tool_use_id,\n tool: tool.tool,\n input: tool.input,\n callIndex,\n resultIndex: found.index,\n resultChars: found.chars,\n isError: found.isError,\n pinned: pinned(callIndex) || pinned(found.index),\n })),\n );\n};\n\nexport const inputText = (input: Readonly<Record<string, unknown>>, limit: number): string =>\n truncate(\n Option.getOrElse(jsonOf(input), () => \"[unserializable input]\"),\n limit,\n );\n\nconst outcomeOf = (call: ToolCall): string => {\n if (call.isError) {\n return \"error\";\n }\n return \"ok\";\n};\n\nconst resultNote = (call: ToolCall): string =>\n `${outcomeOf(call)}, ${String(call.resultChars)} chars (omitted)`;\n\nconst valueText = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, (raw): raw is string => typeof raw === \"string\"),\n Option.getOrElse(() => inputText({ [key]: value }, VALUE_CHARS)),\n );\n return `${key}=${Str.replaceAll(SPACES, \" \")(text)}`;\n};\n\nexport const compactCall = (call: ToolCall): string => {\n const input = pipe(Rec.toEntries(call.input), Arr.map(valueText), Arr.join(\" \"));\n return `${call.id} ${call.tool} ${truncate(input, COMPACT_INPUT_CHARS)} → ${outcomeOf(call)} ${String(call.resultChars)}ch`;\n};\n\nexport const callsByMessage = (\n calls: readonly ToolCall[],\n): ReadonlyMap<number, readonly ToolCall[]> =>\n new Map(\n pipe(\n calls,\n Arr.groupBy((call) => String(call.callIndex)),\n Rec.toEntries,\n Arr.map(([index, own]) => [Number(index), own] as const),\n ),\n );\n\nconst historyCallOf =\n (inputChars: number) =>\n (call: ToolCall): HistoryToolCall => ({\n id: call.id,\n tool: call.tool,\n input: inputText(call.input, inputChars),\n result: resultNote(call),\n });\n\nexport const historyEntries = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n inputChars: number,\n): readonly HistoryEntry[] => {\n const byMessage = callsByMessage(calls);\n return pipe(\n messages,\n Arr.flatMap((message, index): readonly HistoryEntry[] => {\n const own = Option.getOrElse(Option.fromUndefinedOr(byMessage.get(index)), () => []);\n const toolCalls = pipe(own, Arr.map(historyCallOf(inputChars)));\n const entry = { index, role: message.role, text: message.text };\n if (Arr.isReadonlyArrayNonEmpty(toolCalls)) {\n return [{ ...entry, tool_calls: toolCalls }];\n }\n if (Str.isEmpty(Str.trim(message.text))) {\n return [];\n }\n return [entry];\n }),\n );\n};\n","import { Array as Arr, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nconst PIECES = /(?<alpha>[A-Za-z]+)|(?<digits>\\d+)|(?<other>[^\\sA-Za-z\\d])/gu;\nconst DIGITS_PER_TOKEN = 2;\nconst LETTERS_PER_TOKEN = 6;\nconst SYMBOL_TOKENS = 0.9;\nconst ONE = 1;\n\nconst groupOf = (match: RegExpMatchArray, key: string): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[key])),\n );\n\nconst pieceTokens = (match: RegExpMatchArray): number =>\n pipe(\n groupOf(match, \"digits\"),\n Option.map((digits) => Str.length(digits) / DIGITS_PER_TOKEN),\n Option.orElse(() =>\n Option.map(\n groupOf(match, \"alpha\"),\n (alpha) => ONE + Math.floor((Str.length(alpha) - ONE) / LETTERS_PER_TOKEN),\n ),\n ),\n Option.getOrElse(() => SYMBOL_TOKENS),\n );\n\nconst matchesOf = (pattern: RegExp, text: string): readonly RegExpMatchArray[] =>\n Arr.fromIterable(Str.matchAll(pattern)(text));\n\nexport const estimateTokens = (text: string): number => {\n const pieces = pipe(matchesOf(PIECES, text), Arr.map(pieceTokens));\n return Math.ceil(Num.sumAll(pieces));\n};\n","import { Array as Arr, Number as Num, Option, pipe } from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { isPinned, jsonOf } from \"./calls.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nconst ONE = 1;\nconst NONE = 0;\n\nexport const entryTokens = (entry: HistoryEntry): number =>\n estimateTokens(Option.getOrElse(jsonOf(entry), () => \"\")) + ONE;\n\nexport interface Fitting {\n readonly history: readonly Option.Option<HistoryEntry>[];\n readonly perEntry: readonly number[];\n readonly tokens: number;\n}\n\nexport interface Plan {\n readonly messages: readonly Message[];\n readonly calls: readonly ToolCall[];\n readonly options: FitOptions;\n readonly stateOf: (history: readonly HistoryEntry[]) => CompactionState;\n readonly baseTokens: number;\n readonly byMessage: ReadonlyMap<number, readonly ToolCall[]>;\n}\n\nexport type Change = (entry: HistoryEntry) => Option.Option<Option.Option<HistoryEntry>>;\n\nexport const fittingOf = (plan: Plan, history: readonly HistoryEntry[]): Fitting => {\n const perEntry = pipe(history, Arr.map(entryTokens));\n return {\n history: pipe(history, Arr.map(Option.some)),\n perEntry,\n tokens: plan.baseTokens + Num.sumAll(perEntry),\n };\n};\n\nexport const kept = (fitting: Fitting): readonly HistoryEntry[] => Arr.getSomes(fitting.history);\n\nexport const fits = (plan: Plan, fitting: Fitting): boolean =>\n fitting.tokens <= plan.options.maxStateTokens;\n\nexport const fitted = (plan: Plan, fitting: Fitting, stage: string): FittedState => ({\n state: plan.stateOf(kept(fitting)),\n tokens: fitting.tokens,\n stage,\n});\n\nexport const pinnedEntry = (plan: Plan, entry: HistoryEntry): boolean =>\n isPinned(entry.index, plan.messages.length, plan.options.preserveRecentMessages);\n\nconst orderOf = (plan: Plan, fitting: Fitting): readonly number[] => {\n const present = pipe(\n fitting.history,\n Arr.flatMap((entry, index) =>\n pipe(\n entry,\n Option.map((value) => [index, pinnedEntry(plan, value)] as const),\n Option.toArray,\n ),\n ),\n );\n const loose = pipe(\n present,\n Arr.filter(([, pinned]) => !pinned),\n );\n const pinned = pipe(\n present,\n Arr.filter(([, isPinnedEntry]) => isPinnedEntry),\n );\n return pipe(\n [...loose, ...pinned],\n Arr.map(([index]) => index),\n );\n};\n\ninterface Step {\n readonly index: number;\n readonly entry: Option.Option<HistoryEntry>;\n readonly tokens: number;\n}\n\nconst stepOf =\n (fitting: Fitting, change: Change) =>\n (index: number): Option.Option<Step> =>\n pipe(\n Option.flatten(Option.fromUndefinedOr(fitting.history[index])),\n Option.flatMap(change),\n Option.map((entry) => ({\n index,\n entry,\n tokens: Option.match(entry, { onNone: () => NONE, onSome: entryTokens }),\n })),\n );\n\nconst applied = (fitting: Fitting, steps: readonly Step[]): Fitting => {\n const byIndex = new Map(\n pipe(\n steps,\n Arr.map((step) => [step.index, step] as const),\n ),\n );\n const pick = <Value>(index: number, value: Value, of: (step: Step) => Value): Value =>\n Option.match(Option.fromUndefinedOr(byIndex.get(index)), { onNone: () => value, onSome: of });\n const history = pipe(\n fitting.history,\n Arr.map((entry, index) => pick(index, entry, (step) => step.entry)),\n );\n const perEntry = pipe(\n fitting.perEntry,\n Arr.map((tokens, index) => pick(index, tokens, (step) => step.tokens)),\n );\n const delta = Num.sumAll(\n pipe(\n steps,\n Arr.map(\n (step) => step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n ),\n );\n return { history, perEntry, tokens: fitting.tokens + delta };\n};\n\nexport const staged = (\n plan: Plan,\n fitting: Fitting,\n change: Change,\n): readonly [Fitting, boolean] => {\n const steps = pipe(\n orderOf(plan, fitting),\n Arr.flatMap((index) => Option.toArray(stepOf(fitting, change)(index))),\n );\n const totals = pipe(\n steps,\n Arr.scan(\n fitting.tokens,\n (tokens, step) =>\n tokens + step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n Arr.drop(ONE),\n );\n return Option.match(\n Arr.findFirstIndex(totals, (tokens) => tokens <= plan.options.maxStateTokens),\n {\n onNone: () => [applied(fitting, steps), false] as const,\n onSome: (at) => [applied(fitting, Arr.take(steps, at + ONE)), true] as const,\n },\n );\n};\n","import {\n Array as Arr,\n Effect,\n Option,\n Predicate,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { callsByMessage, compactCall, historyEntries, jsonOf, truncate } from \"./calls.ts\";\nimport { fits, fitted, fittingOf, kept, pinnedEntry, staged } from \"./fitting.ts\";\nimport type { Change, Fitting, Plan } from \"./fitting.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n HistoryToolCall,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nexport const STATE_CONTEXT =\n \"A coding assistant conversation is being compacted to free context. `history` is the whole conversation so far, oldest first; tool outputs are replaced by a short `result` note and long texts may be abridged. Each question asks whether one tool call, or the full output of that call, still needs to stay in the history verbatim. Whatever is not kept is deleted permanently, but the assistant can always re-run a tool or re-read a file.\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class HistoryTooLarge extends taggedError<\n HistoryTooLarge,\n { readonly brand: unique symbol }\n>()(\"HistoryTooLarge\", { reason: Schema.String }) {}\n\nconst FULL_INPUT_CHARS = 1000;\nconst SHORT_INPUT_CHARS = 200;\nconst SHORTEST_INPUT_CHARS = 60;\nconst SHORTER_INPUT_CHARS = [SHORT_INPUT_CHARS, SHORTEST_INPUT_CHARS] as const;\nconst TEXT_HEAD = 400;\nconst TEXT_TAIL = 150;\nconst ABRIDGE_MARGIN = 40;\nconst RECENT_GOALS = 3;\nconst GOAL_CHARS = 500;\nconst ONE = 1;\n\nconst abridge = (text: string): string => {\n const omitted = Str.length(text) - TEXT_HEAD - TEXT_TAIL;\n return `${Str.takeLeft(TEXT_HEAD)(text)}\\n[… ${String(omitted)} chars omitted …]\\n${Str.takeRight(TEXT_TAIL)(text)}`;\n};\n\nexport const goalFromMessages = (messages: readonly Message[]): string =>\n pipe(\n messages,\n Arr.filter(\n (message) =>\n message.role === \"user\" &&\n Str.isNonEmpty(Str.trim(message.text)) &&\n Arr.isReadonlyArrayEmpty(message.toolResults),\n ),\n Arr.takeRight(RECENT_GOALS),\n Arr.map((message) => truncate(message.text, GOAL_CHARS)),\n Arr.join(\"\\n\"),\n );\n\nconst abridgeText: Change = (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.some({ ...entry, text: abridge(entry.text) }),\n () => Str.length(entry.text) > TEXT_HEAD + TEXT_TAIL + ABRIDGE_MARGIN,\n );\n\nconst collapseText =\n (plan: Plan): Change =>\n (entry: HistoryEntry) => {\n const original = pipe(\n Arr.get(plan.messages, entry.index),\n Option.map((message) => Str.length(message.text)),\n Option.getOrElse(() => Str.length(entry.text)),\n );\n return Option.liftPredicate(\n Option.some({ ...entry, text: `[… ${String(original)} chars omitted …]` }),\n () => !pinnedEntry(plan, entry) && Str.isNonEmpty(entry.text),\n );\n };\n\nconst compactCalls =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n pipe(\n Option.fromUndefinedOr(plan.byMessage.get(entry.index)),\n Option.filter(() => !pinnedEntry(plan, entry)),\n Option.map((own) => Option.some({ ...entry, tool_calls: pipe(own, Arr.map(compactCall)) })),\n );\n\nconst leaveOut =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.none<HistoryEntry>(),\n () => !pinnedEntry(plan, entry) && Predicate.isUndefined(entry.tool_calls),\n );\n\nconst callsOf = (entry: HistoryEntry): readonly (HistoryToolCall | string)[] =>\n Option.getOrElse(Option.fromUndefinedOr(entry.tool_calls), () => []);\n\nconst stringCalls = (entry: HistoryEntry): readonly string[] =>\n pipe(callsOf(entry), Arr.filter(Predicate.isString));\n\nconst foldable = (plan: Plan, entry: HistoryEntry): boolean =>\n !pinnedEntry(plan, entry) &&\n Str.isEmpty(entry.text) &&\n pipe(Arr.head(callsOf(entry)), Option.exists(Predicate.isString));\n\nconst mergedRun = (group: Arr.NonEmptyReadonlyArray<HistoryEntry>): HistoryEntry => {\n const first = Arr.headNonEmpty(group);\n if (group.length === ONE) {\n return first;\n }\n return { ...first, tool_calls: pipe(group, Arr.flatMap(stringCalls)) };\n};\n\nconst mergeRuns = (plan: Plan, history: readonly HistoryEntry[]): readonly HistoryEntry[] => {\n if (!Arr.isReadonlyArrayNonEmpty(history)) {\n return [];\n }\n return pipe(\n Arr.groupWith(\n history,\n (left, right) => foldable(plan, left) && foldable(plan, right) && left.role === right.role,\n ),\n Arr.map(mergedRun),\n );\n};\n\ntype Stage = readonly [string, (fitting: Fitting) => readonly [Fitting, boolean]];\n\nconst rebuilt = (plan: Plan, inputChars: number) => (): readonly [Fitting, boolean] => {\n const fitting = fittingOf(plan, historyEntries(plan.messages, plan.calls, inputChars));\n return [fitting, fits(plan, fitting)];\n};\n\nconst stagesOf = (plan: Plan): readonly Stage[] => [\n ...pipe(\n SHORTER_INPUT_CHARS,\n Arr.map((limit): Stage => [`inputs<=${String(limit)}`, rebuilt(plan, limit)]),\n ),\n [\"texts abridged\", (fitting) => staged(plan, fitting, abridgeText)],\n [\"old messages collapsed\", (fitting) => staged(plan, fitting, collapseText(plan))],\n [\"old calls compacted\", (fitting) => staged(plan, fitting, compactCalls(plan))],\n [\"old messages left out\", (fitting) => staged(plan, fitting, leaveOut(plan))],\n [\n \"old calls merged\",\n (fitting) => {\n const merged = fittingOf(plan, mergeRuns(plan, kept(fitting)));\n return [merged, fits(plan, merged)];\n },\n ],\n];\n\nconst throughStages = (\n plan: Plan,\n fitting: Fitting,\n stages: readonly Stage[],\n): Result.Result<FittedState, Fitting> =>\n Option.match(Arr.head(stages), {\n onNone: () => Result.fail(fitting),\n onSome: ([name, run]) => {\n const [next, done] = run(fitting);\n if (done) {\n return Result.succeed(fitted(plan, next, name));\n }\n return throughStages(plan, next, Arr.drop(stages, ONE));\n },\n });\n\nconst jsonText = (value: unknown): string => Option.getOrElse(jsonOf(value), () => \"\");\n\nconst planOf = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Plan => {\n const goal = pipe(\n Option.liftPredicate(options.goal, Str.isNonEmpty),\n Option.getOrElse(() => goalFromMessages(messages)),\n );\n const stateOf = (history: readonly HistoryEntry[]): CompactionState => ({\n context: STATE_CONTEXT,\n goal,\n history,\n });\n return {\n messages,\n calls,\n options,\n stateOf,\n baseTokens: estimateTokens(jsonText(stateOf([]))),\n byMessage: callsByMessage(calls),\n };\n};\n\nexport const fitState = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Effect.Effect<FittedState, HistoryTooLarge> => {\n const plan = planOf(messages, calls, options);\n const full = fittingOf(plan, historyEntries(messages, calls, FULL_INPUT_CHARS));\n if (fits(plan, full)) {\n return Effect.succeed(fitted(plan, full, \"full\"));\n }\n return Result.match(throughStages(plan, full, stagesOf(plan)), {\n onSuccess: Effect.succeed,\n onFailure: (last) =>\n Effect.fail(\n HistoryTooLarge.make({\n reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})`,\n }),\n ),\n });\n};\n","import { Array as Arr, Effect, FileSystem, Path, Record as Rec, Schema, pipe } from \"effect\";\n\nconst InstalledEntry = Schema.Struct({\n installPath: Schema.String,\n version: Schema.Unknown,\n gitCommitSha: Schema.Unknown,\n});\nconst InstalledPlugins = Schema.Struct({\n plugins: Schema.Record(Schema.String, Schema.Array(InstalledEntry)),\n});\nconst decodeInstalled = Schema.decodeUnknownEffect(Schema.fromJsonString(InstalledPlugins));\n\nexport interface InstalledPlugin {\n readonly id: string;\n readonly installPath: string;\n readonly version: unknown;\n readonly sha: unknown;\n}\n\nconst flattened = (installed: typeof InstalledPlugins.Type): readonly InstalledPlugin[] =>\n pipe(\n Rec.toEntries(installed.plugins),\n Arr.flatMap(([id, entries]) =>\n pipe(\n entries,\n Arr.map((entry) => ({\n id,\n installPath: entry.installPath,\n version: entry.version,\n sha: entry.gitCommitSha,\n })),\n ),\n ),\n );\n\n/** @internal */\nexport const installedPlugins = Effect.fn(\"installedPlugins\")(function* installedPlugins(\n home: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(home, \".claude\", \"plugins\", \"installed_plugins.json\");\n return yield* fs.readFileString(file).pipe(\n Effect.flatMap(decodeInstalled),\n Effect.map(flattened),\n Effect.orElseSucceed((): readonly InstalledPlugin[] => []),\n );\n});\n","import {\n Array as Arr,\n Option,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nexport type Place = \"ci\" | \"cloud\" | \"local\";\n\nexport interface Origin {\n readonly place: Place;\n readonly project: string;\n readonly hook: string;\n readonly sessionId: string;\n}\n\nexport interface JevSettings {\n readonly openRouterKey: string;\n readonly openRouterModel: string;\n readonly allowTraining: boolean;\n readonly attribution: Readonly<Record<string, string>>;\n}\n\nexport interface JevBackend {\n readonly apiKey: string;\n readonly baseURL: string;\n readonly model: string;\n readonly extra: Readonly<Record<string, unknown>>;\n readonly headers: Readonly<Record<string, string>>;\n readonly textState: boolean;\n}\n\nexport interface PlaceEnv {\n readonly githubActions: string;\n readonly remote: string;\n}\n\nexport type JevState = Readonly<Record<string, string>>;\n\nconst DEFAULT_OPENROUTER_MODEL = \"respan/span-01-lite\";\nconst TEXT_STATE_PREFIX = \"respan/\";\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const placeOf = (env: PlaceEnv): Place => {\n if (env.githubActions === \"true\") {\n return \"ci\";\n }\n if (env.remote === \"true\") {\n return \"cloud\";\n }\n return \"local\";\n};\n\nconst dataCollection = (allowTraining: boolean): string => {\n if (allowTraining) {\n return \"allow\";\n }\n return \"deny\";\n};\n\nexport const jevBackend = (settings: JevSettings, origin: Origin): JevBackend => {\n const model = pipe(\n Option.liftPredicate(settings.openRouterModel, Str.isNonEmpty),\n Option.getOrElse(() => DEFAULT_OPENROUTER_MODEL),\n );\n const session = pipe(\n Option.liftPredicate(origin.sessionId, Str.isNonEmpty),\n Option.match({ onNone: () => ({}), onSome: (id) => ({ session_id: id }) }),\n );\n return {\n apiKey: settings.openRouterKey,\n baseURL: \"https://openrouter.ai/api\",\n model,\n extra: {\n provider: { data_collection: dataCollection(settings.allowTraining) },\n user: `${origin.place}:${origin.project}:${origin.hook}`,\n ...session,\n },\n headers: settings.attribution,\n textState: Str.startsWith(TEXT_STATE_PREFIX)(model),\n };\n};\n\nconst sectionOf = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, Predicate.isString),\n Option.orElse(() => encodeJson(value)),\n Option.getOrElse(() => \"\"),\n );\n return `## ${key}\\n${text}`;\n};\n\nexport const stateFor = (backend: JevBackend, state: JevState): JevState | string => {\n if (!backend.textState) {\n return state;\n }\n return pipe(Rec.toEntries(state), Arr.map(sectionOf), Arr.join(\"\\n\\n\"));\n};\n"],"mappings":";;;;AAEA,MAAMA,gBAAc,OAAO;AAE3B,IAAa,iBAAb,cAAoCA,cAGlC,CAAC,CAAC,kBAAkB,EAAE,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnD,MAAM,YAAY;AAClB,MAAa,uBAAuB;AAEpC,MAAM,YAAY,SAChB,OAAO,OAAO,OAAO,eAAe,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,c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AC1B;AAEA,MAAa,YAAY,SAAqB,UAAuC;CACnF,IAAI,CAAC,QAAQ,WACX,OAAO;CAET,OAAO,KAAKC,OAAI,UAAU,KAAK,GAAGC,MAAI,IAAI,SAAS,GAAGA,MAAI,KAAK,MAAM,CAAC;AACxE"}
1
+ {"version":3,"file":"plugin-kit.mjs","names":["taggedError","taggedError","Arr","RecordSchema","StringSchema","ONE","encodeJson","Str","Arr","Rec","ONE","Str","Arr","Num","ONE","Arr","Num","Str","Arr","Rec","Arr","Str","Rec","Arr"],"sources":["../src/features/run-main/model/hook-io.ts","../src/features/run-main/model/run-hook.ts","../src/shared/lib/cache.ts","../src/shared/lib/record.ts","../src/features/fit-history/model/calls.ts","../src/shared/lib/tokens.ts","../src/features/fit-history/model/fitting.ts","../src/features/fit-history/model/state.ts","../src/shared/lib/installed-plugins.ts","../src/shared/lib/jev-backend.ts"],"sourcesContent":["import { Effect, Runtime, Schema, Stdio, Stream } from \"effect\";\n\nconst EXIT_BLOCKING = 2;\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class HookBlocked extends taggedError<HookBlocked, { readonly brand: unique symbol }>()(\n \"HookBlocked\",\n { reason: Schema.String },\n) {\n public override readonly [Runtime.errorExitCode] = EXIT_BLOCKING;\n public override readonly [Runtime.errorReported] = false;\n}\n\n/** @internal */\nexport const isHookBlocked = Schema.is(HookBlocked);\n\n/** @internal */\nexport const blockHook = (reason: string): Effect.Effect<never, HookBlocked> =>\n Effect.fail(HookBlocked.make({ reason }));\n\n/** @internal */\nexport const readStdin: Effect.Effect<string, never, Stdio.Stdio> = Effect.gen(\n function* readStdin() {\n const stdio = yield* Stdio.Stdio;\n return yield* stdio.stdin.pipe(Stream.decodeText, Stream.mkString, Effect.orDie);\n },\n);\n\n/** @internal */\nexport const readHookInput = <Codec extends Schema.Top>(\n schema: Codec,\n): Effect.Effect<Codec[\"Type\"], Schema.SchemaError, Stdio.Stdio | Codec[\"DecodingServices\"]> =>\n Effect.gen(function* read() {\n const text = yield* readStdin;\n const json = Schema.fromJsonString(schema);\n return yield* Schema.decodeEffect(json)(text);\n });\n\n/** @internal */\nexport const writeStdout = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStdout() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeStderr = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStderr() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeHookOutput =\n <Codec extends Schema.Top>(schema: Codec) =>\n (value: Codec[\"Type\"]): Effect.Effect<void, never, Stdio.Stdio | Codec[\"EncodingServices\"]> =>\n Schema.encodeEffect(Schema.fromJsonString(schema))(value).pipe(\n Effect.orDie,\n Effect.flatMap(writeStdout),\n );\n","import { Cause, Effect, Layer, Option } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { isHookBlocked, writeStderr } from \"./hook-io.ts\";\nimport type { HookBlocked } from \"./hook-io.ts\";\nimport { runMainWith } from \"./run-main.ts\";\nimport type { Platform, Run } from \"./run-main.ts\";\n\nconst blockedIn = <Failure>(cause: Cause.Cause<Failure>): Option.Option<HookBlocked> =>\n Cause.findErrorOption(cause).pipe(\n Option.filter((error): error is Failure & HookBlocked => isHookBlocked(error)),\n );\n\nconst reportBlocked = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Option.match(blockedIn(cause), {\n onNone: () => Effect.void,\n onSome: (blocked) => writeStderr(`${blocked.reason}\\n`),\n });\n\n/** @internal */\nexport const runHookWith =\n <Provided, LayerFailure>({\n serviceName,\n services,\n }: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>): Run<Provided> =>\n (program) => {\n runMainWith({ serviceName, services })(program.pipe(Effect.tapCause(reportBlocked)));\n };\n\n/** @internal */\nexport const runHook = (serviceName: string): Run<never> =>\n runHookWith({ serviceName, services: Layer.empty });\n","import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n\nexport const cacheRootOf = (segments: readonly string[]): Promise<string> =>\n Effect.runPromise(cacheRootEffect(segments));\n","import type { Option } from \"effect/Option\";\nimport {\n Record as RecordSchema,\n String as StringSchema,\n Unknown,\n decodeOption,\n fromJsonString,\n is,\n} from \"effect/Schema\";\n\nexport const isRecord = is(RecordSchema(StringSchema, Unknown));\n\nexport const parseJson = (text: string): Option<unknown> =>\n decodeOption(fromJsonString(Unknown))(text);\n","import { Array as Arr, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport type { HistoryEntry, HistoryToolCall, Message, ToolCall } from \"./types.ts\";\n\nconst FIRST = 0;\nconst ONE = 1;\nconst ELLIPSIS = \"…\";\nconst VALUE_CHARS = 200;\nconst COMPACT_INPUT_CHARS = 60;\nconst SPACES = /\\s+/gu;\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const jsonOf = (value: unknown): Option.Option<string> => encodeJson(value);\n\nexport const truncate = (text: string, limit: number): string => {\n if (Str.length(text) <= limit) {\n return text;\n }\n return `${Str.slice(FIRST, Math.max(FIRST, limit - ONE))(text)}${ELLIPSIS}`;\n};\n\nexport const isPinned = (index: number, total: number, preserveRecentMessages: number): boolean =>\n index === FIRST || index >= total - preserveRecentMessages;\n\ninterface Found {\n readonly index: number;\n readonly chars: number;\n readonly isError: boolean;\n}\n\nconst resultsOf = (messages: readonly Message[]): ReadonlyMap<string, Found> =>\n new Map(\n pipe(\n messages,\n Arr.flatMap((message, index) =>\n pipe(\n message.toolResults,\n Arr.map(\n (result) =>\n [\n result.tool_use_id,\n { index, chars: Str.length(result.text), isError: result.isError },\n ] as const,\n ),\n ),\n ),\n ),\n );\n\nexport const collectToolCalls = (\n messages: readonly Message[],\n preserveRecentMessages: number,\n): readonly ToolCall[] => {\n const results = resultsOf(messages);\n const pinned = (index: number): boolean =>\n isPinned(index, messages.length, preserveRecentMessages);\n return pipe(\n messages,\n Arr.flatMap((message, callIndex) =>\n pipe(\n message.toolUses,\n Arr.flatMap((tool) =>\n pipe(\n Option.fromUndefinedOr(results.get(tool.tool_use_id)),\n Option.map((found) => ({ tool, callIndex, found })),\n Option.toArray,\n ),\n ),\n ),\n ),\n Arr.map(({ tool, callIndex, found }, index) => ({\n id: `t${String(index + ONE)}`,\n tool_use_id: tool.tool_use_id,\n tool: tool.tool,\n input: tool.input,\n callIndex,\n resultIndex: found.index,\n resultChars: found.chars,\n isError: found.isError,\n pinned: pinned(callIndex) || pinned(found.index),\n })),\n );\n};\n\nexport const inputText = (input: Readonly<Record<string, unknown>>, limit: number): string =>\n truncate(\n Option.getOrElse(jsonOf(input), () => \"[unserializable input]\"),\n limit,\n );\n\nconst outcomeOf = (call: ToolCall): string => {\n if (call.isError) {\n return \"error\";\n }\n return \"ok\";\n};\n\nconst resultNote = (call: ToolCall): string =>\n `${outcomeOf(call)}, ${String(call.resultChars)} chars (omitted)`;\n\nconst valueText = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, (raw): raw is string => typeof raw === \"string\"),\n Option.getOrElse(() => inputText({ [key]: value }, VALUE_CHARS)),\n );\n return `${key}=${Str.replaceAll(SPACES, \" \")(text)}`;\n};\n\nexport const compactCall = (call: ToolCall): string => {\n const input = pipe(Rec.toEntries(call.input), Arr.map(valueText), Arr.join(\" \"));\n return `${call.id} ${call.tool} ${truncate(input, COMPACT_INPUT_CHARS)} → ${outcomeOf(call)} ${String(call.resultChars)}ch`;\n};\n\nexport const callsByMessage = (\n calls: readonly ToolCall[],\n): ReadonlyMap<number, readonly ToolCall[]> =>\n new Map(\n pipe(\n calls,\n Arr.groupBy((call) => String(call.callIndex)),\n Rec.toEntries,\n Arr.map(([index, own]) => [Number(index), own] as const),\n ),\n );\n\nconst historyCallOf =\n (inputChars: number) =>\n (call: ToolCall): HistoryToolCall => ({\n id: call.id,\n tool: call.tool,\n input: inputText(call.input, inputChars),\n result: resultNote(call),\n });\n\nexport const historyEntries = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n inputChars: number,\n): readonly HistoryEntry[] => {\n const byMessage = callsByMessage(calls);\n return pipe(\n messages,\n Arr.flatMap((message, index): readonly HistoryEntry[] => {\n const own = Option.getOrElse(Option.fromUndefinedOr(byMessage.get(index)), () => []);\n const toolCalls = pipe(own, Arr.map(historyCallOf(inputChars)));\n const entry = { index, role: message.role, text: message.text };\n if (Arr.isReadonlyArrayNonEmpty(toolCalls)) {\n return [{ ...entry, tool_calls: toolCalls }];\n }\n if (Str.isEmpty(Str.trim(message.text))) {\n return [];\n }\n return [entry];\n }),\n );\n};\n","import { Array as Arr, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nconst PIECES = /(?<alpha>[A-Za-z]+)|(?<digits>\\d+)|(?<other>[^\\sA-Za-z\\d])/gu;\nconst DIGITS_PER_TOKEN = 2;\nconst LETTERS_PER_TOKEN = 6;\nconst SYMBOL_TOKENS = 0.9;\nconst ONE = 1;\n\nconst groupOf = (match: RegExpMatchArray, key: string): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[key])),\n );\n\nconst pieceTokens = (match: RegExpMatchArray): number =>\n pipe(\n groupOf(match, \"digits\"),\n Option.map((digits) => Str.length(digits) / DIGITS_PER_TOKEN),\n Option.orElse(() =>\n Option.map(\n groupOf(match, \"alpha\"),\n (alpha) => ONE + Math.floor((Str.length(alpha) - ONE) / LETTERS_PER_TOKEN),\n ),\n ),\n Option.getOrElse(() => SYMBOL_TOKENS),\n );\n\nconst matchesOf = (pattern: RegExp, text: string): readonly RegExpMatchArray[] =>\n Arr.fromIterable(Str.matchAll(pattern)(text));\n\nexport const estimateTokens = (text: string): number => {\n const pieces = pipe(matchesOf(PIECES, text), Arr.map(pieceTokens));\n return Math.ceil(Num.sumAll(pieces));\n};\n","import { Array as Arr, Number as Num, Option, pipe } from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { isPinned, jsonOf } from \"./calls.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nconst ONE = 1;\nconst NONE = 0;\n\nexport const entryTokens = (entry: HistoryEntry): number =>\n estimateTokens(Option.getOrElse(jsonOf(entry), () => \"\")) + ONE;\n\nexport interface Fitting {\n readonly history: readonly Option.Option<HistoryEntry>[];\n readonly perEntry: readonly number[];\n readonly tokens: number;\n}\n\nexport interface Plan {\n readonly messages: readonly Message[];\n readonly calls: readonly ToolCall[];\n readonly options: FitOptions;\n readonly stateOf: (history: readonly HistoryEntry[]) => CompactionState;\n readonly baseTokens: number;\n readonly byMessage: ReadonlyMap<number, readonly ToolCall[]>;\n}\n\nexport type Change = (entry: HistoryEntry) => Option.Option<Option.Option<HistoryEntry>>;\n\nexport const fittingOf = (plan: Plan, history: readonly HistoryEntry[]): Fitting => {\n const perEntry = pipe(history, Arr.map(entryTokens));\n return {\n history: pipe(history, Arr.map(Option.some)),\n perEntry,\n tokens: plan.baseTokens + Num.sumAll(perEntry),\n };\n};\n\nexport const kept = (fitting: Fitting): readonly HistoryEntry[] => Arr.getSomes(fitting.history);\n\nexport const fits = (plan: Plan, fitting: Fitting): boolean =>\n fitting.tokens <= plan.options.maxStateTokens;\n\nexport const fitted = (plan: Plan, fitting: Fitting, stage: string): FittedState => ({\n state: plan.stateOf(kept(fitting)),\n tokens: fitting.tokens,\n stage,\n});\n\nexport const pinnedEntry = (plan: Plan, entry: HistoryEntry): boolean =>\n isPinned(entry.index, plan.messages.length, plan.options.preserveRecentMessages);\n\nconst orderOf = (plan: Plan, fitting: Fitting): readonly number[] => {\n const present = pipe(\n fitting.history,\n Arr.flatMap((entry, index) =>\n pipe(\n entry,\n Option.map((value) => [index, pinnedEntry(plan, value)] as const),\n Option.toArray,\n ),\n ),\n );\n const loose = pipe(\n present,\n Arr.filter(([, pinned]) => !pinned),\n );\n const pinned = pipe(\n present,\n Arr.filter(([, isPinnedEntry]) => isPinnedEntry),\n );\n return pipe(\n [...loose, ...pinned],\n Arr.map(([index]) => index),\n );\n};\n\ninterface Step {\n readonly index: number;\n readonly entry: Option.Option<HistoryEntry>;\n readonly tokens: number;\n}\n\nconst stepOf =\n (fitting: Fitting, change: Change) =>\n (index: number): Option.Option<Step> =>\n pipe(\n Option.flatten(Option.fromUndefinedOr(fitting.history[index])),\n Option.flatMap(change),\n Option.map((entry) => ({\n index,\n entry,\n tokens: Option.match(entry, { onNone: () => NONE, onSome: entryTokens }),\n })),\n );\n\nconst applied = (fitting: Fitting, steps: readonly Step[]): Fitting => {\n const byIndex = new Map(\n pipe(\n steps,\n Arr.map((step) => [step.index, step] as const),\n ),\n );\n const pick = <Value>(index: number, value: Value, of: (step: Step) => Value): Value =>\n Option.match(Option.fromUndefinedOr(byIndex.get(index)), { onNone: () => value, onSome: of });\n const history = pipe(\n fitting.history,\n Arr.map((entry, index) => pick(index, entry, (step) => step.entry)),\n );\n const perEntry = pipe(\n fitting.perEntry,\n Arr.map((tokens, index) => pick(index, tokens, (step) => step.tokens)),\n );\n const delta = Num.sumAll(\n pipe(\n steps,\n Arr.map(\n (step) => step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n ),\n );\n return { history, perEntry, tokens: fitting.tokens + delta };\n};\n\nexport const staged = (\n plan: Plan,\n fitting: Fitting,\n change: Change,\n): readonly [Fitting, boolean] => {\n const steps = pipe(\n orderOf(plan, fitting),\n Arr.flatMap((index) => Option.toArray(stepOf(fitting, change)(index))),\n );\n const totals = pipe(\n steps,\n Arr.scan(\n fitting.tokens,\n (tokens, step) =>\n tokens + step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n Arr.drop(ONE),\n );\n return Option.match(\n Arr.findFirstIndex(totals, (tokens) => tokens <= plan.options.maxStateTokens),\n {\n onNone: () => [applied(fitting, steps), false] as const,\n onSome: (at) => [applied(fitting, Arr.take(steps, at + ONE)), true] as const,\n },\n );\n};\n","import {\n Array as Arr,\n Effect,\n Option,\n Predicate,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { callsByMessage, compactCall, historyEntries, jsonOf, truncate } from \"./calls.ts\";\nimport { fits, fitted, fittingOf, kept, pinnedEntry, staged } from \"./fitting.ts\";\nimport type { Change, Fitting, Plan } from \"./fitting.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n HistoryToolCall,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nexport const STATE_CONTEXT =\n \"A coding assistant conversation is being compacted to free context. `history` is the whole conversation so far, oldest first; tool outputs are replaced by a short `result` note and long texts may be abridged. Each question asks whether one tool call, or the full output of that call, still needs to stay in the history verbatim. Whatever is not kept is deleted permanently, but the assistant can always re-run a tool or re-read a file.\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class HistoryTooLarge extends taggedError<\n HistoryTooLarge,\n { readonly brand: unique symbol }\n>()(\"HistoryTooLarge\", { reason: Schema.String }) {}\n\nconst FULL_INPUT_CHARS = 1000;\nconst SHORT_INPUT_CHARS = 200;\nconst SHORTEST_INPUT_CHARS = 60;\nconst SHORTER_INPUT_CHARS = [SHORT_INPUT_CHARS, SHORTEST_INPUT_CHARS] as const;\nconst TEXT_HEAD = 400;\nconst TEXT_TAIL = 150;\nconst ABRIDGE_MARGIN = 40;\nconst RECENT_GOALS = 3;\nconst GOAL_CHARS = 500;\nconst ONE = 1;\n\nconst abridge = (text: string): string => {\n const omitted = Str.length(text) - TEXT_HEAD - TEXT_TAIL;\n return `${Str.takeLeft(TEXT_HEAD)(text)}\\n[… ${String(omitted)} chars omitted …]\\n${Str.takeRight(TEXT_TAIL)(text)}`;\n};\n\nexport const goalFromMessages = (messages: readonly Message[]): string =>\n pipe(\n messages,\n Arr.filter(\n (message) =>\n message.role === \"user\" &&\n Str.isNonEmpty(Str.trim(message.text)) &&\n Arr.isReadonlyArrayEmpty(message.toolResults),\n ),\n Arr.takeRight(RECENT_GOALS),\n Arr.map((message) => truncate(message.text, GOAL_CHARS)),\n Arr.join(\"\\n\"),\n );\n\nconst abridgeText: Change = (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.some({ ...entry, text: abridge(entry.text) }),\n () => Str.length(entry.text) > TEXT_HEAD + TEXT_TAIL + ABRIDGE_MARGIN,\n );\n\nconst collapseText =\n (plan: Plan): Change =>\n (entry: HistoryEntry) => {\n const original = pipe(\n Arr.get(plan.messages, entry.index),\n Option.map((message) => Str.length(message.text)),\n Option.getOrElse(() => Str.length(entry.text)),\n );\n return Option.liftPredicate(\n Option.some({ ...entry, text: `[… ${String(original)} chars omitted …]` }),\n () => !pinnedEntry(plan, entry) && Str.isNonEmpty(entry.text),\n );\n };\n\nconst compactCalls =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n pipe(\n Option.fromUndefinedOr(plan.byMessage.get(entry.index)),\n Option.filter(() => !pinnedEntry(plan, entry)),\n Option.map((own) => Option.some({ ...entry, tool_calls: pipe(own, Arr.map(compactCall)) })),\n );\n\nconst leaveOut =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.none<HistoryEntry>(),\n () => !pinnedEntry(plan, entry) && Predicate.isUndefined(entry.tool_calls),\n );\n\nconst callsOf = (entry: HistoryEntry): readonly (HistoryToolCall | string)[] =>\n Option.getOrElse(Option.fromUndefinedOr(entry.tool_calls), () => []);\n\nconst stringCalls = (entry: HistoryEntry): readonly string[] =>\n pipe(callsOf(entry), Arr.filter(Predicate.isString));\n\nconst foldable = (plan: Plan, entry: HistoryEntry): boolean =>\n !pinnedEntry(plan, entry) &&\n Str.isEmpty(entry.text) &&\n pipe(Arr.head(callsOf(entry)), Option.exists(Predicate.isString));\n\nconst mergedRun = (group: Arr.NonEmptyReadonlyArray<HistoryEntry>): HistoryEntry => {\n const first = Arr.headNonEmpty(group);\n if (group.length === ONE) {\n return first;\n }\n return { ...first, tool_calls: pipe(group, Arr.flatMap(stringCalls)) };\n};\n\nconst mergeRuns = (plan: Plan, history: readonly HistoryEntry[]): readonly HistoryEntry[] => {\n if (!Arr.isReadonlyArrayNonEmpty(history)) {\n return [];\n }\n return pipe(\n Arr.groupWith(\n history,\n (left, right) => foldable(plan, left) && foldable(plan, right) && left.role === right.role,\n ),\n Arr.map(mergedRun),\n );\n};\n\ntype Stage = readonly [string, (fitting: Fitting) => readonly [Fitting, boolean]];\n\nconst rebuilt = (plan: Plan, inputChars: number) => (): readonly [Fitting, boolean] => {\n const fitting = fittingOf(plan, historyEntries(plan.messages, plan.calls, inputChars));\n return [fitting, fits(plan, fitting)];\n};\n\nconst stagesOf = (plan: Plan): readonly Stage[] => [\n ...pipe(\n SHORTER_INPUT_CHARS,\n Arr.map((limit): Stage => [`inputs<=${String(limit)}`, rebuilt(plan, limit)]),\n ),\n [\"texts abridged\", (fitting) => staged(plan, fitting, abridgeText)],\n [\"old messages collapsed\", (fitting) => staged(plan, fitting, collapseText(plan))],\n [\"old calls compacted\", (fitting) => staged(plan, fitting, compactCalls(plan))],\n [\"old messages left out\", (fitting) => staged(plan, fitting, leaveOut(plan))],\n [\n \"old calls merged\",\n (fitting) => {\n const merged = fittingOf(plan, mergeRuns(plan, kept(fitting)));\n return [merged, fits(plan, merged)];\n },\n ],\n];\n\nconst throughStages = (\n plan: Plan,\n fitting: Fitting,\n stages: readonly Stage[],\n): Result.Result<FittedState, Fitting> =>\n Option.match(Arr.head(stages), {\n onNone: () => Result.fail(fitting),\n onSome: ([name, run]) => {\n const [next, done] = run(fitting);\n if (done) {\n return Result.succeed(fitted(plan, next, name));\n }\n return throughStages(plan, next, Arr.drop(stages, ONE));\n },\n });\n\nconst jsonText = (value: unknown): string => Option.getOrElse(jsonOf(value), () => \"\");\n\nconst planOf = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Plan => {\n const goal = pipe(\n Option.liftPredicate(options.goal, Str.isNonEmpty),\n Option.getOrElse(() => goalFromMessages(messages)),\n );\n const stateOf = (history: readonly HistoryEntry[]): CompactionState => ({\n context: STATE_CONTEXT,\n goal,\n history,\n });\n return {\n messages,\n calls,\n options,\n stateOf,\n baseTokens: estimateTokens(jsonText(stateOf([]))),\n byMessage: callsByMessage(calls),\n };\n};\n\nexport const fitState = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Effect.Effect<FittedState, HistoryTooLarge> => {\n const plan = planOf(messages, calls, options);\n const full = fittingOf(plan, historyEntries(messages, calls, FULL_INPUT_CHARS));\n if (fits(plan, full)) {\n return Effect.succeed(fitted(plan, full, \"full\"));\n }\n return Result.match(throughStages(plan, full, stagesOf(plan)), {\n onSuccess: Effect.succeed,\n onFailure: (last) =>\n Effect.fail(\n HistoryTooLarge.make({\n reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})`,\n }),\n ),\n });\n};\n","import { Array as Arr, Effect, FileSystem, Path, Record as Rec, Schema, pipe } from \"effect\";\n\nconst InstalledEntry = Schema.Struct({\n installPath: Schema.String,\n version: Schema.Unknown,\n gitCommitSha: Schema.Unknown,\n});\nconst InstalledPlugins = Schema.Struct({\n plugins: Schema.Record(Schema.String, Schema.Array(InstalledEntry)),\n});\nconst decodeInstalled = Schema.decodeUnknownEffect(Schema.fromJsonString(InstalledPlugins));\n\nexport interface InstalledPlugin {\n readonly id: string;\n readonly installPath: string;\n readonly version: unknown;\n readonly sha: unknown;\n}\n\nconst flattened = (installed: typeof InstalledPlugins.Type): readonly InstalledPlugin[] =>\n pipe(\n Rec.toEntries(installed.plugins),\n Arr.flatMap(([id, entries]) =>\n pipe(\n entries,\n Arr.map((entry) => ({\n id,\n installPath: entry.installPath,\n version: entry.version,\n sha: entry.gitCommitSha,\n })),\n ),\n ),\n );\n\n/** @internal */\nexport const installedPlugins = Effect.fn(\"installedPlugins\")(function* installedPlugins(\n home: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(home, \".claude\", \"plugins\", \"installed_plugins.json\");\n return yield* fs.readFileString(file).pipe(\n Effect.flatMap(decodeInstalled),\n Effect.map(flattened),\n Effect.orElseSucceed((): readonly InstalledPlugin[] => []),\n );\n});\n","import {\n Array as Arr,\n Option,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nexport type Place = \"ci\" | \"cloud\" | \"local\";\n\nexport interface Origin {\n readonly place: Place;\n readonly project: string;\n readonly hook: string;\n readonly sessionId: string;\n}\n\nexport interface JevSettings {\n readonly openRouterKey: string;\n readonly openRouterModel: string;\n readonly allowTraining: boolean;\n readonly attribution: Readonly<Record<string, string>>;\n}\n\nexport interface JevBackend {\n readonly apiKey: string;\n readonly baseURL: string;\n readonly model: string;\n readonly extra: Readonly<Record<string, unknown>>;\n readonly headers: Readonly<Record<string, string>>;\n readonly textState: boolean;\n}\n\nexport interface PlaceEnv {\n readonly githubActions: string;\n readonly remote: string;\n}\n\nexport type JevState = Readonly<Record<string, string>>;\n\nconst DEFAULT_OPENROUTER_MODEL = \"respan/span-01-lite\";\nconst TEXT_STATE_PREFIX = \"respan/\";\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const placeOf = (env: PlaceEnv): Place => {\n if (env.githubActions === \"true\") {\n return \"ci\";\n }\n if (env.remote === \"true\") {\n return \"cloud\";\n }\n return \"local\";\n};\n\nconst dataCollection = (allowTraining: boolean): string => {\n if (allowTraining) {\n return \"allow\";\n }\n return \"deny\";\n};\n\nexport const jevBackend = (settings: JevSettings, origin: Origin): JevBackend => {\n const model = pipe(\n Option.liftPredicate(settings.openRouterModel, Str.isNonEmpty),\n Option.getOrElse(() => DEFAULT_OPENROUTER_MODEL),\n );\n const session = pipe(\n Option.liftPredicate(origin.sessionId, Str.isNonEmpty),\n Option.match({ onNone: () => ({}), onSome: (id) => ({ session_id: id }) }),\n );\n return {\n apiKey: settings.openRouterKey,\n baseURL: \"https://openrouter.ai/api\",\n model,\n extra: {\n provider: { data_collection: dataCollection(settings.allowTraining) },\n user: `${origin.place}:${origin.project}:${origin.hook}`,\n ...session,\n },\n headers: settings.attribution,\n textState: Str.startsWith(TEXT_STATE_PREFIX)(model),\n };\n};\n\nconst sectionOf = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, Predicate.isString),\n Option.orElse(() => encodeJson(value)),\n Option.getOrElse(() => \"\"),\n );\n return `## ${key}\\n${text}`;\n};\n\nexport const stateFor = (backend: JevBackend, state: JevState): JevState | string => {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eAAe,SAAS,aAAa,EAAE;GACpE,MAAM,GAAG,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG,OAAO;GAClD,GAAG;EACL;EACA,SAAS,SAAS;EAClB,WAAWA,SAAI,WAAW,iBAAiB,CAAC,CAAC,KAAK;CACpD;AACF;AAEA,MAAM,aAAa,CAAC,KAAK,WAA+C;CAMtE,OAAO,MAAM,IAAI,IALJ,KACX,OAAO,cAAc,OAAO,UAAU,QAAQ,GAC9C,OAAO,aAAa,WAAW,KAAK,CAAC,GACrC,OAAO,gBAAgB,EAAE,CAEH;AAC1B;AAEA,MAAa,YAAY,SAAqB,UAAuC;CACnF,IAAI,CAAC,QAAQ,WACX,OAAO;CAET,OAAO,KAAKC,OAAI,UAAU,KAAK,GAAGC,MAAI,IAAI,SAAS,GAAGA,MAAI,KAAK,MAAM,CAAC;AACxE"}
@@ -1,3 +1,4 @@
1
- import { a as SECURITY_HEADERS_CREDENTIALLESS, c as SERVER_RESPONSE_HEADERS, d as assetHeaders, f as contentSecurityPolicy, i as SECURITY_HEADERS, l as SPECULATION_RULES_FILE, n as EMBEDDED_VIDEO_SOURCES, o as SECURITY_HEADERS_EMBEDDING, p as serverPageHeaders, r as PageSources, s as SERVER_PAGE_HEADERS, t as ASSET_CACHE_CONTROL, u as STATIC_PAGE_HEADERS } from "./headers-BK-aW9Kw.mjs";
2
1
  import { n as WEB_ANALYTICS_SCRIPT_ORIGIN, t as WEB_ANALYTICS_REPORT_ORIGIN } from "./web-analytics-BM9LdncT.mjs";
2
+ import { a as SECURITY_HEADERS_CREDENTIALLESS, c as SERVER_RESPONSE_HEADERS, d as assetHeaders, f as contentSecurityPolicy, i as SECURITY_HEADERS, l as SPECULATION_RULES_FILE, n as EMBEDDED_VIDEO_SOURCES, o as SECURITY_HEADERS_EMBEDDING, p as serverPageHeaders, r as PageSources, s as SERVER_PAGE_HEADERS, t as ASSET_CACHE_CONTROL, u as STATIC_PAGE_HEADERS } from "./headers-BK-aW9Kw.mjs";
3
+ import "./index-BtcxUsGh.mjs";
3
4
  export { ASSET_CACHE_CONTROL, EMBEDDED_VIDEO_SOURCES, type PageSources, SECURITY_HEADERS, SECURITY_HEADERS_CREDENTIALLESS, SECURITY_HEADERS_EMBEDDING, SERVER_PAGE_HEADERS, SERVER_RESPONSE_HEADERS, SPECULATION_RULES_FILE, STATIC_PAGE_HEADERS, WEB_ANALYTICS_REPORT_ORIGIN, WEB_ANALYTICS_SCRIPT_ORIGIN, assetHeaders, contentSecurityPolicy, serverPageHeaders };
@@ -1,6 +1,6 @@
1
1
  import { t as buttonVariants } from "../button-variants-Bupz7GI3.mjs";
2
- import { VariantProps } from "class-variance-authority";
3
2
  import { ComponentProps, ReactNode } from "react";
3
+ import { VariantProps } from "class-variance-authority";
4
4
  export declare const Button: ({ className, variant, size, asChild, ...props }: ComponentProps<"button"> & Readonly<VariantProps<typeof buttonVariants>> & Readonly<{
5
5
  asChild?: boolean;
6
6
  }>) => ReactNode;
@@ -1,30 +1 @@
1
- import { t as buttonVariants } from "../button-variants-BLMlMm-s.mjs";
2
- import { t as cn } from "../cn-DtxpfSUK.mjs";
3
- import { jsx } from "react/jsx-runtime";
4
- import { Slot } from "radix-ui";
5
- // src/shared/ui/button.tsx
6
- const Button = ({ className, variant = "default", size = "default", asChild = false, ...props }) => {
7
- const classes = cn(buttonVariants({
8
- variant,
9
- size,
10
- className
11
- }));
12
- if (asChild) return /* @__PURE__ */ jsx(Slot.Root, {
13
- "data-slot": "button",
14
- "data-variant": variant,
15
- "data-size": size,
16
- className: classes,
17
- ...props
18
- });
19
- return /* @__PURE__ */ jsx("button", {
20
- type: "button",
21
- "data-slot": "button",
22
- "data-variant": variant,
23
- "data-size": size,
24
- className: classes,
25
- ...props
26
- });
27
- };
28
- export { Button };
29
-
30
- //# sourceMappingURL=button.mjs.map
1
+ export { t as Button } from "../button-980Op0uF.mjs";
@@ -1,7 +1,7 @@
1
1
  import { Array, Option, pipe } from "effect";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { constVoid } from "effect/Function";
4
3
  import { useCallback } from "react";
4
+ import { constVoid } from "effect/Function";
5
5
  // src/shared/ui/next-page-trigger.tsx
6
6
  const AHEAD = { rootMargin: "0px 0px 100% 0px" };
7
7
  const NextPageTrigger = ({ onVisible }) => {
@@ -1,5 +1,5 @@
1
- import { VariantProps } from "class-variance-authority";
2
1
  import { ReactNode } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
3
  declare const footerVariants: (props?: ({
4
4
  variant?: "credit" | "links" | "rule" | null | undefined;
5
5
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,5 +1,5 @@
1
- import { VariantProps } from "class-variance-authority";
2
1
  import { ReactNode } from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
3
  declare const headerVariants: (props?: ({
4
4
  layout?: "bar" | "stacked" | null | undefined;
5
5
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,6 +1,6 @@
1
1
  import { c as TableHeadVariant, l as tableHeadVariants } from "../table-class-BeiCXlFj.mjs";
2
- import { VariantProps } from "class-variance-authority";
3
2
  import { ComponentProps, ReactNode } from "react";
3
+ import { VariantProps } from "class-variance-authority";
4
4
  type ColumnHeading = Readonly<{
5
5
  key?: string;
6
6
  label: string;
@@ -1,4 +1,5 @@
1
1
  import { n as WEB_ANALYTICS_SCRIPT_ORIGIN, t as WEB_ANALYTICS_REPORT_ORIGIN } from "../web-analytics-BM9LdncT.mjs";
2
+ import "../index-BtcxUsGh.mjs";
2
3
  export declare const WEB_ANALYTICS_BEACON: {
3
4
  readonly src: "https://static.cloudflareinsights.com/beacon.min.js/v8c78df7c7c0f484497ecbca7046644da1771523124516";
4
5
  readonly integrity: "sha512-8DS7rgIrAmghBFwoOTujcf6D9rXvH8xm8JQ1Ja01h9QX8EzXldiszufYa4IFfKdLUKTTrnSFXLDkUEOTrZQ8Qg==";
@@ -1,6 +1,6 @@
1
1
  import { n as currentReceiver } from "../vitest-otlp-current-receiver-8c7rIP1N.mjs";
2
- import { Array, Effect, Option, Predicate, Schema, pipe } from "effect";
3
2
  import { fileURLToPath } from "node:url";
3
+ import { Array, Effect, Option, Predicate, Schema, pipe } from "effect";
4
4
  import { build } from "vite-plus";
5
5
  // src/app/vitest-otlp-workers.ts
6
6
  const taggedError = Schema.TaggedError;
@@ -1,5 +1,5 @@
1
1
  import { Workers } from "@alchemy.run/cloudflare";
2
- import { Effect, Layer } from "effect";
2
+ import { Effect, Layer, Option, Schema } from "effect";
3
3
  import { Worker, WorkerProps } from "@alchemy.run/cloudflare/Workers/Worker";
4
4
  import { ProviderService } from "alchemy/Provider";
5
5
  export declare const COMPATIBILITY_DATE = "2026-08-25";