linkque-cli-v2 1.2.2 → 1.2.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/linkquejs.js CHANGED
@@ -26464,7 +26464,9 @@ var A2UI_PAYMENT_ACTION_NAME = "payment.trade-pay";
26464
26464
  var A2UI_PAYMENT_CALLBACK_MAX_BYTES = 16 * 1024;
26465
26465
  function getA2UICardActionBindingIssues(value, path23 = "actionBindings") {
26466
26466
  if (!Array.isArray(value)) {
26467
- return [issue2(path23, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")];
26467
+ return [
26468
+ issue2(path23, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")
26469
+ ];
26468
26470
  }
26469
26471
  const issues = [];
26470
26472
  const actionIds = /* @__PURE__ */ new Set();
@@ -26524,7 +26526,13 @@ function validateToolBinding(value, path23, phase, issues) {
26524
26526
  issues.push(issue2(path23, "INVALID_PAYMENT_TOOL", `${path23} must be an object`));
26525
26527
  return;
26526
26528
  }
26527
- rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : ["mcpResourceId", "toolName", "inputBindings", "statusPath", "paidValues"], path23, issues);
26529
+ rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : [
26530
+ "mcpResourceId",
26531
+ "toolName",
26532
+ "inputBindings",
26533
+ "statusPath",
26534
+ "paidValues"
26535
+ ], path23, issues);
26528
26536
  if (!isSafeIdentifier(value.mcpResourceId)) {
26529
26537
  issues.push(issue2(`${path23}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
26530
26538
  }
@@ -26645,7 +26653,12 @@ function rejectExtraKeys(value, allowed, path23, issues) {
26645
26653
  function isJsonPrimitive(value) {
26646
26654
  return value === null || ["string", "number", "boolean"].includes(typeof value);
26647
26655
  }
26648
- var RUNTIME_CONTEXT_KEYS2 = /* @__PURE__ */ new Set(["agentId", "tenantId", "threadId", "userId"]);
26656
+ var RUNTIME_CONTEXT_KEYS2 = /* @__PURE__ */ new Set([
26657
+ "agentId",
26658
+ "tenantId",
26659
+ "threadId",
26660
+ "userId"
26661
+ ]);
26649
26662
 
26650
26663
  // ../agent-a2ui-card-contract/dist/esm/validation.js
26651
26664
  var FIELD_TYPES = [
@@ -27074,7 +27087,8 @@ function validateFields(value, path23, issues) {
27074
27087
  "valueSchema",
27075
27088
  "sourcePath",
27076
27089
  "runtimeContextKey",
27077
- "consistencyGroup"
27090
+ "consistencyGroup",
27091
+ "presentation"
27078
27092
  ], itemPath, issues);
27079
27093
  if (!isSafeIdentifier(candidate.fieldId)) {
27080
27094
  issues.push(issue2(`${itemPath}.fieldId`, "INVALID_FIELD_ID", "fieldId is invalid"));
@@ -27110,9 +27124,33 @@ function validateFields(value, path23, issues) {
27110
27124
  }
27111
27125
  validateFieldSource(candidate, itemPath, issues);
27112
27126
  optionalString(candidate.consistencyGroup, `${itemPath}.consistencyGroup`, issues);
27127
+ validateFieldPresentation(candidate.presentation, itemPath, issues);
27113
27128
  });
27114
27129
  return value;
27115
27130
  }
27131
+ function validateFieldPresentation(value, itemPath, issues) {
27132
+ if (value === void 0)
27133
+ return;
27134
+ const path23 = `${itemPath}.presentation`;
27135
+ if (!isPlainRecord(value)) {
27136
+ issues.push(issue2(path23, "INVALID_FIELD_PRESENTATION", `${path23} must be an object`));
27137
+ return;
27138
+ }
27139
+ if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
27140
+ issues.push(issue2(`${path23}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
27141
+ }
27142
+ if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
27143
+ issues.push(issue2(`${path23}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
27144
+ }
27145
+ if (value.attributePaths !== void 0) {
27146
+ if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
27147
+ issues.push(issue2(`${path23}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
27148
+ }
27149
+ }
27150
+ if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
27151
+ issues.push(issue2(`${path23}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
27152
+ }
27153
+ }
27116
27154
  function validateFieldSource(candidate, itemPath, issues) {
27117
27155
  if (candidate.source === "invocation") {
27118
27156
  if (!isSafeJsonPointer(candidate.sourcePath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkque-cli-v2",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Public Linkque CLI bundle for sandbox debugging",
5
5
  "bin": {
6
6
  "linkquejs": "linkquejs.js"
@@ -6997,7 +6997,7 @@ var require_jmespath = __commonJS({
6997
6997
  return false;
6998
6998
  }
6999
6999
  }
7000
- function isObject(obj) {
7000
+ function isObject2(obj) {
7001
7001
  if (obj !== null) {
7002
7002
  return Object.prototype.toString.call(obj) === "[object Object]";
7003
7003
  } else {
@@ -7023,7 +7023,7 @@ var require_jmespath = __commonJS({
7023
7023
  }
7024
7024
  return true;
7025
7025
  }
7026
- if (isObject(first) === true) {
7026
+ if (isObject2(first) === true) {
7027
7027
  var keysSeen = {};
7028
7028
  for (var key in first) {
7029
7029
  if (hasOwnProperty.call(first, key)) {
@@ -7049,7 +7049,7 @@ var require_jmespath = __commonJS({
7049
7049
  return true;
7050
7050
  } else if (isArray(obj) && obj.length === 0) {
7051
7051
  return true;
7052
- } else if (isObject(obj)) {
7052
+ } else if (isObject2(obj)) {
7053
7053
  for (var key in obj) {
7054
7054
  if (obj.hasOwnProperty(key)) {
7055
7055
  return false;
@@ -7766,7 +7766,7 @@ var require_jmespath = __commonJS({
7766
7766
  var matched, current, result, first, second, field, left, right, collected, i;
7767
7767
  switch (node.type) {
7768
7768
  case "Field":
7769
- if (value !== null && isObject(value)) {
7769
+ if (value !== null && isObject2(value)) {
7770
7770
  field = value[node.name];
7771
7771
  if (field === void 0) {
7772
7772
  return null;
@@ -7836,7 +7836,7 @@ var require_jmespath = __commonJS({
7836
7836
  return collected;
7837
7837
  case "ValueProjection":
7838
7838
  base = this.visit(node.children[0], value);
7839
- if (!isObject(base)) {
7839
+ if (!isObject2(base)) {
7840
7840
  return null;
7841
7841
  }
7842
7842
  collected = [];
@@ -8233,7 +8233,7 @@ var require_jmespath = __commonJS({
8233
8233
  return Math.floor(resolvedArgs[0]);
8234
8234
  },
8235
8235
  _functionLength: function(resolvedArgs) {
8236
- if (!isObject(resolvedArgs[0])) {
8236
+ if (!isObject2(resolvedArgs[0])) {
8237
8237
  return resolvedArgs[0].length;
8238
8238
  } else {
8239
8239
  return Object.keys(resolvedArgs[0]).length;
@@ -17458,7 +17458,15 @@ function getA2UIActionExecuteRequestIssues(value) {
17458
17458
  if (!isPlainRecord(value))
17459
17459
  return ["request must be an object"];
17460
17460
  const issues = [];
17461
- rejectExtraKeysAsStrings(value, ["schemaVersion", "agentId", "threadId", "invocationId", "actionId", "source", "actionContext"], "request", issues);
17461
+ rejectExtraKeysAsStrings(value, [
17462
+ "schemaVersion",
17463
+ "agentId",
17464
+ "threadId",
17465
+ "invocationId",
17466
+ "actionId",
17467
+ "source",
17468
+ "actionContext"
17469
+ ], "request", issues);
17462
17470
  if (value.schemaVersion !== "1")
17463
17471
  issues.push("schemaVersion must be 1");
17464
17472
  requiredIdentifier(value.agentId, "agentId", issues);
@@ -17473,7 +17481,9 @@ function getA2UIActionExecuteRequestIssues(value) {
17473
17481
  }
17474
17482
  function parseA2UIPaymentResultEventPayload(value) {
17475
17483
  if (!isPlainRecord(value)) {
17476
- throw new A2UIActionContractError(["payment result payload must be an object"]);
17484
+ throw new A2UIActionContractError([
17485
+ "payment result payload must be an object"
17486
+ ]);
17477
17487
  }
17478
17488
  const issues = [];
17479
17489
  rejectExtraKeysAsStrings(value, ["actionId", "actionInvocationId", "tradeNO", "actionContext", "callback"], "payment result payload", issues);
@@ -17497,7 +17507,9 @@ function parseA2UIPaymentResultEventPayload(value) {
17497
17507
  }
17498
17508
  function getA2UICardActionBindingIssues(value, path2 = "actionBindings") {
17499
17509
  if (!Array.isArray(value)) {
17500
- return [issue2(path2, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")];
17510
+ return [
17511
+ issue2(path2, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")
17512
+ ];
17501
17513
  }
17502
17514
  const issues = [];
17503
17515
  const actionIds = /* @__PURE__ */ new Set();
@@ -17557,7 +17569,13 @@ function validateToolBinding(value, path2, phase, issues) {
17557
17569
  issues.push(issue2(path2, "INVALID_PAYMENT_TOOL", `${path2} must be an object`));
17558
17570
  return;
17559
17571
  }
17560
- rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : ["mcpResourceId", "toolName", "inputBindings", "statusPath", "paidValues"], path2, issues);
17572
+ rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : [
17573
+ "mcpResourceId",
17574
+ "toolName",
17575
+ "inputBindings",
17576
+ "statusPath",
17577
+ "paidValues"
17578
+ ], path2, issues);
17561
17579
  if (!isSafeIdentifier(value.mcpResourceId)) {
17562
17580
  issues.push(issue2(`${path2}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
17563
17581
  }
@@ -17706,7 +17724,12 @@ function requiredText(value, path2, issues) {
17706
17724
  function isJsonPrimitive(value) {
17707
17725
  return value === null || ["string", "number", "boolean"].includes(typeof value);
17708
17726
  }
17709
- var RUNTIME_CONTEXT_KEYS = /* @__PURE__ */ new Set(["agentId", "tenantId", "threadId", "userId"]);
17727
+ var RUNTIME_CONTEXT_KEYS = /* @__PURE__ */ new Set([
17728
+ "agentId",
17729
+ "tenantId",
17730
+ "threadId",
17731
+ "userId"
17732
+ ]);
17710
17733
 
17711
17734
  // ../agent-a2ui-card-contract/dist/esm/validation.js
17712
17735
  var FIELD_TYPES = [
@@ -17964,7 +17987,8 @@ function validateFields(value, path2, issues) {
17964
17987
  "valueSchema",
17965
17988
  "sourcePath",
17966
17989
  "runtimeContextKey",
17967
- "consistencyGroup"
17990
+ "consistencyGroup",
17991
+ "presentation"
17968
17992
  ], itemPath, issues);
17969
17993
  if (!isSafeIdentifier(candidate.fieldId)) {
17970
17994
  issues.push(issue2(`${itemPath}.fieldId`, "INVALID_FIELD_ID", "fieldId is invalid"));
@@ -18000,9 +18024,33 @@ function validateFields(value, path2, issues) {
18000
18024
  }
18001
18025
  validateFieldSource(candidate, itemPath, issues);
18002
18026
  optionalString(candidate.consistencyGroup, `${itemPath}.consistencyGroup`, issues);
18027
+ validateFieldPresentation(candidate.presentation, itemPath, issues);
18003
18028
  });
18004
18029
  return value;
18005
18030
  }
18031
+ function validateFieldPresentation(value, itemPath, issues) {
18032
+ if (value === void 0)
18033
+ return;
18034
+ const path2 = `${itemPath}.presentation`;
18035
+ if (!isPlainRecord(value)) {
18036
+ issues.push(issue2(path2, "INVALID_FIELD_PRESENTATION", `${path2} must be an object`));
18037
+ return;
18038
+ }
18039
+ if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
18040
+ issues.push(issue2(`${path2}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
18041
+ }
18042
+ if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
18043
+ issues.push(issue2(`${path2}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
18044
+ }
18045
+ if (value.attributePaths !== void 0) {
18046
+ if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
18047
+ issues.push(issue2(`${path2}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
18048
+ }
18049
+ }
18050
+ if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
18051
+ issues.push(issue2(`${path2}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
18052
+ }
18053
+ }
18006
18054
  function validateFieldSource(candidate, itemPath, issues) {
18007
18055
  if (candidate.source === "invocation") {
18008
18056
  if (!isSafeJsonPointer(candidate.sourcePath)) {
@@ -18473,6 +18521,122 @@ function valueType2(value) {
18473
18521
  return typeof value === "object" ? "object" : typeof value;
18474
18522
  }
18475
18523
 
18524
+ // ../agent-a2ui-card-contract/dist/esm/presentation.js
18525
+ var MAX_FIELDS = 32;
18526
+ var MAX_ENTITIES = 10;
18527
+ var DEFAULT_FIELD_ITEMS = 3;
18528
+ var MAX_FIELD_ITEMS = 10;
18529
+ var MAX_ATTRIBUTES = 3;
18530
+ var MAX_TEXT_LENGTH = 160;
18531
+ function createA2UICardPresentationReceiptContent(fields, viewModel) {
18532
+ const coverage = [];
18533
+ const entities = [];
18534
+ const omissions = [];
18535
+ for (const field of fields.slice(0, MAX_FIELDS)) {
18536
+ const policy = field.presentation;
18537
+ if (policy?.visibility === "never") {
18538
+ omissions.push({ fieldId: field.fieldId, reason: "policy" });
18539
+ continue;
18540
+ }
18541
+ const value = readJsonPointer(viewModel, field.path);
18542
+ coverage.push({
18543
+ fieldId: field.fieldId,
18544
+ label: truncateText(field.label).value,
18545
+ present: value !== void 0,
18546
+ valueType: field.type,
18547
+ ...Array.isArray(value) && { itemCount: value.length }
18548
+ });
18549
+ if (!policy || value === void 0)
18550
+ continue;
18551
+ const isCollection = Array.isArray(value);
18552
+ const values = isCollection ? value : [value];
18553
+ const remainingBudget = MAX_ENTITIES - entities.length;
18554
+ const fieldBudget = Math.min(policy.maxItems ?? DEFAULT_FIELD_ITEMS, MAX_FIELD_ITEMS, remainingBudget);
18555
+ const selected = values.slice(0, Math.max(0, fieldBudget));
18556
+ for (const [index2, candidate] of selected.entries()) {
18557
+ const entity = createEntity(field, candidate, index2, isCollection, policy.visibility);
18558
+ if (entity)
18559
+ entities.push(entity);
18560
+ else
18561
+ omissions.push({ fieldId: field.fieldId, reason: "unsupported-value" });
18562
+ }
18563
+ if (values.length > selected.length) {
18564
+ omissions.push({
18565
+ fieldId: field.fieldId,
18566
+ reason: "budget",
18567
+ omittedCount: values.length - selected.length
18568
+ });
18569
+ }
18570
+ }
18571
+ if (fields.length > MAX_FIELDS) {
18572
+ omissions.push({
18573
+ fieldId: "*",
18574
+ reason: "budget",
18575
+ omittedCount: fields.length - MAX_FIELDS
18576
+ });
18577
+ }
18578
+ return { coverage, entities, omissions };
18579
+ }
18580
+ function createEntity(field, value, index2, isCollection, visibility) {
18581
+ const ref = `${field.fieldId}:${index2 + 1}`;
18582
+ if (visibility === "reference-only") {
18583
+ return {
18584
+ ref,
18585
+ fieldId: field.fieldId,
18586
+ ...isCollection && { ordinal: index2 + 1 },
18587
+ label: isCollection ? `${field.label} ${index2 + 1}` : field.label
18588
+ };
18589
+ }
18590
+ if (isPrimitive(value)) {
18591
+ const normalized = normalizePrimitive(value);
18592
+ return {
18593
+ ref,
18594
+ fieldId: field.fieldId,
18595
+ label: field.label,
18596
+ value: normalized.value,
18597
+ ...normalized.truncated && { truncated: true }
18598
+ };
18599
+ }
18600
+ if (!isObject(value))
18601
+ return void 0;
18602
+ const rawLabel = field.presentation?.labelPath ? readJsonPointer(value, field.presentation.labelPath) : void 0;
18603
+ const normalizedLabel = isPrimitive(rawLabel) ? truncateText(String(rawLabel)) : truncateText(`${field.label} ${index2 + 1}`);
18604
+ const attributes = {};
18605
+ let truncated = normalizedLabel.truncated;
18606
+ for (const path2 of (field.presentation?.attributePaths ?? []).slice(0, MAX_ATTRIBUTES)) {
18607
+ const attribute = readJsonPointer(value, path2);
18608
+ if (!isPrimitive(attribute))
18609
+ continue;
18610
+ const normalized = normalizePrimitive(attribute);
18611
+ attributes[path2] = normalized.value;
18612
+ truncated || (truncated = normalized.truncated);
18613
+ }
18614
+ return {
18615
+ ref,
18616
+ fieldId: field.fieldId,
18617
+ ...isCollection && { ordinal: index2 + 1 },
18618
+ label: normalizedLabel.value,
18619
+ ...Object.keys(attributes).length > 0 && { attributes },
18620
+ ...truncated && { truncated: true }
18621
+ };
18622
+ }
18623
+ function isObject(value) {
18624
+ return value !== null && typeof value === "object" && !Array.isArray(value);
18625
+ }
18626
+ function isPrimitive(value) {
18627
+ return value === null || ["string", "number", "boolean"].includes(typeof value);
18628
+ }
18629
+ function normalizePrimitive(value) {
18630
+ if (typeof value !== "string")
18631
+ return { value, truncated: false };
18632
+ return truncateText(value);
18633
+ }
18634
+ function truncateText(value) {
18635
+ if (value.length <= MAX_TEXT_LENGTH)
18636
+ return { value, truncated: false };
18637
+ return { value: `${value.slice(0, MAX_TEXT_LENGTH - 1)}\u2026`, truncated: true };
18638
+ }
18639
+
18476
18640
  // ../linkque-agent-runtime/dist/esm/core/mcpNaming.js
18477
18641
  import { createHash } from "node:crypto";
18478
18642
  function stableToolName(prefix, raw) {
@@ -18482,7 +18646,6 @@ function stableToolName(prefix, raw) {
18482
18646
  }
18483
18647
 
18484
18648
  // ../linkque-agent-runtime/dist/esm/core/cardTools.js
18485
- var PRESENTATION_RESULT_TEXT = "\u5361\u7247\u5DF2\u5C55\u793A\u3002";
18486
18649
  var FALLBACK_OBJECT_SCHEMA = {
18487
18650
  type: "object",
18488
18651
  additionalProperties: true
@@ -18526,22 +18689,7 @@ async function executeCardPresentation(resource, registry, runtimeContext, args,
18526
18689
  })),
18527
18690
  signal
18528
18691
  });
18529
- const protocol = injectResolvedViewModel(JSON.parse(config.a2uiTemplate.content), viewModel);
18530
- const cardInstanceId = `card-instance-${randomUUID()}`;
18531
- return {
18532
- type: "linkque.presentation-tool-result",
18533
- modelText: PRESENTATION_RESULT_TEXT,
18534
- card: {
18535
- type: "a2ui_card",
18536
- itemId: cardInstanceId,
18537
- payload: { protocol },
18538
- metadata: {
18539
- cardRef: resource.resourceId,
18540
- cardRevision: config.revision,
18541
- cardInstanceId
18542
- }
18543
- }
18544
- };
18692
+ return createPresentationResult(resource, config, viewModel);
18545
18693
  }
18546
18694
  async function executeCardPresentationFromSources(resource, runtimeContext, sourceResults, signal) {
18547
18695
  const config = parseCardConfig(resource);
@@ -18611,9 +18759,19 @@ async function executeCardPresentationFromSources(resource, runtimeContext, sour
18611
18759
  function createPresentationResult(resource, config, viewModel) {
18612
18760
  const protocol = injectResolvedViewModel(JSON.parse(config.a2uiTemplate.content), viewModel);
18613
18761
  const cardInstanceId = `card-instance-${randomUUID()}`;
18762
+ const receipt = {
18763
+ version: 1,
18764
+ cardRef: resource.resourceId,
18765
+ cardRevision: config.revision,
18766
+ cardInstanceId,
18767
+ status: "emitted",
18768
+ ...createA2UICardPresentationReceiptContent(config.fields, viewModel),
18769
+ responsePolicy: { verbatimEcho: "forbidden", hint: "acknowledge" }
18770
+ };
18614
18771
  return {
18615
18772
  type: "linkque.presentation-tool-result",
18616
- modelText: PRESENTATION_RESULT_TEXT,
18773
+ modelText: formatPresentationReceiptForModel(receipt),
18774
+ receipt,
18617
18775
  card: {
18618
18776
  type: "a2ui_card",
18619
18777
  itemId: cardInstanceId,
@@ -18626,6 +18784,14 @@ function createPresentationResult(resource, config, viewModel) {
18626
18784
  }
18627
18785
  };
18628
18786
  }
18787
+ function formatPresentationReceiptForModel(receipt) {
18788
+ return [
18789
+ "<a2ui-presentation-receipt>",
18790
+ JSON.stringify(receipt),
18791
+ "</a2ui-presentation-receipt>",
18792
+ "The card above already presents these results. Do not repeat or restate its items as Markdown. Reply only with a brief acknowledgement or information not already presented by the card."
18793
+ ].join("\n");
18794
+ }
18629
18795
  function parseCardConfig(resource) {
18630
18796
  const parsed = parseA2UICardResourceConfig(resource.config);
18631
18797
  if (!parsed.success) {
@@ -53631,6 +53797,7 @@ var AgentRuntime = class _AgentRuntime {
53631
53797
  await hookDispatcher.dispatch(EHookStage.RUN_STARTED, hookCommonParams);
53632
53798
  }
53633
53799
  let assistantText = "";
53800
+ const presentationReceipts = [];
53634
53801
  let failed = false;
53635
53802
  let runError;
53636
53803
  let terminalHookDispatched = false;
@@ -53653,6 +53820,12 @@ var AgentRuntime = class _AgentRuntime {
53653
53820
  for await (const ev of this.agentLoop.run(agentReq)) {
53654
53821
  if (ev.type === "delta")
53655
53822
  assistantText += ev.content;
53823
+ if (ev.type === "tool_end" && !ev.isError) {
53824
+ const details = ev.result && typeof ev.result === "object" && "details" in ev.result ? ev.result.details : void 0;
53825
+ if (isAgentPresentationToolResult(details) && details.receipt && !presentationReceipts.some((receipt) => receipt.cardInstanceId === details.receipt?.cardInstanceId)) {
53826
+ presentationReceipts.push(details.receipt);
53827
+ }
53828
+ }
53656
53829
  if (ev.type === "error") {
53657
53830
  failed = true;
53658
53831
  runError = { message: ev.error.message, code: ev.error.code };
@@ -53661,6 +53834,11 @@ var AgentRuntime = class _AgentRuntime {
53661
53834
  if (ev.type === "done" && !failed && sessionId !== void 0) {
53662
53835
  const completedTurns = [
53663
53836
  ...newTurns,
53837
+ ...presentationReceipts.map((receipt) => ({
53838
+ role: "tool",
53839
+ name: "a2ui_presentation_receipt",
53840
+ content: { type: "a2ui.presentation-receipt", receipt }
53841
+ })),
53664
53842
  { role: "assistant", content: assistantText }
53665
53843
  ];
53666
53844
  if (this.sessionManager.appendMany) {
@@ -65,7 +65,7 @@ import {
65
65
  parseSkillFile,
66
66
  streamToConversationEvents,
67
67
  verifyPaymentResult
68
- } from "../../chunk-7YMZ4CJ5.js";
68
+ } from "../../chunk-RRQKGME5.js";
69
69
  import "../../chunk-XUFLSZM4.js";
70
70
  import "../../chunk-I64V3ICJ.js";
71
71
  import "../../chunk-6MHDOBWO.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getBakedProtocol,
3
3
  setBakedProtocol
4
- } from "../chunk-7YMZ4CJ5.js";
4
+ } from "../chunk-RRQKGME5.js";
5
5
  import "../chunk-XUFLSZM4.js";
6
6
  import "../chunk-I64V3ICJ.js";
7
7
  import "../chunk-6MHDOBWO.js";
package/worker.js CHANGED
@@ -12059,7 +12059,7 @@ var require_jmespath = __commonJS({
12059
12059
  return false;
12060
12060
  }
12061
12061
  }
12062
- function isObject2(obj) {
12062
+ function isObject3(obj) {
12063
12063
  if (obj !== null) {
12064
12064
  return Object.prototype.toString.call(obj) === "[object Object]";
12065
12065
  } else {
@@ -12085,7 +12085,7 @@ var require_jmespath = __commonJS({
12085
12085
  }
12086
12086
  return true;
12087
12087
  }
12088
- if (isObject2(first) === true) {
12088
+ if (isObject3(first) === true) {
12089
12089
  var keysSeen = {};
12090
12090
  for (var key in first) {
12091
12091
  if (hasOwnProperty.call(first, key)) {
@@ -12111,7 +12111,7 @@ var require_jmespath = __commonJS({
12111
12111
  return true;
12112
12112
  } else if (isArray4(obj) && obj.length === 0) {
12113
12113
  return true;
12114
- } else if (isObject2(obj)) {
12114
+ } else if (isObject3(obj)) {
12115
12115
  for (var key in obj) {
12116
12116
  if (obj.hasOwnProperty(key)) {
12117
12117
  return false;
@@ -12828,7 +12828,7 @@ var require_jmespath = __commonJS({
12828
12828
  var matched, current, result, first, second, field, left, right, collected, i2;
12829
12829
  switch (node.type) {
12830
12830
  case "Field":
12831
- if (value !== null && isObject2(value)) {
12831
+ if (value !== null && isObject3(value)) {
12832
12832
  field = value[node.name];
12833
12833
  if (field === void 0) {
12834
12834
  return null;
@@ -12898,7 +12898,7 @@ var require_jmespath = __commonJS({
12898
12898
  return collected;
12899
12899
  case "ValueProjection":
12900
12900
  base = this.visit(node.children[0], value);
12901
- if (!isObject2(base)) {
12901
+ if (!isObject3(base)) {
12902
12902
  return null;
12903
12903
  }
12904
12904
  collected = [];
@@ -13295,7 +13295,7 @@ var require_jmespath = __commonJS({
13295
13295
  return Math.floor(resolvedArgs[0]);
13296
13296
  },
13297
13297
  _functionLength: function(resolvedArgs) {
13298
- if (!isObject2(resolvedArgs[0])) {
13298
+ if (!isObject3(resolvedArgs[0])) {
13299
13299
  return resolvedArgs[0].length;
13300
13300
  } else {
13301
13301
  return Object.keys(resolvedArgs[0]).length;
@@ -14287,7 +14287,15 @@ function getA2UIActionExecuteRequestIssues(value) {
14287
14287
  if (!isPlainRecord(value))
14288
14288
  return ["request must be an object"];
14289
14289
  const issues = [];
14290
- rejectExtraKeysAsStrings(value, ["schemaVersion", "agentId", "threadId", "invocationId", "actionId", "source", "actionContext"], "request", issues);
14290
+ rejectExtraKeysAsStrings(value, [
14291
+ "schemaVersion",
14292
+ "agentId",
14293
+ "threadId",
14294
+ "invocationId",
14295
+ "actionId",
14296
+ "source",
14297
+ "actionContext"
14298
+ ], "request", issues);
14291
14299
  if (value.schemaVersion !== "1")
14292
14300
  issues.push("schemaVersion must be 1");
14293
14301
  requiredIdentifier(value.agentId, "agentId", issues);
@@ -14302,7 +14310,9 @@ function getA2UIActionExecuteRequestIssues(value) {
14302
14310
  }
14303
14311
  function parseA2UIPaymentResultEventPayload(value) {
14304
14312
  if (!isPlainRecord(value)) {
14305
- throw new A2UIActionContractError(["payment result payload must be an object"]);
14313
+ throw new A2UIActionContractError([
14314
+ "payment result payload must be an object"
14315
+ ]);
14306
14316
  }
14307
14317
  const issues = [];
14308
14318
  rejectExtraKeysAsStrings(value, ["actionId", "actionInvocationId", "tradeNO", "actionContext", "callback"], "payment result payload", issues);
@@ -14326,7 +14336,9 @@ function parseA2UIPaymentResultEventPayload(value) {
14326
14336
  }
14327
14337
  function getA2UICardActionBindingIssues(value, path6 = "actionBindings") {
14328
14338
  if (!Array.isArray(value)) {
14329
- return [issue2(path6, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")];
14339
+ return [
14340
+ issue2(path6, "INVALID_ACTION_BINDINGS", "actionBindings must be an array")
14341
+ ];
14330
14342
  }
14331
14343
  const issues = [];
14332
14344
  const actionIds = /* @__PURE__ */ new Set();
@@ -14386,7 +14398,13 @@ function validateToolBinding(value, path6, phase, issues) {
14386
14398
  issues.push(issue2(path6, "INVALID_PAYMENT_TOOL", `${path6} must be an object`));
14387
14399
  return;
14388
14400
  }
14389
- rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : ["mcpResourceId", "toolName", "inputBindings", "statusPath", "paidValues"], path6, issues);
14401
+ rejectExtraKeys(value, phase === "create" ? ["mcpResourceId", "toolName", "inputBindings", "tradeNoPath"] : [
14402
+ "mcpResourceId",
14403
+ "toolName",
14404
+ "inputBindings",
14405
+ "statusPath",
14406
+ "paidValues"
14407
+ ], path6, issues);
14390
14408
  if (!isSafeIdentifier(value.mcpResourceId)) {
14391
14409
  issues.push(issue2(`${path6}.mcpResourceId`, "INVALID_MCP_RESOURCE_ID", "mcpResourceId is invalid"));
14392
14410
  }
@@ -14560,7 +14578,12 @@ var init_payment_action = __esm({
14560
14578
  this.name = "A2UIActionContractError";
14561
14579
  }
14562
14580
  };
14563
- RUNTIME_CONTEXT_KEYS = /* @__PURE__ */ new Set(["agentId", "tenantId", "threadId", "userId"]);
14581
+ RUNTIME_CONTEXT_KEYS = /* @__PURE__ */ new Set([
14582
+ "agentId",
14583
+ "tenantId",
14584
+ "threadId",
14585
+ "userId"
14586
+ ]);
14564
14587
  }
14565
14588
  });
14566
14589
 
@@ -14800,7 +14823,8 @@ function validateFields(value, path6, issues) {
14800
14823
  "valueSchema",
14801
14824
  "sourcePath",
14802
14825
  "runtimeContextKey",
14803
- "consistencyGroup"
14826
+ "consistencyGroup",
14827
+ "presentation"
14804
14828
  ], itemPath, issues);
14805
14829
  if (!isSafeIdentifier(candidate.fieldId)) {
14806
14830
  issues.push(issue2(`${itemPath}.fieldId`, "INVALID_FIELD_ID", "fieldId is invalid"));
@@ -14836,9 +14860,33 @@ function validateFields(value, path6, issues) {
14836
14860
  }
14837
14861
  validateFieldSource(candidate, itemPath, issues);
14838
14862
  optionalString(candidate.consistencyGroup, `${itemPath}.consistencyGroup`, issues);
14863
+ validateFieldPresentation(candidate.presentation, itemPath, issues);
14839
14864
  });
14840
14865
  return value;
14841
14866
  }
14867
+ function validateFieldPresentation(value, itemPath, issues) {
14868
+ if (value === void 0)
14869
+ return;
14870
+ const path6 = `${itemPath}.presentation`;
14871
+ if (!isPlainRecord(value)) {
14872
+ issues.push(issue2(path6, "INVALID_FIELD_PRESENTATION", `${path6} must be an object`));
14873
+ return;
14874
+ }
14875
+ if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
14876
+ issues.push(issue2(`${path6}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
14877
+ }
14878
+ if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
14879
+ issues.push(issue2(`${path6}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
14880
+ }
14881
+ if (value.attributePaths !== void 0) {
14882
+ if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
14883
+ issues.push(issue2(`${path6}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
14884
+ }
14885
+ }
14886
+ if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
14887
+ issues.push(issue2(`${path6}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
14888
+ }
14889
+ }
14842
14890
  function validateFieldSource(candidate, itemPath, issues) {
14843
14891
  if (candidate.source === "invocation") {
14844
14892
  if (!isSafeJsonPointer(candidate.sourcePath)) {
@@ -15405,6 +15453,129 @@ var init_authoring_operation = __esm({
15405
15453
  }
15406
15454
  });
15407
15455
 
15456
+ // ../agent-a2ui-card-contract/dist/esm/presentation.js
15457
+ function createA2UICardPresentationReceiptContent(fields, viewModel) {
15458
+ const coverage = [];
15459
+ const entities = [];
15460
+ const omissions = [];
15461
+ for (const field of fields.slice(0, MAX_FIELDS)) {
15462
+ const policy = field.presentation;
15463
+ if (policy?.visibility === "never") {
15464
+ omissions.push({ fieldId: field.fieldId, reason: "policy" });
15465
+ continue;
15466
+ }
15467
+ const value = readJsonPointer(viewModel, field.path);
15468
+ coverage.push({
15469
+ fieldId: field.fieldId,
15470
+ label: truncateText(field.label).value,
15471
+ present: value !== void 0,
15472
+ valueType: field.type,
15473
+ ...Array.isArray(value) && { itemCount: value.length }
15474
+ });
15475
+ if (!policy || value === void 0)
15476
+ continue;
15477
+ const isCollection = Array.isArray(value);
15478
+ const values = isCollection ? value : [value];
15479
+ const remainingBudget = MAX_ENTITIES - entities.length;
15480
+ const fieldBudget = Math.min(policy.maxItems ?? DEFAULT_FIELD_ITEMS, MAX_FIELD_ITEMS, remainingBudget);
15481
+ const selected = values.slice(0, Math.max(0, fieldBudget));
15482
+ for (const [index2, candidate] of selected.entries()) {
15483
+ const entity = createEntity(field, candidate, index2, isCollection, policy.visibility);
15484
+ if (entity)
15485
+ entities.push(entity);
15486
+ else
15487
+ omissions.push({ fieldId: field.fieldId, reason: "unsupported-value" });
15488
+ }
15489
+ if (values.length > selected.length) {
15490
+ omissions.push({
15491
+ fieldId: field.fieldId,
15492
+ reason: "budget",
15493
+ omittedCount: values.length - selected.length
15494
+ });
15495
+ }
15496
+ }
15497
+ if (fields.length > MAX_FIELDS) {
15498
+ omissions.push({
15499
+ fieldId: "*",
15500
+ reason: "budget",
15501
+ omittedCount: fields.length - MAX_FIELDS
15502
+ });
15503
+ }
15504
+ return { coverage, entities, omissions };
15505
+ }
15506
+ function createEntity(field, value, index2, isCollection, visibility) {
15507
+ const ref = `${field.fieldId}:${index2 + 1}`;
15508
+ if (visibility === "reference-only") {
15509
+ return {
15510
+ ref,
15511
+ fieldId: field.fieldId,
15512
+ ...isCollection && { ordinal: index2 + 1 },
15513
+ label: isCollection ? `${field.label} ${index2 + 1}` : field.label
15514
+ };
15515
+ }
15516
+ if (isPrimitive(value)) {
15517
+ const normalized = normalizePrimitive(value);
15518
+ return {
15519
+ ref,
15520
+ fieldId: field.fieldId,
15521
+ label: field.label,
15522
+ value: normalized.value,
15523
+ ...normalized.truncated && { truncated: true }
15524
+ };
15525
+ }
15526
+ if (!isObject(value))
15527
+ return void 0;
15528
+ const rawLabel = field.presentation?.labelPath ? readJsonPointer(value, field.presentation.labelPath) : void 0;
15529
+ const normalizedLabel = isPrimitive(rawLabel) ? truncateText(String(rawLabel)) : truncateText(`${field.label} ${index2 + 1}`);
15530
+ const attributes = {};
15531
+ let truncated = normalizedLabel.truncated;
15532
+ for (const path6 of (field.presentation?.attributePaths ?? []).slice(0, MAX_ATTRIBUTES)) {
15533
+ const attribute = readJsonPointer(value, path6);
15534
+ if (!isPrimitive(attribute))
15535
+ continue;
15536
+ const normalized = normalizePrimitive(attribute);
15537
+ attributes[path6] = normalized.value;
15538
+ truncated || (truncated = normalized.truncated);
15539
+ }
15540
+ return {
15541
+ ref,
15542
+ fieldId: field.fieldId,
15543
+ ...isCollection && { ordinal: index2 + 1 },
15544
+ label: normalizedLabel.value,
15545
+ ...Object.keys(attributes).length > 0 && { attributes },
15546
+ ...truncated && { truncated: true }
15547
+ };
15548
+ }
15549
+ function isObject(value) {
15550
+ return value !== null && typeof value === "object" && !Array.isArray(value);
15551
+ }
15552
+ function isPrimitive(value) {
15553
+ return value === null || ["string", "number", "boolean"].includes(typeof value);
15554
+ }
15555
+ function normalizePrimitive(value) {
15556
+ if (typeof value !== "string")
15557
+ return { value, truncated: false };
15558
+ return truncateText(value);
15559
+ }
15560
+ function truncateText(value) {
15561
+ if (value.length <= MAX_TEXT_LENGTH)
15562
+ return { value, truncated: false };
15563
+ return { value: `${value.slice(0, MAX_TEXT_LENGTH - 1)}\u2026`, truncated: true };
15564
+ }
15565
+ var MAX_FIELDS, MAX_ENTITIES, DEFAULT_FIELD_ITEMS, MAX_FIELD_ITEMS, MAX_ATTRIBUTES, MAX_TEXT_LENGTH;
15566
+ var init_presentation = __esm({
15567
+ "../agent-a2ui-card-contract/dist/esm/presentation.js"() {
15568
+ "use strict";
15569
+ init_json2();
15570
+ MAX_FIELDS = 32;
15571
+ MAX_ENTITIES = 10;
15572
+ DEFAULT_FIELD_ITEMS = 3;
15573
+ MAX_FIELD_ITEMS = 10;
15574
+ MAX_ATTRIBUTES = 3;
15575
+ MAX_TEXT_LENGTH = 160;
15576
+ }
15577
+ });
15578
+
15408
15579
  // ../agent-a2ui-card-contract/dist/esm/index.js
15409
15580
  var init_esm4 = __esm({
15410
15581
  "../agent-a2ui-card-contract/dist/esm/index.js"() {
@@ -15425,6 +15596,7 @@ var init_esm4 = __esm({
15425
15596
  init_authoring_model();
15426
15597
  init_authoring_operation();
15427
15598
  init_payment_action();
15599
+ init_presentation();
15428
15600
  }
15429
15601
  });
15430
15602
 
@@ -15485,22 +15657,7 @@ async function executeCardPresentation(resource, registry2, runtimeContext, args
15485
15657
  })),
15486
15658
  signal
15487
15659
  });
15488
- const protocol = injectResolvedViewModel(JSON.parse(config2.a2uiTemplate.content), viewModel);
15489
- const cardInstanceId = `card-instance-${(0, import_node_crypto2.randomUUID)()}`;
15490
- return {
15491
- type: "linkque.presentation-tool-result",
15492
- modelText: PRESENTATION_RESULT_TEXT,
15493
- card: {
15494
- type: "a2ui_card",
15495
- itemId: cardInstanceId,
15496
- payload: { protocol },
15497
- metadata: {
15498
- cardRef: resource.resourceId,
15499
- cardRevision: config2.revision,
15500
- cardInstanceId
15501
- }
15502
- }
15503
- };
15660
+ return createPresentationResult(resource, config2, viewModel);
15504
15661
  }
15505
15662
  async function executeCardPresentationFromSources(resource, runtimeContext, sourceResults, signal) {
15506
15663
  const config2 = parseCardConfig(resource);
@@ -15570,9 +15727,19 @@ async function executeCardPresentationFromSources(resource, runtimeContext, sour
15570
15727
  function createPresentationResult(resource, config2, viewModel) {
15571
15728
  const protocol = injectResolvedViewModel(JSON.parse(config2.a2uiTemplate.content), viewModel);
15572
15729
  const cardInstanceId = `card-instance-${(0, import_node_crypto2.randomUUID)()}`;
15730
+ const receipt = {
15731
+ version: 1,
15732
+ cardRef: resource.resourceId,
15733
+ cardRevision: config2.revision,
15734
+ cardInstanceId,
15735
+ status: "emitted",
15736
+ ...createA2UICardPresentationReceiptContent(config2.fields, viewModel),
15737
+ responsePolicy: { verbatimEcho: "forbidden", hint: "acknowledge" }
15738
+ };
15573
15739
  return {
15574
15740
  type: "linkque.presentation-tool-result",
15575
- modelText: PRESENTATION_RESULT_TEXT,
15741
+ modelText: formatPresentationReceiptForModel(receipt),
15742
+ receipt,
15576
15743
  card: {
15577
15744
  type: "a2ui_card",
15578
15745
  itemId: cardInstanceId,
@@ -15585,6 +15752,14 @@ function createPresentationResult(resource, config2, viewModel) {
15585
15752
  }
15586
15753
  };
15587
15754
  }
15755
+ function formatPresentationReceiptForModel(receipt) {
15756
+ return [
15757
+ "<a2ui-presentation-receipt>",
15758
+ JSON.stringify(receipt),
15759
+ "</a2ui-presentation-receipt>",
15760
+ "The card above already presents these results. Do not repeat or restate its items as Markdown. Reply only with a brief acknowledgement or information not already presented by the card."
15761
+ ].join("\n");
15762
+ }
15588
15763
  function parseCardConfig(resource) {
15589
15764
  const parsed = parseA2UICardResourceConfig(resource.config);
15590
15765
  if (!parsed.success) {
@@ -15707,14 +15882,13 @@ function normalizeMcpInputSchema(value) {
15707
15882
  function isJsonObject(value) {
15708
15883
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
15709
15884
  }
15710
- var import_node_crypto2, PRESENTATION_RESULT_TEXT, FALLBACK_OBJECT_SCHEMA, CardMappingError;
15885
+ var import_node_crypto2, FALLBACK_OBJECT_SCHEMA, CardMappingError;
15711
15886
  var init_cardTools = __esm({
15712
15887
  "../linkque-agent-runtime/dist/esm/core/cardTools.js"() {
15713
15888
  "use strict";
15714
15889
  import_node_crypto2 = require("node:crypto");
15715
15890
  init_esm4();
15716
15891
  init_mcpNaming();
15717
- PRESENTATION_RESULT_TEXT = "\u5361\u7247\u5DF2\u5C55\u793A\u3002";
15718
15892
  FALLBACK_OBJECT_SCHEMA = {
15719
15893
  type: "object",
15720
15894
  additionalProperties: true
@@ -38157,11 +38331,11 @@ var require_ponyfill_es2018 = __commonJS({
38157
38331
  throw new TypeError(`${context2} is not a function.`);
38158
38332
  }
38159
38333
  }
38160
- function isObject2(x2) {
38334
+ function isObject3(x2) {
38161
38335
  return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
38162
38336
  }
38163
38337
  function assertObject(x2, context2) {
38164
- if (!isObject2(x2)) {
38338
+ if (!isObject3(x2)) {
38165
38339
  throw new TypeError(`${context2} is not an object.`);
38166
38340
  }
38167
38341
  }
@@ -49657,11 +49831,11 @@ var require_verify_stream = __commonJS({
49657
49831
  var toString = require_tostring();
49658
49832
  var util2 = require("util");
49659
49833
  var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
49660
- function isObject2(thing) {
49834
+ function isObject3(thing) {
49661
49835
  return Object.prototype.toString.call(thing) === "[object Object]";
49662
49836
  }
49663
49837
  function safeJsonParse(thing) {
49664
- if (isObject2(thing))
49838
+ if (isObject3(thing))
49665
49839
  return thing;
49666
49840
  try {
49667
49841
  return JSON.parse(thing);
@@ -83957,7 +84131,7 @@ __export(util_exports, {
83957
84131
  getLengthableOrigin: () => getLengthableOrigin,
83958
84132
  getParsedType: () => getParsedType2,
83959
84133
  getSizableOrigin: () => getSizableOrigin,
83960
- isObject: () => isObject,
84134
+ isObject: () => isObject2,
83961
84135
  isPlainObject: () => isPlainObject,
83962
84136
  issue: () => issue3,
83963
84137
  joinValues: () => joinValues,
@@ -84089,17 +84263,17 @@ function randomString(length = 10) {
84089
84263
  function esc(str2) {
84090
84264
  return JSON.stringify(str2);
84091
84265
  }
84092
- function isObject(data) {
84266
+ function isObject2(data) {
84093
84267
  return typeof data === "object" && data !== null && !Array.isArray(data);
84094
84268
  }
84095
84269
  function isPlainObject(o) {
84096
- if (isObject(o) === false)
84270
+ if (isObject2(o) === false)
84097
84271
  return false;
84098
84272
  const ctor = o.constructor;
84099
84273
  if (ctor === void 0)
84100
84274
  return true;
84101
84275
  const prot = ctor.prototype;
84102
- if (isObject(prot) === false)
84276
+ if (isObject2(prot) === false)
84103
84277
  return false;
84104
84278
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
84105
84279
  return false;
@@ -86286,7 +86460,7 @@ var init_schemas = __esm({
86286
86460
  return (payload, ctx) => fn(shape, payload, ctx);
86287
86461
  };
86288
86462
  let fastpass;
86289
- const isObject2 = isObject;
86463
+ const isObject3 = isObject2;
86290
86464
  const jit = !globalConfig.jitless;
86291
86465
  const allowsEval2 = allowsEval;
86292
86466
  const fastEnabled = jit && allowsEval2.value;
@@ -86295,7 +86469,7 @@ var init_schemas = __esm({
86295
86469
  inst._zod.parse = (payload, ctx) => {
86296
86470
  value ?? (value = _normalized.value);
86297
86471
  const input = payload.value;
86298
- if (!isObject2(input)) {
86472
+ if (!isObject3(input)) {
86299
86473
  payload.issues.push({
86300
86474
  expected: "object",
86301
86475
  code: "invalid_type",
@@ -86439,7 +86613,7 @@ var init_schemas = __esm({
86439
86613
  });
86440
86614
  inst._zod.parse = (payload, ctx) => {
86441
86615
  const input = payload.value;
86442
- if (!isObject(input)) {
86616
+ if (!isObject2(input)) {
86443
86617
  payload.issues.push({
86444
86618
  code: "invalid_type",
86445
86619
  expected: "object",
@@ -95650,8 +95824,8 @@ function discriminatedUnion2(inputPropertyName, options, opts = {}) {
95650
95824
  [outputPropertyName ?? inputPropertyName]: unknownValue,
95651
95825
  isUnknown: true
95652
95826
  }, { [UNKNOWN]: { value: true, enumerable: false, configurable: false } });
95653
- const isObject2 = typeof input === "object" && input !== null;
95654
- if (!isObject2)
95827
+ const isObject3 = typeof input === "object" && input !== null;
95828
+ if (!isObject3)
95655
95829
  return fallback;
95656
95830
  const discriminator = input[inputPropertyName];
95657
95831
  if (typeof discriminator !== "string")
@@ -189378,6 +189552,7 @@ var init_agentRuntime = __esm({
189378
189552
  init_mcpProxyTool();
189379
189553
  init_mcpAggregator();
189380
189554
  init_cardRenderMcpServer();
189555
+ init_cardTools();
189381
189556
  init_cardRenderMcpServerProvider();
189382
189557
  init_knowledgeMcpServer();
189383
189558
  init_noopKnowledgeSearchPort();
@@ -189639,6 +189814,7 @@ var init_agentRuntime = __esm({
189639
189814
  await hookDispatcher.dispatch(EHookStage.RUN_STARTED, hookCommonParams);
189640
189815
  }
189641
189816
  let assistantText = "";
189817
+ const presentationReceipts = [];
189642
189818
  let failed = false;
189643
189819
  let runError;
189644
189820
  let terminalHookDispatched = false;
@@ -189661,6 +189837,12 @@ var init_agentRuntime = __esm({
189661
189837
  for await (const ev of this.agentLoop.run(agentReq)) {
189662
189838
  if (ev.type === "delta")
189663
189839
  assistantText += ev.content;
189840
+ if (ev.type === "tool_end" && !ev.isError) {
189841
+ const details = ev.result && typeof ev.result === "object" && "details" in ev.result ? ev.result.details : void 0;
189842
+ if (isAgentPresentationToolResult(details) && details.receipt && !presentationReceipts.some((receipt) => receipt.cardInstanceId === details.receipt?.cardInstanceId)) {
189843
+ presentationReceipts.push(details.receipt);
189844
+ }
189845
+ }
189664
189846
  if (ev.type === "error") {
189665
189847
  failed = true;
189666
189848
  runError = { message: ev.error.message, code: ev.error.code };
@@ -189669,6 +189851,11 @@ var init_agentRuntime = __esm({
189669
189851
  if (ev.type === "done" && !failed && sessionId !== void 0) {
189670
189852
  const completedTurns = [
189671
189853
  ...newTurns,
189854
+ ...presentationReceipts.map((receipt) => ({
189855
+ role: "tool",
189856
+ name: "a2ui_presentation_receipt",
189857
+ content: { type: "a2ui.presentation-receipt", receipt }
189858
+ })),
189672
189859
  { role: "assistant", content: assistantText }
189673
189860
  ];
189674
189861
  if (this.sessionManager.appendMany) {
@@ -197507,13 +197694,25 @@ var init_conversationBridge = __esm({
197507
197694
 
197508
197695
  // ../linkque-agent-runtime/dist/esm/impl/agui/runConversation.js
197509
197696
  function toAgentRunRequest(req) {
197697
+ const lastUserMessageIndex = req.messages.map((message) => message.role).lastIndexOf("user");
197510
197698
  return {
197511
197699
  threadId: req.threadId,
197512
197700
  runId: req.runId,
197513
- messages: req.messages.map((m2) => ({
197701
+ messages: req.messages.map((m2, index2) => ({
197514
197702
  role: m2.role,
197515
197703
  content: m2.content,
197516
- ...m2.name !== void 0 && { name: m2.name }
197704
+ ...m2.name !== void 0 && { name: m2.name },
197705
+ ...index2 === lastUserMessageIndex && req.attachments.length > 0 ? {
197706
+ attachments: req.attachments.map((attachment) => ({
197707
+ id: attachment.id,
197708
+ name: attachment.name,
197709
+ mimeType: attachment.mimeType,
197710
+ ...attachment.resourceId !== void 0 && {
197711
+ resourceId: attachment.resourceId
197712
+ },
197713
+ ...attachment.url !== void 0 && { url: attachment.url }
197714
+ }))
197715
+ } : {}
197517
197716
  })),
197518
197717
  clientCapabilities: req.clientCapabilities
197519
197718
  };
@@ -197985,15 +198184,6 @@ var handleSandboxChat = async (req, res, deps, activeRuns2, cancelActiveRun2) =>
197985
198184
  );
197986
198185
  return;
197987
198186
  }
197988
- if (request.attachments.length > 0) {
197989
- writeJsonError(
197990
- res,
197991
- 400,
197992
- "ATTACHMENTS_UNSUPPORTED",
197993
- "attachments are not supported by agentdev"
197994
- );
197995
- return;
197996
- }
197997
198187
  if (request.resumeFrom || req.headers["last-event-id"]) {
197998
198188
  writeJsonError(
197999
198189
  res,