toolcraft 0.0.165 → 0.0.166

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/composition.json CHANGED
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.165",
116
+ "version": "0.0.166",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.165",
126
+ "version": "0.0.166",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.165",
116
+ "version": "0.0.166",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.165",
126
+ "version": "0.0.166",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.165",
11
+ "version": "0.0.166",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -109,27 +109,47 @@ export class Prompt extends EventEmitter {
109
109
  return Promise.reject(new Error(nonTtyPromptMessage()));
110
110
  }
111
111
  readNonTtyLine() {
112
+ if (this.input.readableEnded) {
113
+ return Promise.resolve("");
114
+ }
115
+ if (this.input.destroyed) {
116
+ this.state = "cancel";
117
+ return Promise.resolve(CANCEL);
118
+ }
112
119
  return new Promise((resolve) => {
113
- const rl = readline.createInterface({ input: this.input, terminal: false });
120
+ let rl = null;
114
121
  let settled = false;
115
122
  const settle = (value) => {
116
123
  if (settled) {
117
124
  return;
118
125
  }
119
126
  settled = true;
120
- this.signal?.removeEventListener("abort", onAbort);
121
- rl.close();
127
+ this.input.removeListener("close", onCancel);
128
+ this.signal?.removeEventListener("abort", onCancel);
129
+ rl?.close();
122
130
  resolve(value);
123
131
  };
124
- const onAbort = () => {
132
+ const onCancel = () => {
125
133
  this.state = "cancel";
126
134
  settle(CANCEL);
127
135
  };
136
+ this.input.once("close", onCancel);
137
+ rl = readline.createInterface({ input: this.input, terminal: false });
138
+ if (settled) {
139
+ rl.close();
140
+ return;
141
+ }
128
142
  rl.once("line", settle);
129
- rl.once("close", () => settle(rl.line));
130
- this.signal?.addEventListener("abort", onAbort, { once: true });
143
+ rl.once("close", () => settle(rl?.line ?? ""));
144
+ this.signal?.addEventListener("abort", onCancel, { once: true });
131
145
  if (this.signal?.aborted) {
132
- onAbort();
146
+ onCancel();
147
+ }
148
+ else if (this.input.readableEnded) {
149
+ settle(rl.line);
150
+ }
151
+ else if (this.input.destroyed) {
152
+ onCancel();
133
153
  }
134
154
  });
135
155
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "yaml"
159
159
  ],
160
160
  "optionalDependencies": {
161
- "toolcraft-schema": "0.0.165",
161
+ "toolcraft-schema": "0.0.166",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",