> For the complete documentation index, see [llms.txt](https://jig.gitbook.io/sley/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jig.gitbook.io/sley/examples/typescript.md).

# TypeScript examples

Browse complete TypeScript projects by learning goal, Sley mechanism, and cognitive complexity.

Do not choose by ambition. Choose the smallest project that answers your next question, run it, and change one behavior. Complexity estimates cognitive load, not quality; lower is usually the more useful starting point.

## Start here

| Project                                                                                                                                                                                                                                          | What it teaches                                                          | Sley mechanisms                | Complexity |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------ | ---------: |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-hello-world/README.md">TypeScript Hello World</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-hello-world/README.md">Read the lesson</a></p> | Create one typed node, update shared state, and finish an ordinary leaf. | `node`, `state`, `run`         |          1 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-workflow/README.md">A Small Typed Workflow</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-workflow/README.md">Read the lesson</a></p>       | Model a small three-step application as explicit topology.               | `node`, `link`, `Flow`         |          2 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-inspection/README.md">Inspect a Compiled Flow</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-inspection/README.md">Read the lesson</a></p>  | Inspect portable compiled topology and an explicit run result.           | `compile`, `describe`, `start` |        2.5 |

## Composition and failure

| Project                                                                                                                                                                                                                                                                  | What it teaches                                                      | Sley mechanisms                         | Complexity |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- | --------------------------------------- | ---------: |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-retry-recovery/README.md">Retry and Recovery in TypeScript</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-retry-recovery/README.md">Read the lesson</a></p>         | Retry a complete handler and recover locally after attempts fail.    | `retry`, `recover`, `Failure`           |        2.5 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-batch/README.md">Concurrent Service Checks</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-batch/README.md">Read the lesson</a></p>                                  | Check services concurrently and combine terminal outputs once.       | `emit`, `end`, `combine`                |        5.5 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-nested-flow/README.md">Concurrent Nested Workers</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-nested-flow/README.md">Read the lesson</a></p>                      | Run a multi-step nested worker concurrently and combine its results. | `nested Flow`, `concurrency`, `combine` |          4 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-resilient-batch/README.md">Recovering a Partially Completed Batch</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-resilient-batch/README.md">Read the lesson</a></p> | Recover a partial batch from settled terminal records.               | `ScopeFailure`, `terminals`, `recover`  |          6 |

## Agents and integrations

| Project                                                                                                                                                                                                                                                              | What it teaches                                                         | Sley mechanisms                            | Complexity |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------ | ---------: |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-chat/README.md">Terminal Chat</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-chat/README.md">Read the lesson</a></p>                                            | Type shared state in a one-node loop with deliberate hard termination.  | `unlabelled link`, `end`, `maxActivations` |        3.5 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-agent/README.md">Search Agent</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-agent/README.md">Read the lesson</a></p>                                           | Type state and branch input across a bounded search loop.               | `emit`, `input`, `maxActivations`          |         11 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-mcp/README.md">MCP Tool Discovery and Execution</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-mcp/README.md">Read the lesson</a></p>                           | Discover, validate, and invoke one MCP tool in a linear Flow.           | `async handler`, `input`, `validation`     |        5.5 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-orchestrator-workers/README.md">Orchestrator and Workers</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-orchestrator-workers/README.md">Read the lesson</a></p> | Freeze a dynamic plan, fan sections out, and integrate the results.     | `emit`, `input`, `combine`                 |        4.5 |
| <p><a href="https://github.com/jigmd/sley/tree/main/cookbook/typescript-quality-loop/README.md">A Bounded Quality Loop</a><br><a href="https://github.com/jigmd/sley/blob/main/cookbook/typescript-quality-loop/README.md">Read the lesson</a></p>                   | Compose benchmarked component loops, integration, and final evaluation. | `nested Flow`, `combine`, `maxActivations` |          7 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://jig.gitbook.io/sley/examples/typescript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
