mthds 0.9.0 → 0.10.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.
Files changed (110) hide show
  1. package/README.md +43 -21
  2. package/dist/agent/commands/api-commands.js +290 -93
  3. package/dist/agent/commands/api-commands.js.map +1 -1
  4. package/dist/agent/commands/config.js +2 -2
  5. package/dist/agent/commands/config.js.map +1 -1
  6. package/dist/agent/commands/validate.js +5 -13
  7. package/dist/agent/commands/validate.js.map +1 -1
  8. package/dist/agent-cli.js +5 -5
  9. package/dist/agent-cli.js.map +1 -1
  10. package/dist/cli/commands/config.js +2 -2
  11. package/dist/cli/commands/config.js.map +1 -1
  12. package/dist/cli/commands/install.js +19 -39
  13. package/dist/cli/commands/install.js.map +1 -1
  14. package/dist/cli/commands/run.js +82 -69
  15. package/dist/cli/commands/run.js.map +1 -1
  16. package/dist/cli/commands/setup.js +22 -23
  17. package/dist/cli/commands/setup.js.map +1 -1
  18. package/dist/cli/commands/utils.d.ts +1 -1
  19. package/dist/cli/commands/validate.js +10 -14
  20. package/dist/cli/commands/validate.js.map +1 -1
  21. package/dist/cli.js +2 -2
  22. package/dist/cli.js.map +1 -1
  23. package/dist/config/config.d.ts +14 -1
  24. package/dist/config/config.js +31 -6
  25. package/dist/config/config.js.map +1 -1
  26. package/dist/index.d.ts +27 -1
  27. package/dist/index.js +22 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/protocol/concept.d.ts +14 -0
  30. package/dist/protocol/concept.js +10 -0
  31. package/dist/protocol/concept.js.map +1 -0
  32. package/dist/protocol/exceptions.d.ts +10 -0
  33. package/dist/protocol/exceptions.js +12 -0
  34. package/dist/protocol/exceptions.js.map +1 -0
  35. package/dist/protocol/models.d.ts +95 -0
  36. package/dist/protocol/models.js +24 -0
  37. package/dist/protocol/models.js.map +1 -0
  38. package/dist/protocol/options.d.ts +60 -0
  39. package/dist/protocol/options.js +11 -0
  40. package/dist/protocol/options.js.map +1 -0
  41. package/dist/protocol/pipe_output.d.ts +11 -0
  42. package/dist/protocol/pipe_output.js +7 -0
  43. package/dist/protocol/pipe_output.js.map +1 -0
  44. package/dist/protocol/pipeline_inputs.d.ts +8 -0
  45. package/dist/protocol/pipeline_inputs.js +7 -0
  46. package/dist/protocol/pipeline_inputs.js.map +1 -0
  47. package/dist/protocol/protocol.d.ts +47 -0
  48. package/dist/{client → protocol}/protocol.js.map +1 -1
  49. package/dist/protocol/stuff.d.ts +16 -0
  50. package/dist/protocol/stuff.js +8 -0
  51. package/dist/{client/models → protocol}/stuff.js.map +1 -1
  52. package/dist/protocol/working_memory.d.ts +10 -0
  53. package/dist/protocol/working_memory.js +7 -0
  54. package/dist/protocol/working_memory.js.map +1 -0
  55. package/dist/runners/api/client.d.ts +170 -0
  56. package/dist/runners/api/client.js +653 -0
  57. package/dist/runners/api/client.js.map +1 -0
  58. package/dist/runners/api/exceptions.d.ts +106 -0
  59. package/dist/runners/api/exceptions.js +141 -0
  60. package/dist/runners/api/exceptions.js.map +1 -0
  61. package/dist/runners/api/models.d.ts +38 -0
  62. package/dist/runners/api/models.js +13 -0
  63. package/dist/runners/api/models.js.map +1 -0
  64. package/dist/runners/api/runs.d.ts +130 -0
  65. package/dist/runners/api/runs.js +93 -0
  66. package/dist/runners/api/runs.js.map +1 -0
  67. package/dist/runners/base-runner.d.ts +27 -0
  68. package/dist/runners/base-runner.js +25 -0
  69. package/dist/runners/base-runner.js.map +1 -0
  70. package/dist/runners/pipelex/runner.d.ts +38 -0
  71. package/dist/runners/{pipelex-runner.js → pipelex/runner.js} +168 -83
  72. package/dist/runners/pipelex/runner.js.map +1 -0
  73. package/dist/runners/registry.js +10 -4
  74. package/dist/runners/registry.js.map +1 -1
  75. package/dist/runners/types.d.ts +13 -71
  76. package/dist/runners/types.js.map +1 -1
  77. package/package.json +6 -3
  78. package/dist/client/client.d.ts +0 -15
  79. package/dist/client/client.js +0 -127
  80. package/dist/client/client.js.map +0 -1
  81. package/dist/client/exceptions.d.ts +0 -46
  82. package/dist/client/exceptions.js +0 -61
  83. package/dist/client/exceptions.js.map +0 -1
  84. package/dist/client/index.d.ts +0 -5
  85. package/dist/client/index.js +0 -3
  86. package/dist/client/index.js.map +0 -1
  87. package/dist/client/models/index.d.ts +0 -4
  88. package/dist/client/models/index.js +0 -2
  89. package/dist/client/models/index.js.map +0 -1
  90. package/dist/client/models/pipe_output.d.ts +0 -2
  91. package/dist/client/models/pipe_output.js +0 -2
  92. package/dist/client/models/pipe_output.js.map +0 -1
  93. package/dist/client/models/pipeline_inputs.d.ts +0 -3
  94. package/dist/client/models/pipeline_inputs.js +0 -2
  95. package/dist/client/models/pipeline_inputs.js.map +0 -1
  96. package/dist/client/models/stuff.d.ts +0 -1
  97. package/dist/client/models/stuff.js +0 -2
  98. package/dist/client/models/working_memory.d.ts +0 -1
  99. package/dist/client/models/working_memory.js +0 -2
  100. package/dist/client/models/working_memory.js.map +0 -1
  101. package/dist/client/pipeline.d.ts +0 -36
  102. package/dist/client/pipeline.js +0 -2
  103. package/dist/client/pipeline.js.map +0 -1
  104. package/dist/client/protocol.d.ts +0 -5
  105. package/dist/runners/api-runner.d.ts +0 -24
  106. package/dist/runners/api-runner.js +0 -91
  107. package/dist/runners/api-runner.js.map +0 -1
  108. package/dist/runners/pipelex-runner.d.ts +0 -30
  109. package/dist/runners/pipelex-runner.js.map +0 -1
  110. /package/dist/{client → protocol}/protocol.js +0 -0
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Wire models for the MTHDS Protocol — exact mirror of `mthds/protocol/models.py`
3
+ * (which mirrors `mthds-protocol.openapi.yaml`, the standard's normative artifact).
4
+ *
5
+ * POST /execute : -> RunResultExecute (200: pipeline_run_id + pipe_output)
6
+ * POST /start : -> RunResultStart (202: pipeline_run_id only)
7
+ * POST /validate : -> ValidationReport
8
+ * GET /models : -> ModelDeck
9
+ * GET /version : -> VersionInfo
10
+ *
11
+ * Response models declare the protocol's BASE fields only and are
12
+ * extension-open: an implementation may return more, and those server-specific
13
+ * fields are preserved (via the index signature) — the response side of the
14
+ * same passthrough principle as the request-side `extra`.
15
+ */
16
+ /** The MTHDS Protocol version this SDK implements (the MTHDS standard version). */
17
+ export declare const MTHDS_PROTOCOL_VERSION = "0.6.0";
18
+ /**
19
+ * `POST /execute` 200 — the completed run.
20
+ *
21
+ * Two base fields: the authoritative server-generated `pipeline_run_id` and
22
+ * the method's `pipe_output` (always present — a completed run has output).
23
+ * Generic in the output type so `protocol/` never names a runner-side concrete:
24
+ * the default `DictPipeOutput` binding (`DictRunResultExecute`) lives in
25
+ * `runners/api/models.ts`. Extension-open: anything more an implementation
26
+ * returns (a run state, timestamps, output naming) rides the index signature,
27
+ * never named by this SDK.
28
+ */
29
+ export interface RunResultExecute<TPipeOutput = unknown> {
30
+ pipeline_run_id: string;
31
+ pipe_output: TPipeOutput;
32
+ /** Implementation extension fields — defined and documented by the server. */
33
+ [extension: string]: unknown;
34
+ }
35
+ /**
36
+ * `POST /start` 202 (and the optional `/execute` 202 degrade) — the started
37
+ * run's authoritative `pipeline_run_id`, nothing else.
38
+ *
39
+ * A started run has no output yet; how it is delivered later (polling,
40
+ * callbacks, anything else) is implementation-defined and outside the
41
+ * protocol. Extension-open: an implementation may add its own fields (a
42
+ * workflow id, a created-at timestamp), preserved via the index signature.
43
+ */
44
+ export interface RunResultStart {
45
+ pipeline_run_id: string;
46
+ /** Implementation extension fields — defined and documented by the server. */
47
+ [extension: string]: unknown;
48
+ }
49
+ /** Model categories accepted by the protocol's `GET /models?type=` filter. */
50
+ export type ModelCategory = "llm" | "extract" | "img_gen" | "search";
51
+ export declare const MODEL_CATEGORIES: readonly ModelCategory[];
52
+ /** One entry of the model deck (`ModelDeck.models[]`) — base fields + extensions. */
53
+ export interface ModelInfo {
54
+ name: string;
55
+ type?: ModelCategory | null;
56
+ }
57
+ /**
58
+ * The model deck a runner can route to — `GET /models`.
59
+ *
60
+ * The protocol's base is the `models` list; implementations may add their own
61
+ * routing metadata (aliases, fallback chains, anything else) as extensions,
62
+ * preserved via the index signature.
63
+ */
64
+ export interface ModelDeck {
65
+ models: ModelInfo[];
66
+ /** Implementation extension fields (e.g. `aliases`, `waterfalls`). */
67
+ [extension: string]: unknown;
68
+ }
69
+ /**
70
+ * Verdict of `POST /validate` for a VALID bundle — the 200 status IS the verdict.
71
+ *
72
+ * Failures never reach this shape — they are RFC 7807 problems (HTTP 422,
73
+ * surfaced as `ApiResponseError`). The protocol declares no body fields;
74
+ * implementations may include their own artifacts (parsed structures, graphs,
75
+ * anything else), preserved here as extension fields.
76
+ */
77
+ export interface ValidationReport {
78
+ /** Implementation extension fields (e.g. `blueprint`, `graph_spec`, `pipe_structures`). */
79
+ [extension: string]: unknown;
80
+ }
81
+ /**
82
+ * Protocol + runner versions — `GET /version` (always public).
83
+ *
84
+ * The handshake clients use for feature detection. The protocol defines two
85
+ * base fields (`protocol_version`, optional `runner_version`); implementations
86
+ * may add their own identification (an `implementation` name, an underlying
87
+ * runtime version, anything else) as extensions, preserved via the index
88
+ * signature and read by the api runner's bare-runner detection.
89
+ */
90
+ export interface VersionInfo {
91
+ protocol_version: string;
92
+ runner_version?: string | null;
93
+ /** Implementation extension fields (e.g. `implementation`, `runtime_version`). */
94
+ [extension: string]: unknown;
95
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Wire models for the MTHDS Protocol — exact mirror of `mthds/protocol/models.py`
3
+ * (which mirrors `mthds-protocol.openapi.yaml`, the standard's normative artifact).
4
+ *
5
+ * POST /execute : -> RunResultExecute (200: pipeline_run_id + pipe_output)
6
+ * POST /start : -> RunResultStart (202: pipeline_run_id only)
7
+ * POST /validate : -> ValidationReport
8
+ * GET /models : -> ModelDeck
9
+ * GET /version : -> VersionInfo
10
+ *
11
+ * Response models declare the protocol's BASE fields only and are
12
+ * extension-open: an implementation may return more, and those server-specific
13
+ * fields are preserved (via the index signature) — the response side of the
14
+ * same passthrough principle as the request-side `extra`.
15
+ */
16
+ /** The MTHDS Protocol version this SDK implements (the MTHDS standard version). */
17
+ export const MTHDS_PROTOCOL_VERSION = "0.6.0";
18
+ export const MODEL_CATEGORIES = [
19
+ "llm",
20
+ "extract",
21
+ "img_gen",
22
+ "search",
23
+ ];
24
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/protocol/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AA0C9C,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACxD,KAAK;IACL,SAAS;IACT,SAAS;IACT,QAAQ;CACT,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The MTHDS Protocol's request-argument surface — the named arguments of
3
+ * `execute` / `start`.
4
+ *
5
+ * The protocol has no request *model*: a runner takes the request's basic
6
+ * arguments as named parameters and serializes the wire body directly, merging
7
+ * any server-specific extension args (`extra`) as top-level properties. These
8
+ * option/request shapes are the TS expression of that argument surface.
9
+ */
10
+ import type { VariableMultiplicity } from "./pipe_output.js";
11
+ import type { PipelineInputs } from "./pipeline_inputs.js";
12
+ /**
13
+ * Body of the protocol's `POST /execute` — mirrors `RunRequest` in
14
+ * `mthds-protocol.openapi.yaml`. At least one of `pipe_code` /
15
+ * `mthds_contents` is required.
16
+ */
17
+ export interface RunRequest {
18
+ /** Code of the pipe to execute (registered, or defined in `mthds_contents`). */
19
+ pipe_code?: string | null;
20
+ /** MTHDS bundle contents to load (always an array, even for one file). */
21
+ mthds_contents?: string[] | null;
22
+ /** Method inputs: map of input name to content (loose here, strict in the runtime). */
23
+ inputs?: PipelineInputs | Record<string, unknown> | null;
24
+ /** Name of the output slot to return as the main output. */
25
+ output_name?: string | null;
26
+ /** Output multiplicity override (`false`/`true` or an exact count). */
27
+ output_multiplicity?: VariableMultiplicity | null;
28
+ /** Override for the dynamic output concept reference. */
29
+ dynamic_output_concept_ref?: string | null;
30
+ }
31
+ /**
32
+ * Body of the protocol's `POST /start` — the same basic arguments as `RunRequest`.
33
+ *
34
+ * The protocol declares no start-only request fields. Anything an
35
+ * implementation accepts on top (a client-supplied run id, anything else) is
36
+ * an extension arg — the server that defines it is the one that handles it;
37
+ * callers pass it through the generic `extra` option.
38
+ */
39
+ export type StartRequest = RunRequest;
40
+ /**
41
+ * The generic extension passthrough: server-specific args merged into the
42
+ * request body as top-level properties — the server you call defines and
43
+ * handles them; this SDK only passes them through. Protocol args inside
44
+ * `extra` are rejected client-side.
45
+ */
46
+ export interface ExtensionOptions {
47
+ extra?: Record<string, unknown> | null;
48
+ }
49
+ /**
50
+ * Options for `MTHDSProtocol.execute` — the `RunRequest` fields plus the
51
+ * generic `extra` extension passthrough. (The options surface and the wire
52
+ * body are intentionally the same shape.)
53
+ */
54
+ export type RunOptions = RunRequest & ExtensionOptions;
55
+ /**
56
+ * Options for `MTHDSProtocol.start` — the `StartRequest` wire fields (the
57
+ * protocol's basic execution arguments) plus the generic `extra` extension
58
+ * passthrough (server-specific args, merged into the body).
59
+ */
60
+ export type StartOptions = StartRequest & ExtensionOptions;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The MTHDS Protocol's request-argument surface — the named arguments of
3
+ * `execute` / `start`.
4
+ *
5
+ * The protocol has no request *model*: a runner takes the request's basic
6
+ * arguments as named parameters and serializes the wire body directly, merging
7
+ * any server-specific extension args (`extra`) as top-level properties. These
8
+ * option/request shapes are the TS expression of that argument surface.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/protocol/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Pipe-output domain shapes — exact mirror of `mthds/protocol/pipe_output.py`
3
+ * (`VariableMultiplicity`, `PipeOutputAbstract`). The Dict-serialized concrete
4
+ * (`DictPipeOutput`) is runner-side (`runners/api/models.ts`).
5
+ */
6
+ import type { WorkingMemoryAbstract } from "./working_memory.js";
7
+ export type VariableMultiplicity = boolean | number;
8
+ export interface PipeOutputAbstract<TWorkingMemory extends WorkingMemoryAbstract = WorkingMemoryAbstract> {
9
+ working_memory: TWorkingMemory;
10
+ pipeline_run_id: string;
11
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Pipe-output domain shapes — exact mirror of `mthds/protocol/pipe_output.py`
3
+ * (`VariableMultiplicity`, `PipeOutputAbstract`). The Dict-serialized concrete
4
+ * (`DictPipeOutput`) is runner-side (`runners/api/models.ts`).
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=pipe_output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe_output.js","sourceRoot":"","sources":["../../src/protocol/pipe_output.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Pipeline input value shapes — exact mirror of `mthds/protocol/pipeline_inputs.py`
3
+ * (`StuffContentOrData`, `PipelineInputs`). The abstract input shapes only; the
4
+ * Dict-serialized concrete (`DictStuff`) is runner-side (`runners/api/models.ts`).
5
+ */
6
+ import type { StuffContentAbstract } from "./stuff.js";
7
+ export type StuffContentOrData = string | string[] | StuffContentAbstract | StuffContentAbstract[] | Record<string, unknown>;
8
+ export type PipelineInputs = Record<string, StuffContentOrData>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Pipeline input value shapes — exact mirror of `mthds/protocol/pipeline_inputs.py`
3
+ * (`StuffContentOrData`, `PipelineInputs`). The abstract input shapes only; the
4
+ * Dict-serialized concrete (`DictStuff`) is runner-side (`runners/api/models.ts`).
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=pipeline_inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline_inputs.js","sourceRoot":"","sources":["../../src/protocol/pipeline_inputs.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,47 @@
1
+ import type { RunOptions, StartOptions } from "./options.js";
2
+ import type { ModelCategory, ModelDeck, RunResultExecute, RunResultStart, ValidationReport, VersionInfo } from "./models.js";
3
+ /**
4
+ * The MTHDS Protocol — the contract every MTHDS runner implements. Exact
5
+ * mirror of `mthds/protocol/protocol.py` (`MTHDSProtocol`, generic in the
6
+ * pipe-output type).
7
+ *
8
+ * Mirrors the standard's five routes (`mthds-protocol.openapi.yaml`):
9
+ * `execute`, `start`, `validate`, `models`, `version`. A runner is just a
10
+ * runner: it executes and validates methods, and reports its model deck and
11
+ * version. Run polling is NOT part of the protocol — it is a hosted-API
12
+ * extension carried by `MthdsApiClient` and the `Runner` interface only.
13
+ *
14
+ * Generic in `PipeOutputT` (mirroring python's `Generic[PipeOutputT]`): the
15
+ * generic is the mechanism that keeps `protocol/` pure — `execute` returns
16
+ * `RunResultExecute<PipeOutputT>` without the protocol ever naming the
17
+ * runner-side `DictPipeOutput` concrete.
18
+ */
19
+ export interface MTHDSProtocol<PipeOutputT = unknown> {
20
+ /**
21
+ * Execute a method synchronously and wait for its completion.
22
+ *
23
+ * Throws `RunStillRunningError` if the server answers 202 (the
24
+ * protocol's optional async degrade) instead of a final result.
25
+ */
26
+ execute(options: RunOptions): Promise<RunResultExecute<PipeOutputT>>;
27
+ /**
28
+ * Start a method asynchronously without waiting for completion.
29
+ *
30
+ * Carries the protocol's basic arguments only; server-specific extension
31
+ * args ride `options.extra`. Returns `RunResultStart` — the authoritative
32
+ * server-generated `pipeline_run_id`, no output yet.
33
+ */
34
+ start(options: StartOptions): Promise<RunResultStart>;
35
+ /**
36
+ * Parse, validate, and dry-run an MTHDS bundle.
37
+ *
38
+ * Returns the structural artifacts of a VALID bundle; invalid bundles throw
39
+ * (HTTP 422 problem on API runners). `allowSignatures` tolerates
40
+ * unimplemented pipe signatures (strict by default).
41
+ */
42
+ validate(mthdsContents: string[], allowSignatures?: boolean): Promise<ValidationReport>;
43
+ /** The model deck this runner can route to, optionally filtered by category. */
44
+ models(category?: ModelCategory): Promise<ModelDeck>;
45
+ /** Protocol + implementation versions — the handshake for feature detection. */
46
+ version(): Promise<VersionInfo>;
47
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/client/protocol.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/protocol/protocol.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Stuff domain shapes — exact mirror of `mthds/protocol/stuff.py`
3
+ * (`StuffAbstract`, `StuffContentAbstract`). The protocol-level abstract stuff;
4
+ * the Dict-serialized concrete (`DictStuff`) is runner-side
5
+ * (`runners/api/models.ts`).
6
+ */
7
+ import type { ConceptAbstract } from "./concept.js";
8
+ /** Marker base for a stuff's content payload (mirrors python `StuffContentAbstract`). */
9
+ export interface StuffContentAbstract {
10
+ }
11
+ export interface StuffAbstract<TConcept extends ConceptAbstract = ConceptAbstract, TContent extends StuffContentAbstract = StuffContentAbstract> {
12
+ stuff_code: string;
13
+ stuff_name?: string | null;
14
+ concept: TConcept;
15
+ content: TContent;
16
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Stuff domain shapes — exact mirror of `mthds/protocol/stuff.py`
3
+ * (`StuffAbstract`, `StuffContentAbstract`). The protocol-level abstract stuff;
4
+ * the Dict-serialized concrete (`DictStuff`) is runner-side
5
+ * (`runners/api/models.ts`).
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=stuff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stuff.js","sourceRoot":"","sources":["../../../src/client/models/stuff.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"stuff.js","sourceRoot":"","sources":["../../src/protocol/stuff.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Working-memory domain shape — exact mirror of `mthds/protocol/working_memory.py`
3
+ * (`WorkingMemoryAbstract`). The Dict-serialized concrete (`DictWorkingMemory`)
4
+ * is runner-side (`runners/api/models.ts`).
5
+ */
6
+ import type { StuffAbstract } from "./stuff.js";
7
+ export interface WorkingMemoryAbstract<TStuff extends StuffAbstract = StuffAbstract> {
8
+ root: Record<string, TStuff>;
9
+ aliases: Record<string, string>;
10
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Working-memory domain shape — exact mirror of `mthds/protocol/working_memory.py`
3
+ * (`WorkingMemoryAbstract`). The Dict-serialized concrete (`DictWorkingMemory`)
4
+ * is runner-side (`runners/api/models.ts`).
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=working_memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working_memory.js","sourceRoot":"","sources":["../../src/protocol/working_memory.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,170 @@
1
+ import { BaseRunner } from "../base-runner.js";
2
+ import type { Runner, RunnerType, BuildInputsRequest, BuildOutputRequest, BuildRunnerRequest, BuildRunnerResponse, ConceptRequest, ConceptResponse, PipeSpecRequest, PipeSpecResponse } from "../types.js";
3
+ import type { RunOptions, StartOptions } from "../../protocol/options.js";
4
+ import type { ModelCategory, ModelDeck, RunResultStart, ValidationReport, VersionInfo } from "../../protocol/models.js";
5
+ import type { DictRunResultExecute } from "./models.js";
6
+ import type { RunRead, RunResults, RunResultState, WaitForResultOptions } from "./runs.js";
7
+ interface MthdsApiClientOptions {
8
+ /** API token (Bearer). Falls back to `MTHDS_API_KEY`. Optional for anonymous bare runners. */
9
+ apiToken?: string;
10
+ /**
11
+ * API base URL — host only, NO version prefix (e.g. `https://api.pipelex.com`
12
+ * or `http://localhost:8081`). Every endpoint composes as
13
+ * `{baseUrl}/v1/{endpoint}`. Falls back to `MTHDS_API_URL`, then the hosted
14
+ * default.
15
+ */
16
+ baseUrl?: string;
17
+ }
18
+ /** Hosted default — the SDK composes every endpoint as `{base}/v1/{endpoint}`. */
19
+ export declare const DEFAULT_API_BASE_URL = "https://api.pipelex.com";
20
+ /**
21
+ * Client for any MTHDS runner — and THE API runner (parity D8). One class,
22
+ * two consumers: `pipelex-app` instantiates it directly as a protocol client,
23
+ * the CLI gets it via `createRunner()` as a full `Runner`. `extends BaseRunner
24
+ * implements Runner` so it carries the protocol surface, the Pipelex build
25
+ * extensions, and the lifecycle composites (`waitForResult` /
26
+ * `startAndWaitForResult`, inherited from `BaseRunner`).
27
+ *
28
+ * One base URL (`MTHDS_API_URL`); every endpoint is `<base>/v1/<endpoint>`:
29
+ * - **protocol** (`execute` / `start` / `validate` / `models` / `version`) — works
30
+ * against any MTHDS-compliant runner, hosted or bare.
31
+ * - **run lifecycle** (`getRunStatus` / `getRunResult` / `waitForResult`) — the
32
+ * durable polling extension that survives long runs and lets a caller resume by
33
+ * id. Served only by a deployment that includes the platform block (the hosted
34
+ * MTHDS API); a bare `pipelex-api` runner 404s those routes, which the lifecycle
35
+ * methods translate into a clear `RunLifecycleUnavailableError`.
36
+ */
37
+ export declare class MthdsApiClient extends BaseRunner implements Runner {
38
+ readonly type: RunnerType;
39
+ private readonly apiToken;
40
+ private readonly baseUrl;
41
+ /** Origin root derived from the base URL — `/health` lives here, not under `/v1`. */
42
+ private readonly originUrl;
43
+ /** Cached `/v1/version` handshake outcome — whether the durable lifecycle is served. */
44
+ private lifecycleAvailable;
45
+ constructor(options?: MthdsApiClientOptions);
46
+ /** Build an API URL: `<base>/v1/<endpoint>`. */
47
+ private url;
48
+ /**
49
+ * Issue one HTTP request and return the raw status/headers/body. Wraps
50
+ * DNS/connect/TLS/timeout failures as `ApiUnreachableError`; a caller-driven
51
+ * abort (Ctrl-C / agent walk-away) propagates as-is so the poll loop can stop
52
+ * cleanly. Non-2xx interpretation is left to the caller. `url` is a fully
53
+ * resolved absolute URL.
54
+ */
55
+ private requestRaw;
56
+ /**
57
+ * Issue a request and parse the JSON body, throwing a plain `Error` on a
58
+ * non-2xx response. Used by the build extensions and `health` — surfaces
59
+ * that don't need the protocol's structured error taxonomy.
60
+ */
61
+ private requestJson;
62
+ private postApi;
63
+ private throwApiResponseError;
64
+ /**
65
+ * Translate a "route absent" 404 (a bare pipelex-api with no platform block)
66
+ * into a clear `RunLifecycleUnavailableError`. The platform's own 404s (run
67
+ * not found / cross-org) carry a structured error envelope (a `code` field)
68
+ * and are left for normal handling.
69
+ */
70
+ private throwIfLifecycleUnavailable;
71
+ /**
72
+ * Map the protocol's optional 202 execute degrade to a typed
73
+ * error. Hosted does not emit 202 today, but the protocol permits it;
74
+ * raising a typed error (with the `pipeline_run_id` + `Location` + `Retry-After`
75
+ * hints) beats a generic parse failure on an unexpected body shape.
76
+ */
77
+ private throwIfExecuteDegraded;
78
+ health(): Promise<Record<string, unknown>>;
79
+ /**
80
+ * Execute a method synchronously and wait for its completion —
81
+ * `POST /v1/execute`.
82
+ *
83
+ * Behind the hosted gateway, synchronous requests terminate at ~30s; a run
84
+ * that exceeds that surfaces as `PipelineExecuteTimeoutError` pointing at the
85
+ * durable start+poll path. Throws `RunStillRunningError` on the protocol's
86
+ * optional 202 degrade.
87
+ */
88
+ execute(options: RunOptions): Promise<DictRunResultExecute>;
89
+ /**
90
+ * Start a method asynchronously — `POST /v1/start` (202, no output yet).
91
+ *
92
+ * Server-specific extension args ride `options.extra` and merge into the
93
+ * request body — the server you call defines and handles them (including a
94
+ * client-supplied run id where a server supports one). The returned
95
+ * `pipeline_run_id` is always authoritative; on a hosted deployment it is
96
+ * durable — poll `getRunStatus` / `getRunResult`.
97
+ */
98
+ start(options: StartOptions): Promise<RunResultStart>;
99
+ /**
100
+ * Parse, validate, and dry-run an MTHDS bundle — `POST /v1/validate`.
101
+ *
102
+ * Returns the structural artifacts of a valid bundle; an invalid bundle is
103
+ * an HTTP 422 problem, surfaced as `ApiResponseError`.
104
+ */
105
+ validate(mthdsContents: string[], allowSignatures?: boolean): Promise<ValidationReport>;
106
+ /** The model deck the runner can route to — `GET /v1/models[?type=]`. */
107
+ models(category?: ModelCategory): Promise<ModelDeck>;
108
+ /**
109
+ * Protocol + implementation versions — `GET /v1/version` (always public).
110
+ * The handshake for feature detection (hosted extensions or not).
111
+ */
112
+ version(): Promise<VersionInfo>;
113
+ buildInputs(request: BuildInputsRequest): Promise<unknown>;
114
+ buildOutput(request: BuildOutputRequest): Promise<unknown>;
115
+ buildRunner(request: BuildRunnerRequest): Promise<BuildRunnerResponse>;
116
+ concept(request: ConceptRequest): Promise<ConceptResponse>;
117
+ pipeSpec(request: PipeSpecRequest): Promise<PipeSpecResponse>;
118
+ /**
119
+ * Fetch a run's status by bare id — `GET /v1/runs/{pipeline_run_id}/status`.
120
+ *
121
+ * Self-healing: a finished-but-unrecorded run resolves to its true terminal
122
+ * status on read. `degraded: true` means Temporal was unreachable and
123
+ * `status` is the last-known value; `retry_after_seconds` carries the
124
+ * server's backoff hint when present. Throws `RunLifecycleUnavailableError`
125
+ * when the lifecycle routes are absent (a bare runner).
126
+ */
127
+ getRunStatus(runId: string, options?: {
128
+ signal?: AbortSignal;
129
+ }): Promise<RunRead>;
130
+ /**
131
+ * Single-shot result lookup — `GET /v1/runs/{pipeline_run_id}/results`.
132
+ * Maps the server's poll semantics to a discriminated union:
133
+ * - HTTP 202 → `running` (with the `Retry-After` hint)
134
+ * - HTTP 200 → `completed` (with the result artifacts)
135
+ * - HTTP 409 → `failed` (terminal non-`COMPLETED`)
136
+ * - HTTP 503 → `running` (Temporal degraded — retry, never fail a poller)
137
+ *
138
+ * Throws `RunLifecycleUnavailableError` when the lifecycle routes are absent
139
+ * (a bare runner).
140
+ */
141
+ getRunResult(runId: string, options?: {
142
+ signal?: AbortSignal;
143
+ }): Promise<RunResultState>;
144
+ /**
145
+ * Whether the configured server serves the durable run lifecycle, decided
146
+ * via the `GET /v1/version` handshake (master D2) and cached for the
147
+ * client's lifetime. A bare `pipelex-api` runner has no run store; anything
148
+ * else is assumed hosted. When the handshake itself fails, assume hosted
149
+ * (the SDK default) and let the start call surface the real error.
150
+ */
151
+ private supportsRunLifecycle;
152
+ /**
153
+ * Start a run and wait for its result.
154
+ *
155
+ * - **Hosted** (per the `/v1/version` handshake): durable start + poll (the
156
+ * `BaseRunner` composite), the path that survives the gateway's ~30s
157
+ * synchronous ceiling.
158
+ * - **Bare runner** (no run store): the blocking `POST /v1/execute`, which
159
+ * has no gateway cap off-platform and returns the native `pipe_output`.
160
+ */
161
+ startAndWaitForResult(options: StartOptions, pollOptions?: WaitForResultOptions): Promise<RunResults>;
162
+ /**
163
+ * Blocking `POST /v1/execute` adapted onto `RunResults` — the bare-runner
164
+ * path. Forwards every protocol field PLUS the `extra` extension passthrough:
165
+ * an extension-only call (`{ extra }` with no pipe_code/bundle) or a vendor
166
+ * selector riding `extra` must survive this path, not just the durable one.
167
+ */
168
+ private executeBlocking;
169
+ }
170
+ export {};