@theokit/sdk-tools 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c98c40a: Add `createUpdatePlanTool` — a Codex-faithful `update_plan` built-in. The model posts a DECLARATIVE plan
8
+ (an ordered list of steps, each `pending | in_progress | completed`) and refreshes it as work proceeds.
9
+ Surface-agnostic by design: returns STRUCTURED `{ ok, explanation, steps, warning? }` so each surface
10
+ renders the checklist itself (no hard-coded glyphs). Follows Codex's "exactly one step in_progress"
11
+ invariant as a non-fatal `warning` (never rejects), so the agent self-corrects on the next update.
12
+ Distinct from the imperative `createTodolistTool` (add/complete by id) and `createPlanModeTool` (mode
13
+ toggle) — this is the declarative full-plan post.
14
+
15
+ ## 0.16.0
16
+
17
+ ### Minor Changes
18
+
19
+ - ef00db3: Add `createCurrentTimeTool` — a built-in `current_time` tool. Codex-faithful at the core (Codex's
20
+ `clock.curr_time` returns UTC as `YYYY-MM-DD HH:MM:SS UTC`); this keeps that as the default and adds an
21
+ optional IANA `timezone` (additive superset — omitted ⇒ UTC) plus an unambiguous `iso` instant. Returns
22
+ `{ ok, current_time, iso, timezone }` or `{ ok: false, error: 'invalid_timezone' }`. The clock is
23
+ injectable (`{ clock }`) so the tool is deterministic under test.
24
+
3
25
  ## 0.15.1
4
26
 
5
27
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -267,6 +267,46 @@ function createSessionArtifactStore(options) {
267
267
  }
268
268
  return { write, read, has, list, path };
269
269
  }
270
+ function formatInTimezone(now, tz) {
271
+ const parts = new Intl.DateTimeFormat("en-US", {
272
+ timeZone: tz,
273
+ year: "numeric",
274
+ month: "2-digit",
275
+ day: "2-digit",
276
+ hour: "2-digit",
277
+ minute: "2-digit",
278
+ second: "2-digit",
279
+ hour12: false
280
+ }).formatToParts(now);
281
+ const p = {};
282
+ for (const { type, value } of parts) p[type] = value;
283
+ const hour = p.hour === "24" ? "00" : p.hour;
284
+ return `${p.year}-${p.month}-${p.day} ${hour}:${p.minute}:${p.second} ${tz}`;
285
+ }
286
+ function createCurrentTimeTool(opts = {}) {
287
+ const clock = opts.clock ?? (() => /* @__PURE__ */ new Date());
288
+ return sdk.Tool.create({
289
+ name: "current_time",
290
+ description: "Get the current date and time. Returns { current_time, iso, timezone } as a JSON string, where current_time is 'YYYY-MM-DD HH:MM:SS <timezone>' and iso is the ISO-8601 instant. Pass an optional IANA timezone (e.g. 'America/Sao_Paulo', 'Europe/Lisbon'); defaults to UTC. Never state the date or time from memory \u2014 always call this. Returns { ok: false, error: 'invalid_timezone' } for an unknown timezone.",
291
+ inputSchema: zod.z.object({
292
+ timezone: zod.z.string().optional().describe("IANA timezone, e.g. 'America/Sao_Paulo' or 'Europe/Lisbon'. Defaults to UTC.")
293
+ }),
294
+ handler: ({ timezone }) => {
295
+ const tz = timezone ?? "UTC";
296
+ const now = clock();
297
+ try {
298
+ return JSON.stringify({
299
+ ok: true,
300
+ current_time: formatInTimezone(now, tz),
301
+ iso: now.toISOString(),
302
+ timezone: tz
303
+ });
304
+ } catch {
305
+ return JSON.stringify({ ok: false, error: "invalid_timezone", timezone: tz });
306
+ }
307
+ }
308
+ });
309
+ }
270
310
 
271
311
  // src/internal/context-match.ts
272
312
  var ContextMatchError = class extends Error {
@@ -2257,6 +2297,27 @@ function truncateOutput(output, opts) {
2257
2297
  overflowPath
2258
2298
  };
2259
2299
  }
2300
+ var STATUS = ["pending", "in_progress", "completed"];
2301
+ var planStepSchema = zod.z.object({
2302
+ step: zod.z.string().min(1).max(100).describe("A short step, \u2264 ~7 words."),
2303
+ status: zod.z.enum(STATUS)
2304
+ });
2305
+ function createUpdatePlanTool() {
2306
+ return sdk.Tool.create({
2307
+ name: "update_plan",
2308
+ description: "Post or refresh a short plan so the user sees your progress on a multi-step task. Pass an ordered `plan` of steps, each with a status (pending | in_progress | completed); keep exactly one step in_progress at a time and mark steps completed as you finish. Returns { ok, steps, warning? } as a JSON string \u2014 the surface renders the checklist. A `warning` is returned (not an error) if the one-in_progress invariant is violated, so you can self-correct on the next update.",
2309
+ inputSchema: zod.z.object({
2310
+ explanation: zod.z.string().max(200).optional().describe("One line on what changed / why (optional)."),
2311
+ plan: zod.z.array(planStepSchema).min(1).describe("The ordered steps.")
2312
+ }),
2313
+ handler: ({ explanation, plan }) => {
2314
+ const inProgress = plan.filter((s) => s.status === "in_progress").length;
2315
+ const allDone = plan.every((s) => s.status === "completed");
2316
+ const warning = !allDone && inProgress !== 1 ? `keep exactly one step in_progress until all are completed \u2014 found ${inProgress}` : void 0;
2317
+ return JSON.stringify({ ok: true, explanation: explanation ?? null, steps: plan, warning });
2318
+ }
2319
+ });
2320
+ }
2260
2321
  var DEFAULT_TIMEOUT_MS4 = 3e4;
2261
2322
  var MAX_BODY_BYTES = 1 * 1024 * 1024;
2262
2323
  function createWebFetchTool(opts) {
@@ -2572,6 +2633,7 @@ exports.catastrophicShellReason = catastrophicShellReason;
2572
2633
  exports.commandDenialReason = commandDenialReason;
2573
2634
  exports.createApplyPatchTool = createApplyPatchTool;
2574
2635
  exports.createBraveWebSearchAdapter = createBraveWebSearchAdapter;
2636
+ exports.createCurrentTimeTool = createCurrentTimeTool;
2575
2637
  exports.createEditFileTool = createEditFileTool;
2576
2638
  exports.createGenericHttpSearchAdapter = createGenericHttpSearchAdapter;
2577
2639
  exports.createGitDiffTool = createGitDiffTool;
@@ -2586,6 +2648,7 @@ exports.createSearchTextTool = createSearchTextTool;
2586
2648
  exports.createSessionArtifactStore = createSessionArtifactStore;
2587
2649
  exports.createShellTool = createShellTool;
2588
2650
  exports.createTodolistTool = createTodolistTool;
2651
+ exports.createUpdatePlanTool = createUpdatePlanTool;
2589
2652
  exports.createWebFetchTool = createWebFetchTool;
2590
2653
  exports.createWebSearchTool = createWebSearchTool;
2591
2654
  exports.createWriteFileTool = createWriteFileTool;