@sema-agent/client-core 0.103.0 → 0.104.1

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 (45) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +18 -14
  3. package/dist/adapter/downstream/eventToSdkMessage.js +2 -0
  4. package/dist/adapter/downstream/terminalToSdkResult.d.ts +0 -1
  5. package/dist/adapter/downstream/terminalToSdkResult.js +3 -1
  6. package/dist/agentSession/engineAgentRegistryRead.js +3 -0
  7. package/dist/coreValuePorts.d.ts +3 -1
  8. package/dist/coreValuePorts.js +5 -0
  9. package/dist/deviceRebind.d.ts +17 -4
  10. package/dist/deviceRebind.js +43 -14
  11. package/dist/engineAgentAbsence.d.ts +1 -0
  12. package/dist/executionPlacementWords.d.ts +3 -0
  13. package/dist/executionPlacementWords.js +2 -0
  14. package/dist/generated/engineFactTables.d.ts +3 -2
  15. package/dist/generated/engineFactTables.js +17 -1
  16. package/dist/generated/engineNoticeTables.js +12 -0
  17. package/dist/hitl/automaticAnswerVerdict.js +47 -11
  18. package/dist/hitl/livePendingAsk.d.ts +2 -1
  19. package/dist/hitl/livePendingAsk.js +7 -1
  20. package/dist/hitl/sessionPolicyDeliverable.js +31 -5
  21. package/dist/hitl/toolApprovalWire.d.ts +5 -4
  22. package/dist/hitl/toolApprovalWire.js +215 -47
  23. package/dist/host.d.ts +0 -3
  24. package/dist/hostTurnSettings.js +3 -1
  25. package/dist/humanTurn.js +2 -2
  26. package/dist/index.d.ts +5 -2
  27. package/dist/index.js +1 -0
  28. package/dist/jsonFaithful.js +5 -3
  29. package/dist/mcpLiveness.d.ts +1 -1
  30. package/dist/mcpWireCaps.js +1 -1
  31. package/dist/printModelStatus.d.ts +1 -0
  32. package/dist/printModelStatus.js +6 -2
  33. package/dist/retryStatus.d.ts +8 -1
  34. package/dist/retryStatus.js +13 -4
  35. package/dist/ruleCompileVerdict.d.ts +1 -0
  36. package/dist/ruleCompileVerdict.js +3 -1
  37. package/dist/seatContract.d.ts +7 -7
  38. package/dist/seatContract.js +39 -10
  39. package/dist/sessionRowTag.d.ts +24 -0
  40. package/dist/sessionRowTag.js +77 -0
  41. package/dist/steering.d.ts +1 -0
  42. package/dist/steering.js +34 -26
  43. package/dist/systemReminderTag.js +14 -4
  44. package/docs/INTEGRATION-CLIENTS.md +346 -11
  45. package/package.json +5 -5
package/dist/steering.js CHANGED
@@ -25,37 +25,45 @@ const PHRASE_TO_STATUS = [
25
25
  ['failed', 'failed'],
26
26
  ['killed', 'killed'],
27
27
  ];
28
+ const BACKGROUND_TASK_LINE = new RegExp('^- \\[([^\\]]+)\\] Task "([\\s\\S]*)" (' +
29
+ PHRASE_TO_STATUS.map(([phrase]) => phrase.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|') +
30
+ ')(?: — ((?:(?!" )[\\s\\S])*))?$');
28
31
  function parseBackgroundTaskLine(line) {
29
- const trimmed = line.trim();
30
- for (const [phrase, status] of PHRASE_TO_STATUS) {
31
- const suffix = `" ${phrase}`;
32
- if (!trimmed.endsWith(suffix))
33
- continue;
34
- const head = trimmed.slice(0, trimmed.length - suffix.length);
35
- const m = /^- \[([^\]]+)\] Task "([\s\S]*)$/.exec(head);
36
- if (!m)
37
- return null;
38
- const taskId = m[1];
39
- const description = m[2];
40
- if (taskId === undefined || description === undefined)
41
- return null;
42
- return {
43
- type: 'task_status',
44
- taskId,
45
- taskType: 'local_bash',
46
- status,
47
- description,
48
- deltaSummary: null,
49
- };
32
+ const m = BACKGROUND_TASK_LINE.exec(line.trim());
33
+ if (!m)
34
+ return null;
35
+ const taskId = m[1];
36
+ const description = m[2];
37
+ const status = PHRASE_TO_STATUS.find(([phrase]) => phrase === m[3])?.[1];
38
+ if (taskId === undefined || description === undefined || status === undefined)
39
+ return null;
40
+ const read = m[4];
41
+ return {
42
+ type: 'task_status',
43
+ taskId,
44
+ taskType: 'local_bash',
45
+ status,
46
+ description,
47
+ deltaSummary: null,
48
+ ...(read !== undefined ? { read } : {}),
49
+ };
50
+ }
51
+ function rowBoundariesTrusted(lines) {
52
+ let last = lines.length - 1;
53
+ while (last >= 0 && (lines[last] ?? '').trim() === '')
54
+ last--;
55
+ for (let i = 0; i < last; i++) {
56
+ if (/^- \[[^\]]+\] Task "[^"]*$/.test((lines[i] ?? '').trim()))
57
+ return false;
50
58
  }
51
- return null;
59
+ return true;
52
60
  }
53
61
  export function steeringInjectedToAttachments(source, preview) {
54
62
  if (source === 'background_tasks') {
55
- const tasks = preview
56
- .split('\n')
57
- .map(parseBackgroundTaskLine)
58
- .filter((t) => t !== null);
63
+ const lines = preview.split('\n');
64
+ const tasks = rowBoundariesTrusted(lines)
65
+ ? lines.map(parseBackgroundTaskLine).filter((t) => t !== null)
66
+ : [];
59
67
  if (tasks.length > 0)
60
68
  return tasks;
61
69
  }
@@ -39,11 +39,21 @@ export function stripSystemReminderBlocks(text) {
39
39
  }
40
40
  return pos === 0 ? text : out + text.slice(pos);
41
41
  }
42
- const SYSTEM_REMINDER_TAG_TOKEN = /<[^A-Za-z0-9>]{0,12}system-reminder(?:[^>]{0,200}>)?/gi;
43
- const SYSTEM_REMINDER_TAG_HEAD = /<[^A-Za-z0-9>]{0,12}system-reminder/i;
42
+ const ENGINE_DEFUSAL_ENTITY = /&(lt|gt);/g;
43
+ const ENVELOPE_TAG_TOKEN = /<[^A-Za-z0-9>]{0,12}(?:system-reminder|task-notification)(?:[^>]{0,200}>)?/gi;
44
+ const CUT_TAG_HEAD = /<[^A-Za-z0-9>]{0,12}([A-Za-z-]{1,16})…/g;
45
+ const ENVELOPE_TAG_HEAD_BRACKET = /<(?=[^A-Za-z0-9>]{0,12}(?:system-reminder|task-notification|([A-Za-z-]{1,16})…))/gi;
46
+ const ENVELOPE_TAG_NAMES = Object.freeze(['system-reminder', 'task-notification']);
47
+ function isCutTagName(head) {
48
+ if (head === undefined || head === '')
49
+ return false;
50
+ const h = head.toLowerCase();
51
+ return ENVELOPE_TAG_NAMES.some((name) => name.length > h.length && name.startsWith(h));
52
+ }
44
53
  export function stripSystemReminderTagTokens(text) {
45
54
  if (typeof text !== 'string')
46
55
  return text;
47
- const once = text.replace(SYSTEM_REMINDER_TAG_TOKEN, ' ');
48
- return SYSTEM_REMINDER_TAG_HEAD.test(once) ? once.replace(/</g, '&lt;') : once;
56
+ const restored = text.replace(ENGINE_DEFUSAL_ENTITY, (_entity, name) => (name === 'lt' ? '<' : '>'));
57
+ const once = restored.replace(ENVELOPE_TAG_TOKEN, ' ').replace(CUT_TAG_HEAD, (head, name) => (isCutTagName(name) ? ' …' : head));
58
+ return once.replace(ENVELOPE_TAG_HEAD_BRACKET, (bracket, cutName) => (cutName === undefined || isCutTagName(cutName) ? ' ' : bracket));
49
59
  }