@yaklabs-ai/plugin-sdk 0.13.4 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kay-app.js CHANGED
@@ -1,3 +1,16 @@
1
+ // packages/plugin-protocol/dist/json.js
2
+ import { z } from "zod";
3
+ var JsonValue = z.lazy(() => z.union([
4
+ z.string(),
5
+ z.number(),
6
+ z.boolean(),
7
+ z.null(),
8
+ z.array(JsonValue),
9
+ z.record(z.string(), JsonValue)
10
+ ]));
11
+ var JsonObject = z.record(z.string(), JsonValue);
12
+ var JsonSchema = z.record(z.string(), JsonValue);
13
+
1
14
  // packages/plugin-sdk/dist/jev.js
2
15
  var JevCallError = class extends Error {
3
16
  transport;
@@ -73,7 +86,7 @@ function createFallbackOnlyWithJev() {
73
86
  }
74
87
 
75
88
  // packages/plugin-sdk/dist/signals.js
76
- import { z } from "zod";
89
+ import { z as z2 } from "zod";
77
90
  function createFallbackOnlySignals() {
78
91
  const noStore = { status: "unavailable", reason: "no-store" };
79
92
  return {
@@ -103,23 +116,23 @@ var POINTER = /^[^\s\p{C}/?#]+$/u;
103
116
  var LABEL = /^[^\s,@\p{C}]+(?: [^\s,@\p{C}]+)*$/u;
104
117
  var RUN_ID = /^\P{Cc}+$/u;
105
118
  var POINTER_RULE = `1 to ${MAX_POINTER} characters with no whitespace, \`/\`, \`?\`, \`#\`, or control or invisible character`;
106
- var ObserveShape = z.looseObject({
107
- detector: z.looseObject({ id: z.string(), version: z.string() }),
108
- subject: z.looseObject({ kind: z.string(), key: z.string().optional() }).optional(),
109
- after: z.looseObject({ observationId: z.unknown() }).optional(),
110
- reuse: z.looseObject({ maxAgeMs: z.unknown() }).optional(),
111
- source: z.looseObject({
112
- sessionId: z.string(),
113
- entryId: z.string(),
114
- openerEntryId: z.string().optional(),
115
- runId: z.string().optional(),
116
- occurredAtMs: z.unknown().optional()
119
+ var ObserveShape = z2.looseObject({
120
+ detector: z2.looseObject({ id: z2.string(), version: z2.string() }),
121
+ subject: z2.looseObject({ kind: z2.string(), key: z2.string().optional() }).optional(),
122
+ after: z2.looseObject({ observationId: z2.unknown() }).optional(),
123
+ reuse: z2.looseObject({ maxAgeMs: z2.unknown() }).optional(),
124
+ source: z2.looseObject({
125
+ sessionId: z2.string(),
126
+ entryId: z2.string(),
127
+ openerEntryId: z2.string().optional(),
128
+ runId: z2.string().optional(),
129
+ occurredAtMs: z2.unknown().optional()
117
130
  }),
118
- questions: z.record(z.string(), z.unknown())
131
+ questions: z2.record(z2.string(), z2.unknown())
119
132
  });
120
- var ChoiceQuestion = z.looseObject({
121
- type: z.literal("choice"),
122
- criteria: z.record(z.string(), z.unknown())
133
+ var ChoiceQuestion = z2.looseObject({
134
+ type: z2.literal("choice"),
135
+ criteria: z2.record(z2.string(), z2.unknown())
123
136
  });
124
137
  var fits = (value, grammar) => value.length <= MAX_NAME && grammar.test(value);
125
138
  var isWhole = (value, min) => typeof value === "number" && Number.isSafeInteger(value) && value >= min && value <= SIGNAL_TIME_MAX_MS;
@@ -199,10 +212,10 @@ function grammarProblem(input) {
199
212
  }
200
213
  return void 0;
201
214
  }
202
- var EchoText = z.string().catch("");
203
- var Echo = z.object({
204
- detector: z.object({ id: EchoText, version: EchoText }).catch({ id: "", version: "" }),
205
- source: z.object({ sessionId: EchoText, entryId: EchoText }).catch({ sessionId: "", entryId: "" })
215
+ var EchoText = z2.string().catch("");
216
+ var Echo = z2.object({
217
+ detector: z2.object({ id: EchoText, version: EchoText }).catch({ id: "", version: "" }),
218
+ source: z2.object({ sessionId: EchoText, entryId: EchoText }).catch({ sessionId: "", entryId: "" })
206
219
  }).catch({
207
220
  detector: { id: "", version: "" },
208
221
  source: { sessionId: "", entryId: "" }
@@ -258,6 +271,8 @@ var UriProviderError = class extends UriError {
258
271
  retryable;
259
272
  /** Provider-directed delay before retrying, in milliseconds. */
260
273
  retryAfterMs;
274
+ /** See {@link UriProviderErrorOptions.effect}. */
275
+ effect;
261
276
  constructor(options) {
262
277
  super(options.message);
263
278
  this.name = "UriProviderError";
@@ -276,6 +291,8 @@ var UriProviderError = class extends UriError {
276
291
  }
277
292
  this.retryAfterMs = options.retryAfterMs;
278
293
  }
294
+ if (options.effect !== void 0)
295
+ this.effect = options.effect;
279
296
  }
280
297
  };
281
298
  var UriNotFoundError = class extends UriError {
@@ -304,7 +321,7 @@ var UriUnsupportedOperationError = class extends UriError {
304
321
  };
305
322
 
306
323
  // packages/herd-uri/dist/operations.js
307
- import { z as z2 } from "zod";
324
+ import { z as z3 } from "zod";
308
325
  var URI_OPERATIONS = [
309
326
  "help",
310
327
  "read",
@@ -314,44 +331,44 @@ var URI_OPERATIONS = [
314
331
  "search",
315
332
  "delete"
316
333
  ];
317
- var UriOperationSchema = z2.enum(URI_OPERATIONS);
334
+ var UriOperationSchema = z3.enum(URI_OPERATIONS);
318
335
 
319
336
  // packages/herd-uri/dist/help-schema.js
320
- import { z as z3 } from "zod";
321
- var UriContractJsonSchema = z3.record(z3.string(), z3.unknown());
322
- var UriParameterSchema = z3.strictObject({
323
- name: z3.string().min(1),
324
- in: z3.enum(["uri", "query", "selector"]),
325
- required: z3.boolean(),
326
- description: z3.string().optional(),
337
+ import { z as z4 } from "zod";
338
+ var UriContractJsonSchema = z4.record(z4.string(), z4.unknown());
339
+ var UriParameterSchema = z4.strictObject({
340
+ name: z4.string().min(1),
341
+ in: z4.enum(["uri", "query", "selector"]),
342
+ required: z4.boolean(),
343
+ description: z4.string().optional(),
327
344
  schema: UriContractJsonSchema,
328
- examples: z3.array(z3.unknown()).optional()
345
+ examples: z4.array(z4.unknown()).optional()
329
346
  });
330
- var UriPayloadContractSchema = z3.strictObject({
331
- name: z3.string().min(1),
332
- mediaType: z3.string().optional(),
333
- description: z3.string().optional(),
347
+ var UriPayloadContractSchema = z4.strictObject({
348
+ name: z4.string().min(1),
349
+ mediaType: z4.string().optional(),
350
+ description: z4.string().optional(),
334
351
  schema: UriContractJsonSchema.optional(),
335
- semanticConstraints: z3.array(z3.string().min(1)).min(1).optional(),
336
- examples: z3.array(z3.unknown()).optional()
352
+ semanticConstraints: z4.array(z4.string().min(1)).min(1).optional(),
353
+ examples: z4.array(z4.unknown()).optional()
337
354
  });
338
355
 
339
356
  // packages/herd-uri/dist/text-edit.js
340
- import { z as z4 } from "zod";
341
- var findReplaceArm = z4.strictObject({
342
- find: z4.string().min(1),
343
- replace: z4.string(),
344
- all: z4.boolean().optional()
357
+ import { z as z5 } from "zod";
358
+ var findReplaceArm = z5.strictObject({
359
+ find: z5.string().min(1),
360
+ replace: z5.string(),
361
+ all: z5.boolean().optional()
345
362
  });
346
- var oldNewEntry = z4.strictObject({
347
- oldText: z4.string().min(1),
348
- newText: z4.string()
363
+ var oldNewEntry = z5.strictObject({
364
+ oldText: z5.string().min(1),
365
+ newText: z5.string()
349
366
  });
350
- var uriTextEditPayloadArms = z4.union([
367
+ var uriTextEditPayloadArms = z5.union([
351
368
  findReplaceArm,
352
- z4.strictObject({ edits: z4.array(oldNewEntry).min(1) }),
369
+ z5.strictObject({ edits: z5.array(oldNewEntry).min(1) }),
353
370
  oldNewEntry,
354
- z4.array(oldNewEntry).min(1)
371
+ z5.array(oldNewEntry).min(1)
355
372
  ]);
356
373
 
357
374
  // packages/herd-uri/dist/line-selector.js
@@ -447,10 +464,10 @@ function parseLineSelector(input) {
447
464
  }
448
465
 
449
466
  // packages/herd-uri/dist/schema/to-json-schema.js
450
- import { z as z5 } from "zod";
467
+ import { z as z6 } from "zod";
451
468
  function toJsonSchema(schema) {
452
- if (schema instanceof z5.ZodType) {
453
- const { $schema: _dialect, ...value } = z5.toJSONSchema(schema, {
469
+ if (schema instanceof z6.ZodType) {
470
+ const { $schema: _dialect, ...value } = z6.toJSONSchema(schema, {
454
471
  // `io: "input"` describes what a caller may SEND, which is what a parameter and an
455
472
  // `accepts` payload advertise: a field with a Zod default is optional on the wire even
456
473
  // though the parsed value always carries it. Strictness still survives where the validator
@@ -573,8 +590,11 @@ var KAY_APP_AUTOMATION_CONDITION_KINDS = [
573
590
  ];
574
591
  export {
575
592
  JevCallError,
593
+ JsonSchema,
594
+ JsonValue,
576
595
  KAY_APP_AUTOMATION_CONDITION_KINDS,
577
596
  KAY_APP_DATA_CHANGE_MAX_BYTES,
597
+ KAY_APP_DATA_SNAPSHOT_MAX_BYTES,
578
598
  KayAppWorkflowFailure,
579
599
  MAX_CHOICE_LABELS,
580
600
  SIGNAL_TIME_MAX_MS,
@@ -62,7 +62,7 @@ export declare interface PhaseShiftTimelineChange {
62
62
  * version-1 record's source timestamps from the entries it referenced. Those
63
63
  * references are branch-validated by the fold, so the resolution is total.
64
64
  */
65
- export declare function phaseShiftTimelineFromEntries(entries: readonly TranscriptSourceEntry[]): readonly PhaseShiftTimelineRecord[];
65
+ export declare function phaseShiftTimelineFromEntries(entries: readonly TranscriptSourceEntryLike[]): readonly PhaseShiftTimelineRecord[];
66
66
 
67
67
  /**
68
68
  * One accepted detector check, as a surface reads it.
@@ -96,7 +96,7 @@ export declare interface PhaseShiftTimelineRecord {
96
96
  }
97
97
 
98
98
  /** The fields the customType selector needs off a session entry. */
99
- declare interface TranscriptEntry {
99
+ declare interface TranscriptEntryLike {
100
100
  readonly id: string;
101
101
  readonly type: string;
102
102
  readonly customType?: string;
@@ -108,7 +108,7 @@ declare interface TranscriptEntry {
108
108
  * A tree entry plus the ISO timestamp the timeline projections read alongside
109
109
  * the walk result (`turnSegments`, `phaseShiftTimelineFromEntries`).
110
110
  */
111
- declare interface TranscriptSourceEntry extends TranscriptTreeEntry {
111
+ declare interface TranscriptSourceEntryLike extends TranscriptTreeEntryLike {
112
112
  readonly timestamp: string;
113
113
  }
114
114
 
@@ -119,7 +119,7 @@ declare interface TranscriptSourceEntry extends TranscriptTreeEntry {
119
119
  * v3 log carries an ISO string, so requiring either shape here would force one
120
120
  * class of caller to convert entries it only wants walked.
121
121
  */
122
- declare interface TranscriptTreeEntry extends TranscriptEntry {
122
+ declare interface TranscriptTreeEntryLike extends TranscriptEntryLike {
123
123
  readonly parentId?: string | null;
124
124
  readonly targetId?: string | null;
125
125
  }
@@ -1,7 +1,13 @@
1
1
  // packages/plugin-protocol/dist/phase-shift.js
2
- import { z } from "zod";
2
+ import { z as z2 } from "zod";
3
3
 
4
4
  // packages/plugin-protocol/dist/transcript.js
5
+ import { z } from "zod";
6
+ var WorkBlockCoverageSchema = z.strictObject({
7
+ firstToolResultEntryId: z.string().min(1),
8
+ lastToolResultEntryId: z.string().min(1),
9
+ toolResultEntryIds: z.array(z.string().min(1)).min(1).max(4096)
10
+ }).refine((value) => value.firstToolResultEntryId === value.toolResultEntryIds[0] && value.lastToolResultEntryId === value.toolResultEntryIds.at(-1) && new Set(value.toolResultEntryIds).size === value.toolResultEntryIds.length);
5
11
  function branchEntryIds(entries) {
6
12
  const last = entries[entries.length - 1];
7
13
  if (last === void 0)
@@ -23,48 +29,48 @@ var PHASE_SHIFT_ENTRY_NAME = "observation";
23
29
  var PHASE_SHIFT_CUSTOM_TYPE = `ext:${PHASE_SHIFT_EXTENSION_ID}:${PHASE_SHIFT_ENTRY_NAME}`;
24
30
  var PHASE_SHIFT_TIMELINE_CUSTOM_TYPE = `ext:${PHASE_SHIFT_EXTENSION_ID}:timeline`;
25
31
  var PHASE_SHIFT_DETECTOR_VERSION = "activity-memory-v1";
26
- var entryId = z.string().min(1).max(256);
27
- var purpose = z.string().trim().min(1).max(320);
28
- var sourceTime = z.iso.datetime();
29
- var phaseShiftMemorySchema = z.object({
32
+ var entryId = z2.string().min(1).max(256);
33
+ var purpose = z2.string().trim().min(1).max(320);
34
+ var sourceTime = z2.iso.datetime();
35
+ var phaseShiftMemorySchema = z2.object({
30
36
  startEntryId: entryId,
31
37
  purpose,
32
- anchors: z.array(z.object({ entryId, excerpt: z.string().max(250) })).min(1).max(3)
38
+ anchors: z2.array(z2.object({ entryId, excerpt: z2.string().max(250) })).min(1).max(3)
33
39
  });
34
- var phaseShiftCostSchema = z.object({
35
- amountUsd: z.number().nonnegative(),
36
- amountBasis: z.enum(["measured", "list-estimate", "unknown"]),
37
- inputTokens: z.number().int().nonnegative(),
38
- outputTokens: z.number().int().nonnegative(),
40
+ var phaseShiftCostSchema = z2.object({
41
+ amountUsd: z2.number().nonnegative(),
42
+ amountBasis: z2.enum(["measured", "list-estimate", "unknown"]),
43
+ inputTokens: z2.number().int().nonnegative(),
44
+ outputTokens: z2.number().int().nonnegative(),
39
45
  /**
40
46
  * The highest provider-attempt ordinal this check accounted for; recovery
41
47
  * after a failure makes it more than one. An attempt that threw before
42
48
  * reporting usage is invisible to accounting, so this is a lower bound on
43
49
  * what the provider was actually asked to do.
44
50
  */
45
- attempts: z.number().int().positive()
51
+ attempts: z2.number().int().positive()
46
52
  });
47
53
  var observationFields = {
48
- detectorVersion: z.literal(PHASE_SHIFT_DETECTOR_VERSION),
49
- modelReference: z.string().min(1).max(256),
50
- observedAt: z.iso.datetime(),
54
+ detectorVersion: z2.literal(PHASE_SHIFT_DETECTOR_VERSION),
55
+ modelReference: z2.string().min(1).max(256),
56
+ observedAt: z2.iso.datetime(),
51
57
  throughEntryId: entryId,
52
- windowEntryIds: z.array(entryId).min(1).max(40),
58
+ windowEntryIds: z2.array(entryId).min(1).max(40),
53
59
  memory: phaseShiftMemorySchema
54
60
  };
55
61
  var changeFields = {
56
62
  startEntryId: entryId,
57
- relation: z.enum(["outcome", "phase"]),
58
- reason: z.string().trim().min(1).max(2e3),
63
+ relation: z2.enum(["outcome", "phase"]),
64
+ reason: z2.string().trim().min(1).max(2e3),
59
65
  purposeAfter: purpose
60
66
  };
61
- var phaseShiftObservationV1Schema = z.object({
62
- version: z.literal(1),
67
+ var phaseShiftObservationV1Schema = z2.object({
68
+ version: z2.literal(1),
63
69
  ...observationFields,
64
- changes: z.array(z.object(changeFields)).max(39)
70
+ changes: z2.array(z2.object(changeFields)).max(39)
65
71
  });
66
- var phaseShiftObservationV2Schema = z.object({
67
- version: z.literal(2),
72
+ var phaseShiftObservationV2Schema = z2.object({
73
+ version: z2.literal(2),
68
74
  ...observationFields,
69
75
  /** Timestamp of the `windowEntryIds[0]` entry: where this check's coverage starts. */
70
76
  windowStartAt: sourceTime,
@@ -72,13 +78,13 @@ var phaseShiftObservationV2Schema = z.object({
72
78
  throughAt: sourceTime,
73
79
  /** What this check cost to run; absent on a record written before it was accounted. */
74
80
  cost: phaseShiftCostSchema.optional(),
75
- changes: z.array(z.object({
81
+ changes: z2.array(z2.object({
76
82
  ...changeFields,
77
83
  /** Timestamp of the `startEntryId` entry: when the new work began. */
78
84
  startedAt: sourceTime
79
85
  })).max(39)
80
86
  });
81
- var phaseShiftObservationSchema = z.discriminatedUnion("version", [
87
+ var phaseShiftObservationSchema = z2.discriminatedUnion("version", [
82
88
  phaseShiftObservationV1Schema,
83
89
  phaseShiftObservationV2Schema
84
90
  ]);
package/dist/time.d.ts ADDED
@@ -0,0 +1,157 @@
1
+ import { Temporal as Temporal_2 } from '@js-temporal/polyfill';
2
+
3
+ /**
4
+ * The id ICU resolves for an IANA time-zone id, or `undefined` when `id` is not one.
5
+ *
6
+ * Accepts `UTC`, `GMT`, and any id that contains `/` and that ICU resolves. Rejects
7
+ * abbreviations and slash-less legacy ids (`EST`, `CET`, `EST5EDT`), offsets (`+05:30`,
8
+ * `UTC+2`), the empty string, strings over 64 characters and non-strings. ICU maps link
9
+ * names to its own canonical id (`Asia/Kolkata` to `Asia/Calcutta`), and which spelling is
10
+ * canonical depends on the engine, so compare zones with {@link sameZone}, never with `===`.
11
+ */
12
+ export declare function canonicalZone(id: unknown): string | undefined;
13
+
14
+ /** True when {@link canonicalZone} accepts `id`. */
15
+ export declare function isValidZone(id: unknown): boolean;
16
+
17
+ /**
18
+ * `app.time` / `api.time`: host facts about time. Added to `kay.app` in SDK 0.12.1 and to
19
+ * `kay.agent` with the calendar zone-of-record work: a plugin that calls it declares
20
+ * `compatibility.sdk` `^0.12.1`, so an older Bonsai refuses a directory or repository plugin at
21
+ * load instead of the call failing.
22
+ */
23
+ export declare interface KayAppTime {
24
+ /**
25
+ * Reads the daemon's clock and the user's time zone now.
26
+ *
27
+ * Every call asks the host again and returns a new object; nothing is cached. Call it where you
28
+ * need the value (inside a tool, a handler or a workflow step), not inside `activate()`: a value
29
+ * read there is as old as the activation, and the host can run a bundled plugin's `activate()`
30
+ * against a recording api that has no `time`, so a read there throws. The exception is a
31
+ * directory plugin that declares a workflow with a cron `timezone`: `workflows.define` is legal
32
+ * only during `activate()`, so it reads the zone there, and the schedule then keeps that zone.
33
+ * Keep the result for as long as you use it, and not across a long wait (a sleep, a timer, a
34
+ * queued run): the zone can change while you wait. On a daemon that runs on the user's machine,
35
+ * a change of the process's `TZ` shows in the next call. A `TZ` that names a zone wins over the
36
+ * operating system's zone, so a change of the operating-system zone does not show while the
37
+ * process has one. When `TZ` is unset or does not name a zone, a change of the operating-system
38
+ * zone is meant to show, but none has been seen on a real machine yet.
39
+ *
40
+ * A zone the host cannot determine is an answer (`zoneSource: "utc-fallback"`), not an error.
41
+ *
42
+ * Use this to find the zone, not `Intl.DateTimeFormat().resolvedOptions().timeZone`, which can
43
+ * keep a zone the runtime read earlier, or `process.env.TZ`, which is often unset or not a zone.
44
+ * Neither says that the zone is unknown.
45
+ *
46
+ * It does not use `this`, so it is safe to destructure.
47
+ */
48
+ readonly snapshot: () => KayAppTimeSnapshot;
49
+ }
50
+
51
+ /**
52
+ * The plugin-facing time contract: the daemon's clock and the time zone the user is in,
53
+ * read together in one call.
54
+ *
55
+ * Ungated and always present, like `app.paths`. It confers no authority: a plugin runs in the
56
+ * daemon's process and can already read the clock. What the door adds is the daemon's answer
57
+ * for the USER's zone, and a label for the case where that answer is unknown.
58
+ *
59
+ * This is a leaf module. It lives beside both target SDKs (rather than inside `kay-app`) so the
60
+ * `kay.agent` SDK can expose the same door without importing the `kay.app` surface, which pulls
61
+ * that surface into every agent-facing bundle.
62
+ */
63
+ /** One reading of the daemon's clock and the user's time zone. Each call returns a new object. */
64
+ export declare interface KayAppTimeSnapshot {
65
+ /** The daemon's clock when the snapshot was read: milliseconds since the Unix epoch. */
66
+ readonly nowMs: number;
67
+ /**
68
+ * The time zone the user is in, as an IANA id in the spelling ICU resolves (`America/New_York`).
69
+ * One zone can have two ids, and ICU picks one: `Asia/Kolkata` comes back as `Asia/Calcutta`. So
70
+ * never compare zone ids with `===`: compare with `sameZone` from `@bonsai/plugin-sdk/time`. Pass
71
+ * `zone` as the `timeZone` of `Intl.DateTimeFormat` or `toLocaleString` to format a time for the
72
+ * user.
73
+ *
74
+ * When `zoneSource` is `utc-fallback` the zone is unknown, and this value is `UTC` only because a
75
+ * value is required.
76
+ */
77
+ readonly zone: string;
78
+ /**
79
+ * How the daemon found `zone`.
80
+ * - `host`: the daemon runs on the user's machine, and `zone` is the zone the daemon process
81
+ * runs in, read for this call: the process's `TZ` when that names a zone, otherwise the
82
+ * operating system's zone.
83
+ * - `utc-fallback`: the daemon does not know the user's zone. It runs on another machine (a remote
84
+ * daemon), or the machine's zone could not be read or is not an IANA id. `zone` is `UTC`, which
85
+ * here is a placeholder and not a fact about the user: do not show it to the user as their zone.
86
+ */
87
+ readonly zoneSource: "host" | "utc-fallback";
88
+ }
89
+
90
+ /** True when both ids are valid and ICU resolves them to the same zone. */
91
+ export declare function sameZone(a: unknown, b: unknown): boolean;
92
+
93
+ /**
94
+ * The Temporal API of this process: the engine's own `globalThis.Temporal` when it has one
95
+ * (Electron's runtime does, Node 24 does not), and `@js-temporal/polyfill`'s otherwise.
96
+ * `temporalImplementation` says which.
97
+ *
98
+ * It is a value and, through the namespace below, a type namespace: `Temporal.Instant` and
99
+ * `Temporal.ZonedDateTime` name both the classes and their instance types.
100
+ */
101
+ export declare const Temporal: TemporalApi;
102
+
103
+ /**
104
+ * The types of `@js-temporal/polyfill`'s `Temporal` namespace, so code can write
105
+ * `Temporal.Instant` as a type. `Now` and `DateTimeFormat` are left out on purpose: time
106
+ * that logic depends on comes from a `Clock`, and the polyfill's `Intl` export is not part of
107
+ * this API. `test/temporal.test.ts` fails when a new polyfill version adds a type that this
108
+ * list lacks.
109
+ */
110
+ export declare namespace Temporal {
111
+ export type ComparisonResult = Temporal_2.ComparisonResult;
112
+ export type RoundingMode = Temporal_2.RoundingMode;
113
+ export type AssignmentOptions = Temporal_2.AssignmentOptions;
114
+ export type DurationOptions = Temporal_2.DurationOptions;
115
+ export type ToInstantOptions = Temporal_2.ToInstantOptions;
116
+ export type ZonedDateTimeAssignmentOptions = Temporal_2.ZonedDateTimeAssignmentOptions;
117
+ export type ArithmeticOptions = Temporal_2.ArithmeticOptions;
118
+ export type DateUnit = Temporal_2.DateUnit;
119
+ export type TimeUnit = Temporal_2.TimeUnit;
120
+ export type DateTimeUnit = Temporal_2.DateTimeUnit;
121
+ export type PluralUnit<T extends Temporal_2.DateTimeUnit> = Temporal_2.PluralUnit<T>;
122
+ export type LargestUnit<T extends Temporal_2.DateTimeUnit> = Temporal_2.LargestUnit<T>;
123
+ export type SmallestUnit<T extends Temporal_2.DateTimeUnit> = Temporal_2.SmallestUnit<T>;
124
+ export type TotalUnit<T extends Temporal_2.DateTimeUnit> = Temporal_2.TotalUnit<T>;
125
+ export type ToStringPrecisionOptions = Temporal_2.ToStringPrecisionOptions;
126
+ export type ShowCalendarOption = Temporal_2.ShowCalendarOption;
127
+ export type CalendarTypeToStringOptions = Temporal_2.CalendarTypeToStringOptions;
128
+ export type ZonedDateTimeToStringOptions = Temporal_2.ZonedDateTimeToStringOptions;
129
+ export type InstantToStringOptions = Temporal_2.InstantToStringOptions;
130
+ export type DifferenceOptions<T extends Temporal_2.DateTimeUnit> = Temporal_2.DifferenceOptions<T>;
131
+ export type RoundTo<T extends Temporal_2.DateTimeUnit> = Temporal_2.RoundTo<T>;
132
+ export type DurationRoundTo = Temporal_2.DurationRoundTo;
133
+ export type DurationTotalOf = Temporal_2.DurationTotalOf;
134
+ export type DurationArithmeticOptions = Temporal_2.DurationArithmeticOptions;
135
+ export type TransitionDirection = Temporal_2.TransitionDirection;
136
+ export type DurationLike = Temporal_2.DurationLike;
137
+ export type Duration = Temporal_2.Duration;
138
+ export type Instant = Temporal_2.Instant;
139
+ export type CalendarLike = Temporal_2.CalendarLike;
140
+ export type PlainDateLike = Temporal_2.PlainDateLike;
141
+ export type PlainDate = Temporal_2.PlainDate;
142
+ export type PlainDateTimeLike = Temporal_2.PlainDateTimeLike;
143
+ export type PlainDateTime = Temporal_2.PlainDateTime;
144
+ export type PlainMonthDayLike = Temporal_2.PlainMonthDayLike;
145
+ export type PlainMonthDay = Temporal_2.PlainMonthDay;
146
+ export type PlainTimeLike = Temporal_2.PlainTimeLike;
147
+ export type PlainTime = Temporal_2.PlainTime;
148
+ export type TimeZoneLike = Temporal_2.TimeZoneLike;
149
+ export type PlainYearMonthLike = Temporal_2.PlainYearMonthLike;
150
+ export type PlainYearMonth = Temporal_2.PlainYearMonth;
151
+ export type ZonedDateTimeLike = Temporal_2.ZonedDateTimeLike;
152
+ export type ZonedDateTime = Temporal_2.ZonedDateTime;
153
+ }
154
+
155
+ declare type TemporalApi = typeof Temporal_2;
156
+
157
+ export { }
package/dist/time.js ADDED
@@ -0,0 +1,37 @@
1
+ // packages/time/dist/temporal.js
2
+ import { Temporal as Polyfill } from "@js-temporal/polyfill";
3
+ var engineTemporal = Reflect.get(globalThis, "Temporal");
4
+ var Temporal = engineTemporal ?? Polyfill;
5
+
6
+ // packages/time/dist/zones.js
7
+ var MAX_ZONE_ID_LENGTH = 64;
8
+ function hasIanaShape(id) {
9
+ if (id.length > MAX_ZONE_ID_LENGTH)
10
+ return false;
11
+ if (id.includes("/"))
12
+ return true;
13
+ const upper = id.toUpperCase();
14
+ return upper === "UTC" || upper === "GMT";
15
+ }
16
+ function canonicalZone(id) {
17
+ if (typeof id !== "string" || !hasIanaShape(id))
18
+ return void 0;
19
+ try {
20
+ return new Intl.DateTimeFormat("en-US", { timeZone: id }).resolvedOptions().timeZone;
21
+ } catch {
22
+ return void 0;
23
+ }
24
+ }
25
+ function isValidZone(id) {
26
+ return canonicalZone(id) !== void 0;
27
+ }
28
+ function sameZone(a, b) {
29
+ const left = canonicalZone(a);
30
+ return left !== void 0 && left === canonicalZone(b);
31
+ }
32
+ export {
33
+ Temporal,
34
+ canonicalZone,
35
+ isValidZone,
36
+ sameZone
37
+ };