@probelabs/probe 0.6.0-rc335 → 0.6.0-rc337

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/cjs/index.cjs CHANGED
@@ -28791,7 +28791,7 @@ var init_dist5 = __esm({
28791
28791
  return combineHeaders(await resolve(this.config.headers), headers);
28792
28792
  }
28793
28793
  async doGenerate(options) {
28794
- var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
28794
+ var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
28795
28795
  const {
28796
28796
  command: args,
28797
28797
  warnings,
@@ -28820,10 +28820,12 @@ var init_dist5 = __esm({
28820
28820
  let isJsonResponseFromTool = false;
28821
28821
  const jsonObjectTextExtractor = usesJsonInstruction ? new JsonObjectTextExtractor() : void 0;
28822
28822
  for (const part of response.output.message.content) {
28823
- if (part.text != null) {
28823
+ const citationText = (_b16 = (_a17 = part.citationsContent) == null ? void 0 : _a17.content) == null ? void 0 : _b16.map((generatedContent) => generatedContent.text).filter((text2) => text2 != null).join("");
28824
+ const text = (_c = part.text) != null ? _c : citationText ? citationText : void 0;
28825
+ if (text != null) {
28824
28826
  content.push({
28825
28827
  type: "text",
28826
- text: (_a17 = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(part.text)) != null ? _a17 : part.text
28828
+ text: (_d = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(text)) != null ? _d : text
28827
28829
  });
28828
28830
  }
28829
28831
  if (part.reasoningContent) {
@@ -28846,7 +28848,7 @@ var init_dist5 = __esm({
28846
28848
  text: "",
28847
28849
  providerMetadata: {
28848
28850
  bedrock: {
28849
- redactedData: (_b16 = part.reasoningContent.redactedReasoning.data) != null ? _b16 : ""
28851
+ redactedData: (_e = part.reasoningContent.redactedReasoning.data) != null ? _e : ""
28850
28852
  }
28851
28853
  }
28852
28854
  });
@@ -28872,17 +28874,17 @@ var init_dist5 = __esm({
28872
28874
  });
28873
28875
  } else {
28874
28876
  const isMistral = isMistralModel(this.modelId);
28875
- const rawToolCallId = (_d = (_c = part.toolUse) == null ? void 0 : _c.toolUseId) != null ? _d : this.config.generateId();
28877
+ const rawToolCallId = (_g = (_f = part.toolUse) == null ? void 0 : _f.toolUseId) != null ? _g : this.config.generateId();
28876
28878
  content.push({
28877
28879
  type: "tool-call",
28878
28880
  toolCallId: normalizeToolCallId(rawToolCallId, isMistral),
28879
- toolName: (_f = (_e = part.toolUse) == null ? void 0 : _e.name) != null ? _f : `tool-${this.config.generateId()}`,
28880
- input: JSON.stringify((_h = (_g = part.toolUse) == null ? void 0 : _g.input) != null ? _h : {})
28881
+ toolName: (_i = (_h = part.toolUse) == null ? void 0 : _h.name) != null ? _i : `tool-${this.config.generateId()}`,
28882
+ input: JSON.stringify((_k = (_j = part.toolUse) == null ? void 0 : _j.input) != null ? _k : {})
28881
28883
  });
28882
28884
  }
28883
28885
  }
28884
28886
  }
28885
- const stopSequence = (_k = (_j = (_i = response.additionalModelResponseFields) == null ? void 0 : _i.delta) == null ? void 0 : _j.stop_sequence) != null ? _k : null;
28887
+ const stopSequence = (_n = (_m = (_l = response.additionalModelResponseFields) == null ? void 0 : _l.delta) == null ? void 0 : _m.stop_sequence) != null ? _n : null;
28886
28888
  const providerMetadata = response.trace || response.usage || response.performanceConfig || response.serviceTier || isJsonResponseFromTool || stopSequence ? {
28887
28889
  bedrock: {
28888
28890
  ...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
@@ -28892,7 +28894,7 @@ var init_dist5 = __esm({
28892
28894
  ...response.serviceTier && {
28893
28895
  serviceTier: response.serviceTier
28894
28896
  },
28895
- ...(((_l = response.usage) == null ? void 0 : _l.cacheWriteInputTokens) != null || ((_m = response.usage) == null ? void 0 : _m.cacheDetails) != null) && {
28897
+ ...(((_o = response.usage) == null ? void 0 : _o.cacheWriteInputTokens) != null || ((_p = response.usage) == null ? void 0 : _p.cacheDetails) != null) && {
28896
28898
  usage: {
28897
28899
  ...response.usage.cacheWriteInputTokens != null && {
28898
28900
  cacheWriteInputTokens: response.usage.cacheWriteInputTokens
@@ -28913,11 +28915,11 @@ var init_dist5 = __esm({
28913
28915
  response.stopReason,
28914
28916
  isJsonResponseFromTool
28915
28917
  ),
28916
- raw: (_n = response.stopReason) != null ? _n : void 0
28918
+ raw: (_q = response.stopReason) != null ? _q : void 0
28917
28919
  },
28918
28920
  usage: convertBedrockUsage(response.usage),
28919
28921
  response: {
28920
- id: (_o = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _o : void 0,
28922
+ id: (_r = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _r : void 0,
28921
28923
  timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
28922
28924
  modelId: this.modelId,
28923
28925
  headers: responseHeaders
@@ -29358,6 +29360,13 @@ var init_dist5 = __esm({
29358
29360
  content: external_exports.array(
29359
29361
  external_exports.object({
29360
29362
  text: external_exports.string().nullish(),
29363
+ citationsContent: external_exports.object({
29364
+ content: external_exports.array(
29365
+ external_exports.object({
29366
+ text: external_exports.string().nullish()
29367
+ })
29368
+ ).nullish()
29369
+ }).nullish(),
29361
29370
  toolUse: BedrockToolUseSchema.nullish(),
29362
29371
  reasoningContent: external_exports.union([
29363
29372
  external_exports.object({
@@ -29820,7 +29829,7 @@ var init_dist5 = __esm({
29820
29829
  details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
29821
29830
  preview: external_exports.unknown().optional()
29822
29831
  });
29823
- VERSION3 = true ? "4.0.169" : "0.0.0-test";
29832
+ VERSION3 = true ? "4.0.172" : "0.0.0-test";
29824
29833
  bedrockRerankingResponseSchema = lazySchema(
29825
29834
  () => zodSchema(
29826
29835
  external_exports.object({
@@ -90810,6 +90819,7 @@ var require_utils2 = __commonJS({
90810
90819
  "use strict";
90811
90820
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
90812
90821
  var isIPv42 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
90822
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
90813
90823
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
90814
90824
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
90815
90825
  var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
@@ -91275,8 +91285,12 @@ var require_utils2 = __commonJS({
91275
91285
  uriTokens.push(host);
91276
91286
  }
91277
91287
  if (typeof component.port === "number" || typeof component.port === "string") {
91288
+ const port = String(component.port);
91289
+ if (!isPort(port)) {
91290
+ throw new TypeError("URI port is malformed.");
91291
+ }
91278
91292
  uriTokens.push(":");
91279
- uriTokens.push(String(component.port));
91293
+ uriTokens.push(port);
91280
91294
  }
91281
91295
  return uriTokens.length ? uriTokens.join("") : void 0;
91282
91296
  }
@@ -91719,12 +91733,15 @@ var require_fast_uri = __commonJS({
91719
91733
  }
91720
91734
  return false;
91721
91735
  }
91736
+ function isIPLiteral(host) {
91737
+ return host[0] === "[" && host[host.length - 1] === "]";
91738
+ }
91722
91739
  function hasMalformedComponentPercentEncoding(matches) {
91723
91740
  const host = matches[4];
91724
- return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host[0] === "[" && host[host.length - 1] === "]") && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
91741
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
91725
91742
  }
91726
91743
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
91727
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
91744
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
91728
91745
  try {
91729
91746
  parsed.host = new URL("http://" + parsed.host).hostname;
91730
91747
  } catch (e) {
@@ -91811,10 +91828,11 @@ var require_fast_uri = __commonJS({
91811
91828
  if (parsed.host) {
91812
91829
  const ipv4result = isIPv42(parsed.host);
91813
91830
  if (ipv4result === false) {
91814
- const bracketedIPLiteral = parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
91831
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
91832
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
91815
91833
  const ipv6result = normalizeIPv6(parsed.host);
91816
91834
  isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
91817
- malformedIPLiteral = bracketedIPLiteral && ipv6result.error === true;
91835
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
91818
91836
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
91819
91837
  if (malformedIPLiteral) {
91820
91838
  parsed.error = parsed.error || "URI host is malformed.";
@@ -91837,7 +91855,9 @@ var require_fast_uri = __commonJS({
91837
91855
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
91838
91856
  }
91839
91857
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
91840
- malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
91858
+ if (!malformedIPLiteral) {
91859
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
91860
+ }
91841
91861
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
91842
91862
  if (uri.indexOf("%") !== -1) {
91843
91863
  if (parsed.host !== void 0 && !malformedIPLiteral) {
@@ -106808,7 +106828,7 @@ var init_governed_codex_profile = __esm({
106808
106828
  function governedAttestationPredicate(error40) {
106809
106829
  return error40 instanceof TypeError ? GOVERNED_ATTESTATION_ERROR_PREDICATES.get(error40.message) ?? null : null;
106810
106830
  }
106811
- function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
106831
+ function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null) {
106812
106832
  return new GovernedAnswerFailure(
106813
106833
  stage,
106814
106834
  nativeEventFailureBoundary,
@@ -106816,21 +106836,23 @@ function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeE
106816
106836
  nativeEventFailureCorrelationOperand,
106817
106837
  nativeEventFailureAttestationPredicate,
106818
106838
  schemaResultValidationSubreason,
106819
- schemaResultValidationKeyword
106839
+ schemaResultValidationKeyword,
106840
+ providerEngineFailureBoundary
106820
106841
  );
106821
106842
  }
106822
- function normalizeGovernedAnswerFailure(error40, fallback = "unknown", nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
106843
+ function normalizeGovernedAnswerFailure(error40, fallback = "unknown", nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null, nativeEventFailureAttestationPredicate = null) {
106823
106844
  return error40 instanceof GovernedAnswerFailure ? error40 : governedAnswerFailure(
106824
106845
  fallback,
106825
106846
  nativeEventFailureBoundary,
106826
106847
  nativeEventFailureSubreason,
106827
106848
  nativeEventFailureCorrelationOperand,
106828
- fallback === "native_event_grammar" && nativeEventFailureBoundary === "live_envelope_session" && nativeEventFailureSubreason === "attestation" ? governedAttestationPredicate(error40) : null,
106849
+ fallback === "native_event_grammar" && nativeEventFailureBoundary === "live_envelope_session" && nativeEventFailureSubreason === "attestation" ? nativeEventFailureAttestationPredicate ?? governedAttestationPredicate(error40) : null,
106829
106850
  schemaResultValidationSubreason,
106830
- schemaResultValidationKeyword
106851
+ schemaResultValidationKeyword,
106852
+ providerEngineFailureBoundary
106831
106853
  );
106832
106854
  }
106833
- var GOVERNED_ANSWER_FAILURE_STAGES, GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_SUBREASONS, GOVERNED_NATIVE_EVENT_FAILURE_CORRELATION_OPERANDS, GOVERNED_NATIVE_EVENT_FAILURE_ATTESTATION_PREDICATES, GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS, GOVERNED_SCHEMA_RESULT_VALIDATION_KEYWORDS, GOVERNED_ATTESTATION_ERROR_PREDICATES, GovernedAnswerFailure;
106855
+ var GOVERNED_ANSWER_FAILURE_STAGES, GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_SUBREASONS, GOVERNED_NATIVE_EVENT_FAILURE_CORRELATION_OPERANDS, GOVERNED_NATIVE_EVENT_FAILURE_ATTESTATION_PREDICATES, GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS, GOVERNED_SCHEMA_RESULT_VALIDATION_KEYWORDS, GOVERNED_ATTESTATION_ERROR_PREDICATES, GovernedAnswerFailure;
106834
106856
  var init_governed_answer_failure = __esm({
106835
106857
  "src/agent/engines/governed-answer-failure.js"() {
106836
106858
  "use strict";
@@ -106838,8 +106860,10 @@ var init_governed_answer_failure = __esm({
106838
106860
  "native_event_grammar",
106839
106861
  "provider_engine",
106840
106862
  "schema_result_validation",
106863
+ "internal_contract",
106841
106864
  "unknown"
106842
106865
  ]);
106866
+ GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES = /* @__PURE__ */ new Set(["acquire", "query", "close"]);
106843
106867
  GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES = /* @__PURE__ */ new Set([
106844
106868
  "raw_item_predicate",
106845
106869
  "live_envelope_session"
@@ -106883,7 +106907,9 @@ var init_governed_answer_failure = __esm({
106883
106907
  "value_shape",
106884
106908
  "kind",
106885
106909
  "native_tool_evidence",
106886
- "internal_contract"
106910
+ "internal_contract",
106911
+ "invocation_attestation",
106912
+ "native_capability_aggregate"
106887
106913
  ]);
106888
106914
  GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS = /* @__PURE__ */ new Set([
106889
106915
  "response_json",
@@ -106966,7 +106992,7 @@ var init_governed_answer_failure = __esm({
106966
106992
  ["Invalid profile capability overlap", "internal_contract"]
106967
106993
  ]);
106968
106994
  GovernedAnswerFailure = class extends Error {
106969
- constructor(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
106995
+ constructor(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null) {
106970
106996
  super();
106971
106997
  delete this.stack;
106972
106998
  const answerFailureStage = GOVERNED_ANSWER_FAILURE_STAGES.has(stage) ? stage : "unknown";
@@ -106975,6 +107001,10 @@ var init_governed_answer_failure = __esm({
106975
107001
  value: answerFailureStage,
106976
107002
  enumerable: true
106977
107003
  });
107004
+ if (answerFailureStage === "provider_engine") Object.defineProperty(this, "providerEngineFailureBoundary", {
107005
+ value: GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES.has(providerEngineFailureBoundary) ? providerEngineFailureBoundary : null,
107006
+ enumerable: true
107007
+ });
106978
107008
  if (answerFailureStage === "native_event_grammar") Object.defineProperty(this, "nativeEventFailureBoundary", {
106979
107009
  value: GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES.has(nativeEventFailureBoundary) ? nativeEventFailureBoundary : null,
106980
107010
  enumerable: true
@@ -107985,7 +108015,9 @@ async function createCodexEngine(options = {}) {
107985
108015
  }
107986
108016
  });
107987
108017
  if (opts.abortSignal) {
107988
- if (opts.abortSignal.aborted) throw new Error("Codex query cancelled");
108018
+ if (opts.abortSignal.aborted) {
108019
+ throw governedProfile ? governedAnswerFailure("provider_engine", null, null, null, null, null, null, "query") : new Error("Codex query cancelled");
108020
+ }
107989
108021
  abortHandler = () => {
107990
108022
  void cleanup(new Error("Codex query cancelled")).catch(() => {
107991
108023
  });
@@ -108018,7 +108050,16 @@ async function createCodexEngine(options = {}) {
108018
108050
  try {
108019
108051
  result = await resultPromise;
108020
108052
  } catch (error40) {
108021
- throw governedProfile ? governedAnswerFailure(evidenceFailure ? "unknown" : "provider_engine") : error40;
108053
+ throw governedProfile ? evidenceFailure || normalizeGovernedAnswerFailure(
108054
+ error40,
108055
+ "provider_engine",
108056
+ null,
108057
+ null,
108058
+ null,
108059
+ null,
108060
+ null,
108061
+ "query"
108062
+ ) : error40;
108022
108063
  }
108023
108064
  eventHandlers.delete(reqId);
108024
108065
  governedEvidenceHandlers.delete(reqId);
@@ -108036,17 +108077,50 @@ async function createCodexEngine(options = {}) {
108036
108077
  profile: governedProfile,
108037
108078
  events: governedProfile.version === "probe.governed-codex-profile/v2" ? [collected.sessionEvent, collected.capabilities.nativeTools] : [collected.sessionEvent]
108038
108079
  });
108080
+ } catch (error40) {
108081
+ throw normalizeGovernedAnswerFailure(
108082
+ error40,
108083
+ "native_event_grammar",
108084
+ "live_envelope_session",
108085
+ "attestation"
108086
+ );
108087
+ }
108088
+ try {
108039
108089
  probeMcpCallCount = governedProfile.version === "probe.governed-codex-profile/v2" ? governedProbeMcpCallCount(mcpServer?.getGovernedCallEvidence()) : 0;
108040
108090
  } catch (error40) {
108041
- throw normalizeGovernedAnswerFailure(error40, "native_event_grammar", "live_envelope_session", "attestation");
108042
- }
108043
- attestation = hasInvocationDigest ? externalBoundReceipt(internal, dispatch, invocationDigest, {
108044
- nativeCallCount: collected.capabilities.nativeTools.total,
108045
- probeMcpCallCount
108046
- }) : externalReceipt(internal, {
108047
- nativeCallCount: collected.capabilities.nativeTools.total,
108048
- probeMcpCallCount
108049
- });
108091
+ throw normalizeGovernedAnswerFailure(
108092
+ error40,
108093
+ "native_event_grammar",
108094
+ "live_envelope_session",
108095
+ "attestation",
108096
+ null,
108097
+ null,
108098
+ null,
108099
+ null,
108100
+ "native_capability_aggregate"
108101
+ );
108102
+ }
108103
+ try {
108104
+ attestation = hasInvocationDigest ? externalBoundReceipt(internal, dispatch, invocationDigest, {
108105
+ nativeCallCount: collected.capabilities.nativeTools.total,
108106
+ probeMcpCallCount
108107
+ }) : externalReceipt(internal, {
108108
+ nativeCallCount: collected.capabilities.nativeTools.total,
108109
+ probeMcpCallCount
108110
+ });
108111
+ } catch (error40) {
108112
+ throw normalizeGovernedAnswerFailure(
108113
+ error40,
108114
+ "native_event_grammar",
108115
+ "live_envelope_session",
108116
+ "attestation",
108117
+ null,
108118
+ null,
108119
+ null,
108120
+ null,
108121
+ "invocation_attestation"
108122
+ );
108123
+ }
108050
108124
  session.setConversationId(collected.sessionEvent.params.msg.session_id);
108051
108125
  }
108052
108126
  if (result && result.content && Array.isArray(result.content)) {
@@ -108083,7 +108157,7 @@ async function createCodexEngine(options = {}) {
108083
108157
  }
108084
108158
  };
108085
108159
  } catch (error40) {
108086
- if (governedProfile) error40 = normalizeGovernedAnswerFailure(error40, "unknown");
108160
+ if (governedProfile) error40 = normalizeGovernedAnswerFailure(error40, "internal_contract");
108087
108161
  queryError = error40;
108088
108162
  if (debug) {
108089
108163
  console.error("[DEBUG] Codex query error:", error40);
@@ -108098,7 +108172,16 @@ async function createCodexEngine(options = {}) {
108098
108172
  try {
108099
108173
  await cleanup();
108100
108174
  } catch (cleanupError) {
108101
- if (!queryError) throw cleanupError;
108175
+ if (!queryError) throw normalizeGovernedAnswerFailure(
108176
+ cleanupError,
108177
+ "provider_engine",
108178
+ null,
108179
+ null,
108180
+ null,
108181
+ null,
108182
+ null,
108183
+ "close"
108184
+ );
108102
108185
  }
108103
108186
  }
108104
108187
  }
@@ -110185,7 +110268,6 @@ var init_ProbeAgent = __esm({
110185
110268
  agent: this,
110186
110269
  // Pass reference to ProbeAgent for tool access
110187
110270
  systemPrompt,
110188
- customPrompt: this.customPrompt,
110189
110271
  sessionId: this.options?.sessionId,
110190
110272
  debug: this.debug,
110191
110273
  allowedTools: this.allowedTools,
@@ -110202,7 +110284,18 @@ var init_ProbeAgent = __esm({
110202
110284
  }
110203
110285
  return this.engine;
110204
110286
  } catch (error40) {
110205
- if (this.governedCodexProfile) throw error40;
110287
+ if (this.governedCodexProfile) {
110288
+ throw normalizeGovernedAnswerFailure(
110289
+ error40,
110290
+ "provider_engine",
110291
+ null,
110292
+ null,
110293
+ null,
110294
+ null,
110295
+ null,
110296
+ "acquire"
110297
+ );
110298
+ }
110206
110299
  console.warn("[WARNING] Failed to load Codex CLI engine:", error40.message);
110207
110300
  console.warn("[WARNING] Falling back to Vercel AI SDK");
110208
110301
  this.clientApiProvider = null;
@@ -110883,7 +110976,7 @@ Workspace: ${this.allowedFolders.join(", ")}`;
110883
110976
  const { prompt } = this._prepareGovernedAnswerPrompt(message, options);
110884
110977
  const systemPrompt = await this._getCachedCodexNativeSystemPrompt();
110885
110978
  const { previewGovernedCodexInitialDispatch: previewGovernedCodexInitialDispatch2 } = await Promise.resolve().then(() => (init_codex(), codex_exports));
110886
- return previewGovernedCodexInitialDispatch2({ systemPrompt, customPrompt: this.customPrompt, prompt });
110979
+ return previewGovernedCodexInitialDispatch2({ systemPrompt, prompt });
110887
110980
  }
110888
110981
  /**
110889
110982
  * Get the system message with instructions for the AI (XML Tool Format)
@@ -111073,38 +111166,99 @@ You are working with a workspace. Available paths: ${workspaceDesc}
111073
111166
  try {
111074
111167
  try {
111075
111168
  engine = await this.getEngine();
111076
- } catch {
111077
- throw governedAnswerFailure("provider_engine");
111169
+ } catch (error40) {
111170
+ throw normalizeGovernedAnswerFailure(
111171
+ error40,
111172
+ "provider_engine",
111173
+ null,
111174
+ null,
111175
+ null,
111176
+ null,
111177
+ null,
111178
+ "acquire"
111179
+ );
111078
111180
  }
111079
- if (!engine?.query) throw governedAnswerFailure("provider_engine");
111181
+ if (!engine?.query) throw governedAnswerFailure("internal_contract");
111080
111182
  const candidateChunks = [];
111081
111183
  let runtimeAttestation;
111082
111184
  let attestationCount = 0;
111083
111185
  let nativeToolBatch;
111084
111186
  let nativeToolBatchCount = 0;
111085
111187
  const queryOptions = hasInvocationDigest ? { abortSignal: this._abortController.signal, invocationDigest } : { abortSignal: this._abortController.signal };
111086
- for await (const chunk of engine.query(prompt, queryOptions)) {
111087
- if (chunk.type === "text" && chunk.content) candidateChunks.push(chunk.content);
111088
- else if (chunk.type === "metadata" && chunk.data?.attestation) {
111089
- runtimeAttestation = chunk.data.attestation;
111090
- attestationCount++;
111091
- } else if (chunk.type === "toolBatch") {
111092
- nativeToolBatch = chunk;
111093
- nativeToolBatchCount++;
111094
- } else if (chunk.type === "error") throw normalizeGovernedAnswerFailure(chunk.error, "unknown");
111188
+ try {
111189
+ for await (const chunk of engine.query(prompt, queryOptions)) {
111190
+ if (chunk.type === "text" && chunk.content) candidateChunks.push(chunk.content);
111191
+ else if (chunk.type === "metadata" && chunk.data?.attestation) {
111192
+ runtimeAttestation = chunk.data.attestation;
111193
+ attestationCount++;
111194
+ } else if (chunk.type === "toolBatch") {
111195
+ nativeToolBatch = chunk;
111196
+ nativeToolBatchCount++;
111197
+ } else if (chunk.type === "error") {
111198
+ throw normalizeGovernedAnswerFailure(
111199
+ chunk.error,
111200
+ "provider_engine",
111201
+ null,
111202
+ null,
111203
+ null,
111204
+ null,
111205
+ null,
111206
+ "query"
111207
+ );
111208
+ }
111209
+ }
111210
+ } catch (error40) {
111211
+ throw normalizeGovernedAnswerFailure(
111212
+ error40,
111213
+ "provider_engine",
111214
+ null,
111215
+ null,
111216
+ null,
111217
+ null,
111218
+ null,
111219
+ "query"
111220
+ );
111095
111221
  }
111096
111222
  if (hasInvocationDigest) {
111097
111223
  const expectedAttestation = this.governedCodexProfile?.version === "probe.governed-codex-profile/v2" ? "probe.governed-codex-attestation/v3" : "probe.governed-codex-attestation/v2";
111098
111224
  if (attestationCount !== 1 || runtimeAttestation?.version !== expectedAttestation || runtimeAttestation?.executionContext?.source !== "caller" || runtimeAttestation?.executionContext?.invocationDigest !== invocationDigest) {
111099
- throw new Error("Expected exactly one matching governed invocation attestation");
111225
+ throw governedAnswerFailure(
111226
+ "native_event_grammar",
111227
+ "live_envelope_session",
111228
+ "attestation",
111229
+ null,
111230
+ "invocation_attestation"
111231
+ );
111100
111232
  }
111101
- } else if (attestationCount !== 1) throw new Error(`Expected exactly one governed runtime attestation; received ${attestationCount}`);
111233
+ } else if (attestationCount !== 1) {
111234
+ throw governedAnswerFailure(
111235
+ "native_event_grammar",
111236
+ "live_envelope_session",
111237
+ "attestation",
111238
+ null,
111239
+ "invocation_attestation"
111240
+ );
111241
+ }
111102
111242
  if (this.governedCodexProfile?.version === "probe.governed-codex-profile/v2") {
111103
111243
  if (nativeToolBatchCount !== 1 || !Number.isSafeInteger(nativeToolBatch?.total) || !Array.isArray(nativeToolBatch?.tools) || nativeToolBatch.total !== runtimeAttestation?.observed?.nativeTools?.total || JSON.stringify(nativeToolBatch.tools) !== JSON.stringify(runtimeAttestation?.observed?.nativeTools?.tools)) {
111104
- throw new Error("Expected exactly one matching governed native capability aggregate");
111244
+ throw governedAnswerFailure(
111245
+ "native_event_grammar",
111246
+ "live_envelope_session",
111247
+ "attestation",
111248
+ null,
111249
+ "native_capability_aggregate"
111250
+ );
111105
111251
  }
111106
111252
  for (const toolEvent of nativeToolBatch.tools) this.events.emit("toolCall", toolEvent);
111107
- } else if (nativeToolBatchCount !== 0) throw new Error("Unexpected governed native capability aggregate");
111253
+ } else if (nativeToolBatchCount !== 0) {
111254
+ throw governedAnswerFailure(
111255
+ "native_event_grammar",
111256
+ "live_envelope_session",
111257
+ "attestation",
111258
+ null,
111259
+ "native_capability_aggregate"
111260
+ );
111261
+ }
111108
111262
  const validation = validateJsonResponse(candidateChunks.join(""), { debug: this.debug, schema });
111109
111263
  if (!validation.isValid) throw governedSchemaResultValidationFailure(validation);
111110
111264
  if (hasResultIdentity) {
@@ -111120,14 +111274,23 @@ You are working with a workspace. Available paths: ${workspaceDesc}
111120
111274
  }
111121
111275
  return { data: validation.parsed, runtimeAttestation };
111122
111276
  } catch (error40) {
111123
- answerFailure = normalizeGovernedAnswerFailure(error40, "unknown");
111277
+ answerFailure = normalizeGovernedAnswerFailure(error40, "internal_contract");
111124
111278
  throw answerFailure;
111125
111279
  } finally {
111126
111280
  if (engine) {
111127
111281
  try {
111128
111282
  await engine.close();
111129
- } catch {
111130
- if (!answerFailure) throw governedAnswerFailure("unknown");
111283
+ } catch (error40) {
111284
+ if (!answerFailure) throw normalizeGovernedAnswerFailure(
111285
+ error40,
111286
+ "provider_engine",
111287
+ null,
111288
+ null,
111289
+ null,
111290
+ null,
111291
+ null,
111292
+ "close"
111293
+ );
111131
111294
  }
111132
111295
  }
111133
111296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc335",
3
+ "version": "0.6.0-rc337",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",