mthds 0.9.0 → 0.11.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.
- package/README.md +43 -21
- package/dist/agent/binaries.js +2 -2
- package/dist/agent/commands/api-commands.d.ts +8 -0
- package/dist/agent/commands/api-commands.js +310 -93
- package/dist/agent/commands/api-commands.js.map +1 -1
- package/dist/agent/commands/codex-hook.d.ts +20 -0
- package/dist/agent/commands/codex-hook.js +25 -9
- package/dist/agent/commands/codex-hook.js.map +1 -1
- package/dist/agent/commands/config.js +2 -2
- package/dist/agent/commands/config.js.map +1 -1
- package/dist/agent/output.d.ts +4 -0
- package/dist/agent/output.js +7 -0
- package/dist/agent/output.js.map +1 -1
- package/dist/agent/plugin-version.d.ts +1 -1
- package/dist/agent/plugin-version.js +1 -1
- package/dist/agent-cli.js +5 -5
- package/dist/agent-cli.js.map +1 -1
- package/dist/cli/commands/config.js +2 -2
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/install.js +29 -37
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/run.js +82 -69
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/setup.js +22 -23
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/utils.d.ts +9 -1
- package/dist/cli/commands/utils.js +9 -0
- package/dist/cli/commands/utils.js.map +1 -1
- package/dist/cli/commands/validate.js +29 -13
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/config/config.d.ts +14 -1
- package/dist/config/config.js +31 -6
- package/dist/config/config.js.map +1 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/concept.d.ts +14 -0
- package/dist/protocol/concept.js +10 -0
- package/dist/protocol/concept.js.map +1 -0
- package/dist/protocol/exceptions.d.ts +10 -0
- package/dist/protocol/exceptions.js +12 -0
- package/dist/protocol/exceptions.js.map +1 -0
- package/dist/protocol/models.d.ts +150 -0
- package/dist/protocol/models.js +24 -0
- package/dist/protocol/models.js.map +1 -0
- package/dist/protocol/options.d.ts +60 -0
- package/dist/protocol/options.js +11 -0
- package/dist/protocol/options.js.map +1 -0
- package/dist/protocol/pipe_output.d.ts +11 -0
- package/dist/protocol/pipe_output.js +7 -0
- package/dist/protocol/pipe_output.js.map +1 -0
- package/dist/protocol/pipeline_inputs.d.ts +8 -0
- package/dist/protocol/pipeline_inputs.js +7 -0
- package/dist/protocol/pipeline_inputs.js.map +1 -0
- package/dist/protocol/protocol.d.ts +55 -0
- package/dist/{client → protocol}/protocol.js.map +1 -1
- package/dist/protocol/stuff.d.ts +16 -0
- package/dist/protocol/stuff.js +8 -0
- package/dist/{client/models → protocol}/stuff.js.map +1 -1
- package/dist/protocol/working_memory.d.ts +10 -0
- package/dist/protocol/working_memory.js +7 -0
- package/dist/protocol/working_memory.js.map +1 -0
- package/dist/runners/api/client.d.ts +181 -0
- package/dist/runners/api/client.js +679 -0
- package/dist/runners/api/client.js.map +1 -0
- package/dist/runners/api/exceptions.d.ts +121 -0
- package/dist/runners/api/exceptions.js +156 -0
- package/dist/runners/api/exceptions.js.map +1 -0
- package/dist/runners/api/models.d.ts +131 -0
- package/dist/runners/api/models.js +13 -0
- package/dist/runners/api/models.js.map +1 -0
- package/dist/runners/api/runs.d.ts +130 -0
- package/dist/runners/api/runs.js +93 -0
- package/dist/runners/api/runs.js.map +1 -0
- package/dist/runners/base-runner.d.ts +27 -0
- package/dist/runners/base-runner.js +25 -0
- package/dist/runners/base-runner.js.map +1 -0
- package/dist/runners/pipelex/runner.d.ts +38 -0
- package/dist/runners/{pipelex-runner.js → pipelex/runner.js} +171 -83
- package/dist/runners/pipelex/runner.js.map +1 -0
- package/dist/runners/registry.js +10 -4
- package/dist/runners/registry.js.map +1 -1
- package/dist/runners/types.d.ts +13 -71
- package/dist/runners/types.js.map +1 -1
- package/package.json +6 -3
- package/dist/agent/commands/validate.d.ts +0 -18
- package/dist/agent/commands/validate.js +0 -126
- package/dist/agent/commands/validate.js.map +0 -1
- package/dist/client/client.d.ts +0 -15
- package/dist/client/client.js +0 -127
- package/dist/client/client.js.map +0 -1
- package/dist/client/exceptions.d.ts +0 -46
- package/dist/client/exceptions.js +0 -61
- package/dist/client/exceptions.js.map +0 -1
- package/dist/client/index.d.ts +0 -5
- package/dist/client/index.js +0 -3
- package/dist/client/index.js.map +0 -1
- package/dist/client/models/index.d.ts +0 -4
- package/dist/client/models/index.js +0 -2
- package/dist/client/models/index.js.map +0 -1
- package/dist/client/models/pipe_output.d.ts +0 -2
- package/dist/client/models/pipe_output.js +0 -2
- package/dist/client/models/pipe_output.js.map +0 -1
- package/dist/client/models/pipeline_inputs.d.ts +0 -3
- package/dist/client/models/pipeline_inputs.js +0 -2
- package/dist/client/models/pipeline_inputs.js.map +0 -1
- package/dist/client/models/stuff.d.ts +0 -1
- package/dist/client/models/stuff.js +0 -2
- package/dist/client/models/working_memory.d.ts +0 -1
- package/dist/client/models/working_memory.js +0 -2
- package/dist/client/models/working_memory.js.map +0 -1
- package/dist/client/pipeline.d.ts +0 -36
- package/dist/client/pipeline.js +0 -2
- package/dist/client/pipeline.js.map +0 -1
- package/dist/client/protocol.d.ts +0 -5
- package/dist/runners/api-runner.d.ts +0 -24
- package/dist/runners/api-runner.js +0 -91
- package/dist/runners/api-runner.js.map +0 -1
- package/dist/runners/pipelex-runner.d.ts +0 -30
- package/dist/runners/pipelex-runner.js.map +0 -1
- /package/dist/{client → protocol}/protocol.js +0 -0
|
@@ -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,181 @@
|
|
|
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, VersionInfo } from "../../protocol/models.js";
|
|
5
|
+
import type { DictRunResultExecute, PipelexValidationResult } 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
|
+
* `/validate` is a diagnostic endpoint: every produced verdict rides a **200**,
|
|
103
|
+
* discriminated on `is_valid`. This returns the `PipelexValidationResult` union
|
|
104
|
+
* verbatim — `is_valid: true` ⇒ the typed `PipelexValidationReport` (structural
|
|
105
|
+
* artifacts), `is_valid: false` ⇒ a `PipelexInvalidReport` (`validation_errors[]`).
|
|
106
|
+
* An invalid bundle is NOT thrown — the caller pattern-matches `is_valid`. Only a
|
|
107
|
+
* *no-verdict* condition (a malformed request, an `mthds_sources` length mismatch,
|
|
108
|
+
* auth, a server fault) is non-2xx and surfaces as `ApiResponseError`.
|
|
109
|
+
*
|
|
110
|
+
* `mthdsSources` (optional, parallel to `mthdsContents`) names each submitted
|
|
111
|
+
* content — a Pipelex-API extension threaded onto `blueprint.source`, so
|
|
112
|
+
* cross-file diagnostics name the owning file (an unnamed content yields
|
|
113
|
+
* `source: null`). The server 422s a length mismatch; this client sends the
|
|
114
|
+
* arrays verbatim and surfaces that as an `ApiResponseError`.
|
|
115
|
+
*/
|
|
116
|
+
validate(mthdsContents: string[], allowSignatures?: boolean, mthdsSources?: string[]): Promise<PipelexValidationResult>;
|
|
117
|
+
/** The model deck the runner can route to — `GET /v1/models[?type=]`. */
|
|
118
|
+
models(category?: ModelCategory): Promise<ModelDeck>;
|
|
119
|
+
/**
|
|
120
|
+
* Protocol + implementation versions — `GET /v1/version` (always public).
|
|
121
|
+
* The handshake for feature detection (hosted extensions or not).
|
|
122
|
+
*/
|
|
123
|
+
version(): Promise<VersionInfo>;
|
|
124
|
+
buildInputs(request: BuildInputsRequest): Promise<unknown>;
|
|
125
|
+
buildOutput(request: BuildOutputRequest): Promise<unknown>;
|
|
126
|
+
buildRunner(request: BuildRunnerRequest): Promise<BuildRunnerResponse>;
|
|
127
|
+
concept(request: ConceptRequest): Promise<ConceptResponse>;
|
|
128
|
+
pipeSpec(request: PipeSpecRequest): Promise<PipeSpecResponse>;
|
|
129
|
+
/**
|
|
130
|
+
* Fetch a run's status by bare id — `GET /v1/runs/{pipeline_run_id}/status`.
|
|
131
|
+
*
|
|
132
|
+
* Self-healing: a finished-but-unrecorded run resolves to its true terminal
|
|
133
|
+
* status on read. `degraded: true` means Temporal was unreachable and
|
|
134
|
+
* `status` is the last-known value; `retry_after_seconds` carries the
|
|
135
|
+
* server's backoff hint when present. Throws `RunLifecycleUnavailableError`
|
|
136
|
+
* when the lifecycle routes are absent (a bare runner).
|
|
137
|
+
*/
|
|
138
|
+
getRunStatus(runId: string, options?: {
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
}): Promise<RunRead>;
|
|
141
|
+
/**
|
|
142
|
+
* Single-shot result lookup — `GET /v1/runs/{pipeline_run_id}/results`.
|
|
143
|
+
* Maps the server's poll semantics to a discriminated union:
|
|
144
|
+
* - HTTP 202 → `running` (with the `Retry-After` hint)
|
|
145
|
+
* - HTTP 200 → `completed` (with the result artifacts)
|
|
146
|
+
* - HTTP 409 → `failed` (terminal non-`COMPLETED`)
|
|
147
|
+
* - HTTP 503 → `running` (Temporal degraded — retry, never fail a poller)
|
|
148
|
+
*
|
|
149
|
+
* Throws `RunLifecycleUnavailableError` when the lifecycle routes are absent
|
|
150
|
+
* (a bare runner).
|
|
151
|
+
*/
|
|
152
|
+
getRunResult(runId: string, options?: {
|
|
153
|
+
signal?: AbortSignal;
|
|
154
|
+
}): Promise<RunResultState>;
|
|
155
|
+
/**
|
|
156
|
+
* Whether the configured server serves the durable run lifecycle, decided
|
|
157
|
+
* via the `GET /v1/version` handshake (master D2) and cached for the
|
|
158
|
+
* client's lifetime. A bare `pipelex-api` runner has no run store; anything
|
|
159
|
+
* else is assumed hosted. When the handshake itself fails, assume hosted
|
|
160
|
+
* (the SDK default) and let the start call surface the real error.
|
|
161
|
+
*/
|
|
162
|
+
private supportsRunLifecycle;
|
|
163
|
+
/**
|
|
164
|
+
* Start a run and wait for its result.
|
|
165
|
+
*
|
|
166
|
+
* - **Hosted** (per the `/v1/version` handshake): durable start + poll (the
|
|
167
|
+
* `BaseRunner` composite), the path that survives the gateway's ~30s
|
|
168
|
+
* synchronous ceiling.
|
|
169
|
+
* - **Bare runner** (no run store): the blocking `POST /v1/execute`, which
|
|
170
|
+
* has no gateway cap off-platform and returns the native `pipe_output`.
|
|
171
|
+
*/
|
|
172
|
+
startAndWaitForResult(options: StartOptions, pollOptions?: WaitForResultOptions): Promise<RunResults>;
|
|
173
|
+
/**
|
|
174
|
+
* Blocking `POST /v1/execute` adapted onto `RunResults` — the bare-runner
|
|
175
|
+
* path. Forwards every protocol field PLUS the `extra` extension passthrough:
|
|
176
|
+
* an extension-only call (`{ extra }` with no pipe_code/bundle) or a vendor
|
|
177
|
+
* selector riding `extra` must survive this path, not just the durable one.
|
|
178
|
+
*/
|
|
179
|
+
private executeBlocking;
|
|
180
|
+
}
|
|
181
|
+
export {};
|