linkque-cli-v2 1.6.24 → 1.6.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.6.24",
3
+ "version": "1.6.25",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -23,7 +23,7 @@ import {
23
23
  RuntimeConfigProvider,
24
24
  getRunEmbeddedQuery,
25
25
  isDebugLoggingEnabled
26
- } from "./chunk-2D6TBUEQ.js";
26
+ } from "./chunk-IMRER6VX.js";
27
27
  import {
28
28
  __commonJS,
29
29
  __require,
@@ -7416,6 +7416,7 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
7416
7416
  LINKQUEGW_TELEMETRY_LOGS_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/telemetry/v1/logs`,
7417
7417
  LINKQUEGW_TELEMETRY_TRACES_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/telemetry/v1/traces`,
7418
7418
  LINKQUEGW_MCP_SIGN_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/mcp/signature`,
7419
+ LINKQUEGW_A2A_SIGN_ENDPOINT_PRE: `${LINKQUE_ENDPOINT_PRE}/api/a2a/signature`,
7419
7420
  LINKQUE_OPEN_MCP_BASE_URL: "https://opengw.alipay.com",
7420
7421
  LINKQUE_OPEN_MCP_BASE_URL_PRE: "https://opengw-pre.alipay.com",
7421
7422
  EXTERNAL_ACTION_DATABASE_ID: "linkque",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EModelProvider
3
- } from "./chunk-2D6TBUEQ.js";
3
+ } from "./chunk-IMRER6VX.js";
4
4
 
5
5
  // ../linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js
6
6
  var baked;
@@ -40856,6 +40856,7 @@ var EResourceType;
40856
40856
  EResourceType2["SKILL"] = "SKILL";
40857
40857
  EResourceType2["MCP"] = "MCP";
40858
40858
  EResourceType2["MCP_TOOL"] = "MCP_TOOL";
40859
+ EResourceType2["REMOTE_AGENT"] = "REMOTE_AGENT";
40859
40860
  EResourceType2["KNOWLEDGE"] = "KNOWLEDGE";
40860
40861
  EResourceType2["CARD"] = "CARD";
40861
40862
  EResourceType2["TOOL"] = "TOOL";
@@ -40898,6 +40899,7 @@ var EHookExecutorName;
40898
40899
  EHookExecutorName2["McpDiscoveryHookExecutor"] = "McpDiscoveryHookExecutor";
40899
40900
  EHookExecutorName2["BusinessDataPromptHookExecutor"] = "BusinessDataPromptHookExecutor";
40900
40901
  EHookExecutorName2["CurrentTimeHookExecutor"] = "CurrentTimeHookExecutor";
40902
+ EHookExecutorName2["A2aHookExecutor"] = "A2aHookExecutor";
40901
40903
  EHookExecutorName2["MemoryHookExecutor"] = "MemoryHookExecutor";
40902
40904
  })(EHookExecutorName || (EHookExecutorName = {}));
40903
40905
 
@@ -40929,6 +40931,10 @@ function readAuthorizationChallenge(value) {
40929
40931
  return void 0;
40930
40932
  const identity = value.identityAuth;
40931
40933
  const privacy = value.privacyAuth;
40934
+ if (value.authorizationKind !== void 0 && value.authorizationKind !== "mcp" && value.authorizationKind !== "apass")
40935
+ return void 0;
40936
+ if (value.authorizationKind === "apass" && (!record2(value.presentation) || !value.presentation.agreementUrl || !value.presentation.learnMoreUrl))
40937
+ return void 0;
40932
40938
  if (value.presentation !== void 0 && !readAuthorizationPresentation(value.presentation))
40933
40939
  return void 0;
40934
40940
  if (identity !== void 0 && identity !== null && (!record2(identity) || !Array.isArray(identity.agreements) || identity.agreements.length > 16 || !identity.agreements.every(agreement)))
@@ -40947,16 +40953,34 @@ function readAuthorizationChallenge(value) {
40947
40953
  function readAuthorizationPresentation(value) {
40948
40954
  if (!record2(value) || !displayText(value.serviceName, 128) || !displayText(value.description, 1024) || !displayText(value.providerName, 256) || !Array.isArray(value.requestedInformation) || value.requestedInformation.length < 1 || value.requestedInformation.length > 64 || !value.requestedInformation.every((name) => displayText(name, 256)))
40949
40955
  return void 0;
40956
+ const links = [value.learnMoreUrl, value.agreementUrl, value.agreementName];
40957
+ if (links.some((item) => item !== void 0) && (!httpsUrl(value.learnMoreUrl) || !httpsUrl(value.agreementUrl) || !displayText(value.agreementName, 256)))
40958
+ return void 0;
40950
40959
  return {
40951
40960
  serviceName: value.serviceName.trim(),
40952
40961
  description: value.description.trim(),
40953
40962
  providerName: value.providerName.trim(),
40954
- requestedInformation: value.requestedInformation.map((name) => name.trim())
40963
+ requestedInformation: value.requestedInformation.map((name) => name.trim()),
40964
+ ...value.agreementUrl ? {
40965
+ learnMoreUrl: value.learnMoreUrl,
40966
+ agreementUrl: value.agreementUrl,
40967
+ agreementName: value.agreementName.trim()
40968
+ } : {}
40955
40969
  };
40956
40970
  }
40957
40971
  function agreement(value) {
40958
40972
  return record2(value) && ["id", "templateCode", "templateName", "templateText", "url"].every((key) => typeof value[key] === "string" && value[key].length <= 4096);
40959
40973
  }
40974
+ function httpsUrl(value) {
40975
+ if (!bounded(value, 2048))
40976
+ return false;
40977
+ try {
40978
+ const url2 = new URL(value);
40979
+ return url2.protocol === "https:" && !url2.username && !url2.password;
40980
+ } catch {
40981
+ return false;
40982
+ }
40983
+ }
40960
40984
  function bounded(value, limit) {
40961
40985
  return typeof value === "string" && value.length > 0 && value.length <= limit;
40962
40986
  }
@@ -41943,6 +41967,23 @@ function validateA2UIEventSource(value, path2, issues) {
41943
41967
  issues.push(`${path2}.${field} must be a non-empty string when provided`);
41944
41968
  }
41945
41969
  }
41970
+ if (value.remoteAgent !== void 0) {
41971
+ const remote = value.remoteAgent;
41972
+ if (!isRecord2(remote) || !isNonEmptyString2(remote.resourceId) || !Object.hasOwn(remote, "surfaceRevision") || remote.presentationAdapter !== void 0 && !isNonEmptyString2(remote.presentationAdapter))
41973
+ issues.push(`${path2}.remoteAgent must contain a resourceId and surfaceRevision`);
41974
+ else
41975
+ validateJsonValue(remote, `${path2}.remoteAgent`, issues);
41976
+ }
41977
+ if (value.cardSnapshot !== void 0) {
41978
+ const snapshot = value.cardSnapshot;
41979
+ if (!isRecord2(snapshot) || !Array.isArray(snapshot.datas) || !snapshot.datas.every(isRecord2))
41980
+ issues.push(`${path2}.cardSnapshot must contain a datas object array`);
41981
+ else {
41982
+ validateJsonValue(snapshot, `${path2}.cardSnapshot`, issues);
41983
+ if (JSON.stringify(snapshot).length > 1024 * 1024)
41984
+ issues.push(`${path2}.cardSnapshot exceeds the size limit`);
41985
+ }
41986
+ }
41946
41987
  if (value.instanceIndex !== void 0 && (!Number.isSafeInteger(value.instanceIndex) || Number(value.instanceIndex) < 0)) {
41947
41988
  issues.push(`${path2}.instanceIndex must be a non-negative safe integer when provided`);
41948
41989
  }
@@ -42260,9 +42301,6 @@ function isRecord4(value) {
42260
42301
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
42261
42302
  }
42262
42303
 
42263
- // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/gatewayAuthorization.js
42264
- import { randomUUID } from "node:crypto";
42265
-
42266
42304
  // ../linkque-agent-runtime/dist/esm/core/abort.js
42267
42305
  function waitWithSignal(operation, signal) {
42268
42306
  if (typeof operation === "function") {
@@ -42297,7 +42335,83 @@ function waitForPromise(operation, signal) {
42297
42335
  });
42298
42336
  }
42299
42337
 
42338
+ // ../linkque-agent-runtime/dist/esm/impl/apassAuthorization.js
42339
+ var ApassAuthorizationRequiredError = class extends Error {
42340
+ challenge;
42341
+ code = "APASS_AUTHORIZATION_REQUIRED";
42342
+ constructor(challenge) {
42343
+ super("\u7B49\u5F85 APASS \u6388\u6743");
42344
+ this.challenge = challenge;
42345
+ }
42346
+ };
42347
+ function apassChallenge(error) {
42348
+ if (!error || typeof error !== "object" || error.code !== "APASS_AUTHORIZATION_REQUIRED")
42349
+ return void 0;
42350
+ const challenge = readAuthorizationChallenge(error.challenge);
42351
+ if (challenge?.authorizationKind === "apass")
42352
+ return challenge;
42353
+ return void 0;
42354
+ }
42355
+ async function invokeApassAuthorization(baseUrl, authorization, operation, body, fetchImpl = fetch, signal) {
42356
+ const credential = /^(Bearer|Scenario)[\t ]+([^\s,]+)$/iu.exec(authorization);
42357
+ if (!credential || (credential[1].toLowerCase() === "scenario" ? !/^lqs_[A-Za-z0-9_-]{43}$/u.test(credential[2]) : credential[2].startsWith("lqs_")))
42358
+ throw new Error("APASS_USER_AUTHORIZATION_REQUIRED");
42359
+ if (!body || typeof body !== "object" || Array.isArray(body))
42360
+ throw new Error("APASS_AUTHORIZATION_FAILED");
42361
+ const requestBody = {
42362
+ ...body,
42363
+ credentialType: credential[1].toLowerCase() === "scenario" ? "scenarioToken" : "userToken"
42364
+ };
42365
+ const combined = AbortSignal.any([
42366
+ AbortSignal.timeout(15e3),
42367
+ ...signal ? [signal] : []
42368
+ ]);
42369
+ let reader;
42370
+ try {
42371
+ const response = await waitWithSignal(() => fetchImpl(new URL(`/api/apass/${operation}`, baseUrl), {
42372
+ method: "POST",
42373
+ redirect: "error",
42374
+ signal: combined,
42375
+ headers: { "content-type": "application/json", authorization },
42376
+ body: JSON.stringify(requestBody)
42377
+ }), combined);
42378
+ if (!response.ok || !response.body) {
42379
+ void response.body?.cancel().catch(() => void 0);
42380
+ throw new Error("APASS_AUTHORIZATION_FAILED");
42381
+ }
42382
+ reader = response.body.getReader();
42383
+ const decoder = new TextDecoder("utf-8", { fatal: true });
42384
+ let text = "";
42385
+ let bytes2 = 0;
42386
+ while (true) {
42387
+ const chunk = await waitWithSignal(() => reader.read(), combined);
42388
+ if (chunk.done)
42389
+ break;
42390
+ bytes2 += chunk.value.byteLength;
42391
+ if (bytes2 > 65536)
42392
+ throw new Error("APASS_AUTHORIZATION_FAILED");
42393
+ text += decoder.decode(chunk.value, { stream: true });
42394
+ }
42395
+ const result = JSON.parse(text + decoder.decode());
42396
+ if (!result || typeof result !== "object" || Array.isArray(result))
42397
+ throw new Error("APASS_AUTHORIZATION_FAILED");
42398
+ const envelope = result;
42399
+ if (envelope.success !== true || !envelope.data || typeof envelope.data !== "object" || Array.isArray(envelope.data))
42400
+ throw new Error("APASS_AUTHORIZATION_FAILED");
42401
+ return envelope.data;
42402
+ } catch {
42403
+ signal?.throwIfAborted();
42404
+ throw new Error("APASS_AUTHORIZATION_FAILED");
42405
+ } finally {
42406
+ if (reader) {
42407
+ void reader.cancel().catch(() => void 0);
42408
+ reader.releaseLock();
42409
+ }
42410
+ }
42411
+ }
42412
+
42300
42413
  // ../linkque-agent-runtime/dist/esm/impl/mcp/alipay/gatewayAuthorization.js
42414
+ import { randomUUID } from "node:crypto";
42301
42415
  function failed() {
42302
42416
  return Object.assign(new Error("\u6388\u6743\u670D\u52A1\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"), {
42303
42417
  code: "AUTHORIZATION_GATEWAY_FAILED"
@@ -42440,6 +42554,12 @@ function toAuthorizationChallenge(result, serviceName) {
42440
42554
  return challenge;
42441
42555
  }
42442
42556
  async function confirmAuthorization(input, options) {
42557
+ if (input.authorizationKind === "apass") {
42558
+ const result = await invokeApassAuthorization(options.baseUrl, options.authorizationHeader, "confirmAuth", { agentId: input.agentId, authSessionId: input.authSessionId }, options.fetch);
42559
+ if (result.status !== "confirmed" || result.authSessionId !== input.authSessionId)
42560
+ throw failed();
42561
+ return;
42562
+ }
42443
42563
  await invoke(options, "confirmAuth", {
42444
42564
  agentId: input.agentId,
42445
42565
  authSessionId: input.authSessionId
@@ -43525,13 +43645,32 @@ function validateJsonSchemaValue2(schema, value, path2 = "$") {
43525
43645
  validateValue(schema, value, path2, issues);
43526
43646
  return issues;
43527
43647
  }
43528
- function normalizeCardDataValue(schema, value, required = true) {
43648
+ function projectCardData(schema, value) {
43649
+ if (schema.type === "array" && Array.isArray(value) && isPlainRecord(schema.items)) {
43650
+ const items = schema.items;
43651
+ return value.map((child) => projectCardData(items, child));
43652
+ }
43653
+ if (schema.type !== "object" || !isPlainRecord(value) || !isPlainRecord(schema.properties)) {
43654
+ return value;
43655
+ }
43656
+ const properties = schema.properties;
43657
+ return Object.fromEntries(Object.entries(value).flatMap(([key, child]) => {
43658
+ if (Object.prototype.hasOwnProperty.call(properties, key))
43659
+ return [[key, projectCardData(properties[key], child)]];
43660
+ return schema.additionalProperties === false ? [] : [[key, child]];
43661
+ }));
43662
+ }
43663
+ function normalizeCardDataValue(schema, value, required = true, coerceOptionalScalars = true) {
43664
+ return normalizeCardDataNode(schema, value, required, coerceOptionalScalars, true);
43665
+ }
43666
+ function normalizeCardDataNode(schema, value, required, coerceOptionalScalars, parentAllowsCoercion) {
43667
+ const coerce2 = parentAllowsCoercion && (required || coerceOptionalScalars);
43529
43668
  if (value === void 0 || value === null)
43530
43669
  return required ? value : void 0;
43531
43670
  let normalized = value;
43532
- if (schema.type === "string" && (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))) {
43671
+ if (coerce2 && schema.type === "string" && (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))) {
43533
43672
  normalized = String(value);
43534
- } else if ((schema.type === "number" || schema.type === "integer") && typeof value === "string") {
43673
+ } else if (coerce2 && (schema.type === "number" || schema.type === "integer") && typeof value === "string") {
43535
43674
  const text = value.trim();
43536
43675
  if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u.test(text)) {
43537
43676
  const number2 = Number(text);
@@ -43544,11 +43683,11 @@ function normalizeCardDataValue(schema, value, required = true) {
43544
43683
  const requiredKeys = new Set(Array.isArray(schema.required) ? schema.required : []);
43545
43684
  normalized = Object.fromEntries(Object.entries(value).flatMap(([key, child]) => {
43546
43685
  const childSchema = properties[key];
43547
- const next = isPlainRecord(childSchema) ? normalizeCardDataValue(childSchema, child, requiredKeys.has(key)) : child;
43686
+ const next = isPlainRecord(childSchema) ? normalizeCardDataNode(childSchema, child, requiredKeys.has(key), coerceOptionalScalars, coerce2) : child;
43548
43687
  return next === void 0 ? [] : [[key, next]];
43549
43688
  }));
43550
43689
  } else if (schema.type === "array" && Array.isArray(value) && isPlainRecord(schema.items)) {
43551
- normalized = value.map((child) => normalizeCardDataValue(schema.items, child));
43690
+ normalized = value.map((child) => normalizeCardDataNode(schema.items, child, true, coerceOptionalScalars, coerce2));
43552
43691
  }
43553
43692
  return !required && validateJsonSchemaValue2(schema, normalized).length > 0 ? void 0 : normalized;
43554
43693
  }
@@ -43691,7 +43830,7 @@ function validateValue(schema, value, path2, issues) {
43691
43830
  }
43692
43831
  if (schema.additionalProperties === false) {
43693
43832
  for (const key of Object.keys(value)) {
43694
- if (!(key in properties)) {
43833
+ if (!Object.prototype.hasOwnProperty.call(properties, key)) {
43695
43834
  issues.push(issue2(`${path2}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
43696
43835
  }
43697
43836
  }
@@ -43781,7 +43920,22 @@ function standardCardSurfaceSchemas(message) {
43781
43920
  }
43782
43921
  return new Map(Array.from(models, ([id2, model]) => [id2, inferJsonSchemaFromValue(model)]));
43783
43922
  }
43784
- function standardCardBindingModel(message) {
43923
+ function optionalStandardSchema(schema) {
43924
+ if (schema.type === "array" && schema.items) {
43925
+ return {
43926
+ ...schema,
43927
+ items: optionalStandardSchema(schema.items)
43928
+ };
43929
+ }
43930
+ if (schema.type !== "object" || !schema.properties)
43931
+ return schema;
43932
+ return {
43933
+ ...schema,
43934
+ required: [],
43935
+ properties: Object.fromEntries(Object.entries(schema.properties).map(([key, child]) => [key, optionalStandardSchema(child)]))
43936
+ };
43937
+ }
43938
+ function standardCardBindingModel(message, allowPartialModel = false) {
43785
43939
  const surfaces = standardCardSurfaceSchemas(message);
43786
43940
  const fields = [];
43787
43941
  for (const [surfaceId, schema2] of surfaces) {
@@ -43797,26 +43951,29 @@ function standardCardBindingModel(message) {
43797
43951
  path: path2,
43798
43952
  label: surfaces.size === 1 ? key : surfaceId + " / " + key,
43799
43953
  source: "business",
43800
- required: true,
43954
+ required: !allowPartialModel,
43801
43955
  type,
43802
- valueSchema
43956
+ valueSchema: allowPartialModel ? optionalStandardSchema(valueSchema) : valueSchema
43803
43957
  });
43804
43958
  }
43805
43959
  }
43806
43960
  const schema = {
43807
43961
  type: "object",
43808
- properties: Object.fromEntries(surfaces),
43809
- required: [...surfaces].filter(([, item]) => Object.keys(item.properties).length).map(([id2]) => id2),
43962
+ properties: Object.fromEntries([...surfaces].map(([id2, item]) => [
43963
+ id2,
43964
+ allowPartialModel ? optionalStandardSchema(item) : item
43965
+ ])),
43966
+ required: allowPartialModel ? [] : [...surfaces].filter(([, item]) => Object.keys(item.properties).length).map(([id2]) => id2),
43810
43967
  additionalProperties: false
43811
43968
  };
43812
43969
  return { fields, schema };
43813
43970
  }
43814
- function renderStandardCardData(message, data) {
43971
+ function renderStandardCardData(message, data, allowPartialModel = false) {
43815
43972
  const datas = message.datas.filter((instruction) => !("updateDataModel" in instruction));
43816
43973
  const updates = [];
43817
43974
  for (const [surfaceId, schema] of standardCardSurfaceSchemas(message)) {
43818
43975
  const value = data[surfaceId] ?? {};
43819
- const issues = validateJsonSchemaValue2(schema, value);
43976
+ const issues = validateJsonSchemaValue2(allowPartialModel ? optionalStandardSchema(schema) : schema, value);
43820
43977
  if (issues.length)
43821
43978
  throw new Error(`\u6807\u51C6\u5361\u6570\u636E\u4E0D\u5339\u914D\uFF1A${surfaceId} ${issues[0].path} ${issues[0].message}`);
43822
43979
  updates.push({ updateDataModel: { surfaceId, path: "/", value } });
@@ -45142,6 +45299,9 @@ function getA2UICardResourceConfigV3Issues(value, standard = false) {
45142
45299
  requiredString(value.whenToUse, "config.whenToUse", issues);
45143
45300
  optionalString(value.whenNotToUse, "config.whenNotToUse", issues);
45144
45301
  const fields = validateFields(value.fields, "config.fields", issues);
45302
+ if (value.schemaVersion === "4") {
45303
+ validateBindingOutputSchemas(value.bindingOutputSchemas, fields, "config.bindingOutputSchemas", issues);
45304
+ }
45145
45305
  if (fields?.some((field) => field.source === "invocation")) {
45146
45306
  issues.push(issue2("config.fields", "INVOCATION_FIELD_UNSUPPORTED", `schema v${String(value.schemaVersion)} does not support invocation fields`));
45147
45307
  }
@@ -45152,7 +45312,9 @@ function getA2UICardResourceConfigV3Issues(value, standard = false) {
45152
45312
  issues.push(...getA2UIV4ProtocolIssues(card, "config.a2uiTemplate.content"));
45153
45313
  issues.push(...getPersistedV4ProtocolIssues(card, "config.a2uiTemplate.content"));
45154
45314
  }
45155
- if (fields && dataSources && bindings) {
45315
+ if (value.schemaVersion === "4" && value.dataMode === "model") {
45316
+ validateLooseJsonSchema(value.modelInputSchema, "config.modelInputSchema", issues);
45317
+ } else if (fields && dataSources && bindings) {
45156
45318
  validateV3Coverage(fields, dataSources, bindings, issues, { card });
45157
45319
  }
45158
45320
  return issues;
@@ -45720,6 +45882,21 @@ function validateTemplate(value, fields, issues) {
45720
45882
  }
45721
45883
  return void 0;
45722
45884
  }
45885
+ function validateBindingOutputSchemas(value, fields, path2, issues) {
45886
+ if (value === void 0)
45887
+ return;
45888
+ if (!isPlainRecord(value)) {
45889
+ issues.push(issue2(path2, "INVALID_BINDING_OUTPUT_SCHEMA", "Expected a field schema map"));
45890
+ return;
45891
+ }
45892
+ for (const [fieldId, schema] of Object.entries(value)) {
45893
+ if (!fields?.some((field) => field.fieldId === fieldId && field.source === "business")) {
45894
+ issues.push(issue2(path2, "INVALID_BINDING_OUTPUT_SCHEMA", `Unknown business field ${fieldId}`));
45895
+ continue;
45896
+ }
45897
+ validateLooseJsonSchema(schema, `${path2}.${fieldId}`, issues);
45898
+ }
45899
+ }
45723
45900
  function validateLooseJsonSchema(value, path2, issues) {
45724
45901
  const schemaIssues = getJsonSchemaIssues2(value, path2, {
45725
45902
  allowMissingType: true
@@ -45846,6 +46023,11 @@ async function executeA2UICardResolver(input) {
45846
46023
  }
45847
46024
  throw error;
45848
46025
  }
46026
+ if (input.projectOutput && isJsonValue(value)) {
46027
+ const projections = input.bindingOutputSchemas;
46028
+ const projection = projections && Object.prototype.hasOwnProperty.call(projections, field.fieldId) ? projections[field.fieldId] : field.valueSchema;
46029
+ value = normalizeCardDataValue(field.valueSchema, projectCardData(projection, value), field.required, false);
46030
+ }
45849
46031
  value = normalizeOptionalNulls(value, field.valueSchema, field.required);
45850
46032
  if (value !== void 0) {
45851
46033
  assertSchemaValue(field.valueSchema, value, "CARD_MAPPING_SCHEMA_MISMATCH", `mapping result for ${binding.fieldId}`, binding.fieldId);
@@ -46315,6 +46497,8 @@ async function executeCardPresentationFromSources(resource, runtimeContext, sour
46315
46497
  try {
46316
46498
  viewModel = await executeA2UICardResolver({
46317
46499
  resolver,
46500
+ projectOutput: "allowPartialModel" in resource.config && resource.config.allowPartialModel === true,
46501
+ bindingOutputSchemas: config.schemaVersion === "4" ? config.bindingOutputSchemas : void 0,
46318
46502
  fields: config.fields,
46319
46503
  presentationInputSchema: {
46320
46504
  type: "object",
@@ -46358,7 +46542,7 @@ async function createPresentationResult(resource, config, viewModel, cardProvide
46358
46542
  const standardCard = "format" in resource.config && resource.config.format === "alipay-a2ui";
46359
46543
  const payload = standardCard ? {
46360
46544
  format: "alipay-a2ui",
46361
- protocol: renderStandardCardData(JSON.parse(content), viewModel)
46545
+ protocol: renderStandardCardData(JSON.parse(content), viewModel, "allowPartialModel" in resource.config && resource.config.allowPartialModel === true)
46362
46546
  } : {
46363
46547
  protocol: injectResolvedViewModel(JSON.parse(content), viewModel)
46364
46548
  };
@@ -46389,24 +46573,38 @@ async function createPresentationResult(resource, config, viewModel, cardProvide
46389
46573
  }
46390
46574
  };
46391
46575
  }
46576
+ var PRESENTATION_RECEIPT_MODEL_GUIDANCE = "\u5361\u7247\u5DF2\u53D1\u51FA\uFF08\u4E0D\u4EE3\u8868\u5BA2\u6237\u7AEF\u5DF2\u6E32\u67D3\uFF09\u3002\u8BED\u4E49\u5FEB\u7167\u6765\u81EA\u6388\u6743\u7684\u6700\u7EC8\u5361\u7247\u6570\u636E\uFF1Bcolumns \u4E0E rows \u6309\u4F4D\u7F6E\u5BF9\u5E94\uFF0Cnull \u8868\u793A\u7F3A\u5931\u6216\u7A7A\u503C\uFF0Ccomplete=false \u65F6\u4E0D\u5F97\u628A\u91C7\u6837\u5F53\u4F5C\u5168\u96C6\u3002\u4E0D\u8981\u7528 Markdown \u91CD\u590D\u5217\u51FA\u6216\u6539\u5199\u5361\u7247\u4E2D\u7684\u6761\u76EE\uFF1B\u53EA\u8865\u5145\u7528\u6237\u5C1A\u672A\u5F97\u5230\u7684\u6BD4\u8F83\u3001\u89E3\u91CA\u6216\u5FC5\u8981\u8FFD\u95EE\uFF0C\u7528\u6237\u660E\u786E\u8981\u6C42\u6587\u5B57\u8868\u683C\u65F6\u53EF\u4EE5\u63D0\u4F9B\u3002\u5FEB\u7167\u672A\u5305\u542B\u7684\u4FE1\u606F\u4FDD\u6301\u672A\u77E5\uFF0C\u6E90\u5DE5\u5177\u7684\u989D\u5916\u4FE1\u606F\u4E0D\u80FD\u79F0\u4E3A\u5361\u7247\u5DF2\u5C55\u793A\u5185\u5BB9\u3002";
46392
46577
  function formatPresentationReceiptForModel(receipt) {
46393
46578
  return [
46394
46579
  "<a2ui-presentation-receipt>",
46395
46580
  JSON.stringify(projectPresentationReceiptForModel(receipt)),
46396
46581
  "</a2ui-presentation-receipt>",
46397
- "\u5361\u7247\u5DF2\u53D1\u51FA\uFF08\u4E0D\u4EE3\u8868\u5BA2\u6237\u7AEF\u5DF2\u6E32\u67D3\uFF09\u3002\u8BED\u4E49\u5FEB\u7167\u6765\u81EA\u6388\u6743\u7684\u6700\u7EC8\u5361\u7247\u6570\u636E\uFF1Bcolumns \u4E0E rows \u6309\u4F4D\u7F6E\u5BF9\u5E94\uFF0Cnull \u8868\u793A\u7F3A\u5931\u6216\u7A7A\u503C\uFF0Ccomplete=false \u65F6\u4E0D\u5F97\u628A\u91C7\u6837\u5F53\u4F5C\u5168\u96C6\u3002\u4E0D\u8981\u7528 Markdown \u91CD\u590D\u5217\u51FA\u6216\u6539\u5199\u5361\u7247\u4E2D\u7684\u6761\u76EE\uFF1B\u53EA\u8865\u5145\u7528\u6237\u5C1A\u672A\u5F97\u5230\u7684\u6BD4\u8F83\u3001\u89E3\u91CA\u6216\u5FC5\u8981\u8FFD\u95EE\uFF0C\u7528\u6237\u660E\u786E\u8981\u6C42\u6587\u5B57\u8868\u683C\u65F6\u53EF\u4EE5\u63D0\u4F9B\u3002\u5FEB\u7167\u672A\u5305\u542B\u7684\u4FE1\u606F\u4FDD\u6301\u672A\u77E5\uFF0C\u6E90\u5DE5\u5177\u7684\u989D\u5916\u4FE1\u606F\u4E0D\u80FD\u79F0\u4E3A\u5361\u7247\u5DF2\u5C55\u793A\u5185\u5BB9\u3002"
46582
+ PRESENTATION_RECEIPT_MODEL_GUIDANCE
46398
46583
  ].join("\n");
46399
46584
  }
46400
46585
  function projectPresentationReceiptForModel(receipt) {
46401
- if (!receipt.semanticSnapshot)
46402
- return receipt;
46586
+ if (!receipt.semanticSnapshot) {
46587
+ return {
46588
+ version: receipt.version,
46589
+ cardRef: receipt.cardRef,
46590
+ cardRevision: receipt.cardRevision,
46591
+ cardInstanceId: receipt.cardInstanceId,
46592
+ status: receipt.status,
46593
+ responsePolicy: receipt.responsePolicy,
46594
+ coverage: receipt.coverage,
46595
+ entities: receipt.entities,
46596
+ omissions: receipt.omissions,
46597
+ ...receipt.source ? { source: receipt.source } : {}
46598
+ };
46599
+ }
46403
46600
  return {
46404
46601
  version: receipt.version,
46405
46602
  cardRef: receipt.cardRef,
46406
46603
  cardRevision: receipt.cardRevision,
46407
46604
  cardInstanceId: receipt.cardInstanceId,
46408
46605
  status: receipt.status,
46409
- semanticSnapshot: receipt.semanticSnapshot
46606
+ semanticSnapshot: receipt.semanticSnapshot,
46607
+ ...receipt.source ? { source: receipt.source } : {}
46410
46608
  };
46411
46609
  }
46412
46610
  function parseCardConfig(resource) {
@@ -46428,10 +46626,11 @@ function parseCardConfig(resource) {
46428
46626
  async function resolveStandardCardExecution(resource, config, provider, signal) {
46429
46627
  if (!("format" in resource.config) || resource.config.format !== "alipay-a2ui")
46430
46628
  return config;
46431
- if (!provider)
46629
+ const inline = "protocol" in resource.config ? resource.config.protocol : void 0;
46630
+ if (!inline && !provider)
46432
46631
  throw new Error("\u6807\u51C6\u5361\u7F3A\u5C11\u7ED3\u6784\u8BFB\u53D6\u670D\u52A1");
46433
- const content = await provider.loadDefinition(resource.resourceId, signal);
46434
- const { fields, schema } = standardCardBindingModel(JSON.parse(content));
46632
+ const content = inline ? JSON.stringify(inline) : await provider.loadDefinition(resource.resourceId, signal);
46633
+ const { fields, schema } = standardCardBindingModel(JSON.parse(content), resource.config.allowPartialModel === true);
46435
46634
  const issues = getStandardCardExecutionIssues({
46436
46635
  ...resource.config,
46437
46636
  fields,
@@ -46440,15 +46639,30 @@ async function resolveStandardCardExecution(resource, config, provider, signal)
46440
46639
  if (issues.length)
46441
46640
  throw new Error(issues.map((issue3) => issue3.message).join("\uFF1B"));
46442
46641
  const a2uiTemplate = { content, argsSchema: schema };
46642
+ const projections = resource.config.bindingOutputSchemas;
46643
+ const bindingFields = projections ? fields.map((field) => ({
46644
+ ...field,
46645
+ valueSchema: projections[field.fieldId] ?? field.valueSchema
46646
+ })) : fields;
46443
46647
  if (config.schemaVersion === "4" && config.dataMode === "pipeline")
46444
46648
  return { ...config, fields, a2uiTemplate, dataModelSchema: schema };
46445
- return { ...config, fields, a2uiTemplate };
46649
+ return { ...config, fields: bindingFields, a2uiTemplate };
46446
46650
  }
46447
46651
  function isAgentPresentationToolResult(value) {
46448
46652
  if (!isJsonObject(value))
46449
46653
  return false;
46450
46654
  return value.type === "linkque.presentation-tool-result" && typeof value.modelText === "string" && isJsonObject(value.card) && value.card.type === "a2ui_card";
46451
46655
  }
46656
+ function isAgentToolResult(value) {
46657
+ return isJsonObject(value) && value.type === "linkque.tool-result" && typeof value.modelText === "string";
46658
+ }
46659
+ function readToolPresentationReceipts(value) {
46660
+ if (isAgentPresentationToolResult(value))
46661
+ return value.receipt ? [value.receipt] : [];
46662
+ if (isAgentToolResult(value) && Array.isArray(value.presentationReceipts))
46663
+ return value.presentationReceipts;
46664
+ return [];
46665
+ }
46452
46666
  function isAgentPresentationSkippedToolResult(value) {
46453
46667
  if (!isJsonObject(value) || !isJsonObject(value.receipt))
46454
46668
  return false;
@@ -49000,7 +49214,8 @@ var PREPARE_PATCH_KEYS = /* @__PURE__ */ new Set([
49000
49214
  "systemPromptSuffixes",
49001
49215
  "additionalTools",
49002
49216
  "modelTurns",
49003
- "modelHistoryMessageCount"
49217
+ "modelHistoryMessageCount",
49218
+ "inputExecution"
49004
49219
  ]);
49005
49220
  function validateRuntimePatchEnvelope(value, stage, hookName) {
49006
49221
  if (!isObject2(value) || Array.isArray(value)) {
@@ -49065,7 +49280,7 @@ function isRuntimePatchTurn(value) {
49065
49280
  }
49066
49281
  if (!Object.hasOwn(value, "content"))
49067
49282
  return false;
49068
- if (value.id && typeof value.id !== "string") {
49283
+ if (value.id !== void 0 && typeof value.id !== "string") {
49069
49284
  return false;
49070
49285
  }
49071
49286
  if (value.name !== void 0 && typeof value.name !== "string") {
@@ -49110,6 +49325,17 @@ function normalizeRuntimePatch(value, stage, hookName) {
49110
49325
  throw new Error(`\u72B6\u6001\u578B Hook ${hookName} \u7684 Runtime Patch \u6A21\u578B\u5386\u53F2\u5206\u754C\u975E\u6CD5`);
49111
49326
  }
49112
49327
  const result = { stage: EHookStage.PREPARE_AGENT_LOOP };
49328
+ const execution = patch.inputExecution;
49329
+ if (execution !== void 0) {
49330
+ if (!isObject2(execution) || !isNonBlankString(execution.toolCallId) || !isRuntimePatchTool(execution.tool) || !isRuntimePatchTurn(execution.userTurn) || execution.userTurn.role !== "user") {
49331
+ throw new Error(`\u72B6\u6001\u578B Hook ${hookName} \u7684\u8F93\u5165\u64CD\u4F5C\u975E\u6CD5`);
49332
+ }
49333
+ result.inputExecution = {
49334
+ toolCallId: execution.toolCallId,
49335
+ tool: { ...execution.tool },
49336
+ userTurn: structuredClone(execution.userTurn)
49337
+ };
49338
+ }
49113
49339
  if (modelTurns) {
49114
49340
  result.modelTurns = structuredClone(modelTurns);
49115
49341
  result.modelHistoryMessageCount = historyCount;
@@ -49927,6 +50153,7 @@ var RUNTIME_CONFIG_DEFAULTS = Object.freeze({
49927
50153
  LINKQUEGW_WEB_SEARCH_BASE_URL: LINKQUE_ENDPOINT_PROD,
49928
50154
  LINKQUEGW_EVENT_BASE_URL: LINKQUE_ENDPOINT_PROD,
49929
50155
  LINKQUEGW_MCP_SIGN_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/mcp/signature`,
50156
+ LINKQUEGW_A2A_SIGN_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/a2a/signature`,
49930
50157
  LINKQUEGW_TOKEN_VERIFY_ENDPOINT: `${LINKQUE_ENDPOINT_PROD}/api/auth/verify`
49931
50158
  });
49932
50159
  var RuntimeConfigProvider = class {
@@ -50907,6 +51134,15 @@ var EMemorySummaryStatus;
50907
51134
  EMemorySummaryStatus2["CANCELLED"] = "cancelled";
50908
51135
  })(EMemorySummaryStatus || (EMemorySummaryStatus = {}));
50909
51136
 
51137
+ // ../linkque-agent-runtime/dist/esm/core/appendAgentTurns.js
51138
+ async function appendAgentTurns(sessionManager, sessionId, turns) {
51139
+ if (sessionManager.appendMany)
51140
+ await sessionManager.appendMany(sessionId, turns);
51141
+ else
51142
+ for (const turn of turns)
51143
+ await sessionManager.append(sessionId, turn);
51144
+ }
51145
+
50910
51146
  // ../linkque-agent-runtime/dist/esm/impl/scenario/gatewayRunAuthorization.js
50911
51147
  import { hkdfSync, randomBytes } from "node:crypto";
50912
51148
 
@@ -58293,7 +58529,8 @@ function mapAgentEventToBaseEvents(event, messageId, thinkingId) {
58293
58529
  {
58294
58530
  type: EventType.TEXT_MESSAGE_CONTENT,
58295
58531
  messageId,
58296
- delta: event.content
58532
+ delta: event.content,
58533
+ ...event.metadata ? { metadata: event.metadata } : {}
58297
58534
  }
58298
58535
  ];
58299
58536
  }
@@ -58329,7 +58566,8 @@ function mapAgentEventToBaseEvents(event, messageId, thinkingId) {
58329
58566
  toolCallId: event.toolCallId,
58330
58567
  messageId: event.messageId,
58331
58568
  role: "tool",
58332
- content: event.content
58569
+ content: event.content,
58570
+ ...event.metadata ? { metadata: event.metadata } : {}
58333
58571
  }
58334
58572
  ];
58335
58573
  }
@@ -58347,9 +58585,15 @@ function mapAgentEventToBaseEvents(event, messageId, thinkingId) {
58347
58585
  }
58348
58586
  case "client_capability_request": {
58349
58587
  return [
58350
- createConversationCustomEvent(CONVERSATION_CUSTOM_EVENT_NAMES.clientCapabilityRequest, event.value)
58588
+ {
58589
+ ...createConversationCustomEvent(CONVERSATION_CUSTOM_EVENT_NAMES.clientCapabilityRequest, event.value),
58590
+ ...event.metadata ? { metadata: event.metadata } : {}
58591
+ }
58351
58592
  ];
58352
58593
  }
58594
+ case "custom": {
58595
+ return [{ type: EventType.CUSTOM, name: event.name, value: event.value }];
58596
+ }
58353
58597
  case "done":
58354
58598
  case "authorization_pause":
58355
58599
  case "error":
@@ -58458,12 +58702,17 @@ async function* streamToConversationEvents(events, ctx, options = {}) {
58458
58702
  }
58459
58703
  }
58460
58704
  if (ev.type === "delta") {
58705
+ if (activeMessageId !== void 0 && ev.messageId !== void 0 && ev.messageId !== activeMessageId) {
58706
+ yield emitAgui(emitTextEnd(activeMessageId), void 0, messageSource);
58707
+ activeMessageId = void 0;
58708
+ }
58461
58709
  if (activeMessageId === void 0) {
58462
- activeMessageId = generateId();
58710
+ activeMessageId = ev.messageId ?? generateId();
58463
58711
  yield emitAgui({
58464
58712
  type: EventType.TEXT_MESSAGE_START,
58465
58713
  messageId: activeMessageId,
58466
- role: "assistant"
58714
+ role: "assistant",
58715
+ ...ev.metadata ? { metadata: ev.metadata } : {}
58467
58716
  }, void 0);
58468
58717
  }
58469
58718
  } else if (ev.type !== "thinking") {
@@ -59487,6 +59736,7 @@ export {
59487
59736
  readJsonPointer,
59488
59737
  writeJsonPointer,
59489
59738
  validateJsonSchemaValue2 as validateJsonSchemaValue,
59739
+ projectCardData,
59490
59740
  normalizeCardDataValue,
59491
59741
  createA2UICardPipelineModelInputSchema,
59492
59742
  executeA2UICardResolver,
@@ -59496,10 +59746,13 @@ export {
59496
59746
  executeCardPresentation,
59497
59747
  executeCardPresentationFromSources,
59498
59748
  createPresentationResult,
59749
+ PRESENTATION_RECEIPT_MODEL_GUIDANCE,
59499
59750
  projectPresentationReceiptForModel,
59500
59751
  parseCardConfig,
59501
59752
  resolveStandardCardExecution,
59502
59753
  isAgentPresentationToolResult,
59754
+ isAgentToolResult,
59755
+ readToolPresentationReceipts,
59503
59756
  isAgentPresentationSkippedToolResult,
59504
59757
  CARD_SEQUENCE,
59505
59758
  bindingSequence,
@@ -59556,6 +59809,7 @@ export {
59556
59809
  AUTHORIZATION_CONFIRM_EVENT,
59557
59810
  AUTHORIZATION_DISMISS_EVENT,
59558
59811
  parseConfirmAuthorizationRequest,
59812
+ readAuthorizationChallenge,
59559
59813
  readAuthorizationPresentation,
59560
59814
  CANCEL_CONVERSATION_RUN_OPERATION,
59561
59815
  MARK_CONVERSATION_RUNS_READ_OPERATION,
@@ -59579,6 +59833,9 @@ export {
59579
59833
  parseConversationToolCallDisplayName,
59580
59834
  createConversationAGUIEvent,
59581
59835
  encodeConversationSseEvent,
59836
+ ApassAuthorizationRequiredError,
59837
+ apassChallenge,
59838
+ invokeApassAuthorization,
59582
59839
  confirmAuthorization,
59583
59840
  isAuthorizationPause,
59584
59841
  AuthorizationExecution,
@@ -59629,6 +59886,7 @@ export {
59629
59886
  InMemoryMemoryAdapter,
59630
59887
  EMemoryType,
59631
59888
  EMemorySummaryStatus,
59889
+ appendAgentTurns,
59632
59890
  SCENARIO_RUN_ERROR_CODES,
59633
59891
  normalizeScenarioRunErrorCode,
59634
59892
  authorizeAgentRun,