@crouter/sdk 0.3.396 → 0.3.397
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client.js +10 -2
- package/dist/keygen-cli.js +0 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ const client = new Crouter({
|
|
|
47
47
|
|
|
48
48
|
## Runtime version
|
|
49
49
|
|
|
50
|
-
The SDK talks only to a runtime at or above its own version (`SDK_VERSION`), and has no compatibility mode for older ones: its types, such as `RunObject.activity`, describe what a runtime at its release sends. Every runtime answer carries a `Crouter-Runtime-Version` header. When that version is older than the SDK, or the header is missing (every runtime released before this rule shipped), the call throws `RuntimeVersionError` before the SDK reads the response: `code` is `runtime_version_unsupported`, `status` is 426, `retryable` is false, and `sdkVersion` and `runtimeVersion` name both versions. Upgrade the runtime first, then the SDK.
|
|
50
|
+
The SDK talks only to a runtime at or above its own version (`SDK_VERSION`), and has no compatibility mode for older ones: its types, such as `RunObject.activity`, describe what a runtime at its release sends. Every runtime answer carries a `Crouter-Runtime-Version` header. When that version is older than the SDK, or the header is missing (every runtime released before this rule shipped), the call throws `RuntimeVersionError` before the SDK reads the response: `code` is `runtime_version_unsupported`, `status` is 426, `retryable` is false, and `sdkVersion` and `runtimeVersion` name both versions. The SDK also sends its own version on every request except `/healthz` as `Crouter-Minimum-Runtime-Version`; the hosting router and a runtime at this release or later refuse an older runtime with the same 426 *before* any handler runs, so nothing is accepted and no `Idempotency-Key` is recorded (a retry after the roll is a first send). Upgrade the runtime first, then the SDK.
|
|
51
51
|
|
|
52
52
|
Pin `@crouter/sdk` to an exact version. One release is one version set: `@crouter/sdk@X` depends on exactly `@crouter/api@X` and `@crouter/identity@X`, so the pin fixes all three.
|
|
53
53
|
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIError, CrtrClient, RUNTIME_VERSION_HEADER, compareReleaseVersions, routes, } from '@crouter/api';
|
|
1
|
+
import { APIError, CrtrClient, MINIMUM_RUNTIME_VERSION_HEADER, RUNTIME_VERSION_HEADER, compareReleaseVersions, routes, } from '@crouter/api';
|
|
2
2
|
import { APIConnectionError, APIUserAbortError, AuthenticationError, CrouterError, mapError } from './errors.js';
|
|
3
3
|
import { Bash } from './resources/bash.js';
|
|
4
4
|
import { Canvas } from './resources/canvas.js';
|
|
@@ -478,8 +478,16 @@ function isNodeRuntime() {
|
|
|
478
478
|
*/
|
|
479
479
|
function requireCurrentRuntime(inner) {
|
|
480
480
|
const checked = async (input, init) => {
|
|
481
|
-
const response = await (inner ?? globalThis.fetch)(input, init);
|
|
482
481
|
const url = new URL(input instanceof Request ? input.url : String(input), 'http://localhost');
|
|
482
|
+
// Say which runtime this SDK accepts, so the router in front of a hosted runtime, or the runtime itself, refuses
|
|
483
|
+
// an older one before any handler runs. `/healthz` is exempt from both checks.
|
|
484
|
+
let sentInit = init;
|
|
485
|
+
if (url.pathname !== '/healthz') {
|
|
486
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
487
|
+
headers.set(MINIMUM_RUNTIME_VERSION_HEADER, SDK_VERSION);
|
|
488
|
+
sentInit = { ...init, headers };
|
|
489
|
+
}
|
|
490
|
+
const response = await (inner ?? globalThis.fetch)(input, sentInit);
|
|
483
491
|
if (url.pathname === '/healthz')
|
|
484
492
|
return response;
|
|
485
493
|
const runtimeVersion = response.headers.get(RUNTIME_VERSION_HEADER);
|
package/dist/keygen-cli.js
CHANGED
|
File without changes
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This SDK's release version. It is also the oldest runtime the SDK accepts: one release is one version set. */
|
|
2
|
-
export declare const SDK_VERSION = "0.3.
|
|
2
|
+
export declare const SDK_VERSION = "0.3.397";
|
package/dist/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Written by scripts/release-version.mjs on every release; do not edit by hand.
|
|
2
2
|
/** This SDK's release version. It is also the oldest runtime the SDK accepts: one release is one version set. */
|
|
3
|
-
export const SDK_VERSION = '0.3.
|
|
3
|
+
export const SDK_VERSION = '0.3.397';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crouter/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.397",
|
|
4
4
|
"description": "Typed Node and browser client for running crouter agents through the crtrd /v1 API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"build": "tsc -p tsconfig.json && chmod 755 dist/keygen-cli.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@crouter/api": "0.3.
|
|
35
|
-
"@crouter/identity": "0.3.
|
|
34
|
+
"@crouter/api": "0.3.397",
|
|
35
|
+
"@crouter/identity": "0.3.397",
|
|
36
36
|
"jose": "^6.2.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|