@sequenceholdings/managed-functions 0.4.4 → 0.5.1
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 +147 -12
- package/dist/abrigo-contract.d.ts +2 -92
- package/dist/abrigo-contract.js +12 -53
- package/dist/abrigo-response.d.ts +1 -6
- package/dist/abrigo-response.js +3 -25
- package/dist/abrigo.d.ts +5 -5
- package/dist/abrigo.js +66 -92
- package/dist/agent-evidence.d.ts +5 -5
- package/dist/agent-evidence.js +58 -48
- package/dist/agent-source-evidence-contract.d.ts +2 -1197
- package/dist/agent-source-evidence-contract.js +24 -94
- package/dist/agents-contract.d.ts +2 -99
- package/dist/agents-contract.js +13 -67
- package/dist/agents.d.ts +5 -5
- package/dist/agents.js +79 -44
- package/dist/capabilities.d.ts +1 -1
- package/dist/capabilities.js +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +4 -1
- package/dist/directory-config.d.ts +1 -23
- package/dist/directory-config.js +8 -20
- package/dist/directory-contract.d.ts +2 -68
- package/dist/directory-contract.js +13 -55
- package/dist/directory-roster-contract.d.ts +2 -22
- package/dist/directory-roster-contract.js +7 -22
- package/dist/directory.d.ts +4 -8
- package/dist/directory.js +15 -33
- package/dist/group-roster-access.d.ts +7 -0
- package/dist/group-roster-access.js +8 -0
- package/dist/index.d.ts +49 -46
- package/dist/index.js +8 -1
- package/dist/invocation-client.d.ts +4 -4
- package/dist/invocation-client.js +32 -60
- package/dist/invocation-contract.d.ts +2 -59
- package/dist/invocation-contract.js +10 -61
- package/dist/invocation.d.ts +4 -4
- package/dist/invocation.js +42 -63
- package/dist/lattice-provenance-contract.d.ts +2 -607
- package/dist/lattice-provenance-contract.js +14 -154
- package/dist/lattice-provenance.d.ts +3 -3
- package/dist/lattice-provenance.js +46 -97
- package/dist/monitoring-annotations.d.ts +2 -53
- package/dist/monitoring-annotations.js +2 -51
- package/dist/monitoring-contract.d.ts +5 -460
- package/dist/monitoring-contract.js +37 -77
- package/dist/monitoring-events.d.ts +2 -252
- package/dist/monitoring-events.js +15 -125
- package/dist/monitoring.d.ts +3 -3
- package/dist/monitoring.js +41 -41
- package/dist/orm.d.ts +10 -1
- package/dist/orm.js +27 -7
- package/dist/platform-client.d.ts +27 -0
- package/dist/platform-client.js +79 -0
- package/dist/platform-domains.d.ts +1671 -0
- package/dist/platform-domains.js +77 -0
- package/dist/processes-contract.d.ts +2 -149
- package/dist/processes-contract.js +17 -100
- package/dist/processes.d.ts +3 -3
- package/dist/processes.js +64 -49
- package/dist/runtime.cjs +4257 -1667
- package/dist/service-directory-roster.d.ts +12 -3
- package/dist/service-directory-roster.js +11 -17
- package/dist/service-directory.d.ts +4 -8
- package/dist/service-directory.js +16 -67
- package/dist/storage.d.ts +70 -35
- package/dist/storage.js +12 -5
- package/dist/workflow-source-contract.d.ts +2 -524
- package/dist/workflow-source-contract.js +16 -56
- package/dist/workflow-source.d.ts +3 -3
- package/dist/workflow-source.js +106 -43
- package/package.json +4 -3
package/dist/abrigo.js
CHANGED
|
@@ -15,36 +15,54 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.createFunctionCallerAbrigoClient = createFunctionCallerAbrigoClient;
|
|
18
|
+
const adapters_1 = require("@sequenceholdings/platform/adapters");
|
|
18
19
|
const zod_1 = require("zod");
|
|
19
|
-
const abrigo_response_1 = require("./abrigo-response");
|
|
20
20
|
const abrigo_contract_1 = require("./abrigo-contract");
|
|
21
21
|
__exportStar(require("./abrigo-contract"), exports);
|
|
22
22
|
const claimsSchema = zod_1.z.object({
|
|
23
|
-
audience: zod_1.z.literal(abrigo_contract_1.FUNCTION_ABRIGO_READ_AUDIENCE),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
audience: zod_1.z.literal(abrigo_contract_1.FUNCTION_ABRIGO_READ_AUDIENCE),
|
|
24
|
+
environment: zod_1.z.string().min(1).max(4096),
|
|
25
|
+
functionId: zod_1.z.uuid(),
|
|
26
|
+
versionId: zod_1.z.uuid(),
|
|
27
|
+
invocationId: zod_1.z.uuid(),
|
|
28
|
+
serviceAccountId: zod_1.z.uuid(),
|
|
29
|
+
org: zod_1.z.string().min(1).max(255),
|
|
30
|
+
callerKind: zod_1.z.literal("human"),
|
|
31
|
+
callerSub: zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.min(1)
|
|
34
|
+
.max(512)
|
|
35
|
+
.regex(/^[^\s:#|]+\|[^\s:#]+$/)
|
|
36
|
+
.refine((sub) => !sub.startsWith("service-account|") &&
|
|
37
|
+
!sub.startsWith("managed-function|") &&
|
|
38
|
+
!sub.startsWith("system|") &&
|
|
39
|
+
!sub.endsWith("@clients") &&
|
|
40
|
+
sub !== "google-apps|sequence.agent@seqholdings.com", "Only actual human callers may read Abrigo"),
|
|
28
41
|
callerAuthenticationMethod: zod_1.z.string().min(1).max(64),
|
|
29
42
|
exp: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
30
43
|
});
|
|
31
44
|
function credential({ request }) {
|
|
32
|
-
const invalid = () => new abrigo_contract_1.FunctionAbrigoReadError(401,
|
|
45
|
+
const invalid = () => new abrigo_contract_1.FunctionAbrigoReadError(401, "invalid_context", "This invocation has no valid caller Abrigo read credential");
|
|
33
46
|
const headers = request.headers;
|
|
34
|
-
const matches = typeof headers.get ===
|
|
35
|
-
|
|
47
|
+
const matches = typeof headers.get === "function"
|
|
48
|
+
? [headers.get(abrigo_contract_1.FUNCTION_ABRIGO_READ_TOKEN_HEADER)]
|
|
49
|
+
: Object.entries(headers)
|
|
50
|
+
.filter(([name]) => name.toLowerCase() === abrigo_contract_1.FUNCTION_ABRIGO_READ_TOKEN_HEADER)
|
|
51
|
+
.map(([, value]) => value);
|
|
36
52
|
const token = matches[0];
|
|
37
|
-
if (matches.length !== 1 ||
|
|
53
|
+
if (matches.length !== 1 ||
|
|
54
|
+
typeof token !== "string" ||
|
|
55
|
+
token.length > 16_384)
|
|
38
56
|
throw invalid();
|
|
39
57
|
const envelope = /^([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/.exec(token);
|
|
40
58
|
if (!envelope?.[1])
|
|
41
59
|
throw invalid();
|
|
42
60
|
let value;
|
|
43
61
|
try {
|
|
44
|
-
const decoded = Buffer.from(envelope[1],
|
|
45
|
-
if (decoded.toString(
|
|
62
|
+
const decoded = Buffer.from(envelope[1], "base64url");
|
|
63
|
+
if (decoded.toString("base64url") !== envelope[1])
|
|
46
64
|
throw invalid();
|
|
47
|
-
value = JSON.parse(new TextDecoder(
|
|
65
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(decoded));
|
|
48
66
|
}
|
|
49
67
|
catch {
|
|
50
68
|
throw invalid();
|
|
@@ -55,7 +73,7 @@ function credential({ request }) {
|
|
|
55
73
|
return { token, expiresAt: parsed.data.exp };
|
|
56
74
|
}
|
|
57
75
|
function origin(baseUrl) {
|
|
58
|
-
const invalid = () => new abrigo_contract_1.FunctionAbrigoReadError(400,
|
|
76
|
+
const invalid = () => new abrigo_contract_1.FunctionAbrigoReadError(400, "invalid_configuration", "Configure a trusted HTTPS Atlas origin without credentials, path, query or fragment");
|
|
59
77
|
let url;
|
|
60
78
|
try {
|
|
61
79
|
url = new URL(baseUrl);
|
|
@@ -63,88 +81,44 @@ function origin(baseUrl) {
|
|
|
63
81
|
catch {
|
|
64
82
|
throw invalid();
|
|
65
83
|
}
|
|
66
|
-
const loopback = url.protocol ===
|
|
67
|
-
|
|
84
|
+
const loopback = url.protocol === "http:" &&
|
|
85
|
+
["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
86
|
+
if ((!loopback && url.protocol !== "https:") ||
|
|
87
|
+
url.username ||
|
|
88
|
+
url.password ||
|
|
89
|
+
url.pathname !== "/" ||
|
|
90
|
+
url.search ||
|
|
91
|
+
url.hash)
|
|
68
92
|
throw invalid();
|
|
69
93
|
return url.origin;
|
|
70
94
|
}
|
|
71
|
-
function
|
|
72
|
-
if (depth > 64)
|
|
73
|
-
return false;
|
|
74
|
-
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
75
|
-
return true;
|
|
76
|
-
if (typeof value === 'number')
|
|
77
|
-
return Number.isFinite(value) && (!Number.isInteger(value) || Number.isSafeInteger(value));
|
|
78
|
-
if (Array.isArray(value))
|
|
79
|
-
return value.every((item) => validJson(item, depth + 1));
|
|
80
|
-
return typeof value === 'object' && Object.values(value).every((item) => validJson(item, depth + 1));
|
|
81
|
-
}
|
|
82
|
-
async function boundedBody(response) {
|
|
83
|
-
const oversized = () => new abrigo_contract_1.FunctionAbrigoReadError(502, 'response_too_large', 'Abrigo read exceeded the bounded response size; reduce perPage');
|
|
84
|
-
const length = response.headers.get('content-length');
|
|
85
|
-
if (length && /^\d+$/.test(length) && Number(length) > abrigo_contract_1.ABRIGO_READ_MAX_RESPONSE_BYTES) {
|
|
86
|
-
await response.body?.cancel().catch(() => { });
|
|
87
|
-
throw oversized();
|
|
88
|
-
}
|
|
89
|
-
if (!response.body)
|
|
90
|
-
throw new abrigo_contract_1.FunctionAbrigoReadError(502, 'malformed_response', 'Atlas returned invalid Abrigo JSON');
|
|
91
|
-
const reader = response.body.getReader();
|
|
92
|
-
const chunks = [];
|
|
93
|
-
let bytes = 0;
|
|
94
|
-
try {
|
|
95
|
-
for (;;) {
|
|
96
|
-
const chunk = await reader.read();
|
|
97
|
-
if (chunk.done)
|
|
98
|
-
break;
|
|
99
|
-
bytes += chunk.value.byteLength;
|
|
100
|
-
if (bytes > abrigo_contract_1.ABRIGO_READ_MAX_RESPONSE_BYTES) {
|
|
101
|
-
await reader.cancel().catch(() => { });
|
|
102
|
-
throw oversized();
|
|
103
|
-
}
|
|
104
|
-
chunks.push(chunk.value);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
reader.releaseLock();
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks, bytes)));
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
throw new abrigo_contract_1.FunctionAbrigoReadError(502, 'malformed_response', 'Atlas returned invalid Abrigo JSON');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function createFunctionCallerAbrigoClient({ request, baseUrl, fetchImpl = globalThis.fetch }) {
|
|
95
|
+
function createFunctionCallerAbrigoClient({ request, baseUrl, fetchImpl = globalThis.fetch, }) {
|
|
118
96
|
const url = `${origin(baseUrl)}${abrigo_contract_1.FUNCTION_ABRIGO_READ_PATH}`;
|
|
119
97
|
const { token, expiresAt } = credential({ request });
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
catch (error) {
|
|
144
|
-
if (error instanceof abrigo_contract_1.FunctionAbrigoReadError)
|
|
145
|
-
throw error;
|
|
146
|
-
throw new abrigo_contract_1.FunctionAbrigoReadError(503, 'abrigo_read_unavailable', 'The authorized Abrigo read could not be completed');
|
|
147
|
-
}
|
|
98
|
+
const send = (0, adapters_1.createInvocationDomainTransport)({
|
|
99
|
+
baseUrl,
|
|
100
|
+
fetchImpl,
|
|
101
|
+
domain: "abrigo",
|
|
102
|
+
credentials: [
|
|
103
|
+
{ header: abrigo_contract_1.FUNCTION_ABRIGO_READ_TOKEN_HEADER, token, expiresAt },
|
|
104
|
+
],
|
|
105
|
+
maxResponseBytes: abrigo_contract_1.ABRIGO_READ_MAX_RESPONSE_BYTES,
|
|
106
|
+
timeoutMs: abrigo_contract_1.ABRIGO_READ_TIMEOUT_MS,
|
|
107
|
+
error: (status, code, message) => ["timeout", "transport_failed"].includes(code)
|
|
108
|
+
? new abrigo_contract_1.FunctionAbrigoReadError(503, "abrigo_read_unavailable", "The authorized Abrigo read could not be completed")
|
|
109
|
+
: new abrigo_contract_1.FunctionAbrigoReadError(status, /^[a-z][a-z0-9_]*$/.test(code) ? code : "abrigo_read_failed", [
|
|
110
|
+
"invalid_context",
|
|
111
|
+
"expired_context",
|
|
112
|
+
"invalid_configuration",
|
|
113
|
+
"response_too_large",
|
|
114
|
+
"malformed_response",
|
|
115
|
+
].includes(code)
|
|
116
|
+
? message
|
|
117
|
+
: "The authorized Abrigo read failed"),
|
|
118
|
+
failure: {
|
|
119
|
+
code: "abrigo_read_failed",
|
|
120
|
+
message: "The authorized Abrigo read failed",
|
|
148
121
|
},
|
|
149
|
-
};
|
|
122
|
+
});
|
|
123
|
+
return (0, adapters_1.createAbrigoReadClient)({ send });
|
|
150
124
|
}
|
package/dist/agent-evidence.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type FunctionServiceAgentsOptions } from
|
|
2
|
-
import { type FunctionAgentSourceEvidenceRequest, type FunctionAgentConversationEvidenceRequest, type FunctionAgentSourceEvidenceVerification } from
|
|
3
|
-
export type FunctionAgentSourceEvidenceInput = Omit<FunctionAgentSourceEvidenceRequest,
|
|
4
|
-
export type FunctionAgentConversationEvidenceInput = Omit<FunctionAgentConversationEvidenceRequest,
|
|
1
|
+
import { type FunctionServiceAgentsOptions } from "./agents";
|
|
2
|
+
import { type FunctionAgentSourceEvidenceRequest, type FunctionAgentConversationEvidenceRequest, type FunctionAgentSourceEvidenceVerification } from "./agent-source-evidence-contract";
|
|
3
|
+
export type FunctionAgentSourceEvidenceInput = Omit<FunctionAgentSourceEvidenceRequest, "operation">;
|
|
4
|
+
export type FunctionAgentConversationEvidenceInput = Omit<FunctionAgentConversationEvidenceRequest, "operation">;
|
|
5
5
|
export interface FunctionAgentEvidenceClient {
|
|
6
6
|
verifySourceEvidence(input: FunctionAgentSourceEvidenceInput): Promise<FunctionAgentSourceEvidenceVerification>;
|
|
7
7
|
verifyConversationEvidence(input: FunctionAgentConversationEvidenceInput): Promise<FunctionAgentSourceEvidenceVerification>;
|
|
8
8
|
}
|
|
9
|
-
export declare function createFunctionAgentEvidenceClient({ request, baseUrl, fetchImpl }: FunctionServiceAgentsOptions): FunctionAgentEvidenceClient;
|
|
9
|
+
export declare function createFunctionAgentEvidenceClient({ request, baseUrl, fetchImpl, }: FunctionServiceAgentsOptions): FunctionAgentEvidenceClient;
|
package/dist/agent-evidence.js
CHANGED
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createFunctionAgentEvidenceClient = createFunctionAgentEvidenceClient;
|
|
4
|
+
const adapters_1 = require("@sequenceholdings/platform/adapters");
|
|
4
5
|
const zod_1 = require("zod");
|
|
5
6
|
const agents_1 = require("./agents");
|
|
6
7
|
const agent_source_evidence_contract_1 = require("./agent-source-evidence-contract");
|
|
7
8
|
function header(request, name) {
|
|
8
9
|
const { headers } = request;
|
|
9
|
-
const values = typeof headers.get ===
|
|
10
|
-
|
|
10
|
+
const values = typeof headers.get === "function"
|
|
11
|
+
? [headers.get(name)]
|
|
12
|
+
: Object.entries(headers)
|
|
13
|
+
.filter(([key]) => key.toLowerCase() === name)
|
|
14
|
+
.map(([, value]) => value);
|
|
15
|
+
return values.length === 1 && typeof values[0] === "string"
|
|
16
|
+
? values[0]
|
|
17
|
+
: null;
|
|
11
18
|
}
|
|
12
|
-
const bindingSchema = zod_1.z.object({
|
|
19
|
+
const bindingSchema = zod_1.z.object({
|
|
20
|
+
audience: zod_1.z.literal("atlas-managed-function-agent-evidence"),
|
|
21
|
+
sub: zod_1.z.string().startsWith("service-account|"),
|
|
22
|
+
functionId: zod_1.z.uuid(),
|
|
23
|
+
versionId: zod_1.z.uuid(),
|
|
24
|
+
invocationId: zod_1.z.uuid(),
|
|
25
|
+
serviceAccountId: zod_1.z.uuid(),
|
|
26
|
+
org: zod_1.z.string().min(1),
|
|
27
|
+
exp: zod_1.z.number().int(),
|
|
28
|
+
});
|
|
13
29
|
function invocation(request) {
|
|
14
|
-
const denied = () => new agents_1.FunctionAgentReadError(401,
|
|
30
|
+
const denied = () => new agents_1.FunctionAgentReadError(401, "invalid_context", "This invocation has no valid agent-evidence credential");
|
|
15
31
|
const token = header(request, agent_source_evidence_contract_1.FUNCTION_AGENT_EVIDENCE_TOKEN_HEADER);
|
|
16
|
-
const body = token && token.length <= 16_384
|
|
32
|
+
const body = token && token.length <= 16_384
|
|
33
|
+
? /^([A-Za-z0-9_-]+)\.[A-Za-z0-9_-]{43}$/.exec(token)?.[1]
|
|
34
|
+
: null;
|
|
17
35
|
if (!body || !token)
|
|
18
36
|
throw denied();
|
|
19
37
|
let value;
|
|
20
38
|
try {
|
|
21
|
-
value = JSON.parse(Buffer.from(body,
|
|
39
|
+
value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
22
40
|
}
|
|
23
41
|
catch {
|
|
24
42
|
throw denied();
|
|
25
43
|
}
|
|
26
44
|
const binding = bindingSchema.safeParse(value);
|
|
27
|
-
if (!binding.success ||
|
|
45
|
+
if (!binding.success ||
|
|
46
|
+
binding.data.sub !== `service-account|${binding.data.serviceAccountId}`)
|
|
28
47
|
throw denied();
|
|
29
48
|
return { token, binding: binding.data };
|
|
30
49
|
}
|
|
@@ -34,51 +53,42 @@ function origin(baseUrl) {
|
|
|
34
53
|
url = new URL(baseUrl);
|
|
35
54
|
}
|
|
36
55
|
catch {
|
|
37
|
-
throw new agents_1.FunctionAgentReadError(400,
|
|
56
|
+
throw new agents_1.FunctionAgentReadError(400, "invalid_configuration", "Configure a trusted Atlas origin");
|
|
38
57
|
}
|
|
39
|
-
const loopback = url.protocol ===
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
const loopback = url.protocol === "http:" &&
|
|
59
|
+
["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
60
|
+
if ((!loopback && url.protocol !== "https:") ||
|
|
61
|
+
url.username ||
|
|
62
|
+
url.password ||
|
|
63
|
+
url.pathname !== "/" ||
|
|
64
|
+
url.search ||
|
|
65
|
+
url.hash)
|
|
66
|
+
throw new agents_1.FunctionAgentReadError(400, "invalid_configuration", "Configure an HTTPS Atlas origin without credentials, path, query or fragment");
|
|
42
67
|
return url.origin;
|
|
43
68
|
}
|
|
44
|
-
function createFunctionAgentEvidenceClient({ request, baseUrl, fetchImpl = globalThis.fetch }) {
|
|
69
|
+
function createFunctionAgentEvidenceClient({ request, baseUrl, fetchImpl = globalThis.fetch, }) {
|
|
45
70
|
const url = `${origin(baseUrl)}${agent_source_evidence_contract_1.FUNCTION_AGENT_EVIDENCE_PATH}`;
|
|
46
71
|
const { token, binding } = invocation(request);
|
|
47
|
-
const lattice = header(request,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(execution !== null && (execution.receiverFunctionOrgId !== receiver.org || execution.receiver.functionId !== receiver.functionId || execution.receiver.versionId !== receiver.versionId || execution.receiver.invocationId !== receiver.invocationId)))
|
|
67
|
-
throw new agents_1.FunctionAgentReadError(502, 'malformed_response', 'Atlas returned source verification for another request or invocation');
|
|
68
|
-
return verified.data;
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
async verifySourceEvidence(input) {
|
|
72
|
-
const result = await verify(agent_source_evidence_contract_1.functionAgentSourceEvidenceRequestSchema.parse({ ...input, operation: 'verifySourceEvidence' }));
|
|
73
|
-
if (result.source.projection === 'thread-conversation-v1' || result.source.runId !== input.runId)
|
|
74
|
-
throw new agents_1.FunctionAgentReadError(502, 'malformed_response', 'Atlas returned evidence for a different completed source');
|
|
75
|
-
return result;
|
|
76
|
-
},
|
|
77
|
-
async verifyConversationEvidence(input) {
|
|
78
|
-
const result = await verify(agent_source_evidence_contract_1.functionAgentConversationEvidenceRequestSchema.parse({ ...input, operation: 'verifyConversationEvidence' }));
|
|
79
|
-
if (result.source.projection !== 'thread-conversation-v1' || result.source.threadId !== input.threadId || result.source.revision !== input.response.revision || result.source.cutoffAt !== input.response.cutoffAt)
|
|
80
|
-
throw new agents_1.FunctionAgentReadError(502, 'malformed_response', 'Atlas returned evidence for a different settled conversation');
|
|
81
|
-
return result;
|
|
72
|
+
const lattice = header(request, "x-sequence-lattice-execution-token");
|
|
73
|
+
const send = (0, adapters_1.createInvocationDomainTransport)({
|
|
74
|
+
baseUrl,
|
|
75
|
+
fetchImpl,
|
|
76
|
+
domain: "agents-evidence",
|
|
77
|
+
credentials: [
|
|
78
|
+
{
|
|
79
|
+
header: agent_source_evidence_contract_1.FUNCTION_AGENT_EVIDENCE_TOKEN_HEADER,
|
|
80
|
+
token,
|
|
81
|
+
expiresAt: binding.exp,
|
|
82
|
+
},
|
|
83
|
+
...(lattice
|
|
84
|
+
? [{ header: "x-sequence-lattice-execution-token", token: lattice }]
|
|
85
|
+
: []),
|
|
86
|
+
],
|
|
87
|
+
error: (status, code, message) => new agents_1.FunctionAgentReadError(status, code, message),
|
|
88
|
+
failure: {
|
|
89
|
+
code: "agent_evidence_failed",
|
|
90
|
+
message: "Source verification failed",
|
|
82
91
|
},
|
|
83
|
-
};
|
|
92
|
+
});
|
|
93
|
+
return (0, adapters_1.createAgentEvidenceClient)({ binding, send });
|
|
84
94
|
}
|