@theokit/sdk-tools 0.15.1 → 0.16.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 +10 -0
- package/dist/index.cjs +41 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ef00db3: Add `createCurrentTimeTool` — a built-in `current_time` tool. Codex-faithful at the core (Codex's
|
|
8
|
+
`clock.curr_time` returns UTC as `YYYY-MM-DD HH:MM:SS UTC`); this keeps that as the default and adds an
|
|
9
|
+
optional IANA `timezone` (additive superset — omitted ⇒ UTC) plus an unambiguous `iso` instant. Returns
|
|
10
|
+
`{ ok, current_time, iso, timezone }` or `{ ok: false, error: 'invalid_timezone' }`. The clock is
|
|
11
|
+
injectable (`{ clock }`) so the tool is deterministic under test.
|
|
12
|
+
|
|
3
13
|
## 0.15.1
|
|
4
14
|
|
|
5
15
|
### 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 {
|
|
@@ -2572,6 +2612,7 @@ exports.catastrophicShellReason = catastrophicShellReason;
|
|
|
2572
2612
|
exports.commandDenialReason = commandDenialReason;
|
|
2573
2613
|
exports.createApplyPatchTool = createApplyPatchTool;
|
|
2574
2614
|
exports.createBraveWebSearchAdapter = createBraveWebSearchAdapter;
|
|
2615
|
+
exports.createCurrentTimeTool = createCurrentTimeTool;
|
|
2575
2616
|
exports.createEditFileTool = createEditFileTool;
|
|
2576
2617
|
exports.createGenericHttpSearchAdapter = createGenericHttpSearchAdapter;
|
|
2577
2618
|
exports.createGitDiffTool = createGitDiffTool;
|