@intentic/sandbox-contract 1.165.0 → 1.167.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 (69) hide show
  1. package/dist/agent-catalog.d.ts +0 -1
  2. package/dist/agent-catalog.d.ts.map +1 -1
  3. package/dist/agent-catalog.js +1 -2
  4. package/dist/agent-catalog.js.map +1 -1
  5. package/dist/contracts/agent.contract.d.ts +2 -2
  6. package/dist/contracts/agents.contract.d.ts +18 -0
  7. package/dist/contracts/agents.contract.d.ts.map +1 -1
  8. package/dist/contracts/agents.contract.js.map +1 -1
  9. package/dist/contracts/automations.contract.d.ts +1 -1
  10. package/dist/contracts/ci.contract.d.ts +4 -0
  11. package/dist/contracts/ci.contract.d.ts.map +1 -1
  12. package/dist/contracts/ci.contract.js +2 -1
  13. package/dist/contracts/ci.contract.js.map +1 -1
  14. package/dist/contracts/extensions.contract.d.ts +1 -0
  15. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  16. package/dist/contracts/gate.contract.d.ts +47 -0
  17. package/dist/contracts/gate.contract.d.ts.map +1 -0
  18. package/dist/contracts/gate.contract.js +9 -0
  19. package/dist/contracts/gate.contract.js.map +1 -0
  20. package/dist/contracts/kimi.contract.d.ts +0 -70
  21. package/dist/contracts/kimi.contract.d.ts.map +1 -1
  22. package/dist/contracts/kimi.contract.js +1 -5
  23. package/dist/contracts/kimi.contract.js.map +1 -1
  24. package/dist/contracts/settings.contract.d.ts +37 -3
  25. package/dist/contracts/settings.contract.d.ts.map +1 -1
  26. package/dist/contracts/system.contract.d.ts +68 -8
  27. package/dist/contracts/system.contract.d.ts.map +1 -1
  28. package/dist/contracts/system.contract.js +3 -1
  29. package/dist/contracts/system.contract.js.map +1 -1
  30. package/dist/contracts/translator.contract.d.ts +11 -0
  31. package/dist/contracts/translator.contract.d.ts.map +1 -1
  32. package/dist/contracts/translator.contract.js.map +1 -1
  33. package/dist/contracts/workspace.contract.d.ts +3 -1
  34. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  35. package/dist/events.d.ts +98 -2
  36. package/dist/events.d.ts.map +1 -1
  37. package/dist/events.js +21 -2
  38. package/dist/events.js.map +1 -1
  39. package/dist/index.d.ts +188 -81
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +3 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/model-order.d.ts.map +1 -1
  44. package/dist/model-order.js +25 -6
  45. package/dist/model-order.js.map +1 -1
  46. package/dist/schemas.d.ts +179 -21
  47. package/dist/schemas.d.ts.map +1 -1
  48. package/dist/schemas.js +90 -13
  49. package/dist/schemas.js.map +1 -1
  50. package/dist/session-names.d.ts +8 -0
  51. package/dist/session-names.d.ts.map +1 -0
  52. package/dist/session-names.js +17 -0
  53. package/dist/session-names.js.map +1 -0
  54. package/package.json +13 -2
  55. package/src/agent-catalog.ts +6 -11
  56. package/src/contracts/agents.contract.ts +8 -6
  57. package/src/contracts/ci.contract.ts +5 -1
  58. package/src/contracts/gate.contract.ts +19 -0
  59. package/src/contracts/kimi.contract.ts +4 -21
  60. package/src/contracts/system.contract.ts +9 -0
  61. package/src/contracts/translator.contract.ts +4 -6
  62. package/src/events.ts +56 -8
  63. package/src/index.ts +3 -0
  64. package/src/model-order.test.ts +29 -12
  65. package/src/model-order.ts +50 -18
  66. package/src/quick-model.test.ts +3 -3
  67. package/src/schemas.test.ts +20 -0
  68. package/src/schemas.ts +305 -64
  69. package/src/session-names.ts +44 -0
@@ -0,0 +1,44 @@
1
+ /* THE NAMES OF THE SESSIONS ONE TURN OPENS.
2
+ *
3
+ * A turn that runs Bash gets a tmux session; a turn that browses gets a Chromium the daemon watches over CDP.
4
+ * Both are named off the SDK session id by the same derivation, and both are listed together by
5
+ * GET /system/terminals — so the name is wire vocabulary, not an implementation detail of either half.
6
+ *
7
+ * It lives in the contract because three parties derive it and none of them may guess: the daemon NAMES the
8
+ * session, the web app OPENS it, and an extension that wants to point the user at a turn's live browser has only
9
+ * the fleet roster's `sessionId` to work from. A second copy of this string math anywhere is a drift waiting to
10
+ * happen — the copy would keep resolving to a plausible name that nothing has ever listed.
11
+ *
12
+ * Reached as `@intentic/sandbox-contract/session-names`, NOT through the barrel — the same shape tunnel-ids has,
13
+ * and for the same reason: this module has no dependencies, while the barrel pulls the whole contract (and
14
+ * @intentic/extension-api behind it). One subpath keeps a daemon unit test that only wants a session name from
15
+ * having to resolve the entire wire surface.
16
+ */
17
+
18
+ export const WEB_SESSION_PREFIX = "web-";
19
+ export const AGENT_SESSION_PREFIX = "agent-";
20
+ export const JOB_SESSION_PREFIX = "job-";
21
+ export const BROWSER_SESSION_PREFIX = "browser-";
22
+
23
+ /* Eight characters of the SDK session UUID, sanitized to the session-name charset. Eight is what groups a whole
24
+ * turn's work — including its subagents' — under one name, and it clears the name guard
25
+ * (`^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$`) without further escaping. Undefined when the id sanitizes to empty, which
26
+ * is never a valid session name. */
27
+ export const sessionSuffix = (sessionId: string): string | undefined => {
28
+ const id = sessionId.replace(/[^A-Za-z0-9_-]/g, "").slice(0, 8);
29
+ return id === "" ? undefined : id;
30
+ };
31
+
32
+ // The tmux session one SDK session's Bash commands run in — the same derivation the Bash hook routes commands
33
+ // through, so an emitted `terminal` frame and the live session can't drift.
34
+ export const agentSessionName = (sessionId: string): string | undefined => {
35
+ const suffix = sessionSuffix(sessionId);
36
+ return suffix === undefined ? undefined : `${AGENT_SESSION_PREFIX}${suffix}`;
37
+ };
38
+
39
+ // The browser session one SDK session drives. Shares the suffix with agentSessionName on purpose: a
40
+ // conversation's shell and its browser read as the pair they are.
41
+ export const browserSessionName = (sessionId: string): string | undefined => {
42
+ const suffix = sessionSuffix(sessionId);
43
+ return suffix === undefined ? undefined : `${BROWSER_SESSION_PREFIX}${suffix}`;
44
+ };