@clearideas/agent-runtime-server 0.9.0 → 0.10.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/NOTICE +2 -2
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +9 -2
- package/dist/host.d.ts +8 -1
- package/dist/host.js +7 -1
- package/dist/service.js +10 -2
- package/package.json +11 -11
package/NOTICE
CHANGED
|
@@ -3,6 +3,6 @@ Copyright 2026 Clear Ideas Incorporated
|
|
|
3
3
|
|
|
4
4
|
Clear Ideas is a trademark of Clear Ideas Incorporated.
|
|
5
5
|
|
|
6
|
-
The documentation site includes @clearideas/analytics 1.
|
|
6
|
+
The documentation site includes @clearideas/consent-analytics 0.1.0-rc.1, distributed
|
|
7
7
|
under the MIT License. Its license text is available at
|
|
8
|
-
docs/public/assets/analytics/LICENSE.clearideas-analytics.txt.
|
|
8
|
+
docs/public/assets/analytics/LICENSE.clearideas-consent-analytics.txt.
|
package/dist/config.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ export declare const servedModelConfigSchema: z.ZodObject<{
|
|
|
110
110
|
execution: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown>>>;
|
|
111
111
|
policies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
|
|
112
112
|
enforcedPolicies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
|
|
113
|
+
limits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
|
|
114
|
+
enforcedLimits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
|
|
113
115
|
onDisconnect: z.ZodDefault<z.ZodEnum<{
|
|
114
116
|
cancel: "cancel";
|
|
115
117
|
continue: "continue";
|
|
@@ -273,6 +275,8 @@ export declare const serverConfigSchema: z.ZodObject<{
|
|
|
273
275
|
execution: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").AgentRunExecution, unknown>>>;
|
|
274
276
|
policies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
|
|
275
277
|
enforcedPolicies: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").ExecutionPolicies, unknown>>>;
|
|
278
|
+
limits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
|
|
279
|
+
enforcedLimits: z.ZodOptional<z.ZodType<import("@clearideas/agent-runtime-contracts").RunLimits, unknown, z.core.$ZodTypeInternals<import("@clearideas/agent-runtime-contracts").RunLimits, unknown>>>;
|
|
276
280
|
onDisconnect: z.ZodDefault<z.ZodEnum<{
|
|
277
281
|
cancel: "cancel";
|
|
278
282
|
continue: "continue";
|
package/dist/config.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { access, readFile } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
|
-
import { agentRunExecutionSchema, executionPoliciesSchema, } from "@clearideas/agent-runtime-contracts";
|
|
8
|
+
import { agentRunExecutionSchema, executionPoliciesSchema, runLimitsSchema, } from "@clearideas/agent-runtime-contracts";
|
|
9
9
|
import { parse as parseYaml } from "yaml";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
export const SERVER_CONFIG_SCHEMA_VERSION = "1.0";
|
|
@@ -158,6 +158,9 @@ export const servedModelConfigSchema = z.strictObject({
|
|
|
158
158
|
execution: agentRunExecutionSchema.optional(),
|
|
159
159
|
policies: executionPoliciesSchema.optional(),
|
|
160
160
|
enforcedPolicies: executionPoliciesSchema.optional(),
|
|
161
|
+
/** Default run limits for this model's runs, and ceilings on them. */
|
|
162
|
+
limits: runLimitsSchema.optional(),
|
|
163
|
+
enforcedLimits: runLimitsSchema.optional(),
|
|
161
164
|
/** What a client disconnect does to its run. */
|
|
162
165
|
onDisconnect: z.enum(["cancel", "continue"]).default("cancel"),
|
|
163
166
|
/** `budget` maps max_tokens to the run's token budget, capped by the host. */
|
package/dist/errors.d.ts
CHANGED
|
@@ -31,6 +31,6 @@ export declare const invalidRequest: (message: string, param?: string) => Server
|
|
|
31
31
|
* operator exposes error messages: they can contain model output, tool data,
|
|
32
32
|
* or configuration detail.
|
|
33
33
|
*/
|
|
34
|
-
export declare const fromRunError: (
|
|
34
|
+
export declare const fromRunError: (caught: unknown, options: {
|
|
35
35
|
exposeErrors: boolean;
|
|
36
36
|
}) => ServerError;
|
package/dist/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentRuntimeError, MessagesValidationError, } from "@clearideas/agent-runtime-core";
|
|
1
|
+
import { AgentRuntimeError, MessagesValidationError, RUN_BLOCKED_REASON, isRunSuspendedError, } from "@clearideas/agent-runtime-core";
|
|
2
2
|
/** An error with an HTTP status and an OpenAI-shaped body. */
|
|
3
3
|
export class ServerError extends Error {
|
|
4
4
|
status;
|
|
@@ -60,7 +60,14 @@ const MESSAGES_ERROR_STATUS = {
|
|
|
60
60
|
* operator exposes error messages: they can contain model output, tool data,
|
|
61
61
|
* or configuration detail.
|
|
62
62
|
*/
|
|
63
|
-
export const fromRunError = (
|
|
63
|
+
export const fromRunError = (caught, options) => {
|
|
64
|
+
// A run blocked by an error keeps that error as its cause; report it as
|
|
65
|
+
// the failure it is. The run itself stays resumable in the store.
|
|
66
|
+
const error = isRunSuspendedError(caught) &&
|
|
67
|
+
caught.reason === RUN_BLOCKED_REASON &&
|
|
68
|
+
caught.cause !== undefined
|
|
69
|
+
? caught.cause
|
|
70
|
+
: caught;
|
|
64
71
|
if (error instanceof ServerError)
|
|
65
72
|
return error;
|
|
66
73
|
if (error instanceof MessagesValidationError) {
|
package/dist/host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AgentRuntimeConfig, type ConfiguredMcpToolAdapterOptions, type ModelAuthorizationPolicy, type WorkspaceCompositionOptions } from "@clearideas/agent-runtime-config";
|
|
2
|
-
import type { AgentManifest, ExecutionPolicies, RunEvent } from "@clearideas/agent-runtime-contracts";
|
|
2
|
+
import type { AgentManifest, ExecutionPolicies, RunEvent, RunLimits } from "@clearideas/agent-runtime-contracts";
|
|
3
3
|
import type { AgentManifestSource, AgentRuntimeDependencies, AgentRuntimeMessagesOptions, ApprovalAdapter, ArtifactStore, ConnectionCredentialProvider, ContextSummarizerAdapter, EventSink, ModelAdapter, RunSandboxProvider, RunStore, SandboxAdapter, StepExecutor, SubRunAdapter, ToolAdapter, WorkspaceProvider } from "@clearideas/agent-runtime-core";
|
|
4
4
|
import type { SandboxProvider } from "@clearideas/agent-runtime-sandbox";
|
|
5
5
|
/** Adapters a trusted runtime module may contribute to a host. */
|
|
@@ -26,6 +26,13 @@ export interface HostRuntime {
|
|
|
26
26
|
policies?: ExecutionPolicies;
|
|
27
27
|
/** Host execution policies applied last; manifests cannot override them. */
|
|
28
28
|
enforcedPolicies?: ExecutionPolicies;
|
|
29
|
+
/**
|
|
30
|
+
* Host default run limits, replacing values of `DEFAULT_RUN_LIMITS`;
|
|
31
|
+
* manifests and resume grants override them.
|
|
32
|
+
*/
|
|
33
|
+
limits?: RunLimits;
|
|
34
|
+
/** Host ceilings on run limits; nothing can exceed them. */
|
|
35
|
+
enforcedLimits?: RunLimits;
|
|
29
36
|
/** Observes, changes, or replaces context summarization. */
|
|
30
37
|
summarizer?: ContextSummarizerAdapter;
|
|
31
38
|
/**
|
package/dist/host.js
CHANGED
|
@@ -13,7 +13,7 @@ import path from "node:path";
|
|
|
13
13
|
import { pathToFileURL } from "node:url";
|
|
14
14
|
import { JexlConditionEvaluator } from "@clearideas/agent-runtime-condition-jexl";
|
|
15
15
|
import { composeRuntime, emptyAgentRuntimeConfig, loadAgentRuntimeConfig, } from "@clearideas/agent-runtime-config";
|
|
16
|
-
import { executionPoliciesSchema } from "@clearideas/agent-runtime-contracts";
|
|
16
|
+
import { executionPoliciesSchema, runLimitsSchema, } from "@clearideas/agent-runtime-contracts";
|
|
17
17
|
import { LoopStepExecutor } from "@clearideas/agent-runtime-step-loop";
|
|
18
18
|
import { PromptMessageHistoryCompactor, PromptStepExecutor, } from "@clearideas/agent-runtime-step-prompt";
|
|
19
19
|
import { ApprovalStepExecutor, CodeStepExecutor, SubRunStepExecutor, WebhookStepExecutor, } from "@clearideas/agent-runtime-step-standard";
|
|
@@ -131,6 +131,10 @@ const normalizeRuntime = (runtime) => ({
|
|
|
131
131
|
enforcedPolicies: executionPoliciesSchema.parse(runtime.enforcedPolicies),
|
|
132
132
|
}
|
|
133
133
|
: {}),
|
|
134
|
+
...(runtime.limits ? { limits: runLimitsSchema.parse(runtime.limits) } : {}),
|
|
135
|
+
...(runtime.enforcedLimits
|
|
136
|
+
? { enforcedLimits: runLimitsSchema.parse(runtime.enforcedLimits) }
|
|
137
|
+
: {}),
|
|
134
138
|
...(runtime.summarizer ? { summarizer: runtime.summarizer } : {}),
|
|
135
139
|
...(runtime.messages ? { messages: runtime.messages } : {}),
|
|
136
140
|
...((runtime.eventSinks?.length ?? 0) > 0 || runtime.eventSink
|
|
@@ -341,6 +345,8 @@ export const hostRuntimeDependencies = (runtime, options) => ({
|
|
|
341
345
|
...(runtime.enforcedPolicies
|
|
342
346
|
? { enforcedPolicies: runtime.enforcedPolicies }
|
|
343
347
|
: {}),
|
|
348
|
+
...(runtime.limits ? { limits: runtime.limits } : {}),
|
|
349
|
+
...(runtime.enforcedLimits ? { enforcedLimits: runtime.enforcedLimits } : {}),
|
|
344
350
|
...(runtime.summarizer ? { summarizer: runtime.summarizer } : {}),
|
|
345
351
|
messages: withHistoryCompactor(runtime.messages),
|
|
346
352
|
...(options.artifacts ? { artifacts: options.artifacts } : {}),
|
package/dist/service.js
CHANGED
|
@@ -9,7 +9,7 @@ import { tmpdir } from "node:os";
|
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
11
|
import { loadAgentRuntimeConfig, } from "@clearideas/agent-runtime-config";
|
|
12
|
-
import { AgentRuntime, conversationTurns, declaresMessages, defaultManifestHasher, isRunInterruptedError, isRunSuspendedError, resolveAgentVariables, RunInterruptedError, } from "@clearideas/agent-runtime-core";
|
|
12
|
+
import { AgentRuntime, conversationTurns, declaresMessages, defaultManifestHasher, isRunInterruptedError, isRunSuspendedError, RUN_BLOCKED_REASON, resolveAgentVariables, RunInterruptedError, } from "@clearideas/agent-runtime-core";
|
|
13
13
|
import { JexlConditionEvaluator } from "@clearideas/agent-runtime-condition-jexl";
|
|
14
14
|
import { FileAgentManifestSource, FileArtifactStore, MemoryRunStore, } from "@clearideas/agent-runtime-store-local";
|
|
15
15
|
import { AdmissionController } from "./admission.js";
|
|
@@ -694,7 +694,13 @@ export class AgentServer {
|
|
|
694
694
|
});
|
|
695
695
|
}
|
|
696
696
|
catch (error) {
|
|
697
|
-
|
|
697
|
+
// A spent token budget or a reached run limit ends the reply early,
|
|
698
|
+
// like a length stop; other outcomes are errors.
|
|
699
|
+
const stopped = isRunSuspendedError(error) &&
|
|
700
|
+
(error.reason === "token-budget" ||
|
|
701
|
+
(error.reason === RUN_BLOCKED_REASON &&
|
|
702
|
+
error.details?.cause === "limit"));
|
|
703
|
+
if (!stopped)
|
|
698
704
|
throw error;
|
|
699
705
|
finishReason = "length";
|
|
700
706
|
}
|
|
@@ -962,6 +968,8 @@ const modelOverlay = (config, programmatic, messages) => ({
|
|
|
962
968
|
...(config.enforcedPolicies
|
|
963
969
|
? { enforcedPolicies: config.enforcedPolicies }
|
|
964
970
|
: {}),
|
|
971
|
+
...(config.limits ? { limits: config.limits } : {}),
|
|
972
|
+
...(config.enforcedLimits ? { enforcedLimits: config.enforcedLimits } : {}),
|
|
965
973
|
messages: { ...programmatic?.messages, ...messages },
|
|
966
974
|
});
|
|
967
975
|
const loadAuthenticateHook = async (modulePath) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "OpenAI-compatible HTTP server for Agent Runtime manifests, and the host composition shared by Agent Runtime hosts.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Clear Ideas Incorporated",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@clearideas/agent-runtime-condition-jexl": "0.
|
|
40
|
-
"@clearideas/agent-runtime-config": "0.
|
|
41
|
-
"@clearideas/agent-runtime-contracts": "0.
|
|
42
|
-
"@clearideas/agent-runtime-core": "0.
|
|
43
|
-
"@clearideas/agent-runtime-sandbox": "0.
|
|
44
|
-
"@clearideas/agent-runtime-step-loop": "0.
|
|
45
|
-
"@clearideas/agent-runtime-step-prompt": "0.
|
|
46
|
-
"@clearideas/agent-runtime-step-standard": "0.
|
|
47
|
-
"@clearideas/agent-runtime-store-local": "0.
|
|
48
|
-
"@clearideas/agent-runtime-store-sqlite": "0.
|
|
39
|
+
"@clearideas/agent-runtime-condition-jexl": "0.10.0",
|
|
40
|
+
"@clearideas/agent-runtime-config": "0.10.0",
|
|
41
|
+
"@clearideas/agent-runtime-contracts": "0.10.0",
|
|
42
|
+
"@clearideas/agent-runtime-core": "0.10.0",
|
|
43
|
+
"@clearideas/agent-runtime-sandbox": "0.10.0",
|
|
44
|
+
"@clearideas/agent-runtime-step-loop": "0.10.0",
|
|
45
|
+
"@clearideas/agent-runtime-step-prompt": "0.10.0",
|
|
46
|
+
"@clearideas/agent-runtime-step-standard": "0.10.0",
|
|
47
|
+
"@clearideas/agent-runtime-store-local": "0.10.0",
|
|
48
|
+
"@clearideas/agent-runtime-store-sqlite": "0.10.0",
|
|
49
49
|
"yaml": "^2.9.1",
|
|
50
50
|
"zod": "^4.6.6"
|
|
51
51
|
},
|