@native-marketing/sdk 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http.js +75 -3
- package/dist/index.js +91 -38
- package/package.json +1 -1
- package/release.json +2 -2
- package/types/contracts/agent/compact-surface.d.ts +5 -0
- package/types/http/request-policy.d.ts +5 -0
- package/types/sdk/capability-definition.d.ts +18 -0
- package/types/sdk/operations.d.ts +3 -2
- package/types/sdk/tool-definition.d.ts +2 -1
package/dist/http.js
CHANGED
|
@@ -1,11 +1,83 @@
|
|
|
1
1
|
// packages/api-client/src/client.ts
|
|
2
2
|
import createClient from "openapi-fetch";
|
|
3
|
+
|
|
4
|
+
// packages/api-client/src/request-policy.ts
|
|
5
|
+
var verbs = /* @__PURE__ */ new Set(["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"]);
|
|
6
|
+
function unsafe() {
|
|
7
|
+
throw new TypeError("HTTP client request violates its configured secure API boundary.");
|
|
8
|
+
}
|
|
9
|
+
function scopeOf(value) {
|
|
10
|
+
if (typeof value !== "string" || value.trim() !== value || /[\\?#]/.test(value)) unsafe();
|
|
11
|
+
const relative = value.startsWith("/") && !value.startsWith("//");
|
|
12
|
+
let url;
|
|
13
|
+
try {
|
|
14
|
+
url = relative ? new URL(value, "https://relative.invalid") : new URL(value);
|
|
15
|
+
} catch {
|
|
16
|
+
return unsafe();
|
|
17
|
+
}
|
|
18
|
+
if (url.username || url.password || url.search || url.hash) unsafe();
|
|
19
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))
|
|
20
|
+
unsafe();
|
|
21
|
+
return {
|
|
22
|
+
...relative ? {} : { origin: url.origin },
|
|
23
|
+
pathname: url.pathname.replace(/\/+$/, "")
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function httpRequestPolicy(baseUrl, transport) {
|
|
27
|
+
const scope = scopeOf(baseUrl);
|
|
28
|
+
const origin = scope.origin ?? globalThis.location?.origin;
|
|
29
|
+
return {
|
|
30
|
+
validateInit(value) {
|
|
31
|
+
if (value === void 0) return;
|
|
32
|
+
if (value === null || typeof value !== "object") unsafe();
|
|
33
|
+
const init = value;
|
|
34
|
+
if (init.redirect !== void 0 && init.redirect !== "error") unsafe();
|
|
35
|
+
if (init.fetch !== void 0 || init.Request !== void 0 || init.middleware !== void 0)
|
|
36
|
+
unsafe();
|
|
37
|
+
if (init.baseUrl !== void 0) {
|
|
38
|
+
if (typeof init.baseUrl !== "string") unsafe();
|
|
39
|
+
const alternate = scopeOf(init.baseUrl);
|
|
40
|
+
if ((alternate.origin ?? origin) !== origin || alternate.pathname !== scope.pathname)
|
|
41
|
+
unsafe();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async fetch(request) {
|
|
45
|
+
const url = new URL(request.url);
|
|
46
|
+
if (!origin || url.origin !== origin || url.username || url.password || !(url.pathname === scope.pathname || url.pathname.startsWith(`${scope.pathname}/`)) || request.redirect !== "error")
|
|
47
|
+
unsafe();
|
|
48
|
+
return transport(request);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function guardHttpMethods(client, validate) {
|
|
53
|
+
const methods = /* @__PURE__ */ new Map();
|
|
54
|
+
return new Proxy(client, {
|
|
55
|
+
get(target, property, receiver) {
|
|
56
|
+
const value = Reflect.get(target, property, receiver);
|
|
57
|
+
if (typeof property !== "string" || typeof value !== "function" || !(verbs.has(property) || property === "request"))
|
|
58
|
+
return value;
|
|
59
|
+
if (!methods.has(property))
|
|
60
|
+
methods.set(property, async (...args) => {
|
|
61
|
+
validate(args[property === "request" ? 2 : 1]);
|
|
62
|
+
return Reflect.apply(value, target, args);
|
|
63
|
+
});
|
|
64
|
+
return methods.get(property);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// packages/api-client/src/client.ts
|
|
3
70
|
function createContentFactoryClient(options = {}) {
|
|
71
|
+
const baseUrl = options.baseUrl ?? "/api/v1";
|
|
72
|
+
const policy = httpRequestPolicy(
|
|
73
|
+
baseUrl,
|
|
74
|
+
options.fetch ?? ((request) => globalThis.fetch(request))
|
|
75
|
+
);
|
|
4
76
|
const client = createClient({
|
|
5
|
-
baseUrl
|
|
77
|
+
baseUrl,
|
|
6
78
|
credentials: "include",
|
|
7
79
|
redirect: "error",
|
|
8
|
-
|
|
80
|
+
fetch: policy.fetch
|
|
9
81
|
});
|
|
10
82
|
client.use({
|
|
11
83
|
onRequest({ request }) {
|
|
@@ -16,7 +88,7 @@ function createContentFactoryClient(options = {}) {
|
|
|
16
88
|
return new Request(request, { headers, body: "{}" });
|
|
17
89
|
}
|
|
18
90
|
});
|
|
19
|
-
return client;
|
|
91
|
+
return guardHttpMethods(client, policy.validateInit);
|
|
20
92
|
}
|
|
21
93
|
|
|
22
94
|
// packages/contracts/src/business-code.ts
|
package/dist/index.js
CHANGED
|
@@ -5238,6 +5238,7 @@ var capabilityRejectedErrorCodes = [
|
|
|
5238
5238
|
"DISTRIBUTION_TARGET_INVALID",
|
|
5239
5239
|
"FORBIDDEN",
|
|
5240
5240
|
"CAPABILITY_INPUT_INVALID",
|
|
5241
|
+
"CAPABILITY_INPUT_LIMIT_EXCEEDED",
|
|
5241
5242
|
"CAPABILITY_SCHEMA_CHANGED",
|
|
5242
5243
|
"CAPABILITY_CALL_RESERVED",
|
|
5243
5244
|
"FOUNDATION_EDIT_CONFLICT",
|
|
@@ -5489,6 +5490,18 @@ var businessDocumentInputSchema = z72.object({
|
|
|
5489
5490
|
// packages/contracts/src/agent/compact-surface.ts
|
|
5490
5491
|
import { z as z73 } from "zod";
|
|
5491
5492
|
var nativeAgentSurfaceCapability = "io.native-marketing/agent-native";
|
|
5493
|
+
var capabilityInputLimits = Object.freeze({ maxElements: 2e4, maxDepth: 64 });
|
|
5494
|
+
var capabilityProtocolToolNames = [
|
|
5495
|
+
"cf_discover_capabilities",
|
|
5496
|
+
"cf_describe_capability",
|
|
5497
|
+
"cf_read_capability_schema",
|
|
5498
|
+
"cf_search_business",
|
|
5499
|
+
"cf_read_business_document",
|
|
5500
|
+
"cf_get_business_summary",
|
|
5501
|
+
"cf_call_capability",
|
|
5502
|
+
"cf_read_capability",
|
|
5503
|
+
"cf_write_capability"
|
|
5504
|
+
];
|
|
5492
5505
|
var hash = z73.string().regex(/^[a-f0-9]{64}$/u);
|
|
5493
5506
|
var capabilitySchemaReadSchema = capabilityDescribeSchema.extend({
|
|
5494
5507
|
expectedSchemaSha256: hash,
|
|
@@ -6834,6 +6847,7 @@ function isKnownCapabilityRejection(code2, name) {
|
|
|
6834
6847
|
var recoveries = {
|
|
6835
6848
|
CAPABILITY_SCHEMA_CHANGED: "READ_EXACT_SCHEMA",
|
|
6836
6849
|
CAPABILITY_INPUT_INVALID: "READ_EXACT_SCHEMA",
|
|
6850
|
+
CAPABILITY_INPUT_LIMIT_EXCEEDED: "REDUCE_INPUT_SIZE_OR_DEPTH",
|
|
6837
6851
|
OPPORTUNITY_STRATEGY_REFRESH_REQUIRED: "READ_CURRENT_STRATEGY",
|
|
6838
6852
|
CAPABILITY_EFFECT_MISMATCH: "USE_ENTRY_MATCHING_EFFECT",
|
|
6839
6853
|
CAPABILITY_OUTPUT_INVALID: "QUERY_ORIGINAL_OUTCOME_BEFORE_RETRY",
|
|
@@ -7406,6 +7420,7 @@ var CapabilityDefinitionCache = class {
|
|
|
7406
7420
|
remember(value) {
|
|
7407
7421
|
const verified = verifyCapabilityDefinition(value, value.definition.name);
|
|
7408
7422
|
const key2 = `${verified.definition.name}:AGENT_V3:${verified.schemaSha256}`;
|
|
7423
|
+
this.values.delete(key2);
|
|
7409
7424
|
if (this.values.size >= 64) this.values.delete(this.values.keys().next().value);
|
|
7410
7425
|
this.values.set(key2, structuredClone(verified));
|
|
7411
7426
|
}
|
|
@@ -7413,6 +7428,15 @@ var CapabilityDefinitionCache = class {
|
|
|
7413
7428
|
const value = this.values.get(`${name}:AGENT_V3:${hash5}`);
|
|
7414
7429
|
return value ? structuredClone(value) : void 0;
|
|
7415
7430
|
}
|
|
7431
|
+
latest(name) {
|
|
7432
|
+
for (const value of [...this.values.values()].reverse())
|
|
7433
|
+
if (value.definition.name === name) return structuredClone(value);
|
|
7434
|
+
return void 0;
|
|
7435
|
+
}
|
|
7436
|
+
forget(name) {
|
|
7437
|
+
for (const [key2, value] of this.values)
|
|
7438
|
+
if (value.definition.name === name) this.values.delete(key2);
|
|
7439
|
+
}
|
|
7416
7440
|
};
|
|
7417
7441
|
|
|
7418
7442
|
// packages/cli-client/src/capability-errors.ts
|
|
@@ -7436,6 +7460,7 @@ function capabilityError(tool5, data, readOnly = true, input) {
|
|
|
7436
7460
|
outcome,
|
|
7437
7461
|
{
|
|
7438
7462
|
recovery,
|
|
7463
|
+
...code2 === "CAPABILITY_INPUT_LIMIT_EXCEEDED" && outcome === "REJECTED" ? { inputLimits: capabilityInputLimits } : {},
|
|
7439
7464
|
...receipt ? { receipt } : {},
|
|
7440
7465
|
...status ? { status } : {},
|
|
7441
7466
|
...validation?.success && validationMatches ? { validation: validation.data } : {}
|
|
@@ -7454,6 +7479,7 @@ function boundedFetch(origin2, timeout) {
|
|
|
7454
7479
|
throw new CliError("UNTRUSTED_ENDPOINT", "Cross-origin credential requests are forbidden.");
|
|
7455
7480
|
const signal = AbortSignal.any([
|
|
7456
7481
|
AbortSignal.timeout(timeout),
|
|
7482
|
+
...input instanceof Request ? [input.signal] : [],
|
|
7457
7483
|
...init?.signal ? [init.signal] : []
|
|
7458
7484
|
]);
|
|
7459
7485
|
const response = await fetch(input, { ...init, signal, redirect: "error" });
|
|
@@ -7652,12 +7678,12 @@ var ProfileStore = class {
|
|
|
7652
7678
|
const temporary = `${this.path}.${randomUUID()}.tmp`;
|
|
7653
7679
|
const file = await open2(temporary, "wx", 384);
|
|
7654
7680
|
try {
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7681
|
+
try {
|
|
7682
|
+
await file.writeFile(JSON.stringify(profile) + "\n");
|
|
7683
|
+
await file.sync();
|
|
7684
|
+
} finally {
|
|
7685
|
+
await file.close();
|
|
7686
|
+
}
|
|
7661
7687
|
await rename(temporary, this.path);
|
|
7662
7688
|
} finally {
|
|
7663
7689
|
await unlink(temporary).catch(() => void 0);
|
|
@@ -7762,6 +7788,8 @@ async function withClient(profile, timeout, operation) {
|
|
|
7762
7788
|
}
|
|
7763
7789
|
}
|
|
7764
7790
|
async function callTool(client, tool5, input, timeout, readOnly, errorToolName = tool5.name) {
|
|
7791
|
+
if (["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool5.name) && errorToolName === tool5.name && typeof input.name === "string" && /^cf_[a-z0-9_]{1,100}$/.test(input.name))
|
|
7792
|
+
errorToolName = input.name;
|
|
7765
7793
|
const original = ["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool5.name) && input.name === errorToolName ? input.arguments : input;
|
|
7766
7794
|
const unknown = (code2, message) => {
|
|
7767
7795
|
const receipt = capabilityReceiptRead(errorToolName, original);
|
|
@@ -8015,7 +8043,7 @@ function checkTimeout(timeout) {
|
|
|
8015
8043
|
}
|
|
8016
8044
|
|
|
8017
8045
|
// packages/cli-client/src/tool-definition.ts
|
|
8018
|
-
async function nativeToolDefinition(client, name, timeout) {
|
|
8046
|
+
async function nativeToolDefinition(client, name, timeout, definitions, reuse = true) {
|
|
8019
8047
|
const feature = client.getServerCapabilities()?.experimental?.[nativeAgentSurfaceCapability];
|
|
8020
8048
|
if (feature !== void 0) {
|
|
8021
8049
|
if (!feature || typeof feature !== "object" || !("version" in feature) || feature.version !== 1)
|
|
@@ -8023,7 +8051,9 @@ async function nativeToolDefinition(client, name, timeout) {
|
|
|
8023
8051
|
"UNSUPPORTED_AGENT_SURFACE",
|
|
8024
8052
|
"Unsupported discovery version; no business call was sent."
|
|
8025
8053
|
);
|
|
8026
|
-
const
|
|
8054
|
+
const cached = reuse ? definitions?.latest(name) : void 0;
|
|
8055
|
+
const exact = cached ?? await describeNativeCapability(client, name, timeout);
|
|
8056
|
+
if (!cached) definitions?.remember(exact);
|
|
8027
8057
|
return { tool: exact.definition, schemaSha256: exact.schemaSha256 };
|
|
8028
8058
|
}
|
|
8029
8059
|
let cursor;
|
|
@@ -8215,9 +8245,9 @@ function knowledgePathMatchesResource(readingPath, resourcePath) {
|
|
|
8215
8245
|
}
|
|
8216
8246
|
|
|
8217
8247
|
// packages/cli-client/src/operations.ts
|
|
8218
|
-
async function inspectNativeTool(client, name, timeout = 3e4) {
|
|
8248
|
+
async function inspectNativeTool(client, name, timeout = 3e4, definitions) {
|
|
8219
8249
|
check(name, {}, timeout);
|
|
8220
|
-
return (await nativeToolDefinition(client, name, timeout)).tool;
|
|
8250
|
+
return (await nativeToolDefinition(client, name, timeout, definitions)).tool;
|
|
8221
8251
|
}
|
|
8222
8252
|
async function listNativeToolsPage(client, input = {}, timeout = 3e4) {
|
|
8223
8253
|
check("cf_list", input, timeout);
|
|
@@ -8231,13 +8261,25 @@ async function listNativeToolsPage(client, input = {}, timeout = 3e4) {
|
|
|
8231
8261
|
throw new CliError("INVALID_TOOL_DIRECTORY", "Expected one typed tool catalogue page.");
|
|
8232
8262
|
return page2;
|
|
8233
8263
|
}
|
|
8234
|
-
async function callNativeTool(client, name, input, resource, options = {}, timeout = 3e4) {
|
|
8264
|
+
async function callNativeTool(client, name, input, resource, options = {}, timeout = 3e4, definitions) {
|
|
8235
8265
|
check(name, input, timeout);
|
|
8236
8266
|
if (Object.keys(options).some((key2) => !["view", "expectedSchemaSha256"].includes(key2)) || options.view !== void 0 && !["SUMMARY", "INDEX", "PAGE", "ORIGINAL"].includes(options.view))
|
|
8237
8267
|
throw new CliError("INVALID_VIEW", "Use SUMMARY, INDEX, PAGE or ORIGINAL.");
|
|
8238
8268
|
if (options.expectedSchemaSha256 !== void 0 && !/^[a-f0-9]{64}$/.test(options.expectedSchemaSha256))
|
|
8239
8269
|
throw new CliError("INVALID_SCHEMA_HASH", "Supply the observed schema SHA-256.");
|
|
8240
|
-
const
|
|
8270
|
+
const summary2 = agentSummarySourceSchema.safeParse(name), document2 = businessDocumentToolSchema.safeParse(name);
|
|
8271
|
+
const protocol = capabilityProtocolToolNames.some((entry) => entry === name);
|
|
8272
|
+
const cached = definitions?.latest(name), flags2 = cached?.definition.annotations;
|
|
8273
|
+
const reuse = Boolean(
|
|
8274
|
+
cached && !protocol && (options.view === "ORIGINAL" || options.view === void 0 && !summary2.success && !document2.success) && (flags2?.readOnlyHint !== true || flags2.destructiveHint !== true && flags2.openWorldHint === false)
|
|
8275
|
+
);
|
|
8276
|
+
const { tool: tool5, schemaSha256 } = await nativeToolDefinition(
|
|
8277
|
+
client,
|
|
8278
|
+
name,
|
|
8279
|
+
timeout,
|
|
8280
|
+
definitions,
|
|
8281
|
+
reuse
|
|
8282
|
+
);
|
|
8241
8283
|
if (options.expectedSchemaSha256 !== void 0 && schemaSha256 !== options.expectedSchemaSha256)
|
|
8242
8284
|
throw new CliError(
|
|
8243
8285
|
"CAPABILITY_SCHEMA_CHANGED",
|
|
@@ -8245,7 +8287,6 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
|
|
|
8245
8287
|
"NOT_SENT",
|
|
8246
8288
|
{ recovery: "READ_EXACT_SCHEMA" }
|
|
8247
8289
|
);
|
|
8248
|
-
const summary2 = agentSummarySourceSchema.safeParse(name), document2 = businessDocumentToolSchema.safeParse(name);
|
|
8249
8290
|
const read2 = tool5.annotations?.readOnlyHint === true;
|
|
8250
8291
|
const view = options.view ?? (schemaSha256 && read2 ? summary2.success ? "SUMMARY" : document2.success ? "INDEX" : "ORIGINAL" : "ORIGINAL");
|
|
8251
8292
|
if (view !== "ORIGINAL" && (!schemaSha256 || !read2 || (view === "SUMMARY" ? !summary2.success : !document2.success)))
|
|
@@ -8254,29 +8295,41 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
|
|
|
8254
8295
|
"This view is unavailable for this exact tool/resource; no business call was sent."
|
|
8255
8296
|
);
|
|
8256
8297
|
let result2;
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8298
|
+
try {
|
|
8299
|
+
if (view === "SUMMARY" && summary2.success)
|
|
8300
|
+
result2 = await getNativeBusinessSummary(
|
|
8301
|
+
client,
|
|
8302
|
+
{ sourceTool: summary2.data, sourceInput: input },
|
|
8303
|
+
timeout
|
|
8304
|
+
);
|
|
8305
|
+
else if ((view === "INDEX" || view === "PAGE") && document2.success)
|
|
8306
|
+
result2 = await readNativeDocumentPage(
|
|
8307
|
+
client,
|
|
8308
|
+
{
|
|
8309
|
+
sourceTool: document2.data,
|
|
8310
|
+
sourceInput: input,
|
|
8311
|
+
format: view === "INDEX" ? "INDEX" : "JSON_TEXT"
|
|
8312
|
+
},
|
|
8313
|
+
timeout
|
|
8314
|
+
);
|
|
8315
|
+
else if (schemaSha256 && read2 && !protocol && tool5.annotations?.destructiveHint !== true && tool5.annotations?.openWorldHint === false)
|
|
8316
|
+
result2 = await readNativeCapability(
|
|
8317
|
+
client,
|
|
8318
|
+
{ name, expectedSchemaSha256: schemaSha256, arguments: input, delivery: "ORIGINAL" },
|
|
8319
|
+
timeout
|
|
8320
|
+
);
|
|
8321
|
+
else if (schemaSha256 && !read2 && !protocol)
|
|
8322
|
+
result2 = await callNativeCapability(
|
|
8323
|
+
client,
|
|
8324
|
+
{ name, expectedSchemaSha256: schemaSha256, arguments: input, delivery: "ORIGINAL" },
|
|
8325
|
+
timeout
|
|
8326
|
+
);
|
|
8327
|
+
else result2 = await callTool(client, tool5, input, timeout, read2);
|
|
8328
|
+
} catch (error) {
|
|
8329
|
+
if (error instanceof CliError && error.code === "CAPABILITY_SCHEMA_CHANGED")
|
|
8330
|
+
definitions?.forget(name);
|
|
8331
|
+
throw error;
|
|
8332
|
+
}
|
|
8280
8333
|
return { tool: name, view, result: result2, links: reviewLinks(resource, name, result2, input) };
|
|
8281
8334
|
}
|
|
8282
8335
|
function check(name, input, timeout) {
|
|
@@ -8601,8 +8654,8 @@ async function withNativeAgentClient(connection, action, options = {}) {
|
|
|
8601
8654
|
readProjectMediaFile: (input) => readNativeProjectMediaFile(connection, input, timeout),
|
|
8602
8655
|
uploadProjectMedia: (file) => uploadNativeProjectMedia(connection, file, timeout),
|
|
8603
8656
|
uploadMaterial: (file) => uploadNativeMaterial(connection, file, timeout),
|
|
8604
|
-
inspectTool: (name) => inspectNativeTool(client, name, timeout),
|
|
8605
|
-
callTool: (name, input = {}, options2) => callNativeTool(client, name, input, connection.resource, options2, timeout),
|
|
8657
|
+
inspectTool: (name) => inspectNativeTool(client, name, timeout, definitions),
|
|
8658
|
+
callTool: (name, input = {}, options2) => callNativeTool(client, name, input, connection.resource, options2, timeout, definitions),
|
|
8606
8659
|
listToolsPage: (input = {}) => listNativeToolsPage(client, input, timeout),
|
|
8607
8660
|
readCapabilitySchemaPage: (input) => readNativeCapabilitySchemaPage(client, input, timeout),
|
|
8608
8661
|
readDocumentPage: (input) => readNativeDocumentPage(client, input, timeout),
|
package/package.json
CHANGED
package/release.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"sourceCommit": "
|
|
2
|
+
"sourceCommit": "a8ae57db987c771cf1884afa5f318828da0f45ab",
|
|
3
3
|
"workingTreeDirty": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.3",
|
|
5
5
|
"openapiTypesSha256": "1a86e24ce9e458e945e4df5e9c7423c9bf4253ac24b3f627f67ba38c92856a38",
|
|
6
6
|
"localBuild": true
|
|
7
7
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const nativeAgentSurfaceCapability = "io.native-marketing/agent-native";
|
|
3
|
+
export declare const capabilityInputLimits: Readonly<{
|
|
4
|
+
maxElements: 20000;
|
|
5
|
+
maxDepth: 64;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const capabilityProtocolToolNames: readonly ['cf_discover_capabilities', 'cf_describe_capability', 'cf_read_capability_schema', 'cf_search_business', 'cf_read_business_document', 'cf_get_business_summary', 'cf_call_capability', 'cf_read_capability', 'cf_write_capability'];
|
|
3
8
|
export declare const capabilitySchemaReadSchema: z.ZodObject<{
|
|
4
9
|
name: z.ZodString;
|
|
5
10
|
expectedSchemaSha256: z.ZodString;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function httpRequestPolicy(baseUrl: string, transport: (input: Request) => Promise<Response>): {
|
|
2
|
+
validateInit(value: unknown): void;
|
|
3
|
+
fetch(request: Request): Promise<Response>;
|
|
4
|
+
};
|
|
5
|
+
export declare function guardHttpMethods<T extends object>(client: T, validate: (init: unknown) => void): T;
|
|
@@ -21,4 +21,22 @@ export declare class CapabilityDefinitionCache {
|
|
|
21
21
|
callsReauthorize: true;
|
|
22
22
|
};
|
|
23
23
|
} | undefined;
|
|
24
|
+
latest(name: string): {
|
|
25
|
+
schemaVersion: 1;
|
|
26
|
+
schemaSha256: string;
|
|
27
|
+
definition: {
|
|
28
|
+
name: string;
|
|
29
|
+
title?: string | undefined;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
inputSchema: Record<string, unknown>;
|
|
32
|
+
outputSchema?: Record<string, unknown> | undefined;
|
|
33
|
+
annotations?: Record<string, unknown> | undefined;
|
|
34
|
+
_meta?: Record<string, unknown> | undefined;
|
|
35
|
+
};
|
|
36
|
+
authority: {
|
|
37
|
+
discoveryIsAuthority: false;
|
|
38
|
+
callsReauthorize: true;
|
|
39
|
+
};
|
|
40
|
+
} | undefined;
|
|
41
|
+
forget(name: string): void;
|
|
24
42
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Client } from '@modelcontextprotocol/client';
|
|
2
|
+
import type { CapabilityDefinitionCache } from './capability-definition.js';
|
|
2
3
|
export type NativeReadView = 'SUMMARY' | 'INDEX' | 'PAGE' | 'ORIGINAL';
|
|
3
4
|
export type NativeToolOptions = {
|
|
4
5
|
view?: NativeReadView | undefined;
|
|
@@ -10,7 +11,7 @@ export type NativeToolResult<T = unknown> = {
|
|
|
10
11
|
result: T;
|
|
11
12
|
links: Record<string, string>;
|
|
12
13
|
};
|
|
13
|
-
export declare function inspectNativeTool(client: Client, name: string, timeout?: number): Promise<{
|
|
14
|
+
export declare function inspectNativeTool(client: Client, name: string, timeout?: number, definitions?: CapabilityDefinitionCache): Promise<{
|
|
14
15
|
description?: string | undefined;
|
|
15
16
|
inputSchema: {
|
|
16
17
|
[x: string]: unknown;
|
|
@@ -207,4 +208,4 @@ export declare function listNativeToolsPage(client: Client, input?: Record<strin
|
|
|
207
208
|
title?: string | undefined;
|
|
208
209
|
}[];
|
|
209
210
|
}>;
|
|
210
|
-
export declare function callNativeTool(client: Client, name: string, input: Record<string, unknown>, resource: string, options?: NativeToolOptions, timeout?: number): Promise<NativeToolResult>;
|
|
211
|
+
export declare function callNativeTool(client: Client, name: string, input: Record<string, unknown>, resource: string, options?: NativeToolOptions, timeout?: number, definitions?: CapabilityDefinitionCache): Promise<NativeToolResult>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Client, Tool } from '@modelcontextprotocol/client';
|
|
2
|
-
|
|
2
|
+
import type { CapabilityDefinitionCache } from './capability-definition.js';
|
|
3
|
+
export declare function nativeToolDefinition(client: Client, name: string, timeout: number, definitions?: CapabilityDefinitionCache, reuse?: boolean): Promise<{
|
|
3
4
|
tool: Tool;
|
|
4
5
|
schemaSha256: string;
|
|
5
6
|
} | {
|