mthds 0.8.1 → 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 (121) 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/update-check.d.ts +14 -1
  7. package/dist/agent/commands/update-check.js +238 -16
  8. package/dist/agent/commands/update-check.js.map +1 -1
  9. package/dist/agent/commands/validate.js +5 -13
  10. package/dist/agent/commands/validate.js.map +1 -1
  11. package/dist/agent/plugin-version.d.ts +1 -1
  12. package/dist/agent/plugin-version.js +1 -1
  13. package/dist/agent/remote-version.d.ts +31 -0
  14. package/dist/agent/remote-version.js +74 -0
  15. package/dist/agent/remote-version.js.map +1 -0
  16. package/dist/agent/update-cache.d.ts +41 -0
  17. package/dist/agent/update-cache.js +129 -0
  18. package/dist/agent/update-cache.js.map +1 -1
  19. package/dist/agent-cli.js +5 -5
  20. package/dist/agent-cli.js.map +1 -1
  21. package/dist/cli/commands/config.js +2 -2
  22. package/dist/cli/commands/config.js.map +1 -1
  23. package/dist/cli/commands/install.js +19 -39
  24. package/dist/cli/commands/install.js.map +1 -1
  25. package/dist/cli/commands/run.js +82 -69
  26. package/dist/cli/commands/run.js.map +1 -1
  27. package/dist/cli/commands/setup.js +22 -23
  28. package/dist/cli/commands/setup.js.map +1 -1
  29. package/dist/cli/commands/utils.d.ts +1 -1
  30. package/dist/cli/commands/validate.js +10 -14
  31. package/dist/cli/commands/validate.js.map +1 -1
  32. package/dist/cli.js +2 -2
  33. package/dist/cli.js.map +1 -1
  34. package/dist/config/config.d.ts +14 -1
  35. package/dist/config/config.js +31 -6
  36. package/dist/config/config.js.map +1 -1
  37. package/dist/index.d.ts +27 -1
  38. package/dist/index.js +22 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/protocol/concept.d.ts +14 -0
  41. package/dist/protocol/concept.js +10 -0
  42. package/dist/protocol/concept.js.map +1 -0
  43. package/dist/protocol/exceptions.d.ts +10 -0
  44. package/dist/protocol/exceptions.js +12 -0
  45. package/dist/protocol/exceptions.js.map +1 -0
  46. package/dist/protocol/models.d.ts +95 -0
  47. package/dist/protocol/models.js +24 -0
  48. package/dist/protocol/models.js.map +1 -0
  49. package/dist/protocol/options.d.ts +60 -0
  50. package/dist/protocol/options.js +11 -0
  51. package/dist/protocol/options.js.map +1 -0
  52. package/dist/protocol/pipe_output.d.ts +11 -0
  53. package/dist/protocol/pipe_output.js +7 -0
  54. package/dist/protocol/pipe_output.js.map +1 -0
  55. package/dist/protocol/pipeline_inputs.d.ts +8 -0
  56. package/dist/protocol/pipeline_inputs.js +7 -0
  57. package/dist/protocol/pipeline_inputs.js.map +1 -0
  58. package/dist/protocol/protocol.d.ts +47 -0
  59. package/dist/{client → protocol}/protocol.js.map +1 -1
  60. package/dist/protocol/stuff.d.ts +16 -0
  61. package/dist/protocol/stuff.js +8 -0
  62. package/dist/{client/models → protocol}/stuff.js.map +1 -1
  63. package/dist/protocol/working_memory.d.ts +10 -0
  64. package/dist/protocol/working_memory.js +7 -0
  65. package/dist/protocol/working_memory.js.map +1 -0
  66. package/dist/runners/api/client.d.ts +170 -0
  67. package/dist/runners/api/client.js +653 -0
  68. package/dist/runners/api/client.js.map +1 -0
  69. package/dist/runners/api/exceptions.d.ts +106 -0
  70. package/dist/runners/api/exceptions.js +141 -0
  71. package/dist/runners/api/exceptions.js.map +1 -0
  72. package/dist/runners/api/models.d.ts +38 -0
  73. package/dist/runners/api/models.js +13 -0
  74. package/dist/runners/api/models.js.map +1 -0
  75. package/dist/runners/api/runs.d.ts +130 -0
  76. package/dist/runners/api/runs.js +93 -0
  77. package/dist/runners/api/runs.js.map +1 -0
  78. package/dist/runners/base-runner.d.ts +27 -0
  79. package/dist/runners/base-runner.js +25 -0
  80. package/dist/runners/base-runner.js.map +1 -0
  81. package/dist/runners/pipelex/runner.d.ts +38 -0
  82. package/dist/runners/{pipelex-runner.js → pipelex/runner.js} +168 -83
  83. package/dist/runners/pipelex/runner.js.map +1 -0
  84. package/dist/runners/registry.js +10 -4
  85. package/dist/runners/registry.js.map +1 -1
  86. package/dist/runners/types.d.ts +13 -71
  87. package/dist/runners/types.js.map +1 -1
  88. package/package.json +6 -3
  89. package/dist/client/client.d.ts +0 -15
  90. package/dist/client/client.js +0 -127
  91. package/dist/client/client.js.map +0 -1
  92. package/dist/client/exceptions.d.ts +0 -46
  93. package/dist/client/exceptions.js +0 -61
  94. package/dist/client/exceptions.js.map +0 -1
  95. package/dist/client/index.d.ts +0 -5
  96. package/dist/client/index.js +0 -3
  97. package/dist/client/index.js.map +0 -1
  98. package/dist/client/models/index.d.ts +0 -4
  99. package/dist/client/models/index.js +0 -2
  100. package/dist/client/models/index.js.map +0 -1
  101. package/dist/client/models/pipe_output.d.ts +0 -2
  102. package/dist/client/models/pipe_output.js +0 -2
  103. package/dist/client/models/pipe_output.js.map +0 -1
  104. package/dist/client/models/pipeline_inputs.d.ts +0 -3
  105. package/dist/client/models/pipeline_inputs.js +0 -2
  106. package/dist/client/models/pipeline_inputs.js.map +0 -1
  107. package/dist/client/models/stuff.d.ts +0 -1
  108. package/dist/client/models/stuff.js +0 -2
  109. package/dist/client/models/working_memory.d.ts +0 -1
  110. package/dist/client/models/working_memory.js +0 -2
  111. package/dist/client/models/working_memory.js.map +0 -1
  112. package/dist/client/pipeline.d.ts +0 -36
  113. package/dist/client/pipeline.js +0 -2
  114. package/dist/client/pipeline.js.map +0 -1
  115. package/dist/client/protocol.d.ts +0 -5
  116. package/dist/runners/api-runner.d.ts +0 -24
  117. package/dist/runners/api-runner.js +0 -91
  118. package/dist/runners/api-runner.js.map +0 -1
  119. package/dist/runners/pipelex-runner.d.ts +0 -30
  120. package/dist/runners/pipelex-runner.js.map +0 -1
  121. /package/dist/{client → protocol}/protocol.js +0 -0
@@ -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 {};