@tangle-network/agent-interface 0.47.0 → 0.49.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/README.md +4 -0
- package/dist/agent-candidate-execution-plan-schema.d.ts +4 -0
- package/dist/agent-candidate-execution-plan-schema.js +1 -0
- package/dist/agent-candidate-outcome-schema.d.ts +7 -0
- package/dist/agent-candidate-outcome-schema.js +20 -1
- package/dist/agent-candidate-profile-schema.d.ts +3 -0
- package/dist/agent-candidate-profile-schema.js +4 -3
- package/dist/agent-candidate-promotion-schema.d.ts +58 -0
- package/dist/agent-candidate-receipt-schema.d.ts +6 -0
- package/dist/agent-candidate-schema-common.js +10 -1
- package/dist/agent-candidate-schema.d.ts +3 -0
- package/dist/agent-candidate-task-schema.d.ts +4 -0
- package/dist/agent-candidate.d.ts +7 -0
- package/dist/agent-execution-limits.js +10 -0
- package/dist/agent-profile-improvement-schema.d.ts +10 -0
- package/dist/agent-profile.d.ts +18 -0
- package/dist/environment-observation.d.ts +1076 -0
- package/dist/environment-observation.js +306 -0
- package/dist/environment-provider.d.ts +2 -0
- package/dist/environment-provider.js +2 -0
- package/dist/environment-runtime.d.ts +50 -0
- package/dist/environment-runtime.js +31 -0
- package/dist/environment-terminal.d.ts +172 -0
- package/dist/environment-terminal.js +162 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction-data.js +21 -2
- package/dist/interaction-fields.d.ts +7 -0
- package/dist/interaction-fields.js +12 -2
- package/dist/interaction-response-validation.js +2 -2
- package/dist/profile-schema.d.ts +34 -0
- package/dist/profile-schema.js +33 -1
- package/package.json +36 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { boundedIdentifierSchema, boundedStringSchema } from "./contract-limits.js";
|
|
3
|
+
const TERMINAL_MAX_DIMENSION = 10_000;
|
|
4
|
+
const terminalDimensionSchema = z.number().int().positive().max(TERMINAL_MAX_DIMENSION);
|
|
5
|
+
/**
|
|
6
|
+
* Provider-neutral handle for one interactive terminal.
|
|
7
|
+
*
|
|
8
|
+
* The handle carries no raw process id and no environment map, so a terminal
|
|
9
|
+
* reference never leaks host process detail or injected secrets. Every terminal
|
|
10
|
+
* is bound to a parent execution and carries an explicit expiry, so an orphan
|
|
11
|
+
* or an expired terminal fails closed at the call sites that read it.
|
|
12
|
+
*/
|
|
13
|
+
export const TerminalSessionRefSchema = z.strictObject({
|
|
14
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
15
|
+
parentExecutionId: boundedIdentifierSchema,
|
|
16
|
+
name: boundedIdentifierSchema,
|
|
17
|
+
shell: boundedStringSchema.min(1),
|
|
18
|
+
command: boundedStringSchema.optional(),
|
|
19
|
+
cwd: boundedStringSchema.min(1),
|
|
20
|
+
cols: terminalDimensionSchema,
|
|
21
|
+
rows: terminalDimensionSchema,
|
|
22
|
+
connectionId: boundedIdentifierSchema.optional(),
|
|
23
|
+
createdAt: z.iso.datetime().max(64),
|
|
24
|
+
lastActivityAt: z.iso.datetime().max(64),
|
|
25
|
+
expiresAt: z.iso.datetime().max(64),
|
|
26
|
+
isRunning: z.boolean(),
|
|
27
|
+
exitCode: z.number().int().optional(),
|
|
28
|
+
exitSignal: boundedIdentifierSchema.optional(),
|
|
29
|
+
attachCount: z.number().int().nonnegative(),
|
|
30
|
+
});
|
|
31
|
+
/** Raw bytes written to the terminal, normalized to UTF-8 text. */
|
|
32
|
+
export const TerminalInputSchema = z.strictObject({
|
|
33
|
+
data: boundedStringSchema,
|
|
34
|
+
});
|
|
35
|
+
/** New terminal geometry. */
|
|
36
|
+
export const TerminalResizeSchema = z.strictObject({
|
|
37
|
+
cols: terminalDimensionSchema,
|
|
38
|
+
rows: terminalDimensionSchema,
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Create-or-reattach request. A present `terminalSessionId` reattaches to an
|
|
42
|
+
* existing terminal; its absence opens a new one under the parent execution.
|
|
43
|
+
* `mode` selects an `attach` to a live process or a `logical` resume that
|
|
44
|
+
* replays retained output.
|
|
45
|
+
*/
|
|
46
|
+
export const TerminalAttachRequestSchema = z.strictObject({
|
|
47
|
+
parentExecutionId: boundedIdentifierSchema,
|
|
48
|
+
terminalSessionId: boundedIdentifierSchema.optional(),
|
|
49
|
+
connectionId: boundedIdentifierSchema.optional(),
|
|
50
|
+
mode: z.enum(["attach", "logical"]),
|
|
51
|
+
cols: terminalDimensionSchema.optional(),
|
|
52
|
+
rows: terminalDimensionSchema.optional(),
|
|
53
|
+
command: boundedStringSchema.optional(),
|
|
54
|
+
cwd: boundedStringSchema.optional(),
|
|
55
|
+
});
|
|
56
|
+
/** Result of a create-or-reattach request. */
|
|
57
|
+
export const TerminalAttachResultSchema = z.discriminatedUnion("status", [
|
|
58
|
+
z.strictObject({
|
|
59
|
+
status: z.enum(["attached", "reattached"]),
|
|
60
|
+
mode: z.enum(["attach", "logical"]),
|
|
61
|
+
ref: TerminalSessionRefSchema,
|
|
62
|
+
attachCount: z.number().int().nonnegative(),
|
|
63
|
+
}),
|
|
64
|
+
z.strictObject({
|
|
65
|
+
status: z.literal("unavailable"),
|
|
66
|
+
reason: boundedStringSchema.min(1),
|
|
67
|
+
}),
|
|
68
|
+
z.strictObject({
|
|
69
|
+
status: z.literal("unknown"),
|
|
70
|
+
message: boundedStringSchema.min(1),
|
|
71
|
+
retryable: z.boolean(),
|
|
72
|
+
}),
|
|
73
|
+
]);
|
|
74
|
+
/**
|
|
75
|
+
* One ordered terminal output frame. `output` frames carry a monotonic `seq`
|
|
76
|
+
* that a consumer replays from, so a reconnect resumes without loss or
|
|
77
|
+
* duplication.
|
|
78
|
+
*/
|
|
79
|
+
export const TerminalOutputEventSchema = z.discriminatedUnion("type", [
|
|
80
|
+
z.strictObject({
|
|
81
|
+
type: z.literal("ready"),
|
|
82
|
+
cols: terminalDimensionSchema.optional(),
|
|
83
|
+
rows: terminalDimensionSchema.optional(),
|
|
84
|
+
}),
|
|
85
|
+
z.strictObject({
|
|
86
|
+
type: z.literal("output"),
|
|
87
|
+
seq: z.number().int().nonnegative(),
|
|
88
|
+
data: boundedStringSchema,
|
|
89
|
+
}),
|
|
90
|
+
z.strictObject({
|
|
91
|
+
type: z.literal("resize"),
|
|
92
|
+
cols: terminalDimensionSchema,
|
|
93
|
+
rows: terminalDimensionSchema,
|
|
94
|
+
}),
|
|
95
|
+
z.strictObject({
|
|
96
|
+
type: z.literal("exit"),
|
|
97
|
+
exitCode: z.number().int().optional(),
|
|
98
|
+
exitSignal: boundedIdentifierSchema.optional(),
|
|
99
|
+
}),
|
|
100
|
+
z.strictObject({
|
|
101
|
+
type: z.literal("error"),
|
|
102
|
+
message: boundedStringSchema.min(1),
|
|
103
|
+
}),
|
|
104
|
+
]);
|
|
105
|
+
/** Acknowledgement of a detach or close. */
|
|
106
|
+
export const TerminalDetachAckSchema = z.discriminatedUnion("status", [
|
|
107
|
+
z.strictObject({
|
|
108
|
+
status: z.literal("detached"),
|
|
109
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
110
|
+
connectionId: boundedIdentifierSchema.optional(),
|
|
111
|
+
}),
|
|
112
|
+
z.strictObject({
|
|
113
|
+
status: z.literal("closed"),
|
|
114
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
115
|
+
exitCode: z.number().int().optional(),
|
|
116
|
+
exitSignal: boundedIdentifierSchema.optional(),
|
|
117
|
+
}),
|
|
118
|
+
z.strictObject({
|
|
119
|
+
status: z.literal("unknown"),
|
|
120
|
+
terminalSessionId: boundedIdentifierSchema,
|
|
121
|
+
message: boundedStringSchema.min(1),
|
|
122
|
+
retryable: z.boolean(),
|
|
123
|
+
}),
|
|
124
|
+
]);
|
|
125
|
+
/**
|
|
126
|
+
* Fail-closed usability check for a terminal reference. Returns true only when
|
|
127
|
+
* the reference parses, is running, and its expiry is in the future. A parse
|
|
128
|
+
* failure, a stopped terminal, or a past expiry denies use.
|
|
129
|
+
*/
|
|
130
|
+
export function terminalSessionUsable(ref, nowIso) {
|
|
131
|
+
const parsed = TerminalSessionRefSchema.safeParse(ref);
|
|
132
|
+
if (!parsed.success)
|
|
133
|
+
return false;
|
|
134
|
+
const now = Date.parse(nowIso);
|
|
135
|
+
const expiresAt = Date.parse(parsed.data.expiresAt);
|
|
136
|
+
if (!Number.isFinite(now) || !Number.isFinite(expiresAt))
|
|
137
|
+
return false;
|
|
138
|
+
if (now >= expiresAt)
|
|
139
|
+
return false;
|
|
140
|
+
return parsed.data.isRunning;
|
|
141
|
+
}
|
|
142
|
+
/** Bind an attach result to the parent execution and terminal it targeted. */
|
|
143
|
+
export function terminalAttachResultMatchesRequest(request, result) {
|
|
144
|
+
const parsedRequest = TerminalAttachRequestSchema.safeParse(request);
|
|
145
|
+
const parsedResult = TerminalAttachResultSchema.safeParse(result);
|
|
146
|
+
if (!parsedRequest.success || !parsedResult.success)
|
|
147
|
+
return false;
|
|
148
|
+
const outcome = parsedResult.data;
|
|
149
|
+
if (outcome.status !== "attached" && outcome.status !== "reattached") {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
if (outcome.mode !== parsedRequest.data.mode)
|
|
153
|
+
return false;
|
|
154
|
+
if (outcome.ref.parentExecutionId !== parsedRequest.data.parentExecutionId) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (parsedRequest.data.terminalSessionId !== undefined &&
|
|
158
|
+
outcome.ref.terminalSessionId !== parsedRequest.data.terminalSessionId) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from "./host-services.js";
|
|
|
8
8
|
export * from "./mcp.js";
|
|
9
9
|
export * from "./provider-adapter.js";
|
|
10
10
|
export type * from "./environment-provider.js";
|
|
11
|
-
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, } from "./environment-provider.js";
|
|
11
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
12
12
|
export * from "./plan.js";
|
|
13
13
|
export * from "./runtime-control.js";
|
|
14
14
|
export * from "./portable-context.js";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export * from "./provider-config.js";
|
|
|
7
7
|
export * from "./host-services.js";
|
|
8
8
|
export * from "./mcp.js";
|
|
9
9
|
export * from "./provider-adapter.js";
|
|
10
|
-
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, } from "./environment-provider.js";
|
|
10
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
11
11
|
export * from "./plan.js";
|
|
12
12
|
export * from "./runtime-control.js";
|
|
13
13
|
export * from "./portable-context.js";
|
package/dist/interaction-data.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { boundedIdentifierSchema, boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH, CONTRACT_MAX_MAP_ENTRIES, } from "./contract-limits.js";
|
|
3
|
-
import { InteractionFieldNameSchema } from "./interaction-fields.js";
|
|
3
|
+
import { InteractionFieldNameSchema, RESERVED_INTERACTION_FIELD_NAMES, } from "./interaction-fields.js";
|
|
4
4
|
export const InteractionSecretReferenceSchema = z.strictObject({
|
|
5
5
|
kind: z.literal("secret_handle"),
|
|
6
6
|
handleId: boundedIdentifierSchema,
|
|
@@ -15,6 +15,25 @@ const InteractionDataValueSchema = z.union([
|
|
|
15
15
|
]);
|
|
16
16
|
/** Field values keyed by InteractionField.name. */
|
|
17
17
|
export const InteractionDataSchema = z
|
|
18
|
+
.unknown()
|
|
19
|
+
// A record parser assigns keys onto an ordinary object, so a raw own key
|
|
20
|
+
// `__proto__` invokes the legacy prototype setter and vanishes before any
|
|
21
|
+
// key schema runs. Reject reserved keys on the raw input, so this schema and
|
|
22
|
+
// `validateInteractionResponse` refuse the same value rather than one of them
|
|
23
|
+
// accepting a silently emptied object.
|
|
24
|
+
.superRefine((value, refinement) => {
|
|
25
|
+
if (value === null || typeof value !== "object")
|
|
26
|
+
return;
|
|
27
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
28
|
+
if (RESERVED_INTERACTION_FIELD_NAMES.has(key)) {
|
|
29
|
+
refinement.addIssue({
|
|
30
|
+
code: "custom",
|
|
31
|
+
message: `interaction field name "${key}" is reserved`,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
.pipe(z
|
|
18
37
|
.record(InteractionFieldNameSchema, InteractionDataValueSchema)
|
|
19
38
|
.superRefine((data, refinement) => {
|
|
20
39
|
if (Object.keys(data).length > CONTRACT_MAX_MAP_ENTRIES) {
|
|
@@ -23,7 +42,7 @@ export const InteractionDataSchema = z
|
|
|
23
42
|
message: "interaction data has too many fields",
|
|
24
43
|
});
|
|
25
44
|
}
|
|
26
|
-
})
|
|
45
|
+
}))
|
|
27
46
|
.transform((data) => {
|
|
28
47
|
const safe = Object.create(null);
|
|
29
48
|
for (const key of Object.keys(data))
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Field names whose own-key form collides with object internals. A record
|
|
4
|
+
* parser drops a raw `__proto__` key through the legacy prototype setter before
|
|
5
|
+
* a key schema runs, so every schema and validator over interaction data
|
|
6
|
+
* rejects these names against one owner rather than a private copy.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RESERVED_INTERACTION_FIELD_NAMES: ReadonlySet<string>;
|
|
2
9
|
export declare const InteractionFieldNameSchema: z.ZodString;
|
|
3
10
|
export declare const InteractionFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
11
|
type: z.ZodLiteral<"text">;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { boundedIdentifierSchema, boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH, CONTRACT_MAX_STRING_LENGTH, } from "./contract-limits.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Field names whose own-key form collides with object internals. A record
|
|
5
|
+
* parser drops a raw `__proto__` key through the legacy prototype setter before
|
|
6
|
+
* a key schema runs, so every schema and validator over interaction data
|
|
7
|
+
* rejects these names against one owner rather than a private copy.
|
|
8
|
+
*/
|
|
9
|
+
export const RESERVED_INTERACTION_FIELD_NAMES = new Set([
|
|
10
|
+
"__proto__",
|
|
11
|
+
"constructor",
|
|
12
|
+
"prototype",
|
|
13
|
+
]);
|
|
14
|
+
export const InteractionFieldNameSchema = boundedIdentifierSchema.refine((value) => !RESERVED_INTERACTION_FIELD_NAMES.has(value), "interaction field name is reserved");
|
|
5
15
|
// =============================================================================
|
|
6
16
|
// Answer specification — describes the shape of a valid answer.
|
|
7
17
|
// =============================================================================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InteractionRequestSchema, InteractionResponseCommandSchema, InteractionResponseSchema, } from "./interaction-envelope.js";
|
|
2
|
+
import { RESERVED_INTERACTION_FIELD_NAMES } from "./interaction-fields.js";
|
|
2
3
|
import { validateResolutionForRequest } from "./interaction-resolution-validation.js";
|
|
3
|
-
const FORBIDDEN_DATA_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
4
4
|
function validResponse(response) {
|
|
5
5
|
const result = { ok: true };
|
|
6
6
|
Object.defineProperty(result, "response", {
|
|
@@ -17,7 +17,7 @@ function forbiddenKeyErrors(response) {
|
|
|
17
17
|
if (!data || typeof data !== "object")
|
|
18
18
|
return [];
|
|
19
19
|
return Object.getOwnPropertyNames(data)
|
|
20
|
-
.filter((key) =>
|
|
20
|
+
.filter((key) => RESERVED_INTERACTION_FIELD_NAMES.has(key))
|
|
21
21
|
.map((key) => `unknown field "${key}"`);
|
|
22
22
|
}
|
|
23
23
|
/** Validate one response against the exact outstanding request. */
|
package/dist/profile-schema.d.ts
CHANGED
|
@@ -120,6 +120,34 @@ export declare const reasoningEffortSchema: z.ZodEnum<{
|
|
|
120
120
|
xhigh: "xhigh";
|
|
121
121
|
ultracode: "ultracode";
|
|
122
122
|
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Enforce the token ceilings that live together: each single ceiling must not
|
|
125
|
+
* exceed the total. It fails loud on a violation and never clamps a value.
|
|
126
|
+
* `reasoningEffort` is a separate quality dial and is not a bound here.
|
|
127
|
+
*/
|
|
128
|
+
export declare function enforceModelTokenBounds(hints: {
|
|
129
|
+
maxVisibleOutputTokens?: number;
|
|
130
|
+
maxReasoningTokens?: number;
|
|
131
|
+
maxTotalOutputTokens?: number;
|
|
132
|
+
}, context: z.RefinementCtx): void;
|
|
133
|
+
export declare const agentProfileModelHintsBaseSchema: z.ZodObject<{
|
|
134
|
+
default: z.ZodOptional<z.ZodString>;
|
|
135
|
+
small: z.ZodOptional<z.ZodString>;
|
|
136
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
137
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
138
|
+
none: "none";
|
|
139
|
+
minimal: "minimal";
|
|
140
|
+
low: "low";
|
|
141
|
+
medium: "medium";
|
|
142
|
+
high: "high";
|
|
143
|
+
xhigh: "xhigh";
|
|
144
|
+
ultracode: "ultracode";
|
|
145
|
+
}>>;
|
|
146
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
147
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
148
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
150
|
+
}, z.core.$strict>;
|
|
123
151
|
export declare const agentProfileModelHintsSchema: z.ZodObject<{
|
|
124
152
|
default: z.ZodOptional<z.ZodString>;
|
|
125
153
|
small: z.ZodOptional<z.ZodString>;
|
|
@@ -133,6 +161,9 @@ export declare const agentProfileModelHintsSchema: z.ZodObject<{
|
|
|
133
161
|
xhigh: "xhigh";
|
|
134
162
|
ultracode: "ultracode";
|
|
135
163
|
}>>;
|
|
164
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
136
167
|
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
137
168
|
}, z.core.$strict>;
|
|
138
169
|
/**
|
|
@@ -321,6 +352,9 @@ export declare const agentProfileSchema: z.ZodObject<{
|
|
|
321
352
|
xhigh: "xhigh";
|
|
322
353
|
ultracode: "ultracode";
|
|
323
354
|
}>>;
|
|
355
|
+
maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
356
|
+
maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
357
|
+
maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
324
358
|
metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
325
359
|
}, z.core.$strict>>;
|
|
326
360
|
harness: z.ZodOptional<z.ZodEnum<{
|
package/dist/profile-schema.js
CHANGED
|
@@ -91,13 +91,45 @@ export const agentProfileResourcesSchema = z.strictObject({
|
|
|
91
91
|
failOnError: z.boolean().optional(),
|
|
92
92
|
});
|
|
93
93
|
export const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
|
|
94
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Enforce the token ceilings that live together: each single ceiling must not
|
|
96
|
+
* exceed the total. It fails loud on a violation and never clamps a value.
|
|
97
|
+
* `reasoningEffort` is a separate quality dial and is not a bound here.
|
|
98
|
+
*/
|
|
99
|
+
export function enforceModelTokenBounds(hints, context) {
|
|
100
|
+
const { maxVisibleOutputTokens, maxReasoningTokens, maxTotalOutputTokens } = hints;
|
|
101
|
+
if (maxTotalOutputTokens === undefined)
|
|
102
|
+
return;
|
|
103
|
+
if (maxVisibleOutputTokens !== undefined &&
|
|
104
|
+
maxVisibleOutputTokens > maxTotalOutputTokens) {
|
|
105
|
+
context.addIssue({
|
|
106
|
+
code: "custom",
|
|
107
|
+
path: ["maxVisibleOutputTokens"],
|
|
108
|
+
message: "maxVisibleOutputTokens must not exceed maxTotalOutputTokens",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (maxReasoningTokens !== undefined &&
|
|
112
|
+
maxReasoningTokens > maxTotalOutputTokens) {
|
|
113
|
+
context.addIssue({
|
|
114
|
+
code: "custom",
|
|
115
|
+
path: ["maxReasoningTokens"],
|
|
116
|
+
message: "maxReasoningTokens must not exceed maxTotalOutputTokens",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Base shape without cross-field checks, so candidate derivations may still
|
|
121
|
+
// call `.omit`/`.extend`; zod refuses those on a schema that carries a refinement.
|
|
122
|
+
export const agentProfileModelHintsBaseSchema = z.strictObject({
|
|
95
123
|
default: z.string().optional(),
|
|
96
124
|
small: z.string().optional(),
|
|
97
125
|
provider: z.string().optional(),
|
|
98
126
|
reasoningEffort: reasoningEffortSchema.optional(),
|
|
127
|
+
maxVisibleOutputTokens: z.number().int().positive().optional(),
|
|
128
|
+
maxReasoningTokens: z.number().int().positive().optional(),
|
|
129
|
+
maxTotalOutputTokens: z.number().int().positive().optional(),
|
|
99
130
|
metadata: ownPropertyRecordSchema(z.unknown()).optional(),
|
|
100
131
|
});
|
|
132
|
+
export const agentProfileModelHintsSchema = agentProfileModelHintsBaseSchema.superRefine(enforceModelTokenBounds);
|
|
101
133
|
/**
|
|
102
134
|
* Replacement and addition are separate, independently optional fields, and the
|
|
103
135
|
* pair is admitted on purpose: the effective prompt is `systemPrompt` followed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-interface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,6 +16,41 @@
|
|
|
16
16
|
"import": "./dist/environment-provider.js",
|
|
17
17
|
"types": "./dist/environment-provider.d.ts",
|
|
18
18
|
"default": "./dist/environment-provider.js"
|
|
19
|
+
},
|
|
20
|
+
"./profile": {
|
|
21
|
+
"import": "./dist/agent-profile.js",
|
|
22
|
+
"types": "./dist/agent-profile.d.ts",
|
|
23
|
+
"default": "./dist/agent-profile.js"
|
|
24
|
+
},
|
|
25
|
+
"./profile-snapshot": {
|
|
26
|
+
"import": "./dist/agent-profile-snapshot.js",
|
|
27
|
+
"types": "./dist/agent-profile-snapshot.d.ts",
|
|
28
|
+
"default": "./dist/agent-profile-snapshot.js"
|
|
29
|
+
},
|
|
30
|
+
"./profile-schema": {
|
|
31
|
+
"import": "./dist/profile-schema.js",
|
|
32
|
+
"types": "./dist/profile-schema.d.ts",
|
|
33
|
+
"default": "./dist/profile-schema.js"
|
|
34
|
+
},
|
|
35
|
+
"./profile-security": {
|
|
36
|
+
"import": "./dist/profile-security.js",
|
|
37
|
+
"types": "./dist/profile-security.d.ts",
|
|
38
|
+
"default": "./dist/profile-security.js"
|
|
39
|
+
},
|
|
40
|
+
"./harness": {
|
|
41
|
+
"import": "./dist/harness.js",
|
|
42
|
+
"types": "./dist/harness.d.ts",
|
|
43
|
+
"default": "./dist/harness.js"
|
|
44
|
+
},
|
|
45
|
+
"./harness-capabilities": {
|
|
46
|
+
"import": "./dist/harness-capabilities.js",
|
|
47
|
+
"types": "./dist/harness-capabilities.d.ts",
|
|
48
|
+
"default": "./dist/harness-capabilities.js"
|
|
49
|
+
},
|
|
50
|
+
"./interaction": {
|
|
51
|
+
"import": "./dist/interaction.js",
|
|
52
|
+
"types": "./dist/interaction.d.ts",
|
|
53
|
+
"default": "./dist/interaction.js"
|
|
19
54
|
}
|
|
20
55
|
},
|
|
21
56
|
"repository": {
|