@optique/prompt 1.2.0-dev.2196 → 1.2.0-dev.2198

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/dist/index.cjs CHANGED
@@ -64,6 +64,13 @@ function readDefaultValue(adapter, config) {
64
64
  if (config != null && typeof config === "object" && "default" in config) return config.default;
65
65
  return void 0;
66
66
  }
67
+ function unwrapCompleteResult(result) {
68
+ if (!result.success) return result;
69
+ return {
70
+ ...result,
71
+ value: (0, __optique_core_extension.unwrapInjectedAnnotationState)(result.value)
72
+ };
73
+ }
67
74
  /**
68
75
  * Creates a `prompt()` parser wrapper for a prompt library adapter.
69
76
  *
@@ -181,8 +188,8 @@ function createPromptAdapter(adapter) {
181
188
  complete: (state, exec) => {
182
189
  if (isPromptBindState(state) && state.hasCliValue) {
183
190
  const r = withAnnotatedInnerState(state, state.cliState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec), parserInheritsAnnotations);
184
- if (r instanceof Promise) return r;
185
- return Promise.resolve(r);
191
+ if (r instanceof Promise) return r.then(unwrapCompleteResult);
192
+ return Promise.resolve(unwrapCompleteResult(r));
186
193
  }
187
194
  const isProbe = exec != null && exec.phase !== "complete";
188
195
  const annotations = (0, __optique_core_annotations.getAnnotations)(state);
@@ -217,7 +224,7 @@ function createPromptAdapter(adapter) {
217
224
  const handleCompleteResult = (res) => {
218
225
  if (res.success && res.value === void 0 && cliStateIsInjected) return finalizePrompt();
219
226
  if (!res.success) return finalizePrompt();
220
- return Promise.resolve(res);
227
+ return Promise.resolve(unwrapCompleteResult(res));
221
228
  };
222
229
  if (innerR instanceof Promise) return innerR.then(handleCompleteResult);
223
230
  return handleCompleteResult(innerR);
@@ -227,7 +234,7 @@ function createPromptAdapter(adapter) {
227
234
  const handleDeferHookResult = (res) => {
228
235
  if (res.success && res.value === void 0) return finalizePrompt();
229
236
  if (!res.success) return finalizePrompt();
230
- return Promise.resolve(res);
237
+ return Promise.resolve(unwrapCompleteResult(res));
231
238
  };
232
239
  if (innerR instanceof Promise) return innerR.then(handleDeferHookResult);
233
240
  return handleDeferHookResult(innerR);
package/dist/index.js CHANGED
@@ -41,6 +41,13 @@ function readDefaultValue(adapter, config) {
41
41
  if (config != null && typeof config === "object" && "default" in config) return config.default;
42
42
  return void 0;
43
43
  }
44
+ function unwrapCompleteResult(result) {
45
+ if (!result.success) return result;
46
+ return {
47
+ ...result,
48
+ value: unwrapInjectedAnnotationState(result.value)
49
+ };
50
+ }
44
51
  /**
45
52
  * Creates a `prompt()` parser wrapper for a prompt library adapter.
46
53
  *
@@ -158,8 +165,8 @@ function createPromptAdapter(adapter) {
158
165
  complete: (state, exec) => {
159
166
  if (isPromptBindState(state) && state.hasCliValue) {
160
167
  const r = withAnnotatedInnerState(state, state.cliState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec), parserInheritsAnnotations);
161
- if (r instanceof Promise) return r;
162
- return Promise.resolve(r);
168
+ if (r instanceof Promise) return r.then(unwrapCompleteResult);
169
+ return Promise.resolve(unwrapCompleteResult(r));
163
170
  }
164
171
  const isProbe = exec != null && exec.phase !== "complete";
165
172
  const annotations = getAnnotations(state);
@@ -194,7 +201,7 @@ function createPromptAdapter(adapter) {
194
201
  const handleCompleteResult = (res) => {
195
202
  if (res.success && res.value === void 0 && cliStateIsInjected) return finalizePrompt();
196
203
  if (!res.success) return finalizePrompt();
197
- return Promise.resolve(res);
204
+ return Promise.resolve(unwrapCompleteResult(res));
198
205
  };
199
206
  if (innerR instanceof Promise) return innerR.then(handleCompleteResult);
200
207
  return handleCompleteResult(innerR);
@@ -204,7 +211,7 @@ function createPromptAdapter(adapter) {
204
211
  const handleDeferHookResult = (res) => {
205
212
  if (res.success && res.value === void 0) return finalizePrompt();
206
213
  if (!res.success) return finalizePrompt();
207
- return Promise.resolve(res);
214
+ return Promise.resolve(unwrapCompleteResult(res));
208
215
  };
209
216
  if (innerR instanceof Promise) return innerR.then(handleDeferHookResult);
210
217
  return handleDeferHookResult(innerR);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/prompt",
3
- "version": "1.2.0-dev.2196",
3
+ "version": "1.2.0-dev.2198",
4
4
  "description": "Generic prompt adapter support for Optique",
5
5
  "keywords": [
6
6
  "CLI",
@@ -60,16 +60,16 @@
60
60
  },
61
61
  "sideEffects": false,
62
62
  "dependencies": {
63
- "@optique/core": "1.2.0-dev.2196+93daad17"
63
+ "@optique/core": "1.2.0-dev.2198+328dd530"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/node": "^24.0.0",
67
67
  "fast-check": "^4.7.0",
68
68
  "tsdown": "^0.13.0",
69
69
  "typescript": "^5.8.3",
70
- "@optique/env": "1.2.0-dev.2196+93daad17",
71
- "@optique/run": "1.2.0-dev.2196+93daad17",
72
- "@optique/config": "1.2.0-dev.2196+93daad17"
70
+ "@optique/config": "1.2.0-dev.2198+328dd530",
71
+ "@optique/env": "1.2.0-dev.2198+328dd530",
72
+ "@optique/run": "1.2.0-dev.2198+328dd530"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsdown",