@nhtio/adk 0.1.0-master-f0aa531d
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/LICENSE.md +9 -0
- package/README.md +3 -0
- package/batteries/index.d.ts +28 -0
- package/batteries/llm/index.d.ts +11 -0
- package/batteries/llm/openai_chat_completions/adapter.cjs +916 -0
- package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -0
- package/batteries/llm/openai_chat_completions/adapter.d.ts +101 -0
- package/batteries/llm/openai_chat_completions/adapter.mjs +914 -0
- package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -0
- package/batteries/llm/openai_chat_completions/exceptions.cjs +89 -0
- package/batteries/llm/openai_chat_completions/exceptions.cjs.map +1 -0
- package/batteries/llm/openai_chat_completions/exceptions.d.ts +97 -0
- package/batteries/llm/openai_chat_completions/exceptions.mjs +81 -0
- package/batteries/llm/openai_chat_completions/exceptions.mjs.map +1 -0
- package/batteries/llm/openai_chat_completions/helpers.cjs +819 -0
- package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -0
- package/batteries/llm/openai_chat_completions/helpers.d.ts +233 -0
- package/batteries/llm/openai_chat_completions/helpers.mjs +783 -0
- package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -0
- package/batteries/llm/openai_chat_completions/index.d.ts +27 -0
- package/batteries/llm/openai_chat_completions/types.cjs +1 -0
- package/batteries/llm/openai_chat_completions/types.d.ts +524 -0
- package/batteries/llm/openai_chat_completions/types.mjs +0 -0
- package/batteries/llm/openai_chat_completions/validation.cjs +190 -0
- package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -0
- package/batteries/llm/openai_chat_completions/validation.d.ts +31 -0
- package/batteries/llm/openai_chat_completions/validation.mjs +187 -0
- package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -0
- package/batteries/llm/openai_chat_completions.cjs +51 -0
- package/batteries/llm/openai_chat_completions.mjs +5 -0
- package/batteries/llm/webllm_chat_completions/adapter.cjs +658 -0
- package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -0
- package/batteries/llm/webllm_chat_completions/adapter.d.ts +103 -0
- package/batteries/llm/webllm_chat_completions/adapter.mjs +656 -0
- package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -0
- package/batteries/llm/webllm_chat_completions/exceptions.cjs +70 -0
- package/batteries/llm/webllm_chat_completions/exceptions.cjs.map +1 -0
- package/batteries/llm/webllm_chat_completions/exceptions.d.ts +74 -0
- package/batteries/llm/webllm_chat_completions/exceptions.mjs +65 -0
- package/batteries/llm/webllm_chat_completions/exceptions.mjs.map +1 -0
- package/batteries/llm/webllm_chat_completions/helpers.cjs +38 -0
- package/batteries/llm/webllm_chat_completions/helpers.d.ts +6 -0
- package/batteries/llm/webllm_chat_completions/helpers.mjs +2 -0
- package/batteries/llm/webllm_chat_completions/index.d.ts +25 -0
- package/batteries/llm/webllm_chat_completions/types.d.ts +31 -0
- package/batteries/llm/webllm_chat_completions/validation.cjs +115 -0
- package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -0
- package/batteries/llm/webllm_chat_completions/validation.d.ts +8 -0
- package/batteries/llm/webllm_chat_completions/validation.mjs +112 -0
- package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -0
- package/batteries/llm/webllm_chat_completions.cjs +50 -0
- package/batteries/llm/webllm_chat_completions.mjs +6 -0
- package/batteries/llm.cjs +63 -0
- package/batteries/llm.mjs +10 -0
- package/batteries/storage/flydrive/index.d.ts +167 -0
- package/batteries/storage/flydrive.cjs +249 -0
- package/batteries/storage/flydrive.cjs.map +1 -0
- package/batteries/storage/flydrive.mjs +249 -0
- package/batteries/storage/flydrive.mjs.map +1 -0
- package/batteries/storage/in_memory/index.d.ts +106 -0
- package/batteries/storage/in_memory.cjs +121 -0
- package/batteries/storage/in_memory.cjs.map +1 -0
- package/batteries/storage/in_memory.mjs +119 -0
- package/batteries/storage/in_memory.mjs.map +1 -0
- package/batteries/storage/index.d.ts +18 -0
- package/batteries/storage/opfs/index.d.ts +299 -0
- package/batteries/storage/opfs.cjs +368 -0
- package/batteries/storage/opfs.cjs.map +1 -0
- package/batteries/storage/opfs.mjs +366 -0
- package/batteries/storage/opfs.mjs.map +1 -0
- package/batteries/storage.cjs +4 -0
- package/batteries/storage.mjs +2 -0
- package/batteries/tools/color/index.d.ts +37 -0
- package/batteries/tools/color.cjs +659 -0
- package/batteries/tools/color.cjs.map +1 -0
- package/batteries/tools/color.mjs +655 -0
- package/batteries/tools/color.mjs.map +1 -0
- package/batteries/tools/comparison/index.d.ts +29 -0
- package/batteries/tools/comparison.cjs +171 -0
- package/batteries/tools/comparison.cjs.map +1 -0
- package/batteries/tools/comparison.mjs +168 -0
- package/batteries/tools/comparison.mjs.map +1 -0
- package/batteries/tools/data_structure/index.d.ts +30 -0
- package/batteries/tools/data_structure.cjs +270 -0
- package/batteries/tools/data_structure.cjs.map +1 -0
- package/batteries/tools/data_structure.mjs +267 -0
- package/batteries/tools/data_structure.mjs.map +1 -0
- package/batteries/tools/datetime_extended/index.d.ts +51 -0
- package/batteries/tools/datetime_extended.cjs +309 -0
- package/batteries/tools/datetime_extended.cjs.map +1 -0
- package/batteries/tools/datetime_extended.mjs +302 -0
- package/batteries/tools/datetime_extended.mjs.map +1 -0
- package/batteries/tools/datetime_math/index.d.ts +36 -0
- package/batteries/tools/datetime_math.cjs +175 -0
- package/batteries/tools/datetime_math.cjs.map +1 -0
- package/batteries/tools/datetime_math.mjs +171 -0
- package/batteries/tools/datetime_math.mjs.map +1 -0
- package/batteries/tools/encoding/index.d.ts +36 -0
- package/batteries/tools/encoding.cjs +156 -0
- package/batteries/tools/encoding.cjs.map +1 -0
- package/batteries/tools/encoding.mjs +152 -0
- package/batteries/tools/encoding.mjs.map +1 -0
- package/batteries/tools/formatting/index.d.ts +28 -0
- package/batteries/tools/formatting.cjs +120 -0
- package/batteries/tools/formatting.cjs.map +1 -0
- package/batteries/tools/formatting.mjs +117 -0
- package/batteries/tools/formatting.mjs.map +1 -0
- package/batteries/tools/geo_basics/index.d.ts +33 -0
- package/batteries/tools/geo_basics.cjs +136 -0
- package/batteries/tools/geo_basics.cjs.map +1 -0
- package/batteries/tools/geo_basics.mjs +132 -0
- package/batteries/tools/geo_basics.mjs.map +1 -0
- package/batteries/tools/index.d.ts +32 -0
- package/batteries/tools/math/index.d.ts +37 -0
- package/batteries/tools/math.cjs +136 -0
- package/batteries/tools/math.cjs.map +1 -0
- package/batteries/tools/math.mjs +133 -0
- package/batteries/tools/math.mjs.map +1 -0
- package/batteries/tools/memory/index.d.ts +73 -0
- package/batteries/tools/memory.cjs +193 -0
- package/batteries/tools/memory.cjs.map +1 -0
- package/batteries/tools/memory.mjs +187 -0
- package/batteries/tools/memory.mjs.map +1 -0
- package/batteries/tools/parsing/index.d.ts +47 -0
- package/batteries/tools/parsing.cjs +191 -0
- package/batteries/tools/parsing.cjs.map +1 -0
- package/batteries/tools/parsing.mjs +185 -0
- package/batteries/tools/parsing.mjs.map +1 -0
- package/batteries/tools/retrievables/index.d.ts +81 -0
- package/batteries/tools/retrievables.cjs +215 -0
- package/batteries/tools/retrievables.cjs.map +1 -0
- package/batteries/tools/retrievables.mjs +209 -0
- package/batteries/tools/retrievables.mjs.map +1 -0
- package/batteries/tools/standing_instructions/index.d.ts +64 -0
- package/batteries/tools/standing_instructions.cjs +126 -0
- package/batteries/tools/standing_instructions.cjs.map +1 -0
- package/batteries/tools/standing_instructions.mjs +121 -0
- package/batteries/tools/standing_instructions.mjs.map +1 -0
- package/batteries/tools/statistics/index.d.ts +46 -0
- package/batteries/tools/statistics.cjs +253 -0
- package/batteries/tools/statistics.cjs.map +1 -0
- package/batteries/tools/statistics.mjs +248 -0
- package/batteries/tools/statistics.mjs.map +1 -0
- package/batteries/tools/string_processing/index.d.ts +29 -0
- package/batteries/tools/string_processing.cjs +154 -0
- package/batteries/tools/string_processing.cjs.map +1 -0
- package/batteries/tools/string_processing.mjs +151 -0
- package/batteries/tools/string_processing.mjs.map +1 -0
- package/batteries/tools/structured_data/index.d.ts +34 -0
- package/batteries/tools/structured_data.cjs +189 -0
- package/batteries/tools/structured_data.cjs.map +1 -0
- package/batteries/tools/structured_data.mjs +185 -0
- package/batteries/tools/structured_data.mjs.map +1 -0
- package/batteries/tools/text_analysis/index.d.ts +31 -0
- package/batteries/tools/text_analysis.cjs +120 -0
- package/batteries/tools/text_analysis.cjs.map +1 -0
- package/batteries/tools/text_analysis.mjs +117 -0
- package/batteries/tools/text_analysis.mjs.map +1 -0
- package/batteries/tools/text_comparison/index.d.ts +28 -0
- package/batteries/tools/text_comparison.cjs +96 -0
- package/batteries/tools/text_comparison.cjs.map +1 -0
- package/batteries/tools/text_comparison.mjs +93 -0
- package/batteries/tools/text_comparison.mjs.map +1 -0
- package/batteries/tools/time/index.d.ts +27 -0
- package/batteries/tools/time.cjs +63 -0
- package/batteries/tools/time.cjs.map +1 -0
- package/batteries/tools/time.mjs +60 -0
- package/batteries/tools/time.mjs.map +1 -0
- package/batteries/tools/unit_conversion/index.d.ts +19 -0
- package/batteries/tools/unit_conversion.cjs +452 -0
- package/batteries/tools/unit_conversion.cjs.map +1 -0
- package/batteries/tools/unit_conversion.mjs +450 -0
- package/batteries/tools/unit_conversion.mjs.map +1 -0
- package/batteries/tools.cjs +80 -0
- package/batteries/tools.mjs +21 -0
- package/batteries.cjs +142 -0
- package/batteries.mjs +30 -0
- package/chunk-KmRHZBOW.js +35 -0
- package/common-DeZaonK1.mjs +208 -0
- package/common-DeZaonK1.mjs.map +1 -0
- package/common-Od8edUXU.js +232 -0
- package/common-Od8edUXU.js.map +1 -0
- package/common.cjs +31 -0
- package/common.d.ts +108 -0
- package/common.mjs +8 -0
- package/dispatch_runner-9j6bXHL3.mjs +1609 -0
- package/dispatch_runner-9j6bXHL3.mjs.map +1 -0
- package/dispatch_runner-CsoH0nld.js +1627 -0
- package/dispatch_runner-CsoH0nld.js.map +1 -0
- package/dispatch_runner.cjs +3 -0
- package/dispatch_runner.d.ts +17 -0
- package/dispatch_runner.mjs +2 -0
- package/exceptions-D5YrO9Vm.js +280 -0
- package/exceptions-D5YrO9Vm.js.map +1 -0
- package/exceptions-NrzIHw_R.mjs +244 -0
- package/exceptions-NrzIHw_R.mjs.map +1 -0
- package/exceptions.cjs +33 -0
- package/exceptions.d.ts +52 -0
- package/exceptions.mjs +3 -0
- package/factories.cjs +4 -0
- package/factories.d.ts +39 -0
- package/factories.mjs +2 -0
- package/forge.cjs +9 -0
- package/forge.d.ts +49 -0
- package/forge.mjs +5 -0
- package/guards.cjs +96 -0
- package/guards.cjs.map +1 -0
- package/guards.d.ts +83 -0
- package/guards.mjs +72 -0
- package/guards.mjs.map +1 -0
- package/index.cjs +107 -0
- package/index.cjs.map +1 -0
- package/index.d.ts +18 -0
- package/index.mjs +31 -0
- package/index.mjs.map +1 -0
- package/lib/classes/artifact_tool.d.ts +129 -0
- package/lib/classes/base_exception.d.ts +83 -0
- package/lib/classes/identity.d.ts +71 -0
- package/lib/classes/media.d.ts +326 -0
- package/lib/classes/memory.d.ts +72 -0
- package/lib/classes/message.d.ts +137 -0
- package/lib/classes/registry.d.ts +79 -0
- package/lib/classes/retrievable.d.ts +100 -0
- package/lib/classes/spooled_artifact.d.ts +296 -0
- package/lib/classes/spooled_json_artifact.d.ts +158 -0
- package/lib/classes/spooled_markdown_artifact.d.ts +202 -0
- package/lib/classes/thought.d.ts +142 -0
- package/lib/classes/tokenizable.d.ts +124 -0
- package/lib/classes/tool.d.ts +228 -0
- package/lib/classes/tool_call.d.ts +190 -0
- package/lib/classes/tool_registry.d.ts +159 -0
- package/lib/classes/turn_gate.d.ts +109 -0
- package/lib/contracts/dispatch_context.d.ts +345 -0
- package/lib/contracts/media_reader.d.ts +60 -0
- package/lib/contracts/spool_reader.d.ts +80 -0
- package/lib/contracts/spooled_artifact_constructor.d.ts +38 -0
- package/lib/contracts/turn_runner_config.d.ts +101 -0
- package/lib/contracts/turn_runner_context.d.ts +267 -0
- package/lib/dispatch_runner.d.ts +98 -0
- package/lib/exceptions/runtime.d.ts +370 -0
- package/lib/helpers/media_readers.d.ts +39 -0
- package/lib/turn_runner.d.ts +144 -0
- package/lib/types/dispatch_context.d.ts +233 -0
- package/lib/types/dispatch_runner.d.ts +387 -0
- package/lib/types/turn_runner.d.ts +322 -0
- package/lib/utils/canonical_json.d.ts +18 -0
- package/lib/utils/exceptions.d.ts +78 -0
- package/lib/utils/guards.d.ts +32 -0
- package/lib/utils/validation.d.ts +77 -0
- package/package.json +334 -0
- package/runtime-BJVkrGQe.js +519 -0
- package/runtime-BJVkrGQe.js.map +1 -0
- package/runtime-CrEPIFgr.mjs +346 -0
- package/runtime-CrEPIFgr.mjs.map +1 -0
- package/skills/adk-assembly/SKILL.md +109 -0
- package/skills/adk-assembly/references/assembly-contract.md +66 -0
- package/skills/adk-assembly/references/executors-tools-pipelines-events.md +113 -0
- package/skills/adk-assembly/references/first-integration.md +93 -0
- package/skills/adk-assembly/references/storage-and-context.md +102 -0
- package/spooled_artifact-C5ZtGxuJ.mjs +544 -0
- package/spooled_artifact-C5ZtGxuJ.mjs.map +1 -0
- package/spooled_artifact-Cm9Te22K.js +568 -0
- package/spooled_artifact-Cm9Te22K.js.map +1 -0
- package/spooled_artifact.cjs +7 -0
- package/spooled_artifact.d.ts +40 -0
- package/spooled_artifact.mjs +3 -0
- package/spooled_markdown_artifact-BpUJol0W.mjs +771 -0
- package/spooled_markdown_artifact-BpUJol0W.mjs.map +1 -0
- package/spooled_markdown_artifact-RRB113sy.js +786 -0
- package/spooled_markdown_artifact-RRB113sy.js.map +1 -0
- package/thought-CDb457b4.mjs +470 -0
- package/thought-CDb457b4.mjs.map +1 -0
- package/thought-DuN2PgdO.js +494 -0
- package/thought-DuN2PgdO.js.map +1 -0
- package/tool-COSeH8I6.js +302 -0
- package/tool-COSeH8I6.js.map +1 -0
- package/tool-D2WB1EA1.mjs +296 -0
- package/tool-D2WB1EA1.mjs.map +1 -0
- package/tool_call-BKyyxGaZ.mjs +578 -0
- package/tool_call-BKyyxGaZ.mjs.map +1 -0
- package/tool_call-DFgzcVcU.js +608 -0
- package/tool_call-DFgzcVcU.js.map +1 -0
- package/tool_registry-Dkfprsck.js +641 -0
- package/tool_registry-Dkfprsck.js.map +1 -0
- package/tool_registry-DqLOyGyG.mjs +592 -0
- package/tool_registry-DqLOyGyG.mjs.map +1 -0
- package/turn_runner-CMm2BHdX.js +615 -0
- package/turn_runner-CMm2BHdX.js.map +1 -0
- package/turn_runner-y7eyEcJH.mjs +603 -0
- package/turn_runner-y7eyEcJH.mjs.map +1 -0
- package/turn_runner.cjs +3 -0
- package/turn_runner.d.ts +21 -0
- package/turn_runner.mjs +2 -0
- package/types.cjs +1 -0
- package/types.d.ts +56 -0
- package/types.mjs +0 -0
- package/vite-env.d.ts +23 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-constructed tools for parsing natural-language dates and business-calendar calculations.
|
|
3
|
+
*
|
|
4
|
+
* @module @nhtio/adk/batteries/tools/datetime_extended
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Pre-constructed bundled tools for the `datetime_extended` category. Import individually, the whole
|
|
8
|
+
* category, or import every tool via `@nhtio/adk/batteries`.
|
|
9
|
+
*/
|
|
10
|
+
import { Tool } from "../../../common";
|
|
11
|
+
/**
|
|
12
|
+
* Find the Nth occurrence of a weekday in a given month.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Examples: "2nd Friday of March 2026", "last Monday of January 2025". Accepts 1st–5th and
|
|
16
|
+
* `last`. Returns an error if the month does not contain that many occurrences of the weekday.
|
|
17
|
+
*/
|
|
18
|
+
export declare const dateNthWeekdayTool: Tool<import("../../../common").SpooledArtifact>;
|
|
19
|
+
/**
|
|
20
|
+
* Get calendar metadata for a date.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Reports ISO week number, day of year, calendar quarter, fiscal quarter/year (configurable via
|
|
24
|
+
* `fiscal_year_start_month`), week of month, and whether the date is a weekend. Accepts ISO
|
|
25
|
+
* dates, natural-language ("next Tuesday"), and `now`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const dateCalendarInfoTool: Tool<import("../../../common").SpooledArtifact>;
|
|
28
|
+
/**
|
|
29
|
+
* Parse a date/time expression from natural language or common formats.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Examples: `"next Monday"`, `"March 5th"`, `"in 2 weeks"`, `"yesterday"`. Uses chrono-node for
|
|
33
|
+
* relative parsing. `reference_date` overrides the "now" anchor.
|
|
34
|
+
*/
|
|
35
|
+
export declare const dateParseTool: Tool<import("../../../common").SpooledArtifact>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the start or end of a time period containing a given date.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Periods: `day`, `week`, `isoweek` (Monday-start), `month`, `quarter`, `year`. Quarter and year
|
|
41
|
+
* honour `fiscal_year_start_month` for fiscal calendars (default: 1 = calendar year).
|
|
42
|
+
*/
|
|
43
|
+
export declare const datePeriodTool: Tool<import("../../../common").SpooledArtifact>;
|
|
44
|
+
/**
|
|
45
|
+
* Count business days between two dates, or compute the date N business days away.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Monday–Friday only; no holiday calendar awareness. Provide either `to` (count between) or
|
|
49
|
+
* `add_days` (compute target date). Negative `add_days` walks backwards.
|
|
50
|
+
*/
|
|
51
|
+
export declare const dateBusinessDaysTool: Tool<import("../../../common").SpooledArtifact>;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("../../chunk-KmRHZBOW.js");
|
|
3
|
+
require("../../common-Od8edUXU.js");
|
|
4
|
+
const require_tool = require("../../tool-COSeH8I6.js");
|
|
5
|
+
let _nhtio_validation = require("@nhtio/validation");
|
|
6
|
+
let luxon = require("luxon");
|
|
7
|
+
let chrono_node = require("chrono-node");
|
|
8
|
+
chrono_node = require_chunk.__toESM(chrono_node);
|
|
9
|
+
//#region src/batteries/tools/datetime_extended/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* Pre-constructed tools for parsing natural-language dates and business-calendar calculations.
|
|
12
|
+
*
|
|
13
|
+
* @module @nhtio/adk/batteries/tools/datetime_extended
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Pre-constructed bundled tools for the `datetime_extended` category. Import individually, the whole
|
|
17
|
+
* category, or import every tool via `@nhtio/adk/batteries`.
|
|
18
|
+
*/
|
|
19
|
+
function resolveZone(timezone) {
|
|
20
|
+
if (!timezone) return { zone: "UTC" };
|
|
21
|
+
if (!luxon.IANAZone.isValidZone(timezone)) return {
|
|
22
|
+
zone: "",
|
|
23
|
+
error: `Invalid timezone "${timezone}".`
|
|
24
|
+
};
|
|
25
|
+
return { zone: timezone };
|
|
26
|
+
}
|
|
27
|
+
function countBusinessDays(from, to) {
|
|
28
|
+
const forward = to >= from;
|
|
29
|
+
const start = forward ? from.startOf("day") : to.startOf("day");
|
|
30
|
+
const end = forward ? to.startOf("day") : from.startOf("day");
|
|
31
|
+
const totalDays = Math.round(end.diff(start, "days").days);
|
|
32
|
+
const fullWeeks = Math.floor(totalDays / 7);
|
|
33
|
+
let bdays = fullWeeks * 5;
|
|
34
|
+
let cursor = start.plus({ days: fullWeeks * 7 });
|
|
35
|
+
while (cursor < end) {
|
|
36
|
+
cursor = cursor.plus({ days: 1 });
|
|
37
|
+
if (cursor.weekday <= 5) bdays++;
|
|
38
|
+
}
|
|
39
|
+
return forward ? bdays : -bdays;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Find the Nth occurrence of a weekday in a given month.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Examples: "2nd Friday of March 2026", "last Monday of January 2025". Accepts 1st–5th and
|
|
46
|
+
* `last`. Returns an error if the month does not contain that many occurrences of the weekday.
|
|
47
|
+
*/
|
|
48
|
+
var dateNthWeekdayTool = new require_tool.Tool({
|
|
49
|
+
name: "date_nth_weekday",
|
|
50
|
+
description: "Find the Nth occurrence of a weekday in a given month (e.g., \"2nd Friday of March 2026\", \"last Monday of next month\"). Supports 1st–5th and \"last\".",
|
|
51
|
+
inputSchema: _nhtio_validation.validator.object({
|
|
52
|
+
nth: _nhtio_validation.validator.string().required().description("Which occurrence: \"1st\", \"2nd\", \"3rd\", \"4th\", \"5th\", or \"last\"."),
|
|
53
|
+
weekday: _nhtio_validation.validator.string().valid("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday").required().description("Day of the week."),
|
|
54
|
+
month: _nhtio_validation.validator.number().required().description("Month number (1–12)."),
|
|
55
|
+
year: _nhtio_validation.validator.number().optional().description("Year (defaults to current year)."),
|
|
56
|
+
timezone: _nhtio_validation.validator.string().optional().description("IANA timezone (optional, defaults UTC).")
|
|
57
|
+
}),
|
|
58
|
+
handler: async (args) => {
|
|
59
|
+
const { nth, weekday, month: rawMonth, year: rawYear, timezone } = args;
|
|
60
|
+
const { zone, error: zoneError } = resolveZone(timezone);
|
|
61
|
+
if (zoneError) return `Error: ${zoneError}`;
|
|
62
|
+
const targetWeekday = {
|
|
63
|
+
monday: 1,
|
|
64
|
+
tuesday: 2,
|
|
65
|
+
wednesday: 3,
|
|
66
|
+
thursday: 4,
|
|
67
|
+
friday: 5,
|
|
68
|
+
saturday: 6,
|
|
69
|
+
sunday: 7
|
|
70
|
+
}[weekday.toLowerCase()];
|
|
71
|
+
const month = Math.floor(rawMonth);
|
|
72
|
+
if (month < 1 || month > 12) return `Error: Month must be 1–12, got ${rawMonth}.`;
|
|
73
|
+
const year = Math.floor(rawYear ?? luxon.DateTime.now().setZone(zone).year);
|
|
74
|
+
const nthRaw = nth.toLowerCase().replace(/\s/g, "");
|
|
75
|
+
const firstOfMonth = luxon.DateTime.fromObject({
|
|
76
|
+
year,
|
|
77
|
+
month,
|
|
78
|
+
day: 1
|
|
79
|
+
}, { zone });
|
|
80
|
+
if (!firstOfMonth.isValid) return `Error: Invalid date for ${year}-${month}.`;
|
|
81
|
+
const occurrences = [];
|
|
82
|
+
let cursor = firstOfMonth;
|
|
83
|
+
while (cursor.weekday !== targetWeekday) cursor = cursor.plus({ days: 1 });
|
|
84
|
+
while (cursor.month === month) {
|
|
85
|
+
occurrences.push(cursor);
|
|
86
|
+
cursor = cursor.plus({ weeks: 1 });
|
|
87
|
+
}
|
|
88
|
+
let result;
|
|
89
|
+
if (nthRaw === "last") result = occurrences[occurrences.length - 1];
|
|
90
|
+
else {
|
|
91
|
+
const n = {
|
|
92
|
+
"1st": 1,
|
|
93
|
+
"1": 1,
|
|
94
|
+
"first": 1,
|
|
95
|
+
"2nd": 2,
|
|
96
|
+
"2": 2,
|
|
97
|
+
"second": 2,
|
|
98
|
+
"3rd": 3,
|
|
99
|
+
"3": 3,
|
|
100
|
+
"third": 3,
|
|
101
|
+
"4th": 4,
|
|
102
|
+
"4": 4,
|
|
103
|
+
"fourth": 4,
|
|
104
|
+
"5th": 5,
|
|
105
|
+
"5": 5,
|
|
106
|
+
"fifth": 5
|
|
107
|
+
}[nthRaw];
|
|
108
|
+
if (!n) return `Error: Invalid nth value "${nth}". Use 1st–5th or "last".`;
|
|
109
|
+
if (n > occurrences.length) return `Error: There is no ${nth} ${weekday} in ${firstOfMonth.toFormat("LLLL yyyy")} (only ${occurrences.length} occurrence${occurrences.length !== 1 ? "s" : ""}).`;
|
|
110
|
+
result = occurrences[n - 1];
|
|
111
|
+
}
|
|
112
|
+
if (!result) return "Error: Could not compute the date.";
|
|
113
|
+
return `${nth} ${weekday} of ${result.toFormat("LLLL yyyy")}: ${result.toISODate()}\nFormatted: ${result.toFormat("cccc, LLLL d, yyyy")}`;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Get calendar metadata for a date.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* Reports ISO week number, day of year, calendar quarter, fiscal quarter/year (configurable via
|
|
121
|
+
* `fiscal_year_start_month`), week of month, and whether the date is a weekend. Accepts ISO
|
|
122
|
+
* dates, natural-language ("next Tuesday"), and `now`.
|
|
123
|
+
*/
|
|
124
|
+
var dateCalendarInfoTool = new require_tool.Tool({
|
|
125
|
+
name: "date_calendar_info",
|
|
126
|
+
description: "Get calendar metadata for a date: ISO week number, day of year, calendar quarter, fiscal quarter/year, week of month, and whether it is a weekend or weekday.",
|
|
127
|
+
inputSchema: _nhtio_validation.validator.object({
|
|
128
|
+
date: _nhtio_validation.validator.string().required().description("ISO 8601 date, natural language date, or \"now\"."),
|
|
129
|
+
timezone: _nhtio_validation.validator.string().optional().description("IANA timezone (optional, defaults UTC)."),
|
|
130
|
+
fiscal_year_start_month: _nhtio_validation.validator.number().default(1).description("Month when fiscal year starts (1–12, default: 1 = calendar year).")
|
|
131
|
+
}),
|
|
132
|
+
handler: async (args) => {
|
|
133
|
+
const { date: dateStr, timezone, fiscal_year_start_month: rawFyStart } = args;
|
|
134
|
+
const { zone, error: zoneError } = resolveZone(timezone);
|
|
135
|
+
if (zoneError) return `Error: ${zoneError}`;
|
|
136
|
+
let dt;
|
|
137
|
+
if (dateStr.toLowerCase() === "now") dt = luxon.DateTime.now().setZone(zone);
|
|
138
|
+
else {
|
|
139
|
+
dt = luxon.DateTime.fromISO(dateStr, { zone });
|
|
140
|
+
if (!dt.isValid) {
|
|
141
|
+
const parsed = chrono_node.parseDate(dateStr, /* @__PURE__ */ new Date());
|
|
142
|
+
if (!parsed) return `Error: Could not parse date "${dateStr}".`;
|
|
143
|
+
dt = luxon.DateTime.fromJSDate(parsed).setZone(zone);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const fyStart = Math.max(1, Math.min(12, Math.floor(rawFyStart)));
|
|
147
|
+
const calendarQuarter = Math.ceil(dt.month / 3);
|
|
148
|
+
const monthInFY = (dt.month - fyStart + 12) % 12;
|
|
149
|
+
const fiscalQuarter = Math.floor(monthInFY / 3) + 1;
|
|
150
|
+
const fiscalYear = dt.month >= fyStart ? dt.year : dt.year - 1;
|
|
151
|
+
const firstOfMonth = dt.startOf("month");
|
|
152
|
+
const weekOfMonth = Math.ceil((dt.day + firstOfMonth.weekday - 1) / 7);
|
|
153
|
+
const dayOfYear = Math.floor(dt.diff(dt.startOf("year"), "days").days) + 1;
|
|
154
|
+
const isWeekend = dt.weekday >= 6;
|
|
155
|
+
return [
|
|
156
|
+
`Date: ${dt.toISODate()} (${dt.toFormat("cccc, LLLL d, yyyy")})`,
|
|
157
|
+
"",
|
|
158
|
+
`ISO week number: ${dt.weekNumber} (ISO year: ${dt.weekYear})`,
|
|
159
|
+
`Day of year: ${dayOfYear} / ${dt.daysInYear}`,
|
|
160
|
+
`Day of week: ${dt.weekday} (${dt.toFormat("cccc")})`,
|
|
161
|
+
`Week of month: ${weekOfMonth}`,
|
|
162
|
+
`Weekend: ${isWeekend ? "Yes" : "No"}`,
|
|
163
|
+
"",
|
|
164
|
+
`Calendar quarter: Q${calendarQuarter}`,
|
|
165
|
+
`Fiscal quarter: FQ${fiscalQuarter} (FY${fiscalYear}${fyStart !== 1 ? `, starts month ${fyStart}` : ""})`
|
|
166
|
+
].join("\n");
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* Parse a date/time expression from natural language or common formats.
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* Examples: `"next Monday"`, `"March 5th"`, `"in 2 weeks"`, `"yesterday"`. Uses chrono-node for
|
|
174
|
+
* relative parsing. `reference_date` overrides the "now" anchor.
|
|
175
|
+
*/
|
|
176
|
+
var dateParseTool = new require_tool.Tool({
|
|
177
|
+
name: "date_parse",
|
|
178
|
+
description: "Parse a date/time string from natural language or common formats (\"next Monday\", \"March 5th\", \"in 2 weeks\", \"yesterday\"). Returns an ISO 8601 date.",
|
|
179
|
+
inputSchema: _nhtio_validation.validator.object({
|
|
180
|
+
text: _nhtio_validation.validator.string().required().description("Date/time expression to parse (natural language or structured)"),
|
|
181
|
+
reference_date: _nhtio_validation.validator.string().optional().description("ISO date to treat as \"now\" for relative expressions (default: current time)"),
|
|
182
|
+
timezone: _nhtio_validation.validator.string().optional().description("IANA timezone for the result (optional, defaults UTC)")
|
|
183
|
+
}),
|
|
184
|
+
handler: async (args) => {
|
|
185
|
+
const { text, reference_date: referenceDate, timezone } = args;
|
|
186
|
+
const { zone, error: zoneError } = resolveZone(timezone);
|
|
187
|
+
if (zoneError) return `Error: ${zoneError}`;
|
|
188
|
+
let refDate = /* @__PURE__ */ new Date();
|
|
189
|
+
if (referenceDate) {
|
|
190
|
+
refDate = new Date(referenceDate);
|
|
191
|
+
if (Number.isNaN(refDate.getTime())) return `Error: Invalid reference_date "${referenceDate}".`;
|
|
192
|
+
}
|
|
193
|
+
const parsed = chrono_node.parseDate(text, refDate);
|
|
194
|
+
if (!parsed) return `Error: Could not parse a date from "${text}".`;
|
|
195
|
+
const dt = luxon.DateTime.fromJSDate(parsed).setZone(zone);
|
|
196
|
+
return `ISO: ${dt.toISO()}\nFormatted: ${dt.toFormat("cccc, LLLL d, yyyy h:mm a ZZZZ")}`;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* Get the start or end of a time period containing a given date.
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* Periods: `day`, `week`, `isoweek` (Monday-start), `month`, `quarter`, `year`. Quarter and year
|
|
204
|
+
* honour `fiscal_year_start_month` for fiscal calendars (default: 1 = calendar year).
|
|
205
|
+
*/
|
|
206
|
+
var datePeriodTool = new require_tool.Tool({
|
|
207
|
+
name: "date_period",
|
|
208
|
+
description: "Get the start or end of a time period (day, week, month, quarter, year) containing a given date. Supports fiscal year offsets.",
|
|
209
|
+
inputSchema: _nhtio_validation.validator.object({
|
|
210
|
+
date: _nhtio_validation.validator.string().required().description("ISO 8601 date or \"now\""),
|
|
211
|
+
period: _nhtio_validation.validator.string().valid("day", "week", "isoweek", "month", "quarter", "year").required().description("Time period (isoweek = Monday-start week)"),
|
|
212
|
+
boundary: _nhtio_validation.validator.string().valid("start", "end").required().description("\"start\" for the first moment, \"end\" for the last moment of the period"),
|
|
213
|
+
timezone: _nhtio_validation.validator.string().optional().description("IANA timezone (optional, defaults UTC)"),
|
|
214
|
+
fiscal_year_start_month: _nhtio_validation.validator.number().default(1).description("For quarter/year: month number when the fiscal year starts (1–12, default: 1 = calendar year)")
|
|
215
|
+
}),
|
|
216
|
+
handler: async (args) => {
|
|
217
|
+
const { date: dateStr, period, boundary, timezone, fiscal_year_start_month: rawFyStart } = args;
|
|
218
|
+
const { zone, error: zoneError } = resolveZone(timezone);
|
|
219
|
+
if (zoneError) return `Error: ${zoneError}`;
|
|
220
|
+
const dt = dateStr.toLowerCase() === "now" ? luxon.DateTime.now().setZone(zone) : luxon.DateTime.fromISO(dateStr, { zone });
|
|
221
|
+
if (!dt.isValid) return `Error: Invalid date "${dateStr}".`;
|
|
222
|
+
const fyStart = Math.max(1, Math.min(12, Math.floor(rawFyStart)));
|
|
223
|
+
let result;
|
|
224
|
+
switch (period) {
|
|
225
|
+
case "day":
|
|
226
|
+
result = boundary === "start" ? dt.startOf("day") : dt.endOf("day");
|
|
227
|
+
break;
|
|
228
|
+
case "week":
|
|
229
|
+
result = boundary === "start" ? dt.startOf("week") : dt.endOf("week");
|
|
230
|
+
break;
|
|
231
|
+
case "isoweek":
|
|
232
|
+
result = boundary === "start" ? dt.startOf("week").set({ weekday: 1 }) : dt.startOf("week").set({ weekday: 7 }).endOf("day");
|
|
233
|
+
break;
|
|
234
|
+
case "month":
|
|
235
|
+
result = boundary === "start" ? dt.startOf("month") : dt.endOf("month");
|
|
236
|
+
break;
|
|
237
|
+
case "quarter": {
|
|
238
|
+
const monthInFY = (dt.month - fyStart + 12) % 12;
|
|
239
|
+
const qStartMonth = (Math.floor(monthInFY / 3) * 3 + fyStart - 1) % 12 + 1;
|
|
240
|
+
const qStart = dt.set({
|
|
241
|
+
month: qStartMonth,
|
|
242
|
+
day: 1
|
|
243
|
+
}).startOf("day");
|
|
244
|
+
const adjusted = qStart > dt ? qStart.minus({ months: 3 }) : qStart;
|
|
245
|
+
result = boundary === "start" ? adjusted : adjusted.plus({ months: 3 }).minus({ days: 1 }).endOf("day");
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case "year":
|
|
249
|
+
if (fyStart === 1) result = boundary === "start" ? dt.startOf("year") : dt.endOf("year");
|
|
250
|
+
else {
|
|
251
|
+
const fyStartThis = dt.set({
|
|
252
|
+
month: fyStart,
|
|
253
|
+
day: 1
|
|
254
|
+
}).startOf("day");
|
|
255
|
+
const fyBase = dt >= fyStartThis ? fyStartThis : fyStartThis.minus({ years: 1 });
|
|
256
|
+
result = boundary === "start" ? fyBase : fyBase.plus({ years: 1 }).minus({ days: 1 }).endOf("day");
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return `${boundary === "start" ? "Start" : "End"} of ${period} containing ${dateStr}: ${result.toISO()}\nFormatted: ${result.toFormat("cccc, LLLL d, yyyy h:mm:ss a ZZZZ")}`;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
/**
|
|
264
|
+
* Count business days between two dates, or compute the date N business days away.
|
|
265
|
+
*
|
|
266
|
+
* @remarks
|
|
267
|
+
* Monday–Friday only; no holiday calendar awareness. Provide either `to` (count between) or
|
|
268
|
+
* `add_days` (compute target date). Negative `add_days` walks backwards.
|
|
269
|
+
*/
|
|
270
|
+
var dateBusinessDaysTool = new require_tool.Tool({
|
|
271
|
+
name: "date_business_days",
|
|
272
|
+
description: "Count business days (Mon–Fri, no holiday awareness) between two dates, or calculate the date that is N business days from a start date.",
|
|
273
|
+
inputSchema: _nhtio_validation.validator.object({
|
|
274
|
+
from: _nhtio_validation.validator.string().required().description("Start date (ISO 8601 or \"now\")"),
|
|
275
|
+
to: _nhtio_validation.validator.string().optional().description("End date (ISO 8601 or \"now\") — for counting business days between two dates"),
|
|
276
|
+
add_days: _nhtio_validation.validator.number().optional().description("Instead of \"to\": number of business days to add (negative to subtract)"),
|
|
277
|
+
timezone: _nhtio_validation.validator.string().optional().description("IANA timezone (optional, defaults UTC)")
|
|
278
|
+
}),
|
|
279
|
+
handler: async (args) => {
|
|
280
|
+
const { from: fromStr, to: toStr, add_days: addDays, timezone } = args;
|
|
281
|
+
const { zone, error: zoneError } = resolveZone(timezone);
|
|
282
|
+
if (zoneError) return `Error: ${zoneError}`;
|
|
283
|
+
const fromDt = (fromStr.toLowerCase() === "now" ? luxon.DateTime.now() : luxon.DateTime.fromISO(fromStr)).setZone(zone);
|
|
284
|
+
if (!fromDt.isValid) return `Error: Invalid from date "${fromStr}".`;
|
|
285
|
+
if (addDays !== void 0) {
|
|
286
|
+
const n = Math.floor(addDays);
|
|
287
|
+
let cursor = fromDt.startOf("day");
|
|
288
|
+
let remaining = Math.abs(n);
|
|
289
|
+
const dir = n >= 0 ? 1 : -1;
|
|
290
|
+
while (remaining > 0) {
|
|
291
|
+
cursor = cursor.plus({ days: dir });
|
|
292
|
+
if (cursor.weekday <= 5) remaining--;
|
|
293
|
+
}
|
|
294
|
+
return `${n >= 0 ? "+" : ""}${n} business day${Math.abs(n) !== 1 ? "s" : ""} from ${fromStr}: ${cursor.toISODate()}\nFormatted: ${cursor.toFormat("cccc, LLLL d, yyyy")}`;
|
|
295
|
+
}
|
|
296
|
+
if (!toStr) return "Error: Provide either \"to\" date or \"add_days\".";
|
|
297
|
+
const toDt = (toStr.toLowerCase() === "now" ? luxon.DateTime.now() : luxon.DateTime.fromISO(toStr)).setZone(zone);
|
|
298
|
+
if (!toDt.isValid) return `Error: Invalid to date "${toStr}".`;
|
|
299
|
+
return `Business days from ${fromStr} to ${toStr}: ${countBusinessDays(fromDt, toDt)}`;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
//#endregion
|
|
303
|
+
exports.dateBusinessDaysTool = dateBusinessDaysTool;
|
|
304
|
+
exports.dateCalendarInfoTool = dateCalendarInfoTool;
|
|
305
|
+
exports.dateNthWeekdayTool = dateNthWeekdayTool;
|
|
306
|
+
exports.dateParseTool = dateParseTool;
|
|
307
|
+
exports.datePeriodTool = datePeriodTool;
|
|
308
|
+
|
|
309
|
+
//# sourceMappingURL=datetime_extended.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datetime_extended.cjs","names":[],"sources":["../../../src/batteries/tools/datetime_extended/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for parsing natural-language dates and business-calendar calculations.\n *\n * @module @nhtio/adk/batteries/tools/datetime_extended\n *\n * @remarks\n * Pre-constructed bundled tools for the `datetime_extended` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport * as chrono from 'chrono-node'\nimport { Tool } from '@nhtio/adk/common'\nimport { DateTime, IANAZone } from 'luxon'\nimport { validator } from '@nhtio/validation'\n\nfunction resolveZone(timezone: string | undefined): { zone: string; error?: string } {\n if (!timezone) return { zone: 'UTC' }\n if (!IANAZone.isValidZone(timezone)) return { zone: '', error: `Invalid timezone \"${timezone}\".` }\n return { zone: timezone }\n}\n\nfunction countBusinessDays(from: DateTime, to: DateTime): number {\n const forward = to >= from\n const start = forward ? from.startOf('day') : to.startOf('day')\n const end = forward ? to.startOf('day') : from.startOf('day')\n\n const totalDays = Math.round(end.diff(start, 'days').days)\n const fullWeeks = Math.floor(totalDays / 7)\n let bdays = fullWeeks * 5\n\n let cursor = start.plus({ days: fullWeeks * 7 })\n while (cursor < end) {\n cursor = cursor.plus({ days: 1 })\n if (cursor.weekday <= 5) bdays++\n }\n\n return forward ? bdays : -bdays\n}\n\n/**\n * Find the Nth occurrence of a weekday in a given month.\n *\n * @remarks\n * Examples: \"2nd Friday of March 2026\", \"last Monday of January 2025\". Accepts 1st–5th and\n * `last`. Returns an error if the month does not contain that many occurrences of the weekday.\n */\nexport const dateNthWeekdayTool = new Tool({\n name: 'date_nth_weekday',\n description:\n 'Find the Nth occurrence of a weekday in a given month (e.g., \"2nd Friday of March 2026\", \"last Monday of next month\"). Supports 1st–5th and \"last\".',\n inputSchema: validator.object({\n nth: validator\n .string()\n .required()\n .description('Which occurrence: \"1st\", \"2nd\", \"3rd\", \"4th\", \"5th\", or \"last\".'),\n weekday: validator\n .string()\n .valid('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')\n .required()\n .description('Day of the week.'),\n month: validator.number().required().description('Month number (1–12).'),\n year: validator.number().optional().description('Year (defaults to current year).'),\n timezone: validator.string().optional().description('IANA timezone (optional, defaults UTC).'),\n }),\n handler: async (args) => {\n const {\n nth,\n weekday,\n month: rawMonth,\n year: rawYear,\n timezone,\n } = args as {\n nth: string\n weekday: string\n month: number\n year?: number\n timezone?: string\n }\n const { zone, error: zoneError } = resolveZone(timezone)\n if (zoneError) return `Error: ${zoneError}`\n\n const weekdayNames: Record<string, number> = {\n monday: 1,\n tuesday: 2,\n wednesday: 3,\n thursday: 4,\n friday: 5,\n saturday: 6,\n sunday: 7,\n }\n\n const targetWeekday = weekdayNames[weekday.toLowerCase()]\n const month = Math.floor(rawMonth)\n if (month < 1 || month > 12) return `Error: Month must be 1–12, got ${rawMonth}.`\n\n const year = Math.floor(rawYear ?? DateTime.now().setZone(zone).year)\n const nthRaw = nth.toLowerCase().replace(/\\s/g, '')\n\n const firstOfMonth = DateTime.fromObject({ year, month, day: 1 }, { zone })\n if (!firstOfMonth.isValid) return `Error: Invalid date for ${year}-${month}.`\n\n const occurrences: DateTime[] = []\n let cursor = firstOfMonth\n while (cursor.weekday !== targetWeekday) {\n cursor = cursor.plus({ days: 1 })\n }\n while (cursor.month === month) {\n occurrences.push(cursor)\n cursor = cursor.plus({ weeks: 1 })\n }\n\n let result: DateTime | undefined\n\n if (nthRaw === 'last') {\n result = occurrences[occurrences.length - 1]\n } else {\n const nthMap: Record<string, number> = {\n '1st': 1,\n '1': 1,\n 'first': 1,\n '2nd': 2,\n '2': 2,\n 'second': 2,\n '3rd': 3,\n '3': 3,\n 'third': 3,\n '4th': 4,\n '4': 4,\n 'fourth': 4,\n '5th': 5,\n '5': 5,\n 'fifth': 5,\n }\n const n = nthMap[nthRaw]\n if (!n) return `Error: Invalid nth value \"${nth}\". Use 1st–5th or \"last\".`\n if (n > occurrences.length) {\n return `Error: There is no ${nth} ${weekday} in ${firstOfMonth.toFormat('LLLL yyyy')} (only ${occurrences.length} occurrence${occurrences.length !== 1 ? 's' : ''}).`\n }\n result = occurrences[n - 1]\n }\n\n if (!result) return 'Error: Could not compute the date.'\n\n return `${nth} ${weekday} of ${result.toFormat('LLLL yyyy')}: ${result.toISODate()}\\nFormatted: ${result.toFormat('cccc, LLLL d, yyyy')}`\n },\n})\n\n/**\n * Get calendar metadata for a date.\n *\n * @remarks\n * Reports ISO week number, day of year, calendar quarter, fiscal quarter/year (configurable via\n * `fiscal_year_start_month`), week of month, and whether the date is a weekend. Accepts ISO\n * dates, natural-language (\"next Tuesday\"), and `now`.\n */\nexport const dateCalendarInfoTool = new Tool({\n name: 'date_calendar_info',\n description:\n 'Get calendar metadata for a date: ISO week number, day of year, calendar quarter, fiscal quarter/year, week of month, and whether it is a weekend or weekday.',\n inputSchema: validator.object({\n date: validator\n .string()\n .required()\n .description('ISO 8601 date, natural language date, or \"now\".'),\n timezone: validator.string().optional().description('IANA timezone (optional, defaults UTC).'),\n fiscal_year_start_month: validator\n .number()\n .default(1)\n .description('Month when fiscal year starts (1–12, default: 1 = calendar year).'),\n }),\n handler: async (args) => {\n const {\n date: dateStr,\n timezone,\n fiscal_year_start_month: rawFyStart,\n } = args as {\n date: string\n timezone?: string\n fiscal_year_start_month: number\n }\n const { zone, error: zoneError } = resolveZone(timezone)\n if (zoneError) return `Error: ${zoneError}`\n\n let dt: DateTime\n\n if (dateStr.toLowerCase() === 'now') {\n dt = DateTime.now().setZone(zone)\n } else {\n dt = DateTime.fromISO(dateStr, { zone })\n if (!dt.isValid) {\n const parsed = chrono.parseDate(dateStr, new Date())\n if (!parsed) return `Error: Could not parse date \"${dateStr}\".`\n dt = DateTime.fromJSDate(parsed).setZone(zone)\n }\n }\n\n const fyStart = Math.max(1, Math.min(12, Math.floor(rawFyStart)))\n\n const calendarQuarter = Math.ceil(dt.month / 3)\n\n const monthInFY = (dt.month - fyStart + 12) % 12\n const fiscalQuarter = Math.floor(monthInFY / 3) + 1\n const fiscalYear = dt.month >= fyStart ? dt.year : dt.year - 1\n\n const firstOfMonth = dt.startOf('month')\n const weekOfMonth = Math.ceil((dt.day + firstOfMonth.weekday - 1) / 7)\n\n const dayOfYear = Math.floor(dt.diff(dt.startOf('year'), 'days').days) + 1\n\n const isWeekend = dt.weekday >= 6\n\n const lines = [\n `Date: ${dt.toISODate()} (${dt.toFormat('cccc, LLLL d, yyyy')})`,\n '',\n `ISO week number: ${dt.weekNumber} (ISO year: ${dt.weekYear})`,\n `Day of year: ${dayOfYear} / ${dt.daysInYear}`,\n `Day of week: ${dt.weekday} (${dt.toFormat('cccc')})`,\n `Week of month: ${weekOfMonth}`,\n `Weekend: ${isWeekend ? 'Yes' : 'No'}`,\n '',\n `Calendar quarter: Q${calendarQuarter}`,\n `Fiscal quarter: FQ${fiscalQuarter} (FY${fiscalYear}${fyStart !== 1 ? `, starts month ${fyStart}` : ''})`,\n ]\n\n return lines.join('\\n')\n },\n})\n\n/**\n * Parse a date/time expression from natural language or common formats.\n *\n * @remarks\n * Examples: `\"next Monday\"`, `\"March 5th\"`, `\"in 2 weeks\"`, `\"yesterday\"`. Uses chrono-node for\n * relative parsing. `reference_date` overrides the \"now\" anchor.\n */\nexport const dateParseTool = new Tool({\n name: 'date_parse',\n description:\n 'Parse a date/time string from natural language or common formats (\"next Monday\", \"March 5th\", \"in 2 weeks\", \"yesterday\"). Returns an ISO 8601 date.',\n inputSchema: validator.object({\n text: validator\n .string()\n .required()\n .description('Date/time expression to parse (natural language or structured)'),\n reference_date: validator\n .string()\n .optional()\n .description('ISO date to treat as \"now\" for relative expressions (default: current time)'),\n timezone: validator\n .string()\n .optional()\n .description('IANA timezone for the result (optional, defaults UTC)'),\n }),\n handler: async (args) => {\n const {\n text,\n reference_date: referenceDate,\n timezone,\n } = args as {\n text: string\n reference_date?: string\n timezone?: string\n }\n const { zone, error: zoneError } = resolveZone(timezone)\n if (zoneError) return `Error: ${zoneError}`\n\n let refDate = new Date()\n if (referenceDate) {\n refDate = new Date(referenceDate)\n if (Number.isNaN(refDate.getTime()))\n return `Error: Invalid reference_date \"${referenceDate}\".`\n }\n\n const parsed = chrono.parseDate(text, refDate)\n if (!parsed) return `Error: Could not parse a date from \"${text}\".`\n\n const dt = DateTime.fromJSDate(parsed).setZone(zone)\n return `ISO: ${dt.toISO()}\\nFormatted: ${dt.toFormat('cccc, LLLL d, yyyy h:mm a ZZZZ')}`\n },\n})\n\n/**\n * Get the start or end of a time period containing a given date.\n *\n * @remarks\n * Periods: `day`, `week`, `isoweek` (Monday-start), `month`, `quarter`, `year`. Quarter and year\n * honour `fiscal_year_start_month` for fiscal calendars (default: 1 = calendar year).\n */\nexport const datePeriodTool = new Tool({\n name: 'date_period',\n description:\n 'Get the start or end of a time period (day, week, month, quarter, year) containing a given date. Supports fiscal year offsets.',\n inputSchema: validator.object({\n date: validator.string().required().description('ISO 8601 date or \"now\"'),\n period: validator\n .string()\n .valid('day', 'week', 'isoweek', 'month', 'quarter', 'year')\n .required()\n .description('Time period (isoweek = Monday-start week)'),\n boundary: validator\n .string()\n .valid('start', 'end')\n .required()\n .description('\"start\" for the first moment, \"end\" for the last moment of the period'),\n timezone: validator.string().optional().description('IANA timezone (optional, defaults UTC)'),\n fiscal_year_start_month: validator\n .number()\n .default(1)\n .description(\n 'For quarter/year: month number when the fiscal year starts (1–12, default: 1 = calendar year)'\n ),\n }),\n handler: async (args) => {\n const {\n date: dateStr,\n period,\n boundary,\n timezone,\n fiscal_year_start_month: rawFyStart,\n } = args as {\n date: string\n period: 'day' | 'week' | 'isoweek' | 'month' | 'quarter' | 'year'\n boundary: 'start' | 'end'\n timezone?: string\n fiscal_year_start_month: number\n }\n const { zone, error: zoneError } = resolveZone(timezone)\n if (zoneError) return `Error: ${zoneError}`\n\n const dt =\n dateStr.toLowerCase() === 'now'\n ? DateTime.now().setZone(zone)\n : DateTime.fromISO(dateStr, { zone })\n if (!dt.isValid) return `Error: Invalid date \"${dateStr}\".`\n\n const fyStart = Math.max(1, Math.min(12, Math.floor(rawFyStart)))\n\n let result: DateTime\n\n switch (period) {\n case 'day':\n result = boundary === 'start' ? dt.startOf('day') : dt.endOf('day')\n break\n case 'week':\n result = boundary === 'start' ? dt.startOf('week') : dt.endOf('week')\n break\n case 'isoweek':\n result =\n boundary === 'start'\n ? dt.startOf('week').set({ weekday: 1 })\n : dt.startOf('week').set({ weekday: 7 }).endOf('day')\n break\n case 'month':\n result = boundary === 'start' ? dt.startOf('month') : dt.endOf('month')\n break\n case 'quarter': {\n const monthInFY = (dt.month - fyStart + 12) % 12\n const qIndex = Math.floor(monthInFY / 3)\n const qStartMonth = ((qIndex * 3 + fyStart - 1) % 12) + 1\n const qStart = dt.set({ month: qStartMonth, day: 1 }).startOf('day')\n const adjusted = qStart > dt ? qStart.minus({ months: 3 }) : qStart\n result =\n boundary === 'start'\n ? adjusted\n : adjusted.plus({ months: 3 }).minus({ days: 1 }).endOf('day')\n break\n }\n case 'year':\n if (fyStart === 1) {\n result = boundary === 'start' ? dt.startOf('year') : dt.endOf('year')\n } else {\n const fyStartThis = dt.set({ month: fyStart, day: 1 }).startOf('day')\n const fyBase = dt >= fyStartThis ? fyStartThis : fyStartThis.minus({ years: 1 })\n result =\n boundary === 'start'\n ? fyBase\n : fyBase.plus({ years: 1 }).minus({ days: 1 }).endOf('day')\n }\n break\n }\n\n return `${boundary === 'start' ? 'Start' : 'End'} of ${period} containing ${dateStr}: ${result.toISO()}\\nFormatted: ${result.toFormat('cccc, LLLL d, yyyy h:mm:ss a ZZZZ')}`\n },\n})\n\n/**\n * Count business days between two dates, or compute the date N business days away.\n *\n * @remarks\n * Monday–Friday only; no holiday calendar awareness. Provide either `to` (count between) or\n * `add_days` (compute target date). Negative `add_days` walks backwards.\n */\nexport const dateBusinessDaysTool = new Tool({\n name: 'date_business_days',\n description:\n 'Count business days (Mon–Fri, no holiday awareness) between two dates, or calculate the date that is N business days from a start date.',\n inputSchema: validator.object({\n from: validator.string().required().description('Start date (ISO 8601 or \"now\")'),\n to: validator\n .string()\n .optional()\n .description('End date (ISO 8601 or \"now\") — for counting business days between two dates'),\n add_days: validator\n .number()\n .optional()\n .description('Instead of \"to\": number of business days to add (negative to subtract)'),\n timezone: validator.string().optional().description('IANA timezone (optional, defaults UTC)'),\n }),\n handler: async (args) => {\n const {\n from: fromStr,\n to: toStr,\n add_days: addDays,\n timezone,\n } = args as {\n from: string\n to?: string\n add_days?: number\n timezone?: string\n }\n const { zone, error: zoneError } = resolveZone(timezone)\n if (zoneError) return `Error: ${zoneError}`\n\n const fromDt = (\n fromStr.toLowerCase() === 'now' ? DateTime.now() : DateTime.fromISO(fromStr)\n ).setZone(zone)\n if (!fromDt.isValid) return `Error: Invalid from date \"${fromStr}\".`\n\n if (addDays !== undefined) {\n const n = Math.floor(addDays)\n let cursor = fromDt.startOf('day')\n let remaining = Math.abs(n)\n const dir = n >= 0 ? 1 : -1\n while (remaining > 0) {\n cursor = cursor.plus({ days: dir })\n if (cursor.weekday <= 5) remaining--\n }\n return `${n >= 0 ? '+' : ''}${n} business day${Math.abs(n) !== 1 ? 's' : ''} from ${fromStr}: ${cursor.toISODate()}\\nFormatted: ${cursor.toFormat('cccc, LLLL d, yyyy')}`\n }\n\n if (!toStr) return 'Error: Provide either \"to\" date or \"add_days\".'\n\n const toDt = (toStr.toLowerCase() === 'now' ? DateTime.now() : DateTime.fromISO(toStr)).setZone(\n zone\n )\n if (!toDt.isValid) return `Error: Invalid to date \"${toStr}\".`\n\n const count = countBusinessDays(fromDt, toDt)\n return `Business days from ${fromStr} to ${toStr}: ${count}`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;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