linkque-cli-v2 1.3.4 → 1.3.5

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.
@@ -3,11 +3,11 @@ import {
3
3
  runClientCapability,
4
4
  runClientCapabilityCleanup,
5
5
  runClientCapabilityResult
6
- } from "../../chunk-23PMJWOG.js";
6
+ } from "../../chunk-LT6VSAY4.js";
7
7
  import "../../chunk-IWOFD643.js";
8
8
  import "../../chunk-PXCGFBV5.js";
9
9
  import "../../chunk-ETG6PNHQ.js";
10
- import "../../chunk-YSRA6KFZ.js";
10
+ import "../../chunk-VVEDZWQ5.js";
11
11
  import "../../chunk-XUFLSZM4.js";
12
12
  import "../../chunk-GAYNLDWK.js";
13
13
  import "../../chunk-HM7KNEG3.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getBakedProtocol,
3
3
  setBakedProtocol
4
- } from "../chunk-VSZ3UDC7.js";
5
- import "../chunk-YSRA6KFZ.js";
4
+ } from "../chunk-NBYB7HSY.js";
5
+ import "../chunk-VVEDZWQ5.js";
6
6
  import "../chunk-XUFLSZM4.js";
7
7
  import "../chunk-GAYNLDWK.js";
8
8
  import "../chunk-HM7KNEG3.js";
package/worker.js CHANGED
@@ -4360,13 +4360,14 @@ var require_fast_uri = __commonJS({
4360
4360
  if (!malformedIPLiteral) {
4361
4361
  malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP2);
4362
4362
  }
4363
- if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4364
- if (uri.indexOf("%") !== -1) {
4365
- if (parsed.host !== void 0 && !malformedIPLiteral) {
4366
- const host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
4367
- parsed.host = reescapeHostDelimiters(host, isIP2);
4368
- }
4363
+ if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
4364
+ let host = isIP2 ? parsed.host : normalizePercentEncoding(parsed.host, true);
4365
+ if (!isIP2) {
4366
+ host = normalizePercentEncoding(host.toLowerCase());
4369
4367
  }
4368
+ parsed.host = reescapeHostDelimiters(host, isIP2);
4369
+ }
4370
+ if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4370
4371
  if (parsed.path) {
4371
4372
  parsed.path = normalizePathEncoding(parsed.path);
4372
4373
  }
@@ -9452,6 +9453,54 @@ function getA2UIV4ProtocolIssues(value, path9 = "card") {
9452
9453
  validateReferences(surfaces, path9, issues);
9453
9454
  return issues;
9454
9455
  }
9456
+ function validateV4Component(component, componentPath, issues) {
9457
+ const schema = A2UI_V4_COMPONENT_CATALOG.components[component.component];
9458
+ if (!schema) {
9459
+ issues.push(issue2(`${componentPath}.component`, "UNSUPPORTED_COMPONENT", `V4 does not support component ${component.component}`));
9460
+ return;
9461
+ }
9462
+ const allowed = /* @__PURE__ */ new Set([
9463
+ "id",
9464
+ "component",
9465
+ ...Object.keys(schema.properties)
9466
+ ]);
9467
+ for (const key of Object.keys(component))
9468
+ if (!allowed.has(key))
9469
+ issues.push(issue2(`${componentPath}.${key}`, "UNSUPPORTED_COMPONENT_PROP", `${component.component} does not support property ${key}`));
9470
+ for (const [name, property] of Object.entries(schema.properties)) {
9471
+ const value = component[name];
9472
+ if (property.required && value === void 0)
9473
+ issues.push(issue2(`${componentPath}.${name}`, "REQUIRED_COMPONENT_PROP_MISSING", `${component.component}.${name} is required`));
9474
+ if (value !== void 0)
9475
+ validateProperty(value, property, `${componentPath}.${name}`, issues, name);
9476
+ }
9477
+ if (component["x2-overflow"] !== void 0)
9478
+ validateOverflow(component, componentPath, issues);
9479
+ if (component.component === "TextField")
9480
+ validateTextField(component, componentPath, issues);
9481
+ if (component.component === "ChoicePicker") {
9482
+ if (!isStrictBinding(component.value))
9483
+ issues.push(issue2(`${componentPath}.value`, "INPUT_REQUIRES_BINDING", "ChoicePicker.value must be a strict writable binding"));
9484
+ validateOptions(component.options, `${componentPath}.options`, issues);
9485
+ }
9486
+ if (component.component === "Stepper")
9487
+ validateStepper(component, componentPath, issues);
9488
+ if (["Card", "Row", "Column", "List"].includes(component.component)) {
9489
+ for (const axis of ["width", "height"]) {
9490
+ const value = component[axis];
9491
+ const modes = axis === "width" ? ["fit", "fill"] : ["auto"];
9492
+ if (value !== void 0 && !(typeof value === "string" && (modes.includes(value) || /^\d+(?:\.\d+)?px$/.test(value) && Number.isFinite(parseFloat(value))))) {
9493
+ issues.push(issue2(`${componentPath}.${axis}`, "INVALID_COMPONENT_PROP_VALUE", `size must be ${modes.join(" / ")} or a non-negative px string such as 120px`));
9494
+ }
9495
+ }
9496
+ }
9497
+ if (component.checks !== void 0)
9498
+ validateChecks(component.checks, `${componentPath}.checks`, issues);
9499
+ if (component.format !== void 0 && component.component === "Text")
9500
+ validateNumberFormat(component.format, `${componentPath}.format`, issues);
9501
+ if (component.action !== void 0)
9502
+ validateAction(component.action, `${componentPath}.action`, issues, 0);
9503
+ }
9455
9504
  function validateComponents(payload, path9, surfaces, issues) {
9456
9505
  if (!Array.isArray(payload.components)) {
9457
9506
  issues.push(issue2(`${path9}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
@@ -9468,52 +9517,7 @@ function validateComponents(payload, path9, surfaces, issues) {
9468
9517
  if (surface.has(component.id))
9469
9518
  issues.push(issue2(`${componentPath}.id`, "DUPLICATE_COMPONENT_ID", `component id ${component.id} is duplicated`));
9470
9519
  surface.set(component.id, component);
9471
- const schema = A2UI_V4_COMPONENT_CATALOG.components[component.component];
9472
- if (!schema) {
9473
- issues.push(issue2(`${componentPath}.component`, "UNSUPPORTED_COMPONENT", `V4 does not support component ${component.component}`));
9474
- return;
9475
- }
9476
- const allowed = /* @__PURE__ */ new Set([
9477
- "id",
9478
- "component",
9479
- ...Object.keys(schema.properties)
9480
- ]);
9481
- for (const key of Object.keys(component))
9482
- if (!allowed.has(key))
9483
- issues.push(issue2(`${componentPath}.${key}`, "UNSUPPORTED_COMPONENT_PROP", `${component.component} does not support property ${key}`));
9484
- for (const [name, property] of Object.entries(schema.properties)) {
9485
- const value = component[name];
9486
- if (property.required && value === void 0)
9487
- issues.push(issue2(`${componentPath}.${name}`, "REQUIRED_COMPONENT_PROP_MISSING", `${component.component}.${name} is required`));
9488
- if (value !== void 0)
9489
- validateProperty(value, property, `${componentPath}.${name}`, issues, name);
9490
- }
9491
- if (component["x2-overflow"] !== void 0)
9492
- validateOverflow(component, componentPath, issues);
9493
- if (component.component === "TextField")
9494
- validateTextField(component, componentPath, issues);
9495
- if (component.component === "ChoicePicker") {
9496
- if (!isStrictBinding(component.value))
9497
- issues.push(issue2(`${componentPath}.value`, "INPUT_REQUIRES_BINDING", "ChoicePicker.value must be a strict writable binding"));
9498
- validateOptions(component.options, `${componentPath}.options`, issues);
9499
- }
9500
- if (component.component === "Stepper")
9501
- validateStepper(component, componentPath, issues);
9502
- if (["Card", "Row", "Column", "List"].includes(component.component)) {
9503
- for (const axis of ["width", "height"]) {
9504
- const value = component[axis];
9505
- const modes = axis === "width" ? ["fit", "fill"] : ["auto"];
9506
- if (value !== void 0 && !(typeof value === "string" && (modes.includes(value) || /^\d+(?:\.\d+)?px$/.test(value) && Number.isFinite(parseFloat(value))))) {
9507
- issues.push(issue2(`${componentPath}.${axis}`, "INVALID_COMPONENT_PROP_VALUE", `size must be ${modes.join(" / ")} or a non-negative px string such as 120px`));
9508
- }
9509
- }
9510
- }
9511
- if (component.checks !== void 0)
9512
- validateChecks(component.checks, `${componentPath}.checks`, issues);
9513
- if (component.format !== void 0 && component.component === "Text")
9514
- validateNumberFormat(component.format, `${componentPath}.format`, issues);
9515
- if (component.action !== void 0)
9516
- validateAction(component.action, `${componentPath}.action`, issues, 0);
9520
+ validateV4Component(component, componentPath, issues);
9517
9521
  });
9518
9522
  }
9519
9523
  function validateProperty(value, schema, path9, issues, propertyName) {
@@ -11161,6 +11165,7 @@ var init_authoring_operation = __esm({
11161
11165
  "use strict";
11162
11166
  init_authoring_model();
11163
11167
  init_json2();
11168
+ init_v4Catalog();
11164
11169
  }
11165
11170
  });
11166
11171
 
@@ -12579,10 +12584,10 @@ var init_hookRegistry = __esm({
12579
12584
  }
12580
12585
  });
12581
12586
 
12582
- // ../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js
12583
- var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName, ETelemetryOperationName, ETelemetryOutcome, ETelemetrySignal, ETelemetryDiagnosticCode, ETelemetryLossReason, ETelemetryAdvanceOutcome, ETelemetryStreamTermination, ETelemetryCancelSource, ETelemetryObservationBoundary, ETelemetryRemoteCompletion, ETelemetryCommitStatus, ETelemetryHookMode, ETelemetryHookResult, ETelemetrySource, ETelemetryEvidence, ETelemetryCompleteness, ETelemetryCoverage, ETelemetryUsageSource, ETelemetryAttemptVisibility, ETelemetryLinkRelation, ETelemetryToolFailureStage, ETelemetryTerminalEvidence, ETelemetryTerminalSource, ETelemetryModelPurpose, ETelemetryErrorType, ETelemetrySpanKind, ETelemetryGenAiOperation, ETelemetryAssociation, ETelemetryMetadata, ETelemetryVersion;
12587
+ // ../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js
12588
+ var ETelemetryAttribute, ETelemetryEventPrefix, ETelemetryEventPhase, ETelemetryEventName, ETelemetryOperationName, ETelemetryOutcome, ETelemetrySignal, ETelemetryLossReason, ETelemetryAdvanceOutcome, ETelemetryStreamTermination, ETelemetryCancelSource, ETelemetryObservationBoundary, ETelemetryRemoteCompletion, ETelemetryCommitStatus, ETelemetryHookMode, ETelemetryHookResult, ETelemetrySource, ETelemetryEvidence, ETelemetryCompleteness, ETelemetryCoverage, ETelemetryUsageSource, ETelemetryAttemptVisibility, ETelemetryLinkRelation, ETelemetryToolFailureStage, ETelemetryTerminalEvidence, ETelemetryTerminalSource, ETelemetryModelPurpose, ETelemetryErrorType, ETelemetrySpanKind, ETelemetryGenAiOperation, ETelemetryVersion;
12584
12589
  var init_telemetryEnums = __esm({
12585
- "../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js"() {
12590
+ "../linkque-agent-protocol/dist/esm/telemetry/telemetryEnums.js"() {
12586
12591
  "use strict";
12587
12592
  (function(ETelemetryAttribute2) {
12588
12593
  ETelemetryAttribute2["HARNESS_TELEMETRY_SCHEMA_VERSION"] = "harness.telemetry.schema.version";
@@ -12768,23 +12773,6 @@ var init_telemetryEnums = __esm({
12768
12773
  ETelemetrySignal2["LOGS"] = "logs";
12769
12774
  ETelemetrySignal2["TRACES"] = "traces";
12770
12775
  })(ETelemetrySignal || (ETelemetrySignal = {}));
12771
- (function(ETelemetryDiagnosticCode2) {
12772
- ETelemetryDiagnosticCode2["INVALID_AUTHORIZATION"] = "invalid_authorization";
12773
- ETelemetryDiagnosticCode2["PARTITION_LIMIT"] = "partition_limit";
12774
- ETelemetryDiagnosticCode2["UNAVAILABLE_PARTITION"] = "unavailable_partition";
12775
- ETelemetryDiagnosticCode2["QUEUE_LIMIT"] = "queue_limit";
12776
- ETelemetryDiagnosticCode2["QUEUE_EXPIRED"] = "queue_expired";
12777
- ETelemetryDiagnosticCode2["SENDER_FAILED"] = "sender_failed";
12778
- ETelemetryDiagnosticCode2["PARTIAL_SUCCESS"] = "partial_success";
12779
- ETelemetryDiagnosticCode2["AUTHORIZATION_REJECTED"] = "authorization_rejected";
12780
- ETelemetryDiagnosticCode2["PERMANENT_REJECTION"] = "permanent_rejection";
12781
- ETelemetryDiagnosticCode2["SEND_RETRY"] = "send_retry";
12782
- ETelemetryDiagnosticCode2["SHUTDOWN_DROP"] = "shutdown_drop";
12783
- ETelemetryDiagnosticCode2["LOCAL_SINK_FAILED"] = "local_sink_failed";
12784
- ETelemetryDiagnosticCode2["CAPTURE_FAILED"] = "capture_failed";
12785
- ETelemetryDiagnosticCode2["IDENTITY_MISMATCH"] = "identity_mismatch";
12786
- ETelemetryDiagnosticCode2["ACTIVE_LIMIT"] = "active_limit";
12787
- })(ETelemetryDiagnosticCode || (ETelemetryDiagnosticCode = {}));
12788
12776
  (function(ETelemetryLossReason2) {
12789
12777
  ETelemetryLossReason2["UNCAUGHT_ERROR"] = "uncaught_error";
12790
12778
  ETelemetryLossReason2["ACTIVE_LIMIT"] = "active_limit";
@@ -12892,19 +12880,6 @@ var init_telemetryEnums = __esm({
12892
12880
  ETelemetryGenAiOperation2["EXECUTE_TOOL"] = "execute_tool";
12893
12881
  ETelemetryGenAiOperation2["INVOKE_AGENT"] = "invoke_agent";
12894
12882
  })(ETelemetryGenAiOperation || (ETelemetryGenAiOperation = {}));
12895
- (function(ETelemetryAssociation2) {
12896
- ETelemetryAssociation2["LOOP"] = "loop";
12897
- ETelemetryAssociation2["ITERATION"] = "iteration";
12898
- ETelemetryAssociation2["MODEL"] = "model";
12899
- ETelemetryAssociation2["TOOL"] = "tool";
12900
- ETelemetryAssociation2["PROVIDER"] = "provider";
12901
- })(ETelemetryAssociation || (ETelemetryAssociation = {}));
12902
- (function(ETelemetryMetadata2) {
12903
- ETelemetryMetadata2["SCOPE_NAME"] = "com.alipay.linkque.runtime.telemetry";
12904
- ETelemetryMetadata2["RUNTIME_KIND"] = "node_toolkit";
12905
- ETelemetryMetadata2["SERVICE_NAMESPACE"] = "linkque";
12906
- ETelemetryMetadata2["ROUTE_CONTEXT_KEY"] = "linkque.telemetry.route";
12907
- })(ETelemetryMetadata || (ETelemetryMetadata = {}));
12908
12883
  (function(ETelemetryVersion2) {
12909
12884
  ETelemetryVersion2["V0_2"] = "0.2";
12910
12885
  ETelemetryVersion2["V1_0"] = "1.0";
@@ -12912,6 +12887,14 @@ var init_telemetryEnums = __esm({
12912
12887
  }
12913
12888
  });
12914
12889
 
12890
+ // ../linkque-agent-protocol/dist/esm/telemetry.js
12891
+ var init_telemetry = __esm({
12892
+ "../linkque-agent-protocol/dist/esm/telemetry.js"() {
12893
+ "use strict";
12894
+ init_telemetryEnums();
12895
+ }
12896
+ });
12897
+
12915
12898
  // ../linkque-agent-runtime/dist/esm/core/logFailure.js
12916
12899
  function warnLogFailure(stage, error40) {
12917
12900
  (0, import_node_process.emitWarning)(`[${stage}] errorType=${error40 instanceof Error ? error40.name : typeof error40}`, { code: "LINKQUE_RUNTIME_DIAGNOSTIC_FAILURE" });
@@ -13064,7 +13047,7 @@ var import_node_crypto3, PREPARE_PATCH_KEYS, HookDispatcher;
13064
13047
  var init_hookDispatcher = __esm({
13065
13048
  "../linkque-agent-runtime/dist/esm/core/hook/hookDispatcher.js"() {
13066
13049
  "use strict";
13067
- init_telemetryEnums();
13050
+ init_telemetry();
13068
13051
  import_node_crypto3 = require("node:crypto");
13069
13052
  init_esm();
13070
13053
  init_hookContext();
@@ -13486,7 +13469,7 @@ var import_node_crypto4, DEFAULT_HOOK_DRAIN_BUDGET_MS, SideEffectRunner;
13486
13469
  var init_sideEffectRunner = __esm({
13487
13470
  "../linkque-agent-runtime/dist/esm/core/hook/sideEffectRunner.js"() {
13488
13471
  "use strict";
13489
- init_telemetryEnums();
13472
+ init_telemetry();
13490
13473
  import_node_crypto4 = require("node:crypto");
13491
13474
  init_hookLog();
13492
13475
  init_hookMetrics();
@@ -13724,6 +13707,45 @@ var init_sideEffectRunner = __esm({
13724
13707
  }
13725
13708
  });
13726
13709
 
13710
+ // ../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js
13711
+ var ETelemetryDiagnosticCode, ETelemetryAssociation, ETelemetryMetadata;
13712
+ var init_telemetryEnums2 = __esm({
13713
+ "../linkque-agent-runtime/dist/esm/core/telemetry/telemetryEnums.js"() {
13714
+ "use strict";
13715
+ init_telemetry();
13716
+ (function(ETelemetryDiagnosticCode2) {
13717
+ ETelemetryDiagnosticCode2["INVALID_AUTHORIZATION"] = "invalid_authorization";
13718
+ ETelemetryDiagnosticCode2["PARTITION_LIMIT"] = "partition_limit";
13719
+ ETelemetryDiagnosticCode2["UNAVAILABLE_PARTITION"] = "unavailable_partition";
13720
+ ETelemetryDiagnosticCode2["QUEUE_LIMIT"] = "queue_limit";
13721
+ ETelemetryDiagnosticCode2["QUEUE_EXPIRED"] = "queue_expired";
13722
+ ETelemetryDiagnosticCode2["SENDER_FAILED"] = "sender_failed";
13723
+ ETelemetryDiagnosticCode2["PARTIAL_SUCCESS"] = "partial_success";
13724
+ ETelemetryDiagnosticCode2["AUTHORIZATION_REJECTED"] = "authorization_rejected";
13725
+ ETelemetryDiagnosticCode2["PERMANENT_REJECTION"] = "permanent_rejection";
13726
+ ETelemetryDiagnosticCode2["SEND_RETRY"] = "send_retry";
13727
+ ETelemetryDiagnosticCode2["SHUTDOWN_DROP"] = "shutdown_drop";
13728
+ ETelemetryDiagnosticCode2["LOCAL_SINK_FAILED"] = "local_sink_failed";
13729
+ ETelemetryDiagnosticCode2["CAPTURE_FAILED"] = "capture_failed";
13730
+ ETelemetryDiagnosticCode2["IDENTITY_MISMATCH"] = "identity_mismatch";
13731
+ ETelemetryDiagnosticCode2["ACTIVE_LIMIT"] = "active_limit";
13732
+ })(ETelemetryDiagnosticCode || (ETelemetryDiagnosticCode = {}));
13733
+ (function(ETelemetryAssociation2) {
13734
+ ETelemetryAssociation2["LOOP"] = "loop";
13735
+ ETelemetryAssociation2["ITERATION"] = "iteration";
13736
+ ETelemetryAssociation2["MODEL"] = "model";
13737
+ ETelemetryAssociation2["TOOL"] = "tool";
13738
+ ETelemetryAssociation2["PROVIDER"] = "provider";
13739
+ })(ETelemetryAssociation || (ETelemetryAssociation = {}));
13740
+ (function(ETelemetryMetadata2) {
13741
+ ETelemetryMetadata2["SCOPE_NAME"] = "com.alipay.linkque.runtime.telemetry";
13742
+ ETelemetryMetadata2["RUNTIME_KIND"] = "node_toolkit";
13743
+ ETelemetryMetadata2["SERVICE_NAMESPACE"] = "linkque";
13744
+ ETelemetryMetadata2["ROUTE_CONTEXT_KEY"] = "linkque.telemetry.route";
13745
+ })(ETelemetryMetadata || (ETelemetryMetadata = {}));
13746
+ }
13747
+ });
13748
+
13727
13749
  // ../linkque-agent-runtime/dist/esm/core/hook/hookToolWrapper.js
13728
13750
  function resolveHookToolName(tool) {
13729
13751
  return tool.modelName ?? tool.name;
@@ -13769,7 +13791,8 @@ function wrapToolWithHooks(tool, dispatcher, commonParams, now = Date.now, obser
13769
13791
  var init_hookToolWrapper = __esm({
13770
13792
  "../linkque-agent-runtime/dist/esm/core/hook/hookToolWrapper.js"() {
13771
13793
  "use strict";
13772
- init_telemetryEnums();
13794
+ init_telemetry();
13795
+ init_telemetryEnums2();
13773
13796
  init_esm();
13774
13797
  }
13775
13798
  });
@@ -14614,7 +14637,7 @@ var RuntimeObservation;
14614
14637
  var init_runtimeObservation = __esm({
14615
14638
  "../linkque-agent-runtime/dist/esm/core/telemetry/runtimeObservation.js"() {
14616
14639
  "use strict";
14617
- init_telemetryEnums();
14640
+ init_telemetry();
14618
14641
  init_noopRuntimeTelemetry();
14619
14642
  RuntimeObservation = class _RuntimeObservation {
14620
14643
  sink;
@@ -33085,7 +33108,10 @@ var init_run = __esm({
33085
33108
  "../agent-conversation-contract/dist/esm/run.js"() {
33086
33109
  "use strict";
33087
33110
  init_version();
33088
- CONVERSATION_CLIENT_CAPABILITIES = ["location"];
33111
+ CONVERSATION_CLIENT_CAPABILITIES = [
33112
+ "location",
33113
+ "userInfo"
33114
+ ];
33089
33115
  ConversationProtocolValidationError = class extends Error {
33090
33116
  issues;
33091
33117
  code = "CONVERSATION_PROTOCOL_INVALID";
@@ -49007,7 +49033,8 @@ var import_node_crypto6;
49007
49033
  var init_toolObservation = __esm({
49008
49034
  "../linkque-agent-runtime/dist/esm/core/telemetry/toolObservation.js"() {
49009
49035
  "use strict";
49010
- init_telemetryEnums();
49036
+ init_telemetry();
49037
+ init_telemetryEnums2();
49011
49038
  import_node_crypto6 = require("node:crypto");
49012
49039
  }
49013
49040
  });
@@ -49106,7 +49133,8 @@ var import_node_crypto7, PiTelemetry;
49106
49133
  var init_piTelemetry = __esm({
49107
49134
  "../linkque-agent-runtime/dist/esm/impl/agent/pi/piTelemetry.js"() {
49108
49135
  "use strict";
49109
- init_telemetryEnums();
49136
+ init_telemetry();
49137
+ init_telemetryEnums2();
49110
49138
  init_toolObservation();
49111
49139
  import_node_crypto7 = require("node:crypto");
49112
49140
  PiTelemetry = class {
@@ -205152,7 +205180,7 @@ function safeStringifyPayload(payload) {
205152
205180
  var init_createAgentSession = __esm({
205153
205181
  "../linkque-agent-runtime/dist/esm/impl/agent/pi/createAgentSession.js"() {
205154
205182
  "use strict";
205155
- init_telemetryEnums();
205183
+ init_telemetry();
205156
205184
  init_piTelemetry();
205157
205185
  init_logFailure();
205158
205186
  init_dist4();
@@ -206033,7 +206061,7 @@ var ERROR_FLUSH_TIMEOUT_MS;
206033
206061
  var init_runtimeErrorBoundary = __esm({
206034
206062
  "../linkque-agent-runtime/dist/esm/core/telemetry/runtimeErrorBoundary.js"() {
206035
206063
  "use strict";
206036
- init_telemetryEnums();
206064
+ init_telemetry();
206037
206065
  init_runtimeObservation();
206038
206066
  ERROR_FLUSH_TIMEOUT_MS = 200;
206039
206067
  }
@@ -207053,7 +207081,7 @@ var DEFAULT_HARNESS_PROMPT, AgentRuntime;
207053
207081
  var init_agentRuntime = __esm({
207054
207082
  "../linkque-agent-runtime/dist/esm/core/agentRuntime.js"() {
207055
207083
  "use strict";
207056
- init_telemetryEnums();
207084
+ init_telemetry();
207057
207085
  init_noopRuntimeTelemetry();
207058
207086
  init_runtimeErrorBoundary();
207059
207087
  init_toolObservation();
@@ -207837,17 +207865,72 @@ function parseArgs(args, imageId) {
207837
207865
  imageError("IMAGE_INPUT_INVALID");
207838
207866
  return { imageId, query, mode: args.mode };
207839
207867
  }
207868
+ function outputError(reason) {
207869
+ imageError(`IMAGE_OUTPUT_INVALID_${reason}`);
207870
+ }
207840
207871
  function parseObservation(value, imageId, mode) {
207841
- if (!record3(value) || !keys(value, ["version", "imageId", "mode", "truncated", "observation"]) || value.version !== "tool-v1" || value.imageId !== imageId || value.mode !== mode || typeof value.truncated !== "boolean" || !record3(value.observation))
207842
- imageError("IMAGE_OUTPUT_INVALID");
207872
+ if (!record3(value) || !keys(value, ["version", "imageId", "mode", "truncated", "observation"]))
207873
+ outputError("ROOT_FIELDS");
207874
+ if (value.version !== "tool-v1")
207875
+ outputError("VERSION");
207876
+ if (value.imageId !== imageId)
207877
+ outputError("IMAGE_ID");
207878
+ if (value.mode !== mode)
207879
+ outputError("MODE");
207880
+ if (typeof value.truncated !== "boolean")
207881
+ outputError("TRUNCATED");
207843
207882
  const obs = value.observation;
207883
+ if (!record3(obs) || !keys(obs, ["summary", "ocrText", "facts", "uncertainties"]))
207884
+ outputError("OBSERVATION_FIELDS");
207844
207885
  const list = (v, count, chars) => Array.isArray(v) && v.length <= count && v.every((s2) => text(s2, 1, chars));
207845
- if (!keys(obs, ["summary", "ocrText", "facts", "uncertainties"]) || !text(obs.summary, 1, 400) || !text(obs.ocrText, 0, 800) || !list(obs.facts, 8, 120) || !list(obs.uncertainties, 6, 160))
207846
- imageError("IMAGE_OUTPUT_INVALID");
207847
- if ([obs.summary, obs.ocrText, ...obs.facts, ...obs.uncertainties].reduce((n, s2) => n + Array.from(s2).length, 0) > 1200 || obs.uncertainties.filter((s2) => s2 === MARKER).length !== (value.truncated ? 1 : 0))
207848
- imageError("IMAGE_OUTPUT_INVALID");
207886
+ if (!text(obs.summary, 1, 400))
207887
+ outputError("SUMMARY");
207888
+ if (!text(obs.ocrText, 0, 800))
207889
+ outputError("OCR_TEXT");
207890
+ if (!list(obs.facts, 8, 120))
207891
+ outputError("FACTS");
207892
+ if (!list(obs.uncertainties, 6, 160))
207893
+ outputError("UNCERTAINTIES");
207894
+ if ([obs.summary, obs.ocrText, ...obs.facts, ...obs.uncertainties].reduce((n, s2) => n + Array.from(s2).length, 0) > 1200)
207895
+ outputError("OBSERVATION_BUDGET");
207896
+ if (obs.uncertainties.filter((s2) => s2 === MARKER).length !== (value.truncated ? 1 : 0))
207897
+ outputError("TRUNCATION_MARKER");
207849
207898
  return { ok: true, ...value };
207850
207899
  }
207900
+ function parseImageEnvelope(envelope, imageId, mode) {
207901
+ if (!record3(envelope) || typeof envelope.id !== "string" || !envelope.id || envelope.type !== "message" || envelope.role !== "assistant" || envelope.model !== "linkque-image-understanding")
207902
+ outputError("ENVELOPE");
207903
+ if (envelope.stop_reason !== "end_turn")
207904
+ outputError("STOP_REASON");
207905
+ const usage = envelope.usage;
207906
+ if (!record3(usage) || !["input_tokens", "output_tokens"].every((k) => Number.isSafeInteger(usage[k]) && Number(usage[k]) >= 0))
207907
+ outputError("USAGE");
207908
+ if (!Array.isArray(envelope.content) || !envelope.content.length)
207909
+ outputError("TEXT_EMPTY");
207910
+ const parts = [];
207911
+ for (const block of envelope.content) {
207912
+ if (!record3(block))
207913
+ outputError("BLOCK_TYPE");
207914
+ if (block.type === "thinking" || block.type === "redacted_thinking")
207915
+ continue;
207916
+ if (block.type !== "text")
207917
+ outputError("BLOCK_TYPE");
207918
+ if (typeof block.text !== "string")
207919
+ outputError("TEXT_TYPE");
207920
+ parts.push(block.text);
207921
+ }
207922
+ const visible = parts.join("").trim();
207923
+ if (!visible)
207924
+ outputError("TEXT_EMPTY");
207925
+ const fence = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n```$/i.exec(visible);
207926
+ let value;
207927
+ try {
207928
+ value = JSON.parse(fence ? fence[1] : visible);
207929
+ } catch {
207930
+ outputError("TEXT_JSON");
207931
+ }
207932
+ return parseObservation(value, imageId, mode);
207933
+ }
207851
207934
  var IMAGE_PROMPT, MODES, MARKER;
207852
207935
  var init_contract = __esm({
207853
207936
  "../linkque-agent-runtime/dist/esm/impl/plugin/imageUnderstanding/contract.js"() {
@@ -207970,19 +208053,11 @@ function createImageTool(image, input, options, rules) {
207970
208053
  }
207971
208054
  let envelope;
207972
208055
  try {
207973
- envelope = JSON.parse(Buffer.from(await boundedBody(response, 128 * 1024)).toString("utf8"));
207974
- } catch {
207975
- imageError("IMAGE_OUTPUT_INVALID");
207976
- }
207977
- if (!record3(envelope) || typeof envelope.id !== "string" || !envelope.id || envelope.type !== "message" || envelope.role !== "assistant" || envelope.model !== "linkque-image-understanding" || envelope.stop_reason !== "end_turn" || !record3(envelope.usage) || !["input_tokens", "output_tokens"].every((k) => Number.isSafeInteger(envelope.usage && envelope.usage[k]) && Number(envelope.usage[k]) >= 0) || !Array.isArray(envelope.content) || !envelope.content.length || !envelope.content.every((block) => record3(block) && block.type === "text" && typeof block.text === "string"))
207978
- imageError("IMAGE_OUTPUT_INVALID");
207979
- let value;
207980
- try {
207981
- value = JSON.parse(envelope.content.map((block) => block.text).join(""));
208056
+ envelope = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await boundedBody(response, 128 * 1024)));
207982
208057
  } catch {
207983
- imageError("IMAGE_OUTPUT_INVALID");
208058
+ imageError("IMAGE_OUTPUT_INVALID_ENVELOPE_JSON");
207984
208059
  }
207985
- return parseObservation(value, image.id, parsed.mode);
208060
+ return parseImageEnvelope(envelope, image.id, parsed.mode);
207986
208061
  } catch (error40) {
207987
208062
  if (signal.aborted)
207988
208063
  imageError("IMAGE_CANCELLED");
@@ -208929,7 +209004,7 @@ init_createKnowledgeTools();
208929
209004
  init_noopWebSearchPort();
208930
209005
  init_noopRuntimeTelemetry();
208931
209006
  init_runtimeObservation();
208932
- init_telemetryEnums();
209007
+ init_telemetryEnums2();
208933
209008
 
208934
209009
  // ../../node_modules/zod/v4/mini/parse.js
208935
209010
  init_core2();
@@ -215413,7 +215488,8 @@ init_conversationBridge();
215413
215488
  init_config();
215414
215489
 
215415
215490
  // ../linkque-agent-runtime/dist/esm/impl/telemetry/otelRuntimeTelemetry.js
215416
- init_telemetryEnums();
215491
+ init_telemetry();
215492
+ init_telemetryEnums2();
215417
215493
  var import_node_crypto5 = require("node:crypto");
215418
215494
  init_esm6();
215419
215495
  var import_sdk_trace_base = __toESM(require_index_shim(), 1);
@@ -215424,7 +215500,8 @@ var import_otlp_transformer = __toESM(require_src7(), 1);
215424
215500
  init_noopRuntimeTelemetry();
215425
215501
 
215426
215502
  // ../linkque-agent-runtime/dist/esm/impl/telemetry/identityQueue.js
215427
- init_telemetryEnums();
215503
+ init_telemetry();
215504
+ init_telemetryEnums2();
215428
215505
  var import_node_async_hooks = require("node:async_hooks");
215429
215506
  init_esm6();
215430
215507
  var import_core11 = __toESM(require_src(), 1);
@@ -215752,7 +215829,7 @@ var IdentityQueue = class {
215752
215829
  };
215753
215830
 
215754
215831
  // ../linkque-agent-runtime/dist/esm/impl/telemetry/attributes.js
215755
- init_telemetryEnums();
215832
+ init_telemetry();
215756
215833
  var MAX_ATTRIBUTE_COUNT = 64;
215757
215834
  var MAX_STRING_LENGTH = 256;
215758
215835
  var MAX_ARRAY_LENGTH = 16;