omk-adaptorch-wpl 0.96.2 → 0.98.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 +50 -14
- package/dist/adaptorch-api-types.d.ts +69 -0
- package/dist/adaptorch-api-types.d.ts.map +1 -0
- package/dist/adaptorch-api-types.js +9 -0
- package/dist/adaptorch-api-types.js.map +1 -0
- package/dist/adaptorch-api.d.ts +87 -0
- package/dist/adaptorch-api.d.ts.map +1 -0
- package/dist/adaptorch-api.js +179 -0
- package/dist/adaptorch-api.js.map +1 -0
- package/dist/adaptorch-client.d.ts +41 -18
- package/dist/adaptorch-client.d.ts.map +1 -1
- package/dist/adaptorch-client.js +48 -20
- package/dist/adaptorch-client.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# omk-adaptorch-wpl
|
|
2
2
|
|
|
3
|
-
> **Status**:
|
|
4
|
-
>
|
|
5
|
-
>
|
|
6
|
-
>
|
|
7
|
-
>
|
|
3
|
+
> **Status**: Published and installed as an `open-multi-agent-kit` runtime dependency.
|
|
4
|
+
> The package provides Work Packet state, AdaptOrch client, adjudication, and verdict-projection
|
|
5
|
+
> primitives. It does **not** wire an end-to-end dispatch loop into the default OMK CLI:
|
|
6
|
+
> `src/loop.ts` explicitly excludes `adaptorch_run` submission/polling, request assembly, and
|
|
7
|
+
> persistence. A caller or explicitly loaded extension must own those boundaries.
|
|
8
8
|
|
|
9
9
|
## Design documents
|
|
10
10
|
|
|
11
|
-
The
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
The historical design record lives in the repository-local path
|
|
12
|
+
`.omk/runs/adaptorch-native-loop-algorithm-20260701/`; it is not included in the
|
|
13
|
+
published package. Current source and tests override that record:
|
|
14
14
|
|
|
15
15
|
- `final-part1-core-algorithm.md` — Work Packet state machine, termination conditions, cancellation policy
|
|
16
16
|
- `final-part2-verification-layer.md` — the Outcome Adjudicator (5-state verification)
|
|
@@ -22,7 +22,7 @@ review that shaped the safety gates below) lives outside this package at
|
|
|
22
22
|
- `src/state-machine.ts` — the packet lifecycle state machine and transition guards
|
|
23
23
|
- `src/adaptorch-client.ts` — thin typed wrapper around AdaptOrch's 10 MCP tools
|
|
24
24
|
- `src/adjudicator.ts` + `src/adjudicator-registry.ts` — the Outcome Adjudicator and its per-`kind` registry
|
|
25
|
-
- `src/loop.ts` —
|
|
25
|
+
- `src/loop.ts` — adjudication timeout, verdict projection, and next-transition helpers; not an end-to-end dispatcher
|
|
26
26
|
- `src/b2c-mapper.ts` — B2C (Bridge-to-Code) mapping for patch-apply safety
|
|
27
27
|
- `src/b2c-verdict.ts` — Verdict card schema for correctness wall decisions
|
|
28
28
|
- `src/deep-wall.ts` — Deep verification wall for multi-runner evidence gating
|
|
@@ -30,12 +30,12 @@ review that shaped the safety gates below) lives outside this package at
|
|
|
30
30
|
|
|
31
31
|
## Integration
|
|
32
32
|
|
|
33
|
-
The coding-agent
|
|
33
|
+
The default coding-agent source has no production importer that turns this package into a WPL execution path. Related surfaces are:
|
|
34
34
|
|
|
35
|
-
- `packages/coding-agent/src/core/adaptorch-bridge.ts` — advisory-only bridge
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- `packages/coding-agent/docs/adaptorch-preview.md` —
|
|
35
|
+
- `packages/coding-agent/src/core/adaptorch-bridge.ts` — separate advisory-only bridge,
|
|
36
|
+
default-off; its current transport returns no hint.
|
|
37
|
+
- `packages/coding-agent/examples/extensions/correctness-wall/` — explicit opt-in extension that imports the package.
|
|
38
|
+
- `packages/coding-agent/docs/adaptorch-preview.md` — planning blueprint and claim boundary.
|
|
39
39
|
|
|
40
40
|
## Safety notes (do not remove without updating the design docs)
|
|
41
41
|
|
|
@@ -46,4 +46,40 @@ The coding-agent consumes this package via:
|
|
|
46
46
|
- Loop-level budgets (`max_dispatch_attempts`, `max_loop_duration`, dispatch-call budget) are
|
|
47
47
|
immutable for a loop instance's lifetime; raising them requires a new instance under the same review.
|
|
48
48
|
|
|
49
|
+
## AdaptOrch, the service
|
|
50
|
+
|
|
51
|
+
This package is open source and MIT-licensed, like the rest of OMK. AdaptOrch
|
|
52
|
+
itself is a separate, proprietary product: an evidence and risk layer that takes
|
|
53
|
+
a change an AI wrote, runs it inside an isolated copy of the project, and
|
|
54
|
+
returns one report of what the change touched, whether it ran, what the tests
|
|
55
|
+
said before and after, and what looked suspicious.
|
|
56
|
+
|
|
57
|
+
Nothing here calls it by default. `adaptorch-client.ts` is a typed wrapper a
|
|
58
|
+
caller must configure and drive, and the coding agent's `adaptorch-bridge.ts`
|
|
59
|
+
is advisory-only, default-off, and its current transport returns no hint.
|
|
60
|
+
|
|
61
|
+
The division is deliberate and matches how the vendor describes its own
|
|
62
|
+
boundary: AdaptOrch watches and reports, and does not rewrite code, choose a
|
|
63
|
+
different answer, or merge anything. An advisory path must not acquire
|
|
64
|
+
execution authority, because that is what keeps a remote suggestion from
|
|
65
|
+
becoming a local action.
|
|
66
|
+
|
|
67
|
+
Its published claim boundary (`DOC-CLM-001`) states what it does and does not
|
|
68
|
+
claim. It verifies patch applicability through Docker-faithful apply gates,
|
|
69
|
+
canonicalizes tool-generated patches into realized git diffs, separates runner
|
|
70
|
+
health from candidate-caused failures, and records replayable evidence DAGs.
|
|
71
|
+
It explicitly **does not prove semantic correctness** — shadow reports carry
|
|
72
|
+
`correctness_claim=false` — and it blocks hidden tests, gold patches, and
|
|
73
|
+
oracle labels as selector inputs. A verification pass, a manifest hash, or a
|
|
74
|
+
signed receipt is evidence about a run, not authorization to ship it.
|
|
75
|
+
|
|
76
|
+
The free Starter tier is self-hosted and runs on your own machine; bring-your-own
|
|
77
|
+
model key is required on every tier, so no key means no run. Paid tiers add a
|
|
78
|
+
hosted dashboard, shared projects, and exports.
|
|
79
|
+
|
|
80
|
+
**[Review AdaptOrch plans →](https://adaptorch.com/?utm_source=github&utm_medium=package-readme&utm_campaign=omk-adaptorch-wpl#pricing)** · [claim boundary](https://adaptorch.com/claim-boundary?utm_source=github&utm_medium=package-readme&utm_campaign=omk-adaptorch-wpl)
|
|
81
|
+
|
|
82
|
+
Using this package does not require AdaptOrch, and installing OMK does not
|
|
83
|
+
create an account.
|
|
84
|
+
|
|
49
85
|
Preview spec: [`../coding-agent/docs/adaptorch-preview.md`](../coding-agent/docs/adaptorch-preview.md)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptOrch User API v1 data types.
|
|
3
|
+
*
|
|
4
|
+
* Projected from `contracts/openapi/adaptorch-user-api.v1.yaml` in the
|
|
5
|
+
* Adaptorch-MCP repository. Optional fields are optional here because the
|
|
6
|
+
* contract marks them so; a field absent from the contract is absent here.
|
|
7
|
+
*/
|
|
8
|
+
/** Lifecycle states a run can report. */
|
|
9
|
+
export type RunStatus = "QUEUED" | "RUNNING" | "SUCCEEDED" | "FAILED" | "CANCELLING";
|
|
10
|
+
export interface Run {
|
|
11
|
+
readonly run_id: string;
|
|
12
|
+
readonly status: RunStatus;
|
|
13
|
+
readonly kind?: string;
|
|
14
|
+
readonly phase?: string;
|
|
15
|
+
readonly created_at?: string;
|
|
16
|
+
readonly policy_version?: string;
|
|
17
|
+
readonly project_id?: string;
|
|
18
|
+
readonly links?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface RunListResponse {
|
|
21
|
+
readonly items: readonly Run[];
|
|
22
|
+
readonly next_cursor?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Body accepted by `POST /v1/runs`. The contract bounds `subtasks` to 1..50. */
|
|
25
|
+
export interface RunSubmission {
|
|
26
|
+
readonly subtasks: readonly Record<string, unknown>[];
|
|
27
|
+
readonly dependencies?: readonly Record<string, unknown>[];
|
|
28
|
+
readonly model?: string | null;
|
|
29
|
+
readonly synthesis_mode?: string | null;
|
|
30
|
+
readonly global_context?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface CapabilitySet {
|
|
33
|
+
readonly api_version: string;
|
|
34
|
+
readonly features: readonly string[];
|
|
35
|
+
readonly run_types?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
export interface Principal {
|
|
38
|
+
readonly subject_id: string;
|
|
39
|
+
readonly project_id?: string;
|
|
40
|
+
}
|
|
41
|
+
/** One graded check. `status` is a free-form outcome label such as `PASSED`. */
|
|
42
|
+
export interface EvidenceCheck {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly status: string;
|
|
45
|
+
}
|
|
46
|
+
export interface EvidenceReport {
|
|
47
|
+
readonly run_id: string;
|
|
48
|
+
readonly checks: readonly EvidenceCheck[];
|
|
49
|
+
}
|
|
50
|
+
export interface Artifact {
|
|
51
|
+
readonly artifact_id: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly media_type?: string;
|
|
54
|
+
readonly size_bytes?: number;
|
|
55
|
+
readonly sha256?: string;
|
|
56
|
+
readonly download_url?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ArtifactListResponse {
|
|
59
|
+
readonly run_id: string;
|
|
60
|
+
readonly items: readonly Artifact[];
|
|
61
|
+
}
|
|
62
|
+
/** Documented filters for `GET /v1/runs`. */
|
|
63
|
+
export interface ListRunsQuery {
|
|
64
|
+
readonly status?: RunStatus;
|
|
65
|
+
readonly projectId?: string;
|
|
66
|
+
readonly limit?: number;
|
|
67
|
+
readonly cursor?: string;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=adaptorch-api-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptorch-api-types.d.ts","sourceRoot":"","sources":["../src/adaptorch-api-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yCAAyC;AACzC,MAAM,MAAM,SAAS,GAAG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AAE,CAAC;CACvC;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,gFAAgF;AAChF,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACpC;AAED,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB","sourcesContent":["/**\n * AdaptOrch User API v1 data types.\n *\n * Projected from `contracts/openapi/adaptorch-user-api.v1.yaml` in the\n * Adaptorch-MCP repository. Optional fields are optional here because the\n * contract marks them so; a field absent from the contract is absent here.\n */\n\n/** Lifecycle states a run can report. */\nexport type RunStatus = \"QUEUED\" | \"RUNNING\" | \"SUCCEEDED\" | \"FAILED\" | \"CANCELLING\";\n\nexport interface Run {\n\treadonly run_id: string;\n\treadonly status: RunStatus;\n\treadonly kind?: string;\n\treadonly phase?: string;\n\treadonly created_at?: string;\n\treadonly policy_version?: string;\n\treadonly project_id?: string;\n\treadonly links?: Record<string, unknown>;\n}\n\nexport interface RunListResponse {\n\treadonly items: readonly Run[];\n\treadonly next_cursor?: string;\n}\n\n/** Body accepted by `POST /v1/runs`. The contract bounds `subtasks` to 1..50. */\nexport interface RunSubmission {\n\treadonly subtasks: readonly Record<string, unknown>[];\n\treadonly dependencies?: readonly Record<string, unknown>[];\n\treadonly model?: string | null;\n\treadonly synthesis_mode?: string | null;\n\treadonly global_context?: string | null;\n}\n\nexport interface CapabilitySet {\n\treadonly api_version: string;\n\treadonly features: readonly string[];\n\treadonly run_types?: readonly string[];\n}\n\nexport interface Principal {\n\treadonly subject_id: string;\n\treadonly project_id?: string;\n}\n\n/** One graded check. `status` is a free-form outcome label such as `PASSED`. */\nexport interface EvidenceCheck {\n\treadonly name: string;\n\treadonly status: string;\n}\n\nexport interface EvidenceReport {\n\treadonly run_id: string;\n\treadonly checks: readonly EvidenceCheck[];\n}\n\nexport interface Artifact {\n\treadonly artifact_id: string;\n\treadonly name: string;\n\treadonly media_type?: string;\n\treadonly size_bytes?: number;\n\treadonly sha256?: string;\n\treadonly download_url?: string;\n}\n\nexport interface ArtifactListResponse {\n\treadonly run_id: string;\n\treadonly items: readonly Artifact[];\n}\n\n/** Documented filters for `GET /v1/runs`. */\nexport interface ListRunsQuery {\n\treadonly status?: RunStatus;\n\treadonly projectId?: string;\n\treadonly limit?: number;\n\treadonly cursor?: string;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptOrch User API v1 data types.
|
|
3
|
+
*
|
|
4
|
+
* Projected from `contracts/openapi/adaptorch-user-api.v1.yaml` in the
|
|
5
|
+
* Adaptorch-MCP repository. Optional fields are optional here because the
|
|
6
|
+
* contract marks them so; a field absent from the contract is absent here.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=adaptorch-api-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptorch-api-types.js","sourceRoot":"","sources":["../src/adaptorch-api-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * AdaptOrch User API v1 data types.\n *\n * Projected from `contracts/openapi/adaptorch-user-api.v1.yaml` in the\n * Adaptorch-MCP repository. Optional fields are optional here because the\n * contract marks them so; a field absent from the contract is absent here.\n */\n\n/** Lifecycle states a run can report. */\nexport type RunStatus = \"QUEUED\" | \"RUNNING\" | \"SUCCEEDED\" | \"FAILED\" | \"CANCELLING\";\n\nexport interface Run {\n\treadonly run_id: string;\n\treadonly status: RunStatus;\n\treadonly kind?: string;\n\treadonly phase?: string;\n\treadonly created_at?: string;\n\treadonly policy_version?: string;\n\treadonly project_id?: string;\n\treadonly links?: Record<string, unknown>;\n}\n\nexport interface RunListResponse {\n\treadonly items: readonly Run[];\n\treadonly next_cursor?: string;\n}\n\n/** Body accepted by `POST /v1/runs`. The contract bounds `subtasks` to 1..50. */\nexport interface RunSubmission {\n\treadonly subtasks: readonly Record<string, unknown>[];\n\treadonly dependencies?: readonly Record<string, unknown>[];\n\treadonly model?: string | null;\n\treadonly synthesis_mode?: string | null;\n\treadonly global_context?: string | null;\n}\n\nexport interface CapabilitySet {\n\treadonly api_version: string;\n\treadonly features: readonly string[];\n\treadonly run_types?: readonly string[];\n}\n\nexport interface Principal {\n\treadonly subject_id: string;\n\treadonly project_id?: string;\n}\n\n/** One graded check. `status` is a free-form outcome label such as `PASSED`. */\nexport interface EvidenceCheck {\n\treadonly name: string;\n\treadonly status: string;\n}\n\nexport interface EvidenceReport {\n\treadonly run_id: string;\n\treadonly checks: readonly EvidenceCheck[];\n}\n\nexport interface Artifact {\n\treadonly artifact_id: string;\n\treadonly name: string;\n\treadonly media_type?: string;\n\treadonly size_bytes?: number;\n\treadonly sha256?: string;\n\treadonly download_url?: string;\n}\n\nexport interface ArtifactListResponse {\n\treadonly run_id: string;\n\treadonly items: readonly Artifact[];\n}\n\n/** Documented filters for `GET /v1/runs`. */\nexport interface ListRunsQuery {\n\treadonly status?: RunStatus;\n\treadonly projectId?: string;\n\treadonly limit?: number;\n\treadonly cursor?: string;\n}\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptOrch User API v1 client.
|
|
3
|
+
*
|
|
4
|
+
* This is the hosted path, and it is deliberately separate from
|
|
5
|
+
* `adaptorch-client.ts`: that module wraps the MCP tool surface, which reaches
|
|
6
|
+
* a *local* parent engine, while this one speaks plain HTTPS to the control
|
|
7
|
+
* plane and needs nothing installed beyond an API key.
|
|
8
|
+
*
|
|
9
|
+
* Following the same rule as the MCP wrapper, this package still opens no
|
|
10
|
+
* network I/O of its own. The caller injects `fetch`, so a test never needs a
|
|
11
|
+
* socket and a host application keeps ownership of its HTTP stack.
|
|
12
|
+
*/
|
|
13
|
+
import type { ArtifactListResponse, CapabilitySet, EvidenceReport, ListRunsQuery, Principal, Run, RunListResponse, RunSubmission } from "./adaptorch-api-types.ts";
|
|
14
|
+
export type * from "./adaptorch-api-types.ts";
|
|
15
|
+
export interface AdaptOrchRequestInit {
|
|
16
|
+
readonly method: string;
|
|
17
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
18
|
+
readonly body?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface AdaptOrchHttpResponse {
|
|
21
|
+
readonly status: number;
|
|
22
|
+
json(): Promise<unknown>;
|
|
23
|
+
text(): Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
/** Injected HTTP boundary. `globalThis.fetch` satisfies this shape. */
|
|
26
|
+
export type AdaptOrchFetch = (url: string, init: AdaptOrchRequestInit) => Promise<AdaptOrchHttpResponse>;
|
|
27
|
+
export interface AdaptOrchApiConfig {
|
|
28
|
+
readonly baseUrl: string;
|
|
29
|
+
readonly apiKey: string;
|
|
30
|
+
readonly fetch: AdaptOrchFetch;
|
|
31
|
+
}
|
|
32
|
+
/** A non-2xx response, carrying the server's sanitized code and message. */
|
|
33
|
+
export declare class AdaptOrchApiError extends Error {
|
|
34
|
+
readonly status: number;
|
|
35
|
+
readonly code: string | undefined;
|
|
36
|
+
constructor(status: number, code: string | undefined, message: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Choose the credential header.
|
|
40
|
+
*
|
|
41
|
+
* A tenant dashboard key carries the documented `ado_` prefix and must travel
|
|
42
|
+
* only as `X-API-Key`; the contract explicitly forbids also sending it in
|
|
43
|
+
* `Authorization`. Anything else is a non-tenant service credential and uses a
|
|
44
|
+
* bearer token. Sending both would leak a tenant key into a header the control
|
|
45
|
+
* plane does not expect it in.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveAuthHeaders(apiKey: string): Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Reject a base URL that would put a credential on the wire in plaintext.
|
|
50
|
+
* Plain HTTP is allowed only for an exact loopback host, so a lookalike such as
|
|
51
|
+
* `localhost.evil.test` does not slip through a prefix check.
|
|
52
|
+
*/
|
|
53
|
+
export declare function assertSafeApiUrl(baseUrl: string): void;
|
|
54
|
+
/** Default control-plane origin, overridable with `ADAPTORCH_API_URL`. */
|
|
55
|
+
export declare const ADAPTORCH_DEFAULT_API_URL = "https://api.adaptorch.com";
|
|
56
|
+
/**
|
|
57
|
+
* Build a client from the environment: `ADAPTORCH_API_KEY` and an optional
|
|
58
|
+
* `ADAPTORCH_API_URL`. Returns `undefined` when no key is configured, so a
|
|
59
|
+
* caller can treat AdaptOrch as an opt-in the operator enables rather than a
|
|
60
|
+
* dependency that must be present.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createAdaptOrchApiClientFromEnv(fetchImpl: AdaptOrchFetch, env?: Readonly<Record<string, string | undefined>>): AdaptOrchApiClient | undefined;
|
|
63
|
+
/** Typed client for the AdaptOrch User API v1. */
|
|
64
|
+
export declare class AdaptOrchApiClient {
|
|
65
|
+
private readonly baseUrl;
|
|
66
|
+
private readonly apiKey;
|
|
67
|
+
private readonly fetch;
|
|
68
|
+
constructor(config: AdaptOrchApiConfig);
|
|
69
|
+
private request;
|
|
70
|
+
/** `GET /v1/capabilities` — API version and enabled features. */
|
|
71
|
+
capabilities(): Promise<CapabilitySet>;
|
|
72
|
+
/** `GET /v1/whoami` — the calling principal, for verifying a key works. */
|
|
73
|
+
whoami(): Promise<Principal>;
|
|
74
|
+
/** `POST /v1/runs` — submit work. The contract bounds `subtasks` to 1..50. */
|
|
75
|
+
submitRun(submission: RunSubmission): Promise<Run>;
|
|
76
|
+
/** `GET /v1/runs` — list runs, filtered by the documented parameters only. */
|
|
77
|
+
listRuns(query?: ListRunsQuery): Promise<RunListResponse>;
|
|
78
|
+
/** `GET /v1/runs/{run_id}` — one run's current state. */
|
|
79
|
+
getRun(runId: string): Promise<Run>;
|
|
80
|
+
/** `PUT /v1/runs/{run_id}/cancel` — request cancellation. */
|
|
81
|
+
cancelRun(runId: string, reason?: string): Promise<Run>;
|
|
82
|
+
/** `GET /v1/runs/{run_id}/evidence` — the graded checks for a run. */
|
|
83
|
+
getEvidence(runId: string): Promise<EvidenceReport>;
|
|
84
|
+
/** `GET /v1/runs/{run_id}/artifacts` — artifacts a run produced. */
|
|
85
|
+
listArtifacts(runId: string): Promise<ArtifactListResponse>;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=adaptorch-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptorch-api.d.ts","sourceRoot":"","sources":["../src/adaptorch-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACX,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,aAAa,EACb,SAA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A0E;AAC1E,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC9C,SAAS,EAAE,cAAc,EACzB,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAC7D,kBAAkB,GAAG,SAAS,CAQhC;AAED,kDAAkD;AAClD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IAEvC,YAAY,MAAM,EAAE,kBAAkB,EAMrC;YAEa,OAAO;IAsCrB,mEAAiE;IACjE,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,CAErC;IAED,6EAA2E;IAC3E,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAE3B;IAED,gFAA8E;IAC9E,SAAS,CAAC,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAEjD;IAED,gFAA8E;IAC9E,QAAQ,CAAC,KAAK,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAQ5D;IAED,2DAAyD;IACzD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAElC;IAED,+DAA6D;IAC7D,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAMtD;IAED,wEAAsE;IACtE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAElD;IAED,sEAAoE;IACpE,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAE1D;CACD","sourcesContent":["/**\n * AdaptOrch User API v1 client.\n *\n * This is the hosted path, and it is deliberately separate from\n * `adaptorch-client.ts`: that module wraps the MCP tool surface, which reaches\n * a *local* parent engine, while this one speaks plain HTTPS to the control\n * plane and needs nothing installed beyond an API key.\n *\n * Following the same rule as the MCP wrapper, this package still opens no\n * network I/O of its own. The caller injects `fetch`, so a test never needs a\n * socket and a host application keeps ownership of its HTTP stack.\n */\n\nimport type {\n\tArtifactListResponse,\n\tCapabilitySet,\n\tEvidenceReport,\n\tListRunsQuery,\n\tPrincipal,\n\tRun,\n\tRunListResponse,\n\tRunSubmission,\n} from \"./adaptorch-api-types.ts\";\n\nexport type * from \"./adaptorch-api-types.ts\";\n\nexport interface AdaptOrchRequestInit {\n\treadonly method: string;\n\treadonly headers: Readonly<Record<string, string>>;\n\treadonly body?: string;\n}\n\nexport interface AdaptOrchHttpResponse {\n\treadonly status: number;\n\tjson(): Promise<unknown>;\n\ttext(): Promise<string>;\n}\n\n/** Injected HTTP boundary. `globalThis.fetch` satisfies this shape. */\nexport type AdaptOrchFetch = (url: string, init: AdaptOrchRequestInit) => Promise<AdaptOrchHttpResponse>;\n\nexport interface AdaptOrchApiConfig {\n\treadonly baseUrl: string;\n\treadonly apiKey: string;\n\treadonly fetch: AdaptOrchFetch;\n}\n\n/** A non-2xx response, carrying the server's sanitized code and message. */\nexport class AdaptOrchApiError extends Error {\n\treadonly status: number;\n\treadonly code: string | undefined;\n\n\tconstructor(status: number, code: string | undefined, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"AdaptOrchApiError\";\n\t\tthis.status = status;\n\t\tthis.code = code;\n\t}\n}\n\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"::1\"]);\n\n/**\n * Choose the credential header.\n *\n * A tenant dashboard key carries the documented `ado_` prefix and must travel\n * only as `X-API-Key`; the contract explicitly forbids also sending it in\n * `Authorization`. Anything else is a non-tenant service credential and uses a\n * bearer token. Sending both would leak a tenant key into a header the control\n * plane does not expect it in.\n */\nexport function resolveAuthHeaders(apiKey: string): Record<string, string> {\n\tconst key = apiKey.trim();\n\tif (key === \"\") throw new Error(\"AdaptOrch API key is required\");\n\treturn key.startsWith(\"ado_\") ? { \"X-API-Key\": key } : { Authorization: `Bearer ${key}` };\n}\n\n/**\n * Reject a base URL that would put a credential on the wire in plaintext.\n * Plain HTTP is allowed only for an exact loopback host, so a lookalike such as\n * `localhost.evil.test` does not slip through a prefix check.\n */\nexport function assertSafeApiUrl(baseUrl: string): void {\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(baseUrl);\n\t} catch {\n\t\tthrow new Error(`AdaptOrch base URL is not a valid URL: ${baseUrl}`);\n\t}\n\tif (url.protocol === \"https:\") return;\n\tif (url.protocol === \"http:\" && LOOPBACK_HOSTS.has(url.hostname.replace(/^\\[|\\]$/g, \"\"))) return;\n\tthrow new Error(`AdaptOrch base URL must use https (or http on loopback): ${baseUrl}`);\n}\n\n/** Remove a credential from any text that is about to become an error message. */\nfunction redact(text: string, apiKey: string): string {\n\tconst key = apiKey.trim();\n\treturn key === \"\" ? text : text.split(key).join(\"[REDACTED]\");\n}\n\nfunction readErrorFields(body: unknown): { code?: string; message?: string } {\n\tif (typeof body !== \"object\" || body === null) return {};\n\tconst record = body as Record<string, unknown>;\n\treturn {\n\t\t...(typeof record.code === \"string\" ? { code: record.code } : {}),\n\t\t...(typeof record.message === \"string\" ? { message: record.message } : {}),\n\t};\n}\n\n/** Default control-plane origin, overridable with `ADAPTORCH_API_URL`. */\nexport const ADAPTORCH_DEFAULT_API_URL = \"https://api.adaptorch.com\";\n\n/**\n * Build a client from the environment: `ADAPTORCH_API_KEY` and an optional\n * `ADAPTORCH_API_URL`. Returns `undefined` when no key is configured, so a\n * caller can treat AdaptOrch as an opt-in the operator enables rather than a\n * dependency that must be present.\n */\nexport function createAdaptOrchApiClientFromEnv(\n\tfetchImpl: AdaptOrchFetch,\n\tenv: Readonly<Record<string, string | undefined>> = process.env,\n): AdaptOrchApiClient | undefined {\n\tconst apiKey = env.ADAPTORCH_API_KEY?.trim();\n\tif (!apiKey) return undefined;\n\treturn new AdaptOrchApiClient({\n\t\tbaseUrl: env.ADAPTORCH_API_URL?.trim() || ADAPTORCH_DEFAULT_API_URL,\n\t\tapiKey,\n\t\tfetch: fetchImpl,\n\t});\n}\n\n/** Typed client for the AdaptOrch User API v1. */\nexport class AdaptOrchApiClient {\n\tprivate readonly baseUrl: string;\n\tprivate readonly apiKey: string;\n\tprivate readonly fetch: AdaptOrchFetch;\n\n\tconstructor(config: AdaptOrchApiConfig) {\n\t\tassertSafeApiUrl(config.baseUrl);\n\t\tresolveAuthHeaders(config.apiKey);\n\t\tthis.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n\t\tthis.apiKey = config.apiKey;\n\t\tthis.fetch = config.fetch;\n\t}\n\n\tprivate async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n\t\tconst init: AdaptOrchRequestInit = {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t...resolveAuthHeaders(this.apiKey),\n\t\t\t\t...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n\t\t\t},\n\t\t\t...(body === undefined ? {} : { body: JSON.stringify(body) }),\n\t\t};\n\n\t\tlet response: AdaptOrchHttpResponse;\n\t\ttry {\n\t\t\tresponse = await this.fetch(`${this.baseUrl}${path}`, init);\n\t\t} catch (error) {\n\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(`AdaptOrch request failed: ${redact(detail, this.apiKey)}`);\n\t\t}\n\n\t\tlet payload: unknown;\n\t\ttry {\n\t\t\tpayload = await response.json();\n\t\t} catch {\n\t\t\t// A body that is absent or not JSON is not itself a failure: the status\n\t\t\t// still decides, and an error response keeps its generic message.\n\t\t\tpayload = undefined;\n\t\t}\n\t\tif (response.status < 200 || response.status >= 300) {\n\t\t\tconst { code, message } = readErrorFields(payload);\n\t\t\tthrow new AdaptOrchApiError(\n\t\t\t\tresponse.status,\n\t\t\t\tcode,\n\t\t\t\tredact(message ?? `AdaptOrch request failed with status ${response.status}`, this.apiKey),\n\t\t\t);\n\t\t}\n\t\treturn payload as T;\n\t}\n\n\t/** `GET /v1/capabilities` — API version and enabled features. */\n\tcapabilities(): Promise<CapabilitySet> {\n\t\treturn this.request<CapabilitySet>(\"GET\", \"/v1/capabilities\");\n\t}\n\n\t/** `GET /v1/whoami` — the calling principal, for verifying a key works. */\n\twhoami(): Promise<Principal> {\n\t\treturn this.request<Principal>(\"GET\", \"/v1/whoami\");\n\t}\n\n\t/** `POST /v1/runs` — submit work. The contract bounds `subtasks` to 1..50. */\n\tsubmitRun(submission: RunSubmission): Promise<Run> {\n\t\treturn this.request<Run>(\"POST\", \"/v1/runs\", submission);\n\t}\n\n\t/** `GET /v1/runs` — list runs, filtered by the documented parameters only. */\n\tlistRuns(query: ListRunsQuery = {}): Promise<RunListResponse> {\n\t\tconst params = new URLSearchParams();\n\t\tif (query.status !== undefined) params.set(\"status\", query.status);\n\t\tif (query.projectId !== undefined) params.set(\"project_id\", query.projectId);\n\t\tif (query.limit !== undefined) params.set(\"limit\", String(query.limit));\n\t\tif (query.cursor !== undefined) params.set(\"cursor\", query.cursor);\n\t\tconst suffix = params.size === 0 ? \"\" : `?${params.toString()}`;\n\t\treturn this.request<RunListResponse>(\"GET\", `/v1/runs${suffix}`);\n\t}\n\n\t/** `GET /v1/runs/{run_id}` — one run's current state. */\n\tgetRun(runId: string): Promise<Run> {\n\t\treturn this.request<Run>(\"GET\", `/v1/runs/${encodeURIComponent(runId)}`);\n\t}\n\n\t/** `PUT /v1/runs/{run_id}/cancel` — request cancellation. */\n\tcancelRun(runId: string, reason?: string): Promise<Run> {\n\t\treturn this.request<Run>(\n\t\t\t\"PUT\",\n\t\t\t`/v1/runs/${encodeURIComponent(runId)}/cancel`,\n\t\t\treason === undefined ? {} : { reason },\n\t\t);\n\t}\n\n\t/** `GET /v1/runs/{run_id}/evidence` — the graded checks for a run. */\n\tgetEvidence(runId: string): Promise<EvidenceReport> {\n\t\treturn this.request<EvidenceReport>(\"GET\", `/v1/runs/${encodeURIComponent(runId)}/evidence`);\n\t}\n\n\t/** `GET /v1/runs/{run_id}/artifacts` — artifacts a run produced. */\n\tlistArtifacts(runId: string): Promise<ArtifactListResponse> {\n\t\treturn this.request<ArtifactListResponse>(\"GET\", `/v1/runs/${encodeURIComponent(runId)}/artifacts`);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptOrch User API v1 client.
|
|
3
|
+
*
|
|
4
|
+
* This is the hosted path, and it is deliberately separate from
|
|
5
|
+
* `adaptorch-client.ts`: that module wraps the MCP tool surface, which reaches
|
|
6
|
+
* a *local* parent engine, while this one speaks plain HTTPS to the control
|
|
7
|
+
* plane and needs nothing installed beyond an API key.
|
|
8
|
+
*
|
|
9
|
+
* Following the same rule as the MCP wrapper, this package still opens no
|
|
10
|
+
* network I/O of its own. The caller injects `fetch`, so a test never needs a
|
|
11
|
+
* socket and a host application keeps ownership of its HTTP stack.
|
|
12
|
+
*/
|
|
13
|
+
/** A non-2xx response, carrying the server's sanitized code and message. */
|
|
14
|
+
export class AdaptOrchApiError extends Error {
|
|
15
|
+
status;
|
|
16
|
+
code;
|
|
17
|
+
constructor(status, code, message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "AdaptOrchApiError";
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
25
|
+
/**
|
|
26
|
+
* Choose the credential header.
|
|
27
|
+
*
|
|
28
|
+
* A tenant dashboard key carries the documented `ado_` prefix and must travel
|
|
29
|
+
* only as `X-API-Key`; the contract explicitly forbids also sending it in
|
|
30
|
+
* `Authorization`. Anything else is a non-tenant service credential and uses a
|
|
31
|
+
* bearer token. Sending both would leak a tenant key into a header the control
|
|
32
|
+
* plane does not expect it in.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveAuthHeaders(apiKey) {
|
|
35
|
+
const key = apiKey.trim();
|
|
36
|
+
if (key === "")
|
|
37
|
+
throw new Error("AdaptOrch API key is required");
|
|
38
|
+
return key.startsWith("ado_") ? { "X-API-Key": key } : { Authorization: `Bearer ${key}` };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Reject a base URL that would put a credential on the wire in plaintext.
|
|
42
|
+
* Plain HTTP is allowed only for an exact loopback host, so a lookalike such as
|
|
43
|
+
* `localhost.evil.test` does not slip through a prefix check.
|
|
44
|
+
*/
|
|
45
|
+
export function assertSafeApiUrl(baseUrl) {
|
|
46
|
+
let url;
|
|
47
|
+
try {
|
|
48
|
+
url = new URL(baseUrl);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error(`AdaptOrch base URL is not a valid URL: ${baseUrl}`);
|
|
52
|
+
}
|
|
53
|
+
if (url.protocol === "https:")
|
|
54
|
+
return;
|
|
55
|
+
if (url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname.replace(/^\[|\]$/g, "")))
|
|
56
|
+
return;
|
|
57
|
+
throw new Error(`AdaptOrch base URL must use https (or http on loopback): ${baseUrl}`);
|
|
58
|
+
}
|
|
59
|
+
/** Remove a credential from any text that is about to become an error message. */
|
|
60
|
+
function redact(text, apiKey) {
|
|
61
|
+
const key = apiKey.trim();
|
|
62
|
+
return key === "" ? text : text.split(key).join("[REDACTED]");
|
|
63
|
+
}
|
|
64
|
+
function readErrorFields(body) {
|
|
65
|
+
if (typeof body !== "object" || body === null)
|
|
66
|
+
return {};
|
|
67
|
+
const record = body;
|
|
68
|
+
return {
|
|
69
|
+
...(typeof record.code === "string" ? { code: record.code } : {}),
|
|
70
|
+
...(typeof record.message === "string" ? { message: record.message } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Default control-plane origin, overridable with `ADAPTORCH_API_URL`. */
|
|
74
|
+
export const ADAPTORCH_DEFAULT_API_URL = "https://api.adaptorch.com";
|
|
75
|
+
/**
|
|
76
|
+
* Build a client from the environment: `ADAPTORCH_API_KEY` and an optional
|
|
77
|
+
* `ADAPTORCH_API_URL`. Returns `undefined` when no key is configured, so a
|
|
78
|
+
* caller can treat AdaptOrch as an opt-in the operator enables rather than a
|
|
79
|
+
* dependency that must be present.
|
|
80
|
+
*/
|
|
81
|
+
export function createAdaptOrchApiClientFromEnv(fetchImpl, env = process.env) {
|
|
82
|
+
const apiKey = env.ADAPTORCH_API_KEY?.trim();
|
|
83
|
+
if (!apiKey)
|
|
84
|
+
return undefined;
|
|
85
|
+
return new AdaptOrchApiClient({
|
|
86
|
+
baseUrl: env.ADAPTORCH_API_URL?.trim() || ADAPTORCH_DEFAULT_API_URL,
|
|
87
|
+
apiKey,
|
|
88
|
+
fetch: fetchImpl,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** Typed client for the AdaptOrch User API v1. */
|
|
92
|
+
export class AdaptOrchApiClient {
|
|
93
|
+
baseUrl;
|
|
94
|
+
apiKey;
|
|
95
|
+
fetch;
|
|
96
|
+
constructor(config) {
|
|
97
|
+
assertSafeApiUrl(config.baseUrl);
|
|
98
|
+
resolveAuthHeaders(config.apiKey);
|
|
99
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
100
|
+
this.apiKey = config.apiKey;
|
|
101
|
+
this.fetch = config.fetch;
|
|
102
|
+
}
|
|
103
|
+
async request(method, path, body) {
|
|
104
|
+
const init = {
|
|
105
|
+
method,
|
|
106
|
+
headers: {
|
|
107
|
+
Accept: "application/json",
|
|
108
|
+
...resolveAuthHeaders(this.apiKey),
|
|
109
|
+
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
|
110
|
+
},
|
|
111
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
112
|
+
};
|
|
113
|
+
let response;
|
|
114
|
+
try {
|
|
115
|
+
response = await this.fetch(`${this.baseUrl}${path}`, init);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
119
|
+
throw new Error(`AdaptOrch request failed: ${redact(detail, this.apiKey)}`);
|
|
120
|
+
}
|
|
121
|
+
let payload;
|
|
122
|
+
try {
|
|
123
|
+
payload = await response.json();
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// A body that is absent or not JSON is not itself a failure: the status
|
|
127
|
+
// still decides, and an error response keeps its generic message.
|
|
128
|
+
payload = undefined;
|
|
129
|
+
}
|
|
130
|
+
if (response.status < 200 || response.status >= 300) {
|
|
131
|
+
const { code, message } = readErrorFields(payload);
|
|
132
|
+
throw new AdaptOrchApiError(response.status, code, redact(message ?? `AdaptOrch request failed with status ${response.status}`, this.apiKey));
|
|
133
|
+
}
|
|
134
|
+
return payload;
|
|
135
|
+
}
|
|
136
|
+
/** `GET /v1/capabilities` — API version and enabled features. */
|
|
137
|
+
capabilities() {
|
|
138
|
+
return this.request("GET", "/v1/capabilities");
|
|
139
|
+
}
|
|
140
|
+
/** `GET /v1/whoami` — the calling principal, for verifying a key works. */
|
|
141
|
+
whoami() {
|
|
142
|
+
return this.request("GET", "/v1/whoami");
|
|
143
|
+
}
|
|
144
|
+
/** `POST /v1/runs` — submit work. The contract bounds `subtasks` to 1..50. */
|
|
145
|
+
submitRun(submission) {
|
|
146
|
+
return this.request("POST", "/v1/runs", submission);
|
|
147
|
+
}
|
|
148
|
+
/** `GET /v1/runs` — list runs, filtered by the documented parameters only. */
|
|
149
|
+
listRuns(query = {}) {
|
|
150
|
+
const params = new URLSearchParams();
|
|
151
|
+
if (query.status !== undefined)
|
|
152
|
+
params.set("status", query.status);
|
|
153
|
+
if (query.projectId !== undefined)
|
|
154
|
+
params.set("project_id", query.projectId);
|
|
155
|
+
if (query.limit !== undefined)
|
|
156
|
+
params.set("limit", String(query.limit));
|
|
157
|
+
if (query.cursor !== undefined)
|
|
158
|
+
params.set("cursor", query.cursor);
|
|
159
|
+
const suffix = params.size === 0 ? "" : `?${params.toString()}`;
|
|
160
|
+
return this.request("GET", `/v1/runs${suffix}`);
|
|
161
|
+
}
|
|
162
|
+
/** `GET /v1/runs/{run_id}` — one run's current state. */
|
|
163
|
+
getRun(runId) {
|
|
164
|
+
return this.request("GET", `/v1/runs/${encodeURIComponent(runId)}`);
|
|
165
|
+
}
|
|
166
|
+
/** `PUT /v1/runs/{run_id}/cancel` — request cancellation. */
|
|
167
|
+
cancelRun(runId, reason) {
|
|
168
|
+
return this.request("PUT", `/v1/runs/${encodeURIComponent(runId)}/cancel`, reason === undefined ? {} : { reason });
|
|
169
|
+
}
|
|
170
|
+
/** `GET /v1/runs/{run_id}/evidence` — the graded checks for a run. */
|
|
171
|
+
getEvidence(runId) {
|
|
172
|
+
return this.request("GET", `/v1/runs/${encodeURIComponent(runId)}/evidence`);
|
|
173
|
+
}
|
|
174
|
+
/** `GET /v1/runs/{run_id}/artifacts` — artifacts a run produced. */
|
|
175
|
+
listArtifacts(runId) {
|
|
176
|
+
return this.request("GET", `/v1/runs/${encodeURIComponent(runId)}/artifacts`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=adaptorch-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adaptorch-api.js","sourceRoot":"","sources":["../src/adaptorch-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoCH,4EAA4E;AAC5E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAClC,MAAM,CAAS;IACf,IAAI,CAAqB;IAElC,YAAY,MAAc,EAAE,IAAwB,EAAE,OAAe,EAAE;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,K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CAAC,CAAC,CAAC;QACxE,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;QAChE,OAAO,IAAI,CAAC,OAAO,CAAkB,KAAK,EAAE,WAAW,MAAM,EAAE,CAAC,CAAC;IAAA,CACjE;IAED,2DAAyD;IACzD,MAAM,CAAC,KAAa,EAAgB;QACnC,OAAO,IAAI,CAAC,OAAO,CAAM,KAAK,EAAE,YAAY,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAAA,CACzE;IAED,+DAA6D;IAC7D,SAAS,CAAC,KAAa,EAAE,MAAe,EAAgB;QACvD,OAAO,IAAI,CAAC,OAAO,CAClB,KAAK,EACL,YAAY,kBAAkB,CAAC,KAAK,CAAC,SAAS,EAC9C,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CACtC,CAAC;IAAA,CACF;IAED,wEAAsE;IACtE,WAAW,CAAC,KAAa,EAA2B;QACnD,OAAO,IAAI,CAAC,OAAO,CAAiB,KAAK,EAAE,YAAY,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAAA,CAC7F;IAED,sEAAoE;IACpE,aAAa,CAAC,KAAa,EAAiC;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAuB,KAAK,EAAE,YAAY,kBAAkB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAAA,CACpG;CACD","sourcesContent":["/**\n * AdaptOrch User API v1 client.\n *\n * This is the hosted path, and it is deliberately separate from\n * `adaptorch-client.ts`: that module wraps the MCP tool surface, which reaches\n * a *local* parent engine, while this one speaks plain HTTPS to the control\n * plane and needs nothing installed beyond an API key.\n *\n * Following the same rule as the MCP wrapper, this package still opens no\n * network I/O of its own. The caller injects `fetch`, so a test never needs a\n * socket and a host application keeps ownership of its HTTP stack.\n */\n\nimport type {\n\tArtifactListResponse,\n\tCapabilitySet,\n\tEvidenceReport,\n\tListRunsQuery,\n\tPrincipal,\n\tRun,\n\tRunListResponse,\n\tRunSubmission,\n} from \"./adaptorch-api-types.ts\";\n\nexport type * from \"./adaptorch-api-types.ts\";\n\nexport interface AdaptOrchRequestInit {\n\treadonly method: string;\n\treadonly headers: Readonly<Record<string, string>>;\n\treadonly body?: string;\n}\n\nexport interface AdaptOrchHttpResponse {\n\treadonly status: number;\n\tjson(): Promise<unknown>;\n\ttext(): Promise<string>;\n}\n\n/** Injected HTTP boundary. `globalThis.fetch` satisfies this shape. */\nexport type AdaptOrchFetch = (url: string, init: AdaptOrchRequestInit) => Promise<AdaptOrchHttpResponse>;\n\nexport interface AdaptOrchApiConfig {\n\treadonly baseUrl: string;\n\treadonly apiKey: string;\n\treadonly fetch: AdaptOrchFetch;\n}\n\n/** A non-2xx response, carrying the server's sanitized code and message. */\nexport class AdaptOrchApiError extends Error {\n\treadonly status: number;\n\treadonly code: string | undefined;\n\n\tconstructor(status: number, code: string | undefined, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"AdaptOrchApiError\";\n\t\tthis.status = status;\n\t\tthis.code = code;\n\t}\n}\n\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"::1\"]);\n\n/**\n * Choose the credential header.\n *\n * A tenant dashboard key carries the documented `ado_` prefix and must travel\n * only as `X-API-Key`; the contract explicitly forbids also sending it in\n * `Authorization`. Anything else is a non-tenant service credential and uses a\n * bearer token. Sending both would leak a tenant key into a header the control\n * plane does not expect it in.\n */\nexport function resolveAuthHeaders(apiKey: string): Record<string, string> {\n\tconst key = apiKey.trim();\n\tif (key === \"\") throw new Error(\"AdaptOrch API key is required\");\n\treturn key.startsWith(\"ado_\") ? { \"X-API-Key\": key } : { Authorization: `Bearer ${key}` };\n}\n\n/**\n * Reject a base URL that would put a credential on the wire in plaintext.\n * Plain HTTP is allowed only for an exact loopback host, so a lookalike such as\n * `localhost.evil.test` does not slip through a prefix check.\n */\nexport function assertSafeApiUrl(baseUrl: string): void {\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(baseUrl);\n\t} catch {\n\t\tthrow new Error(`AdaptOrch base URL is not a valid URL: ${baseUrl}`);\n\t}\n\tif (url.protocol === \"https:\") return;\n\tif (url.protocol === \"http:\" && LOOPBACK_HOSTS.has(url.hostname.replace(/^\\[|\\]$/g, \"\"))) return;\n\tthrow new Error(`AdaptOrch base URL must use https (or http on loopback): ${baseUrl}`);\n}\n\n/** Remove a credential from any text that is about to become an error message. */\nfunction redact(text: string, apiKey: string): string {\n\tconst key = apiKey.trim();\n\treturn key === \"\" ? text : text.split(key).join(\"[REDACTED]\");\n}\n\nfunction readErrorFields(body: unknown): { code?: string; message?: string } {\n\tif (typeof body !== \"object\" || body === null) return {};\n\tconst record = body as Record<string, unknown>;\n\treturn {\n\t\t...(typeof record.code === \"string\" ? { code: record.code } : {}),\n\t\t...(typeof record.message === \"string\" ? { message: record.message } : {}),\n\t};\n}\n\n/** Default control-plane origin, overridable with `ADAPTORCH_API_URL`. */\nexport const ADAPTORCH_DEFAULT_API_URL = \"https://api.adaptorch.com\";\n\n/**\n * Build a client from the environment: `ADAPTORCH_API_KEY` and an optional\n * `ADAPTORCH_API_URL`. Returns `undefined` when no key is configured, so a\n * caller can treat AdaptOrch as an opt-in the operator enables rather than a\n * dependency that must be present.\n */\nexport function createAdaptOrchApiClientFromEnv(\n\tfetchImpl: AdaptOrchFetch,\n\tenv: Readonly<Record<string, string | undefined>> = process.env,\n): AdaptOrchApiClient | undefined {\n\tconst apiKey = env.ADAPTORCH_API_KEY?.trim();\n\tif (!apiKey) return undefined;\n\treturn new AdaptOrchApiClient({\n\t\tbaseUrl: env.ADAPTORCH_API_URL?.trim() || ADAPTORCH_DEFAULT_API_URL,\n\t\tapiKey,\n\t\tfetch: fetchImpl,\n\t});\n}\n\n/** Typed client for the AdaptOrch User API v1. */\nexport class AdaptOrchApiClient {\n\tprivate readonly baseUrl: string;\n\tprivate readonly apiKey: string;\n\tprivate readonly fetch: AdaptOrchFetch;\n\n\tconstructor(config: AdaptOrchApiConfig) {\n\t\tassertSafeApiUrl(config.baseUrl);\n\t\tresolveAuthHeaders(config.apiKey);\n\t\tthis.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n\t\tthis.apiKey = config.apiKey;\n\t\tthis.fetch = config.fetch;\n\t}\n\n\tprivate async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n\t\tconst init: AdaptOrchRequestInit = {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t...resolveAuthHeaders(this.apiKey),\n\t\t\t\t...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n\t\t\t},\n\t\t\t...(body === undefined ? {} : { body: JSON.stringify(body) }),\n\t\t};\n\n\t\tlet response: AdaptOrchHttpResponse;\n\t\ttry {\n\t\t\tresponse = await this.fetch(`${this.baseUrl}${path}`, init);\n\t\t} catch (error) {\n\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(`AdaptOrch request failed: ${redact(detail, this.apiKey)}`);\n\t\t}\n\n\t\tlet payload: unknown;\n\t\ttry {\n\t\t\tpayload = await response.json();\n\t\t} catch {\n\t\t\t// A body that is absent or not JSON is not itself a failure: the status\n\t\t\t// still decides, and an error response keeps its generic message.\n\t\t\tpayload = undefined;\n\t\t}\n\t\tif (response.status < 200 || response.status >= 300) {\n\t\t\tconst { code, message } = readErrorFields(payload);\n\t\t\tthrow new AdaptOrchApiError(\n\t\t\t\tresponse.status,\n\t\t\t\tcode,\n\t\t\t\tredact(message ?? `AdaptOrch request failed with status ${response.status}`, this.apiKey),\n\t\t\t);\n\t\t}\n\t\treturn payload as T;\n\t}\n\n\t/** `GET /v1/capabilities` — API version and enabled features. */\n\tcapabilities(): Promise<CapabilitySet> {\n\t\treturn this.request<CapabilitySet>(\"GET\", \"/v1/capabilities\");\n\t}\n\n\t/** `GET /v1/whoami` — the calling principal, for verifying a key works. */\n\twhoami(): Promise<Principal> {\n\t\treturn this.request<Principal>(\"GET\", \"/v1/whoami\");\n\t}\n\n\t/** `POST /v1/runs` — submit work. The contract bounds `subtasks` to 1..50. */\n\tsubmitRun(submission: RunSubmission): Promise<Run> {\n\t\treturn this.request<Run>(\"POST\", \"/v1/runs\", submission);\n\t}\n\n\t/** `GET /v1/runs` — list runs, filtered by the documented parameters only. */\n\tlistRuns(query: ListRunsQuery = {}): Promise<RunListResponse> {\n\t\tconst params = new URLSearchParams();\n\t\tif (query.status !== undefined) params.set(\"status\", query.status);\n\t\tif (query.projectId !== undefined) params.set(\"project_id\", query.projectId);\n\t\tif (query.limit !== undefined) params.set(\"limit\", String(query.limit));\n\t\tif (query.cursor !== undefined) params.set(\"cursor\", query.cursor);\n\t\tconst suffix = params.size === 0 ? \"\" : `?${params.toString()}`;\n\t\treturn this.request<RunListResponse>(\"GET\", `/v1/runs${suffix}`);\n\t}\n\n\t/** `GET /v1/runs/{run_id}` — one run's current state. */\n\tgetRun(runId: string): Promise<Run> {\n\t\treturn this.request<Run>(\"GET\", `/v1/runs/${encodeURIComponent(runId)}`);\n\t}\n\n\t/** `PUT /v1/runs/{run_id}/cancel` — request cancellation. */\n\tcancelRun(runId: string, reason?: string): Promise<Run> {\n\t\treturn this.request<Run>(\n\t\t\t\"PUT\",\n\t\t\t`/v1/runs/${encodeURIComponent(runId)}/cancel`,\n\t\t\treason === undefined ? {} : { reason },\n\t\t);\n\t}\n\n\t/** `GET /v1/runs/{run_id}/evidence` — the graded checks for a run. */\n\tgetEvidence(runId: string): Promise<EvidenceReport> {\n\t\treturn this.request<EvidenceReport>(\"GET\", `/v1/runs/${encodeURIComponent(runId)}/evidence`);\n\t}\n\n\t/** `GET /v1/runs/{run_id}/artifacts` — artifacts a run produced. */\n\tlistArtifacts(runId: string): Promise<ArtifactListResponse> {\n\t\treturn this.request<ArtifactListResponse>(\"GET\", `/v1/runs/${encodeURIComponent(runId)}/artifacts`);\n\t}\n}\n"]}
|
|
@@ -6,14 +6,36 @@
|
|
|
6
6
|
* their own transport (e.g. an adapter around an MCP SDK client) until one
|
|
7
7
|
* ships in this package.
|
|
8
8
|
*
|
|
9
|
-
* Tool surface, names, and read/write classification are
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Tool surface, names, and read/write classification are derived from the
|
|
10
|
+
* server's own inventory: `diagnostics.py::EXPECTED_CORE_TOOLS` and
|
|
11
|
+
* `_FULL_ONLY_TOOLS`, cross-checked against `hardening.py::REMOTE_TOOL_NAMES`
|
|
12
|
+
* and the `output_schema.py` projector table. The surface is tiered: nine core
|
|
13
|
+
* tools every deployment exposes, plus two that exist only in a full or local
|
|
14
|
+
* deployment. No "benchmark" or "verification" tools exist in it.
|
|
15
15
|
*/
|
|
16
|
-
import type
|
|
16
|
+
import { type TopologyClassification } from "./types.ts";
|
|
17
|
+
/**
|
|
18
|
+
* Tools every AdaptOrch deployment exposes, including a remote tenant.
|
|
19
|
+
* Mirrors `diagnostics.py::EXPECTED_CORE_TOOLS` in server order.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ADAPTORCH_REMOTE_TOOLS: readonly ["adaptorch_run", "adaptorch_get_run", "adaptorch_get_artifacts", "adaptorch_list_runs", "adaptorch_cancel_run", "adaptorch_server_metrics", "adaptorch_capabilities", "adaptorch_usage", "adaptorch_plan_catalog"];
|
|
22
|
+
/**
|
|
23
|
+
* Tools a remote tenant cannot reach. Trace and topology reads need a full or
|
|
24
|
+
* local deployment, so a caller must not advertise them unconditionally.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ADAPTORCH_FULL_ONLY_TOOLS: readonly ["adaptorch_get_traces", "adaptorch_route_topology"];
|
|
27
|
+
/** The complete tool surface, core tier first. */
|
|
28
|
+
export declare const ADAPTORCH_TOOLS: readonly ["adaptorch_run", "adaptorch_get_run", "adaptorch_get_artifacts", "adaptorch_list_runs", "adaptorch_cancel_run", "adaptorch_server_metrics", "adaptorch_capabilities", "adaptorch_usage", "adaptorch_plan_catalog", "adaptorch_get_traces", "adaptorch_route_topology"];
|
|
29
|
+
/** One tenant's own usage window, as projected by `output_schema.py::_project_usage`. */
|
|
30
|
+
export interface AdaptOrchUsage {
|
|
31
|
+
readonly used: number;
|
|
32
|
+
readonly limit: number;
|
|
33
|
+
readonly tenant_id?: string;
|
|
34
|
+
readonly plan_level?: string;
|
|
35
|
+
readonly period?: string;
|
|
36
|
+
readonly remaining?: number;
|
|
37
|
+
readonly usage_percentage?: number;
|
|
38
|
+
}
|
|
17
39
|
/**
|
|
18
40
|
* Abstract transport for invoking AdaptOrch MCP tools by name.
|
|
19
41
|
*
|
|
@@ -109,10 +131,9 @@ export interface AdaptOrchTraceSpan {
|
|
|
109
131
|
/**
|
|
110
132
|
* Result of `adaptorch_route_topology`.
|
|
111
133
|
*
|
|
112
|
-
* `classification` is the
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* response for callers that need more than the classification.
|
|
134
|
+
* `classification` is the validated value from the current response's
|
|
135
|
+
* `topology` field; `raw` retains the transport response for callers that
|
|
136
|
+
* need the accompanying reason, stages, or features.
|
|
116
137
|
*/
|
|
117
138
|
export interface AdaptOrchRouteTopologyResult {
|
|
118
139
|
classification: TopologyClassification;
|
|
@@ -159,11 +180,7 @@ export declare class AdaptOrchClient {
|
|
|
159
180
|
* `run_id`.
|
|
160
181
|
*/
|
|
161
182
|
getTraces(runId: string): Promise<AdaptOrchTraceSpan[]>;
|
|
162
|
-
/**
|
|
163
|
-
* `adaptorch_route_topology` (read/local). Route a DAG locally through
|
|
164
|
-
* AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without
|
|
165
|
-
* submitting a run.
|
|
166
|
-
*/
|
|
183
|
+
/** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */
|
|
167
184
|
routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult>;
|
|
168
185
|
/**
|
|
169
186
|
* `adaptorch_server_metrics` (read/local). Read redacted MCP server
|
|
@@ -176,8 +193,14 @@ export declare class AdaptOrchClient {
|
|
|
176
193
|
*/
|
|
177
194
|
capabilities(): Promise<Record<string, unknown>>;
|
|
178
195
|
/**
|
|
179
|
-
* `
|
|
180
|
-
*
|
|
196
|
+
* `adaptorch_usage` (read). Read this tenant's own usage window. The
|
|
197
|
+
* control plane scopes the response by key, so a caller never sees another
|
|
198
|
+
* tenant's counters.
|
|
199
|
+
*/
|
|
200
|
+
usage(): Promise<AdaptOrchUsage>;
|
|
201
|
+
/**
|
|
202
|
+
* `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog.
|
|
203
|
+
* Tier names and prices come from the server, never from this client.
|
|
181
204
|
*/
|
|
182
205
|
planCatalog(): Promise<Record<string, unknown>>;
|
|
183
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptorch-client.d.ts","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,O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,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAKnE;IAED;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAExD;IAED;;OAEG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAE5E;IAED;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAE7D;IAED;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAE9D;IAED;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAE5D;IAED;;;;OAIG;IACG,aAAa,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAShF;IAED;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEtD;IAED;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAErD;IAED;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEpD;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are grounded in\n * `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,\n * which cross-checks the real AdaptOrch MCP server against\n * `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and\n * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;\n * no \"benchmark\" or \"verification\" tools exist in the shipped surface.\n */\n\nimport type { TopologyClassification } from \"./types.ts\";\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the topology router's decision\n * (singleton/pipeline/DAG/ensemble, see doc section \"Routing (pre-run\n * planning, local/no dispatch)\"); `raw` retains the untyped transport\n * response for callers that need more than the classification.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/**\n\t * `adaptorch_route_topology` (read/local). Route a DAG locally through\n\t * AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without\n\t * submitting a run.\n\t */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\t// The transport response is not schema-validated; classification is\n\t\t// extracted best-effort since no official schema is documented.\n\t\tconst classification = (raw as { classification?: TopologyClassification } | undefined)?.classification;\n\t\treturn {\n\t\t\tclassification: classification as TopologyClassification,\n\t\t\traw,\n\t\t};\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog\n\t * (Starter $0 / Pro $39 / Team $149).\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"adaptorch-client.d.ts","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA4B,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAMnF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,8NAUzB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,yBAAyB,+DAAgE,CAAC;AAEvG,kDAAkD;AAClD,eAAO,MAAM,eAAe,kRAAqE,CAAC;AAElG,yFAAyF;AACzF,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAA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IACG,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC,CAErC;IAED;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEpD;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are derived from the\n * server's own inventory: `diagnostics.py::EXPECTED_CORE_TOOLS` and\n * `_FULL_ONLY_TOOLS`, cross-checked against `hardening.py::REMOTE_TOOL_NAMES`\n * and the `output_schema.py` projector table. The surface is tiered: nine core\n * tools every deployment exposes, plus two that exist only in a full or local\n * deployment. No \"benchmark\" or \"verification\" tools exist in it.\n */\n\nimport { isTopologyClassification, type TopologyClassification } from \"./types.ts\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Tools every AdaptOrch deployment exposes, including a remote tenant.\n * Mirrors `diagnostics.py::EXPECTED_CORE_TOOLS` in server order.\n */\nexport const ADAPTORCH_REMOTE_TOOLS = [\n\t\"adaptorch_run\",\n\t\"adaptorch_get_run\",\n\t\"adaptorch_get_artifacts\",\n\t\"adaptorch_list_runs\",\n\t\"adaptorch_cancel_run\",\n\t\"adaptorch_server_metrics\",\n\t\"adaptorch_capabilities\",\n\t\"adaptorch_usage\",\n\t\"adaptorch_plan_catalog\",\n] as const;\n\n/**\n * Tools a remote tenant cannot reach. Trace and topology reads need a full or\n * local deployment, so a caller must not advertise them unconditionally.\n */\nexport const ADAPTORCH_FULL_ONLY_TOOLS = [\"adaptorch_get_traces\", \"adaptorch_route_topology\"] as const;\n\n/** The complete tool surface, core tier first. */\nexport const ADAPTORCH_TOOLS = [...ADAPTORCH_REMOTE_TOOLS, ...ADAPTORCH_FULL_ONLY_TOOLS] as const;\n\n/** One tenant's own usage window, as projected by `output_schema.py::_project_usage`. */\nexport interface AdaptOrchUsage {\n\treadonly used: number;\n\treadonly limit: number;\n\treadonly tenant_id?: string;\n\treadonly plan_level?: string;\n\treadonly period?: string;\n\treadonly remaining?: number;\n\treadonly usage_percentage?: number;\n}\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the validated value from the current response's\n * `topology` field; `raw` retains the transport response for callers that\n * need the accompanying reason, stages, or features.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\tconst topology = isRecord(raw) ? raw.topology : undefined;\n\t\tif (!isTopologyClassification(topology)) {\n\t\t\tthrow new Error(\"AdaptOrch route response has invalid topology\");\n\t\t}\n\t\treturn { classification: topology, raw };\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_usage` (read). Read this tenant's own usage window. The\n\t * control plane scopes the response by key, so a caller never sees another\n\t * tenant's counters.\n\t */\n\tasync usage(): Promise<AdaptOrchUsage> {\n\t\treturn (await this.transport.callTool(\"adaptorch_usage\", {})) as AdaptOrchUsage;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog.\n\t * Tier names and prices come from the server, never from this client.\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
|
package/dist/adaptorch-client.js
CHANGED
|
@@ -6,13 +6,39 @@
|
|
|
6
6
|
* their own transport (e.g. an adapter around an MCP SDK client) until one
|
|
7
7
|
* ships in this package.
|
|
8
8
|
*
|
|
9
|
-
* Tool surface, names, and read/write classification are
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Tool surface, names, and read/write classification are derived from the
|
|
10
|
+
* server's own inventory: `diagnostics.py::EXPECTED_CORE_TOOLS` and
|
|
11
|
+
* `_FULL_ONLY_TOOLS`, cross-checked against `hardening.py::REMOTE_TOOL_NAMES`
|
|
12
|
+
* and the `output_schema.py` projector table. The surface is tiered: nine core
|
|
13
|
+
* tools every deployment exposes, plus two that exist only in a full or local
|
|
14
|
+
* deployment. No "benchmark" or "verification" tools exist in it.
|
|
15
15
|
*/
|
|
16
|
+
import { isTopologyClassification } from "./types.js";
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Tools every AdaptOrch deployment exposes, including a remote tenant.
|
|
22
|
+
* Mirrors `diagnostics.py::EXPECTED_CORE_TOOLS` in server order.
|
|
23
|
+
*/
|
|
24
|
+
export const ADAPTORCH_REMOTE_TOOLS = [
|
|
25
|
+
"adaptorch_run",
|
|
26
|
+
"adaptorch_get_run",
|
|
27
|
+
"adaptorch_get_artifacts",
|
|
28
|
+
"adaptorch_list_runs",
|
|
29
|
+
"adaptorch_cancel_run",
|
|
30
|
+
"adaptorch_server_metrics",
|
|
31
|
+
"adaptorch_capabilities",
|
|
32
|
+
"adaptorch_usage",
|
|
33
|
+
"adaptorch_plan_catalog",
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Tools a remote tenant cannot reach. Trace and topology reads need a full or
|
|
37
|
+
* local deployment, so a caller must not advertise them unconditionally.
|
|
38
|
+
*/
|
|
39
|
+
export const ADAPTORCH_FULL_ONLY_TOOLS = ["adaptorch_get_traces", "adaptorch_route_topology"];
|
|
40
|
+
/** The complete tool surface, core tier first. */
|
|
41
|
+
export const ADAPTORCH_TOOLS = [...ADAPTORCH_REMOTE_TOOLS, ...ADAPTORCH_FULL_ONLY_TOOLS];
|
|
16
42
|
/**
|
|
17
43
|
* Typed wrapper around the 10 real AdaptOrch MCP tools.
|
|
18
44
|
*
|
|
@@ -69,20 +95,14 @@ export class AdaptOrchClient {
|
|
|
69
95
|
async getTraces(runId) {
|
|
70
96
|
return (await this.transport.callTool("adaptorch_get_traces", { run_id: runId }));
|
|
71
97
|
}
|
|
72
|
-
/**
|
|
73
|
-
* `adaptorch_route_topology` (read/local). Route a DAG locally through
|
|
74
|
-
* AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without
|
|
75
|
-
* submitting a run.
|
|
76
|
-
*/
|
|
98
|
+
/** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */
|
|
77
99
|
async routeTopology(payloadShape) {
|
|
78
100
|
const raw = await this.transport.callTool("adaptorch_route_topology", { payload_shape: payloadShape });
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
raw,
|
|
85
|
-
};
|
|
101
|
+
const topology = isRecord(raw) ? raw.topology : undefined;
|
|
102
|
+
if (!isTopologyClassification(topology)) {
|
|
103
|
+
throw new Error("AdaptOrch route response has invalid topology");
|
|
104
|
+
}
|
|
105
|
+
return { classification: topology, raw };
|
|
86
106
|
}
|
|
87
107
|
/**
|
|
88
108
|
* `adaptorch_server_metrics` (read/local). Read redacted MCP server
|
|
@@ -99,8 +119,16 @@ export class AdaptOrchClient {
|
|
|
99
119
|
return (await this.transport.callTool("adaptorch_capabilities", {}));
|
|
100
120
|
}
|
|
101
121
|
/**
|
|
102
|
-
* `
|
|
103
|
-
*
|
|
122
|
+
* `adaptorch_usage` (read). Read this tenant's own usage window. The
|
|
123
|
+
* control plane scopes the response by key, so a caller never sees another
|
|
124
|
+
* tenant's counters.
|
|
125
|
+
*/
|
|
126
|
+
async usage() {
|
|
127
|
+
return (await this.transport.callTool("adaptorch_usage", {}));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog.
|
|
131
|
+
* Tier names and prices come from the server, never from this client.
|
|
104
132
|
*/
|
|
105
133
|
async planCatalog() {
|
|
106
134
|
return (await this.transport.callTool("adaptorch_plan_catalog", {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptorch-client.js","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqHH;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACV,SAAS,CAAqB;IAE/C,YAAY,SAA6B,EAAE;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAAA,CAC3B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AC,YAAqB,EAAyC;QACjF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC;QACvG,oEAAoE;QACpE,gEAAgE;QAChE,MAAM,cAAc,GAAI,GAA+D,EAAE,cAAc,CAAC;QACxG,OAAO;YACN,cAAc,EAAE,cAAwC;YACxD,GAAG;SACH,CAAC;IAAA,CACF;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,GAAqC;QACvD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAClG;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,GAAqC;QACtD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,GAAqC;QACrD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are grounded in\n * `.omk/runs/lazycodex-adaptorch-loop-plan-20260701/lane2-adaptorch-tool-surface.md`,\n * which cross-checks the real AdaptOrch MCP server against\n * `docs/tools.md`, `README.md`, `mcp_server.py` dispatch, and\n * `diagnostics.py::EXPECTED_CORE_TOOLS`. There are exactly 10 real tools;\n * no \"benchmark\" or \"verification\" tools exist in the shipped surface.\n */\n\nimport type { TopologyClassification } from \"./types.ts\";\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the topology router's decision\n * (singleton/pipeline/DAG/ensemble, see doc section \"Routing (pre-run\n * planning, local/no dispatch)\"); `raw` retains the untyped transport\n * response for callers that need more than the classification.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/**\n\t * `adaptorch_route_topology` (read/local). Route a DAG locally through\n\t * AdaptOrch's topology router (singleton/pipeline/DAG/ensemble) without\n\t * submitting a run.\n\t */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\t// The transport response is not schema-validated; classification is\n\t\t// extracted best-effort since no official schema is documented.\n\t\tconst classification = (raw as { classification?: TopologyClassification } | undefined)?.classification;\n\t\treturn {\n\t\t\tclassification: classification as TopologyClassification,\n\t\t\traw,\n\t\t};\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog\n\t * (Starter $0 / Pro $39 / Team $149).\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"adaptorch-client.js","sourceRoot":"","sources":["../src/adaptorch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,wBAAwB,EAA+B,MAAM,YAAY,CAAC;AAEnF,SAAS,QAAQ,CAAC,KAAc,EAAoC;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAA,CAC5E;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,eAAe;IACf,mBAAmB;IACnB,yBAAyB;IACzB,qBAAqB;IACrB,sBAAsB;IACtB,0BAA0B;IAC1B,wBAAwB;IACxB,iBAAiB;IACjB,wBAAwB;CACf,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,EAAE,0BAA0B,CAAU,CAAC;AAEvG,kDAAkD;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,sBAAsB,EAAE,GAAG,yBAAyB,CAAU,CAAC;AA6HlG;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACV,SAAS,CAAqB;IAE/C,YAAY,SAA6B,EAAE;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAAA,CAC3B;IAED;;;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B,EAAyC;QACjF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC;QACvG,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAAA,CACzC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,GAAqC;QACvD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAClG;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,GAAqC;QACtD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,GAA4B;QACtC,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAmB,CAAC;IAAA,CAChF;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,GAAqC;QACrD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAA4B,CAAC;IAAA,CAChG;CACD","sourcesContent":["/**\n * AdaptOrch MCP client wrapper.\n *\n * Design-stage / experimental: this module has no production\n * `AdaptOrchTransport` implementation wired in yet. Callers must supply\n * their own transport (e.g. an adapter around an MCP SDK client) until one\n * ships in this package.\n *\n * Tool surface, names, and read/write classification are derived from the\n * server's own inventory: `diagnostics.py::EXPECTED_CORE_TOOLS` and\n * `_FULL_ONLY_TOOLS`, cross-checked against `hardening.py::REMOTE_TOOL_NAMES`\n * and the `output_schema.py` projector table. The surface is tiered: nine core\n * tools every deployment exposes, plus two that exist only in a full or local\n * deployment. No \"benchmark\" or \"verification\" tools exist in it.\n */\n\nimport { isTopologyClassification, type TopologyClassification } from \"./types.ts\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Tools every AdaptOrch deployment exposes, including a remote tenant.\n * Mirrors `diagnostics.py::EXPECTED_CORE_TOOLS` in server order.\n */\nexport const ADAPTORCH_REMOTE_TOOLS = [\n\t\"adaptorch_run\",\n\t\"adaptorch_get_run\",\n\t\"adaptorch_get_artifacts\",\n\t\"adaptorch_list_runs\",\n\t\"adaptorch_cancel_run\",\n\t\"adaptorch_server_metrics\",\n\t\"adaptorch_capabilities\",\n\t\"adaptorch_usage\",\n\t\"adaptorch_plan_catalog\",\n] as const;\n\n/**\n * Tools a remote tenant cannot reach. Trace and topology reads need a full or\n * local deployment, so a caller must not advertise them unconditionally.\n */\nexport const ADAPTORCH_FULL_ONLY_TOOLS = [\"adaptorch_get_traces\", \"adaptorch_route_topology\"] as const;\n\n/** The complete tool surface, core tier first. */\nexport const ADAPTORCH_TOOLS = [...ADAPTORCH_REMOTE_TOOLS, ...ADAPTORCH_FULL_ONLY_TOOLS] as const;\n\n/** One tenant's own usage window, as projected by `output_schema.py::_project_usage`. */\nexport interface AdaptOrchUsage {\n\treadonly used: number;\n\treadonly limit: number;\n\treadonly tenant_id?: string;\n\treadonly plan_level?: string;\n\treadonly period?: string;\n\treadonly remaining?: number;\n\treadonly usage_percentage?: number;\n}\n\n/**\n * Abstract transport for invoking AdaptOrch MCP tools by name.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\". No\n * concrete implementation ships with this package yet; a caller must\n * provide one (e.g. wrapping an MCP SDK client's `callTool`).\n */\nexport interface AdaptOrchTransport {\n\tcallTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n\n/**\n * Payload accepted by `adaptorch_run`.\n *\n * See doc section \"Run / lifecycle (submit, inspect, list, cancel)\":\n * `adaptorch_run` submits a task payload (prompt/context/raw payload,\n * connector, synthesis mode, budget policy) to the control-plane, and can\n * optionally block until the run reaches a terminal status.\n */\nexport interface AdaptOrchRunPayload {\n\ttaskPayload: unknown;\n\tconnector?: string;\n\tsynthesisMode?: string;\n\tbudgetPolicy?: unknown;\n\twaitForTerminal?: boolean;\n\ttimeoutSeconds?: number;\n\tpollIntervalSeconds?: number;\n}\n\n/**\n * Result of `adaptorch_run`.\n *\n * Shape is inferred from the doc's description of the tool's purpose, not\n * guaranteed by an official schema.\n */\nexport interface AdaptOrchRunResult {\n\trun_id: string;\n\tstatus?: string;\n}\n\n/**\n * Result of `adaptorch_get_run`.\n *\n * Shape is inferred from the doc's description (\"fetch a run summary by\n * run_id\"), not guaranteed by an official schema; extra fields are\n * expected to vary by connector/synthesis mode.\n */\nexport interface AdaptOrchRunSummary {\n\trun_id: string;\n\tstatus: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_list_runs`.\n *\n * Shape is inferred, not guaranteed by an official schema.\n */\nexport interface AdaptOrchRunListEntry {\n\trun_id: string;\n\tstatus: string;\n}\n\n/**\n * Result of `adaptorch_cancel_run`.\n *\n * Shape is inferred from the doc's description (\"request cancellation of\n * an in-flight run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchCancelResult {\n\trun_id: string;\n\tcancelled: boolean;\n}\n\n/**\n * Entry in the result of `adaptorch_get_artifacts`.\n *\n * Shape is inferred from the doc's description (\"fetch artifact metadata\n * for a run\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchArtifact {\n\tpath: string;\n\tsize_bytes?: number;\n\tcreated_at?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Entry in the result of `adaptorch_get_traces`.\n *\n * Shape is inferred from the doc's description (\"fetch execution traces\n * for a run by run_id\"), not guaranteed by an official schema.\n */\nexport interface AdaptOrchTraceSpan {\n\tspan_id?: string;\n\tkind?: string;\n\tseverity?: string;\n\t[key: string]: unknown;\n}\n\n/**\n * Result of `adaptorch_route_topology`.\n *\n * `classification` is the validated value from the current response's\n * `topology` field; `raw` retains the transport response for callers that\n * need the accompanying reason, stages, or features.\n */\nexport interface AdaptOrchRouteTopologyResult {\n\tclassification: TopologyClassification;\n\traw: unknown;\n}\n\n/**\n * Typed wrapper around the 10 real AdaptOrch MCP tools.\n *\n * See doc section \"The real, current 10-tool MCP surface (grouped)\" for\n * the full tool list, purposes, and read/write classification. This\n * class only translates method calls into `transport.callTool` calls\n * with the exact tool names the doc lists; it does not implement a\n * transport itself.\n */\nexport class AdaptOrchClient {\n\tprivate readonly transport: AdaptOrchTransport;\n\n\tconstructor(transport: AdaptOrchTransport) {\n\t\tthis.transport = transport;\n\t}\n\n\t/**\n\t * `adaptorch_run` (write). Submit a task payload to the control-plane,\n\t * optionally blocking until the run reaches a terminal status.\n\t */\n\tasync run(payload: AdaptOrchRunPayload): Promise<AdaptOrchRunResult> {\n\t\t// The transport result shape is not schema-validated here; callers\n\t\t// relying on strict correctness should validate at the transport\n\t\t// boundary.\n\t\treturn (await this.transport.callTool(\"adaptorch_run\", { ...payload })) as AdaptOrchRunResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_run` (read). Fetch a run summary by `run_id`.\n\t */\n\tasync getRun(runId: string): Promise<AdaptOrchRunSummary> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_run\", { run_id: runId })) as AdaptOrchRunSummary;\n\t}\n\n\t/**\n\t * `adaptorch_list_runs` (read). List recent control-plane runs.\n\t */\n\tasync listRuns(params?: { limit?: number }): Promise<AdaptOrchRunListEntry[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_list_runs\", { ...params })) as AdaptOrchRunListEntry[];\n\t}\n\n\t/**\n\t * `adaptorch_cancel_run` (write). Request cancellation of an in-flight\n\t * run by `run_id`.\n\t */\n\tasync cancelRun(runId: string): Promise<AdaptOrchCancelResult> {\n\t\treturn (await this.transport.callTool(\"adaptorch_cancel_run\", { run_id: runId })) as AdaptOrchCancelResult;\n\t}\n\n\t/**\n\t * `adaptorch_get_artifacts` (read). Fetch artifact metadata for a run.\n\t */\n\tasync getArtifacts(runId: string): Promise<AdaptOrchArtifact[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_artifacts\", { run_id: runId })) as AdaptOrchArtifact[];\n\t}\n\n\t/**\n\t * `adaptorch_get_traces` (read). Fetch execution traces for a run by\n\t * `run_id`.\n\t */\n\tasync getTraces(runId: string): Promise<AdaptOrchTraceSpan[]> {\n\t\treturn (await this.transport.callTool(\"adaptorch_get_traces\", { run_id: runId })) as AdaptOrchTraceSpan[];\n\t}\n\n\t/** Route a DAG locally and fail closed if the MCP response drifts from the current topology contract. */\n\tasync routeTopology(payloadShape: unknown): Promise<AdaptOrchRouteTopologyResult> {\n\t\tconst raw = await this.transport.callTool(\"adaptorch_route_topology\", { payload_shape: payloadShape });\n\t\tconst topology = isRecord(raw) ? raw.topology : undefined;\n\t\tif (!isTopologyClassification(topology)) {\n\t\t\tthrow new Error(\"AdaptOrch route response has invalid topology\");\n\t\t}\n\t\treturn { classification: topology, raw };\n\t}\n\n\t/**\n\t * `adaptorch_server_metrics` (read/local). Read redacted MCP server\n\t * metrics (tool-call counters, latency percentiles).\n\t */\n\tasync serverMetrics(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_server_metrics\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_capabilities` (read/local). Read supported synthesis\n\t * modes, connectors, and server features.\n\t */\n\tasync capabilities(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_capabilities\", {})) as Record<string, unknown>;\n\t}\n\n\t/**\n\t * `adaptorch_usage` (read). Read this tenant's own usage window. The\n\t * control plane scopes the response by key, so a caller never sees another\n\t * tenant's counters.\n\t */\n\tasync usage(): Promise<AdaptOrchUsage> {\n\t\treturn (await this.transport.callTool(\"adaptorch_usage\", {})) as AdaptOrchUsage;\n\t}\n\n\t/**\n\t * `adaptorch_plan_catalog` (read/local). Read the hosted plan catalog.\n\t * Tier names and prices come from the server, never from this client.\n\t */\n\tasync planCatalog(): Promise<Record<string, unknown>> {\n\t\treturn (await this.transport.callTool(\"adaptorch_plan_catalog\", {})) as Record<string, unknown>;\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* for the design this package implements. Ships as a runtime dependency of the
|
|
6
6
|
* `open-multi-agent-kit` CLI.
|
|
7
7
|
*/
|
|
8
|
+
export type { AdaptOrchApiConfig, AdaptOrchFetch, AdaptOrchHttpResponse, AdaptOrchRequestInit, Artifact, ArtifactListResponse, CapabilitySet, EvidenceCheck, EvidenceReport, ListRunsQuery, Principal, Run, RunListResponse, RunStatus, RunSubmission, } from "./adaptorch-api.ts";
|
|
9
|
+
export { ADAPTORCH_DEFAULT_API_URL, AdaptOrchApiClient, AdaptOrchApiError, assertSafeApiUrl, createAdaptOrchApiClientFromEnv, resolveAuthHeaders, } from "./adaptorch-api.ts";
|
|
8
10
|
export type { AdaptOrchTransport } from "./adaptorch-client.ts";
|
|
9
|
-
export { AdaptOrchClient } from "./adaptorch-client.ts";
|
|
11
|
+
export { ADAPTORCH_FULL_ONLY_TOOLS, ADAPTORCH_REMOTE_TOOLS, ADAPTORCH_TOOLS, AdaptOrchClient, } from "./adaptorch-client.ts";
|
|
10
12
|
export type { AdjudicationRequest, AdjudicationResult, PerRunVerdict } from "./adjudicator.ts";
|
|
11
13
|
export { adjudicate } from "./adjudicator.ts";
|
|
12
14
|
export type { AdjudicationReasonCode, CheckResult, VerdictState, VerifierRegistryEntry, } from "./adjudicator-registry.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACX,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,SAAS,EACT,GAAG,EACH,eAAe,EACf,SAAS,EACT,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACN,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,EACf,eAAe,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACX,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,qBAAqB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EACX,aAAa,EACb,WAAW,EACX,WAAW,EAC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BAAoB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,YAAY,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EACX,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5G,YAAY,EACX,eAAe,EACf,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Public entry point for `omk-adaptorch-wpl` (stable since 0.91.0).\n *\n * See README.md and `.omk/runs/adaptorch-native-loop-algorithm-20260701/final-part{1,2,3}-*.md`\n * for the design this package implements. Ships as a runtime dependency of the\n * `open-multi-agent-kit` CLI.\n */\n\nexport type {\n\tAdaptOrchApiConfig,\n\tAdaptOrchFetch,\n\tAdaptOrchHttpResponse,\n\tAdaptOrchRequestInit,\n\tArtifact,\n\tArtifactListResponse,\n\tCapabilitySet,\n\tEvidenceCheck,\n\tEvidenceReport,\n\tListRunsQuery,\n\tPrincipal,\n\tRun,\n\tRunListResponse,\n\tRunStatus,\n\tRunSubmission,\n} from \"./adaptorch-api.ts\";\nexport {\n\tADAPTORCH_DEFAULT_API_URL,\n\tAdaptOrchApiClient,\n\tAdaptOrchApiError,\n\tassertSafeApiUrl,\n\tcreateAdaptOrchApiClientFromEnv,\n\tresolveAuthHeaders,\n} from \"./adaptorch-api.ts\";\nexport type { AdaptOrchTransport } from \"./adaptorch-client.ts\";\nexport {\n\tADAPTORCH_FULL_ONLY_TOOLS,\n\tADAPTORCH_REMOTE_TOOLS,\n\tADAPTORCH_TOOLS,\n\tAdaptOrchClient,\n} from \"./adaptorch-client.ts\";\nexport type { AdjudicationRequest, AdjudicationResult, PerRunVerdict } from \"./adjudicator.ts\";\nexport { adjudicate } from \"./adjudicator.ts\";\nexport type {\n\tAdjudicationReasonCode,\n\tCheckResult,\n\tVerdictState,\n\tVerifierRegistryEntry,\n} from \"./adjudicator-registry.ts\";\nexport {\n\tADJUDICATION_REASON_CODES,\n\tcreateVerifierRegistry,\n\tDEFAULT_VERIFIER,\n\treduceReasonCodes,\n} from \"./adjudicator-registry.ts\";\nexport type { MapToB2CInput, MapToB2COutput } from \"./b2c-mapper.ts\";\nexport { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from \"./b2c-mapper.ts\";\nexport type {\n\tUserRiskLevel,\n\tUserVerdict,\n\tVerdictCard,\n\tVerdictLimits,\n\tVerdictNextAction,\n\tVerificationReceipt,\n} from \"./b2c-verdict.ts\";\nexport { B2C_VERDICT_SCHEMA_VERSION } from \"./b2c-verdict.ts\";\nexport type {\n\tDeepWallPhase,\n\tDeepWallResult,\n\tDeepWallRunnerEvidence,\n\tDeepWallRunnerFn,\n\tDeepWallRunnerResult,\n\tDeepWallStatus,\n\tDeepWallStubResult,\n\tRunDeepWallStubParams,\n} from \"./deep-wall.ts\";\nexport {\n\tDEEP_RUNNER_ERROR,\n\tDEEP_RUNNER_EVIDENCE_MISSING,\n\tDEEP_RUNNER_NOT_WIRED,\n\tDEEP_WALL_UNAVAILABLE,\n\tisDeepRunnerCompletionAllowed,\n\tresolveDeepWallPhaseFromEnv,\n\trunDeepWall,\n\trunDeepWallStub,\n} from \"./deep-wall.ts\";\nexport type {\n\tEvaluateCorrectnessWallParams,\n\tEvaluateCorrectnessWallResult,\n} from \"./evaluate-correctness-wall.ts\";\nexport { evaluateCorrectnessWall } from \"./evaluate-correctness-wall.ts\";\nexport type { InMemoryAdaptOrchFixture } from \"./in-memory-adaptorch.ts\";\nexport { createInMemoryAdaptOrchClient } from \"./in-memory-adaptorch.ts\";\nexport type { AdaptOrchCallToolFn, OaTransportMode } from \"./live-adaptorch-transport.ts\";\nexport { createLiveAdaptOrchClient, parseOaTransportModeFromEnv } from \"./live-adaptorch-transport.ts\";\nexport type { NextActionKind, VerdictDisposition } from \"./loop.ts\";\nexport {\n\tdecideNextTransition,\n\thandleAdjudicationFailure,\n\tprojectVerdictToDisposition,\n\trunAdjudicationWithTimeout,\n} from \"./loop.ts\";\nexport type {\n\tCreateMcpIntrospectionTransportOptions,\n\tMcpIntrospectionMode,\n} from \"./mcp-introspection-transport.ts\";\nexport { createMcpIntrospectionClient } from \"./mcp-introspection-transport.ts\";\nexport type { PolicyFlag } from \"./policy-wall.ts\";\nexport {\n\tPOLICY_FLAG,\n\tparseDiffPaths,\n\tpathMatchesApprovedScope,\n\trunFastWall,\n\tscanDiffLinesForSecrets,\n} from \"./policy-wall.ts\";\nexport type { SignedWallReceipt, SignWallReceiptInput, VerifyWallReceiptInput } from \"./receipt-signature.ts\";\nexport { signWallReceipt, verifyWallReceipt } from \"./receipt-signature.ts\";\nexport type { BuildRegeneratePacketInput, RegeneratePacket } from \"./regenerate-packet.ts\";\nexport { buildRegeneratePacket } from \"./regenerate-packet.ts\";\nexport type { RepairBudgetState } from \"./repair-budget.ts\";\nexport { capRepairHints, parseRepairBudget, shouldOfferRepair } from \"./repair-budget.ts\";\nexport type { RepairHintInput } from \"./repair-loop.ts\";\nexport { deriveRepairHints } from \"./repair-loop.ts\";\nexport type {\n\tVerificationDigest,\n\tVerificationDigestInput,\n\tWallReceiptMeta,\n} from \"./signed-receipt.ts\";\nexport { buildVerificationDigest } from \"./signed-receipt.ts\";\nexport { applyTransition, canTransition, isTerminalState, requiresHumanApproval } from \"./state-machine.ts\";\nexport type {\n\tCardinalityMode,\n\tDispatchRecord,\n\tLoopConfig,\n\tLoopTerminationCondition,\n\tTopologyClassification,\n\tTransitionLogEntry,\n\tWorkPacket,\n\tWorkPacketState,\n} from \"./types.ts\";\nexport { ADJUDICATIONS_DIR, LOOP_STATE_FILE, PACKET_INDEX_FILE, PACKETS_DIR, RUN_MAP_FILE } from \"./types.ts\";\nexport { CORRECTNESS_WALL_VERSION } from \"./wall-meta.ts\";\n"]}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* for the design this package implements. Ships as a runtime dependency of the
|
|
6
6
|
* `open-multi-agent-kit` CLI.
|
|
7
7
|
*/
|
|
8
|
-
export {
|
|
8
|
+
export { ADAPTORCH_DEFAULT_API_URL, AdaptOrchApiClient, AdaptOrchApiError, assertSafeApiUrl, createAdaptOrchApiClientFromEnv, resolveAuthHeaders, } from "./adaptorch-api.js";
|
|
9
|
+
export { ADAPTORCH_FULL_ONLY_TOOLS, ADAPTORCH_REMOTE_TOOLS, ADAPTORCH_TOOLS, AdaptOrchClient, } from "./adaptorch-client.js";
|
|
9
10
|
export { adjudicate } from "./adjudicator.js";
|
|
10
11
|
export { ADJUDICATION_REASON_CODES, createVerifierRegistry, DEFAULT_VERIFIER, reduceReasonCodes, } from "./adjudicator-registry.js";
|
|
11
12
|
export { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from "./b2c-mapper.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmBH,OAAO,EACN,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,kBAAkB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,EACf,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAO9C,OAAO,EACN,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AASpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAW9D,OAAO,EACN,iBAAiB,EACjB,4BAA4B,EAC5B,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,WAAW,EACX,eAAe,GACf,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEvG,OAAO,EACN,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,EAC3B,0BAA0B,GAC1B,MAAM,WAAW,CAAC;AAKnB,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAEhF,OAAO,EACN,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,WAAW,EACX,uBAAuB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAW5G,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Public entry point for `omk-adaptorch-wpl` (stable since 0.91.0).\n *\n * See README.md and `.omk/runs/adaptorch-native-loop-algorithm-20260701/final-part{1,2,3}-*.md`\n * for the design this package implements. Ships as a runtime dependency of the\n * `open-multi-agent-kit` CLI.\n */\n\nexport type {\n\tAdaptOrchApiConfig,\n\tAdaptOrchFetch,\n\tAdaptOrchHttpResponse,\n\tAdaptOrchRequestInit,\n\tArtifact,\n\tArtifactListResponse,\n\tCapabilitySet,\n\tEvidenceCheck,\n\tEvidenceReport,\n\tListRunsQuery,\n\tPrincipal,\n\tRun,\n\tRunListResponse,\n\tRunStatus,\n\tRunSubmission,\n} from \"./adaptorch-api.ts\";\nexport {\n\tADAPTORCH_DEFAULT_API_URL,\n\tAdaptOrchApiClient,\n\tAdaptOrchApiError,\n\tassertSafeApiUrl,\n\tcreateAdaptOrchApiClientFromEnv,\n\tresolveAuthHeaders,\n} from \"./adaptorch-api.ts\";\nexport type { AdaptOrchTransport } from \"./adaptorch-client.ts\";\nexport {\n\tADAPTORCH_FULL_ONLY_TOOLS,\n\tADAPTORCH_REMOTE_TOOLS,\n\tADAPTORCH_TOOLS,\n\tAdaptOrchClient,\n} from \"./adaptorch-client.ts\";\nexport type { AdjudicationRequest, AdjudicationResult, PerRunVerdict } from \"./adjudicator.ts\";\nexport { adjudicate } from \"./adjudicator.ts\";\nexport type {\n\tAdjudicationReasonCode,\n\tCheckResult,\n\tVerdictState,\n\tVerifierRegistryEntry,\n} from \"./adjudicator-registry.ts\";\nexport {\n\tADJUDICATION_REASON_CODES,\n\tcreateVerifierRegistry,\n\tDEFAULT_VERIFIER,\n\treduceReasonCodes,\n} from \"./adjudicator-registry.ts\";\nexport type { MapToB2CInput, MapToB2COutput } from \"./b2c-mapper.ts\";\nexport { BATCH1_NO_DOCKER_RUNNER, mapToB2C } from \"./b2c-mapper.ts\";\nexport type {\n\tUserRiskLevel,\n\tUserVerdict,\n\tVerdictCard,\n\tVerdictLimits,\n\tVerdictNextAction,\n\tVerificationReceipt,\n} from \"./b2c-verdict.ts\";\nexport { B2C_VERDICT_SCHEMA_VERSION } from \"./b2c-verdict.ts\";\nexport type {\n\tDeepWallPhase,\n\tDeepWallResult,\n\tDeepWallRunnerEvidence,\n\tDeepWallRunnerFn,\n\tDeepWallRunnerResult,\n\tDeepWallStatus,\n\tDeepWallStubResult,\n\tRunDeepWallStubParams,\n} from \"./deep-wall.ts\";\nexport {\n\tDEEP_RUNNER_ERROR,\n\tDEEP_RUNNER_EVIDENCE_MISSING,\n\tDEEP_RUNNER_NOT_WIRED,\n\tDEEP_WALL_UNAVAILABLE,\n\tisDeepRunnerCompletionAllowed,\n\tresolveDeepWallPhaseFromEnv,\n\trunDeepWall,\n\trunDeepWallStub,\n} from \"./deep-wall.ts\";\nexport type {\n\tEvaluateCorrectnessWallParams,\n\tEvaluateCorrectnessWallResult,\n} from \"./evaluate-correctness-wall.ts\";\nexport { evaluateCorrectnessWall } from \"./evaluate-correctness-wall.ts\";\nexport type { InMemoryAdaptOrchFixture } from \"./in-memory-adaptorch.ts\";\nexport { createInMemoryAdaptOrchClient } from \"./in-memory-adaptorch.ts\";\nexport type { AdaptOrchCallToolFn, OaTransportMode } from \"./live-adaptorch-transport.ts\";\nexport { createLiveAdaptOrchClient, parseOaTransportModeFromEnv } from \"./live-adaptorch-transport.ts\";\nexport type { NextActionKind, VerdictDisposition } from \"./loop.ts\";\nexport {\n\tdecideNextTransition,\n\thandleAdjudicationFailure,\n\tprojectVerdictToDisposition,\n\trunAdjudicationWithTimeout,\n} from \"./loop.ts\";\nexport type {\n\tCreateMcpIntrospectionTransportOptions,\n\tMcpIntrospectionMode,\n} from \"./mcp-introspection-transport.ts\";\nexport { createMcpIntrospectionClient } from \"./mcp-introspection-transport.ts\";\nexport type { PolicyFlag } from \"./policy-wall.ts\";\nexport {\n\tPOLICY_FLAG,\n\tparseDiffPaths,\n\tpathMatchesApprovedScope,\n\trunFastWall,\n\tscanDiffLinesForSecrets,\n} from \"./policy-wall.ts\";\nexport type { SignedWallReceipt, SignWallReceiptInput, VerifyWallReceiptInput } from \"./receipt-signature.ts\";\nexport { signWallReceipt, verifyWallReceipt } from \"./receipt-signature.ts\";\nexport type { BuildRegeneratePacketInput, RegeneratePacket } from \"./regenerate-packet.ts\";\nexport { buildRegeneratePacket } from \"./regenerate-packet.ts\";\nexport type { RepairBudgetState } from \"./repair-budget.ts\";\nexport { capRepairHints, parseRepairBudget, shouldOfferRepair } from \"./repair-budget.ts\";\nexport type { RepairHintInput } from \"./repair-loop.ts\";\nexport { deriveRepairHints } from \"./repair-loop.ts\";\nexport type {\n\tVerificationDigest,\n\tVerificationDigestInput,\n\tWallReceiptMeta,\n} from \"./signed-receipt.ts\";\nexport { buildVerificationDigest } from \"./signed-receipt.ts\";\nexport { applyTransition, canTransition, isTerminalState, requiresHumanApproval } from \"./state-machine.ts\";\nexport type {\n\tCardinalityMode,\n\tDispatchRecord,\n\tLoopConfig,\n\tLoopTerminationCondition,\n\tTopologyClassification,\n\tTransitionLogEntry,\n\tWorkPacket,\n\tWorkPacketState,\n} from \"./types.ts\";\nexport { ADJUDICATIONS_DIR, LOOP_STATE_FILE, PACKET_INDEX_FILE, PACKETS_DIR, RUN_MAP_FILE } from \"./types.ts\";\nexport { CORRECTNESS_WALL_VERSION } from \"./wall-meta.ts\";\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -18,11 +18,10 @@ export type WorkPacketState = "DRAFTED" | "ROUTED" | "AWAITING_APPROVAL" | "DISP
|
|
|
18
18
|
* single-call-vs-client-side-fanout ambiguity.
|
|
19
19
|
*/
|
|
20
20
|
export type CardinalityMode = "single_call" | "fanout_n";
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export type TopologyClassification = "singleton" | "pipeline" | "dag" | "ensemble";
|
|
21
|
+
/** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */
|
|
22
|
+
export declare const TOPOLOGY_CLASSIFICATIONS: readonly ["parallel", "sequential", "hierarchical", "hybrid", "multi_model_ensemble", "multi_turn_debate"];
|
|
23
|
+
export type TopologyClassification = (typeof TOPOLOGY_CLASSIFICATIONS)[number];
|
|
24
|
+
export declare function isTopologyClassification(value: unknown): value is TopologyClassification;
|
|
26
25
|
/**
|
|
27
26
|
* Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record
|
|
28
27
|
* holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,WAAW,GACX,UAAU,GACV,cAAc,GACd,WAAW,GACX,QAAQ,CAAC;AAEZ;;;;;GAKG;AACH,MA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,GAAG,IAAI,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GACjC,uBAAuB,GACvB,2BAA2B,GAC3B,mBAAmB,GACnB,sBAAsB,GACtB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,CAAC;AAEpB;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,8FAA2F;IAC3F,gCAAgC,EAAE,MAAM,CAAC;IACzC,sEAAqE;IACrE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mHAAgH;IAChH,wBAAwB,EAAE,MAAM,CAAC;IACjC;;;;OAIG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,4BAA4B,EAAE;QAC7B,iGAAiG;QACjG,oBAAoB,EAAE,MAAM,CAAC;QAC7B,sFAAsF;QACtF,qBAAqB,EAAE,MAAM,CAAC;QAC9B,kGAAkG;QAClG,2BAA2B,EAAE,MAAM,CAAC;KACpC,CAAC;IACF;;;OAGG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,yBAAyB,EAAE,eAAe,GAAG,IAAI,CAAC;CAClD;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/**\n * Part 1 §3.1 — the four topology classes `adaptorch_route_topology` can return for a\n * packet's payload, decided once per packet before any `adaptorch_run` call.\n */\nexport type TopologyClassification = \"singleton\" | \"pipeline\" | \"dag\" | \"ensemble\";\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,WAAW,GACX,UAAU,GACV,cAAc,GACd,WAAW,GACX,QAAQ,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,4GAO3B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI/E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB,CAExF;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,eAAe,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO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;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */\nexport const TOPOLOGY_CLASSIFICATIONS = [\n\t\"parallel\",\n\t\"sequential\",\n\t\"hierarchical\",\n\t\"hybrid\",\n\t\"multi_model_ensemble\",\n\t\"multi_turn_debate\",\n] as const;\n\nexport type TopologyClassification = (typeof TOPOLOGY_CLASSIFICATIONS)[number];\n\nconst TOPOLOGY_CLASSIFICATION_SET: ReadonlySet<string> = new Set(TOPOLOGY_CLASSIFICATIONS);\n\nexport function isTopologyClassification(value: unknown): value is TopologyClassification {\n\treturn typeof value === \"string\" && TOPOLOGY_CLASSIFICATION_SET.has(value);\n}\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
|
package/dist/types.js
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
* and 7. It is an implementation of that document, not a restatement of it — see the design
|
|
5
5
|
* doc for rationale, transition semantics, and the open questions left for other lanes.
|
|
6
6
|
*/
|
|
7
|
+
/** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */
|
|
8
|
+
export const TOPOLOGY_CLASSIFICATIONS = [
|
|
9
|
+
"parallel",
|
|
10
|
+
"sequential",
|
|
11
|
+
"hierarchical",
|
|
12
|
+
"hybrid",
|
|
13
|
+
"multi_model_ensemble",
|
|
14
|
+
"multi_turn_debate",
|
|
15
|
+
];
|
|
16
|
+
const TOPOLOGY_CLASSIFICATION_SET = new Set(TOPOLOGY_CLASSIFICATIONS);
|
|
17
|
+
export function isTopologyClassification(value) {
|
|
18
|
+
return typeof value === "string" && TOPOLOGY_CLASSIFICATION_SET.has(value);
|
|
19
|
+
}
|
|
7
20
|
/**
|
|
8
21
|
* Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so
|
|
9
22
|
* other modules never hardcode these path segments.
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH,gGAAgG;AAChG,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,UAAU;IACV,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,sBAAsB;IACtB,mBAAmB;CACV,CAAC;AAIX,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAE3F,MAAM,UAAU,wBAAwB,CAAC,KAAc,EAAmC;IACzF,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,2BAA2B,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAAA,CAC3E;AAgID;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC","sourcesContent":["/**\n * Design-fidelity note: this file implements the Work Packet on-disk schema and supporting\n * type vocabulary defined in Part 1 (`final-part1-core-algorithm.md`), Sections 1, 2, 3, 4,\n * and 7. It is an implementation of that document, not a restatement of it — see the design\n * doc for rationale, transition semantics, and the open questions left for other lanes.\n */\n\n/**\n * Work Packet lifecycle states.\n *\n * Part 1 §2 — the fourteen states of the packet-level state machine, including the\n * ESCALATED / AWAITING_APPROVAL / ADJUDICATION_FAILED additions from this revision.\n */\nexport type WorkPacketState =\n\t| \"DRAFTED\"\n\t| \"ROUTED\"\n\t| \"AWAITING_APPROVAL\"\n\t| \"DISPATCHED\"\n\t| \"ACTIVE\"\n\t| \"HALTING\"\n\t| \"RAW_TERMINAL\"\n\t| \"UNDER_REVIEW\"\n\t| \"ADJUDICATION_FAILED\"\n\t| \"CONFIRMED\"\n\t| \"DECLINED\"\n\t| \"RETRY_QUEUED\"\n\t| \"ESCALATED\"\n\t| \"CLOSED\";\n\n/**\n * Part 1 §3.3 — whether a Dispatch Record's run_id set was produced by a single\n * `adaptorch_run` call (`single_call`) or by N calls the loop itself issued (`fanout_n`).\n * This tag is what lets the rest of the state machine stay agnostic to the Section 3.2\n * single-call-vs-client-side-fanout ambiguity.\n */\nexport type CardinalityMode = \"single_call\" | \"fanout_n\";\n\n/** Current `adaptorch_route_topology` values, synchronized with AdaptOrch's `Topology` enum. */\nexport const TOPOLOGY_CLASSIFICATIONS = [\n\t\"parallel\",\n\t\"sequential\",\n\t\"hierarchical\",\n\t\"hybrid\",\n\t\"multi_model_ensemble\",\n\t\"multi_turn_debate\",\n] as const;\n\nexport type TopologyClassification = (typeof TOPOLOGY_CLASSIFICATIONS)[number];\n\nconst TOPOLOGY_CLASSIFICATION_SET: ReadonlySet<string> = new Set(TOPOLOGY_CLASSIFICATIONS);\n\nexport function isTopologyClassification(value: unknown): value is TopologyClassification {\n\treturn typeof value === \"string\" && TOPOLOGY_CLASSIFICATION_SET.has(value);\n}\n\n/**\n * Part 1 §3.3 / §7 — one concrete submission attempt for a Work Packet. A Dispatch Record\n * holds a run_id *set* (not a single run_id) tagged with its cardinality mode, so polling,\n * cancellation, and review packaging work the same way regardless of which Section 3.2\n * reading turns out to be correct.\n */\nexport interface DispatchRecord {\n\tattempt_n: number;\n\tcardinality_mode: CardinalityMode;\n\trun_ids: string[];\n\tsubmitted_at: string;\n\tmode: \"blocking\" | \"polling\";\n\tterminal_status?: string;\n\tterminal_at?: string;\n}\n\n/**\n * Part 1 §7 — one append-only entry in a Work Packet's transition log. Recorded for every\n * state change, including adjudication-call failures that have no `AdjudicationResult` to\n * archive elsewhere.\n */\nexport interface TransitionLogEntry {\n\tfrom: WorkPacketState;\n\tto: WorkPacketState;\n\tat: string;\n\tcause: string;\n}\n\n/**\n * Part 1 §1 / §7 — the Work Packet: the durable unit of intent this loop manages, potentially\n * resubmitted across several Dispatch Records over its life.\n *\n * The design doc (§7) also describes `adjudication_retry_count` (a separate bounded counter\n * for retrying the `adjudicate()` call itself, Part 1 §2/§6) and\n * `last_human_approved_topology_class` as persisted fields. Those are not modeled on this\n * type in this cut; a later change can add them without breaking the fields defined here.\n */\nexport interface WorkPacket {\n\tpacket_id: string;\n\tkind: string;\n\tcreated_at: string;\n\tpayload: unknown;\n\ttopology_decision: {\n\t\tclassification: TopologyClassification;\n\t\tdecided_at: string;\n\t\traw_route_response: unknown;\n\t} | null;\n\tdispatch_records: DispatchRecord[];\n\tstate: WorkPacketState;\n\tretry_count: number;\n\ttransition_log: TransitionLogEntry[];\n\tlast_adjudication_ref: string | null;\n\t/** Part 1 §4 — the per-packet attempt budget (`max_dispatch_attempts`) and how much of it has been used. */\n\tattempt_budget: {\n\t\tmax_dispatch_attempts: number;\n\t\tdispatch_attempts_used: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 / §7 — the payload most recently approved by a human reviewer (or the\n\t * original payload at creation, implicitly approved). `null` only if the packet has not yet\n\t * been assigned an initial baseline. Used by `requiresHumanApproval` to decide whether the\n\t * next attempt needs an AWAITING_APPROVAL gate before its first dispatch.\n\t */\n\tlast_human_approved_payload: unknown | null;\n}\n\n/**\n * Part 1 §4 — the named reasons the loop stops admitting new DRAFTED packets and begins\n * draining. `capacity_ceiling` and the cardinality-mismatch guard are soft governors (they\n * reduce admission/concurrency rather than terminating the loop outright); the others are\n * hard termination conditions.\n */\nexport type LoopTerminationCondition =\n\t| \"completion_exhaustion\"\n\t| \"per_packet_attempt_budget\"\n\t| \"wall_clock_budget\"\n\t| \"dispatch_call_budget\"\n\t| \"stagnation_guard\"\n\t| \"capacity_ceiling\"\n\t| \"external_abort\";\n\n/**\n * Part 1 §4 — loop-instance configuration. Per the \"Budget immutability\" rule in §4, every\n * field here is fixed at loop-instance creation and must not be mutated for that instance's\n * lifetime; raising a threshold requires starting a new loop instance.\n */\nexport interface LoopConfig {\n\tloop_instance_id: string;\n\t/** Part 1 §4 \"Per-packet attempt budget\" — illustrative default in the design doc is 3. */\n\tmax_dispatch_attempts_per_packet: number;\n\t/** Part 1 §4 \"Loop wall-clock budget\", expressed in milliseconds. */\n\tmax_loop_duration_ms: number;\n\t/** Part 1 §4 \"Loop dispatch-call budget\" — total `adaptorch_run` invocations allowed across the loop's life. */\n\tmax_total_dispatch_calls: number;\n\t/**\n\t * Part 1 §4 \"Stagnation guard\" — the number of consecutive loop-wide DECLINED verdicts\n\t * with indistinguishable evidence (same reason text / same evidence digest) that triggers\n\t * a halt.\n\t */\n\tstagnation_repeat_threshold: number;\n\t/**\n\t * Part 1 §4 \"Capacity ceiling (soft governor)\". Shape chosen for this implementation, not\n\t * dictated verbatim by the design doc: a saturation fraction/duration pair that must be\n\t * sustained before the governor engages, and the reduced concurrency ceiling it engages to.\n\t */\n\tcapacity_governor_thresholds: {\n\t\t/** Fraction (0-1) of `adaptorch_server_metrics` saturation considered \"sustained saturation\". */\n\t\tsaturation_threshold: number;\n\t\t/** How long saturation must persist, in milliseconds, before the governor engages. */\n\t\tsustained_duration_ms: number;\n\t\t/** Concurrency budget (max packets allowed into ACTIVE at once) while the governor is engaged. */\n\t\treduced_concurrency_ceiling: number;\n\t};\n\t/**\n\t * Part 1 §2 state 3 — the documented opt-in escape hatch that skips AWAITING_APPROVAL\n\t * for every attempt in this loop instance, regardless of payload/topology drift.\n\t */\n\tpre_approved_batch: boolean;\n\t/**\n\t * Part 1 §3.4 — the result of the one-time cardinality calibration probe, or `null` before\n\t * that probe has run. Continuously cross-checked (at zero extra call cost) against later\n\t * `adaptorch_get_run`/reconciliation-sweep observations per §3.4.\n\t */\n\tobserved_cardinality_mode: CardinalityMode | null;\n}\n\n/**\n * Part 1 §7 — on-disk file layout constants, rooted at a loop-instance directory. Exported so\n * other modules never hardcode these path segments.\n */\nexport const PACKETS_DIR = \"packets\";\nexport const PACKET_INDEX_FILE = \"packet_index.json\";\nexport const RUN_MAP_FILE = \"run_map.json\";\nexport const LOOP_STATE_FILE = \"loop_state.json\";\nexport const ADJUDICATIONS_DIR = \"adjudications\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-adaptorch-wpl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"description": "AdaptOrch-native Work Packet Loop (WPL) — state machine, verification layer, and integration bridge for OMK orchestration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|