@tangle-network/agent-interface 0.45.0 → 0.46.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 +1 -1
- package/dist/agent-candidate-profile-schema.d.ts +2 -2
- package/dist/agent-candidate-promotion-schema.d.ts +22 -22
- package/dist/agent-candidate-schema-common.js +1 -1
- package/dist/agent-candidate-schema.d.ts +2 -2
- package/dist/agent-execution-preparation.d.ts +26 -26
- package/dist/agent-profile.d.ts +10 -3
- package/dist/agent-profile.js +45 -22
- package/dist/backend-message.d.ts +14 -0
- package/dist/backend-message.js +1 -0
- package/dist/contract-limits.d.ts +26 -0
- package/dist/contract-limits.js +175 -0
- package/dist/environment-exact-process.d.ts +161 -0
- package/dist/environment-exact-process.js +1 -0
- package/dist/environment-profile-capabilities.d.ts +26 -0
- package/dist/environment-profile-capabilities.js +34 -0
- package/dist/environment-provider.d.ts +3 -730
- package/dist/environment-provider.js +3 -245
- package/dist/environment-requests.d.ts +70 -0
- package/dist/environment-requests.js +1 -0
- package/dist/environment-runtime.d.ts +834 -0
- package/dist/environment-runtime.js +228 -0
- package/dist/execution-types.d.ts +47 -0
- package/dist/execution-types.js +1 -0
- package/dist/host-services.d.ts +91 -0
- package/dist/host-services.js +1 -0
- package/dist/index.d.ts +10 -617
- package/dist/index.js +10 -125
- package/dist/interaction-answer-validation.d.ts +13 -0
- package/dist/interaction-answer-validation.js +149 -0
- package/dist/interaction-data.d.ts +22 -0
- package/dist/interaction-data.js +46 -0
- package/dist/interaction-envelope.d.ts +258 -0
- package/dist/interaction-envelope.js +245 -0
- package/dist/interaction-fields.d.ts +130 -0
- package/dist/interaction-fields.js +227 -0
- package/dist/interaction-permissions.d.ts +28 -0
- package/dist/interaction-permissions.js +57 -0
- package/dist/interaction-resolution-validation.d.ts +9 -0
- package/dist/interaction-resolution-validation.js +50 -0
- package/dist/interaction-response-validation.d.ts +17 -0
- package/dist/interaction-response-validation.js +102 -0
- package/dist/interaction.d.ts +6 -397
- package/dist/interaction.js +6 -603
- package/dist/mcp.d.ts +38 -0
- package/dist/mcp.js +1 -0
- package/dist/parts.d.ts +104 -0
- package/dist/parts.js +55 -0
- package/dist/portable-context-base.d.ts +82 -0
- package/dist/portable-context-base.js +63 -0
- package/dist/portable-context-continuation.d.ts +168 -0
- package/dist/portable-context-continuation.js +194 -0
- package/dist/portable-context-plan-request.d.ts +86 -0
- package/dist/portable-context-plan-request.js +102 -0
- package/dist/portable-context-plan.d.ts +229 -0
- package/dist/portable-context-plan.js +241 -0
- package/dist/portable-context-shared.d.ts +36 -0
- package/dist/portable-context-shared.js +46 -0
- package/dist/portable-context-transfer.d.ts +319 -0
- package/dist/portable-context-transfer.js +206 -0
- package/dist/portable-context.d.ts +5 -753
- package/dist/portable-context.js +5 -754
- package/dist/profile-diff.js +56 -47
- package/dist/provider-adapter.d.ts +45 -0
- package/dist/provider-adapter.js +1 -0
- package/dist/provider-config.d.ts +58 -0
- package/dist/provider-config.js +42 -0
- package/dist/runtime-control.d.ts +87 -10
- package/dist/runtime-control.js +159 -38
- package/dist/stream-events.d.ts +55 -0
- package/dist/stream-events.js +1 -0
- package/dist/workspace-branching-shared.d.ts +7 -0
- package/dist/workspace-branching-shared.js +20 -0
- package/dist/workspace-branching.d.ts +4 -254
- package/dist/workspace-branching.js +4 -400
- package/dist/workspace-checkpoint.d.ts +99 -0
- package/dist/workspace-checkpoint.js +169 -0
- package/dist/workspace-cleanup.d.ts +85 -0
- package/dist/workspace-cleanup.js +156 -0
- package/dist/workspace-confidentiality.d.ts +59 -0
- package/dist/workspace-confidentiality.js +123 -0
- package/dist/workspace-fork.d.ts +182 -0
- package/dist/workspace-fork.js +267 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InteractionResolution } from "./interaction-data.js";
|
|
2
|
+
import type { InteractionAnswerSpec, InteractionResponseScope } from "./interaction-fields.js";
|
|
3
|
+
type InteractionResolutionRequest = {
|
|
4
|
+
kind: string;
|
|
5
|
+
answerSpec: InteractionAnswerSpec;
|
|
6
|
+
responseScopes?: InteractionResponseScope[];
|
|
7
|
+
};
|
|
8
|
+
export declare function validateResolutionForRequest(request: InteractionResolutionRequest, resolution: InteractionResolution): string[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { InteractionKind, PermissionGrantSchema, PERMISSION_GRANT_FIELD } from "./interaction-permissions.js";
|
|
2
|
+
import { validateInteractionAnswer } from "./interaction-answer-validation.js";
|
|
3
|
+
/**
|
|
4
|
+
* A declined or cancelled resolution submits no answer, so any secret-typed
|
|
5
|
+
* field it carries can only be leakage into a transport that retains it.
|
|
6
|
+
*/
|
|
7
|
+
function secretFieldErrors(spec, resolution) {
|
|
8
|
+
const secretFields = new Set(spec.fields
|
|
9
|
+
.filter((field) => field.type === "secret")
|
|
10
|
+
.map((field) => field.name));
|
|
11
|
+
return Object.keys(resolution.data ?? {})
|
|
12
|
+
.filter((fieldName) => secretFields.has(fieldName))
|
|
13
|
+
.map((fieldName) => `field "${fieldName}" is secret and cannot ride a ${resolution.outcome} resolution`);
|
|
14
|
+
}
|
|
15
|
+
export function validateResolutionForRequest(request, resolution) {
|
|
16
|
+
if (resolution.outcome !== "accepted") {
|
|
17
|
+
const errors = secretFieldErrors(request.answerSpec, resolution);
|
|
18
|
+
if (Object.keys(resolution.data ?? {}).length > 0) {
|
|
19
|
+
errors.push(`a ${resolution.outcome} resolution cannot carry answer fields`);
|
|
20
|
+
}
|
|
21
|
+
return errors;
|
|
22
|
+
}
|
|
23
|
+
const validation = validateInteractionAnswer(request.answerSpec, resolution.data);
|
|
24
|
+
const errors = validation.ok ? [] : [...validation.errors];
|
|
25
|
+
if (request.kind !== InteractionKind.Permission)
|
|
26
|
+
return errors;
|
|
27
|
+
const grant = resolution.data?.[PERMISSION_GRANT_FIELD];
|
|
28
|
+
if (!Array.isArray(grant) || grant.length !== 1) {
|
|
29
|
+
errors.push('permission response must select exactly one "grant" value');
|
|
30
|
+
return errors;
|
|
31
|
+
}
|
|
32
|
+
const parsedGrant = PermissionGrantSchema.safeParse(grant[0]);
|
|
33
|
+
if (!parsedGrant.success) {
|
|
34
|
+
errors.push(`permission response has invalid grant "${String(grant[0])}"`);
|
|
35
|
+
return errors;
|
|
36
|
+
}
|
|
37
|
+
if (parsedGrant.data === "deny")
|
|
38
|
+
return errors;
|
|
39
|
+
const requiredScope = {
|
|
40
|
+
allow_once: "interaction",
|
|
41
|
+
allow_session: "session",
|
|
42
|
+
allow_always: "persistent",
|
|
43
|
+
deny: "interaction",
|
|
44
|
+
};
|
|
45
|
+
const permitted = new Set(request.responseScopes ?? ["interaction"]);
|
|
46
|
+
if (!permitted.has(requiredScope[parsedGrant.data])) {
|
|
47
|
+
errors.push(`permission grant "${parsedGrant.data}" exceeds the request's response scopes`);
|
|
48
|
+
}
|
|
49
|
+
return errors;
|
|
50
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type InteractionRequest, type InteractionResponse, type InteractionResponseCommand } from "./interaction-envelope.js";
|
|
2
|
+
import { type InteractionValidation } from "./interaction-answer-validation.js";
|
|
3
|
+
export type InteractionResponseValidation = {
|
|
4
|
+
ok: true;
|
|
5
|
+
response: InteractionResponse;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
errors: string[];
|
|
9
|
+
};
|
|
10
|
+
/** Validate one response against the exact outstanding request. */
|
|
11
|
+
export declare function validateInteractionResponse(request: InteractionRequest, response: unknown): InteractionResponseValidation;
|
|
12
|
+
/** Validate a durable response command, including its run and request digest. */
|
|
13
|
+
export declare function validateInteractionResponseCommand(request: InteractionRequest, command: InteractionResponseCommand): InteractionResponseValidation;
|
|
14
|
+
/** Parse and return the safe response for callers that need an enumerable result. */
|
|
15
|
+
export declare function validateAndParseInteractionResponse(request: InteractionRequest, response: unknown): InteractionResponseValidation;
|
|
16
|
+
/** Verdict-only form for callers that never forward the value. */
|
|
17
|
+
export declare function interactionResponseIsValid(request: InteractionRequest, response: unknown): InteractionValidation;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { InteractionRequestSchema, InteractionResponseCommandSchema, InteractionResponseSchema, } from "./interaction-envelope.js";
|
|
2
|
+
import { validateResolutionForRequest } from "./interaction-resolution-validation.js";
|
|
3
|
+
const FORBIDDEN_DATA_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
4
|
+
function validResponse(response) {
|
|
5
|
+
const result = { ok: true };
|
|
6
|
+
Object.defineProperty(result, "response", {
|
|
7
|
+
value: response,
|
|
8
|
+
enumerable: false,
|
|
9
|
+
writable: false,
|
|
10
|
+
});
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
function forbiddenKeyErrors(response) {
|
|
14
|
+
if (!response || typeof response !== "object")
|
|
15
|
+
return [];
|
|
16
|
+
const data = response.data;
|
|
17
|
+
if (!data || typeof data !== "object")
|
|
18
|
+
return [];
|
|
19
|
+
return Object.getOwnPropertyNames(data)
|
|
20
|
+
.filter((key) => FORBIDDEN_DATA_KEYS.has(key))
|
|
21
|
+
.map((key) => `unknown field "${key}"`);
|
|
22
|
+
}
|
|
23
|
+
/** Validate one response against the exact outstanding request. */
|
|
24
|
+
export function validateInteractionResponse(request, response) {
|
|
25
|
+
const parsedRequest = InteractionRequestSchema.safeParse(request);
|
|
26
|
+
if (!parsedRequest.success) {
|
|
27
|
+
return {
|
|
28
|
+
ok: false,
|
|
29
|
+
errors: parsedRequest.error.issues.map((issue) => issue.message),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const exactRequest = parsedRequest.data;
|
|
33
|
+
const forbidden = forbiddenKeyErrors(response);
|
|
34
|
+
if (forbidden.length > 0)
|
|
35
|
+
return { ok: false, errors: forbidden };
|
|
36
|
+
const parsed = InteractionResponseSchema.safeParse(response);
|
|
37
|
+
if (!parsed.success) {
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
errors: parsed.error.issues.map((issue) => issue.message),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (exactRequest.id !== parsed.data.id) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
errors: ["response id does not match the outstanding interaction"],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (exactRequest.allowedOutcomes !== undefined &&
|
|
50
|
+
!exactRequest.allowedOutcomes.includes(parsed.data.outcome)) {
|
|
51
|
+
return {
|
|
52
|
+
ok: false,
|
|
53
|
+
errors: ["response outcome is not allowed by the outstanding interaction"],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const errors = validateResolutionForRequest(exactRequest, parsed.data);
|
|
57
|
+
if (errors.length > 0)
|
|
58
|
+
return { ok: false, errors };
|
|
59
|
+
// Secret answers are ephemeral input for the provider call. The caller that
|
|
60
|
+
// persists interaction records must redact them before journaling or tracing.
|
|
61
|
+
return validResponse(parsed.data);
|
|
62
|
+
}
|
|
63
|
+
/** Validate a durable response command, including its run and request digest. */
|
|
64
|
+
export function validateInteractionResponseCommand(request, command) {
|
|
65
|
+
const parsedRequest = InteractionRequestSchema.safeParse(request);
|
|
66
|
+
if (!parsedRequest.success) {
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
errors: parsedRequest.error.issues.map((issue) => issue.message),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const parsedCommand = InteractionResponseCommandSchema.safeParse(command);
|
|
73
|
+
if (!parsedCommand.success) {
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
errors: parsedCommand.error.issues.map((issue) => issue.message),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const binding = parsedCommand.data.binding;
|
|
80
|
+
if (binding.requestDigest !== parsedRequest.data.requestDigest ||
|
|
81
|
+
binding.runId !== parsedRequest.data.binding.runId ||
|
|
82
|
+
binding.provider !== parsedRequest.data.binding.provider ||
|
|
83
|
+
binding.environmentId !== parsedRequest.data.binding.environmentId ||
|
|
84
|
+
binding.sessionId !== parsedRequest.data.binding.sessionId ||
|
|
85
|
+
binding.executionId !== parsedRequest.data.binding.executionId ||
|
|
86
|
+
binding.interactionId !== parsedRequest.data.binding.interactionId) {
|
|
87
|
+
return { ok: false, errors: ["response command binding is stale"] };
|
|
88
|
+
}
|
|
89
|
+
return validateInteractionResponse(parsedRequest.data, parsedCommand.data.response);
|
|
90
|
+
}
|
|
91
|
+
/** Parse and return the safe response for callers that need an enumerable result. */
|
|
92
|
+
export function validateAndParseInteractionResponse(request, response) {
|
|
93
|
+
const result = validateInteractionResponse(request, response);
|
|
94
|
+
if (!result.ok)
|
|
95
|
+
return result;
|
|
96
|
+
return { ok: true, response: result.response };
|
|
97
|
+
}
|
|
98
|
+
/** Verdict-only form for callers that never forward the value. */
|
|
99
|
+
export function interactionResponseIsValid(request, response) {
|
|
100
|
+
const result = validateInteractionResponse(request, response);
|
|
101
|
+
return result.ok ? { ok: true } : { ok: false, errors: result.errors };
|
|
102
|
+
}
|
package/dist/interaction.d.ts
CHANGED
|
@@ -1,397 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* same `id`. This subsumes the original question/answer pair and extends it to
|
|
8
|
-
* permissions, plans, and provider-specific asks.
|
|
9
|
-
*
|
|
10
|
-
* Design contract:
|
|
11
|
-
* - The envelope is stable; `kind` is an OPEN label, so new ask types need no
|
|
12
|
-
* change to this contract. Well-known kinds (see `InteractionKind`) get
|
|
13
|
-
* richer rendering and platform handling; unknown kinds render generically
|
|
14
|
-
* from `answerSpec` and still work end-to-end.
|
|
15
|
-
* - `answerSpec` is a small closed set of flat field types, so any consumer can
|
|
16
|
-
* render a form and validate a response without a general schema engine. This
|
|
17
|
-
* mirrors MCP elicitation so MCP-originated asks map onto this 1:1.
|
|
18
|
-
* - `default` + `timeoutMs`/`onTimeout` make unattended resolution explicit and
|
|
19
|
-
* auditable, replacing blanket permission-bypass flags.
|
|
20
|
-
*/
|
|
21
|
-
import { z } from "zod";
|
|
22
|
-
export declare const InteractionFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
23
|
-
type: z.ZodLiteral<"text">;
|
|
24
|
-
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
-
placeholder: z.ZodOptional<z.ZodString>;
|
|
26
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
27
|
-
default: z.ZodOptional<z.ZodString>;
|
|
28
|
-
name: z.ZodString;
|
|
29
|
-
label: z.ZodString;
|
|
30
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
32
|
-
type: z.ZodLiteral<"number">;
|
|
33
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
34
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
default: z.ZodOptional<z.ZodNumber>;
|
|
36
|
-
name: z.ZodString;
|
|
37
|
-
label: z.ZodString;
|
|
38
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
40
|
-
type: z.ZodLiteral<"boolean">;
|
|
41
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
-
name: z.ZodString;
|
|
43
|
-
label: z.ZodString;
|
|
44
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
-
type: z.ZodLiteral<"select">;
|
|
47
|
-
options: z.ZodArray<z.ZodObject<{
|
|
48
|
-
value: z.ZodString;
|
|
49
|
-
label: z.ZodString;
|
|
50
|
-
description: z.ZodOptional<z.ZodString>;
|
|
51
|
-
}, z.core.$strict>>;
|
|
52
|
-
multi: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
-
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
-
default: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
-
name: z.ZodString;
|
|
56
|
-
label: z.ZodString;
|
|
57
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
-
type: z.ZodLiteral<"secret">;
|
|
60
|
-
placeholder: z.ZodOptional<z.ZodString>;
|
|
61
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
62
|
-
name: z.ZodString;
|
|
63
|
-
label: z.ZodString;
|
|
64
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
-
}, z.core.$strict>], "type">;
|
|
66
|
-
export type InteractionField = z.infer<typeof InteractionFieldSchema>;
|
|
67
|
-
export declare const InteractionAnswerSpecSchema: z.ZodObject<{
|
|
68
|
-
fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
69
|
-
type: z.ZodLiteral<"text">;
|
|
70
|
-
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
-
placeholder: z.ZodOptional<z.ZodString>;
|
|
72
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
73
|
-
default: z.ZodOptional<z.ZodString>;
|
|
74
|
-
name: z.ZodString;
|
|
75
|
-
label: z.ZodString;
|
|
76
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
78
|
-
type: z.ZodLiteral<"number">;
|
|
79
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
80
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
81
|
-
default: z.ZodOptional<z.ZodNumber>;
|
|
82
|
-
name: z.ZodString;
|
|
83
|
-
label: z.ZodString;
|
|
84
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
86
|
-
type: z.ZodLiteral<"boolean">;
|
|
87
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
-
name: z.ZodString;
|
|
89
|
-
label: z.ZodString;
|
|
90
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
92
|
-
type: z.ZodLiteral<"select">;
|
|
93
|
-
options: z.ZodArray<z.ZodObject<{
|
|
94
|
-
value: z.ZodString;
|
|
95
|
-
label: z.ZodString;
|
|
96
|
-
description: z.ZodOptional<z.ZodString>;
|
|
97
|
-
}, z.core.$strict>>;
|
|
98
|
-
multi: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
-
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
-
default: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
-
name: z.ZodString;
|
|
102
|
-
label: z.ZodString;
|
|
103
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
105
|
-
type: z.ZodLiteral<"secret">;
|
|
106
|
-
placeholder: z.ZodOptional<z.ZodString>;
|
|
107
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
108
|
-
name: z.ZodString;
|
|
109
|
-
label: z.ZodString;
|
|
110
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
-
}, z.core.$strict>], "type">>;
|
|
112
|
-
}, z.core.$strict>;
|
|
113
|
-
export type InteractionAnswerSpec = z.infer<typeof InteractionAnswerSpecSchema>;
|
|
114
|
-
export declare const InteractionFieldTypeSchema: z.ZodEnum<{
|
|
115
|
-
number: "number";
|
|
116
|
-
boolean: "boolean";
|
|
117
|
-
text: "text";
|
|
118
|
-
select: "select";
|
|
119
|
-
secret: "secret";
|
|
120
|
-
}>;
|
|
121
|
-
export type InteractionFieldType = z.infer<typeof InteractionFieldTypeSchema>;
|
|
122
|
-
/** Scope at which an accepted answer may be reused by an explicit policy. */
|
|
123
|
-
export declare const InteractionResponseScopeSchema: z.ZodEnum<{
|
|
124
|
-
interaction: "interaction";
|
|
125
|
-
session: "session";
|
|
126
|
-
persistent: "persistent";
|
|
127
|
-
}>;
|
|
128
|
-
export type InteractionResponseScope = z.infer<typeof InteractionResponseScopeSchema>;
|
|
129
|
-
/** Negotiated interaction behavior. Absence means interactions are unsupported. */
|
|
130
|
-
export declare const InteractionCapabilitiesSchema: z.ZodObject<{
|
|
131
|
-
kinds: z.ZodArray<z.ZodString>;
|
|
132
|
-
answerFieldTypes: z.ZodArray<z.ZodEnum<{
|
|
133
|
-
number: "number";
|
|
134
|
-
boolean: "boolean";
|
|
135
|
-
text: "text";
|
|
136
|
-
select: "select";
|
|
137
|
-
secret: "secret";
|
|
138
|
-
}>>;
|
|
139
|
-
responseScopes: z.ZodArray<z.ZodEnum<{
|
|
140
|
-
interaction: "interaction";
|
|
141
|
-
session: "session";
|
|
142
|
-
persistent: "persistent";
|
|
143
|
-
}>>;
|
|
144
|
-
secretAnswers: z.ZodBoolean;
|
|
145
|
-
concurrentRequests: z.ZodBoolean;
|
|
146
|
-
replay: z.ZodBoolean;
|
|
147
|
-
responseIdempotency: z.ZodBoolean;
|
|
148
|
-
}, z.core.$strict>;
|
|
149
|
-
export type InteractionCapabilities = z.infer<typeof InteractionCapabilitiesSchema>;
|
|
150
|
-
export declare const InteractionSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
151
|
-
type: z.ZodLiteral<"tool">;
|
|
152
|
-
toolName: z.ZodString;
|
|
153
|
-
input: z.ZodOptional<z.ZodUnknown>;
|
|
154
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
155
|
-
type: z.ZodLiteral<"command">;
|
|
156
|
-
command: z.ZodString;
|
|
157
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
158
|
-
type: z.ZodLiteral<"file">;
|
|
159
|
-
path: z.ZodString;
|
|
160
|
-
preview: z.ZodOptional<z.ZodString>;
|
|
161
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
162
|
-
type: z.ZodLiteral<"resource">;
|
|
163
|
-
uri: z.ZodString;
|
|
164
|
-
}, z.core.$strict>], "type">;
|
|
165
|
-
export type InteractionSubject = z.infer<typeof InteractionSubjectSchema>;
|
|
166
|
-
export declare const InteractionOutcomeSchema: z.ZodEnum<{
|
|
167
|
-
cancelled: "cancelled";
|
|
168
|
-
accepted: "accepted";
|
|
169
|
-
declined: "declined";
|
|
170
|
-
}>;
|
|
171
|
-
export type InteractionOutcome = z.infer<typeof InteractionOutcomeSchema>;
|
|
172
|
-
/** Field values keyed by `InteractionField.name`. Validated against `answerSpec`. */
|
|
173
|
-
export declare const InteractionDataSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
174
|
-
export type InteractionData = z.infer<typeof InteractionDataSchema>;
|
|
175
|
-
export declare const InteractionResolutionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
176
|
-
outcome: z.ZodLiteral<"accepted">;
|
|
177
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
178
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
179
|
-
outcome: z.ZodLiteral<"declined">;
|
|
180
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
181
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
182
|
-
outcome: z.ZodLiteral<"cancelled">;
|
|
183
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
184
|
-
}, z.core.$strict>], "outcome">;
|
|
185
|
-
export type InteractionResolution = z.infer<typeof InteractionResolutionSchema>;
|
|
186
|
-
export declare const InteractionRequestSchema: z.ZodObject<{
|
|
187
|
-
id: z.ZodString;
|
|
188
|
-
kind: z.ZodString;
|
|
189
|
-
title: z.ZodString;
|
|
190
|
-
body: z.ZodOptional<z.ZodString>;
|
|
191
|
-
subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
192
|
-
type: z.ZodLiteral<"tool">;
|
|
193
|
-
toolName: z.ZodString;
|
|
194
|
-
input: z.ZodOptional<z.ZodUnknown>;
|
|
195
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
196
|
-
type: z.ZodLiteral<"command">;
|
|
197
|
-
command: z.ZodString;
|
|
198
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
199
|
-
type: z.ZodLiteral<"file">;
|
|
200
|
-
path: z.ZodString;
|
|
201
|
-
preview: z.ZodOptional<z.ZodString>;
|
|
202
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
203
|
-
type: z.ZodLiteral<"resource">;
|
|
204
|
-
uri: z.ZodString;
|
|
205
|
-
}, z.core.$strict>], "type">>;
|
|
206
|
-
answerSpec: z.ZodObject<{
|
|
207
|
-
fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
208
|
-
type: z.ZodLiteral<"text">;
|
|
209
|
-
multiline: z.ZodOptional<z.ZodBoolean>;
|
|
210
|
-
placeholder: z.ZodOptional<z.ZodString>;
|
|
211
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
212
|
-
default: z.ZodOptional<z.ZodString>;
|
|
213
|
-
name: z.ZodString;
|
|
214
|
-
label: z.ZodString;
|
|
215
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
216
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
217
|
-
type: z.ZodLiteral<"number">;
|
|
218
|
-
min: z.ZodOptional<z.ZodNumber>;
|
|
219
|
-
max: z.ZodOptional<z.ZodNumber>;
|
|
220
|
-
default: z.ZodOptional<z.ZodNumber>;
|
|
221
|
-
name: z.ZodString;
|
|
222
|
-
label: z.ZodString;
|
|
223
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
225
|
-
type: z.ZodLiteral<"boolean">;
|
|
226
|
-
default: z.ZodOptional<z.ZodBoolean>;
|
|
227
|
-
name: z.ZodString;
|
|
228
|
-
label: z.ZodString;
|
|
229
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
230
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
231
|
-
type: z.ZodLiteral<"select">;
|
|
232
|
-
options: z.ZodArray<z.ZodObject<{
|
|
233
|
-
value: z.ZodString;
|
|
234
|
-
label: z.ZodString;
|
|
235
|
-
description: z.ZodOptional<z.ZodString>;
|
|
236
|
-
}, z.core.$strict>>;
|
|
237
|
-
multi: z.ZodOptional<z.ZodBoolean>;
|
|
238
|
-
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
239
|
-
default: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
240
|
-
name: z.ZodString;
|
|
241
|
-
label: z.ZodString;
|
|
242
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
244
|
-
type: z.ZodLiteral<"secret">;
|
|
245
|
-
placeholder: z.ZodOptional<z.ZodString>;
|
|
246
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
247
|
-
name: z.ZodString;
|
|
248
|
-
label: z.ZodString;
|
|
249
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
250
|
-
}, z.core.$strict>], "type">>;
|
|
251
|
-
}, z.core.$strict>;
|
|
252
|
-
responseScopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
253
|
-
interaction: "interaction";
|
|
254
|
-
session: "session";
|
|
255
|
-
persistent: "persistent";
|
|
256
|
-
}>>>;
|
|
257
|
-
default: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
258
|
-
outcome: z.ZodLiteral<"accepted">;
|
|
259
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
260
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
261
|
-
outcome: z.ZodLiteral<"declined">;
|
|
262
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
263
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
264
|
-
outcome: z.ZodLiteral<"cancelled">;
|
|
265
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
266
|
-
}, z.core.$strict>], "outcome">>;
|
|
267
|
-
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
268
|
-
onTimeout: z.ZodOptional<z.ZodEnum<{
|
|
269
|
-
default: "default";
|
|
270
|
-
fail: "fail";
|
|
271
|
-
wait: "wait";
|
|
272
|
-
}>>;
|
|
273
|
-
}, z.core.$strict>;
|
|
274
|
-
export type InteractionRequest = z.infer<typeof InteractionRequestSchema>;
|
|
275
|
-
export declare const InteractionResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
276
|
-
id: z.ZodString;
|
|
277
|
-
outcome: z.ZodLiteral<"accepted">;
|
|
278
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
279
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
280
|
-
id: z.ZodString;
|
|
281
|
-
outcome: z.ZodLiteral<"declined">;
|
|
282
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
283
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
284
|
-
id: z.ZodString;
|
|
285
|
-
outcome: z.ZodLiteral<"cancelled">;
|
|
286
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
287
|
-
}, z.core.$strict>], "outcome">;
|
|
288
|
-
export type InteractionResponse = z.infer<typeof InteractionResponseSchema>;
|
|
289
|
-
/** A request is unique only within this run and optional provider session. */
|
|
290
|
-
export declare const InteractionBindingSchema: z.ZodObject<{
|
|
291
|
-
runId: z.ZodString;
|
|
292
|
-
environmentId: z.ZodString;
|
|
293
|
-
sessionId: z.ZodOptional<z.ZodString>;
|
|
294
|
-
interactionId: z.ZodString;
|
|
295
|
-
}, z.core.$strict>;
|
|
296
|
-
export type InteractionBinding = z.infer<typeof InteractionBindingSchema>;
|
|
297
|
-
/** Retryable command sent to an environment or retained session. */
|
|
298
|
-
export declare const InteractionResponseCommandSchema: z.ZodObject<{
|
|
299
|
-
operationId: z.ZodString;
|
|
300
|
-
binding: z.ZodObject<{
|
|
301
|
-
runId: z.ZodString;
|
|
302
|
-
environmentId: z.ZodString;
|
|
303
|
-
sessionId: z.ZodOptional<z.ZodString>;
|
|
304
|
-
interactionId: z.ZodString;
|
|
305
|
-
}, z.core.$strict>;
|
|
306
|
-
response: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
307
|
-
id: z.ZodString;
|
|
308
|
-
outcome: z.ZodLiteral<"accepted">;
|
|
309
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
310
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
311
|
-
id: z.ZodString;
|
|
312
|
-
outcome: z.ZodLiteral<"declined">;
|
|
313
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
314
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
315
|
-
id: z.ZodString;
|
|
316
|
-
outcome: z.ZodLiteral<"cancelled">;
|
|
317
|
-
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
|
|
318
|
-
}, z.core.$strict>], "outcome">;
|
|
319
|
-
}, z.core.$strict>;
|
|
320
|
-
export type InteractionResponseCommand = z.infer<typeof InteractionResponseCommandSchema>;
|
|
321
|
-
export declare const InteractionAcknowledgementStatusSchema: z.ZodEnum<{
|
|
322
|
-
cancelled: "cancelled";
|
|
323
|
-
expired: "expired";
|
|
324
|
-
accepted: "accepted";
|
|
325
|
-
already_resolved_same: "already_resolved_same";
|
|
326
|
-
already_resolved_different: "already_resolved_different";
|
|
327
|
-
unknown_interaction: "unknown_interaction";
|
|
328
|
-
unknown_run: "unknown_run";
|
|
329
|
-
binding_mismatch: "binding_mismatch";
|
|
330
|
-
invalid_response: "invalid_response";
|
|
331
|
-
transport_failure: "transport_failure";
|
|
332
|
-
}>;
|
|
333
|
-
export type InteractionAcknowledgementStatus = z.infer<typeof InteractionAcknowledgementStatusSchema>;
|
|
334
|
-
/** Durable result of one interaction response operation. */
|
|
335
|
-
export declare const InteractionAcknowledgementSchema: z.ZodObject<{
|
|
336
|
-
operationId: z.ZodString;
|
|
337
|
-
binding: z.ZodObject<{
|
|
338
|
-
runId: z.ZodString;
|
|
339
|
-
environmentId: z.ZodString;
|
|
340
|
-
sessionId: z.ZodOptional<z.ZodString>;
|
|
341
|
-
interactionId: z.ZodString;
|
|
342
|
-
}, z.core.$strict>;
|
|
343
|
-
status: z.ZodEnum<{
|
|
344
|
-
cancelled: "cancelled";
|
|
345
|
-
expired: "expired";
|
|
346
|
-
accepted: "accepted";
|
|
347
|
-
already_resolved_same: "already_resolved_same";
|
|
348
|
-
already_resolved_different: "already_resolved_different";
|
|
349
|
-
unknown_interaction: "unknown_interaction";
|
|
350
|
-
unknown_run: "unknown_run";
|
|
351
|
-
binding_mismatch: "binding_mismatch";
|
|
352
|
-
invalid_response: "invalid_response";
|
|
353
|
-
transport_failure: "transport_failure";
|
|
354
|
-
}>;
|
|
355
|
-
message: z.ZodOptional<z.ZodString>;
|
|
356
|
-
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
357
|
-
}, z.core.$strict>;
|
|
358
|
-
export type InteractionAcknowledgement = z.infer<typeof InteractionAcknowledgementSchema>;
|
|
359
|
-
export declare const InteractionKind: {
|
|
360
|
-
/** Agent asks the user to answer/choose. Answer = the chosen field values. */
|
|
361
|
-
readonly Question: "question";
|
|
362
|
-
/** Agent requests approval to run a tool/command. Answer = a `PermissionGrant`. */
|
|
363
|
-
readonly Permission: "permission";
|
|
364
|
-
/** Agent shares a plan/todo list for review/approval. */
|
|
365
|
-
readonly Plan: "plan";
|
|
366
|
-
};
|
|
367
|
-
export type WellKnownInteractionKind = (typeof InteractionKind)[keyof typeof InteractionKind];
|
|
368
|
-
/** Field name carrying the grant on a `permission` interaction's response. */
|
|
369
|
-
export declare const PERMISSION_GRANT_FIELD = "grant";
|
|
370
|
-
/** Optional free-text field carrying the user's reason on a `permission` response. */
|
|
371
|
-
export declare const PERMISSION_FEEDBACK_FIELD = "feedback";
|
|
372
|
-
/** Graduated permission decision — the value of the `grant` field. */
|
|
373
|
-
export declare const PermissionGrantSchema: z.ZodEnum<{
|
|
374
|
-
deny: "deny";
|
|
375
|
-
allow_once: "allow_once";
|
|
376
|
-
allow_session: "allow_session";
|
|
377
|
-
allow_always: "allow_always";
|
|
378
|
-
}>;
|
|
379
|
-
export type PermissionGrant = z.infer<typeof PermissionGrantSchema>;
|
|
380
|
-
/** Build a permission answer spec that cannot offer a broader reusable grant. */
|
|
381
|
-
export declare function permissionAnswerSpec(opts?: {
|
|
382
|
-
allowFeedback?: boolean;
|
|
383
|
-
responseScopes?: readonly InteractionResponseScope[];
|
|
384
|
-
}): InteractionAnswerSpec;
|
|
385
|
-
export type InteractionValidation = {
|
|
386
|
-
ok: true;
|
|
387
|
-
} | {
|
|
388
|
-
ok: false;
|
|
389
|
-
errors: string[];
|
|
390
|
-
};
|
|
391
|
-
/**
|
|
392
|
-
* Validate an accepted answer against its spec. Used by the broker before a
|
|
393
|
-
* response reaches the adapter, so malformed answers are rejected centrally.
|
|
394
|
-
*/
|
|
395
|
-
export declare function validateInteractionAnswer(spec: InteractionAnswerSpec, data: InteractionData | undefined): InteractionValidation;
|
|
396
|
-
/** Validate one response against the exact outstanding request. */
|
|
397
|
-
export declare function validateInteractionResponse(request: InteractionRequest, response: InteractionResponse): InteractionValidation;
|
|
1
|
+
export * from "./interaction-fields.js";
|
|
2
|
+
export * from "./interaction-data.js";
|
|
3
|
+
export * from "./interaction-envelope.js";
|
|
4
|
+
export * from "./interaction-permissions.js";
|
|
5
|
+
export * from "./interaction-answer-validation.js";
|
|
6
|
+
export * from "./interaction-response-validation.js";
|