@sema-agent/client-core 0.110.0 → 0.112.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 (243) hide show
  1. package/CHANGELOG.md +244 -0
  2. package/README.md +59 -18
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +25 -4
  6. package/dist/adapt/toolCards.d.ts +3 -1
  7. package/dist/adapt/toolCards.js +4 -2
  8. package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
  9. package/dist/adapter/activeRunSelfHeal.js +171 -3
  10. package/dist/adapter/downstream/eventToSdkMessage.js +10 -10
  11. package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
  12. package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
  13. package/dist/adapter/runStream.d.ts +5 -0
  14. package/dist/adapter/runStream.js +15 -3
  15. package/dist/agentSession/engineSessionBackgroundStop.js +2 -2
  16. package/dist/attachmentRoute.d.ts +20 -0
  17. package/dist/attachmentRoute.js +39 -0
  18. package/dist/attachmentsWireCaps.js +1 -1
  19. package/dist/builtinOutputStyles.d.ts +12 -0
  20. package/dist/builtinOutputStyles.js +147 -0
  21. package/dist/checkpointRowVerdict.d.ts +3 -0
  22. package/dist/checkpointRowVerdict.js +14 -1
  23. package/dist/compactionStatus.d.ts +9 -0
  24. package/dist/compactionStatus.js +29 -5
  25. package/dist/consoleCaPin.d.ts +136 -0
  26. package/dist/consoleCaPin.js +827 -0
  27. package/dist/controlRouter.js +2 -1
  28. package/dist/coreValuePorts.d.ts +39 -1
  29. package/dist/coreValuePorts.js +10 -0
  30. package/dist/decideReceipt.d.ts +2 -1
  31. package/dist/deviceRebind.js +3 -3
  32. package/dist/displayUntrusted.d.ts +1 -0
  33. package/dist/displayUntrusted.js +6 -0
  34. package/dist/effectiveFacts.d.ts +9 -0
  35. package/dist/effectiveFacts.js +33 -0
  36. package/dist/engineAddress.d.ts +1 -0
  37. package/dist/engineAddress.js +4 -1
  38. package/dist/engineCredentialRelease.d.ts +54 -0
  39. package/dist/engineCredentialRelease.js +146 -0
  40. package/dist/engineErrorCodes.d.ts +1 -0
  41. package/dist/engineErrorCodes.js +1 -0
  42. package/dist/engineHealthProbeVerdict.d.ts +24 -0
  43. package/dist/engineHealthProbeVerdict.js +123 -0
  44. package/dist/engineNoticeCodes.js +5 -7
  45. package/dist/engineRepoint.d.ts +12 -5
  46. package/dist/engineRepoint.js +44 -19
  47. package/dist/engineRowRef.d.ts +3 -0
  48. package/dist/engineRowRef.js +11 -1
  49. package/dist/engineSwapCrossing.d.ts +57 -0
  50. package/dist/engineSwapCrossing.js +297 -0
  51. package/dist/engineUnavailable.d.ts +45 -0
  52. package/dist/engineUnavailable.js +496 -0
  53. package/dist/engineUrl.js +4 -2
  54. package/dist/eventLeg.js +3 -3
  55. package/dist/gateFailureCodes.js +2 -2
  56. package/dist/generated/sdkFactTables.d.ts +2 -1
  57. package/dist/generated/sdkFactTables.js +14 -0
  58. package/dist/generated/settingsSchemaFns.d.ts +1 -0
  59. package/dist/generated/settingsSchemaFns.js +3 -0
  60. package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
  61. package/dist/generated/settingsSchemaTables.d.ts +56 -0
  62. package/dist/generated/settingsSchemaTables.js +19 -0
  63. package/dist/generated/settingsSchemaTypes.d.ts +23 -13
  64. package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
  65. package/dist/generated/settingsSchemaUrlShape.js +17 -0
  66. package/dist/hitl/approvalDelivery.d.ts +1 -0
  67. package/dist/hitl/approvalDelivery.js +1 -1
  68. package/dist/hitl/approvalResolution.d.ts +1 -1
  69. package/dist/hitl/approvalResolution.js +2 -1
  70. package/dist/hitl/askGateWire.js +5 -6
  71. package/dist/hitl/decisionRefusal.d.ts +6 -0
  72. package/dist/hitl/decisionRefusal.js +19 -10
  73. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  74. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  75. package/dist/hitl/decisionSend.d.ts +7 -0
  76. package/dist/hitl/decisionSend.js +34 -12
  77. package/dist/hitl/editedApprovalAcceptance.js +1 -1
  78. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  79. package/dist/hitl/elicitationRefusal.js +23 -0
  80. package/dist/hitl/frameRouter.d.ts +2 -2
  81. package/dist/hitl/frameRouter.js +8 -15
  82. package/dist/hitl/gateIdentity.d.ts +5 -0
  83. package/dist/hitl/gateIdentity.js +23 -0
  84. package/dist/hitl/hitlBridge.d.ts +6 -0
  85. package/dist/hitl/hitlBridge.js +10 -4
  86. package/dist/hitl/hitlHostSurface.d.ts +2 -1
  87. package/dist/hitl/hitlHostSurface.js +7 -2
  88. package/dist/hitl/localAllowRedemption.d.ts +70 -0
  89. package/dist/hitl/localAllowRedemption.js +276 -0
  90. package/dist/hitl/parkOwnership.js +2 -1
  91. package/dist/hitl/parkResolver.js +14 -4
  92. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  93. package/dist/hitl/persistedRulesWire.js +70 -0
  94. package/dist/hitl/planReviewWire.d.ts +3 -0
  95. package/dist/hitl/planReviewWire.js +23 -6
  96. package/dist/hitl/policyDenyCause.d.ts +1 -1
  97. package/dist/hitl/policyDenyCause.js +1 -1
  98. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  99. package/dist/hitl/resumeRunningCard.js +1 -0
  100. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  101. package/dist/hitl/screenCardCarriers.js +41 -0
  102. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  103. package/dist/hitl/screenDecisionCards.js +363 -0
  104. package/dist/hitl/sessionPolicyWire.js +2 -2
  105. package/dist/hitl/standingRows.d.ts +6 -2
  106. package/dist/hitl/standingRows.js +27 -2
  107. package/dist/hitl/toolApprovalWire.d.ts +30 -8
  108. package/dist/hitl/toolApprovalWire.js +264 -121
  109. package/dist/hooksReaderGenerations.js +1 -1
  110. package/dist/hooksWireCaps.js +3 -3
  111. package/dist/hostSettingNoticeArm.d.ts +3 -0
  112. package/dist/hostSettingNoticeArm.js +12 -0
  113. package/dist/hostTurnSettings.d.ts +3 -0
  114. package/dist/hostTurnSettings.js +38 -5
  115. package/dist/humanTurnRead.js +11 -1
  116. package/dist/i18n/messages.en.d.ts +292 -0
  117. package/dist/i18n/messages.en.js +298 -7
  118. package/dist/i18n/messages.zh.js +316 -6
  119. package/dist/i18n/translate.d.ts +3 -0
  120. package/dist/i18n/translate.js +78 -10
  121. package/dist/i18n/zh.d.ts +1 -0
  122. package/dist/i18n/zh.js +1 -0
  123. package/dist/index.d.ts +71 -20
  124. package/dist/index.js +44 -13
  125. package/dist/interactiveHalt.js +2 -1
  126. package/dist/interactiveInterrupt.js +20 -2
  127. package/dist/liveModelCatalog.d.ts +4 -0
  128. package/dist/liveModelCatalog.js +12 -3
  129. package/dist/localConfig/documents.d.ts +61 -0
  130. package/dist/localConfig/documents.js +51 -0
  131. package/dist/localConfig/kernel.d.ts +149 -0
  132. package/dist/localConfig/kernel.js +597 -0
  133. package/dist/localConfig/mcp/edit.d.ts +161 -0
  134. package/dist/localConfig/mcp/edit.js +846 -0
  135. package/dist/localConfig/mcp/servers.d.ts +165 -0
  136. package/dist/localConfig/mcp/servers.js +776 -0
  137. package/dist/localConfig/mcp/views.d.ts +170 -0
  138. package/dist/localConfig/mcp/views.js +429 -0
  139. package/dist/localConfig/modelPool.d.ts +262 -0
  140. package/dist/localConfig/modelPool.js +1489 -0
  141. package/dist/localConfig/modelPoolWords.d.ts +13 -0
  142. package/dist/localConfig/modelPoolWords.js +20 -0
  143. package/dist/localConfig/receiptShape.d.ts +7 -0
  144. package/dist/localConfig/receiptShape.js +135 -0
  145. package/dist/localConfig/settingsWrite.d.ts +127 -0
  146. package/dist/localConfig/settingsWrite.js +237 -0
  147. package/dist/localConfig/skills.d.ts +124 -0
  148. package/dist/localConfig/skills.js +397 -0
  149. package/dist/localConfig/skillsWords.d.ts +10 -0
  150. package/dist/localConfig/skillsWords.js +5 -0
  151. package/dist/localEngineSeatReading.d.ts +2 -2
  152. package/dist/localEngineSeatReading.js +5 -3
  153. package/dist/localEngineSpawn.d.ts +0 -7
  154. package/dist/localEngineSpawn.js +0 -92
  155. package/dist/localEngineStep.d.ts +2 -2
  156. package/dist/localEngineStep.js +2 -0
  157. package/dist/mcpProbeWire.js +2 -1
  158. package/dist/mcpReconnect.js +3 -3
  159. package/dist/mcpWireCaps.js +1 -1
  160. package/dist/memoryVerbsWire.js +3 -2
  161. package/dist/model/engineModelWords.d.ts +3 -0
  162. package/dist/model/engineModelWords.js +13 -0
  163. package/dist/model/onboardJudgement.d.ts +14 -4
  164. package/dist/model/onboardJudgement.js +91 -139
  165. package/dist/model/subagentModelWord.d.ts +21 -2
  166. package/dist/model/subagentModelWord.js +100 -29
  167. package/dist/modelCapabilityProbe.js +3 -40
  168. package/dist/modelConfigGapNotice.d.ts +20 -0
  169. package/dist/modelConfigGapNotice.js +102 -0
  170. package/dist/modsKernelIdentity.js +2 -47
  171. package/dist/notifications.d.ts +19 -0
  172. package/dist/notifications.js +114 -12
  173. package/dist/ownKey.d.ts +7 -0
  174. package/dist/ownKey.js +71 -8
  175. package/dist/pendingUserRow.d.ts +4 -0
  176. package/dist/pendingUserRow.js +16 -0
  177. package/dist/permissionsDeclaration.d.ts +3 -1
  178. package/dist/permissionsDeclaration.js +33 -9
  179. package/dist/planReviewCardFacts.d.ts +3 -0
  180. package/dist/planReviewCardFacts.js +52 -2
  181. package/dist/pluginHooksWire.d.ts +9 -1
  182. package/dist/pluginHooksWire.js +40 -6
  183. package/dist/printToolResultFrame.js +4 -2
  184. package/dist/promptBlockedCopy.js +12 -7
  185. package/dist/promptSuggestionBatch.d.ts +7 -0
  186. package/dist/promptSuggestionBatch.js +9 -0
  187. package/dist/promptSuggestionsTail.d.ts +39 -0
  188. package/dist/promptSuggestionsTail.js +116 -0
  189. package/dist/request/taskRequest.js +10 -6
  190. package/dist/requestCoordinate.d.ts +1 -0
  191. package/dist/requestCoordinate.js +13 -0
  192. package/dist/resumeRefusalCopy.d.ts +3 -1
  193. package/dist/resumeRefusalCopy.js +12 -4
  194. package/dist/rewindArchiveReading.js +4 -4
  195. package/dist/runCancelContext.d.ts +2 -1
  196. package/dist/runCancelContext.js +1 -0
  197. package/dist/runLedgerSnapshot.js +3 -3
  198. package/dist/runPermissionModeSwitch.js +3 -4
  199. package/dist/scenarioRefusal.js +11 -13
  200. package/dist/scenarioSkills.js +11 -6
  201. package/dist/seam.d.ts +16 -2
  202. package/dist/seam.js +10 -0
  203. package/dist/seatContract.d.ts +259 -9
  204. package/dist/seatContract.js +444 -15
  205. package/dist/sessionCostReading.d.ts +70 -0
  206. package/dist/sessionCostReading.js +150 -0
  207. package/dist/sessionHooksRoster.d.ts +4 -0
  208. package/dist/sessionHooksRoster.js +158 -0
  209. package/dist/sessionIdSegment.d.ts +1 -0
  210. package/dist/sessionIdSegment.js +4 -1
  211. package/dist/sessionMemoryErase.js +2 -1
  212. package/dist/sessionMemoryStatus.js +2 -2
  213. package/dist/sessionReadRedaction.d.ts +7 -0
  214. package/dist/sessionReadRedaction.js +26 -0
  215. package/dist/sessionSyncFileHistory.js +8 -9
  216. package/dist/settingsHooksSalvage.js +2 -1
  217. package/dist/sha256Bytes.d.ts +1 -0
  218. package/dist/sha256Bytes.js +46 -0
  219. package/dist/skillOverrideChain.d.ts +83 -0
  220. package/dist/skillOverrideChain.js +378 -0
  221. package/dist/skillsWireCaps.d.ts +3 -0
  222. package/dist/skillsWireCaps.js +16 -1
  223. package/dist/sseIdleTriage.js +2 -1
  224. package/dist/storeDurabilityWord.d.ts +15 -0
  225. package/dist/storeDurabilityWord.js +18 -0
  226. package/dist/storePostureCapability.d.ts +7 -3
  227. package/dist/storePostureCapability.js +69 -39
  228. package/dist/subagent/engineSubagentResume.js +2 -2
  229. package/dist/subagent/engineSubagentTail.js +2 -1
  230. package/dist/subagentContentStore.d.ts +11 -0
  231. package/dist/subagentContentStore.js +28 -2
  232. package/dist/toolResult.d.ts +1 -0
  233. package/dist/toolResult.js +2 -0
  234. package/dist/turnFailurePresentation.js +4 -10
  235. package/dist/userAttachmentEnvelope.d.ts +2 -1
  236. package/dist/userAttachmentEnvelope.js +10 -0
  237. package/dist/wireErrorTriage.js +2 -1
  238. package/dist/wireFailureShape.d.ts +4 -0
  239. package/dist/wireFailureShape.js +141 -19
  240. package/dist/wireRefusalCopy.d.ts +6 -5
  241. package/dist/wireRefusalCopy.js +49 -92
  242. package/docs/INTEGRATION-CLIENTS.md +2718 -17
  243. package/package.json +7 -3
@@ -1,5 +1,5 @@
1
1
  import { engineCapNestedValue } from '../engineCapsCache.js';
2
- import { isStatusDerivedCoarseCode } from '../engineErrorCodes.js';
2
+ import { LIMIT_RATE_EXCEEDED, isStatusDerivedCoarseCode } from '../engineErrorCodes.js';
3
3
  import { clientHasVerbs, engineWireFor, INJECTED_WIRE_SETTLE_MS, noAnswerDetailFrom, sendOnce, settleInjected } from '../engineWireFor.js';
4
4
  import { engineWireDebugEnabled } from '../engineWireTarget.js';
5
5
  import { hostLog } from '../host.js';
@@ -135,7 +135,7 @@ function refusedWhyOf(rawCode, status) {
135
135
  return 'session_not_found';
136
136
  if (code === 'not_found.route')
137
137
  return 'route_absent';
138
- if (code === 'limit.rate_exceeded')
138
+ if (code === LIMIT_RATE_EXCEEDED)
139
139
  return 'rate_limited';
140
140
  if (code.startsWith('auth.'))
141
141
  return 'not_permitted';
@@ -0,0 +1,20 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ export declare const TOOLS_LOCATIONS: readonly ["this-machine", "elsewhere", "unconfirmed"];
3
+ export type ToolsLocation = (typeof TOOLS_LOCATIONS)[number];
4
+ export declare const ATTACHMENT_ROUTE_LEGS: readonly ["at_mention", "edited_file", "paste", "ide_selection"];
5
+ export type AttachmentRouteLeg = (typeof ATTACHMENT_ROUTE_LEGS)[number];
6
+ export interface AttachmentRouteFacts {
7
+ readonly leg: AttachmentRouteLeg;
8
+ readonly toolsLocation: ToolsLocation;
9
+ }
10
+ export type AttachmentWithheldReason = 'tools-elsewhere' | 'tools-location-unconfirmed';
11
+ export type AttachmentRoute = {
12
+ readonly route: 'attach_content';
13
+ readonly localCopy: boolean;
14
+ } | {
15
+ readonly route: 'withhold';
16
+ readonly reason: AttachmentWithheldReason;
17
+ };
18
+ export declare function attachmentRouteOf(facts: AttachmentRouteFacts): AttachmentRoute;
19
+ export declare function attachmentWithheldReasonText(reason: AttachmentWithheldReason, lang?: UiLanguage): string;
20
+ export declare function attachmentLocalCopyNote(): string;
@@ -0,0 +1,39 @@
1
+ import { msg, renderMessage } from './i18n/translate.js';
2
+ import { readOwnDataNonEmptyString } from './ownKey.js';
3
+ export const TOOLS_LOCATIONS = Object.freeze(['this-machine', 'elsewhere', 'unconfirmed']);
4
+ export const ATTACHMENT_ROUTE_LEGS = Object.freeze(['at_mention', 'edited_file', 'paste', 'ide_selection']);
5
+ const _withheldReasonsPinned = true;
6
+ void _withheldReasonsPinned;
7
+ const ATTACH = Object.freeze({ route: 'attach_content', localCopy: false });
8
+ const ATTACH_LOCAL_COPY = Object.freeze({ route: 'attach_content', localCopy: true });
9
+ const WITHHOLD_ELSEWHERE = Object.freeze({ route: 'withhold', reason: 'tools-elsewhere' });
10
+ const WITHHOLD_UNCONFIRMED = Object.freeze({ route: 'withhold', reason: 'tools-location-unconfirmed' });
11
+ const SNAPSHOT_LEGS = new Set(['paste', 'ide_selection']);
12
+ function closedWord(facts, key, words) {
13
+ try {
14
+ if (typeof facts !== 'object' || facts === null)
15
+ return undefined;
16
+ const raw = readOwnDataNonEmptyString(facts, key);
17
+ return raw !== undefined && words.includes(raw) ? raw : undefined;
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ }
23
+ export function attachmentRouteOf(facts) {
24
+ const where = closedWord(facts, 'toolsLocation', TOOLS_LOCATIONS);
25
+ if (where === 'this-machine')
26
+ return ATTACH;
27
+ const leg = closedWord(facts, 'leg', ATTACHMENT_ROUTE_LEGS);
28
+ if (leg !== undefined && SNAPSHOT_LEGS.has(leg))
29
+ return ATTACH_LOCAL_COPY;
30
+ return where === 'elsewhere' ? WITHHOLD_ELSEWHERE : WITHHOLD_UNCONFIRMED;
31
+ }
32
+ export function attachmentWithheldReasonText(reason, lang) {
33
+ return reason === 'tools-elsewhere'
34
+ ? renderMessage(msg('attachments.withheld.toolsElsewhere.row'), lang)
35
+ : renderMessage(msg('attachments.withheld.toolsLocationUnconfirmed.row'), lang);
36
+ }
37
+ export function attachmentLocalCopyNote() {
38
+ return renderMessage(msg('attachments.localCopy.model'));
39
+ }
@@ -25,7 +25,7 @@ const OPT_IN_KEYS = [
25
25
  'mcpInstructions',
26
26
  ];
27
27
  const DEFAULT_ON_ONLY_KEYS = ['agentListing', 'skillsListing'];
28
- const PRODUCT_DEFAULT_KEYS = ['backgroundTasks', 'toolsDelta', 'todoReminder'];
28
+ const PRODUCT_DEFAULT_KEYS = ['backgroundTasks', 'toolsDelta', 'todoReminder', 'mcpInstructions'];
29
29
  function productDefaultAttachments() {
30
30
  const out = {};
31
31
  for (const k of PRODUCT_DEFAULT_KEYS)
@@ -0,0 +1,12 @@
1
+ export type BuiltinOutputStyleName = 'default' | 'Proactive' | 'Concise' | 'Explanatory' | 'Learning';
2
+ export interface BuiltinOutputStyle {
3
+ readonly name: string;
4
+ readonly source: 'built-in';
5
+ readonly description: string;
6
+ readonly keepCodingInstructions: true;
7
+ readonly prompt: string;
8
+ readonly turnReminder?: string;
9
+ readonly waitingTurnReminder?: string;
10
+ }
11
+ export declare const BUILTIN_OUTPUT_STYLES: Readonly<Record<BuiltinOutputStyleName, BuiltinOutputStyle | null>>;
12
+ export declare function builtinOutputStyleOf(name: string): BuiltinOutputStyle | null | undefined;
@@ -0,0 +1,147 @@
1
+ const INSIGHTS_SECTION = `
2
+ ## Insights
3
+ In order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):
4
+ "\`★ Insight ─────────────────────────────────────\`
5
+ [2-3 key educational points]
6
+ \`─────────────────────────────────────────────────\`"
7
+
8
+ These insights should be included in the conversation, not in the codebase. You should generally focus on interesting insights that are specific to the codebase or the code you just wrote, rather than general programming concepts.`;
9
+ const PROACTIVE_SECTION = `The user chose continuous, autonomous execution. You should:
10
+
11
+ 1. **Execute immediately** — Start implementing right away. Make reasonable assumptions and proceed on low-risk work.
12
+ 2. **Minimize interruptions** — Prefer making reasonable assumptions over asking questions for routine decisions.
13
+ 3. **Prefer action over planning** — Do not enter plan mode unless the user explicitly asks. When in doubt, start coding.
14
+ 4. **Expect course corrections** — The user may provide suggestions or course corrections at any point; treat those as normal input.
15
+ 5. **Do not take overly destructive actions** — This is not a license to destroy. Anything that deletes data or modifies shared or production systems still needs explicit user confirmation. If you reach such a decision point, ask and wait, or course correct to a safer method instead.
16
+ 6. **Avoid data exfiltration** — Post even routine messages to chat platforms or work tickets only if the user has directed you to. You must not share secrets (e.g. credentials, internal documentation) unless the user has explicitly authorized both that specific secret and its destination.`;
17
+ const CONCISE_SECTION = `The user chose brevity over narration. You should:
18
+
19
+ 1. **Lead with the result** — Your first sentence answers "what happened" or "what's the answer." No preamble ("Let me...", "Now I'll...") and no closing recap of what you already said.
20
+ 2. **Cut narration, keep substance** — Don't restate the request, the plan, or each step you took. Report outcomes, decisions, and anything the user must act on.
21
+ 3. **Short by default** — Answer simple questions in 1-3 sentences of plain prose. Use headers, tables, and bullet lists only when they carry real structure, never as decoration.
22
+ 4. **State things plainly** — Skip hedging boilerplate. Mention a caveat only when it changes what the user should do next.
23
+ 5. **Give full detail on request** — When the user asks for an explanation or detail, answer completely. Conciseness never means withholding requested information.
24
+ 6. **Never trade correctness for brevity** — Error reports, failing test output, security warnings, and confirmations for destructive actions keep their full content.
25
+
26
+ Where these rules conflict with more general communication or formatting guidance elsewhere in your instructions, these rules win.`;
27
+ export const BUILTIN_OUTPUT_STYLES = Object.freeze({
28
+ default: null,
29
+ Proactive: Object.freeze({
30
+ name: 'Proactive',
31
+ source: 'built-in',
32
+ description: "Sema executes immediately, minimizes interruptions, and prefers action over planning",
33
+ keepCodingInstructions: true,
34
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. You should work proactively and autonomously, executing immediately and minimizing interruptions.
35
+
36
+ # Proactive Style Active
37
+ ${PROACTIVE_SECTION}`,
38
+ turnReminder: "Execute autonomously, minimize interruptions, prefer action over planning.",
39
+ waitingTurnReminder: "Execute autonomously and minimize interruptions. If the only work left is waiting for a background task or monitor you started, end your turn now: you will be notified when it finishes or fires. Do not poll, sleep, or re-read its output while you wait.",
40
+ }),
41
+ Concise: Object.freeze({
42
+ name: 'Concise',
43
+ source: 'built-in',
44
+ description: "Sema responds tersely, leading with results and skipping preamble and narration",
45
+ keepCodingInstructions: true,
46
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. Keep your responses short and direct while doing the work just as thoroughly.
47
+
48
+ # Concise Style Active
49
+ ${CONCISE_SECTION}`,
50
+ turnReminder: "Be concise: lead with the result, skip preamble and narration, keep only what the user needs.",
51
+ }),
52
+ Explanatory: Object.freeze({
53
+ name: 'Explanatory',
54
+ source: 'built-in',
55
+ description: "Sema explains its implementation choices and codebase patterns",
56
+ keepCodingInstructions: true,
57
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should provide educational insights about the codebase along the way.
58
+
59
+ You should be clear and educational, providing helpful explanations while remaining focused on the task. Balance educational content with task completion. When providing insights, you may exceed typical length constraints, but remain focused and relevant.
60
+
61
+ # Explanatory Style Active
62
+ ${INSIGHTS_SECTION}`,
63
+ }),
64
+ Learning: Object.freeze({
65
+ name: 'Learning',
66
+ source: 'built-in',
67
+ description: "Sema pauses and asks you to write small pieces of code for hands-on practice",
68
+ keepCodingInstructions: true,
69
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should help users learn more about the codebase through hands-on practice and educational insights.
70
+
71
+ You should be collaborative and encouraging. Balance task completion with learning by requesting user input for meaningful design decisions while handling routine implementation yourself.
72
+
73
+ # Learning Style Active
74
+ ## Requesting Human Contributions
75
+ In order to encourage learning, ask the human to contribute 2-10 line code pieces when generating 20+ lines involving:
76
+ - Design decisions (error handling, data structures)
77
+ - Business logic with multiple valid approaches
78
+ - Key algorithms or interface definitions
79
+
80
+ **TodoList Integration**: If using a TodoList for the overall task, include a specific todo item like "Request human input on [specific decision]" when planning to request human input. This ensures proper task tracking. Note: TodoList is not required for all tasks.
81
+
82
+ Example TodoList flow:
83
+ ✓ "Set up component structure with placeholder for logic"
84
+ ✓ "Request human collaboration on decision logic implementation"
85
+ ✓ "Integrate contribution and complete feature"
86
+
87
+ ### Request Format
88
+ \`\`\`
89
+ ● **Learn by Doing**
90
+ **Context:** [what's built and why this decision matters]
91
+ **Your Task:** [specific function/section in file, mention file and TODO(human) but do not include line numbers]
92
+ **Guidance:** [trade-offs and constraints to consider]
93
+ \`\`\`
94
+
95
+ ### Key Guidelines
96
+ - Frame contributions as valuable design decisions, not busy work
97
+ - You must first add a TODO(human) section into the codebase with your editing tools before making the Learn by Doing request
98
+ - Make sure there is one and only one TODO(human) section in the code
99
+ - Don't take any action or output anything after the Learn by Doing request. Wait for human implementation before proceeding.
100
+
101
+ ### Example Requests
102
+
103
+ **Whole Function Example:**
104
+ \`\`\`
105
+ ● **Learn by Doing**
106
+
107
+ **Context:** I've set up the hint feature UI with a button that triggers the hint system. The infrastructure is ready: when clicked, it calls selectHintCell() to determine which cell to hint, then highlights that cell with a yellow background and shows possible values. The hint system needs to decide which empty cell would be most helpful to reveal to the user.
108
+
109
+ **Your Task:** In sudoku.js, implement the selectHintCell(board) function. Look for TODO(human). This function should analyze the board and return {row, col} for the best cell to hint, or null if the puzzle is complete.
110
+
111
+ **Guidance:** Consider multiple strategies: prioritize cells with only one possible value (naked singles), or cells that appear in rows/columns/boxes with many filled cells. You could also consider a balanced approach that helps without making it too easy. The board parameter is a 9x9 array where 0 represents empty cells.
112
+ \`\`\`
113
+
114
+ **Partial Function Example:**
115
+ \`\`\`
116
+ ● **Learn by Doing**
117
+
118
+ **Context:** I've built a file upload component that validates files before accepting them. The main validation logic is complete, but it needs specific handling for different file type categories in the switch statement.
119
+
120
+ **Your Task:** In upload.js, inside the validateFile() function's switch statement, implement the 'case "document":' branch. Look for TODO(human). This should validate document files (pdf, doc, docx).
121
+
122
+ **Guidance:** Consider checking file size limits (maybe 10MB for documents?), validating the file extension matches the MIME type, and returning {valid: boolean, error?: string}. The file object has properties: name, size, type.
123
+ \`\`\`
124
+
125
+ **Debugging Example:**
126
+ \`\`\`
127
+ ● **Learn by Doing**
128
+
129
+ **Context:** The user reported that number inputs aren't working correctly in the calculator. I've identified the handleInput() function as the likely source, but need to understand what values are being processed.
130
+
131
+ **Your Task:** In calculator.js, inside the handleInput() function, add 2-3 console.log statements after the TODO(human) comment to help debug why number inputs fail.
132
+
133
+ **Guidance:** Consider logging: the raw input value, the parsed result, and any validation state. This will help us understand where the conversion breaks.
134
+ \`\`\`
135
+
136
+ ### After Contributions
137
+ Share one insight connecting their code to broader patterns or system effects. Avoid praise or repetition.
138
+
139
+ ## Insights
140
+ ${INSIGHTS_SECTION}`,
141
+ }),
142
+ });
143
+ export function builtinOutputStyleOf(name) {
144
+ if (typeof name !== 'string' || !Object.hasOwn(BUILTIN_OUTPUT_STYLES, name))
145
+ return undefined;
146
+ return BUILTIN_OUTPUT_STYLES[name];
147
+ }
@@ -32,3 +32,6 @@ export type CheckpointDeadlineState = 'armed' | 'none' | 'unknown';
32
32
  export declare function checkpointDeadlineStateOf(row: object | null | undefined): CheckpointDeadlineState;
33
33
  export declare function unboundWayOutContent(state: CheckpointDeadlineState, lang?: UiLanguage | (string & {})): string;
34
34
  export declare function rowBarWayOutContent(bar: CheckpointRowBar, state: CheckpointDeadlineState, lang?: UiLanguage | (string & {})): string;
35
+ export type DecisionRefusalWayOut = 'cancel_run' | 'newer_worker';
36
+ export declare function isDecisionRefusalWayOut(v: {} | null | undefined): v is DecisionRefusalWayOut;
37
+ export declare function decisionRefusalWayOutContent(wayOut: DecisionRefusalWayOut | (string & {}), lang?: UiLanguage | (string & {})): string | undefined;
@@ -121,6 +121,19 @@ export function unboundWayOutContent(state, lang) {
121
121
  }
122
122
  export function rowBarWayOutContent(bar, state, lang) {
123
123
  if (bar.kind === 'lacking')
124
- return renderMessage(msg('approval.rowUnresumable.lackingWayOut'), isUiLanguage(lang) ? lang : undefined);
124
+ return lackingWayOutContent(lang);
125
125
  return unboundWayOutContent(state, lang);
126
126
  }
127
+ function lackingWayOutContent(lang) {
128
+ return renderMessage(msg('approval.rowUnresumable.lackingWayOut'), isUiLanguage(lang) ? lang : undefined);
129
+ }
130
+ const WAY_OUT_WORDS = Object.freeze({ cancel_run: true, newer_worker: true });
131
+ const DECISION_REFUSAL_WAY_OUTS = Object.freeze(Object.keys(WAY_OUT_WORDS));
132
+ export function isDecisionRefusalWayOut(v) {
133
+ return typeof v === 'string' && DECISION_REFUSAL_WAY_OUTS.includes(v);
134
+ }
135
+ export function decisionRefusalWayOutContent(wayOut, lang) {
136
+ if (!isDecisionRefusalWayOut(wayOut))
137
+ return undefined;
138
+ return wayOut === 'newer_worker' ? lackingWayOutContent(lang) : unboundWayOutContent('unknown', lang);
139
+ }
@@ -1,6 +1,8 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
1
2
  export interface CompactionStatusReading {
2
3
  readonly compacting: boolean;
3
4
  readonly since?: number;
5
+ readonly openTriggers?: readonly string[];
4
6
  }
5
7
  export type CompactionStatusChange = {
6
8
  readonly kind: 'opened';
@@ -32,3 +34,10 @@ export interface PrintCompactionStatusCtx {
32
34
  }
33
35
  export declare function createCompactionStatusTracker(): CompactionStatusTracker;
34
36
  export declare function compactionStatusFrameOf(change: CompactionStatusChange | null | undefined, ctx: PrintCompactionStatusCtx): PrintCompactionStatusFrame | null;
37
+ export type CompactionStopVerdict = {
38
+ readonly kind: 'compaction_canceled';
39
+ } | {
40
+ readonly kind: 'interrupted';
41
+ };
42
+ export declare function compactionStopVerdict(reading: CompactionStatusReading | null | undefined): CompactionStopVerdict;
43
+ export declare function compactionCanceledSentence(lang?: UiLanguage): string;
@@ -1,4 +1,5 @@
1
- import { readOwnDataValue } from './ownKey.js';
1
+ import { msg, renderMessage } from './i18n/translate.js';
2
+ import { appendOwnElement, readOwnDataValue } from './ownKey.js';
2
3
  import { snapshotIsSubFlow, snapshotSegmentIdentity } from './adapter/types.js';
3
4
  const _printStatusFramePins = [true, true];
4
5
  void _printStatusFramePins;
@@ -20,9 +21,10 @@ function armLane(m) {
20
21
  function openOf(pass, lane, startedAt, trigger) {
21
22
  if (lane === 'unreadable')
22
23
  return null;
23
- if (nonEmpty(trigger) === undefined)
24
+ const t = nonEmpty(trigger);
25
+ if (t === undefined)
24
26
  return null;
25
- return { kind: 'open', pass, main: lane === 'main', ...(typeof startedAt === 'number' && Number.isFinite(startedAt) ? { startedAt } : {}) };
27
+ return { kind: 'open', pass, main: lane === 'main', trigger: t, ...(typeof startedAt === 'number' && Number.isFinite(startedAt) ? { startedAt } : {}) };
26
28
  }
27
29
  function parse(input) {
28
30
  const plane = own(input, 'plane');
@@ -101,7 +103,11 @@ export function createCompactionStatusTracker() {
101
103
  if (mainOpen() === 0)
102
104
  return { compacting: false };
103
105
  const s = since();
104
- return { compacting: true, ...(s !== undefined ? { since: s } : {}) };
106
+ const triggers = [];
107
+ for (const e of open.values())
108
+ if (e.main)
109
+ appendOwnElement(triggers, e.trigger);
110
+ return { compacting: true, ...(s !== undefined ? { since: s } : {}), openTriggers: Object.freeze(triggers) };
105
111
  };
106
112
  return {
107
113
  take(input) {
@@ -115,7 +121,7 @@ export function createCompactionStatusTracker() {
115
121
  if (open.has(p.pass) || closed.has(p.pass))
116
122
  return null;
117
123
  const before = mainOpen();
118
- open.set(p.pass, { main: p.main === true, ...(p.startedAt !== undefined ? { startedAt: p.startedAt } : {}) });
124
+ open.set(p.pass, { main: p.main === true, trigger: p.trigger ?? '', ...(p.startedAt !== undefined ? { startedAt: p.startedAt } : {}) });
119
125
  if (before === 0 && p.main === true) {
120
126
  const s = since();
121
127
  return { kind: 'opened', pass: p.pass, ...(s !== undefined ? { since: s } : {}) };
@@ -194,3 +200,21 @@ export function compactionStatusFrameOf(change, ctx) {
194
200
  return null;
195
201
  }
196
202
  }
203
+ const STOP_CANCELED = Object.freeze({ kind: 'compaction_canceled' });
204
+ const STOP_INTERRUPTED = Object.freeze({ kind: 'interrupted' });
205
+ export function compactionStopVerdict(reading) {
206
+ try {
207
+ if (own(reading, 'compacting') !== true)
208
+ return STOP_INTERRUPTED;
209
+ const triggers = own(reading, 'openTriggers');
210
+ if (!Array.isArray(triggers) || own(triggers, 'length') !== 1)
211
+ return STOP_INTERRUPTED;
212
+ return own(triggers, '0') === 'manual' ? STOP_CANCELED : STOP_INTERRUPTED;
213
+ }
214
+ catch {
215
+ return STOP_INTERRUPTED;
216
+ }
217
+ }
218
+ export function compactionCanceledSentence(lang) {
219
+ return renderMessage(msg('session.compaction.canceled'), lang);
220
+ }
@@ -0,0 +1,136 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ export declare const CA_PIN_LIMITS: Readonly<{
3
+ addressMaxChars: 2048;
4
+ authorityMaxChars: 300;
5
+ fingerprintsMax: 16;
6
+ fingerprintMaxChars: 128;
7
+ bodyMaxBytes: 1048576;
8
+ servedMax: 16;
9
+ pemMaxBytes: 16384;
10
+ budgetMs: 120000;
11
+ roundMs: 10000;
12
+ retriesMax: 3;
13
+ waitCapMs: 60000;
14
+ jitterMaxMs: 2000;
15
+ }>;
16
+ export type CenterAddressSeat = 'invite' | 'address';
17
+ export type CenterAddressRefusal = 'bad_input' | 'empty' | 'too_long' | 'unsafe_character' | 'scheme' | 'userinfo' | 'percent_in_host' | 'unparseable' | 'query' | 'fragment' | 'trailing_dot' | 'ip_not_canonical' | 'plaintext_remote' | 'path' | 'fingerprint' | 'too_many_fingerprints';
18
+ export type CenterAddressReading = {
19
+ readonly ok: true;
20
+ readonly seat: CenterAddressSeat;
21
+ readonly origin: string;
22
+ readonly centerKey: string;
23
+ readonly fingerprints: readonly string[];
24
+ } | {
25
+ readonly ok: false;
26
+ readonly reason: CenterAddressRefusal;
27
+ };
28
+ export type TrustOriginRefusal = 'empty' | 'too_long' | 'unsafe_character' | 'scheme' | 'userinfo' | 'percent_in_host' | 'unparseable' | 'trailing_dot' | 'ip_not_canonical';
29
+ export type TrustOriginReading = {
30
+ readonly ok: true;
31
+ readonly origin: string;
32
+ } | {
33
+ readonly ok: false;
34
+ readonly reason: TrustOriginRefusal;
35
+ };
36
+ export declare function readCenterAddress(raw: string | null | undefined, seat: CenterAddressSeat): CenterAddressReading;
37
+ export declare function trustOriginOf(url: string | null | undefined): TrustOriginReading;
38
+ export type CaFingerprintsRefusal = 'bad_input' | 'prefix' | 'fingerprint' | 'too_many_fingerprints';
39
+ export type CaFingerprintsReading = {
40
+ readonly ok: true;
41
+ readonly fingerprints: readonly string[];
42
+ } | {
43
+ readonly ok: false;
44
+ readonly reason: CaFingerprintsRefusal;
45
+ readonly index?: number;
46
+ };
47
+ export declare function caFingerprintsOf(texts: readonly string[] | null | undefined): CaFingerprintsReading;
48
+ export declare function caFingerprintOfDer(der: Uint8Array): string;
49
+ export declare function caFingerprintDisplay(fp: string | null | undefined): string | undefined;
50
+ export type CaCertificateParser = (der: Uint8Array) => CaCertificateFacts | null | undefined;
51
+ export interface CaCertificateFacts {
52
+ readonly raw: Uint8Array;
53
+ readonly subject: string;
54
+ readonly notAfter: string;
55
+ readonly selfSigned: boolean;
56
+ }
57
+ export interface CaBootstrapRequest {
58
+ readonly named?: readonly string[];
59
+ readonly parseCertificate?: CaCertificateParser;
60
+ }
61
+ export interface CaServedCertificate {
62
+ readonly fingerprint: string;
63
+ readonly pem: string;
64
+ readonly selfSigned: boolean;
65
+ readonly subject?: string;
66
+ readonly notAfter?: string;
67
+ }
68
+ export type CaBootstrapRefusal = 'bad_input' | 'parser_unavailable' | 'body_too_large' | 'body_not_json' | 'body_shape' | 'served_count' | 'certificate_too_large' | 'certificate_not_canonical' | 'certificate_unparseable' | 'served_duplicate' | 'named_not_served' | 'anchor_not_self_signed' | 'unconfigured_with_fingerprints';
69
+ export type CaBootstrapReading = {
70
+ readonly kind: 'unconfigured';
71
+ } | {
72
+ readonly kind: 'served';
73
+ readonly certificates: readonly CaServedCertificate[];
74
+ readonly anchors: readonly CaServedCertificate[];
75
+ } | {
76
+ readonly kind: 'refused';
77
+ readonly reason: CaBootstrapRefusal;
78
+ readonly index?: number;
79
+ };
80
+ export declare function readCaBootstrapBody(body: Uint8Array, request: CaBootstrapRequest): CaBootstrapReading;
81
+ export type CaBootstrapPhase = 'idle' | 'in-flight' | 'reading' | 'waiting' | 'stopped';
82
+ export type CaBootstrapStopReason = 'bad_input' | 'cancelled' | 'timed_out' | 'transport_failed' | 'content_type' | 'ca_unavailable' | 'endpoint_missing' | 'unexpected_status' | 'retry_after_unusable' | 'retry_after_too_long' | 'retries_exhausted' | 'budget_exhausted';
83
+ export interface CaBootstrapStop {
84
+ readonly action: 'stop';
85
+ readonly reason: CaBootstrapStopReason;
86
+ readonly status?: number;
87
+ readonly retryAfterSec?: number;
88
+ readonly remainingSec?: number;
89
+ }
90
+ export type CaBootstrapDecision = {
91
+ readonly action: 'attempt';
92
+ readonly timeoutMs: number;
93
+ } | {
94
+ readonly action: 'wait';
95
+ readonly afterMs: number;
96
+ readonly retryAfterSec: number;
97
+ } | {
98
+ readonly action: 'read-body';
99
+ } | {
100
+ readonly action: 'proceed';
101
+ } | CaBootstrapStop;
102
+ export interface CaBootstrapState {
103
+ readonly phase: CaBootstrapPhase;
104
+ readonly deadlineMs: number;
105
+ readonly lastNowMs: number;
106
+ readonly attempts: number;
107
+ readonly roundDeadlineMs?: number;
108
+ readonly notBeforeMs?: number;
109
+ readonly retryAfterSec?: number;
110
+ readonly stop?: CaBootstrapStop;
111
+ }
112
+ export type CaBootstrapEvent = {
113
+ readonly type: 'begin';
114
+ } | {
115
+ readonly type: 'response';
116
+ readonly status: number;
117
+ readonly contentType?: string;
118
+ readonly retryAfter?: string;
119
+ readonly jitter?: number;
120
+ } | {
121
+ readonly type: 'checkpoint';
122
+ } | {
123
+ readonly type: 'timed-out';
124
+ } | {
125
+ readonly type: 'failed';
126
+ } | {
127
+ readonly type: 'cancelled';
128
+ };
129
+ export interface CaBootstrapStep {
130
+ readonly state: CaBootstrapState;
131
+ readonly decision: CaBootstrapDecision;
132
+ }
133
+ export declare function caBootstrapOpen(nowMs: number): CaBootstrapState;
134
+ export declare function caBootstrapStep(state: CaBootstrapState, event: CaBootstrapEvent, nowMs: number): CaBootstrapStep;
135
+ export type CaPinRefusal = CenterAddressRefusal | TrustOriginRefusal | CaFingerprintsRefusal | CaBootstrapRefusal | CaBootstrapStopReason;
136
+ export declare function caPinRefusalSentence(reason: CaPinRefusal | (string & {}), lang?: UiLanguage): string;