@yaklabs-ai/plugin-sdk 0.13.5 → 0.13.7

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: "" }
@@ -308,7 +321,7 @@ var UriUnsupportedOperationError = class extends UriError {
308
321
  };
309
322
 
310
323
  // packages/herd-uri/dist/operations.js
311
- import { z as z2 } from "zod";
324
+ import { z as z3 } from "zod";
312
325
  var URI_OPERATIONS = [
313
326
  "help",
314
327
  "read",
@@ -318,44 +331,44 @@ var URI_OPERATIONS = [
318
331
  "search",
319
332
  "delete"
320
333
  ];
321
- var UriOperationSchema = z2.enum(URI_OPERATIONS);
334
+ var UriOperationSchema = z3.enum(URI_OPERATIONS);
322
335
 
323
336
  // packages/herd-uri/dist/help-schema.js
324
- import { z as z3 } from "zod";
325
- var UriContractJsonSchema = z3.record(z3.string(), z3.unknown());
326
- var UriParameterSchema = z3.strictObject({
327
- name: z3.string().min(1),
328
- in: z3.enum(["uri", "query", "selector"]),
329
- required: z3.boolean(),
330
- 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(),
331
344
  schema: UriContractJsonSchema,
332
- examples: z3.array(z3.unknown()).optional()
345
+ examples: z4.array(z4.unknown()).optional()
333
346
  });
334
- var UriPayloadContractSchema = z3.strictObject({
335
- name: z3.string().min(1),
336
- mediaType: z3.string().optional(),
337
- 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(),
338
351
  schema: UriContractJsonSchema.optional(),
339
- semanticConstraints: z3.array(z3.string().min(1)).min(1).optional(),
340
- examples: z3.array(z3.unknown()).optional()
352
+ semanticConstraints: z4.array(z4.string().min(1)).min(1).optional(),
353
+ examples: z4.array(z4.unknown()).optional()
341
354
  });
342
355
 
343
356
  // packages/herd-uri/dist/text-edit.js
344
- import { z as z4 } from "zod";
345
- var findReplaceArm = z4.strictObject({
346
- find: z4.string().min(1),
347
- replace: z4.string(),
348
- 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()
349
362
  });
350
- var oldNewEntry = z4.strictObject({
351
- oldText: z4.string().min(1),
352
- newText: z4.string()
363
+ var oldNewEntry = z5.strictObject({
364
+ oldText: z5.string().min(1),
365
+ newText: z5.string()
353
366
  });
354
- var uriTextEditPayloadArms = z4.union([
367
+ var uriTextEditPayloadArms = z5.union([
355
368
  findReplaceArm,
356
- z4.strictObject({ edits: z4.array(oldNewEntry).min(1) }),
369
+ z5.strictObject({ edits: z5.array(oldNewEntry).min(1) }),
357
370
  oldNewEntry,
358
- z4.array(oldNewEntry).min(1)
371
+ z5.array(oldNewEntry).min(1)
359
372
  ]);
360
373
 
361
374
  // packages/herd-uri/dist/line-selector.js
@@ -451,10 +464,10 @@ function parseLineSelector(input) {
451
464
  }
452
465
 
453
466
  // packages/herd-uri/dist/schema/to-json-schema.js
454
- import { z as z5 } from "zod";
467
+ import { z as z6 } from "zod";
455
468
  function toJsonSchema(schema) {
456
- if (schema instanceof z5.ZodType) {
457
- const { $schema: _dialect, ...value } = z5.toJSONSchema(schema, {
469
+ if (schema instanceof z6.ZodType) {
470
+ const { $schema: _dialect, ...value } = z6.toJSONSchema(schema, {
458
471
  // `io: "input"` describes what a caller may SEND, which is what a parameter and an
459
472
  // `accepts` payload advertise: a field with a Zod default is optional on the wire even
460
473
  // though the parsed value always carries it. Strictness still survives where the validator
@@ -577,8 +590,11 @@ var KAY_APP_AUTOMATION_CONDITION_KINDS = [
577
590
  ];
578
591
  export {
579
592
  JevCallError,
593
+ JsonSchema,
594
+ JsonValue,
580
595
  KAY_APP_AUTOMATION_CONDITION_KINDS,
581
596
  KAY_APP_DATA_CHANGE_MAX_BYTES,
597
+ KAY_APP_DATA_SNAPSHOT_MAX_BYTES,
582
598
  KayAppWorkflowFailure,
583
599
  MAX_CHOICE_LABELS,
584
600
  SIGNAL_TIME_MAX_MS,
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
+ };