llmist 9.3.2 → 9.5.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.
package/dist/index.d.cts CHANGED
@@ -2456,6 +2456,36 @@ interface ExecutionContext {
2456
2456
  * ```
2457
2457
  */
2458
2458
  logger?: Logger<ILogObj>;
2459
+ /**
2460
+ * Request human input during gadget execution.
2461
+ *
2462
+ * When available, gadgets can use this callback to ask the user questions
2463
+ * and receive their answers. This is used internally by gadgets that throw
2464
+ * `HumanInputRequiredException` - the executor catches the exception and
2465
+ * calls this callback if provided.
2466
+ *
2467
+ * Subagents created via `createSubagent()` will automatically inherit this
2468
+ * capability from their parent context, enabling nested agents to bubble up
2469
+ * human input requests to the CLI's TUI.
2470
+ *
2471
+ * This is optional - it will be `undefined` for:
2472
+ * - Gadgets executed via CLI `gadget run` command
2473
+ * - Non-interactive (piped) execution
2474
+ * - Direct gadget testing without agent context
2475
+ *
2476
+ * @example
2477
+ * ```typescript
2478
+ * // Subagents automatically inherit human input capability:
2479
+ * const agent = createSubagent(ctx, {
2480
+ * name: "BrowseWeb",
2481
+ * gadgets: [Navigate, Click, AskUser],
2482
+ * }).ask("Log in to example.com");
2483
+ *
2484
+ * // The AskUser gadget inside BrowseWeb can now prompt the user
2485
+ * // and the input request will bubble up to the CLI's TUI
2486
+ * ```
2487
+ */
2488
+ requestHumanInput?: (question: string) => Promise<string>;
2459
2489
  }
2460
2490
  /**
2461
2491
  * Host llmist exports provided to external gadgets via ExecutionContext.
@@ -9167,6 +9197,7 @@ interface SubagentOptions {
9167
9197
  * - Resolves model with "inherit" support from CLI config
9168
9198
  * - Shares the parent's execution tree for cost tracking
9169
9199
  * - Forwards the abort signal for proper cancellation
9200
+ * - Inherits human input handler (for 2FA, CAPTCHAs, etc.)
9170
9201
  *
9171
9202
  * @param ctx - ExecutionContext passed to gadget's execute()
9172
9203
  * @param options - Subagent configuration options
@@ -9198,6 +9229,10 @@ interface SubagentOptions {
9198
9229
  * for await (const event of agent.run()) {
9199
9230
  * // Events flow through shared tree automatically
9200
9231
  * }
9232
+ *
9233
+ * // Human input bubbles up automatically:
9234
+ * // If a gadget throws HumanInputRequiredException,
9235
+ * // the parent's onHumanInput handler will be called
9201
9236
  * ```
9202
9237
  */
9203
9238
  declare function createSubagent(ctx: ExecutionContext, options: SubagentOptions): AgentBuilder;
package/dist/index.d.ts CHANGED
@@ -2456,6 +2456,36 @@ interface ExecutionContext {
2456
2456
  * ```
2457
2457
  */
2458
2458
  logger?: Logger<ILogObj>;
2459
+ /**
2460
+ * Request human input during gadget execution.
2461
+ *
2462
+ * When available, gadgets can use this callback to ask the user questions
2463
+ * and receive their answers. This is used internally by gadgets that throw
2464
+ * `HumanInputRequiredException` - the executor catches the exception and
2465
+ * calls this callback if provided.
2466
+ *
2467
+ * Subagents created via `createSubagent()` will automatically inherit this
2468
+ * capability from their parent context, enabling nested agents to bubble up
2469
+ * human input requests to the CLI's TUI.
2470
+ *
2471
+ * This is optional - it will be `undefined` for:
2472
+ * - Gadgets executed via CLI `gadget run` command
2473
+ * - Non-interactive (piped) execution
2474
+ * - Direct gadget testing without agent context
2475
+ *
2476
+ * @example
2477
+ * ```typescript
2478
+ * // Subagents automatically inherit human input capability:
2479
+ * const agent = createSubagent(ctx, {
2480
+ * name: "BrowseWeb",
2481
+ * gadgets: [Navigate, Click, AskUser],
2482
+ * }).ask("Log in to example.com");
2483
+ *
2484
+ * // The AskUser gadget inside BrowseWeb can now prompt the user
2485
+ * // and the input request will bubble up to the CLI's TUI
2486
+ * ```
2487
+ */
2488
+ requestHumanInput?: (question: string) => Promise<string>;
2459
2489
  }
2460
2490
  /**
2461
2491
  * Host llmist exports provided to external gadgets via ExecutionContext.
@@ -9167,6 +9197,7 @@ interface SubagentOptions {
9167
9197
  * - Resolves model with "inherit" support from CLI config
9168
9198
  * - Shares the parent's execution tree for cost tracking
9169
9199
  * - Forwards the abort signal for proper cancellation
9200
+ * - Inherits human input handler (for 2FA, CAPTCHAs, etc.)
9170
9201
  *
9171
9202
  * @param ctx - ExecutionContext passed to gadget's execute()
9172
9203
  * @param options - Subagent configuration options
@@ -9198,6 +9229,10 @@ interface SubagentOptions {
9198
9229
  * for await (const event of agent.run()) {
9199
9230
  * // Events flow through shared tree automatically
9200
9231
  * }
9232
+ *
9233
+ * // Human input bubbles up automatically:
9234
+ * // If a gadget throws HumanInputRequiredException,
9235
+ * // the parent's onHumanInput handler will be called
9201
9236
  * ```
9202
9237
  */
9203
9238
  declare function createSubagent(ctx: ExecutionContext, options: SubagentOptions): AgentBuilder;
package/dist/index.js CHANGED
@@ -8106,7 +8106,9 @@ var init_executor = __esm({
8106
8106
  // Host exports for external gadgets to use host's llmist classes
8107
8107
  hostExports: getHostExportsInternal(),
8108
8108
  // Logger for structured logging (respects CLI's log level/file config)
8109
- logger: this.logger
8109
+ logger: this.logger,
8110
+ // Human input callback for subagents to bubble up input requests
8111
+ requestHumanInput: this.requestHumanInput
8110
8112
  };
8111
8113
  let rawResult;
8112
8114
  if (timeoutMs && timeoutMs > 0) {
@@ -12491,6 +12493,9 @@ function createSubagent(ctx, options) {
12491
12493
  defaultValue: defaultMaxIterations
12492
12494
  });
12493
12495
  let builder = new AgentBuilder2(client).withModel(model).withGadgets(...gadgets).withMaxIterations(maxIterations).withParentContext(ctx);
12496
+ if (ctx.requestHumanInput) {
12497
+ builder = builder.onHumanInput(ctx.requestHumanInput);
12498
+ }
12494
12499
  if (systemPrompt) {
12495
12500
  builder = builder.withSystem(systemPrompt);
12496
12501
  }