@sess.si/sdk 0.1.0-rc.8 → 0.1.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/CHANGELOG.md +66 -9
- package/NOTICE +1 -1
- package/README.md +92 -16
- package/dist/ask.d.ts +0 -1
- package/dist/ask.js +0 -1
- package/dist/cli/main.d.ts +0 -1
- package/dist/cli/main.js +0 -1
- package/dist/cli/verify.d.ts +0 -1
- package/dist/cli/verify.js +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -1
- package/dist/commerce/builders.d.ts +99 -0
- package/dist/commerce/builders.js +208 -0
- package/dist/commerce/currency.d.ts +4 -0
- package/dist/commerce/currency.js +25 -0
- package/dist/commerce/items.d.ts +119 -0
- package/dist/commerce/items.js +280 -0
- package/dist/commerce/lint.d.ts +16 -0
- package/dist/commerce/lint.js +56 -0
- package/dist/errors.d.ts +5 -2
- package/dist/errors.js +15 -25
- package/dist/generated/openapi.d.ts +12 -13
- package/dist/generated/openapi.js +0 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -1
- package/dist/internal/decode.d.ts +0 -1
- package/dist/internal/decode.js +9 -2
- package/dist/internal/json.d.ts +0 -1
- package/dist/internal/json.js +0 -1
- package/dist/internal/time.d.ts +0 -1
- package/dist/internal/time.js +0 -1
- package/dist/internal/version.d.ts +2 -0
- package/dist/internal/version.js +2 -0
- package/dist/polling.d.ts +0 -1
- package/dist/polling.js +0 -1
- package/dist/qr/encoder.d.ts +0 -1
- package/dist/qr/encoder.js +0 -1
- package/dist/qr/index.d.ts +0 -1
- package/dist/qr/index.js +0 -1
- package/dist/receipts/bundle.d.ts +0 -1
- package/dist/receipts/bundle.js +0 -1
- package/dist/receipts/index.d.ts +0 -1
- package/dist/receipts/index.js +0 -1
- package/dist/receipts/json.d.ts +0 -1
- package/dist/receipts/json.js +0 -1
- package/dist/receipts/key-cache.d.ts +0 -1
- package/dist/receipts/key-cache.js +0 -1
- package/dist/receipts/renderers.d.ts +0 -1
- package/dist/receipts/renderers.js +1 -2
- package/dist/receipts/resource.d.ts +0 -1
- package/dist/receipts/resource.js +0 -1
- package/dist/receipts/verify.d.ts +0 -1
- package/dist/receipts/verify.js +0 -1
- package/dist/sessions.d.ts +0 -1
- package/dist/sessions.js +0 -1
- package/dist/transport.d.ts +0 -1
- package/dist/transport.js +35 -5
- package/dist/types.d.ts +56 -2
- package/dist/types.js +0 -1
- package/dist/webhook-resource.d.ts +0 -1
- package/dist/webhook-resource.js +0 -1
- package/dist/webhooks/index.d.ts +0 -1
- package/dist/webhooks/index.js +0 -1
- package/package.json +8 -3
- package/dist/ask.d.ts.map +0 -1
- package/dist/ask.js.map +0 -1
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/verify.d.ts.map +0 -1
- package/dist/cli/verify.js.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/generated/openapi.d.ts.map +0 -1
- package/dist/generated/openapi.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/decode.d.ts.map +0 -1
- package/dist/internal/decode.js.map +0 -1
- package/dist/internal/json.d.ts.map +0 -1
- package/dist/internal/json.js.map +0 -1
- package/dist/internal/time.d.ts.map +0 -1
- package/dist/internal/time.js.map +0 -1
- package/dist/polling.d.ts.map +0 -1
- package/dist/polling.js.map +0 -1
- package/dist/qr/encoder.d.ts.map +0 -1
- package/dist/qr/encoder.js.map +0 -1
- package/dist/qr/index.d.ts.map +0 -1
- package/dist/qr/index.js.map +0 -1
- package/dist/receipts/bundle.d.ts.map +0 -1
- package/dist/receipts/bundle.js.map +0 -1
- package/dist/receipts/index.d.ts.map +0 -1
- package/dist/receipts/index.js.map +0 -1
- package/dist/receipts/json.d.ts.map +0 -1
- package/dist/receipts/json.js.map +0 -1
- package/dist/receipts/key-cache.d.ts.map +0 -1
- package/dist/receipts/key-cache.js.map +0 -1
- package/dist/receipts/renderers.d.ts.map +0 -1
- package/dist/receipts/renderers.js.map +0 -1
- package/dist/receipts/resource.d.ts.map +0 -1
- package/dist/receipts/resource.js.map +0 -1
- package/dist/receipts/verify.d.ts.map +0 -1
- package/dist/receipts/verify.js.map +0 -1
- package/dist/sessions.d.ts.map +0 -1
- package/dist/sessions.js.map +0 -1
- package/dist/transport.d.ts.map +0 -1
- package/dist/transport.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/webhook-resource.d.ts.map +0 -1
- package/dist/webhook-resource.js.map +0 -1
- package/dist/webhooks/index.d.ts.map +0 -1
- package/dist/webhooks/index.js.map +0 -1
- package/src/ask.ts +0 -683
- package/src/cli/main.ts +0 -8
- package/src/cli/verify.ts +0 -349
- package/src/client.ts +0 -55
- package/src/errors.ts +0 -127
- package/src/generated/openapi.ts +0 -8586
- package/src/index.ts +0 -5
- package/src/internal/decode.ts +0 -348
- package/src/internal/json.ts +0 -64
- package/src/internal/time.ts +0 -85
- package/src/polling.ts +0 -173
- package/src/qr/encoder.ts +0 -345
- package/src/qr/index.ts +0 -203
- package/src/receipts/bundle.ts +0 -547
- package/src/receipts/index.ts +0 -29
- package/src/receipts/json.ts +0 -168
- package/src/receipts/key-cache.ts +0 -143
- package/src/receipts/renderers.ts +0 -220
- package/src/receipts/resource.ts +0 -264
- package/src/receipts/verify.ts +0 -554
- package/src/sessions.ts +0 -238
- package/src/transport.ts +0 -566
- package/src/types.ts +0 -219
- package/src/webhook-resource.ts +0 -81
- package/src/webhooks/index.ts +0 -246
package/src/ask.ts
DELETED
|
@@ -1,683 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { inspect } from 'node:util';
|
|
3
|
-
import { SessError, lengthMessage } from './errors.js';
|
|
4
|
-
import { canonicalJson } from './receipts/json.js';
|
|
5
|
-
import type { ReceiptResource } from './receipts/resource.js';
|
|
6
|
-
import type { Sessions } from './sessions.js';
|
|
7
|
-
import { isInteractiveSession } from './types.js';
|
|
8
|
-
import type {
|
|
9
|
-
AcceptedResponse,
|
|
10
|
-
FieldSchema,
|
|
11
|
-
InteractiveInteraction,
|
|
12
|
-
InteractiveSession,
|
|
13
|
-
RequestOptions,
|
|
14
|
-
SurfaceComponent,
|
|
15
|
-
VersionedResult,
|
|
16
|
-
} from './types.js';
|
|
17
|
-
import { withSignal } from './internal/time.js';
|
|
18
|
-
|
|
19
|
-
interface AskFieldBase {
|
|
20
|
-
/** Key of this field in the answer: `^[a-z][a-z0-9_]{0,63}$`. */
|
|
21
|
-
readonly name: string;
|
|
22
|
-
/** What the field asks for: short, a few words; at most 60. Example: `Refund amount` */
|
|
23
|
-
readonly label: string;
|
|
24
|
-
/** Default `true`, except boolean fields (default `false`). */
|
|
25
|
-
readonly required?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* One simple field of a single question. Each kind compiles to the ordinary interactive field
|
|
29
|
-
* with the runtime names, limits and schema semantics. `default` is a proposal the person can
|
|
30
|
-
* correct; it must itself be a valid value.
|
|
31
|
-
*/
|
|
32
|
-
export type AskField =
|
|
33
|
-
| (AskFieldBase & { readonly type: 'text'; readonly multiline?: boolean; readonly default?: string })
|
|
34
|
-
| (AskFieldBase & {
|
|
35
|
-
readonly type: 'number' | 'integer';
|
|
36
|
-
readonly minimum?: number;
|
|
37
|
-
readonly maximum?: number;
|
|
38
|
-
readonly default?: number;
|
|
39
|
-
})
|
|
40
|
-
| (AskFieldBase & { readonly type: 'boolean'; readonly default?: boolean })
|
|
41
|
-
| (AskFieldBase & {
|
|
42
|
-
readonly type: 'choice';
|
|
43
|
-
/** 1–100 choices. The words shown for one choice: short; at most 60. Example: `Next Monday` */
|
|
44
|
-
readonly options: readonly [string, ...string[]];
|
|
45
|
-
readonly default?: string;
|
|
46
|
-
})
|
|
47
|
-
| (AskFieldBase & {
|
|
48
|
-
readonly type: 'multi_choice';
|
|
49
|
-
/** 1–100 choices. The words shown for one choice: short; at most 60. Example: `Next Monday` */
|
|
50
|
-
readonly options: readonly [string, ...string[]];
|
|
51
|
-
readonly default?: readonly string[];
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* A question plus typed fields: the same shape as the MCP `sess_ask` tool input. Lengths are in
|
|
56
|
-
* Unicode code points and are never truncated: a value over its limit throws a `SessError` whose
|
|
57
|
-
* `field`, `limit` and `length` say which value to shorten and to what.
|
|
58
|
-
*/
|
|
59
|
-
export interface AskInput<F extends readonly AskField[] = readonly AskField[]> {
|
|
60
|
-
/**
|
|
61
|
-
* The page's heading: a question or a task, about 40 characters; at most 80.
|
|
62
|
-
* Examples: `Approve the refund?`, `Pick a delivery date`
|
|
63
|
-
*/
|
|
64
|
-
readonly question: string;
|
|
65
|
-
/** Optional plain-text context shown above the fields, at most 4,000 characters. */
|
|
66
|
-
readonly details?: string;
|
|
67
|
-
/** A button: a verb, 1–3 words; at most 24. Default `Send`. Examples: `Approve`, `Send refund` */
|
|
68
|
-
readonly submit_label?: string;
|
|
69
|
-
/** One to twelve fields with unique names. */
|
|
70
|
-
readonly fields: F;
|
|
71
|
-
/**
|
|
72
|
-
* Advanced: how long the link stays open, in whole seconds from creation: from 30 up to your
|
|
73
|
-
* plan's link lifetime (Sess checks the ceiling). Absent: the plan's lifetime.
|
|
74
|
-
*/
|
|
75
|
-
readonly expires_in?: number;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type AskValue<T> = T extends { type: 'text' }
|
|
79
|
-
? string
|
|
80
|
-
: T extends { type: 'number' | 'integer' }
|
|
81
|
-
? number
|
|
82
|
-
: T extends { type: 'boolean' }
|
|
83
|
-
? boolean
|
|
84
|
-
: T extends { type: 'choice'; options: readonly (infer O extends string)[] }
|
|
85
|
-
? O
|
|
86
|
-
: T extends { type: 'multi_choice'; options: readonly (infer O extends string)[] }
|
|
87
|
-
? readonly O[]
|
|
88
|
-
: never;
|
|
89
|
-
/** A checkbox and a multiple choice always have a value; other fields only when required. */
|
|
90
|
-
type AlwaysPresent<T> = T extends { type: 'boolean' | 'multi_choice' }
|
|
91
|
-
? true
|
|
92
|
-
: T extends { required: false }
|
|
93
|
-
? false
|
|
94
|
-
: T extends { required: true }
|
|
95
|
-
? true
|
|
96
|
-
: T extends { required: boolean }
|
|
97
|
-
? false
|
|
98
|
-
: true;
|
|
99
|
-
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
100
|
-
/** The verified answer type inferred from the field definitions (and checked at runtime). */
|
|
101
|
-
export type AskAnswer<F extends readonly AskField[]> = Simplify<
|
|
102
|
-
{
|
|
103
|
-
readonly [P in F[number] as AlwaysPresent<P> extends true ? P['name'] : never]: AskValue<P>;
|
|
104
|
-
} & {
|
|
105
|
-
readonly [P in F[number] as AlwaysPresent<P> extends true ? never : P['name']]?: AskValue<P>;
|
|
106
|
-
}
|
|
107
|
-
>;
|
|
108
|
-
|
|
109
|
-
export interface AskOptions extends RequestOptions {
|
|
110
|
-
/** Trusted expected receipt audience for this question; defaults to the client configuration. */
|
|
111
|
-
expectedWorkspaceId?: string;
|
|
112
|
-
}
|
|
113
|
-
export interface AskAnswerOptions {
|
|
114
|
-
/** Total local wait for the person, default ten minutes. Ending it never closes the Session. */
|
|
115
|
-
timeoutMs?: number;
|
|
116
|
-
/** Polling interval, default 1,500 ms plus jitter, minimum 1,000 ms. */
|
|
117
|
-
intervalMs?: number;
|
|
118
|
-
/** Ends the local wait of this call only. */
|
|
119
|
-
signal?: AbortSignal;
|
|
120
|
-
}
|
|
121
|
-
/** One question: its private link now, its verified answer later. */
|
|
122
|
-
export interface AskHandle<T> {
|
|
123
|
-
/** Private bearer link for the person. Deliver it only to them; keep it out of logs. */
|
|
124
|
-
readonly link: string;
|
|
125
|
-
readonly sessionId: string;
|
|
126
|
-
/** The Surface revision of the question, for recovery through the advanced API. */
|
|
127
|
-
readonly revision: number;
|
|
128
|
-
/**
|
|
129
|
-
* When the link stops taking answers (`action_expires_at`, ISO 8601), as created. On a link of
|
|
130
|
-
* 20 hours or less the person may ask for more time, which moves it forward up to a fixed
|
|
131
|
-
* horizon; while the link is lapsed (past it, still extendable) `answer()` keeps waiting. An
|
|
132
|
-
* answer accepted before the end is still returned after it; with none, `answer()` ends with
|
|
133
|
-
* `wait_ended` code `LINK_EXPIRED` once the link has expired. Null only from a runtime that
|
|
134
|
-
* does not report it.
|
|
135
|
-
*/
|
|
136
|
-
readonly expiresAt: string | null;
|
|
137
|
-
/**
|
|
138
|
-
* Waits for the answer, verifies its signed receipt and exact bindings, checks that it is still
|
|
139
|
-
* the current step, completes (closes) the Session, then returns the typed answer.
|
|
140
|
-
*/
|
|
141
|
-
answer(options?: AskAnswerOptions): Promise<T>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** The runtime byte limit for one stored interaction. */
|
|
145
|
-
const SURFACE_LIMIT_BYTES = 131_072;
|
|
146
|
-
/**
|
|
147
|
-
* Sess's limits, in Unicode code points (the runtime checks the same numbers; nothing is ever
|
|
148
|
-
* truncated): the question (title) 80, details (a text component) 4,000, the submit button 24,
|
|
149
|
-
* field labels and options 60.
|
|
150
|
-
*/
|
|
151
|
-
const LIMITS = Object.freeze({
|
|
152
|
-
fields: 12,
|
|
153
|
-
options: 100,
|
|
154
|
-
depth: 8,
|
|
155
|
-
textMax: 4000,
|
|
156
|
-
question: 80,
|
|
157
|
-
details: 4000,
|
|
158
|
-
submitLabel: 24,
|
|
159
|
-
label: 60,
|
|
160
|
-
option: 60,
|
|
161
|
-
});
|
|
162
|
-
const TYPES = ['text', 'number', 'integer', 'boolean', 'choice', 'multi_choice'] as const;
|
|
163
|
-
type AskType = (typeof TYPES)[number];
|
|
164
|
-
const FIELD_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
165
|
-
const RESERVED = new Set(['__proto__', 'constructor', 'prototype']);
|
|
166
|
-
// Plain text: no C0/C1 controls other than tab and newline, no bidirectional overrides.
|
|
167
|
-
const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f--]/;
|
|
168
|
-
|
|
169
|
-
/** Internal compiled field: what an accepted answer is checked against. */
|
|
170
|
-
interface CompiledField {
|
|
171
|
-
name: string;
|
|
172
|
-
type: AskType;
|
|
173
|
-
required: boolean;
|
|
174
|
-
options?: readonly string[];
|
|
175
|
-
minimum?: number;
|
|
176
|
-
maximum?: number;
|
|
177
|
-
}
|
|
178
|
-
export interface CompiledAsk {
|
|
179
|
-
interaction: InteractiveInteraction;
|
|
180
|
-
fields: readonly CompiledField[];
|
|
181
|
-
/** The link lifetime in seconds, when the question set one. */
|
|
182
|
-
expiresIn?: number;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** The shortest link lifetime Sess accepts, in seconds (the ceiling is the plan's). */
|
|
186
|
-
export const LINK_LIFETIME_FLOOR_SECONDS = 30;
|
|
187
|
-
|
|
188
|
-
type Json = string | number | boolean | null | Json[] | { [key: string]: Json };
|
|
189
|
-
type JsonObject = { [key: string]: Json };
|
|
190
|
-
|
|
191
|
-
function invalid(path: string, problem: string): never {
|
|
192
|
-
// Paths and problems only: caller values never enter the message.
|
|
193
|
-
throw new SessError('configuration', `Invalid question: ${path} ${problem}.`, {
|
|
194
|
-
code: 'INVALID_QUESTION',
|
|
195
|
-
outcome: 'not_sent',
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
/** `fields[0].label` → `/fields/0/label`: the JSON pointer of an input path. */
|
|
199
|
-
function pointer(path: string): string {
|
|
200
|
-
return `/${path
|
|
201
|
-
.replace(/\[(\d+)\]/g, '.$1')
|
|
202
|
-
.split('.')
|
|
203
|
-
.join('/')}`;
|
|
204
|
-
}
|
|
205
|
-
function tooLong(path: string, limit: number, length: number): never {
|
|
206
|
-
// The value itself never enters the message: only its pointer, the limit and its length, in
|
|
207
|
-
// Sess's own sentences.
|
|
208
|
-
throw new SessError('configuration', lengthMessage(pointer(path), limit, length), {
|
|
209
|
-
code: 'INVALID_QUESTION',
|
|
210
|
-
outcome: 'not_sent',
|
|
211
|
-
field: pointer(path),
|
|
212
|
-
limit,
|
|
213
|
-
length,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
function safeKey(key: string): string {
|
|
217
|
-
return /^[A-Za-z0-9_]{1,40}$/.test(key) ? key : '?';
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/** Detached copy of plain JSON data: no accessors, symbols, special objects or deep nesting. */
|
|
221
|
-
function plain(value: unknown, path: string, depth = 0): Json {
|
|
222
|
-
if (value === null || typeof value === 'string' || typeof value === 'boolean') return value;
|
|
223
|
-
if (typeof value === 'number') {
|
|
224
|
-
if (!Number.isFinite(value)) invalid(path, 'must be a finite number');
|
|
225
|
-
return value;
|
|
226
|
-
}
|
|
227
|
-
if (typeof value !== 'object') return invalid(path, 'must be JSON data');
|
|
228
|
-
if (depth >= LIMITS.depth) invalid(path, 'is nested too deeply');
|
|
229
|
-
if (Array.isArray(value)) {
|
|
230
|
-
if (Object.getPrototypeOf(value) !== Array.prototype) invalid(path, 'must be a plain array');
|
|
231
|
-
const out: Json[] = [];
|
|
232
|
-
for (let i = 0; i < value.length; i++) {
|
|
233
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, i);
|
|
234
|
-
if (!descriptor || !('value' in descriptor)) invalid(`${path}[${i}]`, 'must be a plain element');
|
|
235
|
-
out.push(plain(descriptor.value, `${path}[${i}]`, depth + 1));
|
|
236
|
-
}
|
|
237
|
-
return out;
|
|
238
|
-
}
|
|
239
|
-
const prototype = Object.getPrototypeOf(value);
|
|
240
|
-
if (prototype !== Object.prototype && prototype !== null) invalid(path, 'must be a plain object');
|
|
241
|
-
if (Object.getOwnPropertySymbols(value).length) invalid(path, 'must not have symbol keys');
|
|
242
|
-
const out: JsonObject = {};
|
|
243
|
-
for (const key of Object.getOwnPropertyNames(value)) {
|
|
244
|
-
if (RESERVED.has(key)) invalid(path, 'has a reserved key');
|
|
245
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key)!;
|
|
246
|
-
if (!('value' in descriptor) || !descriptor.enumerable) invalid(path, 'must have plain data properties');
|
|
247
|
-
// An optional property given as undefined is omitted, as in request serialization.
|
|
248
|
-
if (descriptor.value === undefined) continue;
|
|
249
|
-
out[key] = plain(descriptor.value, path ? `${path}.${safeKey(key)}` : safeKey(key), depth + 1);
|
|
250
|
-
}
|
|
251
|
-
return out;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function object(value: Json | undefined, path: string): JsonObject {
|
|
255
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
256
|
-
return invalid(path, 'must be an object');
|
|
257
|
-
return value;
|
|
258
|
-
}
|
|
259
|
-
function closed(value: JsonObject, path: string, allowed: readonly string[], required: readonly string[]) {
|
|
260
|
-
for (const key of Object.keys(value))
|
|
261
|
-
if (!allowed.includes(key)) invalid(path, `has an unsupported property "${safeKey(key)}"`);
|
|
262
|
-
for (const key of required) if (!Object.hasOwn(value, key)) invalid(path, `needs "${key}"`);
|
|
263
|
-
}
|
|
264
|
-
const codePoints = (value: string) => [...value].length;
|
|
265
|
-
function text(value: Json | undefined, path: string, max: number): string {
|
|
266
|
-
if (typeof value !== 'string') return invalid(path, 'must be a string');
|
|
267
|
-
if (!value.isWellFormed()) invalid(path, 'must be well-formed Unicode');
|
|
268
|
-
const length = codePoints(value);
|
|
269
|
-
if (length > max) tooLong(path, max, length);
|
|
270
|
-
if (length < 1) invalid(path, `must be 1–${max} characters`);
|
|
271
|
-
if (!/\S/.test(value)) invalid(path, 'must not be blank');
|
|
272
|
-
if (CONTROL.test(value)) invalid(path, 'contains control or bidirectional override characters');
|
|
273
|
-
return value;
|
|
274
|
-
}
|
|
275
|
-
function finite(value: Json | undefined, path: string): number {
|
|
276
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) return invalid(path, 'must be a finite number');
|
|
277
|
-
return value;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/** Whether `value` is valid for the field: a proposal before creation or an accepted value after. */
|
|
281
|
-
function validValue(field: CompiledField, value: unknown): boolean {
|
|
282
|
-
switch (field.type) {
|
|
283
|
-
case 'text':
|
|
284
|
-
// The runtime bounds a string field without maxLength to 4000 code points.
|
|
285
|
-
return typeof value === 'string' && value.isWellFormed() && codePoints(value) <= LIMITS.textMax;
|
|
286
|
-
case 'number':
|
|
287
|
-
case 'integer':
|
|
288
|
-
return (
|
|
289
|
-
typeof value === 'number' &&
|
|
290
|
-
Number.isFinite(value) &&
|
|
291
|
-
(field.type === 'number' || Number.isInteger(value)) &&
|
|
292
|
-
(field.minimum === undefined || value >= field.minimum) &&
|
|
293
|
-
(field.maximum === undefined || value <= field.maximum)
|
|
294
|
-
);
|
|
295
|
-
case 'boolean':
|
|
296
|
-
return typeof value === 'boolean';
|
|
297
|
-
case 'choice':
|
|
298
|
-
return typeof value === 'string' && field.options!.includes(value);
|
|
299
|
-
case 'multi_choice':
|
|
300
|
-
return (
|
|
301
|
-
Array.isArray(value) &&
|
|
302
|
-
value.every((item) => typeof item === 'string' && field.options!.includes(item)) &&
|
|
303
|
-
new Set(value).size === value.length
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function compileField(raw: Json, path: string, names: Set<string>) {
|
|
309
|
-
const f = object(raw, path);
|
|
310
|
-
closed(
|
|
311
|
-
f,
|
|
312
|
-
path,
|
|
313
|
-
['name', 'label', 'type', 'required', 'options', 'default', 'multiline', 'minimum', 'maximum'],
|
|
314
|
-
['name', 'label', 'type'],
|
|
315
|
-
);
|
|
316
|
-
if (typeof f.name !== 'string' || !FIELD_NAME.test(f.name) || RESERVED.has(f.name))
|
|
317
|
-
invalid(`${path}.name`, 'must match ^[a-z][a-z0-9_]{0,63}$');
|
|
318
|
-
const name = f.name;
|
|
319
|
-
if (names.has(name)) invalid(`${path}.name`, 'duplicates another field name');
|
|
320
|
-
names.add(name);
|
|
321
|
-
const label = text(f.label, `${path}.label`, LIMITS.label);
|
|
322
|
-
const type = f.type as AskType;
|
|
323
|
-
if (!TYPES.includes(type)) invalid(`${path}.type`, `must be one of ${TYPES.join(', ')}`);
|
|
324
|
-
const choice = type === 'choice' || type === 'multi_choice';
|
|
325
|
-
if (choice !== (f.options !== undefined))
|
|
326
|
-
invalid(
|
|
327
|
-
`${path}.options`,
|
|
328
|
-
choice ? 'is required for choice fields' : 'is only allowed for choice fields',
|
|
329
|
-
);
|
|
330
|
-
if (f.multiline !== undefined && type !== 'text') invalid(`${path}.multiline`, 'is only allowed for text');
|
|
331
|
-
if ((f.minimum !== undefined || f.maximum !== undefined) && type !== 'number' && type !== 'integer')
|
|
332
|
-
invalid(path, 'minimum/maximum are only allowed for number and integer');
|
|
333
|
-
for (const key of ['required', 'multiline'] as const)
|
|
334
|
-
if (f[key] !== undefined && typeof f[key] !== 'boolean') invalid(`${path}.${key}`, 'must be a boolean');
|
|
335
|
-
const required = f.required === undefined ? type !== 'boolean' : f.required === true;
|
|
336
|
-
const compiled: CompiledField = { name, type, required };
|
|
337
|
-
let schema: FieldSchema;
|
|
338
|
-
switch (type) {
|
|
339
|
-
case 'text':
|
|
340
|
-
schema = { type: 'string' };
|
|
341
|
-
break;
|
|
342
|
-
case 'number':
|
|
343
|
-
case 'integer': {
|
|
344
|
-
const minimum = f.minimum === undefined ? undefined : finite(f.minimum, `${path}.minimum`);
|
|
345
|
-
const maximum = f.maximum === undefined ? undefined : finite(f.maximum, `${path}.maximum`);
|
|
346
|
-
if (minimum !== undefined && maximum !== undefined && minimum > maximum)
|
|
347
|
-
invalid(`${path}.minimum`, 'must not exceed maximum');
|
|
348
|
-
if (minimum !== undefined) compiled.minimum = minimum;
|
|
349
|
-
if (maximum !== undefined) compiled.maximum = maximum;
|
|
350
|
-
schema = {
|
|
351
|
-
type,
|
|
352
|
-
...(minimum !== undefined ? { minimum } : {}),
|
|
353
|
-
...(maximum !== undefined ? { maximum } : {}),
|
|
354
|
-
};
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
case 'boolean':
|
|
358
|
-
schema = { type: 'boolean' };
|
|
359
|
-
break;
|
|
360
|
-
case 'choice':
|
|
361
|
-
case 'multi_choice': {
|
|
362
|
-
const options = f.options;
|
|
363
|
-
if (!Array.isArray(options) || options.length < 1 || options.length > LIMITS.options)
|
|
364
|
-
invalid(`${path}.options`, `must list 1–${LIMITS.options} options`);
|
|
365
|
-
const values = options.map((option, i) => text(option, `${path}.options[${i}]`, LIMITS.option));
|
|
366
|
-
if (new Set(values).size !== values.length) invalid(`${path}.options`, 'must be unique');
|
|
367
|
-
compiled.options = Object.freeze([...values]);
|
|
368
|
-
schema =
|
|
369
|
-
type === 'choice'
|
|
370
|
-
? { type: 'string', enum: values }
|
|
371
|
-
: { type: 'array', items: { type: 'string', enum: [...values] }, uniqueItems: true };
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
if (f.default !== undefined && !validValue(compiled, f.default))
|
|
376
|
-
invalid(`${path}.default`, 'is not a valid value for this field');
|
|
377
|
-
const component: SurfaceComponent = {
|
|
378
|
-
type: 'field',
|
|
379
|
-
name,
|
|
380
|
-
label,
|
|
381
|
-
required,
|
|
382
|
-
schema,
|
|
383
|
-
...(f.multiline !== undefined ? { multiline: f.multiline as boolean } : {}),
|
|
384
|
-
...(f.default !== undefined ? { value: f.default } : {}),
|
|
385
|
-
};
|
|
386
|
-
return { component, compiled: Object.freeze(compiled) };
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* The one deterministic simple-field compiler: validates a question locally, without network,
|
|
391
|
-
* credential or clock access, and expands it into the ordinary interactive Surface.
|
|
392
|
-
*/
|
|
393
|
-
export function compileAsk(input: unknown): CompiledAsk {
|
|
394
|
-
const a = object(plain(input, ''), 'input');
|
|
395
|
-
closed(a, 'input', ['question', 'details', 'fields', 'submit_label', 'expires_in'], ['question', 'fields']);
|
|
396
|
-
const expiresIn = a.expires_in;
|
|
397
|
-
if (
|
|
398
|
-
expiresIn !== undefined &&
|
|
399
|
-
(typeof expiresIn !== 'number' ||
|
|
400
|
-
!Number.isSafeInteger(expiresIn) ||
|
|
401
|
-
expiresIn < LINK_LIFETIME_FLOOR_SECONDS)
|
|
402
|
-
)
|
|
403
|
-
invalid('expires_in', `must be a whole number of seconds, at least ${LINK_LIFETIME_FLOOR_SECONDS}`);
|
|
404
|
-
const title = text(a.question, 'question', LIMITS.question);
|
|
405
|
-
const details = a.details === undefined ? undefined : text(a.details, 'details', LIMITS.details);
|
|
406
|
-
const submit =
|
|
407
|
-
a.submit_label === undefined ? 'Send' : text(a.submit_label, 'submit_label', LIMITS.submitLabel);
|
|
408
|
-
const fields = a.fields;
|
|
409
|
-
if (!Array.isArray(fields) || fields.length < 1 || fields.length > LIMITS.fields)
|
|
410
|
-
invalid('fields', `must contain 1–${LIMITS.fields} fields`);
|
|
411
|
-
const components: SurfaceComponent[] = [];
|
|
412
|
-
if (details !== undefined) components.push({ type: 'text', text: details });
|
|
413
|
-
const names = new Set<string>();
|
|
414
|
-
const compiled: CompiledField[] = [];
|
|
415
|
-
fields.forEach((field, i) => {
|
|
416
|
-
const result = compileField(field, `fields[${i}]`, names);
|
|
417
|
-
components.push(result.component);
|
|
418
|
-
compiled.push(result.compiled);
|
|
419
|
-
});
|
|
420
|
-
const interaction: InteractiveInteraction = {
|
|
421
|
-
mode: 'interactive',
|
|
422
|
-
title,
|
|
423
|
-
source: { kind: 'sess_surface', components },
|
|
424
|
-
actions: [{ id: 'submit', label: submit, intent: 'submit' }],
|
|
425
|
-
};
|
|
426
|
-
if (Buffer.byteLength(JSON.stringify(interaction), 'utf8') > SURFACE_LIMIT_BYTES)
|
|
427
|
-
invalid('input', `exceeds the ${SURFACE_LIMIT_BYTES}-byte Surface limit`);
|
|
428
|
-
return {
|
|
429
|
-
interaction,
|
|
430
|
-
fields: Object.freeze(compiled),
|
|
431
|
-
...(expiresIn !== undefined ? { expiresIn: expiresIn as number } : {}),
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Checks verified answer data against the compiled fields and returns a frozen copy in field
|
|
437
|
-
* order. It follows the runtime decoding: a checkbox is always present, a multiple choice is
|
|
438
|
-
* always a list, and an empty optional value is absent.
|
|
439
|
-
*/
|
|
440
|
-
export function checkAnswer(
|
|
441
|
-
fields: readonly CompiledField[],
|
|
442
|
-
data: unknown,
|
|
443
|
-
): Readonly<Record<string, unknown>> {
|
|
444
|
-
const mismatch = () =>
|
|
445
|
-
new SessError('protocol', 'The verified answer does not match the question’s fields.', {
|
|
446
|
-
code: 'INVALID_RESPONSE',
|
|
447
|
-
});
|
|
448
|
-
if (data === null || typeof data !== 'object' || Array.isArray(data)) throw mismatch();
|
|
449
|
-
const source = data as Record<string, unknown>;
|
|
450
|
-
const known = new Set(fields.map((f) => f.name));
|
|
451
|
-
for (const key of Object.keys(source)) if (!known.has(key)) throw mismatch();
|
|
452
|
-
const out: Record<string, unknown> = {};
|
|
453
|
-
for (const field of fields) {
|
|
454
|
-
if (!Object.hasOwn(source, field.name)) {
|
|
455
|
-
if (field.required || field.type === 'boolean' || field.type === 'multi_choice') throw mismatch();
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
const value = source[field.name];
|
|
459
|
-
if (!validValue(field, value) || value === '') throw mismatch();
|
|
460
|
-
out[field.name] = Array.isArray(value) ? Object.freeze([...value]) : value;
|
|
461
|
-
}
|
|
462
|
-
return Object.freeze(out);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/** The replay identity of the completion, saved before its first dispatch. */
|
|
466
|
-
interface Completion {
|
|
467
|
-
eventId: string;
|
|
468
|
-
ifMatch: string;
|
|
469
|
-
idempotencyKey: string;
|
|
470
|
-
uncertain: boolean;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
class Handle<T> implements AskHandle<T> {
|
|
474
|
-
readonly sessionId: string;
|
|
475
|
-
readonly revision: number;
|
|
476
|
-
readonly expiresAt: string | null;
|
|
477
|
-
#link: string;
|
|
478
|
-
#sessions: Sessions;
|
|
479
|
-
#receipts: ReceiptResource;
|
|
480
|
-
#expectedWorkspaceId: string | undefined;
|
|
481
|
-
#fields: readonly CompiledField[];
|
|
482
|
-
#surface: string;
|
|
483
|
-
#result: { value: T } | undefined;
|
|
484
|
-
#settling: Promise<T> | undefined;
|
|
485
|
-
#completion: Completion | undefined;
|
|
486
|
-
|
|
487
|
-
constructor(context: {
|
|
488
|
-
sessionId: string;
|
|
489
|
-
revision: number;
|
|
490
|
-
expiresAt: string | null;
|
|
491
|
-
link: string;
|
|
492
|
-
sessions: Sessions;
|
|
493
|
-
receipts: ReceiptResource;
|
|
494
|
-
expectedWorkspaceId: string | undefined;
|
|
495
|
-
compiled: CompiledAsk;
|
|
496
|
-
}) {
|
|
497
|
-
this.sessionId = context.sessionId;
|
|
498
|
-
this.revision = context.revision;
|
|
499
|
-
this.expiresAt = context.expiresAt;
|
|
500
|
-
this.#link = context.link;
|
|
501
|
-
this.#sessions = context.sessions;
|
|
502
|
-
this.#receipts = context.receipts;
|
|
503
|
-
this.#expectedWorkspaceId = context.expectedWorkspaceId;
|
|
504
|
-
this.#fields = context.compiled.fields;
|
|
505
|
-
// The runtime stores the interaction with its only response policy.
|
|
506
|
-
this.#surface = canonicalJson({ ...context.compiled.interaction, response_policy: 'first' });
|
|
507
|
-
this.answer = this.answer.bind(this);
|
|
508
|
-
Object.freeze(this);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
get link(): string {
|
|
512
|
-
return this.#link;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
async answer(options: AskAnswerOptions = {}): Promise<T> {
|
|
516
|
-
if (!options || typeof options !== 'object')
|
|
517
|
-
throw new SessError('configuration', 'answer options must be an object.', { outcome: 'not_sent' });
|
|
518
|
-
const { timeoutMs, intervalMs, signal } = options;
|
|
519
|
-
if (this.#result) return this.#result.value;
|
|
520
|
-
const waited = await this.#sessions.waitForResponse(this.sessionId, {
|
|
521
|
-
revision: this.revision,
|
|
522
|
-
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
523
|
-
...(intervalMs !== undefined ? { intervalMs } : {}),
|
|
524
|
-
...(signal !== undefined ? { signal } : {}),
|
|
525
|
-
});
|
|
526
|
-
// Another call may have settled this handle during the wait.
|
|
527
|
-
const settled = this.#result as { value: T } | undefined;
|
|
528
|
-
if (settled) return settled.value;
|
|
529
|
-
// One logical settlement per handle, shared by concurrent callers. It is not bound to the
|
|
530
|
-
// signal of any caller: an abort ends only that local wait.
|
|
531
|
-
this.#settling ??= this.#settle(waited.response).finally(() => {
|
|
532
|
-
this.#settling = undefined;
|
|
533
|
-
});
|
|
534
|
-
if (!signal) return this.#settling;
|
|
535
|
-
try {
|
|
536
|
-
return await withSignal(this.#settling, signal);
|
|
537
|
-
} catch (error) {
|
|
538
|
-
if (signal.aborted)
|
|
539
|
-
throw new SessError('aborted', 'Waiting for the answer was aborted. The Session remains available.', {
|
|
540
|
-
sessionId: this.sessionId,
|
|
541
|
-
revision: this.revision,
|
|
542
|
-
});
|
|
543
|
-
throw error;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
async #settle(accepted: AcceptedResponse): Promise<T> {
|
|
548
|
-
const verified = await this.#receipts.verifyResponse({
|
|
549
|
-
sessionId: this.sessionId,
|
|
550
|
-
response: accepted,
|
|
551
|
-
...(this.#expectedWorkspaceId !== undefined ? { expectedWorkspaceId: this.#expectedWorkspaceId } : {}),
|
|
552
|
-
});
|
|
553
|
-
const response = verified.response;
|
|
554
|
-
if (
|
|
555
|
-
response.event_id !== accepted.event_id ||
|
|
556
|
-
response.revision !== this.revision ||
|
|
557
|
-
response.action_id !== 'submit' ||
|
|
558
|
-
verified.surface.id !== this.sessionId ||
|
|
559
|
-
verified.surface.revision !== this.revision ||
|
|
560
|
-
canonicalJson(verified.surface.interaction) !== this.#surface
|
|
561
|
-
)
|
|
562
|
-
throw new SessError('receipt_verification', 'The verified answer is not bound to this question.', {
|
|
563
|
-
code: 'RECORD_BINDING_MISMATCH',
|
|
564
|
-
});
|
|
565
|
-
const value = checkAnswer(this.#fields, response.data) as T;
|
|
566
|
-
await this.#complete(response.event_id);
|
|
567
|
-
this.#result = { value };
|
|
568
|
-
return value;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/** Completed at exactly this revision and still retaining exactly this accepted event. */
|
|
572
|
-
#completedHere(session: InteractiveSession, eventId: string): boolean {
|
|
573
|
-
return (
|
|
574
|
-
session.status === 'completed' &&
|
|
575
|
-
session.revision === this.revision &&
|
|
576
|
-
session.responses.some((r) => r.event_id === eventId && r.revision === this.revision)
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
async #complete(eventId: string): Promise<void> {
|
|
581
|
-
if (this.#completion && this.#completion.eventId !== eventId)
|
|
582
|
-
throw new SessError('receipt_verification', 'A different answer was already used for this question.', {
|
|
583
|
-
code: 'RECORD_BINDING_MISMATCH',
|
|
584
|
-
});
|
|
585
|
-
// Currentness after verification: a historically valid answer alone does not allow progression.
|
|
586
|
-
const current = await this.#sessions.retrieve(this.sessionId);
|
|
587
|
-
const session = current.data;
|
|
588
|
-
if (!isInteractiveSession(session))
|
|
589
|
-
throw this.#ended('NOT_INTERACTIVE', 'A display Session has no accepted human responses.');
|
|
590
|
-
if (this.#completedHere(session, eventId)) return;
|
|
591
|
-
const retained = session.responses.some((r) => r.event_id === eventId && r.revision === this.revision);
|
|
592
|
-
if (!retained || session.revision !== this.revision || session.status !== 'responded')
|
|
593
|
-
throw this.#ended('REVISION_SUPERSEDED', 'The answered revision is no longer the current step.');
|
|
594
|
-
// Saved before the first dispatch and replayed after any uncertainty: never a fresh identity.
|
|
595
|
-
this.#completion ??= {
|
|
596
|
-
eventId,
|
|
597
|
-
ifMatch: current.meta.etag,
|
|
598
|
-
idempotencyKey: `sess-ask:${randomUUID()}`,
|
|
599
|
-
uncertain: false,
|
|
600
|
-
};
|
|
601
|
-
const pending = this.#completion;
|
|
602
|
-
let result: VersionedResult<InteractiveSession>;
|
|
603
|
-
try {
|
|
604
|
-
result = await this.#sessions.complete(this.sessionId, {
|
|
605
|
-
ifMatch: pending.ifMatch,
|
|
606
|
-
idempotencyKey: pending.idempotencyKey,
|
|
607
|
-
});
|
|
608
|
-
} catch (error) {
|
|
609
|
-
if (error instanceof SessError && error.code === 'SESSION_COMPLETED') {
|
|
610
|
-
// Already completed: confirmed only by reading it back at this revision with this event.
|
|
611
|
-
const readback = await this.#sessions.retrieve(this.sessionId);
|
|
612
|
-
if (isInteractiveSession(readback.data) && this.#completedHere(readback.data, eventId)) return;
|
|
613
|
-
throw error;
|
|
614
|
-
}
|
|
615
|
-
// A definite rejection of an identity that was never uncertain wrote nothing; anything else
|
|
616
|
-
// keeps the identity for an exact replay on the next call.
|
|
617
|
-
if (error instanceof SessError && error.outcome === 'rejected' && !pending.uncertain)
|
|
618
|
-
this.#completion = undefined;
|
|
619
|
-
else pending.uncertain = true;
|
|
620
|
-
throw error;
|
|
621
|
-
}
|
|
622
|
-
if (!this.#completedHere(result.data, eventId)) {
|
|
623
|
-
pending.uncertain = true;
|
|
624
|
-
throw new SessError('protocol', 'Completion was not confirmed at the answered revision.', {
|
|
625
|
-
code: 'INVALID_RESPONSE',
|
|
626
|
-
operation: 'sessions.complete',
|
|
627
|
-
outcome: 'unknown',
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
#ended(code: string, message: string): SessError {
|
|
633
|
-
return new SessError('wait_ended', message, { code, sessionId: this.sessionId, revision: this.revision });
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/** The private link is omitted from serialization and inspection. */
|
|
637
|
-
toJSON(): object {
|
|
638
|
-
return { sessionId: this.sessionId, revision: this.revision };
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
[inspect.custom](): object {
|
|
642
|
-
return this.toJSON();
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/** Validates locally, creates once (the link is available before any wait) and returns the handle. */
|
|
647
|
-
export async function ask<T>(
|
|
648
|
-
sessions: Sessions,
|
|
649
|
-
receipts: ReceiptResource,
|
|
650
|
-
input: unknown,
|
|
651
|
-
options: AskOptions = {},
|
|
652
|
-
): Promise<AskHandle<T>> {
|
|
653
|
-
const compiled = compileAsk(input);
|
|
654
|
-
if (!options || typeof options !== 'object')
|
|
655
|
-
throw new SessError('configuration', 'ask options must be an object.', { outcome: 'not_sent' });
|
|
656
|
-
const { expectedWorkspaceId, ...requestOptions } = options;
|
|
657
|
-
if (
|
|
658
|
-
expectedWorkspaceId !== undefined &&
|
|
659
|
-
(typeof expectedWorkspaceId !== 'string' || !/^[A-Za-z0-9_:-]{1,128}$/.test(expectedWorkspaceId))
|
|
660
|
-
)
|
|
661
|
-
throw new SessError('configuration', 'expectedWorkspaceId must be a trusted workspace identifier.', {
|
|
662
|
-
outcome: 'not_sent',
|
|
663
|
-
});
|
|
664
|
-
// Creation carries the whole interaction and is attempted once. An uncertain outcome surfaces as
|
|
665
|
-
// the unknown_outcome error of the client and is never retried here.
|
|
666
|
-
const created = await sessions.create(
|
|
667
|
-
{
|
|
668
|
-
interaction: compiled.interaction,
|
|
669
|
-
...(compiled.expiresIn !== undefined ? { expires_in: compiled.expiresIn } : {}),
|
|
670
|
-
},
|
|
671
|
-
requestOptions,
|
|
672
|
-
);
|
|
673
|
-
return new Handle<T>({
|
|
674
|
-
sessionId: created.data.id,
|
|
675
|
-
revision: created.data.revision,
|
|
676
|
-
expiresAt: typeof created.data.action_expires_at === 'string' ? created.data.action_expires_at : null,
|
|
677
|
-
link: created.data.human_url,
|
|
678
|
-
sessions,
|
|
679
|
-
receipts,
|
|
680
|
-
expectedWorkspaceId,
|
|
681
|
-
compiled,
|
|
682
|
-
});
|
|
683
|
-
}
|
package/src/cli/main.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// The `sess` executable. The only command is `sess verify <bundle.json>` (see ./verify.ts).
|
|
3
|
-
import { runCli } from './verify.js';
|
|
4
|
-
|
|
5
|
-
process.exitCode = await runCli(process.argv.slice(2), {
|
|
6
|
-
stdout: (text) => process.stdout.write(text),
|
|
7
|
-
stderr: (text) => process.stderr.write(text),
|
|
8
|
-
});
|