> For the complete documentation index, see [llms.txt](https://docs.urbit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.urbit.org/urbit-os/kernel/khan/types.md).

# Khan Data Types

Khan only uses a handful of types, described below.

## `+avow` <a href="#avow" id="avow"></a>

Thread result mold builder

```hoon
|$  [a]  (each a goof)
```

Khan returns this structure when the thread either successfully completes, or fails.

If the [`+each`](/hoon/stdlib/1c.md#each) is `%.y`, it succeeded and `.p` contains the result in either a `$cage` or a `$page`. If the thread was run internally it's a `$cage`, and if it was run externally it's a `$page`.

If the `+each` is `%.n`, the thread failed and `.p` contains a `$goof`, which is:

```hoon
+$  goof  [mote=term =tang]
```

The `.mote` is an error code like `%foobar` and the `.tang` contains something like a stack trace.

#### Example

```
> `(avow:khan cage)`[%.y %noun !>('foo')]
[%.y p=[p=%noun q=[#t/@t q=7.303.014]]]

> `(avow:khan cage)`[%.n %foo-error 'blah' 'blah' ~]
[%.n p=[mote=%foo-error tang=~['blah' 'blah']]]
```

***

## `$bear` <a href="#bear" id="bear"></a>

Thread location

```hoon
$@(desk beak)
```

This is tells Khan where to look for a thread. It's either a `$desk` or a full `$beak`. Khan will look in the `/ted` directory of the specified location.

#### Example

```
> `bear:khan`%base
%base

> `bear:khan`[~sampel %base da+now]
[p=~sampel q=%base r=[%da p=~2022.11.6..08.33.22..9818]]
```

***

## `$cast` <a href="#cast" id="cast"></a>

External thread argument

```hoon
(pair mark page)
```

This is only used if you're running a thread via Khan's external interface. The `$mark` specifies the output mark, and a `$page` is a pair of input `$mark` and raw noun.

#### Example

```
> `cast:khan`[%noun %noun 123]
[p=%noun q=[p=%noun q=123]]
```

***

## `+fyrd` <a href="#fyrd" id="fyrd"></a>

Mold builder for a thread run request

```hoon
|$  [a]  [=bear name=term args=a]
```

The fields are:

* [`.bear`](#bear): thread location.
* `.name`: thread name. Khan will look in `/ted` for this. If it's in a subdirectory like `/ted/foo/bar.hoon`, you'd say `%foo-bar`.
* `.args`: a `$cage` if it's an internal request, and a [`$cast`](#cast) if it's an external request.

#### Examples

```
> `(fyrd:khan cage)`[%base %mythread %noun !>(123)]
[bear=%base name=%mythread args=[p=%noun q=[#t/@ud q=123]]]

> `(fyrd:khan cast:khan)`[%base %mythread %noun %noun 123]
[bear=%base name=%mythread args=[p=%noun q=[p=%noun q=123]]]
```

***


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.urbit.org/urbit-os/kernel/khan/types.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
