apps 0.0.1-beta.1 → 0.0.1-beta.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.
Files changed (58) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/browser-XIPJGLH2.js +65 -0
  3. package/js/{chunk-6YBRWRK3.js → chunk-5MQZEB6Y.js} +16 -4
  4. package/js/chunk-D47C7KG5.js +172 -0
  5. package/js/{chunk-ZTFQHGEB.js → chunk-FDNTX5QJ.js} +1 -3
  6. package/js/{chunk-OHRT55C4.js → chunk-G7ZIRKMK.js} +0 -3
  7. package/js/{chunk-G7IE6BKC.js → chunk-HDTGZWP2.js} +2 -2
  8. package/js/{chunk-KOXMLKTM.js → chunk-J7O55ZV7.js} +20 -148
  9. package/js/{chunk-RBAC33PQ.js → chunk-JN55AYQH.js} +3 -57
  10. package/js/chunk-LGIYBDWA.js +85 -0
  11. package/js/{chunk-IHQ4ML7K.js → chunk-MYYEW3RA.js} +130 -86
  12. package/js/chunk-NQ3OMCA5.js +39 -0
  13. package/js/{chunk-PZ36XMXW.js → chunk-PYUYJRSK.js} +1 -1
  14. package/js/{chunk-X7SFGU4Q.js → chunk-RN2MXB4R.js} +4 -4
  15. package/js/{chunk-4LPG6RCH.js → chunk-T2LAZCAD.js} +4 -24
  16. package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
  17. package/js/{chunk-2HHMABB6.js → chunk-WFSQXYUT.js} +46 -10
  18. package/js/{chunk-6IIO4NPI.js → chunk-Z5NMEGJN.js} +1 -1
  19. package/js/client.js +2 -2
  20. package/js/contracts.js +8 -1
  21. package/js/effect.js +8 -7
  22. package/js/es-APDZKREY.js +40968 -0
  23. package/js/graphql.js +10 -9
  24. package/js/host.js +12 -11
  25. package/js/index.js +7 -5
  26. package/js/mcp/effect.js +10 -9
  27. package/js/mcp/stdio.js +10 -9
  28. package/js/mcp.js +12 -11
  29. package/js/openapi.js +776 -41590
  30. package/js/skills/effect.js +1 -2
  31. package/js/skills.js +47 -10
  32. package/js/ui/auth/contracts.js +7 -8
  33. package/js/ui/auth.js +13 -11
  34. package/js/ui/contracts.js +1 -1
  35. package/js/ui/serving.js +3 -2
  36. package/package.json +1 -1
  37. package/runtime.json +1 -1
  38. package/types/app-cache/src/contracts/cache.d.ts +42 -2
  39. package/types/app-cache/src/index.d.ts +59 -1
  40. package/types/apps/src/contracts/cache.d.ts +4 -1
  41. package/types/apps/src/contracts/host.d.ts +8 -672
  42. package/types/apps/src/contracts/openapi.d.ts +6 -0
  43. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  44. package/types/apps/src/contracts/protocols/1.d.ts +1575 -0
  45. package/types/apps/src/contracts/skills.d.ts +17 -8
  46. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  47. package/types/apps/src/implementation/cache.d.ts +3 -1
  48. package/types/apps/src/implementation/openapi-compile.d.ts +1 -1
  49. package/types/apps/src/implementation/openapi-document.d.ts +0 -2
  50. package/types/apps/src/implementation/openapi-names.d.ts +18 -0
  51. package/types/apps/src/implementation/openapi-request.d.ts +0 -1
  52. package/types/apps/src/implementation/openapi-source.d.ts +5 -1
  53. package/types/apps/src/implementation/schema.d.ts +0 -5
  54. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  55. package/types/apps/src/implementation/ui-auth.d.ts +11 -5
  56. package/types/apps/src/skills.d.ts +6 -3
  57. package/types/apps/src/ui-auth.d.ts +2 -2
  58. package/js/chunk-TE4KO4HI.js +0 -47
@@ -0,0 +1,65 @@
1
+ import {
2
+ Alias,
3
+ Composer,
4
+ Document,
5
+ Lexer,
6
+ LineCounter,
7
+ Pair,
8
+ Parser,
9
+ Scalar,
10
+ Schema,
11
+ YAMLError,
12
+ YAMLMap,
13
+ YAMLParseError,
14
+ YAMLSeq,
15
+ YAMLWarning,
16
+ browser_default,
17
+ cst_exports,
18
+ isAlias,
19
+ isCollection,
20
+ isDocument,
21
+ isMap,
22
+ isNode,
23
+ isPair,
24
+ isScalar,
25
+ isSeq,
26
+ parse,
27
+ parseAllDocuments,
28
+ parseDocument,
29
+ stringify,
30
+ visit,
31
+ visitAsync
32
+ } from "./chunk-UVL56Z6E.js";
33
+ import "./chunk-CZ7CSFO4.js";
34
+ export {
35
+ Alias,
36
+ cst_exports as CST,
37
+ Composer,
38
+ Document,
39
+ Lexer,
40
+ LineCounter,
41
+ Pair,
42
+ Parser,
43
+ Scalar,
44
+ Schema,
45
+ YAMLError,
46
+ YAMLMap,
47
+ YAMLParseError,
48
+ YAMLSeq,
49
+ YAMLWarning,
50
+ browser_default as default,
51
+ isAlias,
52
+ isCollection,
53
+ isDocument,
54
+ isMap,
55
+ isNode,
56
+ isPair,
57
+ isScalar,
58
+ isSeq,
59
+ parse,
60
+ parseAllDocuments,
61
+ parseDocument,
62
+ stringify,
63
+ visit,
64
+ visitAsync
65
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  CacheError
3
- } from "./chunk-RBAC33PQ.js";
3
+ } from "./chunk-LGIYBDWA.js";
4
4
  import {
5
5
  wrap
6
- } from "./chunk-2HHMABB6.js";
6
+ } from "./chunk-WFSQXYUT.js";
7
7
  import {
8
8
  JsonObject
9
9
  } from "./chunk-SATWJKN6.js";
@@ -51,10 +51,22 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
51
51
  let summaryBytes = 0;
52
52
  let batch = [];
53
53
  let batchBytes = 0;
54
- const flush = () => invoke(async () => {
55
- if (batch.length) await context.cache.write(batch, retention);
54
+ let flushes = 0;
55
+ const flush = () => Effect_exports.suspend(() => {
56
+ const entries = batch;
57
+ const bytes = batchBytes;
56
58
  batch = [];
57
59
  batchBytes = 0;
60
+ if (!entries.length) return Effect_exports.void;
61
+ return invoke(() => context.cache.write(entries, retention)).pipe(
62
+ Effect_exports.withSpan("app.cache.flush", {
63
+ attributes: {
64
+ "cache.flush.index": flushes++,
65
+ "cache.flush.entries": entries.length,
66
+ "cache.flush.bytes": bytes
67
+ }
68
+ })
69
+ );
58
70
  });
59
71
  const append = (entry) => Effect_exports.gen(function* () {
60
72
  const bytes = new TextEncoder().encode(JSON.stringify(entry)).byteLength;
@@ -0,0 +1,172 @@
1
+ import {
2
+ CacheAcquired,
3
+ CacheEntry,
4
+ CacheError,
5
+ cacheLimits
6
+ } from "./chunk-LGIYBDWA.js";
7
+ import {
8
+ Clock_exports,
9
+ Duration_exports,
10
+ Effect_exports,
11
+ Exit_exports,
12
+ Schema_exports
13
+ } from "./chunk-FW5HBOIK.js";
14
+
15
+ // ../app-cache/src/index.ts
16
+ var canonical = (value) => {
17
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
18
+ if (value !== null && typeof value === "object")
19
+ return `{${Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
20
+ return JSON.stringify(value);
21
+ };
22
+ var cacheKey = (key) => Effect_exports.gen(function* () {
23
+ const parsed = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(key).pipe(
24
+ Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
25
+ );
26
+ const bytes = new TextEncoder().encode(canonical(parsed));
27
+ if (bytes.byteLength > cacheLimits.keyBytes)
28
+ return yield* new CacheError({ reason: "capacity" });
29
+ const hash = yield* Effect_exports.tryPromise({
30
+ try: () => crypto.subtle.digest("SHA-256", bytes),
31
+ catch: () => new CacheError({ reason: "invalid" })
32
+ });
33
+ return [...new Uint8Array(hash)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
34
+ });
35
+ var makeCache = (host, background, scope = "shared", deadline) => {
36
+ const transport = (command) => host(command).pipe(
37
+ Effect_exports.withSpan("app.cache.command", {
38
+ attributes: { "cache.operation": command.operation }
39
+ })
40
+ );
41
+ const keyOf = (key) => cacheKey([scope, key]);
42
+ const readKeys = (keys) => transport({ operation: "read", keys }).pipe(
43
+ Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(Schema_exports.NullOr(CacheEntry)))),
44
+ Effect_exports.mapError(() => new CacheError({ reason: "storage" }))
45
+ );
46
+ const durations = (freshFor, staleFor = 0) => Effect_exports.try({
47
+ try: () => {
48
+ const fresh = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor));
49
+ const stale = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor));
50
+ if (![fresh, stale].every((value) => Number.isFinite(value) && value >= 0) || fresh + stale > cacheLimits.retentionMs)
51
+ throw new CacheError({ reason: "invalid" });
52
+ return { fresh, stale };
53
+ },
54
+ catch: () => new CacheError({ reason: "invalid" })
55
+ });
56
+ const get = (options, refresh) => Effect_exports.gen(function* () {
57
+ const key = yield* keyOf(options.key);
58
+ const { fresh, stale } = yield* durations(options.freshFor, options.staleFor);
59
+ const decode = (value) => Schema_exports.decodeUnknownEffect(options.schema)(value);
60
+ const load = (lease) => Effect_exports.gen(function* () {
61
+ const value = yield* options.load.pipe(Effect_exports.flatMap(decode));
62
+ const json = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(value).pipe(
63
+ Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
64
+ );
65
+ const now = yield* Clock_exports.currentTimeMillis;
66
+ const published = yield* transport({
67
+ operation: "publish",
68
+ key,
69
+ lease,
70
+ entry: {
71
+ value: json,
72
+ version: crypto.randomUUID(),
73
+ freshUntil: now + fresh,
74
+ staleUntil: now + fresh + stale
75
+ }
76
+ }).pipe(Effect_exports.withSpan("app.cache.publish"));
77
+ if (published !== true) return yield* new CacheError({ reason: "unavailable" });
78
+ return value;
79
+ }).pipe(
80
+ Effect_exports.withSpan("app.cache.load"),
81
+ Effect_exports.timeout(cacheLimits.loadTimeoutMs),
82
+ // Publishing clears the lease in the same transaction. Only an unpublished load releases it.
83
+ Effect_exports.onExit(
84
+ (exit) => Exit_exports.isSuccess(exit) ? Effect_exports.void : transport({ operation: "release", key, lease }).pipe(
85
+ Effect_exports.catch(() => Effect_exports.void)
86
+ )
87
+ )
88
+ );
89
+ const waitUntil = Math.min(
90
+ (yield* Clock_exports.currentTimeMillis) + cacheLimits.waitMs,
91
+ deadline ?? Number.POSITIVE_INFINITY
92
+ );
93
+ let initialVersion;
94
+ while (true) {
95
+ const { entry, lease } = yield* transport({
96
+ operation: "acquire",
97
+ key,
98
+ refresh,
99
+ ...initialVersion === void 0 ? {} : { version: initialVersion }
100
+ }).pipe(
101
+ Effect_exports.flatMap(
102
+ (reply) => Schema_exports.decodeUnknownEffect(CacheAcquired)(reply).pipe(
103
+ Effect_exports.mapError(() => new CacheError({ reason: "storage" }))
104
+ )
105
+ )
106
+ );
107
+ const now = yield* Clock_exports.currentTimeMillis;
108
+ if (initialVersion === void 0) initialVersion = entry?.version ?? null;
109
+ const refreshed = refresh && entry !== null && entry.version !== initialVersion;
110
+ if (entry !== null && (refreshed || !refresh && lease === null && now < entry.freshUntil)) {
111
+ yield* Effect_exports.annotateCurrentSpan("cache.result", "fresh");
112
+ return yield* decode(entry.value);
113
+ }
114
+ if (!refresh && entry !== null && now < entry.staleUntil) {
115
+ yield* Effect_exports.annotateCurrentSpan("cache.result", "stale");
116
+ if (lease !== null) yield* background(load(lease).pipe(Effect_exports.asVoid));
117
+ return yield* decode(entry.value);
118
+ }
119
+ if (lease !== null) {
120
+ yield* Effect_exports.annotateCurrentSpan("cache.result", "miss");
121
+ return yield* load(lease);
122
+ }
123
+ if (now >= waitUntil) {
124
+ yield* Effect_exports.annotateCurrentSpan("cache.result", "local");
125
+ return yield* options.load.pipe(
126
+ Effect_exports.flatMap(decode),
127
+ Effect_exports.timeout(cacheLimits.loadTimeoutMs),
128
+ Effect_exports.withSpan("app.cache.load", { attributes: { "cache.load.leased": false } })
129
+ );
130
+ }
131
+ yield* Effect_exports.sleep("100 millis");
132
+ }
133
+ }).pipe(Effect_exports.withSpan("app.cache.get"));
134
+ return {
135
+ /** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
136
+ read: (keys) => Effect_exports.forEach(keys, keyOf).pipe(Effect_exports.flatMap(readKeys)),
137
+ /** Publish bounded immutable parts before publishing the manifest that references them. */
138
+ write: (entries, retention) => Effect_exports.gen(function* () {
139
+ const { fresh } = yield* durations(retention);
140
+ const now = yield* Clock_exports.currentTimeMillis;
141
+ const values = yield* Effect_exports.forEach(
142
+ entries,
143
+ ({ key, value }) => Effect_exports.gen(function* () {
144
+ return {
145
+ key: yield* keyOf(key),
146
+ entry: {
147
+ value,
148
+ version: crypto.randomUUID(),
149
+ freshUntil: now + fresh,
150
+ staleUntil: now + fresh
151
+ }
152
+ };
153
+ })
154
+ );
155
+ yield* transport({ operation: "write", entries: values });
156
+ }),
157
+ /** Revoke retained data and any loader's right to publish its in-flight result. */
158
+ invalidate: (key) => keyOf(key).pipe(
159
+ Effect_exports.flatMap((key2) => transport({ operation: "invalidate", key: key2 })),
160
+ Effect_exports.asVoid
161
+ ),
162
+ /** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
163
+ get: (options) => get(options, false),
164
+ /** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
165
+ revalidate: (options) => get(options, true)
166
+ };
167
+ };
168
+
169
+ export {
170
+ cacheKey,
171
+ makeCache
172
+ };
@@ -1,6 +1,3 @@
1
- import {
2
- parseDocument
3
- } from "./chunk-NCYXZN2G.js";
4
1
  import {
5
2
  AppSkillMetadata,
6
3
  AppSkillName,
@@ -28,6 +25,7 @@ var skillFromFiles = (input, source = {}) => Effect_exports.gen(function* () {
28
25
  );
29
26
  if (match?.[1] === void 0) return yield* invalid("frontmatter");
30
27
  const frontmatter = match[1];
28
+ const { parseDocument } = (yield* Effect_exports.promise(() => import("./browser-XIPJGLH2.js"))).default;
31
29
  const value = yield* Effect_exports.try({
32
30
  try: () => {
33
31
  const yaml = parseDocument(frontmatter);
@@ -1784,10 +1784,7 @@ var AppUiApi = HttpApi_exports.make("app-ui").add(
1784
1784
  );
1785
1785
 
1786
1786
  export {
1787
- HttpApiEndpoint_exports,
1788
- HttpApi_exports,
1789
1787
  HttpApiClient_exports,
1790
- HttpApiGroup_exports,
1791
1788
  UiContext,
1792
1789
  UiOperation,
1793
1790
  UiUnauthorized,
@@ -2,7 +2,7 @@ import {
2
2
  adaptMcpTools,
3
3
  mcpClient,
4
4
  mcpJsonSchemaValidator
5
- } from "./chunk-X7SFGU4Q.js";
5
+ } from "./chunk-RN2MXB4R.js";
6
6
  import {
7
7
  accountProviderError,
8
8
  httpProviderError
@@ -11,7 +11,7 @@ import {
11
11
  McpError,
12
12
  McpToolsOptions,
13
13
  defaultMcpClientLimits
14
- } from "./chunk-IHQ4ML7K.js";
14
+ } from "./chunk-MYYEW3RA.js";
15
15
  import {
16
16
  ProviderError
17
17
  } from "./chunk-W7D7WVSY.js";
@@ -1,20 +1,20 @@
1
+ import {
2
+ makeCache
3
+ } from "./chunk-D47C7KG5.js";
1
4
  import {
2
5
  folderSkillsEffect
3
- } from "./chunk-ZTFQHGEB.js";
6
+ } from "./chunk-FDNTX5QJ.js";
4
7
  import {
5
- CacheEntry,
6
- CacheError,
7
8
  authorDatabase,
8
- cacheLimits,
9
9
  isApp,
10
10
  toEffectApp,
11
11
  unavailableStorage
12
- } from "./chunk-RBAC33PQ.js";
12
+ } from "./chunk-JN55AYQH.js";
13
13
  import {
14
14
  fromPromise,
15
15
  nativeOperation,
16
16
  toPromise
17
- } from "./chunk-PZ36XMXW.js";
17
+ } from "./chunk-PYUYJRSK.js";
18
18
  import {
19
19
  parseProviderError
20
20
  } from "./chunk-ZJWDMTE3.js";
@@ -62,7 +62,10 @@ import {
62
62
  defaultWebhookTransportLimits,
63
63
  maxInputProblems,
64
64
  workflowDurationMillis
65
- } from "./chunk-IHQ4ML7K.js";
65
+ } from "./chunk-MYYEW3RA.js";
66
+ import {
67
+ CacheError
68
+ } from "./chunk-LGIYBDWA.js";
66
69
  import {
67
70
  AppSkills,
68
71
  SkillFile,
@@ -79,7 +82,7 @@ import {
79
82
  decoderOf,
80
83
  importedJsonSchema,
81
84
  jsonSchemaDecoder
82
- } from "./chunk-2HHMABB6.js";
85
+ } from "./chunk-WFSQXYUT.js";
83
86
  import {
84
87
  JsonObject,
85
88
  JsonValue
@@ -87,7 +90,6 @@ import {
87
90
  import {
88
91
  Cause_exports,
89
92
  Clock_exports,
90
- Duration_exports,
91
93
  Effect_exports,
92
94
  Encoding_exports,
93
95
  Match_exports,
@@ -452,144 +454,14 @@ var dispatchWebhook = (definition, command, context, accounts) => Effect_exports
452
454
  );
453
455
  });
454
456
 
455
- // ../app-cache/src/index.ts
456
- var canonical = (value) => {
457
- if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
458
- if (value !== null && typeof value === "object")
459
- return `{${Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
460
- return JSON.stringify(value);
461
- };
462
- var cacheKey = (key) => Effect_exports.gen(function* () {
463
- const parsed = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(key).pipe(
464
- Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
465
- );
466
- const bytes = new TextEncoder().encode(canonical(parsed));
467
- if (bytes.byteLength > cacheLimits.keyBytes)
468
- return yield* new CacheError({ reason: "capacity" });
469
- const hash = yield* Effect_exports.tryPromise({
470
- try: () => crypto.subtle.digest("SHA-256", bytes),
471
- catch: () => new CacheError({ reason: "invalid" })
472
- });
473
- return [...new Uint8Array(hash)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
474
- });
475
- var makeCache = (transport, background, scope = "shared") => {
476
- const keyOf = (key) => cacheKey([scope, key]);
477
- const readKeys = (keys) => transport({ operation: "read", keys }).pipe(
478
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(Schema_exports.NullOr(CacheEntry)))),
479
- Effect_exports.mapError(() => new CacheError({ reason: "storage" }))
480
- );
481
- const durations = (freshFor, staleFor = 0) => Effect_exports.try({
482
- try: () => {
483
- const fresh = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor));
484
- const stale = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor));
485
- if (![fresh, stale].every((value) => Number.isFinite(value) && value >= 0) || fresh + stale > cacheLimits.retentionMs)
486
- throw new CacheError({ reason: "invalid" });
487
- return { fresh, stale };
488
- },
489
- catch: () => new CacheError({ reason: "invalid" })
490
- });
491
- const get = (options, refresh) => Effect_exports.gen(function* () {
492
- const key = yield* keyOf(options.key);
493
- const { fresh, stale } = yield* durations(options.freshFor, options.staleFor);
494
- const decode = (value) => Schema_exports.decodeUnknownEffect(options.schema)(value);
495
- const load = (lease) => Effect_exports.gen(function* () {
496
- const value = yield* options.load.pipe(Effect_exports.flatMap(decode));
497
- const json = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(value).pipe(
498
- Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
499
- );
500
- const now = yield* Clock_exports.currentTimeMillis;
501
- const published = yield* transport({
502
- operation: "publish",
503
- key,
504
- lease,
505
- entry: {
506
- value: json,
507
- version: crypto.randomUUID(),
508
- freshUntil: now + fresh,
509
- staleUntil: now + fresh + stale
510
- }
511
- });
512
- if (published !== true) return yield* new CacheError({ reason: "unavailable" });
513
- return value;
514
- }).pipe(
515
- Effect_exports.withSpan("app.cache.load"),
516
- Effect_exports.timeout(cacheLimits.loadTimeoutMs),
517
- Effect_exports.ensuring(
518
- transport({ operation: "release", key, lease }).pipe(Effect_exports.catch(() => Effect_exports.void))
519
- )
520
- );
521
- const deadline = (yield* Clock_exports.currentTimeMillis) + cacheLimits.leaseMs;
522
- let initialVersion;
523
- while (true) {
524
- const entry = (yield* readKeys([key]))[0] ?? null;
525
- const now = yield* Clock_exports.currentTimeMillis;
526
- if (initialVersion === void 0) initialVersion = entry?.version ?? null;
527
- const refreshed = refresh && entry !== null && entry.version !== initialVersion;
528
- if (entry !== null && (refreshed || !refresh && now < entry.freshUntil)) {
529
- yield* Effect_exports.annotateCurrentSpan("cache.result", "fresh");
530
- return yield* decode(entry.value);
531
- }
532
- const lease = yield* transport({
533
- operation: "claim",
534
- key,
535
- version: entry?.version ?? null
536
- }).pipe(Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.NullOr(Schema_exports.String))));
537
- if (!refresh && entry !== null && now < entry.staleUntil) {
538
- yield* Effect_exports.annotateCurrentSpan("cache.result", "stale");
539
- if (lease !== null) yield* background(load(lease).pipe(Effect_exports.asVoid));
540
- return yield* decode(entry.value);
541
- }
542
- if (lease !== null) {
543
- yield* Effect_exports.annotateCurrentSpan("cache.result", "miss");
544
- return yield* load(lease);
545
- }
546
- if (now >= deadline) return yield* new CacheError({ reason: "timeout" });
547
- yield* Effect_exports.sleep("100 millis");
548
- }
549
- }).pipe(Effect_exports.withSpan("app.cache.get"));
550
- return {
551
- /** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
552
- read: (keys) => Effect_exports.forEach(keys, keyOf).pipe(Effect_exports.flatMap(readKeys)),
553
- /** Publish bounded immutable parts before publishing the manifest that references them. */
554
- write: (entries, retention) => Effect_exports.gen(function* () {
555
- const { fresh } = yield* durations(retention);
556
- const now = yield* Clock_exports.currentTimeMillis;
557
- const values = yield* Effect_exports.forEach(
558
- entries,
559
- ({ key, value }) => Effect_exports.gen(function* () {
560
- return {
561
- key: yield* keyOf(key),
562
- entry: {
563
- value,
564
- version: crypto.randomUUID(),
565
- freshUntil: now + fresh,
566
- staleUntil: now + fresh
567
- }
568
- };
569
- })
570
- );
571
- yield* transport({ operation: "write", entries: values });
572
- }),
573
- /** Revoke retained data and any loader's right to publish its in-flight result. */
574
- invalidate: (key) => keyOf(key).pipe(
575
- Effect_exports.flatMap((key2) => transport({ operation: "invalidate", key: key2 })),
576
- Effect_exports.asVoid
577
- ),
578
- /** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
579
- get: (options) => get(options, false),
580
- /** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
581
- revalidate: (options) => get(options, true)
582
- };
583
- };
584
-
585
457
  // src/implementation/cache.ts
586
458
  var unavailableCache = {
587
459
  transport: () => Effect_exports.fail(new CacheError({ reason: "unavailable" })),
588
460
  background: () => Effect_exports.die(new Error("Cache background runner is unavailable"))
589
461
  };
590
- var authorCache = (host, accounts, signal) => {
462
+ var authorCache = (host, accounts, signal, deadline) => {
591
463
  const scoped = (scope, callerSignal = signal) => {
592
- const cache = makeCache(host.transport, host.background, scope);
464
+ const cache = makeCache(host.transport, host.background, scope, deadline);
593
465
  const load = (method, options) => cache[method]({
594
466
  key: options.key,
595
467
  schema: decoderOf(options.schema),
@@ -641,7 +513,7 @@ var authorCache = (host, accounts, signal) => {
641
513
  const bound = Object.values(accounts).flatMap((value) => Array.isArray(value) ? value : [value]).find((value) => value.id === account.id);
642
514
  if (bound === void 0) throw new CacheError({ reason: "invalid" });
643
515
  return scoped(
644
- { account: bound.id, method: bound.method, fields: bound.fields },
516
+ { account: bound.id, method: bound.method, generation: bound.generation },
645
517
  callerSignal
646
518
  );
647
519
  }
@@ -728,10 +600,10 @@ function requirements(slots, database) {
728
600
  }).pipe(Effect_exports.mapError(() => new HostDeclarationInvalid()));
729
601
  });
730
602
  }
731
- function canonical2(value) {
732
- if (Array.isArray(value)) return `[${value.map(canonical2).join(",")}]`;
603
+ function canonical(value) {
604
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
733
605
  if (value !== null && typeof value === "object") {
734
- return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical2(item)}`).join(",")}}`;
606
+ return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
735
607
  }
736
608
  return JSON.stringify(value);
737
609
  }
@@ -760,7 +632,7 @@ function bindAccounts(slots, declarations, context) {
760
632
  for (const account of accounts) {
761
633
  if (ids.has(account.id)) return yield* Effect_exports.fail(new HostAccountsInvalid());
762
634
  ids.add(account.id);
763
- if (canonical2(account.provider) !== canonical2(requirement.definition) || !Object.hasOwn(provider.auth, account.method))
635
+ if (canonical(account.provider) !== canonical(requirement.definition) || !Object.hasOwn(provider.auth, account.method))
764
636
  return yield* Effect_exports.fail(new HostAccountsInvalid());
765
637
  const method = provider.auth[account.method];
766
638
  if (method === void 0) return yield* Effect_exports.fail(new HostAccountsInvalid());
@@ -855,7 +727,8 @@ function dispatch(app, request, context, signal) {
855
727
  cache: authorCache(
856
728
  context.cache ?? unavailableCache,
857
729
  Redacted_exports.value(context.accounts),
858
- invocationSignal
730
+ invocationSignal,
731
+ deadline
859
732
  ),
860
733
  files,
861
734
  ...yield* bindAccounts(native.accounts, declared, context).pipe(
@@ -1283,6 +1156,5 @@ var createAppHandler = (app) => (request, context) => Effect_exports.gen(functio
1283
1156
  export {
1284
1157
  prepareElicitation,
1285
1158
  ApprovalDecision,
1286
- cacheKey,
1287
1159
  createAppHandler
1288
1160
  };
@@ -5,15 +5,15 @@ import {
5
5
  import {
6
6
  fromPromise,
7
7
  nativeOperation
8
- } from "./chunk-PZ36XMXW.js";
8
+ } from "./chunk-PYUYJRSK.js";
9
9
  import {
10
10
  ScheduleTiming
11
- } from "./chunk-IHQ4ML7K.js";
11
+ } from "./chunk-MYYEW3RA.js";
12
12
  import {
13
13
  decoderOf,
14
14
  isSchema,
15
15
  storageFieldOf
16
- } from "./chunk-2HHMABB6.js";
16
+ } from "./chunk-WFSQXYUT.js";
17
17
  import {
18
18
  AppStorageUnavailable
19
19
  } from "./chunk-FZJOYIZO.js";
@@ -25,55 +25,6 @@ import {
25
25
  Schema_exports
26
26
  } from "./chunk-FW5HBOIK.js";
27
27
 
28
- // ../app-cache/src/contracts/cache.ts
29
- var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
30
- reason: Schema_exports.Literals(["unavailable", "storage", "invalid", "capacity", "timeout"])
31
- }) {
32
- };
33
- var cacheLimits = {
34
- keyBytes: 8192,
35
- entryBytes: 2e6,
36
- batchBytes: 8e6,
37
- batchEntries: 128,
38
- totalBytes: 128e6,
39
- totalEntries: 1e5,
40
- retentionMs: 7 * 24 * 60 * 60 * 1e3,
41
- loadTimeoutMs: 9e4,
42
- leaseMs: 12e4
43
- };
44
- var Key = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{64}$/));
45
- var Time = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
46
- var CacheEntry = Schema_exports.Struct({
47
- value: Schema_exports.Json,
48
- version: Schema_exports.String,
49
- freshUntil: Time,
50
- staleUntil: Time
51
- });
52
- var CacheCommand = Schema_exports.Union([
53
- Schema_exports.Struct({ operation: Schema_exports.Literal("read"), keys: Schema_exports.Array(Key) }),
54
- Schema_exports.Struct({
55
- operation: Schema_exports.Literal("claim"),
56
- key: Key,
57
- version: Schema_exports.NullOr(Schema_exports.String)
58
- }),
59
- Schema_exports.Struct({
60
- operation: Schema_exports.Literal("publish"),
61
- key: Key,
62
- lease: Schema_exports.String,
63
- entry: CacheEntry
64
- }),
65
- Schema_exports.Struct({ operation: Schema_exports.Literal("release"), key: Key, lease: Schema_exports.String }),
66
- Schema_exports.Struct({
67
- operation: Schema_exports.Literal("write"),
68
- entries: Schema_exports.Array(Schema_exports.Struct({ key: Key, entry: CacheEntry }))
69
- }),
70
- Schema_exports.Struct({ operation: Schema_exports.Literal("invalidate"), key: Key })
71
- ]);
72
- var CacheReply = Schema_exports.Union([
73
- Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: Schema_exports.Json }),
74
- Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: CacheError })
75
- ]);
76
-
77
28
  // src/implementation/workflows.ts
78
29
  var NativeWorkflow = /* @__PURE__ */ Symbol("apps.Workflow");
79
30
  var workflow = (options, run) => ({
@@ -251,11 +202,6 @@ var unavailableStorage = {
251
202
  };
252
203
 
253
204
  export {
254
- CacheError,
255
- cacheLimits,
256
- CacheEntry,
257
- CacheCommand,
258
- CacheReply,
259
205
  workflow,
260
206
  isApp,
261
207
  toEffectApp,