@kirha/planner 0.1.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.
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ import { type ParamsValue, type PlanStep } from "../types";
3
+ export declare const ParamSchema: z.ZodType<ParamsValue>;
4
+ export declare function parseModelOutput(raw: string): {
5
+ think: string | undefined;
6
+ plan: PlanStep[] | undefined;
7
+ };
8
+ export declare function parsePlanSteps(rawSteps: string): PlanStep[];
@@ -0,0 +1,2 @@
1
+ import type { StringTemplateReference } from "../types";
2
+ export declare function parseTemplateString(tpl: string, stepIdByIndex: Map<number, string>): StringTemplateReference | string;
@@ -0,0 +1,64 @@
1
+ export type ToolHandler<TInput = unknown, TOutput = unknown> = (args: TInput) => Promise<TOutput>;
2
+ export interface Tool<TInput = unknown, TOutput = unknown> {
3
+ name: string;
4
+ description: string;
5
+ inputSchema: string;
6
+ outputSchema: string;
7
+ handler: ToolHandler<TInput, TOutput>;
8
+ }
9
+ export interface StepResult {
10
+ stepId: string;
11
+ toolName: string;
12
+ arguments: Record<string, unknown>;
13
+ output: unknown;
14
+ error?: string;
15
+ }
16
+ export type PlanValidationErrorCode = "tool_not_found" | "schema_parse_error" | "dependency_step_missing" | "input_key_missing" | "output_key_missing" | "type_mismatch";
17
+ export interface PlanValidationError {
18
+ code: PlanValidationErrorCode;
19
+ message: string;
20
+ stepId?: string;
21
+ toolName?: string;
22
+ argumentPath?: string;
23
+ fromStepId?: string;
24
+ outputPath?: string;
25
+ expectedType?: string;
26
+ actualType?: string;
27
+ }
28
+ export interface PlanValidationResult {
29
+ valid: boolean;
30
+ errors: PlanValidationError[];
31
+ }
32
+ export interface DependencyReference {
33
+ $fromStep: string;
34
+ $outputKey: string;
35
+ }
36
+ export interface StringTemplateReference {
37
+ $fromTemplateString: string;
38
+ $values: DependencyReference[];
39
+ }
40
+ export interface RawDependencyReference {
41
+ fromStep: number;
42
+ outputKey: string;
43
+ }
44
+ export type ParamsValue = string | number | boolean | null | ParamObject | DependencyReference | StringTemplateReference | Array<ParamsValue | DependencyReference>;
45
+ interface ParamObject {
46
+ [key: string]: ParamsValue;
47
+ }
48
+ export type PlanStepParams = Record<string, ParamsValue>;
49
+ export declare enum PlanStepStatus {
50
+ Pending = "pending",
51
+ Executing = "executing",
52
+ Done = "done",
53
+ Failed = "failed",
54
+ Skipped = "skipped",
55
+ Timeout = "timeout"
56
+ }
57
+ export interface PlanStep {
58
+ stepId: string;
59
+ status: PlanStepStatus;
60
+ toolName: string;
61
+ arguments: PlanStepParams;
62
+ thought?: string;
63
+ }
64
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { DependencyReference, RawDependencyReference, StringTemplateReference } from "./types";
2
+ export type PathSegment = string | number;
3
+ export type Path = PathSegment[];
4
+ export declare function parsePath(path: string): Path;
5
+ export declare function normalizePath(path: string): string;
6
+ export declare function formatPath(path: Path): string;
7
+ export declare function isNumericString(value: string): boolean;
8
+ export declare function getNestedValue(obj: unknown, path: Path): unknown;
9
+ export type ReferenceCallbacks = {
10
+ onDependency?: (ref: DependencyReference, path: Path) => void;
11
+ onTemplate?: (ref: StringTemplateReference, path: Path) => void;
12
+ };
13
+ export declare function traverseReferences(value: unknown, callbacks: ReferenceCallbacks, currentPath?: Path): void;
14
+ export declare function extractDependencyStepIds(args: Record<string, unknown>): string[];
15
+ export declare function isDependencyReference(value: unknown): value is DependencyReference;
16
+ export declare function isStringTemplateReference(value: unknown): value is StringTemplateReference;
17
+ export declare function isRawDependencyReference(value: unknown): value is RawDependencyReference;
@@ -0,0 +1,2 @@
1
+ import type { PlanStep, PlanValidationResult, Tool } from "../types";
2
+ export declare function isValidPlan(steps: PlanStep[], tools: Tool[]): PlanValidationResult;
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@kirha/planner",
3
+ "version": "0.1.0",
4
+ "description": "SDK for tool-planning agents - generate and execute DAG execution plans from natural language",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "bun build ./src/index.ts --outdir ./dist --target node && bun run build:types",
21
+ "build:types": "tsc --project tsconfig.build.json",
22
+ "test": "bun test",
23
+ "lint": "biome check --write",
24
+ "prepublishOnly": "bun run build"
25
+ },
26
+ "keywords": [
27
+ "ai",
28
+ "llm",
29
+ "agent",
30
+ "tool-planning",
31
+ "dag",
32
+ "execution-plan",
33
+ "openai"
34
+ ],
35
+ "author": "Kirha",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/kirha-ai/planner-typescript-sdk"
40
+ },
41
+ "devDependencies": {
42
+ "@biomejs/biome": "2.3.10",
43
+ "@types/bun": "latest",
44
+ "@types/uuid": "^11.0.0",
45
+ "typescript": "^5.0.0"
46
+ },
47
+ "peerDependencies": {
48
+ "typescript": "^5"
49
+ },
50
+ "dependencies": {
51
+ "json5": "^2.2.3",
52
+ "openai": "^6.14.0",
53
+ "uuid": "^13.0.0",
54
+ "zod": "^4.2.1"
55
+ }
56
+ }