larkin 0.5.10 → 0.5.12

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.
@@ -9,7 +9,7 @@ Runtime package versions: 97
9
9
  | Package | Version | Relationship | Declared license | License texts (SHA-256) | Lock integrity |
10
10
  | --- | ---: | --- | --- | --- | --- |
11
11
  | @larksuite/channel | 0.4.1 | runtime direct | MIT | LICENSE (c969fc7e3af68e6bf40b0d8dd9c3dcc377eb685a2139535b203b39fdcad739ee) | sha512-9xklkzGEnME9MCCKlSzgG0FERJV4HlNX52hthytpxxP2oqH5S8lQBixPsHYU0AQ8SBfzP+LaGz5QaDOlP4EY0A== |
12
- | @larksuiteoapi/node-sdk | 1.72.0 | runtime transitive | MIT | LICENSE (81f1894dbe3c15ce42310bdc8a39c664f270328b82e8c64c03f55de6aac626ac) | sha512-8oKnaTxRFRNPQfeeG69yafdLzWvvrvXlIqX3QRvozR1/6kvZyi9iMhp6lwC+hMgJA/GCFwMZRadkJzlUE+kyvQ== |
12
+ | @larksuiteoapi/node-sdk | 1.74.0 | runtime transitive | MIT | LICENSE (81f1894dbe3c15ce42310bdc8a39c664f270328b82e8c64c03f55de6aac626ac) | sha512-K2WoGy6x97u2kPPSFsu0v9X8CY+0q4OwO3rhXiOSRXYjGS7ovydFpEH07AS5VYcBnbQCoc5sGezo0IEGVViuoA== |
13
13
  | @opentelemetry/api | 1.9.1 | runtime direct | Apache-2.0 | LICENSE (c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4) | sha512-gLyJlPHPZYdAk1JENA9LeHejZe1Ti77/pTeFm/nMXmQH/HFZlcS/O2XJB+L8fkbrNSqhdtlvjBVjxwUYanNH5Q== |
14
14
  | @opentelemetry/context-async-hooks | 2.10.0 | runtime transitive | Apache-2.0 | LICENSE (c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4) | sha512-bvyMcgLEkozzSzpEEEo1OMoeQ97bxj6Qs2uN3mPrSdDvObMI1myffD/BPqcLlzZO9//d1SqQA/WPw7Cz2AiqhA== |
15
15
  | @opentelemetry/core | 2.10.0 | runtime transitive | Apache-2.0 | LICENSE (c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4) | sha512-/wNZ8twnEQQA4HoHu22+vcsdru6pWPWxW+7w+FlxT6Id7PE/WIbZmVKkte+PF72e0F2dnImFeHD2syyE1Mw6MQ== |
@@ -103,8 +103,11 @@ class HostChannelBusiness {
103
103
  * Replace the SDK's action-value TTL dedup handler after channel.connect().
104
104
  * Durable callback event_id ownership lives in InteractionStateMachine, so
105
105
  * retries receive the same response while later state-version clicks remain legal.
106
+ * Unregister first (node-sdk >= 1.74, issue #220) so the deliberate replacement
107
+ * is not reported as a duplicate registration.
106
108
  */
107
109
  registerCardActions(agent, dispatcher) {
110
+ dispatcher.unregister?.("card.action.trigger");
108
111
  dispatcher.register({
109
112
  "card.action.trigger": async (raw) => {
110
113
  const event = (0, channel_1.normalizeCardAction)(raw, { includeRaw: true });
@@ -100,8 +100,11 @@ export class HostChannelBusiness {
100
100
  * Replace the SDK's action-value TTL dedup handler after channel.connect().
101
101
  * Durable callback event_id ownership lives in InteractionStateMachine, so
102
102
  * retries receive the same response while later state-version clicks remain legal.
103
+ * Unregister first (node-sdk >= 1.74, issue #220) so the deliberate replacement
104
+ * is not reported as a duplicate registration.
103
105
  */
104
106
  registerCardActions(agent, dispatcher) {
107
+ dispatcher.unregister?.("card.action.trigger");
105
108
  dispatcher.register({
106
109
  "card.action.trigger": async (raw) => {
107
110
  const event = normalizeCardAction(raw, { includeRaw: true });
@@ -1484,7 +1484,11 @@ function createHostShell({ env = process.env, runtimeHost, channelPackage, event
1484
1484
  }
1485
1485
  else {
1486
1486
  const category = message.event.errorCategory || "provider";
1487
- hostState.recordStatusError(agent, `${category}: Runtime input failed ${message.event.retryable ? "retryably" : "non-retryably"}; inspect delivery health and Runtime/provider configuration`);
1487
+ // Surface the provider's finish reason when the Runtime text names one we
1488
+ // recognize (allow-listed token only; raw Runtime text never reaches status).
1489
+ const finishReason = (0, provider_error_classifier_js_1.providerFinishReason)(message.event.message);
1490
+ const detail = finishReason ? ` (provider finish_reason=${finishReason})` : "";
1491
+ hostState.recordStatusError(agent, `${category}: Runtime input failed ${message.event.retryable ? "retryably" : "non-retryably"}${detail}; inspect delivery health and Runtime/provider configuration`);
1488
1492
  }
1489
1493
  }
1490
1494
  };
@@ -17,7 +17,7 @@ import { HostChannelBusiness } from "./host-channel-business.mjs";
17
17
  import { HostInteractionOrchestrator } from "./interaction-orchestrator.mjs";
18
18
  import { targetFor } from "./message-policy.mjs";
19
19
  import { authFailureAppliesTo, parsePersistedAuthFailure, providerAuthenticationFailureReadiness, readinessForPersistedAuthFailure, RuntimePrerequisiteError, } from "../runtime/runtime-readiness.mjs";
20
- import { safeProviderDiagnostic } from "../runtime/provider-error-classifier.mjs";
20
+ import { providerFinishReason, safeProviderDiagnostic } from "../runtime/provider-error-classifier.mjs";
21
21
  import { readDocumentCommentSubscription, verifyCallbackProbe } from "../platform/callback-capability.mjs";
22
22
  import { loadConfig, resolveInboxAuditSchedule, resolveMentionPolicy } from "../platform/config.mjs";
23
23
  import { processCommandToken } from "../app/internal-command.mjs";
@@ -1444,7 +1444,11 @@ export function createHostShell({ env = process.env, runtimeHost, channelPackage
1444
1444
  }
1445
1445
  else {
1446
1446
  const category = message.event.errorCategory || "provider";
1447
- hostState.recordStatusError(agent, `${category}: Runtime input failed ${message.event.retryable ? "retryably" : "non-retryably"}; inspect delivery health and Runtime/provider configuration`);
1447
+ // Surface the provider's finish reason when the Runtime text names one we
1448
+ // recognize (allow-listed token only; raw Runtime text never reaches status).
1449
+ const finishReason = providerFinishReason(message.event.message);
1450
+ const detail = finishReason ? ` (provider finish_reason=${finishReason})` : "";
1451
+ hostState.recordStatusError(agent, `${category}: Runtime input failed ${message.event.retryable ? "retryably" : "non-retryably"}${detail}; inspect delivery health and Runtime/provider configuration`);
1448
1452
  }
1449
1453
  }
1450
1454
  };
@@ -4,6 +4,7 @@ exports.INTERNAL_CONTEXT_WINDOW_PROJECTION_REASON = exports.CANONICAL_CONTEXT_WI
4
4
  exports.safeProviderDiagnostic = safeProviderDiagnostic;
5
5
  exports.buildStrictProviderErrorInput = buildStrictProviderErrorInput;
6
6
  exports.classifyStrictProviderError = classifyStrictProviderError;
7
+ exports.providerFinishReason = providerFinishReason;
7
8
  exports.CODEX_ERROR_PREFIX = "Codex error: ";
8
9
  exports.CANONICAL_CONTEXT_WINDOW_MESSAGE = "Your input exceeds the context window of this model. Please adjust your input and try again.";
9
10
  exports.INTERNAL_CONTEXT_WINDOW_PROJECTION_REASON = "provider rejected the input because the context window was exceeded";
@@ -51,3 +52,27 @@ function classifyStrictProviderError(error) {
51
52
  }
52
53
  return undefined;
53
54
  }
55
+ /**
56
+ * Finish reasons we are willing to quote into user-visible status. The list is
57
+ * deliberately closed: Runtime/provider text is never echoed, so only a token
58
+ * validated against this vocabulary can reach `status`.
59
+ */
60
+ const SURFACED_FINISH_REASONS = new Set([
61
+ "stop", "length", "content_filter", "tool_calls", "function_call",
62
+ "end_turn", "max_tokens", "stop_sequence", "tool_use", "refusal",
63
+ "safety", "recitation", "blocklist", "prohibited_content", "spii", "malformed_function_call", "other",
64
+ "error", "timeout", "rate_limit", "overloaded", "cancelled", "aborted",
65
+ ]);
66
+ /**
67
+ * Narrow, allow-listed extraction of a provider finish reason from Runtime text
68
+ * (e.g. "Provider finish_reason: content_filter"). Returns the validated token
69
+ * only — the surrounding payload never leaves this function, so a status line
70
+ * can say why a reply was withheld without echoing raw Runtime data.
71
+ */
72
+ function providerFinishReason(value) {
73
+ if (typeof value !== "string" || value.length === 0 || value.length > 8_192)
74
+ return null;
75
+ const match = /(?:finish[_-]?reason|rawstopreason)\s*[:=]\s*"?([A-Za-z_]{2,32})"?/i.exec(value);
76
+ const token = match?.[1]?.toLowerCase() ?? "";
77
+ return SURFACED_FINISH_REASONS.has(token) ? token : null;
78
+ }
@@ -45,3 +45,27 @@ export function classifyStrictProviderError(error) {
45
45
  }
46
46
  return undefined;
47
47
  }
48
+ /**
49
+ * Finish reasons we are willing to quote into user-visible status. The list is
50
+ * deliberately closed: Runtime/provider text is never echoed, so only a token
51
+ * validated against this vocabulary can reach `status`.
52
+ */
53
+ const SURFACED_FINISH_REASONS = new Set([
54
+ "stop", "length", "content_filter", "tool_calls", "function_call",
55
+ "end_turn", "max_tokens", "stop_sequence", "tool_use", "refusal",
56
+ "safety", "recitation", "blocklist", "prohibited_content", "spii", "malformed_function_call", "other",
57
+ "error", "timeout", "rate_limit", "overloaded", "cancelled", "aborted",
58
+ ]);
59
+ /**
60
+ * Narrow, allow-listed extraction of a provider finish reason from Runtime text
61
+ * (e.g. "Provider finish_reason: content_filter"). Returns the validated token
62
+ * only — the surrounding payload never leaves this function, so a status line
63
+ * can say why a reply was withheld without echoing raw Runtime data.
64
+ */
65
+ export function providerFinishReason(value) {
66
+ if (typeof value !== "string" || value.length === 0 || value.length > 8_192)
67
+ return null;
68
+ const match = /(?:finish[_-]?reason|rawstopreason)\s*[:=]\s*"?([A-Za-z_]{2,32})"?/i.exec(value);
69
+ const token = match?.[1]?.toLowerCase() ?? "";
70
+ return SURFACED_FINISH_REASONS.has(token) ? token : null;
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "larkin",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "private": false,
5
5
  "larkinPackageRole": "npm-published",
6
6
  "files": [
@@ -116,5 +116,8 @@
116
116
  "typescript": "^7.0.2",
117
117
  "vite": "^8.1.5",
118
118
  "vitest": "^4.1.10"
119
+ },
120
+ "overrides": {
121
+ "@larksuiteoapi/node-sdk": "^1.74.0"
119
122
  }
120
123
  }