@sess.si/sdk 0.1.0-rc.9 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,6 +1,34 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0-rc.9 — 2026-10-28 (prepared, unpublished)
3
+ ## 0.1.1 — 2026-11-04
4
+
5
+ - The npm package page only: `keywords`, and `homepage` now points at the docs quickstart. The API
6
+ is that of 0.1.0, unchanged, and so are the runtime dependencies. The default `User-Agent` names
7
+ the new version.
8
+
9
+ ## 0.1.0 — 2026-10-31
10
+
11
+ - The first stable release, published to the `latest` dist-tag. The API is that of
12
+ 0.1.0-rc.10, unchanged.
13
+ - Development dependency only: the contract generator's `@redocly/openapi-core` now resolves
14
+ `minimatch` 11.0.1 (advisory GHSA-g3hv-75wg-m249), through a scoped `overrides` entry. No
15
+ runtime dependency changes; the generated types are byte-identical.
16
+
17
+ ## 0.1.0-rc.10 — 2026-10-28
18
+
19
+ - Short human links: a request identifier holding a run of 22 or more base64url characters (a
20
+ short-link token is 22, as in `/n/<token>`; a `/s/` token 43; either may be glued to more) is
21
+ withheld from `SessError.requestId` and request events. Sess's own `req_<uuid>` ids are kept.
22
+ - A key Sess does not accept (HTTP 401 `UNAUTHORIZED`) now says so: the `SessError` message is
23
+ "Sess did not accept your API key. Check SESS_API_KEY and the portal you made it on." instead of
24
+ the generic "The Sess API returned an error. See the status and code fields." Other messages
25
+ are unchanged. `code`, `status` and `requestId` are still on the error.
26
+ - A `SessError` has an own property only for a field with a value. Printing one (an uncaught
27
+ error, `console.log`, `util.inspect`, `JSON.stringify`) no longer lists absent fields as
28
+ `undefined`; reading an absent field still gives `undefined`. The Node quickstart and the
29
+ README print the message first, then a `Details:` line with the code and request ID.
30
+
31
+ ## 0.1.0-rc.9 — 2026-10-28
4
32
 
5
33
  - Commerce: bills as ordinary Surfaces, for Sess's `items` component. Sess takes no payment.
6
34
  `money(amount, currency)` checks a whole number of minor units (cents for USD, yen for JPY, fils
@@ -36,9 +64,9 @@
36
64
  document paths. Every published package's packed bytes now pass a hygiene check (no maps,
37
65
  fixtures, non-public hosts, credential-shaped strings or internal references).
38
66
 
39
- ## 0.1.0-rc.8 — 2026-10-22 (prepared, unpublished)
67
+ ## 0.1.0-rc.8 — 2026-10-22
40
68
 
41
- - Link timing (Decision 0009 Amendment 10). On an interactive Sess link of 20 hours or less the
69
+ - Link timing. On an interactive Sess link of 20 hours or less the
42
70
  person may ask for more time, up to ten times, never past a fixed horizon. Session reads carry
43
71
  `link_state` (`live`, `lapsed` or `expired`), `action_expires_horizon`, `extensions_used` and the
44
72
  `extensions` history; the Session log (`listEvents()`) lists the same records as
@@ -55,7 +83,7 @@
55
83
  describes: the interactive text limits with `field`, `limit` and `length` on a length error,
56
84
  `progress`, the receipt `format` and the renderer identities list. The generated wire types gain
57
85
  them; the SDK's public types and behavior in this change are link timing only.
58
- - Renderer identities (Decision 0009 Amendment 13). A receipt's `surface.renderer_version` now
86
+ - Renderer identities. A receipt's `surface.renderer_version` now
59
87
  verifies when it is an identity this release bundles (`sess-html-form-1`, `sess-html-form-2`;
60
88
  `BUNDLED_RENDERER_IDENTITIES`) or one on the issuer's renderer list whose signature verifies
61
89
  under the same trusted keys and issuer, so a later Sess page change needs no SDK update. Every
@@ -91,7 +119,7 @@
91
119
  Sess's own fix. The README and the quickstart show catching it, shortening the value and asking again.
92
120
  Surfaces stored before these limits still read as before.
93
121
 
94
- ## 0.1.0-rc.7 — 2026-10-18 (prepared, unpublished)
122
+ ## 0.1.0-rc.7 — 2026-10-18
95
123
 
96
124
  Includes everything in the unpublished 0.1.0-rc.6 below, which is not published on its own.
97
125
 
@@ -108,7 +136,7 @@ Includes everything in the unpublished 0.1.0-rc.6 below, which is not published
108
136
  - `ResponseMeta.serverDate`: the response's HTTP `Date`, when the runtime sends one.
109
137
  - Contract snapshot from Sess runtime commit `b48e8e7` (see `contract/contract-lock.json`), with
110
138
  `expires_in`, `action_expires_at` on create and the target's `default_expires_in`.
111
- - `@sess.si/sdk/qr` (S-07): `qr(url, { format: 'svg' | 'png' | 'terminal' })` draws a Sess link as a
139
+ - `@sess.si/sdk/qr`: `qr(url, { format: 'svg' | 'png' | 'terminal' })` draws a Sess link as a
112
140
  QR code locally (error correction level M, 4-module quiet zone, deterministic, no network call), and
113
141
  `printQr(url)` prints "Scan to answer on your phone" and the code on an interactive terminal only:
114
142
  never without a TTY, in CI or with `NODE_ENV=production`; `--no-qr` or `{ qr: false }` turn it off
package/README.md CHANGED
@@ -5,7 +5,7 @@ Ask a person a question from your server and continue with their verified answer
5
5
  **Create and run** a small agent:
6
6
 
7
7
  ```sh
8
- npm create @sess.si/agent@next my-agent
8
+ npm create @sess.si/agent@latest my-agent
9
9
  ```
10
10
 
11
11
  **What you'll see:** a Sess link. Answer two questions on your phone and your plan prints in the
@@ -14,7 +14,7 @@ terminal with a verified receipt.
14
14
  **Install** the SDK in your own server project:
15
15
 
16
16
  ```sh
17
- npm install --save-exact @sess.si/sdk@next
17
+ npm install --save-exact @sess.si/sdk@0.1.1
18
18
  ```
19
19
 
20
20
  ## Ask a person
@@ -56,6 +56,29 @@ confirmed; calling `answer()` again replays the same completion. The handle live
56
56
  resume after a restart, persist `sessionId` and `revision` and continue with the API below
57
57
  ([Integration](docs/integration.md#one-question-with-sessask)).
58
58
 
59
+ If Sess refuses a call, the error says what happened and what to do. A key Sess does not accept
60
+ prints: "Sess did not accept your API key. Check SESS_API_KEY and the portal you made it on." The
61
+ message comes first; the code and request ID follow it:
62
+
63
+ <!-- example:ask-error -->
64
+
65
+ ```js
66
+ try {
67
+ const question = await sess.ask({
68
+ question: 'Approve the synthetic refund?',
69
+ fields: [{ name: 'approved', label: 'Approve it', type: 'boolean' }],
70
+ });
71
+ console.log(`Send this Sess link to the person: ${question.link}`);
72
+ } catch (error) {
73
+ console.error(error.message); // what happened and what to do
74
+ const request = error.requestId ? `, request ${error.requestId}` : '';
75
+ console.error(`Details: ${error.code ?? error.kind}${request}`);
76
+ process.exitCode = 1;
77
+ }
78
+ ```
79
+
80
+ <!-- /example:ask-error -->
81
+
59
82
  ## Keep it short
60
83
 
61
84
  A person reads the page on a phone, so Sess keeps every piece of it short. Lengths count
@@ -97,10 +120,9 @@ async function askShort(question: string) {
97
120
  }
98
121
  ```
99
122
 
100
- **Release status:** every SDK release so far is a `0.1.0` release candidate, served under the `next`
101
- dist-tag. There is no stable release yet: do not install the bare name, whose `latest` tag points at a
102
- deprecated `0.0.0-stage` placeholder. The [changelog](CHANGELOG.md) describes each version;
103
- `npm view @sess.si/sdk dist-tags` shows what the registry serves now.
123
+ **Release status:** `0.1.1` is the current release, served under the `latest` dist-tag. Its API is
124
+ that of `0.1.0`, the first stable release. `next` stays at the last release candidate, `0.1.0-rc.10`. The [changelog](CHANGELOG.md) describes
125
+ each version; `npm view @sess.si/sdk dist-tags` shows what the registry serves now.
104
126
 
105
127
  ## Commerce
106
128
 
@@ -220,11 +242,10 @@ exact Surface and input, and the issuer's public keys. Check it on your own comp
220
242
  trust (never the keys inside the bundle):
221
243
 
222
244
  ```sh
223
- npx -p @sess.si/sdk@0.1.0-rc.5 sess verify bundle.json --issuer https://api.sess.si --keys sess-receipt-keys.json
245
+ npx -p @sess.si/sdk@0.1.1 sess verify bundle.json --issuer https://api.sess.si --keys sess-receipt-keys.json
224
246
  ```
225
247
 
226
- The `sess` command first ships in `0.1.0-rc.5`; name that version (or a later one) exactly, because
227
- the bare package name resolves to the `latest` placeholder, which has no command.
248
+ The `sess` command first ships in `0.1.0-rc.5`; any later version, `0.1.1` included, has it.
228
249
 
229
250
  You'll see `Valid decision bundle.` and what was accepted, when, on which revision; or `Invalid`
230
251
  and the first reason. Exit status is 0 valid, 1 invalid, 2 usage error; add `--json` for the full
package/dist/errors.d.ts CHANGED
@@ -21,7 +21,10 @@ export interface SessErrorDetails {
21
21
  /** With a length error: the value's actual length, in Unicode code points. */
22
22
  length?: number;
23
23
  }
24
- /** Stable error fields; messages never include response bodies or request secrets. */
24
+ /**
25
+ * Stable error fields; messages never include response bodies or request secrets. An optional
26
+ * field is an own property only when it has a value, so printing an error lists no empty fields.
27
+ */
25
28
  export declare class SessError extends Error {
26
29
  readonly kind: SessErrorKind;
27
30
  readonly code?: string;
@@ -49,6 +52,7 @@ export declare class SessError extends Error {
49
52
  /** Explicit access only. A usable create body may accompany a defective header. */
50
53
  getRecoveryResult(): Readonly<CreateSessionResponse> | undefined;
51
54
  toJSON(): object;
55
+ /** `util.inspect` and `console.log`: the same fields as JSON, without the absent ones. */
52
56
  [inspect.custom](): object;
53
57
  }
54
58
  /** Internal: the one-line fix every length error carries (field, limit, actual length, fix). */
package/dist/errors.js CHANGED
@@ -1,34 +1,18 @@
1
1
  import { inspect } from 'node:util';
2
2
  const recovery = new WeakMap();
3
- /** Stable error fields; messages never include response bodies or request secrets. */
3
+ /**
4
+ * Stable error fields; messages never include response bodies or request secrets. An optional
5
+ * field is an own property only when it has a value, so printing an error lists no empty fields.
6
+ */
4
7
  export class SessError extends Error {
5
8
  kind;
6
- code;
7
- reason;
8
- status;
9
- requestId;
10
- operation;
11
- attempts;
12
- outcome;
13
- idempotencyKey;
14
- retryAfterMs;
15
- sessionId;
16
- revision;
17
- /**
18
- * Set only when a value is too long (a 400 INVALID_SCHEMA from Sess, or INVALID_QUESTION from
19
- * `ask`): a JSON pointer to it, e.g. `/interaction/title`. Nothing is ever truncated: shorten
20
- * the value to at most `limit` characters and send again.
21
- */
22
- field;
23
- /** With `field`: the most the value may have, in Unicode code points (e.g. title 80). */
24
- limit;
25
- /** With `field`: the value's actual length, in Unicode code points. */
26
- length;
27
9
  constructor(kind, message, details = {}) {
28
10
  super(message);
29
11
  this.name = 'SessError';
30
12
  this.kind = kind;
31
- Object.assign(this, details);
13
+ for (const [name, value] of Object.entries(details))
14
+ if (value !== undefined)
15
+ Object.assign(this, { [name]: value });
32
16
  }
33
17
  /** Explicit access only. A usable create body may accompany a defective header. */
34
18
  getRecoveryResult() {
@@ -36,7 +20,7 @@ export class SessError extends Error {
36
20
  }
37
21
  toJSON() {
38
22
  const { name, kind, message, code, reason, status, requestId, operation, attempts, outcome, idempotencyKey, retryAfterMs, field, limit, length, } = this;
39
- return {
23
+ const fields = {
40
24
  name,
41
25
  kind,
42
26
  message,
@@ -53,7 +37,9 @@ export class SessError extends Error {
53
37
  limit,
54
38
  length,
55
39
  };
40
+ return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
56
41
  }
42
+ /** `util.inspect` and `console.log`: the same fields as JSON, without the absent ones. */
57
43
  [inspect.custom]() {
58
44
  return this.toJSON();
59
45
  }
@@ -1,2 +1,2 @@
1
1
  /** This package's version, sent in the User-Agent header. Tests check it against package.json. */
2
- export declare const SDK_VERSION = "0.1.0-rc.9";
2
+ export declare const SDK_VERSION = "0.1.1";
@@ -1,2 +1,2 @@
1
1
  /** This package's version, sent in the User-Agent header. Tests check it against package.json. */
2
- export const SDK_VERSION = '0.1.0-rc.9';
2
+ export const SDK_VERSION = '0.1.1';
package/dist/transport.js CHANGED
@@ -25,6 +25,8 @@ const rejections = {
25
25
  // rate limit; a plain 429 (no code, or RATE_LIMITED) stays transient and its outcome uncertain.
26
26
  429: ['PLAN_LIMIT_REACHED'],
27
27
  };
28
+ /** A 401 UNAUTHORIZED: Sess refused the API key. */
29
+ const UNAUTHORIZED_MESSAGE = 'Sess did not accept your API key. Check SESS_API_KEY and the portal you made it on.';
28
30
  /** RFC 9110 product tokens (`name` or `name/version`), separated by single spaces. */
29
31
  const PRODUCT = "[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:/[!#$%&'*+.^_`|~0-9A-Za-z-]+)?";
30
32
  const PRODUCTS = new RegExp(`^${PRODUCT}(?: ${PRODUCT})*$`);
@@ -90,11 +92,16 @@ function origin(input, allowInsecure) {
90
92
  }
91
93
  return url.origin;
92
94
  }
95
+ /** The request id the Sess API assigns: `req_` and a random UUID. */
96
+ const SESS_REQUEST_ID = /^req_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
93
97
  function safeText(value, pattern, key, opaqueIdentifier = false) {
94
98
  if (typeof value !== 'string' ||
95
99
  !pattern.test(value) ||
96
100
  /sess_(?:sk|mg|tk|mk)_|whsec_|eyJ/.test(value) ||
97
- (opaqueIdentifier && /^[A-Za-z0-9_-]{43}$/.test(value)) ||
101
+ // A request identifier holding a run of 22 or more base64url characters may carry a reflected
102
+ // human-link token (22 for /n/ short links, 43 for /s/ links, alone or glued to more token
103
+ // characters), so it is withheld. Sess's own request ids, req_ and a lowercase UUID, are kept.
104
+ (opaqueIdentifier && /[A-Za-z0-9_-]{22,}/.test(value) && !SESS_REQUEST_ID.test(value)) ||
98
105
  (key && value.includes(key)))
99
106
  return undefined;
100
107
  return value;
@@ -348,7 +355,9 @@ export class Transport {
348
355
  const length = lengthDetail(remote, code, key);
349
356
  const message = length.field !== undefined
350
357
  ? lengthMessage(length.field, length.limit, length.length)
351
- : 'The Sess API returned an error. See the status and code fields.';
358
+ : response.status === 401 && code === 'UNAUTHORIZED'
359
+ ? UNAUTHORIZED_MESSAGE
360
+ : 'The Sess API returned an error. See the status and code fields.';
352
361
  throw new SessError('api', message, {
353
362
  code,
354
363
  reason,
package/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "@sess.si/sdk",
3
- "version": "0.1.0-rc.9",
3
+ "version": "0.1.1",
4
4
  "description": "Ask a person from your server and continue with their verified answer. Sess API client with receipt and webhook verification.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
+ "keywords": [
8
+ "mcp",
9
+ "agent",
10
+ "human-in-the-loop",
11
+ "approval",
12
+ "form",
13
+ "receipt",
14
+ "claude",
15
+ "openai"
16
+ ],
7
17
  "repository": {
8
18
  "type": "git",
9
19
  "url": "git+https://github.com/w1991e/sess-sdk.git"
@@ -11,7 +21,7 @@
11
21
  "bugs": {
12
22
  "url": "https://github.com/w1991e/sess-sdk/issues"
13
23
  },
14
- "homepage": "https://github.com/w1991e/sess-sdk#readme",
24
+ "homepage": "https://docs.sess.si/quickstart/",
15
25
  "engines": {
16
26
  "node": ">=22.14.0"
17
27
  },
@@ -80,5 +90,10 @@
80
90
  "typescript": "5.9.3",
81
91
  "typescript-current": "npm:typescript@7.0.2",
82
92
  "vitest": "5.0.4"
93
+ },
94
+ "overrides": {
95
+ "@redocly/openapi-core": {
96
+ "minimatch": "11.0.1"
97
+ }
83
98
  }
84
99
  }