@grackle-ai/ahp 0.131.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/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/vendor/ahp/action-origin.generated.d.ts +33 -0
- package/dist/vendor/ahp/action-origin.generated.d.ts.map +1 -0
- package/dist/vendor/ahp/action-origin.generated.js +71 -0
- package/dist/vendor/ahp/action-origin.generated.js.map +1 -0
- package/dist/vendor/ahp/actions.d.ts +14 -0
- package/dist/vendor/ahp/actions.d.ts.map +1 -0
- package/dist/vendor/ahp/actions.js +15 -0
- package/dist/vendor/ahp/actions.js.map +1 -0
- package/dist/vendor/ahp/channels-changeset/actions.d.ts +87 -0
- package/dist/vendor/ahp/channels-changeset/actions.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-changeset/actions.js +9 -0
- package/dist/vendor/ahp/channels-changeset/actions.js.map +1 -0
- package/dist/vendor/ahp/channels-changeset/commands.d.ts +103 -0
- package/dist/vendor/ahp/channels-changeset/commands.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-changeset/commands.js +22 -0
- package/dist/vendor/ahp/channels-changeset/commands.js.map +1 -0
- package/dist/vendor/ahp/channels-changeset/reducer.d.ts +18 -0
- package/dist/vendor/ahp/channels-changeset/reducer.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-changeset/reducer.js +65 -0
- package/dist/vendor/ahp/channels-changeset/reducer.js.map +1 -0
- package/dist/vendor/ahp/channels-changeset/state.d.ts +155 -0
- package/dist/vendor/ahp/channels-changeset/state.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-changeset/state.js +39 -0
- package/dist/vendor/ahp/channels-changeset/state.js.map +1 -0
- package/dist/vendor/ahp/channels-otlp/notifications.d.ts +121 -0
- package/dist/vendor/ahp/channels-otlp/notifications.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-otlp/notifications.js +11 -0
- package/dist/vendor/ahp/channels-otlp/notifications.js.map +1 -0
- package/dist/vendor/ahp/channels-otlp/state.d.ts +65 -0
- package/dist/vendor/ahp/channels-otlp/state.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-otlp/state.js +10 -0
- package/dist/vendor/ahp/channels-otlp/state.js.map +1 -0
- package/dist/vendor/ahp/channels-root/actions.d.ts +62 -0
- package/dist/vendor/ahp/channels-root/actions.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-root/actions.js +8 -0
- package/dist/vendor/ahp/channels-root/actions.js.map +1 -0
- package/dist/vendor/ahp/channels-root/commands.d.ts +172 -0
- package/dist/vendor/ahp/channels-root/commands.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-root/commands.js +10 -0
- package/dist/vendor/ahp/channels-root/commands.js.map +1 -0
- package/dist/vendor/ahp/channels-root/notifications.d.ts +136 -0
- package/dist/vendor/ahp/channels-root/notifications.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-root/notifications.js +9 -0
- package/dist/vendor/ahp/channels-root/notifications.js.map +1 -0
- package/dist/vendor/ahp/channels-root/reducer.d.ts +12 -0
- package/dist/vendor/ahp/channels-root/reducer.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-root/reducer.js +36 -0
- package/dist/vendor/ahp/channels-root/reducer.js.map +1 -0
- package/dist/vendor/ahp/channels-root/state.d.ts +123 -0
- package/dist/vendor/ahp/channels-root/state.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-root/state.js +19 -0
- package/dist/vendor/ahp/channels-root/state.js.map +1 -0
- package/dist/vendor/ahp/channels-session/actions.d.ts +736 -0
- package/dist/vendor/ahp/channels-session/actions.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-session/actions.js +8 -0
- package/dist/vendor/ahp/channels-session/actions.js.map +1 -0
- package/dist/vendor/ahp/channels-session/commands.d.ts +261 -0
- package/dist/vendor/ahp/channels-session/commands.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-session/commands.js +23 -0
- package/dist/vendor/ahp/channels-session/commands.js.map +1 -0
- package/dist/vendor/ahp/channels-session/reducer.d.ts +14 -0
- package/dist/vendor/ahp/channels-session/reducer.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-session/reducer.js +703 -0
- package/dist/vendor/ahp/channels-session/reducer.js.map +1 -0
- package/dist/vendor/ahp/channels-session/state.d.ts +1217 -0
- package/dist/vendor/ahp/channels-session/state.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-session/state.js +229 -0
- package/dist/vendor/ahp/channels-session/state.js.map +1 -0
- package/dist/vendor/ahp/channels-terminal/actions.d.ts +185 -0
- package/dist/vendor/ahp/channels-terminal/actions.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-terminal/actions.js +8 -0
- package/dist/vendor/ahp/channels-terminal/actions.js.map +1 -0
- package/dist/vendor/ahp/channels-terminal/commands.d.ts +50 -0
- package/dist/vendor/ahp/channels-terminal/commands.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-terminal/commands.js +8 -0
- package/dist/vendor/ahp/channels-terminal/commands.js.map +1 -0
- package/dist/vendor/ahp/channels-terminal/reducer.d.ts +12 -0
- package/dist/vendor/ahp/channels-terminal/reducer.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-terminal/reducer.js +80 -0
- package/dist/vendor/ahp/channels-terminal/reducer.js.map +1 -0
- package/dist/vendor/ahp/channels-terminal/state.d.ts +151 -0
- package/dist/vendor/ahp/channels-terminal/state.d.ts.map +1 -0
- package/dist/vendor/ahp/channels-terminal/state.js +18 -0
- package/dist/vendor/ahp/channels-terminal/state.js.map +1 -0
- package/dist/vendor/ahp/commands.d.ts +14 -0
- package/dist/vendor/ahp/commands.d.ts.map +1 -0
- package/dist/vendor/ahp/commands.js +15 -0
- package/dist/vendor/ahp/commands.js.map +1 -0
- package/dist/vendor/ahp/common/actions.d.ts +107 -0
- package/dist/vendor/ahp/common/actions.d.ts.map +1 -0
- package/dist/vendor/ahp/common/actions.js +77 -0
- package/dist/vendor/ahp/common/actions.js.map +1 -0
- package/dist/vendor/ahp/common/commands.d.ts +594 -0
- package/dist/vendor/ahp/common/commands.d.ts.map +1 -0
- package/dist/vendor/ahp/common/commands.js +32 -0
- package/dist/vendor/ahp/common/commands.js.map +1 -0
- package/dist/vendor/ahp/common/errors.d.ts +184 -0
- package/dist/vendor/ahp/common/errors.d.ts.map +1 -0
- package/dist/vendor/ahp/common/errors.js +82 -0
- package/dist/vendor/ahp/common/errors.js.map +1 -0
- package/dist/vendor/ahp/common/messages.d.ts +330 -0
- package/dist/vendor/ahp/common/messages.d.ts.map +1 -0
- package/dist/vendor/ahp/common/messages.js +11 -0
- package/dist/vendor/ahp/common/messages.js.map +1 -0
- package/dist/vendor/ahp/common/notifications.d.ts +58 -0
- package/dist/vendor/ahp/common/notifications.d.ts.map +1 -0
- package/dist/vendor/ahp/common/notifications.js +20 -0
- package/dist/vendor/ahp/common/notifications.js.map +1 -0
- package/dist/vendor/ahp/common/reducer-helpers.d.ts +24 -0
- package/dist/vendor/ahp/common/reducer-helpers.d.ts.map +1 -0
- package/dist/vendor/ahp/common/reducer-helpers.js +31 -0
- package/dist/vendor/ahp/common/reducer-helpers.js.map +1 -0
- package/dist/vendor/ahp/common/state.d.ts +286 -0
- package/dist/vendor/ahp/common/state.d.ts.map +1 -0
- package/dist/vendor/ahp/common/state.js +11 -0
- package/dist/vendor/ahp/common/state.js.map +1 -0
- package/dist/vendor/ahp/errors.d.ts +8 -0
- package/dist/vendor/ahp/errors.d.ts.map +1 -0
- package/dist/vendor/ahp/errors.js +9 -0
- package/dist/vendor/ahp/errors.js.map +1 -0
- package/dist/vendor/ahp/index.d.ts +24 -0
- package/dist/vendor/ahp/index.d.ts.map +1 -0
- package/dist/vendor/ahp/index.js +21 -0
- package/dist/vendor/ahp/index.js.map +1 -0
- package/dist/vendor/ahp/messages.d.ts +8 -0
- package/dist/vendor/ahp/messages.d.ts.map +1 -0
- package/dist/vendor/ahp/messages.js +9 -0
- package/dist/vendor/ahp/messages.js.map +1 -0
- package/dist/vendor/ahp/notifications.d.ts +11 -0
- package/dist/vendor/ahp/notifications.d.ts.map +1 -0
- package/dist/vendor/ahp/notifications.js +12 -0
- package/dist/vendor/ahp/notifications.js.map +1 -0
- package/dist/vendor/ahp/reducers.d.ts +12 -0
- package/dist/vendor/ahp/reducers.d.ts.map +1 -0
- package/dist/vendor/ahp/reducers.js +13 -0
- package/dist/vendor/ahp/reducers.js.map +1 -0
- package/dist/vendor/ahp/state.d.ts +15 -0
- package/dist/vendor/ahp/state.d.ts.map +1 -0
- package/dist/vendor/ahp/state.js +16 -0
- package/dist/vendor/ahp/state.js.map +1 -0
- package/dist/vendor/ahp/version/message-checks.d.ts +15 -0
- package/dist/vendor/ahp/version/message-checks.d.ts.map +1 -0
- package/dist/vendor/ahp/version/message-checks.js +16 -0
- package/dist/vendor/ahp/version/message-checks.js.map +1 -0
- package/dist/vendor/ahp/version/registry.d.ts +56 -0
- package/dist/vendor/ahp/version/registry.d.ts.map +1 -0
- package/dist/vendor/ahp/version/registry.js +138 -0
- package/dist/vendor/ahp/version/registry.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Codes — Source of truth for all AHP error code definitions.
|
|
3
|
+
*
|
|
4
|
+
* @module common/errors
|
|
5
|
+
* @description AHP uses JSON-RPC 2.0 error codes. In addition to the standard
|
|
6
|
+
* JSON-RPC codes, AHP defines application-specific error codes in the `-32000`
|
|
7
|
+
* to `-32099` range.
|
|
8
|
+
*/
|
|
9
|
+
import type { ProtectedResourceMetadata } from './state.js';
|
|
10
|
+
import type { ResourceRequestParams } from './commands.js';
|
|
11
|
+
/**
|
|
12
|
+
* Standard JSON-RPC 2.0 error codes.
|
|
13
|
+
*
|
|
14
|
+
* @category Standard JSON-RPC Codes
|
|
15
|
+
*/
|
|
16
|
+
export declare const JsonRpcErrorCodes: {
|
|
17
|
+
/** Invalid JSON */
|
|
18
|
+
readonly ParseError: -32700;
|
|
19
|
+
/** Not a valid JSON-RPC request */
|
|
20
|
+
readonly InvalidRequest: -32600;
|
|
21
|
+
/** Unknown method name */
|
|
22
|
+
readonly MethodNotFound: -32601;
|
|
23
|
+
/** Invalid method parameters */
|
|
24
|
+
readonly InvalidParams: -32602;
|
|
25
|
+
/** Unspecified server error */
|
|
26
|
+
readonly InternalError: -32603;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* AHP application-specific error codes.
|
|
30
|
+
*
|
|
31
|
+
* @category AHP Application Codes
|
|
32
|
+
* @version 1
|
|
33
|
+
*/
|
|
34
|
+
export declare const AhpErrorCodes: {
|
|
35
|
+
/** The referenced session URI does not exist */
|
|
36
|
+
readonly SessionNotFound: -32001;
|
|
37
|
+
/** The requested agent provider is not registered */
|
|
38
|
+
readonly ProviderNotFound: -32002;
|
|
39
|
+
/** A session with the given URI already exists */
|
|
40
|
+
readonly SessionAlreadyExists: -32003;
|
|
41
|
+
/** The operation requires no active turn, but one is in progress */
|
|
42
|
+
readonly TurnInProgress: -32004;
|
|
43
|
+
/**
|
|
44
|
+
* The server cannot speak any of the protocol versions offered by the
|
|
45
|
+
* client in `InitializeParams.protocolVersions`. The `data` field of the
|
|
46
|
+
* JSON-RPC error MAY be an `UnsupportedProtocolVersionErrorData` advertising
|
|
47
|
+
* the protocol versions the server is willing to speak.
|
|
48
|
+
*/
|
|
49
|
+
readonly UnsupportedProtocolVersion: -32005;
|
|
50
|
+
/** The requested content URI does not exist */
|
|
51
|
+
readonly ContentNotFound: -32006;
|
|
52
|
+
/**
|
|
53
|
+
* A command failed because the client has not authenticated for a required
|
|
54
|
+
* protected resource. The `data` field of the JSON-RPC error MUST be an
|
|
55
|
+
* `AuthRequiredErrorData` describing the resources that require
|
|
56
|
+
* authentication.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link /specification/authentication | Authentication}
|
|
59
|
+
*/
|
|
60
|
+
readonly AuthRequired: -32007;
|
|
61
|
+
/** The requested file, folder, or URI does not exist */
|
|
62
|
+
readonly NotFound: -32008;
|
|
63
|
+
/**
|
|
64
|
+
* The client is not permitted to access the requested resource.
|
|
65
|
+
*
|
|
66
|
+
* Servers SHOULD return this when a client attempts to read or browse
|
|
67
|
+
* a path outside the allowed set (e.g. outside the session's working
|
|
68
|
+
* directory or workspace roots).
|
|
69
|
+
*
|
|
70
|
+
* The `data` field of the JSON-RPC error MAY be a
|
|
71
|
+
* `PermissionDeniedErrorData` advertising a `resourceRequest` that, if
|
|
72
|
+
* granted, would unlock the operation.
|
|
73
|
+
*/
|
|
74
|
+
readonly PermissionDenied: -32009;
|
|
75
|
+
/**
|
|
76
|
+
* The target resource already exists and the operation does not allow
|
|
77
|
+
* overwriting (e.g. `resourceWrite` with `createOnly: true`).
|
|
78
|
+
*/
|
|
79
|
+
readonly AlreadyExists: -32010;
|
|
80
|
+
};
|
|
81
|
+
/** Union type of all AHP application error codes. */
|
|
82
|
+
export type AhpErrorCode = (typeof AhpErrorCodes)[keyof typeof AhpErrorCodes];
|
|
83
|
+
/** Union type of all JSON-RPC error codes. */
|
|
84
|
+
export type JsonRpcErrorCode = (typeof JsonRpcErrorCodes)[keyof typeof JsonRpcErrorCodes];
|
|
85
|
+
/**
|
|
86
|
+
* Details carried in the `data` field of an `AuthRequired` (-32007) error.
|
|
87
|
+
*
|
|
88
|
+
* Wraps the protected resource list in `{ resources: [...] }` rather than
|
|
89
|
+
* returning a bare array, so additional fields can be added in future
|
|
90
|
+
* versions without breaking the wire shape.
|
|
91
|
+
*
|
|
92
|
+
* @category Error Details
|
|
93
|
+
* @version 1
|
|
94
|
+
*/
|
|
95
|
+
export interface AuthRequiredErrorData {
|
|
96
|
+
/** Protected resources that require authentication. */
|
|
97
|
+
resources: ProtectedResourceMetadata[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Details carried in the `data` field of a `PermissionDenied` (-32009) error.
|
|
101
|
+
*
|
|
102
|
+
* The receiver MAY advertise a `resourceRequest` payload describing the
|
|
103
|
+
* access that, if granted, would unlock the operation. The caller MAY then
|
|
104
|
+
* issue `resourceRequest` with that payload to negotiate access.
|
|
105
|
+
*
|
|
106
|
+
* @category Error Details
|
|
107
|
+
* @version 1
|
|
108
|
+
*/
|
|
109
|
+
export interface PermissionDeniedErrorData {
|
|
110
|
+
/**
|
|
111
|
+
* The resource access that, if granted via `resourceRequest`, would unlock
|
|
112
|
+
* the operation. Omitted when no specific access grant would resolve the
|
|
113
|
+
* denial (for example, when the resource is fundamentally inaccessible).
|
|
114
|
+
*/
|
|
115
|
+
request?: ResourceRequestParams;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Details carried in the `data` field of an `UnsupportedProtocolVersion`
|
|
119
|
+
* (-32005) error.
|
|
120
|
+
*
|
|
121
|
+
* @category Error Details
|
|
122
|
+
* @version 1
|
|
123
|
+
*/
|
|
124
|
+
export interface UnsupportedProtocolVersionErrorData {
|
|
125
|
+
/**
|
|
126
|
+
* Protocol versions the server is willing to speak.
|
|
127
|
+
*
|
|
128
|
+
* Each entry is either a [SemVer](https://semver.org) `MAJOR.MINOR.PATCH`
|
|
129
|
+
* string (e.g. `"0.1.0"`) or a [SemVer range](https://semver.org/#spec-item-11)
|
|
130
|
+
* constraint (e.g. `">=0.1.0 <0.3.0"` or `"^0.2.0"`).
|
|
131
|
+
*/
|
|
132
|
+
supportedVersions: string[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Maps each AHP error code that carries structured `data` to the type of
|
|
136
|
+
* that data.
|
|
137
|
+
*
|
|
138
|
+
* Error codes not present in this map either have no `data` payload or
|
|
139
|
+
* carry an unspecified payload that callers SHOULD treat as `unknown`.
|
|
140
|
+
*
|
|
141
|
+
* @category Error Details
|
|
142
|
+
* @version 1
|
|
143
|
+
*/
|
|
144
|
+
export interface AhpErrorDetailsMap {
|
|
145
|
+
[AhpErrorCodes.AuthRequired]: AuthRequiredErrorData;
|
|
146
|
+
[AhpErrorCodes.PermissionDenied]: PermissionDeniedErrorData;
|
|
147
|
+
[AhpErrorCodes.UnsupportedProtocolVersion]: UnsupportedProtocolVersionErrorData;
|
|
148
|
+
}
|
|
149
|
+
/** AHP error codes that carry a structured `data` payload. */
|
|
150
|
+
export type AhpErrorCodeWithData = keyof AhpErrorDetailsMap;
|
|
151
|
+
/**
|
|
152
|
+
* A typed JSON-RPC error object whose `data` is narrowed by `code`.
|
|
153
|
+
*
|
|
154
|
+
* Distributes over the `AhpErrorCode` union so narrowing on `code` reveals
|
|
155
|
+
* the precise `data` type. For codes listed in {@link AhpErrorDetailsMap}
|
|
156
|
+
* `data` is required; for all other codes `data` is an optional `unknown`.
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* function handle(err: AhpError) {
|
|
160
|
+
* if (err.code === AhpErrorCodes.PermissionDenied) {
|
|
161
|
+
* err.data.request; // typed as ResourceRequestParams | undefined
|
|
162
|
+
* }
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @category Error Details
|
|
167
|
+
* @version 1
|
|
168
|
+
*/
|
|
169
|
+
export type AhpError<C extends AhpErrorCode = AhpErrorCode> = C extends AhpErrorCode ? C extends keyof AhpErrorDetailsMap ? {
|
|
170
|
+
/** The error code. */
|
|
171
|
+
readonly code: C;
|
|
172
|
+
/** Human-readable error message. */
|
|
173
|
+
readonly message: string;
|
|
174
|
+
/** Structured detail payload mandated by `AhpErrorDetailsMap`. */
|
|
175
|
+
readonly data: AhpErrorDetailsMap[C];
|
|
176
|
+
} : {
|
|
177
|
+
/** The error code. */
|
|
178
|
+
readonly code: C;
|
|
179
|
+
/** Human-readable error message. */
|
|
180
|
+
readonly message: string;
|
|
181
|
+
/** Optional, unspecified detail payload. */
|
|
182
|
+
readonly data?: unknown;
|
|
183
|
+
} : never;
|
|
184
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../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C5D,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAE,mCAAmC,CAAC;CACjF;AAED,8DAA8D;AAC9D,MAAM,MAAM,oBAAoB,GAAG,MAAM,kBAAkB,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IACxD,CAAC,SAAS,YAAY,GAClB,CAAC,SAAS,MAAM,kBAAkB,GAChC;IACA,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;CACtC,GACC;IACA,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB,GACD,KAAK,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint-disable -- vendored third-party code, see SOURCE.md */
|
|
2
|
+
/**
|
|
3
|
+
* Error Codes — Source of truth for all AHP error code definitions.
|
|
4
|
+
*
|
|
5
|
+
* @module common/errors
|
|
6
|
+
* @description AHP uses JSON-RPC 2.0 error codes. In addition to the standard
|
|
7
|
+
* JSON-RPC codes, AHP defines application-specific error codes in the `-32000`
|
|
8
|
+
* to `-32099` range.
|
|
9
|
+
*/
|
|
10
|
+
// ─── Standard JSON-RPC Codes ─────────────────────────────────────────────────
|
|
11
|
+
/**
|
|
12
|
+
* Standard JSON-RPC 2.0 error codes.
|
|
13
|
+
*
|
|
14
|
+
* @category Standard JSON-RPC Codes
|
|
15
|
+
*/
|
|
16
|
+
export const JsonRpcErrorCodes = {
|
|
17
|
+
/** Invalid JSON */
|
|
18
|
+
ParseError: -32700,
|
|
19
|
+
/** Not a valid JSON-RPC request */
|
|
20
|
+
InvalidRequest: -32600,
|
|
21
|
+
/** Unknown method name */
|
|
22
|
+
MethodNotFound: -32601,
|
|
23
|
+
/** Invalid method parameters */
|
|
24
|
+
InvalidParams: -32602,
|
|
25
|
+
/** Unspecified server error */
|
|
26
|
+
InternalError: -32603,
|
|
27
|
+
};
|
|
28
|
+
// ─── AHP Application Codes ──────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* AHP application-specific error codes.
|
|
31
|
+
*
|
|
32
|
+
* @category AHP Application Codes
|
|
33
|
+
* @version 1
|
|
34
|
+
*/
|
|
35
|
+
export const AhpErrorCodes = {
|
|
36
|
+
/** The referenced session URI does not exist */
|
|
37
|
+
SessionNotFound: -32001,
|
|
38
|
+
/** The requested agent provider is not registered */
|
|
39
|
+
ProviderNotFound: -32002,
|
|
40
|
+
/** A session with the given URI already exists */
|
|
41
|
+
SessionAlreadyExists: -32003,
|
|
42
|
+
/** The operation requires no active turn, but one is in progress */
|
|
43
|
+
TurnInProgress: -32004,
|
|
44
|
+
/**
|
|
45
|
+
* The server cannot speak any of the protocol versions offered by the
|
|
46
|
+
* client in `InitializeParams.protocolVersions`. The `data` field of the
|
|
47
|
+
* JSON-RPC error MAY be an `UnsupportedProtocolVersionErrorData` advertising
|
|
48
|
+
* the protocol versions the server is willing to speak.
|
|
49
|
+
*/
|
|
50
|
+
UnsupportedProtocolVersion: -32005,
|
|
51
|
+
/** The requested content URI does not exist */
|
|
52
|
+
ContentNotFound: -32006,
|
|
53
|
+
/**
|
|
54
|
+
* A command failed because the client has not authenticated for a required
|
|
55
|
+
* protected resource. The `data` field of the JSON-RPC error MUST be an
|
|
56
|
+
* `AuthRequiredErrorData` describing the resources that require
|
|
57
|
+
* authentication.
|
|
58
|
+
*
|
|
59
|
+
* @see {@link /specification/authentication | Authentication}
|
|
60
|
+
*/
|
|
61
|
+
AuthRequired: -32007,
|
|
62
|
+
/** The requested file, folder, or URI does not exist */
|
|
63
|
+
NotFound: -32008,
|
|
64
|
+
/**
|
|
65
|
+
* The client is not permitted to access the requested resource.
|
|
66
|
+
*
|
|
67
|
+
* Servers SHOULD return this when a client attempts to read or browse
|
|
68
|
+
* a path outside the allowed set (e.g. outside the session's working
|
|
69
|
+
* directory or workspace roots).
|
|
70
|
+
*
|
|
71
|
+
* The `data` field of the JSON-RPC error MAY be a
|
|
72
|
+
* `PermissionDeniedErrorData` advertising a `resourceRequest` that, if
|
|
73
|
+
* granted, would unlock the operation.
|
|
74
|
+
*/
|
|
75
|
+
PermissionDenied: -32009,
|
|
76
|
+
/**
|
|
77
|
+
* The target resource already exists and the operation does not allow
|
|
78
|
+
* overwriting (e.g. `resourceWrite` with `createOnly: true`).
|
|
79
|
+
*/
|
|
80
|
+
AlreadyExists: -32010,
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/vendor/ahp/common/errors.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE;;;;;;;GAOG;AAKH,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,mBAAmB;IACnB,UAAU,EAAE,CAAC,KAAK;IAClB,mCAAmC;IACnC,cAAc,EAAE,CAAC,KAAK;IACtB,0BAA0B;IAC1B,cAAc,EAAE,CAAC,KAAK;IACtB,gCAAgC;IAChC,aAAa,EAAE,CAAC,KAAK;IACrB,+BAA+B;IAC/B,aAAa,EAAE,CAAC,KAAK;CACb,CAAC;AAEX,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,gDAAgD;IAChD,eAAe,EAAE,CAAC,KAAK;IACvB,qDAAqD;IACrD,gBAAgB,EAAE,CAAC,KAAK;IACxB,kDAAkD;IAClD,oBAAoB,EAAE,CAAC,KAAK;IAC5B,oEAAoE;IACpE,cAAc,EAAE,CAAC,KAAK;IACtB;;;;;OAKG;IACH,0BAA0B,EAAE,CAAC,KAAK;IAClC,+CAA+C;IAC/C,eAAe,EAAE,CAAC,KAAK;IACvB;;;;;;;OAOG;IACH,YAAY,EAAE,CAAC,KAAK;IACpB,wDAAwD;IACxD,QAAQ,EAAE,CAAC,KAAK;IAChB;;;;;;;;;;OAUG;IACH,gBAAgB,EAAE,CAAC,KAAK;IACxB;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK;CACb,CAAC"}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Types — Fully typed JSON-RPC message definitions for the AHP wire protocol.
|
|
3
|
+
*
|
|
4
|
+
* @module common/messages
|
|
5
|
+
* @description Typed JSON-RPC request, response, and notification types for all
|
|
6
|
+
* AHP methods. Narrowing on the `method` field gives fully typed `params` and
|
|
7
|
+
* result types.
|
|
8
|
+
*/
|
|
9
|
+
import type { InitializeParams, InitializeResult, PingParams, ReconnectParams, ReconnectResult, SubscribeParams, SubscribeResult, ResourceReadParams, ResourceReadResult, ResourceWriteParams, ResourceWriteResult, ResourceListParams, ResourceListResult, ResourceCopyParams, ResourceCopyResult, ResourceDeleteParams, ResourceDeleteResult, ResourceMoveParams, ResourceMoveResult, ResourceRequestParams, ResourceRequestResult, UnsubscribeParams, DispatchActionParams, AuthenticateParams, AuthenticateResult } from './commands.js';
|
|
10
|
+
import type { ListSessionsParams, ListSessionsResult, ResolveSessionConfigParams, ResolveSessionConfigResult, SessionConfigCompletionsParams, SessionConfigCompletionsResult } from '../channels-root/commands.js';
|
|
11
|
+
import type { CreateSessionParams, DisposeSessionParams, FetchTurnsParams, FetchTurnsResult, CompletionsParams, CompletionsResult } from '../channels-session/commands.js';
|
|
12
|
+
import type { CreateTerminalParams, DisposeTerminalParams } from '../channels-terminal/commands.js';
|
|
13
|
+
import type { InvokeChangesetOperationParams, InvokeChangesetOperationResult } from '../channels-changeset/commands.js';
|
|
14
|
+
import type { ActionEnvelope } from './actions.js';
|
|
15
|
+
import type { SessionAddedParams, SessionRemovedParams, SessionSummaryChangedParams } from '../channels-root/notifications.js';
|
|
16
|
+
import type { AuthRequiredParams } from './notifications.js';
|
|
17
|
+
import type { OtlpExportLogsParams, OtlpExportTracesParams, OtlpExportMetricsParams } from '../channels-otlp/notifications.js';
|
|
18
|
+
import type { AhpError } from './errors.js';
|
|
19
|
+
/** A JSON-RPC request: has both `method` and `id`. */
|
|
20
|
+
export interface JsonRpcRequest {
|
|
21
|
+
readonly jsonrpc: '2.0';
|
|
22
|
+
readonly id: number;
|
|
23
|
+
readonly method: string;
|
|
24
|
+
readonly params?: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** A JSON-RPC success response. */
|
|
27
|
+
export interface JsonRpcSuccessResponse {
|
|
28
|
+
readonly jsonrpc: '2.0';
|
|
29
|
+
readonly id: number;
|
|
30
|
+
readonly result: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** A JSON-RPC error response. */
|
|
33
|
+
export interface JsonRpcErrorResponse {
|
|
34
|
+
readonly jsonrpc: '2.0';
|
|
35
|
+
readonly id: number;
|
|
36
|
+
readonly error: {
|
|
37
|
+
readonly code: number;
|
|
38
|
+
readonly message: string;
|
|
39
|
+
readonly data?: unknown;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A typed JSON-RPC error response whose error object is a fully typed
|
|
44
|
+
* {@link AhpError}. Useful when the caller knows the response is an AHP
|
|
45
|
+
* application error and wants `data` narrowed by `code`.
|
|
46
|
+
*/
|
|
47
|
+
export interface AhpErrorResponse {
|
|
48
|
+
readonly jsonrpc: '2.0';
|
|
49
|
+
readonly id: number;
|
|
50
|
+
readonly error: AhpError;
|
|
51
|
+
}
|
|
52
|
+
/** A JSON-RPC response (success or error). */
|
|
53
|
+
export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
|
54
|
+
/** A JSON-RPC notification: has `method` but no `id`. */
|
|
55
|
+
export interface JsonRpcNotification {
|
|
56
|
+
readonly jsonrpc: '2.0';
|
|
57
|
+
readonly method: string;
|
|
58
|
+
readonly params?: unknown;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Registry mapping each command method name to its params and result types.
|
|
62
|
+
*
|
|
63
|
+
* `CommandMap` covers methods that the client sends to the server. Methods
|
|
64
|
+
* that may also be initiated by the server are duplicated in
|
|
65
|
+
* {@link ServerCommandMap}; the entries in the two maps are kept identical.
|
|
66
|
+
*
|
|
67
|
+
* @category Commands
|
|
68
|
+
*/
|
|
69
|
+
export interface CommandMap {
|
|
70
|
+
'initialize': {
|
|
71
|
+
params: InitializeParams;
|
|
72
|
+
result: InitializeResult;
|
|
73
|
+
};
|
|
74
|
+
'ping': {
|
|
75
|
+
params: PingParams;
|
|
76
|
+
result: null;
|
|
77
|
+
};
|
|
78
|
+
'reconnect': {
|
|
79
|
+
params: ReconnectParams;
|
|
80
|
+
result: ReconnectResult;
|
|
81
|
+
};
|
|
82
|
+
'subscribe': {
|
|
83
|
+
params: SubscribeParams;
|
|
84
|
+
result: SubscribeResult;
|
|
85
|
+
};
|
|
86
|
+
'createSession': {
|
|
87
|
+
params: CreateSessionParams;
|
|
88
|
+
result: null;
|
|
89
|
+
};
|
|
90
|
+
'disposeSession': {
|
|
91
|
+
params: DisposeSessionParams;
|
|
92
|
+
result: null;
|
|
93
|
+
};
|
|
94
|
+
'createTerminal': {
|
|
95
|
+
params: CreateTerminalParams;
|
|
96
|
+
result: null;
|
|
97
|
+
};
|
|
98
|
+
'disposeTerminal': {
|
|
99
|
+
params: DisposeTerminalParams;
|
|
100
|
+
result: null;
|
|
101
|
+
};
|
|
102
|
+
'listSessions': {
|
|
103
|
+
params: ListSessionsParams;
|
|
104
|
+
result: ListSessionsResult;
|
|
105
|
+
};
|
|
106
|
+
'resourceRead': {
|
|
107
|
+
params: ResourceReadParams;
|
|
108
|
+
result: ResourceReadResult;
|
|
109
|
+
};
|
|
110
|
+
'resourceWrite': {
|
|
111
|
+
params: ResourceWriteParams;
|
|
112
|
+
result: ResourceWriteResult;
|
|
113
|
+
};
|
|
114
|
+
'resourceList': {
|
|
115
|
+
params: ResourceListParams;
|
|
116
|
+
result: ResourceListResult;
|
|
117
|
+
};
|
|
118
|
+
'resourceCopy': {
|
|
119
|
+
params: ResourceCopyParams;
|
|
120
|
+
result: ResourceCopyResult;
|
|
121
|
+
};
|
|
122
|
+
'resourceDelete': {
|
|
123
|
+
params: ResourceDeleteParams;
|
|
124
|
+
result: ResourceDeleteResult;
|
|
125
|
+
};
|
|
126
|
+
'resourceMove': {
|
|
127
|
+
params: ResourceMoveParams;
|
|
128
|
+
result: ResourceMoveResult;
|
|
129
|
+
};
|
|
130
|
+
'resourceRequest': {
|
|
131
|
+
params: ResourceRequestParams;
|
|
132
|
+
result: ResourceRequestResult;
|
|
133
|
+
};
|
|
134
|
+
'fetchTurns': {
|
|
135
|
+
params: FetchTurnsParams;
|
|
136
|
+
result: FetchTurnsResult;
|
|
137
|
+
};
|
|
138
|
+
'authenticate': {
|
|
139
|
+
params: AuthenticateParams;
|
|
140
|
+
result: AuthenticateResult;
|
|
141
|
+
};
|
|
142
|
+
'resolveSessionConfig': {
|
|
143
|
+
params: ResolveSessionConfigParams;
|
|
144
|
+
result: ResolveSessionConfigResult;
|
|
145
|
+
};
|
|
146
|
+
'sessionConfigCompletions': {
|
|
147
|
+
params: SessionConfigCompletionsParams;
|
|
148
|
+
result: SessionConfigCompletionsResult;
|
|
149
|
+
};
|
|
150
|
+
'completions': {
|
|
151
|
+
params: CompletionsParams;
|
|
152
|
+
result: CompletionsResult;
|
|
153
|
+
};
|
|
154
|
+
'invokeChangesetOperation': {
|
|
155
|
+
params: InvokeChangesetOperationParams;
|
|
156
|
+
result: InvokeChangesetOperationResult;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Registry mapping each server → client request method to its params and
|
|
161
|
+
* result types.
|
|
162
|
+
*
|
|
163
|
+
* Bidirectional commands (currently only `resourceRequest`) appear in both
|
|
164
|
+
* {@link CommandMap} and `ServerCommandMap` with identical params/result
|
|
165
|
+
* shapes. The receiver decides whether to allow, deny, or prompt for the
|
|
166
|
+
* requested operation regardless of which peer initiated it.
|
|
167
|
+
*
|
|
168
|
+
* @category Commands
|
|
169
|
+
*/
|
|
170
|
+
export interface ServerCommandMap {
|
|
171
|
+
'resourceRequest': {
|
|
172
|
+
params: ResourceRequestParams;
|
|
173
|
+
result: ResourceRequestResult;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Registry mapping each client → server notification method to its params type.
|
|
178
|
+
*
|
|
179
|
+
* Every notification's params MUST carry a top-level `channel: URI` so that
|
|
180
|
+
* the server can route the message to the correct subscription. See
|
|
181
|
+
* {@link UnsubscribeParams} for the canonical "base" shape.
|
|
182
|
+
*
|
|
183
|
+
* @category Notifications
|
|
184
|
+
*/
|
|
185
|
+
export interface ClientNotificationMap {
|
|
186
|
+
'unsubscribe': {
|
|
187
|
+
params: UnsubscribeParams;
|
|
188
|
+
};
|
|
189
|
+
'dispatchAction': {
|
|
190
|
+
params: DispatchActionParams;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Registry mapping each server → client notification method to its params type.
|
|
195
|
+
*
|
|
196
|
+
* Every notification's params MUST carry a top-level `channel: URI` so that
|
|
197
|
+
* the client can dispatch the message to the right subscription.
|
|
198
|
+
*
|
|
199
|
+
* @category Notifications
|
|
200
|
+
*/
|
|
201
|
+
export interface ServerNotificationMap {
|
|
202
|
+
'action': {
|
|
203
|
+
params: ActionEnvelope;
|
|
204
|
+
};
|
|
205
|
+
'root/sessionAdded': {
|
|
206
|
+
params: SessionAddedParams;
|
|
207
|
+
};
|
|
208
|
+
'root/sessionRemoved': {
|
|
209
|
+
params: SessionRemovedParams;
|
|
210
|
+
};
|
|
211
|
+
'root/sessionSummaryChanged': {
|
|
212
|
+
params: SessionSummaryChangedParams;
|
|
213
|
+
};
|
|
214
|
+
'auth/required': {
|
|
215
|
+
params: AuthRequiredParams;
|
|
216
|
+
};
|
|
217
|
+
'otlp/exportLogs': {
|
|
218
|
+
params: OtlpExportLogsParams;
|
|
219
|
+
};
|
|
220
|
+
'otlp/exportTraces': {
|
|
221
|
+
params: OtlpExportTracesParams;
|
|
222
|
+
};
|
|
223
|
+
'otlp/exportMetrics': {
|
|
224
|
+
params: OtlpExportMetricsParams;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A fully typed JSON-RPC request for a specific AHP command.
|
|
229
|
+
*
|
|
230
|
+
* When used as a union (default generic), narrowing on `method` gives typed `params`:
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* function handle(req: AhpRequest) {
|
|
234
|
+
* if (req.method === 'fetchTurns') {
|
|
235
|
+
* req.params.session; // typed as URI
|
|
236
|
+
* }
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* Defaults to client → server requests ({@link CommandMap}). Use
|
|
241
|
+
* {@link AhpServerRequest} for server → client requests.
|
|
242
|
+
*/
|
|
243
|
+
export type AhpRequest<M extends keyof CommandMap = keyof CommandMap> = M extends unknown ? {
|
|
244
|
+
readonly jsonrpc: '2.0';
|
|
245
|
+
readonly id: number;
|
|
246
|
+
readonly method: M;
|
|
247
|
+
readonly params: CommandMap[M]['params'];
|
|
248
|
+
} : never;
|
|
249
|
+
/**
|
|
250
|
+
* A fully typed JSON-RPC request initiated by the server. Identical in shape
|
|
251
|
+
* to {@link AhpRequest} but parameterised over {@link ServerCommandMap}.
|
|
252
|
+
*/
|
|
253
|
+
export type AhpServerRequest<M extends keyof ServerCommandMap = keyof ServerCommandMap> = M extends unknown ? {
|
|
254
|
+
readonly jsonrpc: '2.0';
|
|
255
|
+
readonly id: number;
|
|
256
|
+
readonly method: M;
|
|
257
|
+
readonly params: ServerCommandMap[M]['params'];
|
|
258
|
+
} : never;
|
|
259
|
+
/**
|
|
260
|
+
* A fully typed JSON-RPC success response for a specific AHP command.
|
|
261
|
+
*
|
|
262
|
+
* Since JSON-RPC responses do not carry `method`, use this with an explicit
|
|
263
|
+
* generic parameter when you know the method from the associated request:
|
|
264
|
+
*
|
|
265
|
+
* ```ts
|
|
266
|
+
* const result: AhpSuccessResponse<'fetchTurns'> = ...;
|
|
267
|
+
* result.result.turns; // typed as Turn[]
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export type AhpSuccessResponse<M extends keyof CommandMap = keyof CommandMap> = M extends unknown ? {
|
|
271
|
+
readonly jsonrpc: '2.0';
|
|
272
|
+
readonly id: number;
|
|
273
|
+
readonly result: CommandMap[M]['result'];
|
|
274
|
+
} : never;
|
|
275
|
+
/** Typed JSON-RPC response (success with known result type, or error). */
|
|
276
|
+
export type AhpResponse<M extends keyof CommandMap = keyof CommandMap> = AhpSuccessResponse<M> | JsonRpcErrorResponse;
|
|
277
|
+
/**
|
|
278
|
+
* A fully typed JSON-RPC success response for a server → client request
|
|
279
|
+
* ({@link ServerCommandMap}).
|
|
280
|
+
*/
|
|
281
|
+
export type AhpServerSuccessResponse<M extends keyof ServerCommandMap = keyof ServerCommandMap> = M extends unknown ? {
|
|
282
|
+
readonly jsonrpc: '2.0';
|
|
283
|
+
readonly id: number;
|
|
284
|
+
readonly result: ServerCommandMap[M]['result'];
|
|
285
|
+
} : never;
|
|
286
|
+
/** Typed JSON-RPC response to a server → client request. */
|
|
287
|
+
export type AhpServerResponse<M extends keyof ServerCommandMap = keyof ServerCommandMap> = AhpServerSuccessResponse<M> | JsonRpcErrorResponse;
|
|
288
|
+
/** A client → server notification. */
|
|
289
|
+
export type AhpClientNotification<M extends keyof ClientNotificationMap = keyof ClientNotificationMap> = M extends unknown ? {
|
|
290
|
+
readonly jsonrpc: '2.0';
|
|
291
|
+
readonly method: M;
|
|
292
|
+
readonly params: ClientNotificationMap[M]['params'];
|
|
293
|
+
} : never;
|
|
294
|
+
/** A server → client notification. */
|
|
295
|
+
export type AhpServerNotification<M extends keyof ServerNotificationMap = keyof ServerNotificationMap> = M extends unknown ? {
|
|
296
|
+
readonly jsonrpc: '2.0';
|
|
297
|
+
readonly method: M;
|
|
298
|
+
readonly params: ServerNotificationMap[M]['params'];
|
|
299
|
+
} : never;
|
|
300
|
+
/**
|
|
301
|
+
* A fully typed JSON-RPC notification — either direction.
|
|
302
|
+
*
|
|
303
|
+
* The client → server `dispatchAction` method and the server → client
|
|
304
|
+
* `action` method are distinct entries in the registries; their params have
|
|
305
|
+
* unrelated shapes ({@link DispatchActionParams} vs {@link ActionEnvelope}).
|
|
306
|
+
*/
|
|
307
|
+
export type AhpNotification = AhpClientNotification | AhpServerNotification;
|
|
308
|
+
/**
|
|
309
|
+
* Discriminated union of all AHP protocol messages.
|
|
310
|
+
*
|
|
311
|
+
* Narrow using standard JSON-RPC structure:
|
|
312
|
+
* - Has `method` + `id` → request ({@link AhpRequest} or {@link AhpServerRequest})
|
|
313
|
+
* - Has `method`, no `id` → notification ({@link AhpNotification})
|
|
314
|
+
* - Has `result` or `error` + `id` → response ({@link AhpResponse})
|
|
315
|
+
*
|
|
316
|
+
* Then narrow on `method` for fully typed params:
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* function dispatch(msg: ProtocolMessage) {
|
|
320
|
+
* if ('method' in msg && 'id' in msg) {
|
|
321
|
+
* // msg is AhpRequest | AhpServerRequest
|
|
322
|
+
* if (msg.method === 'fetchTurns') {
|
|
323
|
+
* msg.params.session; // URI
|
|
324
|
+
* }
|
|
325
|
+
* }
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
export type ProtocolMessage = AhpRequest | AhpServerRequest | AhpSuccessResponse | AhpServerSuccessResponse | JsonRpcErrorResponse | AhpNotification;
|
|
330
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/vendor/ahp/common/messages.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aA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,GAAG,KAAK,CAAC;AAEZ,sCAAsC;AACtC,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,MAAM,qBAAqB,GAAG,MAAM,qBAAqB,IACnG,CAAC,SAAS,OAAO,GAAG;IAClB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACrD,GAAG,KAAK,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAI5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,gBAAgB,GAChB,kBAAkB,GAClB,wBAAwB,GACxB,oBAAoB,GACpB,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* eslint-disable -- vendored third-party code, see SOURCE.md */
|
|
2
|
+
/**
|
|
3
|
+
* Message Types — Fully typed JSON-RPC message definitions for the AHP wire protocol.
|
|
4
|
+
*
|
|
5
|
+
* @module common/messages
|
|
6
|
+
* @description Typed JSON-RPC request, response, and notification types for all
|
|
7
|
+
* AHP methods. Narrowing on the `method` field gives fully typed `params` and
|
|
8
|
+
* result types.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/vendor/ahp/common/messages.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE;;;;;;;GAOG"}
|