@crouter/api 0.3.395 → 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/dist/api/dto/run-events.d.ts +3 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +1 -1
- package/dist/api/runtime-version.d.ts +25 -0
- package/dist/api/runtime-version.js +22 -0
- package/dist/shared/generated-context.d.ts +4 -0
- package/dist/shared/generated-context.js +5 -2
- package/package.json +1 -1
|
@@ -17,11 +17,13 @@ export type RunStatusDTO = 'running' | 'waiting_on_user' | 'idle' | 'settled';
|
|
|
17
17
|
* - `thinking`: a root turn is open and the model is reasoning, or its call is in flight before any output.
|
|
18
18
|
* - `tool`: the model is writing a tool call, or the tool is executing. `tool.summary` is the command's
|
|
19
19
|
* first line or the path the call acts on, null while the call is still streaming or when it has neither.
|
|
20
|
+
* - `submitting_result`: the model is writing, or the runtime is recording, the run's `output_schema`
|
|
21
|
+
* result (its `submit_result` call). Never reported as `tool`.
|
|
20
22
|
* - `writing`: the model is streaming answer text.
|
|
21
23
|
* - `between_turns`: no root turn is open, yet the run is still running — a child node is working,
|
|
22
24
|
* mail waits to start the next turn, or the runtime is about to remind the root of its `output_schema`. */
|
|
23
25
|
export type RunActivityDTO = {
|
|
24
|
-
phase: 'starting' | 'thinking' | 'writing' | 'between_turns';
|
|
26
|
+
phase: 'starting' | 'thinking' | 'writing' | 'submitting_result' | 'between_turns';
|
|
25
27
|
} | {
|
|
26
28
|
phase: 'tool';
|
|
27
29
|
tool: {
|
package/dist/api/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export type { ErrorBody } from './errors.js';
|
|
|
5
5
|
export { errorCodes } from './error-codes.js';
|
|
6
6
|
export type { ErrorCode, ErrorEnvelope, ErrorOrigin, ErrorType } from './error-codes.js';
|
|
7
7
|
export { API_VERSION, routes } from './routes.js';
|
|
8
|
-
export { RUNTIME_VERSION_HEADER, compareReleaseVersions } from './runtime-version.js';
|
|
8
|
+
export { RUNTIME_VERSION_HEADER, MINIMUM_RUNTIME_VERSION_HEADER, compareReleaseVersions, minimumRuntimeRefusal } from './runtime-version.js';
|
|
9
|
+
export type { MinimumRuntimeRefusal } from './runtime-version.js';
|
|
9
10
|
export * from '../shared/generated-context.js';
|
|
10
11
|
export * from './dto/common.js';
|
|
11
12
|
export * from './dto/health.js';
|
package/dist/api/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { CrtrClient, waitForDaemonAvailability } from './client.js';
|
|
|
5
5
|
export { APIError, ApiError, isErrorBody } from './errors.js';
|
|
6
6
|
export { errorCodes } from './error-codes.js';
|
|
7
7
|
export { API_VERSION, routes } from './routes.js';
|
|
8
|
-
export { RUNTIME_VERSION_HEADER, compareReleaseVersions } from './runtime-version.js';
|
|
8
|
+
export { RUNTIME_VERSION_HEADER, MINIMUM_RUNTIME_VERSION_HEADER, compareReleaseVersions, minimumRuntimeRefusal } from './runtime-version.js';
|
|
9
9
|
export * from '../shared/generated-context.js';
|
|
10
10
|
export * from './dto/common.js';
|
|
11
11
|
export * from './dto/health.js';
|
|
@@ -4,3 +4,28 @@ export declare const RUNTIME_VERSION_HEADER = "Crouter-Runtime-Version";
|
|
|
4
4
|
* suffix is ignored). Negative when `a` is older, zero when equal, positive when
|
|
5
5
|
* newer. A version that does not parse sorts below every version that does. */
|
|
6
6
|
export declare function compareReleaseVersions(a: string, b: string): number;
|
|
7
|
+
/** Request header naming the oldest runtime release the caller accepts, e.g. `0.3.396`. The SDK sends its own
|
|
8
|
+
* version on every request except `/healthz`. Optional: absent means no check. The router in front of a hosted
|
|
9
|
+
* runtime and the runtime itself each refuse a request that names a newer release than the runtime's, before any
|
|
10
|
+
* handler runs (so nothing is accepted and no idempotency key is recorded). */
|
|
11
|
+
export declare const MINIMUM_RUNTIME_VERSION_HEADER = "Crouter-Minimum-Runtime-Version";
|
|
12
|
+
/** The refusal a runtime answers instead of handling a request, or `null` when the request may be handled.
|
|
13
|
+
* - `required` absent: handled.
|
|
14
|
+
* - `required` not `major.minor.patch` (optional `v`, optional suffix): 400 `invalid_request`.
|
|
15
|
+
* - `runtimeVersion` older than `required`, or not a release version: 426 `runtime_version_unsupported`
|
|
16
|
+
* (details `{sdk_version, runtime_version}`, the SDK's `RuntimeVersionDetails`). */
|
|
17
|
+
export type MinimumRuntimeRefusal = {
|
|
18
|
+
status: 400;
|
|
19
|
+
code: 'invalid_request';
|
|
20
|
+
message: string;
|
|
21
|
+
param: string;
|
|
22
|
+
} | {
|
|
23
|
+
status: 426;
|
|
24
|
+
code: 'runtime_version_unsupported';
|
|
25
|
+
message: string;
|
|
26
|
+
details: {
|
|
27
|
+
sdk_version: string;
|
|
28
|
+
runtime_version: string | null;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare function minimumRuntimeRefusal(required: string | undefined, runtimeVersion: string | null): MinimumRuntimeRefusal | null;
|
|
@@ -26,3 +26,25 @@ function parseRelease(version) {
|
|
|
26
26
|
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(version.trim());
|
|
27
27
|
return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
28
28
|
}
|
|
29
|
+
/** Request header naming the oldest runtime release the caller accepts, e.g. `0.3.396`. The SDK sends its own
|
|
30
|
+
* version on every request except `/healthz`. Optional: absent means no check. The router in front of a hosted
|
|
31
|
+
* runtime and the runtime itself each refuse a request that names a newer release than the runtime's, before any
|
|
32
|
+
* handler runs (so nothing is accepted and no idempotency key is recorded). */
|
|
33
|
+
export const MINIMUM_RUNTIME_VERSION_HEADER = 'Crouter-Minimum-Runtime-Version';
|
|
34
|
+
export function minimumRuntimeRefusal(required, runtimeVersion) {
|
|
35
|
+
if (required === undefined)
|
|
36
|
+
return null;
|
|
37
|
+
if (parseRelease(required) === null) {
|
|
38
|
+
return { status: 400, code: 'invalid_request', param: MINIMUM_RUNTIME_VERSION_HEADER, message: `${MINIMUM_RUNTIME_VERSION_HEADER} must be a release version like 0.3.396.` };
|
|
39
|
+
}
|
|
40
|
+
if (runtimeVersion !== null && parseRelease(runtimeVersion) !== null && compareReleaseVersions(runtimeVersion, required) >= 0)
|
|
41
|
+
return null;
|
|
42
|
+
const sdkVersion = required.trim();
|
|
43
|
+
return {
|
|
44
|
+
status: 426, code: 'runtime_version_unsupported',
|
|
45
|
+
message: runtimeVersion === null
|
|
46
|
+
? `The runtime did not name its version; the caller requires a runtime at ${sdkVersion} or later. Roll the runtime forward.`
|
|
47
|
+
: `The runtime is ${runtimeVersion}; the caller requires a runtime at ${sdkVersion} or later. Roll the runtime forward.`,
|
|
48
|
+
details: { sdk_version: sdkVersion, runtime_version: runtimeVersion },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -15,6 +15,10 @@ export declare const PARK_SUMMARY_PROMPT: string;
|
|
|
15
15
|
/** Static recovery prompts shared by the broker producer and display classifier. */
|
|
16
16
|
export declare const AUTH_FAULT_RECOVERY_BODY = "Provider credentials were just updated (a new login landed). Your previous turn stopped on a provider authentication failure. Continue from where you left off and retry the work that failed.";
|
|
17
17
|
export declare const CONNECTION_FAULT_RECOVERY_BODY = "The network connection is back online. Your previous turn stopped on a connection error (the network was down). Continue from where you left off and retry the work that failed.";
|
|
18
|
+
/** A run node's connection retry. Its broker never probes the network (its
|
|
19
|
+
* model calls go through the daemon), so it cannot claim the network is back;
|
|
20
|
+
* the attempt itself is the probe. */
|
|
21
|
+
export declare const RUN_CONNECTION_FAULT_RETRY_BODY = "Your previous turn stopped on a connection error reaching the model provider. Retrying now: continue from where you left off and retry the work that failed.";
|
|
18
22
|
export declare const PROVIDER_FAULT_RECOVERY_BODY = "Your previous turn stopped on a provider fault. Continue from where you left off and retry the work that failed.";
|
|
19
23
|
export type ModelFallbackRecoveryReason = 'credential' | 'not-found';
|
|
20
24
|
/** Format the stop guard's dynamic structured-output mandate. */
|
|
@@ -24,6 +24,10 @@ export const PARK_SUMMARY_PROMPT = 'This conversation has been idle with nothing
|
|
|
24
24
|
/** Static recovery prompts shared by the broker producer and display classifier. */
|
|
25
25
|
export const AUTH_FAULT_RECOVERY_BODY = 'Provider credentials were just updated (a new login landed). Your previous turn stopped on a provider authentication failure. Continue from where you left off and retry the work that failed.';
|
|
26
26
|
export const CONNECTION_FAULT_RECOVERY_BODY = 'The network connection is back online. Your previous turn stopped on a connection error (the network was down). Continue from where you left off and retry the work that failed.';
|
|
27
|
+
/** A run node's connection retry. Its broker never probes the network (its
|
|
28
|
+
* model calls go through the daemon), so it cannot claim the network is back;
|
|
29
|
+
* the attempt itself is the probe. */
|
|
30
|
+
export const RUN_CONNECTION_FAULT_RETRY_BODY = 'Your previous turn stopped on a connection error reaching the model provider. Retrying now: continue from where you left off and retry the work that failed.';
|
|
27
31
|
export const PROVIDER_FAULT_RECOVERY_BODY = 'Your previous turn stopped on a provider fault. Continue from where you left off and retry the work that failed.';
|
|
28
32
|
const REVIEW_APPROVAL_OPEN = '<crtr-review-approval>';
|
|
29
33
|
const REVIEW_APPROVAL_CLOSE = '</crtr-review-approval>';
|
|
@@ -32,8 +36,7 @@ const MODEL_FALLBACK_RECOVERY_CLOSE = '</model-fallback-recovery>';
|
|
|
32
36
|
const STRUCTURED_OUTPUT_REPROMPT_SUFFIX = '\n```';
|
|
33
37
|
/** Format the stop guard's dynamic structured-output mandate. */
|
|
34
38
|
export function formatStructuredOutputReprompt(schema, requestId) {
|
|
35
|
-
|
|
36
|
-
return `You must submit a result matching the required schema with \`${submit}\` before you can stop, or decline it with \`${submit} --decline "<reason>" --code <token>\` when the schema cannot be honestly satisfied. You cannot finish or go dormant any other way while this request is pending.\n\nRequired schema:\n\n\`\`\`json\n${schema}${STRUCTURED_OUTPUT_REPROMPT_SUFFIX}`;
|
|
39
|
+
return `You must submit a result matching the required schema before you can stop: call the \`submit_result\` tool with \`request_id: "${requestId}"\` and the JSON in \`result\`, or with \`decline: { reason, code }\` when the schema cannot be honestly satisfied. You cannot finish or go dormant any other way while this request is pending.\n\nRequired schema:\n\n\`\`\`json\n${schema}${STRUCTURED_OUTPUT_REPROMPT_SUFFIX}`;
|
|
37
40
|
}
|
|
38
41
|
/** Keep model-fallback guidance editable without making it a reader contract. */
|
|
39
42
|
export function formatModelFallbackRecovery(previousModel, nextModel, reason) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crouter/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.397",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|