@sema-agent/client-core 0.101.0 → 0.103.0

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/README.md +19 -11
  3. package/dist/adapt/toolCards.d.ts +4 -2
  4. package/dist/adapt/toolCards.js +22 -6
  5. package/dist/adapt.d.ts +1 -1
  6. package/dist/adapt.js +1 -1
  7. package/dist/adapter/downstream/eventToSdkMessage.d.ts +5 -1
  8. package/dist/adapter/downstream/eventToSdkMessage.js +26 -70
  9. package/dist/adapter/downstream/terminalToSdkResult.js +0 -1
  10. package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
  11. package/dist/adapter/downstream/wiringManifestView.js +141 -0
  12. package/dist/cloudConfigWireCaps.js +6 -3
  13. package/dist/compensations.js +1 -1
  14. package/dist/credentialPlaneCapability.d.ts +22 -0
  15. package/dist/credentialPlaneCapability.js +75 -0
  16. package/dist/deviceExecutorManagementCapability.d.ts +1 -0
  17. package/dist/deviceExecutorManagementCapability.js +3 -1
  18. package/dist/displayUntrusted.d.ts +8 -4
  19. package/dist/displayUntrusted.js +769 -96
  20. package/dist/engineErrorCodes.d.ts +1 -0
  21. package/dist/engineErrorCodes.js +3 -1
  22. package/dist/engineNoticeCodes.d.ts +26 -0
  23. package/dist/engineNoticeCodes.js +121 -12
  24. package/dist/engineRowRef.js +2 -0
  25. package/dist/errorSupplementRoles.js +1 -3
  26. package/dist/eventLeg.js +2 -1
  27. package/dist/fleet/fleetProjection.js +16 -10
  28. package/dist/gateOutcome.d.ts +20 -0
  29. package/dist/gateOutcome.js +89 -0
  30. package/dist/generated/engineAskFaceTables.js +2 -2
  31. package/dist/generated/engineFactTables.d.ts +6 -2
  32. package/dist/generated/engineFactTables.js +41 -1
  33. package/dist/generated/engineNoticeTables.js +18 -0
  34. package/dist/generated/settingsSchemaDefaultModel.d.ts +1 -1
  35. package/dist/generated/settingsSchemaDefaultModel.js +2 -2
  36. package/dist/generated/settingsSchemaFns.d.ts +15 -0
  37. package/dist/generated/settingsSchemaFns.js +25 -2
  38. package/dist/generated/settingsSchemaHooksClassifier.js +109 -29
  39. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
  40. package/dist/generated/settingsSchemaMcpRequestEntry.js +213 -93
  41. package/dist/generated/settingsSchemaMcpServerName.d.ts +1 -0
  42. package/dist/generated/settingsSchemaMcpServerName.js +8 -0
  43. package/dist/generated/settingsSchemaOwnKeyRead.d.ts +1 -0
  44. package/dist/generated/settingsSchemaOwnKeyRead.js +172 -0
  45. package/dist/generated/settingsSchemaPlainJsonObject.d.ts +1 -0
  46. package/dist/generated/settingsSchemaPlainJsonObject.js +28 -0
  47. package/dist/generated/settingsSchemaSafetyMergeSpec.js +10 -7
  48. package/dist/generated/settingsSchemaTierWords.d.ts +1 -0
  49. package/dist/generated/settingsSchemaTierWords.js +7 -0
  50. package/dist/generated/settingsSchemaTypes.d.ts +3 -1
  51. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  52. package/dist/hitl/decisionConflict.js +11 -11
  53. package/dist/hitl/decisionRefusal.d.ts +1 -0
  54. package/dist/hitl/decisionRefusal.js +4 -2
  55. package/dist/hitl/editedRuleTextPrecheck.d.ts +1 -0
  56. package/dist/hitl/editedRuleTextPrecheck.js +26 -1
  57. package/dist/hitl/persistedRulesWire.js +1 -0
  58. package/dist/hitl/planReviewWire.d.ts +2 -1
  59. package/dist/hitl/planReviewWire.js +8 -12
  60. package/dist/hitl/sessionPolicyDeliverable.d.ts +0 -1
  61. package/dist/hitl/sessionPolicyDeliverable.js +0 -5
  62. package/dist/hitl/sessionPolicyWire.js +1 -1
  63. package/dist/hitl/toolApprovalWire.d.ts +18 -6
  64. package/dist/hitl/toolApprovalWire.js +9 -4
  65. package/dist/i18n/messages.en.d.ts +43 -0
  66. package/dist/i18n/messages.en.js +44 -1
  67. package/dist/i18n/messages.zh.js +46 -1
  68. package/dist/index.d.ts +11 -2
  69. package/dist/index.js +7 -1
  70. package/dist/inheritEnvWire.d.ts +1 -0
  71. package/dist/inheritEnvWire.js +8 -5
  72. package/dist/interactiveHalt.d.ts +3 -1
  73. package/dist/interactiveHalt.js +2 -0
  74. package/dist/interactiveInterrupt.d.ts +2 -0
  75. package/dist/interactiveInterrupt.js +15 -0
  76. package/dist/mcpEngineLeg.d.ts +3 -0
  77. package/dist/mcpEngineLeg.js +4 -1
  78. package/dist/mcpLiveness.d.ts +18 -0
  79. package/dist/mcpLiveness.js +48 -1
  80. package/dist/mcpReconnect.d.ts +3 -0
  81. package/dist/mcpReconnect.js +6 -0
  82. package/dist/mcpStatusSupersetKeys.js +24 -1
  83. package/dist/mcpWireCaps.d.ts +2 -3
  84. package/dist/mcpWireCaps.js +9 -8
  85. package/dist/memoryEntriesWire.d.ts +35 -1
  86. package/dist/memoryEntriesWire.js +110 -14
  87. package/dist/modsFace.d.ts +8 -0
  88. package/dist/modsFace.js +63 -0
  89. package/dist/ownKey.d.ts +1 -0
  90. package/dist/ownKey.js +15 -0
  91. package/dist/postureKnob.js +1 -1
  92. package/dist/prepareRefusal.d.ts +0 -1
  93. package/dist/prepareRefusal.js +0 -3
  94. package/dist/printToolResultFrame.js +1 -1
  95. package/dist/promptProfileWireCaps.d.ts +1 -3
  96. package/dist/promptProfileWireCaps.js +2 -2
  97. package/dist/request/printNotification.js +1 -1
  98. package/dist/request/taskRequest.d.ts +22 -1
  99. package/dist/request/taskRequest.js +126 -10
  100. package/dist/retryStatus.d.ts +13 -1
  101. package/dist/retryStatus.js +20 -5
  102. package/dist/seam.js +1 -1
  103. package/dist/seatContract.d.ts +22 -6
  104. package/dist/seatContract.js +45 -6
  105. package/dist/sessionBackground.d.ts +165 -0
  106. package/dist/sessionBackground.js +781 -0
  107. package/dist/sessionBackgroundHandoff.d.ts +54 -0
  108. package/dist/sessionBackgroundHandoff.js +321 -0
  109. package/dist/sessionMap.js +4 -1
  110. package/dist/sessionMemoryErase.js +24 -2
  111. package/dist/settingsCredentialKeyPaths.js +2 -17
  112. package/dist/thinkingLatch.d.ts +69 -0
  113. package/dist/thinkingLatch.js +255 -0
  114. package/dist/thinkingLatchWords.d.ts +7 -0
  115. package/dist/thinkingLatchWords.js +4 -0
  116. package/dist/toolResult.js +2 -24
  117. package/dist/turnFailurePresentation.js +8 -1
  118. package/dist/wireFailureShape.d.ts +12 -1
  119. package/dist/wireFailureShape.js +58 -24
  120. package/dist/wireRefusalCopy.d.ts +0 -3
  121. package/dist/wireRefusalCopy.js +0 -17
  122. package/docs/INTEGRATION-CLIENTS.md +458 -14
  123. package/package.json +5 -5
  124. package/dist/argvFlagValue.d.ts +0 -8
  125. package/dist/argvFlagValue.js +0 -37
@@ -5,6 +5,7 @@ import { SETTINGS_MODEL_API_WORDS } from "./generated/settingsSchemaTables.js";
5
5
  import { PROBE_VERDICTS } from "./modelCapabilityProbe.js";
6
6
  import { guardedRead, ownDataField, ownDataRefusalKeyOf, ownSendableField, readOwnDataValue } from "./ownKey.js";
7
7
  import { MCP_LIVENESS_STATES } from "./mcpLiveness.js";
8
+ import { THINKING_LATCH_EVENTS, THINKING_LATCH_ROW_WORDS } from "./thinkingLatchWords.js";
8
9
  const bad = (reason, field) => field === undefined ? { reason } : { reason, field };
9
10
  const nested = (prefix, verdict) => {
10
11
  const path = verdict.field === undefined
@@ -158,8 +159,10 @@ const oneOfRule = (label, words) => ruleOf(label, (v) => typeof v === "string" &
158
159
  const R_STR = ruleOf("string", (v) => typeof v === "string");
159
160
  const R_NONEMPTY = ruleOf("non-empty string", (v) => typeof v === "string" && v.length > 0);
160
161
  const R_BOOL = ruleOf("boolean", (v) => typeof v === "boolean");
162
+ const R_THINKING_LATCH_ROW = oneOfRule("latch word", THINKING_LATCH_ROW_WORDS);
161
163
  const R_TRUE = ruleOf("true", (v) => v === true);
162
164
  const R_NUM = ruleOf("finite number", (v) => typeof v === "number" && Number.isFinite(v));
165
+ const R_NUM0 = ruleOf("finite non-negative number", (v) => typeof v === "number" && Number.isFinite(v) && v >= 0);
163
166
  const R_INT0 = ruleOf("non-negative integer", (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0);
164
167
  const R_INT1 = ruleOf("positive integer", (v) => typeof v === "number" && Number.isSafeInteger(v) && v > 0);
165
168
  const keyWords = (k) => k
@@ -354,7 +357,7 @@ export function readSeatStreamDelta(message) {
354
357
  return Object.freeze({ kind: "malformed" });
355
358
  }
356
359
  }
357
- export const SEAT_CAPABILITY_NAMES = Object.freeze(["pickFolder", "rewind", "recents", "patchSession", "devices", "engineTarget", "onboard", "mcpToolToggles"]);
360
+ export const SEAT_CAPABILITY_NAMES = Object.freeze(["pickFolder", "rewind", "recents", "patchSession", "devices", "engineTarget", "onboard", "mcpToolToggles", "thinkingLatch"]);
358
361
  const notReported = () => Object.freeze({ kind: "not_reported" });
359
362
  const malformedReading = () => Object.freeze({ kind: "malformed" });
360
363
  const reported = (available) => Object.freeze({ kind: "reported", available });
@@ -430,6 +433,7 @@ const SEAT_CAPABILITY_PHRASES = Object.freeze({
430
433
  engineTarget: Object.freeze({ action: "Switching engines", ability: "switch engines", support: "engine-switching support" }),
431
434
  onboard: Object.freeze({ action: "Model setup", ability: "add models", support: "model-setup support" }),
432
435
  mcpToolToggles: Object.freeze({ action: "Per-tool switching", ability: "toggle tools", support: "per-tool switches" }),
436
+ thinkingLatch: Object.freeze({ action: "Switching thinking", ability: "switch thinking", support: "thinking-switch support" }),
433
437
  });
434
438
  export function seatCapabilityUnavailableDetail(name, reading) {
435
439
  const phrase = Object.hasOwn(SEAT_CAPABILITY_PHRASES, name)
@@ -556,6 +560,7 @@ export const SEAT_TURN_SETTINGS_ORIGINS = Object.freeze({
556
560
  export const SEAT_REWIND_INTENT_KEYS = ["mode", "targetMessageUuid"];
557
561
  export const ATTACHMENT_UPLOAD_REQUEST_KEYS = ["name", "mimeType", "bytes"];
558
562
  export const SESSION_ROW_PATCH_REQUEST_KEYS = Object.freeze(["sessionId", "title", "pinned"]);
563
+ const SET_THINKING_LATCH_REQUEST_KEYS = Object.freeze(["sessionId", "event"]);
559
564
  export const SESSION_SEARCH_RESULT_KEYS = ["sessionId", "title", "matches"];
560
565
  export const GET_TRANSCRIPT_RESULT_KEYS = ["sessionId", "messages"];
561
566
  const DEVICE_REFUSED_SPEC = { status: reqF(R_INT0), errorCode: optF(R_STR), message: optF(R_STR) };
@@ -878,6 +883,11 @@ function mcpPanelLivenessArms() {
878
883
  return arms;
879
884
  }
880
885
  const MCP_PANEL_LIVENESS_VIEW = armsRule("mcp liveness", "state", mcpPanelLivenessArms());
886
+ const MCP_PANEL_AUTHORIZATION = shapeRule("mcp authorization", {
887
+ reason: reqF(R_NONEMPTY),
888
+ authorizeUrl: optF(R_NONEMPTY),
889
+ resourceMetadataUrl: optF(R_NONEMPTY),
890
+ });
881
891
  const MCP_PANEL_LEG_ENTRY = shapeRule("leg entry", {
882
892
  name: reqF(R_NONEMPTY),
883
893
  status: reqF(R_NONEMPTY),
@@ -888,6 +898,8 @@ const MCP_PANEL_LEG_ENTRY = shapeRule("leg entry", {
888
898
  httpStatus: optF(R_NUM),
889
899
  liveness: optF(MCP_PANEL_LIVENESS_VIEW),
890
900
  livenessUnreadable: optF(R_TRUE),
901
+ authorization: optF(MCP_PANEL_AUTHORIZATION),
902
+ authorizationUnreadable: optF(R_TRUE),
891
903
  });
892
904
  const MCP_PANEL_LAST_LEG = shapeRule("last leg", {
893
905
  runId: reqF(R_NONEMPTY),
@@ -971,6 +983,12 @@ const checkLocalSessionRecord = seatCheck((s) => {
971
983
  if (!isAbsent(pinned) && typeof pinned !== "boolean") {
972
984
  return bad("pinned must be a boolean when present (absent = not pinned or unknown)", "pinned");
973
985
  }
986
+ const latch = own(s, "thinkingLatch");
987
+ if (!isAbsent(latch)) {
988
+ const verdict = R_THINKING_LATCH_ROW.test(latch, "thinkingLatch");
989
+ if (verdict !== true)
990
+ return verdict;
991
+ }
974
992
  return true;
975
993
  });
976
994
  export function isLocalSessionRecord(s) {
@@ -1059,6 +1077,8 @@ const RETRY_COMMON_SPEC = {
1059
1077
  providerConditionSource: optF(R_STR),
1060
1078
  elapsedMs: optF(R_NUM),
1061
1079
  timeoutMs: optF(R_NUM),
1080
+ sleptMs: optF(R_NUM0),
1081
+ waitSegment: optF(R_NONEMPTY),
1062
1082
  };
1063
1083
  const RETRY_STATUS = armsRule("retry status", "kind", {
1064
1084
  stalled: { ...RETRY_COMMON_SPEC, detail: optF(R_STR) },
@@ -1438,6 +1458,14 @@ export const checkSessionRowPatchRequest = seatCheck((v) => {
1438
1458
  export function isSessionRowPatchRequest(v) {
1439
1459
  return checkSessionRowPatchRequest(v) === true;
1440
1460
  }
1461
+ const checkSetThinkingLatchShape = seatShapeCheck(shapeRule("latch request", {
1462
+ sessionId: reqF(R_NONEMPTY),
1463
+ event: reqF(oneOfRule("latch event", THINKING_LATCH_EVENTS)),
1464
+ }));
1465
+ export const checkSetThinkingLatchRequest = seatCheck((v) => isPlainRecord(v) ? checkSetThinkingLatchShape(v) : bad("setThinkingLatch request is not a plain object"));
1466
+ export function isSetThinkingLatchRequest(v) {
1467
+ return checkSetThinkingLatchRequest(v) === true;
1468
+ }
1441
1469
  const checkSendMessageAck = seatCheck((v) => {
1442
1470
  if (!isPlainRecord(v))
1443
1471
  return bad("sendMessage ack is not a plain object");
@@ -1609,6 +1637,7 @@ export const LOCAL_SESSIONS_SPEC = {
1609
1637
  readSessionMcpPanel: { kind: "invoke", check: checkSessionMcpPanelResult },
1610
1638
  listMcpToolToggles: { kind: "invoke", check: checkMcpToolTogglesResult },
1611
1639
  setMcpToolToggle: { kind: "invoke", check: checkOkAck },
1640
+ setThinkingLatch: { kind: "invoke", check: checkOkAck },
1612
1641
  onEvent: { kind: "event", check: checkLocalSessionEvent },
1613
1642
  onToolPermissionRequest: { kind: "event", check: checkToolPermissionRequest },
1614
1643
  },
@@ -1656,6 +1685,7 @@ export const SEAT_METHOD_NAMES = [
1656
1685
  "readSessionMcpPanel",
1657
1686
  "listMcpToolToggles",
1658
1687
  "setMcpToolToggle",
1688
+ "setThinkingLatch",
1659
1689
  "onEvent",
1660
1690
  "onToolPermissionRequest",
1661
1691
  ];
@@ -1714,6 +1744,7 @@ export const LOCAL_SESSION_RECORD_KEYS = [
1714
1744
  "queuedMessages",
1715
1745
  "parked",
1716
1746
  "pinned",
1747
+ "thinkingLatch",
1717
1748
  ];
1718
1749
  export const SEND_MESSAGE_REQUEST_KEYS = [
1719
1750
  "sessionId",
@@ -1758,7 +1789,7 @@ export const SEAT_VALIDATOR_KEY_COVERAGE = {
1758
1789
  LocalSessionRecord: {
1759
1790
  guard: "isLocalSessionRecord",
1760
1791
  check: checkLocalSessionRecord,
1761
- validated: ["sessionId", "engineSessionId", "model", "title", "cwd", "isRunning", "createdAt", "lastActivityAt", "queuedMessages", "parked", "pinned"],
1792
+ validated: ["sessionId", "engineSessionId", "model", "title", "cwd", "isRunning", "createdAt", "lastActivityAt", "queuedMessages", "parked", "pinned", "thinkingLatch"],
1762
1793
  unchecked: [],
1763
1794
  },
1764
1795
  ToolPermissionRequest: {
@@ -1882,6 +1913,12 @@ export const SEAT_VALIDATOR_KEY_COVERAGE = {
1882
1913
  validated: ["sessionId", "title", "pinned"],
1883
1914
  unchecked: [],
1884
1915
  },
1916
+ SetThinkingLatchRequest: {
1917
+ guard: "isSetThinkingLatchRequest",
1918
+ check: checkSetThinkingLatchRequest,
1919
+ validated: ["sessionId", "event"],
1920
+ unchecked: [],
1921
+ },
1885
1922
  ApplyModelConfigResult: {
1886
1923
  check: checkApplyModelConfigResult,
1887
1924
  validated: ["ok", "requiresRestart", "reason", "detail"],
@@ -1935,7 +1972,7 @@ export const SEAT_VALIDATOR_KEY_COVERAGE = {
1935
1972
  },
1936
1973
  SeatCapabilitiesState: {
1937
1974
  check: checkSeatCapabilitiesState,
1938
- validated: ["pickFolder", "rewind", "recents", "patchSession", "devices", "engineTarget", "onboard", "mcpToolToggles"],
1975
+ validated: ["pickFolder", "rewind", "recents", "patchSession", "devices", "engineTarget", "onboard", "mcpToolToggles", "thinkingLatch"],
1939
1976
  unchecked: [],
1940
1977
  },
1941
1978
  RecentFoldersResult: {
@@ -2006,7 +2043,7 @@ export const SEAT_VALIDATOR_COVERAGE_EXEMPT = [
2006
2043
  {
2007
2044
  label: "PickFolderResult",
2008
2045
  check: checkPickFolderResult,
2009
- why: "载荷是**串或 null**(选中的路径 / 用户取消,CC-469),没有键面 ⇒ `keyof` 覆盖表在它身上无从谈起。判别力由 run-seat-wave2-test.mjs ST1-1 承担:认 null 与非空串、拒空串 / 数 / undefined / 对象 / 布尔五形。",
2046
+ why: "载荷是**串或 null**(选中的路径 / 用户取消,CC-469),没有键面 ⇒ `keyof` 覆盖表在它身上无从谈起。判别力由对应的座位契约测试套承担:认 null 与非空串、拒空串 / 数 / undefined / 对象 / 布尔五形。",
2010
2047
  },
2011
2048
  {
2012
2049
  label: "BooleanAck",
@@ -2017,10 +2054,10 @@ export const SEAT_VALIDATOR_COVERAGE_EXEMPT = [
2017
2054
  label: "LaneProof",
2018
2055
  check: (v) => checkLaneProof(v, "laneProof"),
2019
2056
  why: "判别式联合:必填键面随 `lane` 臂而变(subagent 要 parentToolCallId、workflow 要 via+key),而覆盖表的方法是「一个最小合法体 + 逐键投毒」—— 那套方法在它身上没有判别力(main 臂对另外两臂的伴随位本来就不该拒,投毒过了不代表漏校)。" +
2020
- "🔴 FIX④(2026-08-07 订正):本条此前自称判别力由「F 段**逐臂**投毒(空对象 / 非对象 / **未登记车道词**)」承担 —— 全树实扫,那三样里只有**空对象**与**非对象**真的存在(run-seat-contract-keys-test.mjs F 段)," +
2057
+ "🔴 (2026-08-07 订正)本条此前自称判别力由「**逐臂**投毒(空对象 / 非对象 / **未登记车道词**)」承担 —— 全树实扫,那三样里只有**空对象**与**非对象**真的存在(座位契约键测试套的逐臂投毒段)," +
2021
2058
  "「未登记车道词」实际只钉了 `lane: 7`(非串,证明不了闭集成员判定在场),「逐臂」(subagent 缺 parentToolCallId / workflow 缺 via+key)则是**零覆盖**。也就是说这条豁免曾经拿三件不存在的判据给自己背书。" +
2022
2059
  "现势(判据锚在真存在的东西上):① `LANE_PROOF_LANE_TUPLE` ⇄ seam.ts 车道联合的双向 `Covers`(本文件 `_seatContractPins`,加车道不跟 ⇒ 编译红);" +
2023
- "② run-client-core-pure-test.mjs **FIX7 段 ④** —— 未登记车道词 / subagent 缺伴随位 / workflow 缺 via 或 key 三条投毒 + 两条逐臂正控 + 一条「main 臂不被过紧误拒」负控,全部直接喂本条的 `check`。",
2060
+ "② 本包纯测试套的投毒段 —— 未登记车道词 / subagent 缺伴随位 / workflow 缺 via 或 key 三条投毒 + 两条逐臂正控 + 一条「main 臂不被过紧误拒」负控,全部直接喂本条的 `check`。",
2024
2061
  },
2025
2062
  ];
2026
2063
  const _seatContractPins = [
@@ -2050,6 +2087,8 @@ const _seatContractPins = [
2050
2087
  true, true, true,
2051
2088
  true,
2052
2089
  true, true, true,
2090
+ true, true, true, true, true, true,
2091
+ true, true, true,
2053
2092
  true, true,
2054
2093
  ];
2055
2094
  void _seatContractPins;
@@ -0,0 +1,165 @@
1
+ import type { AgentClient, AgentEvent, TaskRequest } from '@sema-agent/sdk';
2
+ import { type EnvLike } from './hostEnv.js';
3
+ import type { UiLanguage } from './env/uiLanguage.js';
4
+ export type SessionBackgroundableReading = {
5
+ readonly kind: 'advertised';
6
+ } | {
7
+ readonly kind: 'declined';
8
+ } | {
9
+ readonly kind: 'not_reported';
10
+ } | {
11
+ readonly kind: 'unreadable';
12
+ } | {
13
+ readonly kind: 'unobserved';
14
+ };
15
+ export declare function projectSessionBackgroundable(caps: {} | null | undefined): SessionBackgroundableReading | undefined;
16
+ export declare function readSessionBackgroundable(baseUrl?: string | undefined): SessionBackgroundableReading;
17
+ export type InteractiveEngineLane = 'self-spawned' | 'external';
18
+ export interface InteractiveEngineWireInit {
19
+ readonly baseUrl: string;
20
+ readonly lane: InteractiveEngineLane;
21
+ readonly tasks: Pick<AgentClient['tasks'], 'stream'>;
22
+ readonly runs: Pick<AgentClient['runs'], 'events' | 'get'>;
23
+ }
24
+ export interface InteractiveEngineWire {
25
+ readonly baseUrl: string;
26
+ readonly lane: InteractiveEngineLane;
27
+ }
28
+ type SdkStreamOptions = Parameters<AgentClient['tasks']['stream']>[1];
29
+ type SdkEventsOptions = NonNullable<Parameters<AgentClient['runs']['events']>[1]>;
30
+ type SdkGetOptions = NonNullable<Parameters<AgentClient['runs']['get']>[1]>;
31
+ type SdkRunRecord = Awaited<ReturnType<AgentClient['runs']['get']>>;
32
+ export type OpeningPhase = 'opening' | 'bound' | 'running' | 'ended-unstarted' | 'finished' | 'stream-ended' | 'handing-off' | 'handed-off' | 'engine-ended';
33
+ export interface OpeningRecordView {
34
+ readonly phase: OpeningPhase;
35
+ readonly inconsistent: boolean;
36
+ readonly capsGenAtBind: number | undefined;
37
+ readonly stopRequested: boolean;
38
+ readonly stamped: boolean;
39
+ readonly postureReason: InteractiveDetachPostureReason;
40
+ readonly proof: 'loopback-self-spawned' | 'none';
41
+ readonly taskId: string | undefined;
42
+ readonly sessionId: string | undefined;
43
+ readonly openAsks: ReadonlyMap<string, number | undefined>;
44
+ readonly askUnacked: boolean;
45
+ }
46
+ export interface OpeningRecord extends OpeningRecordView {
47
+ readonly openingId: number;
48
+ readonly sessionKey: string | undefined;
49
+ phase: OpeningPhase;
50
+ inconsistent: boolean;
51
+ capsGenAtBind: number | undefined;
52
+ stopRequested: boolean;
53
+ stamped: boolean;
54
+ postureReason: InteractiveDetachPostureReason;
55
+ proof: 'loopback-self-spawned' | 'none';
56
+ taskId: string | undefined;
57
+ sessionId: string | undefined;
58
+ readonly openAsks: Map<string, number | undefined>;
59
+ askUnacked: boolean;
60
+ replay: boolean;
61
+ readonly tear: (reason: string) => void;
62
+ }
63
+ export interface HandedOffEntry {
64
+ readonly taskId: string;
65
+ readonly sessionKey: string;
66
+ state: 'running' | 'ended' | 'unconfirmed';
67
+ readonly stop: (cause: 'disposed' | 'engine-ended') => void;
68
+ readonly reconcile: () => void;
69
+ }
70
+ export interface WireState {
71
+ retired: boolean;
72
+ readonly baseUrl: string;
73
+ readonly lane: InteractiveEngineLane;
74
+ readonly stream: (req: TaskRequest, opts: SdkStreamOptions) => AsyncGenerator<AgentEvent>;
75
+ readonly events: (taskId: string, opts: SdkEventsOptions) => AsyncGenerator<AgentEvent>;
76
+ readonly get: (taskId: string, opts: SdkGetOptions) => Promise<SdkRunRecord>;
77
+ readonly bySession: Map<string, OpeningRecord>;
78
+ readonly byTask: Map<string, OpeningRecord>;
79
+ readonly order: OpeningRecord[];
80
+ readonly handedOff: Map<string, HandedOffEntry>;
81
+ nextOpeningId: number;
82
+ }
83
+ export declare const OPENING_RECORD_CAP = 256;
84
+ export type OwnSlot = {
85
+ readonly state: 'absent';
86
+ } | {
87
+ readonly state: 'unreadable';
88
+ } | {
89
+ readonly state: 'data';
90
+ readonly value: {} | null;
91
+ };
92
+ export declare function ownSlotOf(o: object, key: string): OwnSlot;
93
+ export declare function wireStateOf(wire: InteractiveEngineWire | null | undefined): WireState | undefined;
94
+ export declare function interactiveEngineWire(init: InteractiveEngineWireInit): InteractiveEngineWire | undefined;
95
+ export declare function retireInteractiveEngineWire(wire: InteractiveEngineWire): void;
96
+ export interface InteractiveOpeningInput {
97
+ readonly sessionKey: string;
98
+ readonly reattachable: boolean;
99
+ readonly env?: EnvLike;
100
+ }
101
+ export type InteractiveDetachPostureReason = 'self-spawned' | 'unreadable-input' | 'retired-wire' | 'env-off' | 'not-reattachable' | 'declined' | 'unacknowledged' | 'not_reported' | 'unobserved' | 'unreadable' | 'durable-off-400';
102
+ export interface InteractiveDetachPosture {
103
+ readonly stamp: boolean;
104
+ readonly reason: InteractiveDetachPostureReason;
105
+ }
106
+ export declare function interactiveDetachPosture(wire: InteractiveEngineWire, input: InteractiveOpeningInput): InteractiveDetachPosture;
107
+ export type InteractiveStreamOptions = {
108
+ transientOk: true;
109
+ signal?: AbortSignal;
110
+ headers?: Record<string, string>;
111
+ onResponse?: (res: Response) => void;
112
+ idempotencyKey?: string | null;
113
+ heartbeatGraceMs?: number;
114
+ };
115
+ export declare function streamInteractiveRun(wire: InteractiveEngineWire, req: TaskRequest, opts: InteractiveStreamOptions, input: InteractiveOpeningInput): AsyncGenerator<AgentEvent>;
116
+ export type BackgroundHandoffVerdict = {
117
+ readonly verdict: 'eligible';
118
+ readonly taskId: string;
119
+ } | {
120
+ readonly verdict: 'ineligible';
121
+ readonly reason: BackgroundHandoffRefusal;
122
+ readonly cause?: InteractiveDetachPostureReason;
123
+ } | {
124
+ readonly verdict: 'unknown';
125
+ readonly reason: BackgroundHandoffUnknown;
126
+ };
127
+ export type BackgroundHandoffRefusal = 'no-run' | 'stream-ended' | 'already-handed-off' | 'finished' | 'engine-replaced' | 'stopping' | 'not-stamped' | 'declined' | 'not-started' | 'awaiting-user';
128
+ export type BackgroundHandoffUnknown = 'unreadable-input' | 'capability-unconfirmed' | 'detach-unconfirmed' | 'awaiting-user-unattributable';
129
+ export interface HoldOwnerView {
130
+ readonly taskId: string | undefined;
131
+ readonly sessionId: string | undefined;
132
+ }
133
+ export interface HandoffJudgeFacts {
134
+ readonly inputReadable: boolean;
135
+ readonly wirePresent: boolean;
136
+ readonly wireRecognized: boolean;
137
+ readonly rec: OpeningRecordView | undefined;
138
+ readonly capability: SessionBackgroundableReading['kind'];
139
+ readonly capsGenerationNow: number | undefined;
140
+ readonly holds: readonly HoldOwnerView[];
141
+ readonly nowMs: number;
142
+ }
143
+ export declare function handoffVerdictOf(f: HandoffJudgeFacts): BackgroundHandoffVerdict;
144
+ export interface HandoffJudgeInput {
145
+ readonly wire: InteractiveEngineWire | undefined;
146
+ readonly sessionKey: string;
147
+ }
148
+ export interface JudgedHandoff {
149
+ readonly verdict: BackgroundHandoffVerdict;
150
+ readonly rec: OpeningRecord | undefined;
151
+ readonly state: WireState | undefined;
152
+ }
153
+ export declare function judgeHandoff(input: HandoffJudgeInput | null | undefined): JudgedHandoff;
154
+ export declare function backgroundHandoffEligibility(input: {
155
+ readonly wire: InteractiveEngineWire | undefined;
156
+ readonly sessionKey: string;
157
+ }): BackgroundHandoffVerdict;
158
+ export declare function backgroundHandoffSentence(v: BackgroundHandoffVerdict, lang?: UiLanguage): string | undefined;
159
+ export interface InteractiveStopFacts {
160
+ readonly detachArmed: boolean;
161
+ readonly handedOff: boolean;
162
+ }
163
+ export declare function interactiveStopFacts(wire: InteractiveEngineWire | undefined, taskId: string): InteractiveStopFacts;
164
+ export declare function noteInteractiveStopRequested(wire: InteractiveEngineWire, taskId: string): 'withheld' | 'proceed';
165
+ export {};