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

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);
@@ -215,9 +222,10 @@ function createPromptAdapter(adapter) {
215
222
  const completeState = parseResult.success ? parseResult.next.state : effectiveInitialState;
216
223
  const innerR = parser.complete(completeState, exec);
217
224
  const handleCompleteResult = (res) => {
218
- if (res.success && res.value === void 0 && cliStateIsInjected) return finalizePrompt();
219
- if (!res.success) return finalizePrompt();
220
- return Promise.resolve(res);
225
+ const unwrapped = unwrapCompleteResult(res);
226
+ if (unwrapped.success && unwrapped.value === void 0 && cliStateIsInjected) return finalizePrompt();
227
+ if (!unwrapped.success) return finalizePrompt();
228
+ return Promise.resolve(unwrapped);
221
229
  };
222
230
  if (innerR instanceof Promise) return innerR.then(handleCompleteResult);
223
231
  return handleCompleteResult(innerR);
@@ -225,9 +233,10 @@ function createPromptAdapter(adapter) {
225
233
  if (hasDeferHook) {
226
234
  const innerR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec), parserInheritsAnnotations);
227
235
  const handleDeferHookResult = (res) => {
228
- if (res.success && res.value === void 0) return finalizePrompt();
229
- if (!res.success) return finalizePrompt();
230
- return Promise.resolve(res);
236
+ const unwrapped = unwrapCompleteResult(res);
237
+ if (unwrapped.success && unwrapped.value === void 0) return finalizePrompt();
238
+ if (!unwrapped.success) return finalizePrompt();
239
+ return Promise.resolve(unwrapped);
231
240
  };
232
241
  if (innerR instanceof Promise) return innerR.then(handleDeferHookResult);
233
242
  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);
@@ -192,9 +199,10 @@ function createPromptAdapter(adapter) {
192
199
  const completeState = parseResult.success ? parseResult.next.state : effectiveInitialState;
193
200
  const innerR = parser.complete(completeState, exec);
194
201
  const handleCompleteResult = (res) => {
195
- if (res.success && res.value === void 0 && cliStateIsInjected) return finalizePrompt();
196
- if (!res.success) return finalizePrompt();
197
- return Promise.resolve(res);
202
+ const unwrapped = unwrapCompleteResult(res);
203
+ if (unwrapped.success && unwrapped.value === void 0 && cliStateIsInjected) return finalizePrompt();
204
+ if (!unwrapped.success) return finalizePrompt();
205
+ return Promise.resolve(unwrapped);
198
206
  };
199
207
  if (innerR instanceof Promise) return innerR.then(handleCompleteResult);
200
208
  return handleCompleteResult(innerR);
@@ -202,9 +210,10 @@ function createPromptAdapter(adapter) {
202
210
  if (hasDeferHook) {
203
211
  const innerR = withAnnotatedInnerState(state, effectiveInitialState, (annotatedInnerState) => parser.complete(annotatedInnerState, exec), parserInheritsAnnotations);
204
212
  const handleDeferHookResult = (res) => {
205
- if (res.success && res.value === void 0) return finalizePrompt();
206
- if (!res.success) return finalizePrompt();
207
- return Promise.resolve(res);
213
+ const unwrapped = unwrapCompleteResult(res);
214
+ if (unwrapped.success && unwrapped.value === void 0) return finalizePrompt();
215
+ if (!unwrapped.success) return finalizePrompt();
216
+ return Promise.resolve(unwrapped);
208
217
  };
209
218
  if (innerR instanceof Promise) return innerR.then(handleDeferHookResult);
210
219
  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.2200",
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.2200+9ff07852"
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.2200+9ff07852",
71
+ "@optique/env": "1.2.0-dev.2200+9ff07852",
72
+ "@optique/run": "1.2.0-dev.2200+9ff07852"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsdown",