JSPM

@loopstack/hitl-ask-user-example-workflow

0.23.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 32
    • Score
      100M100P100Q93513F
    • License MIT

    Example workflow that uses @loopstack/hitl's AskUserWorkflow to prompt the user for free-text input and echoes the answer back

    Package Exports

    • @loopstack/hitl-ask-user-example-workflow
    • @loopstack/hitl-ask-user-example-workflow/src/__tests__/hitl-ask-user-example.workflow.spec.ts
    • @loopstack/hitl-ask-user-example-workflow/src/hitl-ask-user-example.module.ts
    • @loopstack/hitl-ask-user-example-workflow/src/hitl-ask-user-example.workflow.ts
    • @loopstack/hitl-ask-user-example-workflow/src/index.ts

    Readme


    title: HITL Ask User Example description: Example prompting the user for free-text input using AskUserWorkflow as a sub-workflow with callback, waiting on human input without blocking

    @loopstack/hitl-ask-user-example-workflow

    Demonstrates how to prompt the user for free-text input from inside a workflow using the AskUserWorkflow from @loopstack/hitl. The user's answer is captured and echoed back as an assistant message.

    By using this example you'll get...

    • A parent workflow that launches AskUserWorkflow as a sub-workflow with a callback
    • A concrete pattern for waiting on human input without blocking the worker
    • An AskUserDocument rendered in the UI while the workflow is paused

    Installation

    npm install @loopstack/hitl-ask-user-example-workflow

    The package depends on @loopstack/hitl.

    Then register the module in your app:

    import { StudioApp } from '@loopstack/common';
    import { HitlAskUserExampleModule, HitlAskUserExampleWorkflow } from '@loopstack/hitl-ask-user-example-workflow';
    
    @StudioApp({
      title: 'HITL Ask User Example',
      workflows: [HitlAskUserExampleWorkflow],
    })
    @Module({
      imports: [HitlAskUserExampleModule],
    })
    export class MyAppModule {}

    How It Works

    1. The workflow starts and calls AskUserWorkflow.run({ question }) as a sub-workflow.
    2. The sub-workflow renders an AskUserDocument and stops at waiting_for_user.
    3. When the user submits an answer, the sub-workflow finishes and the parent's callback fires.
    4. The parent saves a MessageDocument with the answer and ends.

    Public API

    • HitlAskUserExampleModule
    • HitlAskUserExampleWorkflow

    Dependencies

    • @loopstack/common
    • @loopstack/hitl