toolcraft 0.0.2 → 0.0.4

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.
Files changed (85) hide show
  1. package/README.md +461 -58
  2. package/dist/cli.compile-check.js +1 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +768 -40
  5. package/dist/human-in-loop/approval-tasks.d.ts +31 -0
  6. package/dist/human-in-loop/approval-tasks.js +201 -0
  7. package/dist/human-in-loop/approvals-commands.d.ts +11 -0
  8. package/dist/human-in-loop/approvals-commands.js +191 -0
  9. package/dist/human-in-loop/config.d.ts +11 -0
  10. package/dist/human-in-loop/config.js +21 -0
  11. package/dist/human-in-loop/default-provider.d.ts +2 -0
  12. package/dist/human-in-loop/default-provider.js +26 -0
  13. package/dist/human-in-loop/gate.d.ts +4 -0
  14. package/dist/human-in-loop/gate.js +57 -0
  15. package/dist/human-in-loop/index.d.ts +7 -0
  16. package/dist/human-in-loop/index.js +4 -0
  17. package/dist/human-in-loop/runner.d.ts +3 -0
  18. package/dist/human-in-loop/runner.js +196 -0
  19. package/dist/human-in-loop/spawn.d.ts +3 -0
  20. package/dist/human-in-loop/spawn.js +16 -0
  21. package/dist/human-in-loop/state-machine.d.ts +4 -0
  22. package/dist/human-in-loop/state-machine.js +10 -0
  23. package/dist/human-in-loop/types.d.ts +41 -0
  24. package/dist/human-in-loop/types.js +13 -0
  25. package/dist/index.compile-check.js +24 -0
  26. package/dist/index.d.ts +32 -13
  27. package/dist/index.js +82 -17
  28. package/dist/json-schema-converter.d.ts +21 -0
  29. package/dist/json-schema-converter.js +432 -0
  30. package/dist/mcp-proxy.d.ts +8 -0
  31. package/dist/mcp-proxy.js +383 -0
  32. package/dist/mcp.compile-check.js +1 -0
  33. package/dist/mcp.d.ts +2 -0
  34. package/dist/mcp.js +103 -11
  35. package/dist/sdk.compile-check.js +77 -0
  36. package/dist/sdk.d.ts +14 -5
  37. package/dist/sdk.js +57 -6
  38. package/dist/user-error.d.ts +3 -0
  39. package/dist/user-error.js +6 -0
  40. package/node_modules/@poe-code/agent-human-in-loop/README.md +42 -0
  41. package/node_modules/@poe-code/agent-human-in-loop/dist/index.d.ts +5 -0
  42. package/node_modules/@poe-code/agent-human-in-loop/dist/index.js +3 -0
  43. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/mock.d.ts +2 -0
  44. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/mock.js +11 -0
  45. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript-script.d.ts +4 -0
  46. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript-script.js +40 -0
  47. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript.d.ts +6 -0
  48. package/node_modules/@poe-code/agent-human-in-loop/dist/providers/osascript.js +33 -0
  49. package/node_modules/@poe-code/agent-human-in-loop/dist/request-approval.d.ts +4 -0
  50. package/node_modules/@poe-code/agent-human-in-loop/dist/request-approval.js +4 -0
  51. package/node_modules/@poe-code/agent-human-in-loop/dist/types.d.ts +14 -0
  52. package/node_modules/@poe-code/agent-human-in-loop/dist/types.js +1 -0
  53. package/node_modules/@poe-code/agent-human-in-loop/package.json +25 -0
  54. package/node_modules/@poe-code/agent-mcp-config/dist/apply.d.ts +6 -0
  55. package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +175 -0
  56. package/node_modules/@poe-code/agent-mcp-config/dist/configs.d.ts +22 -0
  57. package/node_modules/@poe-code/agent-mcp-config/dist/configs.js +74 -0
  58. package/node_modules/@poe-code/agent-mcp-config/dist/index.d.ts +3 -0
  59. package/node_modules/@poe-code/agent-mcp-config/dist/index.js +2 -0
  60. package/node_modules/@poe-code/agent-mcp-config/dist/shapes.d.ts +31 -0
  61. package/node_modules/@poe-code/agent-mcp-config/dist/shapes.js +87 -0
  62. package/node_modules/@poe-code/agent-mcp-config/dist/types.d.ts +25 -0
  63. package/node_modules/@poe-code/agent-mcp-config/dist/types.js +1 -0
  64. package/node_modules/@poe-code/agent-mcp-config/package.json +25 -0
  65. package/node_modules/@poe-code/task-list/README.md +114 -0
  66. package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.d.ts +2 -0
  67. package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +466 -0
  68. package/node_modules/@poe-code/task-list/dist/backends/utils.d.ts +8 -0
  69. package/node_modules/@poe-code/task-list/dist/backends/utils.js +58 -0
  70. package/node_modules/@poe-code/task-list/dist/backends/yaml-file.d.ts +2 -0
  71. package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +444 -0
  72. package/node_modules/@poe-code/task-list/dist/index.d.ts +4 -0
  73. package/node_modules/@poe-code/task-list/dist/index.js +4 -0
  74. package/node_modules/@poe-code/task-list/dist/open.d.ts +3 -0
  75. package/node_modules/@poe-code/task-list/dist/open.js +34 -0
  76. package/node_modules/@poe-code/task-list/dist/schema/store.schema.json +32 -0
  77. package/node_modules/@poe-code/task-list/dist/schema/task.schema.json +33 -0
  78. package/node_modules/@poe-code/task-list/dist/state-machine.d.ts +16 -0
  79. package/node_modules/@poe-code/task-list/dist/state-machine.js +67 -0
  80. package/node_modules/@poe-code/task-list/dist/state.d.ts +29 -0
  81. package/node_modules/@poe-code/task-list/dist/state.js +61 -0
  82. package/node_modules/@poe-code/task-list/dist/types.d.ts +116 -0
  83. package/node_modules/@poe-code/task-list/dist/types.js +37 -0
  84. package/node_modules/@poe-code/task-list/package.json +26 -0
  85. package/package.json +22 -7
@@ -0,0 +1,61 @@
1
+ import { findEvent } from "./state-machine.js";
2
+ import { InvalidTransitionError } from "./types.js";
3
+ export const defaultStateMachine = {
4
+ initial: "draft",
5
+ states: ["draft", "planned", "in-progress", "done", "archived"],
6
+ events: {
7
+ plan: { from: ["draft"], to: "planned" },
8
+ start: { from: ["planned"], to: "in-progress" },
9
+ complete: { from: ["in-progress"], to: "done" },
10
+ archive: { from: "*", to: "archived" }
11
+ }
12
+ };
13
+ function deriveLegacyTransitions(machine) {
14
+ const transitions = Object.fromEntries(machine.states.map((state) => [state, new Set()]));
15
+ for (const fromState of machine.states) {
16
+ for (const eventName of Object.keys(machine.events)) {
17
+ const event = findEvent(machine, fromState, eventName);
18
+ if (event !== undefined) {
19
+ transitions[fromState].add(event.to);
20
+ }
21
+ }
22
+ }
23
+ const terminalState = machine.events.archive.to;
24
+ const activeStates = machine.states.filter((state) => state !== terminalState);
25
+ for (let index = 1; index < activeStates.length; index += 1) {
26
+ transitions[activeStates[index]].add(activeStates[index - 1]);
27
+ }
28
+ return transitions;
29
+ }
30
+ const defaultTransitions = deriveLegacyTransitions(defaultStateMachine);
31
+ export function resolveStateMachine(stateMachine) {
32
+ return stateMachine ?? defaultStateMachine;
33
+ }
34
+ export function assertEvent(machine, fromState, eventName) {
35
+ const event = findEvent(machine, fromState, eventName);
36
+ if (event === undefined) {
37
+ throw new InvalidTransitionError(`Cannot fire event "${eventName}" from task state "${fromState}".`);
38
+ }
39
+ return event;
40
+ }
41
+ function canTransition(machine, fromState, toState) {
42
+ if (Object.is(machine, defaultStateMachine)) {
43
+ return defaultTransitions[fromState]?.has(toState) ?? false;
44
+ }
45
+ for (const eventName of Object.keys(machine.events)) {
46
+ if (findEvent(machine, fromState, eventName)?.to === toState) {
47
+ return true;
48
+ }
49
+ }
50
+ return false;
51
+ }
52
+ export function assertTransition(machineOrFrom, fromOrTo, maybeTo) {
53
+ const machine = maybeTo === undefined
54
+ ? defaultStateMachine
55
+ : machineOrFrom;
56
+ const fromState = maybeTo === undefined ? machineOrFrom : fromOrTo;
57
+ const toState = maybeTo === undefined ? fromOrTo : maybeTo;
58
+ if (!canTransition(machine, fromState, toState)) {
59
+ throw new InvalidTransitionError(`Cannot transition task from "${fromState}" to "${toState}".`);
60
+ }
61
+ }
@@ -0,0 +1,116 @@
1
+ import type { StateMachineDef } from "./state-machine.js";
2
+ export type TaskState = "draft" | "planned" | "in-progress" | "done" | "archived";
3
+ export interface Task {
4
+ list: string;
5
+ id: string;
6
+ qualifiedId: string;
7
+ name: string;
8
+ state: string;
9
+ description: string;
10
+ metadata: Record<string, unknown>;
11
+ }
12
+ export interface TaskCreate {
13
+ id: string;
14
+ name: string;
15
+ description?: string;
16
+ metadata?: Record<string, unknown>;
17
+ }
18
+ export interface TaskUpdate {
19
+ name?: string;
20
+ description?: string;
21
+ metadata?: Record<string, unknown>;
22
+ state?: never;
23
+ }
24
+ export interface TaskFireOptions {
25
+ metadataPatch?: Record<string, unknown>;
26
+ }
27
+ export interface ListFilter {
28
+ state?: string;
29
+ includeArchived?: boolean;
30
+ }
31
+ export interface Tasks {
32
+ readonly name: string;
33
+ readonly stateMachine: StateMachineDef;
34
+ all(filter?: ListFilter): Promise<Task[]>;
35
+ get(id: string): Promise<Task>;
36
+ create(input: TaskCreate): Promise<Task>;
37
+ update(id: string, patch: TaskUpdate): Promise<Task>;
38
+ fire(id: string, event: string, opts?: TaskFireOptions): Promise<Task>;
39
+ canFire(id: string, event: string): Promise<boolean>;
40
+ events(id: string): Promise<readonly string[]>;
41
+ delete(id: string): Promise<void>;
42
+ }
43
+ export interface TaskList {
44
+ list(name: string): Tasks;
45
+ lists(): Promise<string[]>;
46
+ allTasks(filter?: ListFilter): Promise<Task[]>;
47
+ get(qualifiedId: string): Promise<Task>;
48
+ }
49
+ export interface TaskDefaults {
50
+ metadata?: Record<string, unknown>;
51
+ }
52
+ export interface TaskListFs {
53
+ mkdir(path: string, options?: {
54
+ recursive?: boolean;
55
+ }): Promise<void>;
56
+ open(path: string, flags: string): Promise<{
57
+ close(): Promise<void>;
58
+ writeFile(data: string | NodeJS.ArrayBufferView, options?: BufferEncoding | {
59
+ encoding?: BufferEncoding;
60
+ }): Promise<void>;
61
+ }>;
62
+ readFile(path: string, encoding: BufferEncoding): Promise<string>;
63
+ readdir(path: string): Promise<string[]>;
64
+ rename(fromPath: string, toPath: string): Promise<void>;
65
+ stat(path: string): Promise<{
66
+ isDirectory(): boolean;
67
+ isFile(): boolean;
68
+ mtimeMs: number;
69
+ }>;
70
+ unlink(path: string): Promise<void>;
71
+ writeFile(path: string, data: string | NodeJS.ArrayBufferView, options?: BufferEncoding | {
72
+ encoding?: BufferEncoding;
73
+ flag?: string;
74
+ }): Promise<void>;
75
+ }
76
+ export interface OpenTaskListOptions {
77
+ type: "markdown-dir" | "yaml-file";
78
+ path: string;
79
+ defaults?: TaskDefaults;
80
+ create?: boolean;
81
+ lockStaleMs?: number;
82
+ lockRetries?: number;
83
+ fs?: TaskListFs;
84
+ stateMachine?: StateMachineDef;
85
+ }
86
+ export interface BackendDeps {
87
+ path: string;
88
+ defaults: Required<TaskDefaults>;
89
+ lockStaleMs: number;
90
+ lockRetries: number;
91
+ create: boolean;
92
+ fs: TaskListFs;
93
+ stateMachine?: StateMachineDef;
94
+ }
95
+ export type BackendFactory = (deps: BackendDeps) => Promise<TaskList>;
96
+ export declare class TaskNotFoundError extends Error {
97
+ constructor(message?: string);
98
+ }
99
+ export declare class TaskAlreadyExistsError extends Error {
100
+ constructor(message?: string);
101
+ }
102
+ export declare class InvalidTransitionError extends Error {
103
+ readonly task?: Task;
104
+ readonly event?: string;
105
+ readonly to?: string;
106
+ readonly reason: string;
107
+ constructor(messageOrOptions?: string | {
108
+ task?: Task;
109
+ event?: string;
110
+ to?: string;
111
+ reason: string;
112
+ });
113
+ }
114
+ export declare class MalformedTaskError extends Error {
115
+ constructor(message?: string);
116
+ }
@@ -0,0 +1,37 @@
1
+ export class TaskNotFoundError extends Error {
2
+ constructor(message = "Task not found.") {
3
+ super(message);
4
+ this.name = "TaskNotFoundError";
5
+ }
6
+ }
7
+ export class TaskAlreadyExistsError extends Error {
8
+ constructor(message = "Task already exists.") {
9
+ super(message);
10
+ this.name = "TaskAlreadyExistsError";
11
+ }
12
+ }
13
+ export class InvalidTransitionError extends Error {
14
+ task;
15
+ event;
16
+ to;
17
+ reason;
18
+ constructor(messageOrOptions = "Invalid task transition.") {
19
+ const options = typeof messageOrOptions === "string"
20
+ ? {
21
+ reason: messageOrOptions
22
+ }
23
+ : messageOrOptions;
24
+ super(options.reason);
25
+ this.name = "InvalidTransitionError";
26
+ this.task = options.task;
27
+ this.event = options.event;
28
+ this.to = options.to;
29
+ this.reason = options.reason;
30
+ }
31
+ }
32
+ export class MalformedTaskError extends Error {
33
+ constructor(message = "Malformed task.") {
34
+ super(message);
35
+ this.name = "MalformedTaskError";
36
+ }
37
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@poe-code/task-list",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "test": "cd ../.. && vitest run packages/task-list/src",
17
+ "test:unit": "cd ../.. && vitest run packages/task-list/src"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "dependencies": {
23
+ "@poe-code/file-lock": "*",
24
+ "yaml": "*"
25
+ }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,28 +17,40 @@
17
17
  "types": "./dist/mcp.d.ts",
18
18
  "import": "./dist/mcp.js"
19
19
  },
20
+ "./mcp-proxy": {
21
+ "types": "./dist/mcp-proxy.d.ts",
22
+ "import": "./dist/mcp-proxy.js"
23
+ },
20
24
  "./sdk": {
21
25
  "types": "./dist/sdk.d.ts",
22
26
  "import": "./dist/sdk.js"
27
+ },
28
+ "./human-in-loop": {
29
+ "types": "./dist/human-in-loop/index.d.ts",
30
+ "import": "./dist/human-in-loop/index.js"
23
31
  }
24
32
  },
25
33
  "scripts": {
26
34
  "build": "rm -rf dist && tsc",
27
- "test": "cd ../.. && vitest run packages/toolcraft/src/*.test.ts",
28
- "test:unit": "cd ../.. && vitest run packages/toolcraft/src/*.test.ts",
35
+ "test": "cd ../.. && vitest run packages/toolcraft/src",
36
+ "test:unit": "cd ../.. && vitest run packages/toolcraft/src",
29
37
  "lint": "cd ../.. && eslint packages/toolcraft/src --ext ts && tsc -p packages/toolcraft/tsconfig.json --noEmit",
30
- "prepack": "node ../../scripts/manage-bundled-workspace-deps.mjs prepare . @poe-code/design-system",
31
- "postpack": "node ../../scripts/manage-bundled-workspace-deps.mjs cleanup . @poe-code/design-system"
38
+ "prepack": "node ../../scripts/manage-bundled-workspace-deps.mjs prepare . @poe-code/design-system @poe-code/agent-mcp-config @poe-code/agent-human-in-loop @poe-code/task-list",
39
+ "postpack": "node ../../scripts/manage-bundled-workspace-deps.mjs cleanup . @poe-code/design-system @poe-code/agent-mcp-config @poe-code/agent-human-in-loop @poe-code/task-list"
32
40
  },
33
41
  "dependencies": {
34
42
  "@clack/core": "^1.0.0",
35
43
  "@clack/prompts": "^1.0.0",
44
+ "@poe-code/agent-human-in-loop": "*",
45
+ "@poe-code/agent-mcp-config": "*",
36
46
  "@poe-code/design-system": "^0.0.1",
47
+ "@poe-code/task-list": "*",
37
48
  "chalk": "^5.6.2",
38
49
  "commander": "^14.0.3",
39
50
  "console-table-printer": "^2.15.0",
51
+ "tiny-mcp-client": "*",
40
52
  "tiny-stdio-mcp-server": "^0.1.0",
41
- "toolcraft-schema": "^0.0.2"
53
+ "toolcraft-schema": "^0.0.4"
42
54
  },
43
55
  "files": [
44
56
  "dist"
@@ -52,6 +64,9 @@
52
64
  "directory": "packages/toolcraft"
53
65
  },
54
66
  "bundleDependencies": [
55
- "@poe-code/design-system"
67
+ "@poe-code/design-system",
68
+ "@poe-code/agent-mcp-config",
69
+ "@poe-code/agent-human-in-loop",
70
+ "@poe-code/task-list"
56
71
  ]
57
72
  }