---
url: >-
  https://adk.nht.io/api/batteries/artifacts/ecmascript/classes/SpooledEcmaScriptArtifact.md
description: >-
  A {@link @nhtio/adk!SpooledArtifact} specialisation for EcmaScript (JavaScript
  and TypeScript) source files.
---

# Class: SpooledEcmaScriptArtifact

Defined in: [src/batteries/artifacts/ecmascript/index.ts:166](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L166)

A [@nhtio/adk!SpooledArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md) specialisation for EcmaScript (JavaScript and TypeScript)
source files.

## Remarks

Parses source code syntactically (no type checker) using the TypeScript compiler API, enabling
structural queries without materialising the full file into memory.

The parser automatically infers the script kind (`.js`, `.ts`, `.jsx`, `.tsx`) from the
`fileName` when provided; defaults to `ts` when omitted (it parses the widest grammar).

All parsing errors are non-fatal — TypeScript's parser is error-tolerant and produces a
partial tree. Diagnostics are not surfaced by the query methods.

## Extends

* [`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md)

## Constructors

### Constructor

```ts
new SpooledEcmaScriptArtifact(reader: SpoolReader, options?: {
  fileName?: string;
  scriptKind?: "js" | "jsx" | "ts" | "tsx";
}): SpooledEcmaScriptArtifact;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:180](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L180)

#### Parameters

| Parameter             | Type                                                                                | Description                                                                                                                                                                                                |
| --------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `reader`              | [`SpoolReader`](../../../../@nhtio/adk/spooled_artifact/interfaces/SpoolReader.md)  | The backing store to read from.                                                                                                                                                                            |
| `options?`            | { `fileName?`: `string`; `scriptKind?`: `"js"` | `"jsx"` | `"ts"` | `"tsx"`; } | Optional configuration.                                                                                                                                                                                    |
| `options.fileName?`   | `string`                                                                            | The source file name. When provided, script kind is inferred from the extension (`.mts`/`.cts`/`.ts` → `'ts'`, `.mjs`/`.cjs`/`.js` → `'js'`, `.tsx` → `'tsx'`, `.jsx` → `'jsx'`). Defaults to `undefined`. |
| `options.scriptKind?` | `"js"` | `"jsx"` | `"ts"` | `"tsx"`                                              | Explicit script kind override. Defaults to `'ts'` when not provided and cannot be inferred from `fileName`.                                                                                                |

#### Returns

`SpooledEcmaScriptArtifact`

#### Overrides

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`constructor`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#constructor)

## Properties

| Property                                        | Modifier | Type                                                                                                  | Description                                                                                                                                                            | Overrides                                                                                                                                                                                        | Defined in                                                                                                                                              |
| ----------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|  `toolMethods` | `static` | readonly [`ToolMethodDescriptor`](../../../../@nhtio/adk/common/interfaces/ToolMethodDescriptor.md)\[] | The EcmaScript-specific artifact-query descriptors this class adds. **Remarks** Lists seven descriptors; the base seven (`artifact_head`, etc.) are forged separately. | [`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`toolMethods`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#property-toolmethods) | [src/batteries/artifacts/ecmascript/index.ts:209](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L209) |

## Methods

### \[ENCODE\_METHOD]\()

```ts
ENCODE_METHOD: unknown;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:1135](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L1135)

Serialise this SpooledEcmaScriptArtifact into an encoder snapshot.

#### Returns

`unknown`

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`[ENCODE_METHOD]`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#encode_method)

***

### \[ENCODE\_METHOD]\()

```ts
ENCODE_METHOD: unknown;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:314](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L314)

Serialise this SpooledArtifact into an `@nhtio/encoder` snapshot — the reader **handle**, not the
bytes.

#### Returns

`unknown`

A snapshot consumed by SpooledArtifact.\[DECODE\_METHOD].

#### Remarks

Emits the backing reader's [ReaderDescriptor](../../../../@nhtio/adk/common/interfaces/ReaderDescriptor.md); decode re-binds the reader through the
registered resolver. Throws [@nhtio/adk!E\_READER\_NOT\_DESCRIBABLE](../../../../@nhtio/adk/exceptions/variables/E_READER_NOT_DESCRIBABLE.md) when the reader cannot
describe itself. Subclasses override this to include their own discriminators (e.g.
[@nhtio/adk!SpooledJsonArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledJsonArtifact.md) adds `format`).

#### Inherited from

```ts
SpooledArtifact.[ENCODE_METHOD]
```

***

### asString()

```ts
asString(): Promise<string>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:630](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L630)

Returns the full artifact body as a single byte-faithful string.

#### Returns

`Promise`<`string`>

The full content as a single string.

#### Remarks

Round-trip faithful to whatever bytes the [@nhtio/adk!SpoolReader](../../../../@nhtio/adk/spooled_artifact/interfaces/SpoolReader.md) was constructed over —
preserves trailing newlines and non-`\n` line terminators that [SpooledArtifact.cat](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#cat)
discards via its line-based view. This is the canonical primitive for "inline the artifact
content directly into a message" use cases.

`asString()` and the static `forgeTools(ctx)` factory on each subclass are independent
alternatives — a consumer chooses per turn whether to inline the body in a message
(`await tc.results.asString()`) or hand the model query tools
(`SpooledArtifact.forgeTools(ctx)`). Neither calls the other; either works with neither.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`asString`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#asstring)

***

### byteLength()

```ts
byteLength(): Promise<number>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:501](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L501)

Returns the total byte length of the underlying data.

#### Returns

`Promise`<`number`>

The byte length as reported by the [@nhtio/adk!SpoolReader](../../../../@nhtio/adk/spooled_artifact/interfaces/SpoolReader.md).

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`byteLength`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#bytelength)

***

### cat()

```ts
cat(start?: number, end?: number): Promise<string[]>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:482](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L482)

Returns lines from the artifact, optionally bounded to a range.

#### Parameters

| Parameter | Type     | Description                                                    |
| --------- | -------- | -------------------------------------------------------------- |
| `start?`  | `number` | 0-based start line index (inclusive). Defaults to `0`.         |
| `end?`    | `number` | 0-based end line index (exclusive). Defaults to `lineCount()`. |

#### Returns

`Promise`<`string`\[]>

Array of line strings in the requested range.

#### Remarks

Without arguments, returns all lines — equivalent to POSIX `cat`. With `start` and/or `end`,
behaves like `Array.prototype.slice`: `start` defaults to `0`, `end` defaults to the total
line count, and only lines in `[start, end)` are fetched from the backing store. For large
artifacts, prefer a bounded range or [SpooledArtifact.head](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#head) / [SpooledArtifact.tail](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#tail).

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`cat`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#cat)

***

### es\_exports()

```ts
es_exports(): Promise<EcmaScriptExport[]>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:578](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L578)

Return every export declaration and re-export.

#### Returns

`Promise`<[`EcmaScriptExport`](../interfaces/EcmaScriptExport.md)\[]>

***

### es\_imports()

```ts
es_imports(): Promise<EcmaScriptImport[]>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:520](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L520)

Return every import declaration.

#### Returns

`Promise`<[`EcmaScriptImport`](../interfaces/EcmaScriptImport.md)\[]>

***

### es\_jsdoc()

```ts
es_jsdoc(name: string): Promise<string>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:1077](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L1077)

Return the JSDoc comment for a named declaration.
Searches top-level declarations (functions, classes, interfaces, enums, type aliases,
const/let/var bindings), class members (methods, properties, constructors, accessors),
and interface members (method signatures, property signatures) — the same lookup
[SpooledEcmaScriptArtifact.es\_signature](#es_signature) uses, so the two always agree on what a
name resolves to.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

#### Returns

`Promise`<`string`>

***

### es\_outline()

```ts
es_outline(): Promise<OutlineEntry[]>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:703](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L703)

Return a structural outline of classes and interfaces with their members.

#### Returns

`Promise`<[`OutlineEntry`](../interfaces/OutlineEntry.md)\[]>

***

### es\_references()

```ts
es_references(name: string): Promise<IdentifierReference[]>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:1109](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L1109)

Return every line where an identifier appears (syntactic scan only).

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

#### Returns

`Promise`<[`IdentifierReference`](../interfaces/IdentifierReference.md)\[]>

***

### es\_signature()

```ts
es_signature(name: string): Promise<string>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:1059](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L1059)

Return the signature text for a named declaration.
Searches top-level declarations (functions, classes, interfaces, enums, type aliases,
const/let/var bindings), class members (methods, properties, constructors, accessors),
and interface members (method signatures, property signatures) — the same lookup
[SpooledEcmaScriptArtifact.es\_jsdoc](#es_jsdoc) uses, so the two always agree on what a
name resolves to.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

#### Returns

`Promise`<`string`>

***

### es\_symbols()

```ts
es_symbols(kind?: string): Promise<EcmaScriptSymbol[]>;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:419](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L419)

Return every top-level declaration, optionally filtered by kind.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `kind?`   | `string` |

#### Returns

`Promise`<[`EcmaScriptSymbol`](../interfaces/EcmaScriptSymbol.md)\[]>

***

### estimateHandleTokens()

```ts
estimateHandleTokens(
   callId: string,
   encoding:
  | "gpt2"
  | "r50k_base"
  | "p50k_base"
  | "p50k_edit"
  | "cl100k_base"
  | "o200k_base"
  | "gemini"
  | "gemma"
  | "llama2"
  | "claude",
   renderer?: (input: {
  artifact: unknown;
  byteLength: number;
  callId: string;
  encoding?: string;
  estimatedTokens?: number;
  lineCount: number;
}) => string): number;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:547](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L547)

Estimates tokens for the exact handle-body metadata rendered for this artifact.

The fallback renderer is an interim core-safe implementation. Its output is deliberately
specified here for fan-in parity: the lines are the fixed prose and metadata strings below,
with one `\n` separator, and method entries formatted as `- name — description` (or `- name`).
The canonical renderer in `chat_common` should eventually delegate to this builder rather than
maintain a second copy.

#### Parameters

| Parameter   | Type                                                                                                                                                                        | Description                                       |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| `callId`    | `string`                                                                                                                                                                    | The turn-local artifact identifier.               |
| `encoding`  | | `"gpt2"` | `"r50k_base"` | `"p50k_base"` | `"p50k_edit"` | `"cl100k_base"` | `"o200k_base"` | `"gemini"` | `"gemma"` | `"llama2"` | `"claude"`                  | The token encoding used for estimation.           |
| `renderer?` | (`input`: { `artifact`: `unknown`; `byteLength`: `number`; `callId`: `string`; `encoding?`: `string`; `estimatedTokens?`: `number`; `lineCount`: `number`; }) => `string` | Optional renderer overriding the interim default. |

#### Returns

`number`

A synchronous token estimate.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`estimateHandleTokens`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#estimatehandletokens)

***

### estimateTokens()

```ts
estimateTokens(encoding:
  | "gpt2"
  | "r50k_base"
  | "p50k_base"
  | "p50k_edit"
  | "cl100k_base"
  | "o200k_base"
  | "gemini"
  | "gemma"
  | "llama2"
| "claude"): Promise<number>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:609](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L609)

Estimates the total token count of the artifact under `encoding`.

#### Parameters

| Parameter  | Type                                                                                                                                                       | Description                                  |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| `encoding` | | `"gpt2"` | `"r50k_base"` | `"p50k_base"` | `"p50k_edit"` | `"cl100k_base"` | `"o200k_base"` | `"gemini"` | `"gemma"` | `"llama2"` | `"claude"` | The encoding identifier to use for counting. |

#### Returns

`Promise`<`number`>

The estimated number of tokens.

#### Remarks

Reads the full byte-faithful content via [SpooledArtifact.asString](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#asstring) (which delegates to
[@nhtio/adk!SpoolReader.readAll](../../../../@nhtio/adk/spooled_artifact/interfaces/SpoolReader.md#readall)) and delegates to [@nhtio/adk!Tokenizable.estimateTokens](../../../../@nhtio/adk/common/classes/Tokenizable.md#estimatetokens). The estimate
therefore reflects the actual source bytes — including trailing newlines and non-`\n` line
terminators that the line-based [SpooledArtifact.cat](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#cat) view would otherwise discard or
misrepresent.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`estimateTokens`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#estimatetokens)

***

### grep()

```ts
grep(pattern: RegExp): Promise<string[]>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:454](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L454)

Returns all lines that match `pattern`.

#### Parameters

| Parameter | Type     | Description                                       |
| --------- | -------- | ------------------------------------------------- |
| `pattern` | `RegExp` | The regular expression to test each line against. |

#### Returns

`Promise`<`string`\[]>

Array of matching line strings, in order.

#### Remarks

Behaves like POSIX `grep`: each line is tested against the pattern and included in the result
when it matches. The pattern is applied as a JavaScript `RegExp`; flags (e.g. case-
insensitivity) should be encoded in the expression itself.

Stateful flags (`g`, `y`) on the supplied `RegExp` would normally cause `pattern.test()` to
advance `lastIndex` across calls, producing skipped matches and order-dependent results. To
keep the per-line semantics stateless, `grep` resets `pattern.lastIndex` to `0` before each
line test. The forged `artifact_grep` tool also rejects `g` and `y` flags up-front at schema
validation time.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`grep`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#grep)

***

### hasSizeHints()

```ts
hasSizeHints(): boolean;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:520](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L520)

Returns whether producer-computed size metadata is available.

#### Returns

`boolean`

`true` when SpooledArtifact.\_setSizeHints has populated the cache.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`hasSizeHints`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#hassizehints)

***

### head()

```ts
head(n?: number): Promise<string[]>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:401](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L401)

Returns the first `n` lines of the artifact.

#### Parameters

| Parameter | Type     | Default value | Description                                |
| --------- | -------- | ------------- | ------------------------------------------ |
| `n`       | `number` | `10`          | Number of lines to return. Defaults to 10. |

#### Returns

`Promise`<`string`\[]>

Array of line strings, without trailing newlines.

#### Remarks

If the artifact contains fewer than `n` lines, all available lines are returned. Matches the
behaviour of POSIX `head -n`.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`head`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#head)

***

### lineCount()

```ts
lineCount(): Promise<number>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:529](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L529)

Returns the total number of lines in the artifact.

#### Returns

`Promise`<`number`>

The line count as reported by the [@nhtio/adk!SpoolReader](../../../../@nhtio/adk/spooled_artifact/interfaces/SpoolReader.md).

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`lineCount`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#linecount)

***

### tail()

```ts
tail(n?: number): Promise<string[]>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:424](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L424)

Returns the last `n` lines of the artifact.

#### Parameters

| Parameter | Type     | Default value | Description                                |
| --------- | -------- | ------------- | ------------------------------------------ |
| `n`       | `number` | `10`          | Number of lines to return. Defaults to 10. |

#### Returns

`Promise`<`string`\[]>

Array of line strings, without trailing newlines.

#### Remarks

If the artifact contains fewer than `n` lines, all available lines are returned. Matches the
behaviour of POSIX `tail -n`.

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`tail`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#tail)

***

### \[DECODE\_METHOD]\()

```ts
static DECODE_METHOD: SpooledEcmaScriptArtifact;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:1146](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L1146)

Reconstruct a SpooledEcmaScriptArtifact from an encoder snapshot.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `data`    | `unknown` |

#### Returns

`SpooledEcmaScriptArtifact`

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`[DECODE_METHOD]`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#decode_method)

***

### \[DECODE\_METHOD]\()

```ts
static DECODE_METHOD: SpooledArtifact;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:328](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L328)

Reconstruct a [SpooledArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md) from an SpooledArtifact.\[ENCODE\_METHOD] snapshot.

#### Parameters

| Parameter | Type      | Description                                                 |
| --------- | --------- | ----------------------------------------------------------- |
| `data`    | `unknown` | The snapshot produced by SpooledArtifact.\[ENCODE\_METHOD]. |

#### Returns

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md)

A fresh [SpooledArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md) backed by a freshly-resolved reader.

#### Remarks

Re-binds the reader via @nhtio/adk!resolveSpoolReader; throws
[@nhtio/adk!E\_NO\_READER\_RESOLVER](../../../../@nhtio/adk/exceptions/variables/E_NO_READER_RESOLVER.md) when no resolver is registered for the descriptor's tag.

#### Inherited from

```ts
SpooledArtifact.[DECODE_METHOD]
```

***

### forgeTools()

```ts
static forgeTools(ctx: DispatchContext): ToolRegistry;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:284](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L284)

Forges base-class tools plus EcmaScript-specific tools narrowed to SpooledEcmaScriptArtifact.

#### Parameters

| Parameter | Type                                                                            |
| --------- | ------------------------------------------------------------------------------- |
| `ctx`     | [`DispatchContext`](../../../../@nhtio/adk/types/interfaces/DispatchContext.md) |

#### Returns

[`ToolRegistry`](../../../../@nhtio/adk/forge/classes/ToolRegistry.md)

#### Overrides

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`forgeTools`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#forgetools)

***

### isSpooledArtifact()

```ts
static isSpooledArtifact(value: unknown): value is SpooledArtifact;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:361](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L361)

Returns `true` if `value` is a [SpooledArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md) instance (including any subclass).

#### Parameters

| Parameter | Type      | Description        |
| --------- | --------- | ------------------ |
| `value`   | `unknown` | The value to test. |

#### Returns

`value is SpooledArtifact`

`true` when `value` is a [SpooledArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md) instance.

#### Remarks

Uses the cross-realm-safe [@nhtio/adk!isInstanceOf](../../../../@nhtio/adk/guards/functions/isInstanceOf.md) guard: `instanceof` first, then
`Symbol.hasInstance`, then a `constructor.name` fallback. Subclass instances (e.g.
[@nhtio/adk!SpooledJsonArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledJsonArtifact.md)) satisfy this guard because `instanceof` walks the prototype
chain. The fallbacks handle the dual-module-copy case where two distinct `SpooledArtifact`
classes coexist in the same realm (e.g. one bundled into a downstream library, one in the
consumer's `node_modules`).

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`isSpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#isspooledartifact)

***

### isSpooledArtifactConstructor()

```ts
static isSpooledArtifactConstructor(value: unknown): value is SpooledArtifactConstructor<SpooledArtifact>;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:378](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L378)

Returns `true` if `value` is a constructor function whose prototype chain includes
[SpooledArtifact](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md) (including `SpooledArtifact` itself).

#### Parameters

| Parameter | Type      | Description        |
| --------- | --------- | ------------------ |
| `value`   | `unknown` | The value to test. |

#### Returns

`value is SpooledArtifactConstructor<SpooledArtifact>`

`true` when `value` is a constructor for `SpooledArtifact` or a subclass.

#### Remarks

Used by [@nhtio/adk!Tool](../../../../@nhtio/adk/forge/classes/Tool.md) to validate the optional `artifactConstructor` field. Performs an
`instanceof`-based check on the prototype chain; falls back to a duck-type test that looks
for the canonical SpooledArtifact instance methods on `value.prototype` for cross-realm
safety (constructors passed from a different module copy or VM context).

#### Inherited from

[`SpooledArtifact`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md).[`isSpooledArtifactConstructor`](../../../../@nhtio/adk/spooled_artifact/classes/SpooledArtifact.md#isspooledartifactconstructor)

***

### isSpooledEcmaScriptArtifact()

```ts
static isSpooledEcmaScriptArtifact(value: unknown): value is SpooledEcmaScriptArtifact;
```

Defined in: [src/batteries/artifacts/ecmascript/index.ts:199](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/batteries/artifacts/ecmascript/index.ts#L199)

Returns `true` if `value` is a SpooledEcmaScriptArtifact instance.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `value`   | `unknown` |

#### Returns

`value is SpooledEcmaScriptArtifact`

#### Remarks

Uses the cross-realm-safe [@nhtio/adk!isInstanceOf](../../../../@nhtio/adk/guards/functions/isInstanceOf.md) guard. Safe against the
dual-module-copy case.
