@stitchwire/client 0.0.0-stage → 0.31.1
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/LICENSE +21 -0
- package/README.md +296 -2
- package/dist/chunk-d3248e3w.js +728 -0
- package/dist/chunk-mva06nh4.js +709 -0
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.js +84 -0
- package/dist/enrollment.d.ts +1 -0
- package/dist/enrollment.js +503 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1680 -0
- package/dist/types/client/src/contracts.d.ts +1 -0
- package/dist/types/client/src/enrollment.d.ts +11 -0
- package/dist/types/client/src/index.d.ts +1 -0
- package/dist/types/contracts/src/door/client-error.d.ts +20 -0
- package/dist/types/contracts/src/door/common.d.ts +3 -0
- package/dist/types/contracts/src/door/event-lifecycle.d.ts +22 -0
- package/dist/types/contracts/src/door/local-contract.d.ts +466 -0
- package/dist/types/contracts/src/door/paths.d.ts +17 -0
- package/dist/types/contracts/src/door/request-bounds.d.ts +4 -0
- package/dist/types/contracts/src/door/requests.d.ts +47 -0
- package/dist/types/contracts/src/door/results.d.ts +319 -0
- package/dist/types/contracts/src/door/status.d.ts +859 -0
- package/dist/types/contracts/src/door/streams.d.ts +226 -0
- package/dist/types/contracts/src/enrollment/fleet-admission.d.ts +413 -0
- package/dist/types/contracts/src/enrollment/outcome.d.ts +29 -0
- package/dist/types/contracts/src/enrollment/request.d.ts +281 -0
- package/dist/types/contracts/src/enrollment/result.d.ts +713 -0
- package/dist/types/contracts/src/fleet/bundle.d.ts +209 -0
- package/dist/types/contracts/src/fleet/identity.d.ts +4 -0
- package/dist/types/contracts/src/fleet/manifest.d.ts +71 -0
- package/dist/types/contracts/src/fleet/status.d.ts +56 -0
- package/dist/types/contracts/src/peer-contract.d.ts +78 -0
- package/dist/types/contracts/src/protocol/bounds.d.ts +37 -0
- package/dist/types/contracts/src/protocol/broker-health.d.ts +384 -0
- package/dist/types/contracts/src/protocol/event.d.ts +222 -0
- package/dist/types/contracts/src/protocol/failure.d.ts +146 -0
- package/dist/types/contracts/src/protocol/identity.d.ts +11 -0
- package/dist/types/contracts/src/protocol/json-bounds.d.ts +6 -0
- package/dist/types/contracts/src/protocol/lane-url.d.ts +16 -0
- package/dist/types/contracts/src/protocol/paths.d.ts +7 -0
- package/dist/types/contracts/src/protocol/payload.d.ts +25 -0
- package/dist/types/contracts/src/protocol/presence.d.ts +66 -0
- package/dist/types/contracts/src/protocol/release.d.ts +61 -0
- package/dist/types/contracts/src/protocol/result.d.ts +41 -0
- package/dist/types/contracts/src/protocol/rpc.d.ts +106 -0
- package/dist/types/contracts/src/protocol/schema-parse.d.ts +23 -0
- package/dist/types/contracts/src/protocol/stream.d.ts +290 -0
- package/dist/types/contracts/src/protocol/topic.d.ts +185 -0
- package/dist/types/contracts/src/service/budgets.d.ts +3 -0
- package/dist/types/contracts/src/service/contract-descriptor.d.ts +9 -0
- package/dist/types/contracts/src/service/contracts.d.ts +430 -0
- package/dist/types/contracts/src/service/declaration.d.ts +122 -0
- package/dist/types/contracts/src/service/diagnostics.d.ts +104 -0
- package/dist/types/contracts/src/service/owner-route-path.d.ts +11 -0
- package/dist/types/contracts/src/service/policy-schema.d.ts +154 -0
- package/dist/types/contracts/src/service/request-bounds.d.ts +5 -0
- package/dist/types/contracts/src/service/service-contract.d.ts +112 -0
- package/dist/types/local-client/src/broker-health.d.ts +18 -0
- package/dist/types/local-client/src/client.d.ts +377 -0
- package/dist/types/local-client/src/contracts.d.ts +112 -0
- package/dist/types/local-client/src/declarations.d.ts +57 -0
- package/dist/types/local-client/src/door-paths.d.ts +18 -0
- package/dist/types/local-client/src/errno.d.ts +6 -0
- package/dist/types/local-client/src/error-chain.d.ts +25 -0
- package/dist/types/local-client/src/errors.d.ts +39 -0
- package/dist/types/local-client/src/event-sequence.d.ts +4 -0
- package/dist/types/local-client/src/feed.d.ts +8 -0
- package/dist/types/local-client/src/http.d.ts +20 -0
- package/dist/types/local-client/src/index.d.ts +13 -0
- package/dist/types/local-client/src/ingress.d.ts +31 -0
- package/dist/types/local-client/src/operation.d.ts +37 -0
- package/dist/types/local-client/src/options.d.ts +18 -0
- package/dist/types/local-client/src/paths.d.ts +52 -0
- package/dist/types/local-client/src/readers.d.ts +143 -0
- package/dist/types/local-client/src/service.d.ts +33 -0
- package/dist/types/local-client/src/status-readers.d.ts +756 -0
- package/dist/types/local-client/src/unary.d.ts +10 -0
- package/package.json +58 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ServiceLimitsSchema: z.ZodObject<{
|
|
3
|
+
requestBytes: z.ZodNumber;
|
|
4
|
+
responseBytes: z.ZodNumber;
|
|
5
|
+
timeoutMs: z.ZodNumber;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
/**
|
|
8
|
+
* What an operation does to the owner's state, in the only two words the fleet uses.
|
|
9
|
+
*
|
|
10
|
+
* It is a closed set on purpose. A grant of kind `service-read` admits every `read` operation of a
|
|
11
|
+
* service without naming any of them, so the owner — who writes the descriptor — decides what
|
|
12
|
+
* counts as reading, and the fleet operator never has to enumerate another project's operation
|
|
13
|
+
* names. That delegation only works if both sides spell the word the same way: a descriptor that
|
|
14
|
+
* says `act`, `demand` or `mutate` describes something the wire cannot classify, and any invariant
|
|
15
|
+
* written over one vocabulary is silently inapplicable to the other.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ServiceEffectSchema: z.ZodEnum<{
|
|
18
|
+
read: "read";
|
|
19
|
+
write: "write";
|
|
20
|
+
}>;
|
|
21
|
+
export type ServiceEffect = z.infer<typeof ServiceEffectSchema>;
|
|
22
|
+
export declare const ServiceOperationSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
effect: z.ZodEnum<{
|
|
26
|
+
read: "read";
|
|
27
|
+
write: "write";
|
|
28
|
+
}>;
|
|
29
|
+
limits: z.ZodObject<{
|
|
30
|
+
requestBytes: z.ZodNumber;
|
|
31
|
+
responseBytes: z.ZodNumber;
|
|
32
|
+
timeoutMs: z.ZodNumber;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
response: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
kind: z.ZodLiteral<"unary">;
|
|
36
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
37
|
+
kind: z.ZodLiteral<"stream">;
|
|
38
|
+
lifetimeMs: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
}, z.core.$strict>], "kind">;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export declare const ServiceDescriptorSchema: z.ZodObject<{
|
|
43
|
+
service: z.ZodString;
|
|
44
|
+
revision: z.ZodString;
|
|
45
|
+
maxInflight: z.ZodNumber;
|
|
46
|
+
operations: z.ZodArray<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
path: z.ZodString;
|
|
49
|
+
effect: z.ZodEnum<{
|
|
50
|
+
read: "read";
|
|
51
|
+
write: "write";
|
|
52
|
+
}>;
|
|
53
|
+
limits: z.ZodObject<{
|
|
54
|
+
requestBytes: z.ZodNumber;
|
|
55
|
+
responseBytes: z.ZodNumber;
|
|
56
|
+
timeoutMs: z.ZodNumber;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
response: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
59
|
+
kind: z.ZodLiteral<"unary">;
|
|
60
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
+
kind: z.ZodLiteral<"stream">;
|
|
62
|
+
lifetimeMs: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, z.core.$strict>], "kind">;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
export type ServiceDescriptor = z.infer<typeof ServiceDescriptorSchema>;
|
|
68
|
+
export declare const ServiceBindingSchema: z.ZodObject<{
|
|
69
|
+
service: z.ZodString;
|
|
70
|
+
descriptorPath: z.ZodString;
|
|
71
|
+
socketPath: z.ZodString;
|
|
72
|
+
endpointPath: z.ZodString;
|
|
73
|
+
maxInflight: z.ZodNumber;
|
|
74
|
+
limits: z.ZodObject<{
|
|
75
|
+
requestBytes: z.ZodNumber;
|
|
76
|
+
responseBytes: z.ZodNumber;
|
|
77
|
+
timeoutMs: z.ZodNumber;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
}, z.core.$strict>;
|
|
80
|
+
export type ServiceBinding = z.infer<typeof ServiceBindingSchema>;
|
|
81
|
+
export declare const ServiceGrantSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
82
|
+
caller: z.ZodString;
|
|
83
|
+
target: z.ZodString;
|
|
84
|
+
service: z.ZodString;
|
|
85
|
+
scope: z.ZodObject<{
|
|
86
|
+
kind: z.ZodLiteral<"service-read">;
|
|
87
|
+
}, z.core.$strict>;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
caller: z.ZodString;
|
|
90
|
+
target: z.ZodString;
|
|
91
|
+
service: z.ZodString;
|
|
92
|
+
scope: z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"operation">;
|
|
94
|
+
operation: z.ZodString;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
}, z.core.$strict>]>;
|
|
97
|
+
export type ServiceGrant = z.infer<typeof ServiceGrantSchema>;
|
|
98
|
+
/**
|
|
99
|
+
* No count: a node declares the callers of every owner's declaration in one list, so any count here
|
|
100
|
+
* is reached by adding services, not by a wrong file. What carries grants from elsewhere — owner
|
|
101
|
+
* declarations, the fleet bundle, lane frames — is bounded in bytes; a configuration file is the
|
|
102
|
+
* operator's own.
|
|
103
|
+
*/
|
|
104
|
+
export declare const ServiceGrantsSchema: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
105
|
+
caller: z.ZodString;
|
|
106
|
+
target: z.ZodString;
|
|
107
|
+
service: z.ZodString;
|
|
108
|
+
scope: z.ZodObject<{
|
|
109
|
+
kind: z.ZodLiteral<"service-read">;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
112
|
+
caller: z.ZodString;
|
|
113
|
+
target: z.ZodString;
|
|
114
|
+
service: z.ZodString;
|
|
115
|
+
scope: z.ZodObject<{
|
|
116
|
+
kind: z.ZodLiteral<"operation">;
|
|
117
|
+
operation: z.ZodString;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
}, z.core.$strict>]>>;
|
|
120
|
+
/** One service per binding and one budget per socket, for every schema that carries bindings. */
|
|
121
|
+
export declare function checkServiceBindings(value: {
|
|
122
|
+
bindings: readonly ServiceBinding[];
|
|
123
|
+
}, ctx: z.RefinementCtx): void;
|
|
124
|
+
export declare const ServicePolicySchema: z.ZodObject<{
|
|
125
|
+
bindings: z.ZodArray<z.ZodObject<{
|
|
126
|
+
service: z.ZodString;
|
|
127
|
+
descriptorPath: z.ZodString;
|
|
128
|
+
socketPath: z.ZodString;
|
|
129
|
+
endpointPath: z.ZodString;
|
|
130
|
+
maxInflight: z.ZodNumber;
|
|
131
|
+
limits: z.ZodObject<{
|
|
132
|
+
requestBytes: z.ZodNumber;
|
|
133
|
+
responseBytes: z.ZodNumber;
|
|
134
|
+
timeoutMs: z.ZodNumber;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
}, z.core.$strict>>;
|
|
137
|
+
grants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
138
|
+
caller: z.ZodString;
|
|
139
|
+
target: z.ZodString;
|
|
140
|
+
service: z.ZodString;
|
|
141
|
+
scope: z.ZodObject<{
|
|
142
|
+
kind: z.ZodLiteral<"service-read">;
|
|
143
|
+
}, z.core.$strict>;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
caller: z.ZodString;
|
|
146
|
+
target: z.ZodString;
|
|
147
|
+
service: z.ZodString;
|
|
148
|
+
scope: z.ZodObject<{
|
|
149
|
+
kind: z.ZodLiteral<"operation">;
|
|
150
|
+
operation: z.ZodString;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
}, z.core.$strict>]>>;
|
|
153
|
+
}, z.core.$strict>;
|
|
154
|
+
export type ServicePolicy = z.infer<typeof ServicePolicySchema>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Small implicit operations stay small; larger documents require explicit owner opt-in. */
|
|
2
|
+
export declare const SERVICE_DEFAULT_REQUEST_BYTES = 65536;
|
|
3
|
+
/** Bounded document transport, not an upload or durable file-transfer protocol. */
|
|
4
|
+
export declare const SERVICE_MAX_REQUEST_BYTES = 1048576;
|
|
5
|
+
export declare const SERVICE_MAX_REQUEST_ENVELOPE_BYTES: number;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const serviceContract: import("stitchkit").ContractDef<{
|
|
2
|
+
readonly invokeService: {
|
|
3
|
+
readonly method: "POST";
|
|
4
|
+
readonly path: "/services/invoke";
|
|
5
|
+
readonly desc: "Invoke an explicitly granted owner operation";
|
|
6
|
+
readonly input: import("zod").ZodObject<{
|
|
7
|
+
traceId: import("zod").ZodOptional<import("zod").ZodUUID>;
|
|
8
|
+
to: import("zod").ZodString;
|
|
9
|
+
service: import("zod").ZodString;
|
|
10
|
+
revision: import("zod").ZodString;
|
|
11
|
+
operation: import("zod").ZodString;
|
|
12
|
+
payload: import("zod").ZodString;
|
|
13
|
+
timeoutMs: import("zod").ZodNumber;
|
|
14
|
+
}, import("zod/v4/core").$strict>;
|
|
15
|
+
readonly output: import("zod").ZodObject<{
|
|
16
|
+
v: import("zod").ZodLiteral<7>;
|
|
17
|
+
outcome: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
18
|
+
status: import("zod").ZodLiteral<"response">;
|
|
19
|
+
delivery: import("zod").ZodLiteral<"received">;
|
|
20
|
+
httpStatus: import("zod").ZodNumber;
|
|
21
|
+
payload: import("zod").ZodString;
|
|
22
|
+
diagnostics: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
23
|
+
traceId: import("zod").ZodUUID;
|
|
24
|
+
requestId: import("zod").ZodUUID;
|
|
25
|
+
phases: import("zod").ZodArray<import("zod").ZodObject<{
|
|
26
|
+
phase: import("zod").ZodEnum<{
|
|
27
|
+
admitted: "admitted";
|
|
28
|
+
"body-end": "body-end";
|
|
29
|
+
"body-start": "body-start";
|
|
30
|
+
"descriptor-end": "descriptor-end";
|
|
31
|
+
"descriptor-start": "descriptor-start";
|
|
32
|
+
"endpoint-end": "endpoint-end";
|
|
33
|
+
"endpoint-start": "endpoint-start";
|
|
34
|
+
"http-headers": "http-headers";
|
|
35
|
+
"http-start": "http-start";
|
|
36
|
+
"target-received": "target-received";
|
|
37
|
+
terminal: "terminal";
|
|
38
|
+
}>;
|
|
39
|
+
elapsedMs: import("zod").ZodNumber;
|
|
40
|
+
}, import("zod/v4/core").$strict>>;
|
|
41
|
+
}, import("zod/v4/core").$strict>>;
|
|
42
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
43
|
+
status: import("zod").ZodLiteral<"failure">;
|
|
44
|
+
code: import("zod").ZodEnum<{
|
|
45
|
+
cancelled: "cancelled";
|
|
46
|
+
capacity: "capacity";
|
|
47
|
+
denied: "denied";
|
|
48
|
+
"invalid-request": "invalid-request";
|
|
49
|
+
"invalid-response": "invalid-response";
|
|
50
|
+
offline: "offline";
|
|
51
|
+
timeout: "timeout";
|
|
52
|
+
unavailable: "unavailable";
|
|
53
|
+
unsupported: "unsupported";
|
|
54
|
+
}>;
|
|
55
|
+
delivery: import("zod").ZodEnum<{
|
|
56
|
+
"not-dispatched": "not-dispatched";
|
|
57
|
+
unknown: "unknown";
|
|
58
|
+
}>;
|
|
59
|
+
retryAfterMs: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
60
|
+
refusal: import("zod").ZodEnum<{
|
|
61
|
+
capacity: "capacity";
|
|
62
|
+
none: "none";
|
|
63
|
+
policy: "policy";
|
|
64
|
+
request: "request";
|
|
65
|
+
}>;
|
|
66
|
+
detail: import("zod").ZodOptional<import("zod").ZodString>;
|
|
67
|
+
transportCause: import("zod").ZodNullable<import("zod").ZodEnum<{
|
|
68
|
+
"acknowledgement-timeout": "acknowledgement-timeout";
|
|
69
|
+
"lane-lost-after-dispatch": "lane-lost-after-dispatch";
|
|
70
|
+
"no-connected-lane": "no-connected-lane";
|
|
71
|
+
"presence-pending-timeout": "presence-pending-timeout";
|
|
72
|
+
"target-offline": "target-offline";
|
|
73
|
+
}>>;
|
|
74
|
+
cancellationOrigin: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
75
|
+
"agent-shutdown": "agent-shutdown";
|
|
76
|
+
"broker-deadline": "broker-deadline";
|
|
77
|
+
"broker-shutdown": "broker-shutdown";
|
|
78
|
+
"caller-abort": "caller-abort";
|
|
79
|
+
"caller-deadline": "caller-deadline";
|
|
80
|
+
"caller-disconnect": "caller-disconnect";
|
|
81
|
+
"door-deadline": "door-deadline";
|
|
82
|
+
"door-disconnect": "door-disconnect";
|
|
83
|
+
"executor-deadline": "executor-deadline";
|
|
84
|
+
"lane-disconnect": "lane-disconnect";
|
|
85
|
+
"target-disconnect": "target-disconnect";
|
|
86
|
+
}>>;
|
|
87
|
+
diagnostics: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
88
|
+
traceId: import("zod").ZodUUID;
|
|
89
|
+
requestId: import("zod").ZodUUID;
|
|
90
|
+
phases: import("zod").ZodArray<import("zod").ZodObject<{
|
|
91
|
+
phase: import("zod").ZodEnum<{
|
|
92
|
+
admitted: "admitted";
|
|
93
|
+
"body-end": "body-end";
|
|
94
|
+
"body-start": "body-start";
|
|
95
|
+
"descriptor-end": "descriptor-end";
|
|
96
|
+
"descriptor-start": "descriptor-start";
|
|
97
|
+
"endpoint-end": "endpoint-end";
|
|
98
|
+
"endpoint-start": "endpoint-start";
|
|
99
|
+
"http-headers": "http-headers";
|
|
100
|
+
"http-start": "http-start";
|
|
101
|
+
"target-received": "target-received";
|
|
102
|
+
terminal: "terminal";
|
|
103
|
+
}>;
|
|
104
|
+
elapsedMs: import("zod").ZodNumber;
|
|
105
|
+
}, import("zod/v4/core").$strict>>;
|
|
106
|
+
}, import("zod/v4/core").$strict>>;
|
|
107
|
+
}, import("zod/v4/core").$strict>], "status">;
|
|
108
|
+
traceId: import("zod").ZodOptional<import("zod").ZodUUID>;
|
|
109
|
+
}, import("zod/v4/core").$strict>;
|
|
110
|
+
readonly maxJsonBodyBytes: number;
|
|
111
|
+
};
|
|
112
|
+
}, "public">;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BrokerHealth } from './contracts.ts';
|
|
2
|
+
export declare const DEFAULT_BROKER_HEALTH_TIMEOUT_MS = 8000;
|
|
3
|
+
export declare const DEFAULT_BROKER_HEALTH_MAX_BYTES: number;
|
|
4
|
+
export type BrokerHealthFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
5
|
+
export interface ReadBrokerHealthOptions {
|
|
6
|
+
/** Total deadline for headers and body; defaults to 8 000 ms for cross-region TLS hops. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
/** Maximum response payload bytes accepted; defaults to 8 MiB. */
|
|
9
|
+
maxResponseBytes?: number;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
/** Optional fetch implementation override (for tests or custom TLS transports). */
|
|
12
|
+
fetch?: BrokerHealthFetch;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Fetch and validate a broker's `/health` JSON snapshot with bounded timeout and response size.
|
|
16
|
+
* Accepts `ws://`, `wss://`, `http://` or `https://` lane URLs; refuses redirects and malformed payloads.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readBrokerHealth(laneUrl: string, options?: ReadBrokerHealthOptions): Promise<BrokerHealth>;
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LocalCallSchema, LocalEventPublishSchema, LocalEventSubscribeSchema, LocalStreamRequestSchema } from '../../contracts/src/door/requests.ts';
|
|
3
|
+
import { PeerRequestSchema } from '../../contracts/src/peer-contract.ts';
|
|
4
|
+
import { type ServiceCall } from '../../contracts/src/service/contracts.ts';
|
|
5
|
+
import type { ServiceClientTrace } from '../../contracts/src/service/diagnostics.ts';
|
|
6
|
+
import { type WireFeed } from './feed.ts';
|
|
7
|
+
import { type RequestOptions, type WireClientOptions } from './options.ts';
|
|
8
|
+
import { type EventFlowItem, type EventItem } from './readers.ts';
|
|
9
|
+
export type CallRequest = z.input<typeof LocalCallSchema>;
|
|
10
|
+
export type StreamRequest = z.input<typeof LocalStreamRequestSchema>;
|
|
11
|
+
export type PublishRequest = z.input<typeof LocalEventPublishSchema>;
|
|
12
|
+
export type SubscribeRequest = z.input<typeof LocalEventSubscribeSchema>;
|
|
13
|
+
export type PeerRequest = z.input<typeof PeerRequestSchema>;
|
|
14
|
+
export interface ServiceRequestOptions extends RequestOptions {
|
|
15
|
+
/** Called before validation/admission/dispatch so an outer deadline can retain correlation. */
|
|
16
|
+
onTrace?: (trace: ServiceClientTrace) => void;
|
|
17
|
+
}
|
|
18
|
+
/** Borrows the local agent's identity; never launches a daemon or connects to a broker. */
|
|
19
|
+
export declare function createWireClient(options: WireClientOptions): {
|
|
20
|
+
invokeService(input: ServiceCall, options?: ServiceRequestOptions): Promise<{
|
|
21
|
+
v: 7;
|
|
22
|
+
outcome: {
|
|
23
|
+
status: "response";
|
|
24
|
+
delivery: "received";
|
|
25
|
+
httpStatus: number;
|
|
26
|
+
payload: string;
|
|
27
|
+
diagnostics?: {
|
|
28
|
+
traceId: string;
|
|
29
|
+
requestId: string;
|
|
30
|
+
phases: {
|
|
31
|
+
phase: "admitted" | "body-end" | "body-start" | "descriptor-end" | "descriptor-start" | "endpoint-end" | "endpoint-start" | "http-headers" | "http-start" | "target-received" | "terminal";
|
|
32
|
+
elapsedMs: number;
|
|
33
|
+
}[];
|
|
34
|
+
} | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
status: "failure";
|
|
37
|
+
code: "cancelled" | "capacity" | "denied" | "invalid-request" | "invalid-response" | "offline" | "timeout" | "unavailable" | "unsupported";
|
|
38
|
+
delivery: "not-dispatched" | "unknown";
|
|
39
|
+
retryAfterMs: number | null;
|
|
40
|
+
refusal: "capacity" | "none" | "policy" | "request";
|
|
41
|
+
detail?: string | undefined;
|
|
42
|
+
transportCause: "acknowledgement-timeout" | "lane-lost-after-dispatch" | "no-connected-lane" | "presence-pending-timeout" | "target-offline" | null;
|
|
43
|
+
cancellationOrigin?: "agent-shutdown" | "broker-deadline" | "broker-shutdown" | "caller-abort" | "caller-deadline" | "caller-disconnect" | "door-deadline" | "door-disconnect" | "executor-deadline" | "lane-disconnect" | "target-disconnect" | undefined;
|
|
44
|
+
diagnostics?: {
|
|
45
|
+
traceId: string;
|
|
46
|
+
requestId: string;
|
|
47
|
+
phases: {
|
|
48
|
+
phase: "admitted" | "body-end" | "body-start" | "descriptor-end" | "descriptor-start" | "endpoint-end" | "endpoint-start" | "http-headers" | "http-start" | "target-received" | "terminal";
|
|
49
|
+
elapsedMs: number;
|
|
50
|
+
}[];
|
|
51
|
+
} | undefined;
|
|
52
|
+
};
|
|
53
|
+
traceId: string;
|
|
54
|
+
}>;
|
|
55
|
+
call(input: CallRequest, options?: RequestOptions): Promise<{
|
|
56
|
+
refusal: "capacity" | "none" | "policy" | "request";
|
|
57
|
+
retryAfterMs: number | null;
|
|
58
|
+
transportCause: "acknowledgement-timeout" | "lane-lost-after-dispatch" | "no-connected-lane" | "presence-pending-timeout" | "target-offline" | null;
|
|
59
|
+
id: string;
|
|
60
|
+
ts: string;
|
|
61
|
+
from: string;
|
|
62
|
+
code: number;
|
|
63
|
+
stdout: string;
|
|
64
|
+
stderr: string;
|
|
65
|
+
failure: "cancelled" | "denied" | "exec" | "none" | "offline" | "rejected" | "timeout" | "transport";
|
|
66
|
+
detail: string;
|
|
67
|
+
truncated: boolean;
|
|
68
|
+
v: 7;
|
|
69
|
+
}>;
|
|
70
|
+
status(options?: RequestOptions): Promise<{
|
|
71
|
+
v: 7;
|
|
72
|
+
nodeId: string;
|
|
73
|
+
connected: boolean;
|
|
74
|
+
serves: boolean;
|
|
75
|
+
version: string;
|
|
76
|
+
lanes: {
|
|
77
|
+
id: string;
|
|
78
|
+
url: string;
|
|
79
|
+
connected: boolean;
|
|
80
|
+
serves: boolean;
|
|
81
|
+
nodesVisible: number;
|
|
82
|
+
eventSubscriptions: {
|
|
83
|
+
observedAt: string;
|
|
84
|
+
activeSubscriptions: number;
|
|
85
|
+
};
|
|
86
|
+
presence: "disconnected" | "pending" | "ready" | "unavailable" | "unrecognized";
|
|
87
|
+
lastFailure: {
|
|
88
|
+
at: string;
|
|
89
|
+
reason: string;
|
|
90
|
+
refused: boolean;
|
|
91
|
+
} | null;
|
|
92
|
+
}[];
|
|
93
|
+
publicationAudit: {
|
|
94
|
+
queued: number;
|
|
95
|
+
dropped: number;
|
|
96
|
+
writeFailures: number;
|
|
97
|
+
lastFailure: string | null;
|
|
98
|
+
recovery?: {
|
|
99
|
+
filesChecked: number;
|
|
100
|
+
anomalies: number;
|
|
101
|
+
skippedBytes: number;
|
|
102
|
+
quarantinedUnlisted?: number | undefined;
|
|
103
|
+
firstAnomaly?: {
|
|
104
|
+
file: string;
|
|
105
|
+
offset: number;
|
|
106
|
+
line: number;
|
|
107
|
+
terminated: boolean;
|
|
108
|
+
skippedBytes: number;
|
|
109
|
+
reason: "invalid-event" | "invalid-frame" | "invalid-json" | "invalid-utf8" | "nul-byte" | "oversized-line" | "unrecognized" | "unterminated-line";
|
|
110
|
+
position: "interior" | "tail" | "unrecognized";
|
|
111
|
+
} | undefined;
|
|
112
|
+
lastAnomaly?: {
|
|
113
|
+
file: string;
|
|
114
|
+
offset: number;
|
|
115
|
+
line: number;
|
|
116
|
+
terminated: boolean;
|
|
117
|
+
skippedBytes: number;
|
|
118
|
+
reason: "invalid-event" | "invalid-frame" | "invalid-json" | "invalid-utf8" | "nul-byte" | "oversized-line" | "unrecognized" | "unterminated-line";
|
|
119
|
+
position: "interior" | "tail" | "unrecognized";
|
|
120
|
+
} | undefined;
|
|
121
|
+
quarantined?: readonly {
|
|
122
|
+
file: string;
|
|
123
|
+
quarantinedAs: string;
|
|
124
|
+
code?: string | undefined;
|
|
125
|
+
reason?: "not-a-regular-file" | "torn-without-retention-slot" | "unreadable" | "unrecognized" | undefined;
|
|
126
|
+
}[] | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
journal: {
|
|
129
|
+
path: string;
|
|
130
|
+
bytes: number;
|
|
131
|
+
generations: number;
|
|
132
|
+
maxBytes: number;
|
|
133
|
+
keep: number;
|
|
134
|
+
rotations: number;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
serviceAudit?: {
|
|
138
|
+
queued: number;
|
|
139
|
+
dropped: number;
|
|
140
|
+
writeFailures: number;
|
|
141
|
+
lastFailure: string | null;
|
|
142
|
+
recovery?: {
|
|
143
|
+
filesChecked: number;
|
|
144
|
+
anomalies: number;
|
|
145
|
+
skippedBytes: number;
|
|
146
|
+
quarantinedUnlisted?: number | undefined;
|
|
147
|
+
firstAnomaly?: {
|
|
148
|
+
file: string;
|
|
149
|
+
offset: number;
|
|
150
|
+
line: number;
|
|
151
|
+
terminated: boolean;
|
|
152
|
+
skippedBytes: number;
|
|
153
|
+
reason: "invalid-event" | "invalid-frame" | "invalid-json" | "invalid-utf8" | "nul-byte" | "oversized-line" | "unrecognized" | "unterminated-line";
|
|
154
|
+
position: "interior" | "tail" | "unrecognized";
|
|
155
|
+
} | undefined;
|
|
156
|
+
lastAnomaly?: {
|
|
157
|
+
file: string;
|
|
158
|
+
offset: number;
|
|
159
|
+
line: number;
|
|
160
|
+
terminated: boolean;
|
|
161
|
+
skippedBytes: number;
|
|
162
|
+
reason: "invalid-event" | "invalid-frame" | "invalid-json" | "invalid-utf8" | "nul-byte" | "oversized-line" | "unrecognized" | "unterminated-line";
|
|
163
|
+
position: "interior" | "tail" | "unrecognized";
|
|
164
|
+
} | undefined;
|
|
165
|
+
quarantined?: readonly {
|
|
166
|
+
file: string;
|
|
167
|
+
quarantinedAs: string;
|
|
168
|
+
code?: string | undefined;
|
|
169
|
+
reason?: "not-a-regular-file" | "torn-without-retention-slot" | "unreadable" | "unrecognized" | undefined;
|
|
170
|
+
}[] | undefined;
|
|
171
|
+
} | undefined;
|
|
172
|
+
journal: {
|
|
173
|
+
path: string;
|
|
174
|
+
bytes: number;
|
|
175
|
+
generations: number;
|
|
176
|
+
maxBytes: number;
|
|
177
|
+
keep: number;
|
|
178
|
+
rotations: number;
|
|
179
|
+
};
|
|
180
|
+
} | undefined;
|
|
181
|
+
allow: {
|
|
182
|
+
name: string;
|
|
183
|
+
path: string;
|
|
184
|
+
present: boolean;
|
|
185
|
+
cwd: string | null;
|
|
186
|
+
cwdPresent: boolean;
|
|
187
|
+
timeoutMs: number;
|
|
188
|
+
outputBytes: number;
|
|
189
|
+
concurrency: number;
|
|
190
|
+
callerArgs: "append" | "none" | "options" | "unrecognized";
|
|
191
|
+
stdin: "none" | "text" | "unrecognized";
|
|
192
|
+
}[];
|
|
193
|
+
streams: {
|
|
194
|
+
name: string;
|
|
195
|
+
path: string;
|
|
196
|
+
present: boolean;
|
|
197
|
+
cwd: string | null;
|
|
198
|
+
cwdPresent: boolean;
|
|
199
|
+
stableCursor: boolean;
|
|
200
|
+
timeoutMs: number;
|
|
201
|
+
maxBytes: number;
|
|
202
|
+
concurrency: number;
|
|
203
|
+
format: "ndjson" | "raw" | "unrecognized";
|
|
204
|
+
}[];
|
|
205
|
+
events: {
|
|
206
|
+
publish: string[];
|
|
207
|
+
subscribe: string[];
|
|
208
|
+
activeSubscriptions: number;
|
|
209
|
+
observedAt: string;
|
|
210
|
+
pendingPublishes: number;
|
|
211
|
+
namespaces: {
|
|
212
|
+
publish: string[];
|
|
213
|
+
subscribe: string[];
|
|
214
|
+
};
|
|
215
|
+
declarations: {
|
|
216
|
+
descriptors: {
|
|
217
|
+
path: string;
|
|
218
|
+
topics: number;
|
|
219
|
+
detail: string | null;
|
|
220
|
+
state: "invalid" | "loaded" | "missing" | "unrecognized";
|
|
221
|
+
}[];
|
|
222
|
+
refused: {
|
|
223
|
+
topic: string;
|
|
224
|
+
detail: string;
|
|
225
|
+
}[];
|
|
226
|
+
lanes: {
|
|
227
|
+
lane: string;
|
|
228
|
+
declaredAt: string;
|
|
229
|
+
accepted: number;
|
|
230
|
+
refused: {
|
|
231
|
+
topic: string;
|
|
232
|
+
detail: string;
|
|
233
|
+
}[];
|
|
234
|
+
}[];
|
|
235
|
+
};
|
|
236
|
+
subscriptions: {
|
|
237
|
+
subscriptionId: string;
|
|
238
|
+
topic: string;
|
|
239
|
+
}[];
|
|
240
|
+
topics: {
|
|
241
|
+
topic: string;
|
|
242
|
+
activeSubscriptions: number;
|
|
243
|
+
}[];
|
|
244
|
+
};
|
|
245
|
+
services: {
|
|
246
|
+
namespaces: string[];
|
|
247
|
+
declarations: {
|
|
248
|
+
descriptors: {
|
|
249
|
+
path: string;
|
|
250
|
+
service: string | null;
|
|
251
|
+
callers: number;
|
|
252
|
+
detail: string | null;
|
|
253
|
+
state: "invalid" | "loaded" | "missing" | "unrecognized";
|
|
254
|
+
}[];
|
|
255
|
+
refused: {
|
|
256
|
+
path: string;
|
|
257
|
+
service: string;
|
|
258
|
+
detail: string;
|
|
259
|
+
}[];
|
|
260
|
+
lanes: {
|
|
261
|
+
lane: string;
|
|
262
|
+
declaredAt: string;
|
|
263
|
+
accepted: number;
|
|
264
|
+
refused: {
|
|
265
|
+
service: string;
|
|
266
|
+
caller: string;
|
|
267
|
+
detail: string;
|
|
268
|
+
}[];
|
|
269
|
+
}[];
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
bundle: {
|
|
273
|
+
serial: number | null;
|
|
274
|
+
issuedAt: string | null;
|
|
275
|
+
signer: string | null;
|
|
276
|
+
detail: string | null;
|
|
277
|
+
checkedAt: string | null;
|
|
278
|
+
config: "aligned" | "drifted" | "unconfigured" | "unknown" | "unrecognized";
|
|
279
|
+
copy: "full" | "none" | "own" | "unrecognized";
|
|
280
|
+
lanes: {
|
|
281
|
+
lane: string;
|
|
282
|
+
serial: number | null;
|
|
283
|
+
syncedAt: string;
|
|
284
|
+
detail: string | null;
|
|
285
|
+
}[];
|
|
286
|
+
};
|
|
287
|
+
admission: {
|
|
288
|
+
maxInflight: number;
|
|
289
|
+
maxCallsPerMinute: number;
|
|
290
|
+
maxStreamProducers: number;
|
|
291
|
+
maxStreamConsumers: number;
|
|
292
|
+
maxStreamBufferedBytes: number;
|
|
293
|
+
maxEventSubscriptions: number;
|
|
294
|
+
maxPendingPublishes: number;
|
|
295
|
+
maxPublishesPerMinute: number;
|
|
296
|
+
};
|
|
297
|
+
config: {
|
|
298
|
+
path: string;
|
|
299
|
+
mode: string | null;
|
|
300
|
+
} | null;
|
|
301
|
+
release: {
|
|
302
|
+
current: string | null;
|
|
303
|
+
latest: string | null;
|
|
304
|
+
latestAt: string | null;
|
|
305
|
+
checkedAt: string | null;
|
|
306
|
+
ok: boolean;
|
|
307
|
+
};
|
|
308
|
+
application: {
|
|
309
|
+
id: string;
|
|
310
|
+
lifecycle: string;
|
|
311
|
+
health: string;
|
|
312
|
+
ready: boolean;
|
|
313
|
+
capturedAt: string;
|
|
314
|
+
resources: {
|
|
315
|
+
total: number;
|
|
316
|
+
ready: number;
|
|
317
|
+
degraded: number;
|
|
318
|
+
failed: number;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
nodes: {
|
|
322
|
+
nodeId: string;
|
|
323
|
+
online: boolean;
|
|
324
|
+
serves: boolean;
|
|
325
|
+
connections: number;
|
|
326
|
+
since: string | null;
|
|
327
|
+
version: string | null;
|
|
328
|
+
versionSeenAt: string | null;
|
|
329
|
+
observingSince: string;
|
|
330
|
+
behind: "major" | "minor" | "patch" | "unrecognized" | null;
|
|
331
|
+
departure: {
|
|
332
|
+
at: string;
|
|
333
|
+
reason: string;
|
|
334
|
+
kind: "announced" | "broker-restart" | "lost" | "unrecognized";
|
|
335
|
+
} | null;
|
|
336
|
+
}[];
|
|
337
|
+
}>;
|
|
338
|
+
peerObservation(input: PeerRequest, options?: RequestOptions): Promise<{
|
|
339
|
+
v: 7;
|
|
340
|
+
observer: string;
|
|
341
|
+
target: string;
|
|
342
|
+
outcome: "capacity" | "denied" | "offline" | "ok" | "stale" | "timeout" | "unsupported";
|
|
343
|
+
observedAt: string | null;
|
|
344
|
+
freshnessMs: 5000;
|
|
345
|
+
ageMs: number | null;
|
|
346
|
+
aggregationWindowMs: 60000;
|
|
347
|
+
sampleCount: number;
|
|
348
|
+
latestMs: number | null;
|
|
349
|
+
medianMs: number | null;
|
|
350
|
+
route: {
|
|
351
|
+
id: string;
|
|
352
|
+
url: string;
|
|
353
|
+
epoch: string;
|
|
354
|
+
} | null;
|
|
355
|
+
}>;
|
|
356
|
+
publish(input: PublishRequest, options?: RequestOptions): Promise<{
|
|
357
|
+
refusal: "capacity" | "none" | "policy" | "request";
|
|
358
|
+
retryAfterMs: number | null;
|
|
359
|
+
transportCause: "acknowledgement-timeout" | "lane-lost-after-dispatch" | "no-connected-lane" | "presence-pending-timeout" | "target-offline" | null;
|
|
360
|
+
ok: boolean;
|
|
361
|
+
failure: "cancelled" | "denied" | "exec" | "none" | "offline" | "rejected" | "timeout" | "transport";
|
|
362
|
+
detail: string;
|
|
363
|
+
}>;
|
|
364
|
+
stream(input: StreamRequest, options?: RequestOptions): WireFeed<import("./readers.ts").StreamItem>;
|
|
365
|
+
subscribe: {
|
|
366
|
+
(input: SubscribeRequest & {
|
|
367
|
+
lifecycle: true;
|
|
368
|
+
}, options?: RequestOptions): WireFeed<EventItem>;
|
|
369
|
+
(input: SubscribeRequest & {
|
|
370
|
+
lifecycle?: false;
|
|
371
|
+
}, options?: RequestOptions): WireFeed<EventFlowItem>;
|
|
372
|
+
(input: SubscribeRequest, options?: RequestOptions): WireFeed<EventItem>;
|
|
373
|
+
};
|
|
374
|
+
close(): void;
|
|
375
|
+
[Symbol.dispose](): void;
|
|
376
|
+
};
|
|
377
|
+
export type WireClient = ReturnType<typeof createWireClient>;
|