mixdog 1.2.6 → 1.3.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 (246) hide show
  1. package/LICENSES/simple-icons-CC0-1.0.txt +30 -0
  2. package/NOTICE.md +19 -0
  3. package/package.json +4 -1
  4. package/scripts/check-model-recommendations.mjs +89 -0
  5. package/scripts/gate-local.mjs +7 -0
  6. package/scripts/lib/isolated-test-env.mjs +16 -0
  7. package/src/agents/reviewer/AGENT.md +4 -2
  8. package/src/agents/reviewer/agent.json +1 -1
  9. package/src/defaults/shipped-history.json +7 -0
  10. package/src/defaults/skills/browser-use/SKILL.md +5 -0
  11. package/src/defaults/skills/memory-management/SKILL.md +4 -1
  12. package/src/defaults/skills/setup/references/actions.md +11 -4
  13. package/src/defaults/skills/setup-guide/SKILL.md +175 -0
  14. package/src/defaults/skills/setup-guide/model-recommendations.json +333 -0
  15. package/src/lib/rules-builder.cjs +55 -6
  16. package/src/rules/agent/AGENT.md +4 -0
  17. package/src/rules/agent-mode/AGENT_MODE.md +24 -0
  18. package/src/rules/agent-mode/MIXY.md +21 -0
  19. package/src/rules/agent-mode/ROUTINE.md +6 -0
  20. package/src/rules/lead/LEAD.md +7 -3
  21. package/src/rules/shared/70-delivery.md +3 -0
  22. package/src/runtime/agent/orchestrator/agent-runtime/room-supervisor-completion.mjs +86 -0
  23. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +77 -14
  24. package/src/runtime/agent/orchestrator/context/role-instructions.mjs +182 -13
  25. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +4 -2
  26. package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +215 -0
  27. package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +5 -4
  28. package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +10 -1
  29. package/src/runtime/agent/orchestrator/mcp/client.mjs +115 -11
  30. package/src/runtime/agent/orchestrator/mcp/oauth-account.mjs +97 -0
  31. package/src/runtime/agent/orchestrator/mcp/oauth-client.mjs +49 -0
  32. package/src/runtime/agent/orchestrator/mcp/oauth-credentials.mjs +59 -9
  33. package/src/runtime/agent/orchestrator/mcp/oauth-login.mjs +32 -7
  34. package/src/runtime/agent/orchestrator/mcp/oauth-provider.mjs +45 -6
  35. package/src/runtime/agent/orchestrator/mcp/oauth.mjs +195 -6
  36. package/src/runtime/agent/orchestrator/mcp/server-connectors.mjs +17 -0
  37. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
  38. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +1 -0
  39. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +10 -3
  40. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +4 -0
  41. package/src/runtime/agent/orchestrator/providers/cursor-client-version.mjs +1 -1
  42. package/src/runtime/agent/orchestrator/providers/openai-error-contract.mjs +17 -12
  43. package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +10 -0
  44. package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +96 -1
  45. package/src/runtime/agent/orchestrator/runtime-core/context-status-shape.mjs +4 -0
  46. package/src/runtime/agent/orchestrator/runtime-core/extension-scopes.mjs +6 -4
  47. package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +12 -0
  48. package/src/runtime/agent/orchestrator/runtime-core/plugin-mcp.mjs +1 -0
  49. package/src/runtime/agent/orchestrator/runtime-core/tool-bridge.mjs +12 -6
  50. package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +32 -5
  51. package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +10 -4
  52. package/src/runtime/agent/orchestrator/runtime-core/workflow/agents.mjs +4 -1
  53. package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +50 -20
  54. package/src/runtime/agent/orchestrator/runtime-core/workflow-ids.mjs +2 -0
  55. package/src/runtime/agent/orchestrator/session/agent-home.d.mts +4 -0
  56. package/src/runtime/agent/orchestrator/session/agent-home.mjs +33 -0
  57. package/src/runtime/agent/orchestrator/session/agent-mode.mjs +62 -0
  58. package/src/runtime/agent/orchestrator/session/agent-room-supervisor.d.mts +31 -0
  59. package/src/runtime/agent/orchestrator/session/agent-room-supervisor.mjs +241 -0
  60. package/src/runtime/agent/orchestrator/session/agent-room.d.mts +162 -0
  61. package/src/runtime/agent/orchestrator/session/agent-room.mjs +641 -0
  62. package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +7 -1
  63. package/src/runtime/agent/orchestrator/session/compact/user-message-kind.mjs +2 -0
  64. package/src/runtime/agent/orchestrator/session/compaction-archive-capture.mjs +6 -2
  65. package/src/runtime/agent/orchestrator/session/human-gate/gate.mjs +165 -0
  66. package/src/runtime/agent/orchestrator/session/human-gate/held-message.mjs +95 -0
  67. package/src/runtime/agent/orchestrator/session/human-gate/outbound-policy.mjs +221 -0
  68. package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +195 -0
  69. package/src/runtime/agent/orchestrator/session/human-gate/store.mjs +167 -0
  70. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +3 -1
  71. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +10 -0
  72. package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +16 -1
  73. package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +74 -15
  74. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +9 -1
  75. package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +5 -4
  76. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +13 -3
  77. package/src/runtime/agent/orchestrator/session/loop/usage.mjs +7 -0
  78. package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +1 -0
  79. package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +3 -1
  80. package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +6 -0
  81. package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +2 -0
  82. package/src/runtime/agent/orchestrator/session/manager/pending-lifecycle-epoch.mjs +0 -8
  83. package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +44 -16
  84. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +22 -5
  85. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +39 -4
  86. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +27 -5
  87. package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +55 -8
  88. package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +16 -0
  89. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +3 -2
  90. package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +6 -0
  91. package/src/runtime/agent/orchestrator/session/manager/workflow-switch-notice.mjs +58 -0
  92. package/src/runtime/agent/orchestrator/session/mixy-name.mjs +24 -0
  93. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +32 -5
  94. package/src/runtime/agent/orchestrator/session/routine-result.d.mts +70 -0
  95. package/src/runtime/agent/orchestrator/session/routine-result.mjs +277 -0
  96. package/src/runtime/agent/orchestrator/session/store/sweep/sweep-row.mjs +8 -0
  97. package/src/runtime/agent/orchestrator/session/store-record-strict-scan.mjs +28 -9
  98. package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +16 -2
  99. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +44 -12
  100. package/src/runtime/agent/orchestrator/session/store-summary-last-message.mjs +46 -0
  101. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +0 -4
  102. package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +44 -1
  103. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +12 -0
  104. package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +113 -5
  105. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +4 -0
  106. package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +25 -1
  107. package/src/runtime/agent/orchestrator/tools/lib/shell-run-background/promote-job.mjs +8 -0
  108. package/src/runtime/agent/orchestrator/tools/lib/shell-run-settle.mjs +6 -0
  109. package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +3 -0
  110. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +75 -57
  111. package/src/runtime/browser-bridge/client.mjs +24 -0
  112. package/src/runtime/channels/lib/scheduler.mjs +40 -12
  113. package/src/runtime/channels/lib/schedules-db.mjs +71 -12
  114. package/src/runtime/channels/lib/webhook/session-dispatch.mjs +36 -16
  115. package/src/runtime/channels/lib/webhook.mjs +0 -1
  116. package/src/runtime/channels/lib/webhooks-db.mjs +100 -10
  117. package/src/runtime/channels/lib/worker-main.mjs +17 -20
  118. package/src/runtime/computer-bridge/client.mjs +28 -1
  119. package/src/runtime/connectors/gmail-app-password.mjs +690 -0
  120. package/src/runtime/connectors/google-mcp.mjs +446 -0
  121. package/src/runtime/memory/lib/core-memory-access.mjs +69 -0
  122. package/src/runtime/memory/lib/core-memory-file.mjs +16 -8
  123. package/src/runtime/memory/lib/core-memory-index.mjs +15 -9
  124. package/src/runtime/memory/lib/core-memory-management.mjs +10 -4
  125. package/src/runtime/memory/lib/core-memory-store.mjs +53 -30
  126. package/src/runtime/memory/lib/core-memory-uniqueness.mjs +10 -6
  127. package/src/runtime/memory/lib/http-router/session-routes.mjs +3 -2
  128. package/src/runtime/memory/lib/memory-action-handlers/core-actions.mjs +44 -14
  129. package/src/runtime/memory/lib/memory-schema/core-and-meta.mjs +11 -0
  130. package/src/runtime/memory/lib/memory.mjs +7 -1
  131. package/src/runtime/memory/lib/query-core-recall.mjs +9 -1
  132. package/src/runtime/memory/lib/query-hybrid-search.mjs +2 -0
  133. package/src/runtime/memory/lib/tool-call-handler.mjs +2 -0
  134. package/src/runtime/memory/tool-defs.mjs +5 -0
  135. package/src/runtime/shared/agent-avatar-sprites.mjs +445 -0
  136. package/src/runtime/shared/agent-avatar.d.mts +64 -0
  137. package/src/runtime/shared/agent-avatar.mjs +320 -0
  138. package/src/runtime/shared/agent-route-config.d.mts +3 -0
  139. package/src/runtime/shared/agent-route-config.mjs +16 -0
  140. package/src/runtime/shared/atomic-file.mjs +14 -1
  141. package/src/runtime/shared/config.mjs +8 -1
  142. package/src/runtime/shared/connector-accounts.mjs +15 -0
  143. package/src/runtime/shared/connector-catalog.d.mts +52 -0
  144. package/src/runtime/shared/connector-catalog.mjs +230 -0
  145. package/src/runtime/shared/connector-triggers.d.mts +3 -0
  146. package/src/runtime/shared/connector-triggers.mjs +43 -0
  147. package/src/runtime/shared/google-oauth-client.mjs +24 -0
  148. package/src/runtime/shared/held-request-host.d.mts +12 -0
  149. package/src/runtime/shared/held-request-host.mjs +71 -0
  150. package/src/runtime/shared/plain-preview.d.mts +1 -0
  151. package/src/runtime/shared/plain-preview.mjs +28 -0
  152. package/src/runtime/shared/routine-limits.d.mts +11 -0
  153. package/src/runtime/shared/routine-limits.mjs +21 -0
  154. package/src/runtime/shared/routine-trigger.d.mts +10 -0
  155. package/src/runtime/shared/routine-trigger.mjs +44 -0
  156. package/src/runtime/shared/schedule-model-ref.mjs +9 -10
  157. package/src/runtime/shared/slow-span.mjs +4 -12
  158. package/src/runtime/shared/statusline/statusline-segments.mjs +13 -1
  159. package/src/runtime/shared/transcript-metadata.mjs +10 -0
  160. package/src/runtime/shared/turn-changes.mjs +0 -8
  161. package/src/runtime/shared/usage-readout-totals.mjs +56 -0
  162. package/src/runtime/shared/user-data-guard.mjs +114 -36
  163. package/src/session-runtime/agent-home-delivery.mjs +459 -0
  164. package/src/session-runtime/agent-profile-changes.mjs +21 -0
  165. package/src/session-runtime/agent-room-delivery.mjs +92 -0
  166. package/src/session-runtime/agent-task-sessions.mjs +200 -0
  167. package/src/session-runtime/boot/apis.mjs +50 -18
  168. package/src/session-runtime/boot/facade.mjs +5 -8
  169. package/src/session-runtime/boot/infrastructure.mjs +28 -17
  170. package/src/session-runtime/boot/tools.mjs +3 -0
  171. package/src/session-runtime/channel-config-api.mjs +53 -5
  172. package/src/session-runtime/cwd-plugins/core-memory-context.mjs +36 -20
  173. package/src/session-runtime/cwd-plugins/plugin-status.mjs +6 -1
  174. package/src/session-runtime/held-requests.mjs +228 -0
  175. package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +121 -0
  176. package/src/session-runtime/internal-tool-executor/feature-tools.mjs +5 -1
  177. package/src/session-runtime/internal-tool-executor/knowledge-tools.mjs +31 -2
  178. package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +31 -2
  179. package/src/session-runtime/internal-tool-executor.mjs +2 -0
  180. package/src/session-runtime/lifecycle/session-catalog.mjs +9 -0
  181. package/src/session-runtime/lifecycle/session-switch/resume.mjs +4 -0
  182. package/src/session-runtime/lifecycle/shared.mjs +6 -0
  183. package/src/session-runtime/mcp-glue/server-catalog.mjs +8 -0
  184. package/src/session-runtime/mcp-glue/server-input.mjs +3 -0
  185. package/src/session-runtime/mcp-oauth-login.mjs +112 -15
  186. package/src/session-runtime/model-route/set-route.mjs +14 -3
  187. package/src/session-runtime/owned-automation-run.mjs +229 -0
  188. package/src/session-runtime/resource-api.mjs +5 -0
  189. package/src/session-runtime/resource-mcp-api.mjs +107 -13
  190. package/src/session-runtime/resource-skills-api.mjs +12 -0
  191. package/src/session-runtime/room-member-gate.mjs +48 -0
  192. package/src/session-runtime/routine-home-turn.mjs +156 -0
  193. package/src/session-runtime/routine-owner.mjs +48 -0
  194. package/src/session-runtime/schedule-session-run.mjs +30 -64
  195. package/src/session-runtime/services/agent-tool/helpers.mjs +10 -0
  196. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-plan.mjs +19 -4
  197. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +2 -0
  198. package/src/session-runtime/services/channel-admin.mjs +93 -24
  199. package/src/session-runtime/services/memory-access.mjs +37 -0
  200. package/src/session-runtime/services/provider-admin.mjs +74 -39
  201. package/src/session-runtime/services/schedule-access.mjs +91 -0
  202. package/src/session-runtime/session-create/session-options.mjs +34 -7
  203. package/src/session-runtime/session-hooks.mjs +16 -8
  204. package/src/session-runtime/setup-tool/executor.mjs +68 -6
  205. package/src/session-runtime/setup-tool/extended-actions.mjs +72 -14
  206. package/src/session-runtime/setup-tool/settings-contract.mjs +8 -6
  207. package/src/session-runtime/setup-tool/tool-defs.mjs +8 -0
  208. package/src/session-runtime/skills-api.mjs +16 -1
  209. package/src/session-runtime/tool-policy-refresh.mjs +238 -29
  210. package/src/session-runtime/turn/session-ops.mjs +8 -1
  211. package/src/session-runtime/turn/turn-run/ask-callbacks.mjs +10 -2
  212. package/src/session-runtime/turn/turn-run/turn-prepare.mjs +3 -0
  213. package/src/session-runtime/webhook-session-run.mjs +49 -67
  214. package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +239 -0
  215. package/src/session-runtime/workflow-agents-api/agent-editor.mjs +556 -22
  216. package/src/session-runtime/workflow-agents-api/workflow-packs.mjs +11 -1
  217. package/src/session-runtime/workflow-agents-api.mjs +4 -1
  218. package/src/standalone/daemon-agent-control.mjs +1 -8
  219. package/src/standalone/daemon-session-control.mjs +11 -2
  220. package/src/standalone/daemon.mjs +18 -4
  221. package/src/standalone/session-protocol.mjs +27 -0
  222. package/src/standalone/session-service/session-calls/session-turns.mjs +9 -0
  223. package/src/standalone/session-service.mjs +19 -0
  224. package/src/tui/app/slash-commands.mjs +20 -0
  225. package/src/tui/dist/index.mjs +164 -86
  226. package/src/tui/session/context-state.mjs +6 -1
  227. package/src/tui/session/notice-surface.mjs +35 -4
  228. package/src/tui/session/queue-helpers.mjs +2 -1
  229. package/src/tui/session/session-api/extensions.mjs +4 -0
  230. package/src/tui/session/session-api/intake/submission.mjs +5 -0
  231. package/src/tui/session/session-api/integrations.mjs +8 -0
  232. package/src/tui/session/session-api/lifecycle/session-reset.mjs +13 -3
  233. package/src/tui/session/session-api/lifecycle.mjs +17 -1
  234. package/src/tui/session/session-api/routes.mjs +48 -3
  235. package/src/tui/session/session-flow/drain.mjs +12 -3
  236. package/src/tui/session/session-flow/queue/entry-shape.mjs +2 -1
  237. package/src/tui/session/session-flow/queue/take-entries.mjs +3 -2
  238. package/src/tui/session/session-flow/steering.mjs +58 -24
  239. package/src/tui/session/tool-approval.mjs +26 -5
  240. package/src/tui/session/transcript-intake.mjs +6 -2
  241. package/src/tui/session/transcript-spill.mjs +5 -1
  242. package/src/tui/session/tui-steering-persist.mjs +65 -42
  243. package/src/tui/session/turn-live-call.mjs +56 -0
  244. package/src/tui/session/turn.mjs +22 -6
  245. package/src/session-runtime/automation-agents.mjs +0 -94
  246. package/src/session-runtime/automation-workflow.mjs +0 -59
@@ -48,11 +48,21 @@ export function createWorkflowPacksApi(deps) {
48
48
  }));
49
49
  }
50
50
 
51
- async function setWorkflow(workflowId) {
51
+ // `{ scope: 'session' }` (the composer's selector in a session): a session
52
+ // with a conversation switches alone from its next turn
53
+ // (switchSessionWorkflow) and the configured workflow — the default for new
54
+ // sessions — stays as it is. Without a conversation, and without the
55
+ // scope, the choice becomes the configured workflow and an empty session
56
+ // picks it up in place, as before.
57
+ async function setWorkflow(workflowId, options = {}) {
52
58
  const requested = normalizeWorkflowId(workflowId, DEFAULT_WORKFLOW_ID);
53
59
  const id = requested === 'solo' ? DEFAULT_WORKFLOW_ID : requested;
54
60
  const pack = loadWorkflowPack(resolveDataDir(deps), id);
55
61
  if (!pack || pack.id !== id) throw new Error(`workflow "${workflowId}" not found`);
62
+ if (options?.scope === 'session') {
63
+ const switched = await deps.switchSessionWorkflow?.(id);
64
+ if (switched) return { ...switched.workflow, ...switched };
65
+ }
56
66
  saveActiveWorkflow(id);
57
67
  const applied = await deps.refreshEmptySessionToolPolicy?.();
58
68
  deps.invalidatePreSessionToolSurface?.();
@@ -1,5 +1,6 @@
1
1
  import { createOnboardingApi } from './workflow-agents-api/onboarding.mjs';
2
2
  import { createAgentEditorApi } from './workflow-agents-api/agent-editor.mjs';
3
+ import { createAgentConnectorsApi } from './workflow-agents-api/agent-connectors.mjs';
3
4
  import { createAgentRouteApi } from './workflow-agents-api/agent-route.mjs';
4
5
  import { createWorkflowPacksApi } from './workflow-agents-api/workflow-packs.mjs';
5
6
  import { createStyleAndModeApi } from './workflow-agents-api/style-and-mode.mjs';
@@ -11,9 +12,11 @@ import { createStyleAndModeApi } from './workflow-agents-api/style-and-mode.mjs'
11
12
  // getOnboardingStatus from the composed runtime API through `this`.
12
13
  export function createWorkflowAgentsApi(deps) {
13
14
  const routeApi = createAgentRouteApi(deps);
15
+ const editorApi = createAgentEditorApi({ ...deps, setAgentRoute: routeApi.setAgentRoute });
14
16
  return {
15
17
  ...createOnboardingApi(deps),
16
- ...createAgentEditorApi({ ...deps, setAgentRoute: routeApi.setAgentRoute }),
18
+ ...editorApi,
19
+ ...createAgentConnectorsApi(deps, editorApi),
17
20
  ...routeApi,
18
21
  ...createWorkflowPacksApi(deps),
19
22
  ...createStyleAndModeApi(deps),
@@ -8,8 +8,6 @@
8
8
  // this control exists — the host takes `execute` as a constructor option), and
9
9
  // `cwd`. Output: { canonicalAgentTool, execute }.
10
10
 
11
- import { deliverAutomationCompletion } from '../session-runtime/automation-agents.mjs';
12
-
13
11
  export function createCanonicalAgentControl({ getSessionService, getSessionRuntimeHost, cwd }) {
14
12
  let canonicalAgentToolPromise = null;
15
13
 
@@ -34,12 +32,7 @@ export function createCanonicalAgentControl({ getSessionService, getSessionRunti
34
32
  isKeychainPrewarmReady: () => true,
35
33
  sessionSurface: sessionService.agentSurface,
36
34
  notifySessionCompletion(ownerSessionId, text, meta = {}) {
37
- // A schedule/webhook run owns no session runtime; its own
38
- // agent-result waiter takes the completions it is owed.
39
- return (
40
- getSessionRuntimeHost()?.notifySessionCompletion?.(ownerSessionId, text, meta) === true ||
41
- deliverAutomationCompletion(ownerSessionId, text, meta)
42
- );
35
+ return getSessionRuntimeHost()?.notifySessionCompletion?.(ownerSessionId, text, meta) === true;
43
36
  },
44
37
  });
45
38
  })
@@ -1,20 +1,26 @@
1
1
  import { SESSION_ID_PATTERN } from '../runtime/agent/orchestrator/runtime-core/session-id.mjs';
2
2
  import { sessionListOutput, sessionReadOutput, SESSION_TOOL_OUTPUT_BYTES } from './session-tool-output.mjs';
3
+ import { createAgentTaskSessions } from '../session-runtime/agent-task-sessions.mjs';
3
4
 
4
5
  const TARGET_ACTIONS = new Set(['status', 'read', 'send', 'cancel', 'delete']);
5
6
  const MUTATING_ACTIONS = new Set(['send', 'cancel', 'delete']);
6
7
 
7
8
  /** Model-facing session operations over the same service used by desktop and TUI. */
8
- export function createSessionControl({ getSessionService }) {
9
+ export function createSessionControl({
10
+ getSessionService,
11
+ agentTasks = createAgentTaskSessions({ getSessionService }),
12
+ }) {
9
13
  return async function executeSessionControl(args = {}, context = {}) {
10
14
  const action = args.action;
11
- if (action !== 'list' && !TARGET_ACTIONS.has(action)) {
15
+ if (action !== 'list' && action !== 'create' && !TARGET_ACTIONS.has(action)) {
12
16
  throw new Error(`session: unsupported remote action "${action}"`);
13
17
  }
14
18
  const caller = context.callerSessionId;
15
19
  if (typeof caller !== 'string' || !SESSION_ID_PATTERN.test(caller)) {
16
20
  throw new Error('session: caller session is required');
17
21
  }
22
+ // `callerAgentId`: set only for an attended agent conversation (workspace-tools.mjs).
23
+ if (action === 'create') return agentTasks.create(args, context);
18
24
  const sessionId = typeof args.session_id === 'string' ? args.session_id.trim() : '';
19
25
  if (TARGET_ACTIONS.has(action) && (typeof sessionId !== 'string' || !SESSION_ID_PATTERN.test(sessionId))) {
20
26
  throw new Error(`session: session_id is required for action=${action}`);
@@ -45,6 +51,9 @@ export function createSessionControl({ getSessionService }) {
45
51
  if (typeof args.prompt !== 'string' || !args.prompt.trim()) {
46
52
  throw new Error('session: prompt is required for action=send');
47
53
  }
54
+ // The agent's follow-up in a task session it created reports back too.
55
+ const origin = await agentTasks.originFor(sessionId, context.callerAgentId);
56
+ if (origin) return { sessionId, accepted: await agentTasks.send(sessionId, args.prompt, origin) };
48
57
  const result = await service.submitSession({
49
58
  sessionId,
50
59
  prompt: args.prompt,
@@ -77,6 +77,8 @@ import { createStoredSessionViews } from './daemon-stored-session-views.mjs';
77
77
  import * as quotaResumeStore from '../runtime/shared/quota-resume-store.mjs';
78
78
  import { registerWorktreeCacheCleanups } from '../runtime/shared/worktrees/cache-cleanups.mjs';
79
79
  import { createInlineSessionRuntimeHost } from './session-runtime-inline-host.mjs';
80
+ import { recoverScheduleResults, setAgentHomeLiveSurface } from '../session-runtime/agent-home-delivery.mjs';
81
+ import { recoverRoutineDeliveries } from '../session-runtime/owned-automation-run.mjs';
80
82
  import { getStandaloneMemoryRuntime } from '../session-runtime/services/memory-runtime-proxy.mjs';
81
83
  import { registerTranscriptPurgeHook } from '../session-runtime/session-transcript-purge.mjs';
82
84
  import { createBootPhaseProfiler } from './boot-phase-profiler.mjs';
@@ -95,7 +97,6 @@ import { createDesktopRuntime } from './daemon-desktop-runtime.mjs';
95
97
  import { createCanonicalAgentControl } from './daemon-agent-control.mjs';
96
98
  import { createSessionControl } from './daemon-session-control.mjs';
97
99
  import { flushAllIndexWrites } from '../session-runtime/services/agent-tool/index-write-queue.mjs';
98
- import { registerAutomationAgentTool } from '../session-runtime/automation-agents.mjs';
99
100
  import {
100
101
  compareRuntimeVersions,
101
102
  SESSION_CAPABILITY_FINGERPRINT,
@@ -925,9 +926,6 @@ async function main() {
925
926
  cwd: CWD,
926
927
  });
927
928
  canonicalAgentControl = agentControl;
928
- // Schedules and webhooks run headless here; their sessions reach the same
929
- // canonical agent control through the automation tool scope.
930
- registerAutomationAgentTool(agentControl.execute);
931
929
  const requestedRuntimeMode = String(process.env.MIXDOG_SESSION_RUNTIME_MODE || '')
932
930
  .trim()
933
931
  .toLowerCase();
@@ -984,6 +982,22 @@ async function main() {
984
982
  },
985
983
  log,
986
984
  });
985
+ // Schedule results reach an open home thread at once (and wait out its turn).
986
+ setAgentHomeLiveSurface({
987
+ busy: (sessionId) => sessionService.liveSessionBusy(sessionId),
988
+ notice: (sessionId, notice) => sessionService.pushLiveSessionNotice(sessionId, notice),
989
+ // A task session's result (session create): the agent relays it in one turn.
990
+ wake: (sessionId, prompt) =>
991
+ sessionService.submitSession({ sessionId, prompt, options: { mode: 'prompt', kickoff: true } }),
992
+ // A routine fire: one queued turn in its bot's thread (routine-home-turn.mjs).
993
+ submit: async (sessionId, prompt, options) =>
994
+ (await sessionService.submitSession({ sessionId, prompt, options }))?.accepted === true,
995
+ abort: (sessionId) => sessionService.abortSession({ sessionId }),
996
+ });
997
+ // Results queued before a restart are posted now; results a finished run
998
+ // could not queue (kept on its routine's record) are queued again.
999
+ recoverScheduleResults().catch((error) => log(`routine results recovery failed: ${error?.message || error}`));
1000
+ recoverRoutineDeliveries().catch((error) => log(`routine delivery recovery failed: ${error?.message || error}`));
987
1001
  sessionTransport = createSessionTransport({
988
1002
  // ctx carries the CLIENT token: the session service refcounts views across
989
1003
  // processes with it, so a terminal exiting cannot destroy the session a
@@ -9,7 +9,18 @@ export const SESSION_READ_ACTIONS = Object.freeze([
9
9
  'inspectProjectBranch',
10
10
  'isSessionTerminal',
11
11
  'contextStatus',
12
+ 'agentDefinitionPresence',
13
+ 'archivedAgentIdentities',
12
14
  'getAgentDefinition',
15
+ 'getAgentAvatarImage',
16
+ 'getAgentConnectors',
17
+ 'getProjectConnectors',
18
+ 'getAgentPermissions',
19
+ 'listConnectors',
20
+ 'listConnectorTools',
21
+ 'getLeadPersona',
22
+ 'getLeadAgentBody',
23
+ 'getLeadStatus',
13
24
  'getAutoClear',
14
25
  'getChannelSettings',
15
26
  'getChannelSetup',
@@ -91,6 +102,7 @@ export const SESSION_CONFIGURE_ACTIONS = Object.freeze([
91
102
  'addPlugin',
92
103
  'addSkill',
93
104
  'agentControl',
105
+ 'appendRoomRows',
94
106
  'askSide',
95
107
  'authenticateProvider',
96
108
  'beginOAuthProviderLogin',
@@ -111,6 +123,8 @@ export const SESSION_CONFIGURE_ACTIONS = Object.freeze([
111
123
  'consumeCodexRateLimitResetCredit',
112
124
  'createWorkflow',
113
125
  'deleteAgentDefinition',
126
+ 'restoreAgentDefinition',
127
+ 'purgeAgentDefinition',
114
128
  'deleteHookRule',
115
129
  'deleteMediaAsset',
116
130
  'deleteMediaAssets',
@@ -142,7 +156,9 @@ export const SESSION_CONFIGURE_ACTIONS = Object.freeze([
142
156
  'reloadSkills',
143
157
  'rememberPromptHistory',
144
158
  'removeMcpServer',
159
+ 'removeSkill',
145
160
  'continueSessionInModel',
161
+ 'decideRoomTurn',
146
162
  'scheduleQuotaResume',
147
163
  'cancelQuotaResume',
148
164
  'retryFailedTurn',
@@ -164,7 +180,18 @@ export const SESSION_CONFIGURE_ACTIONS = Object.freeze([
164
180
  'runDoctor',
165
181
  'runScheduleNow',
166
182
  'runUpdateNow',
183
+ 'runWebhookNow',
184
+ 'retryRoutineDelivery',
167
185
  'saveAgentDefinition',
186
+ 'setAgentConnectors',
187
+ 'setAgentConnectorEnabled',
188
+ 'setAgentConnectorToolPermission',
189
+ 'setProjectConnectorEnabled',
190
+ 'setAgentPermission',
191
+ 'saveLeadPersona',
192
+ 'saveLeadAgentBody',
193
+ 'setLeadCreated',
194
+ 'saveLeadIdentity',
168
195
  'saveMcpServer',
169
196
  'saveOpenAIUsageSessionKey',
170
197
  'saveProviderApiKey',
@@ -11,6 +11,9 @@ import {
11
11
  } from '../../../runtime/attachments/store.mjs';
12
12
  import { providerNativePdf } from '../../../runtime/agent/orchestrator/providers/registry.mjs';
13
13
  import { cancelBackgroundTasks } from '../../../runtime/shared/background-tasks.mjs';
14
+ import { isAgentModeSession } from '../../../runtime/agent/orchestrator/session/agent-mode.mjs';
15
+ import { recognisedAgentRoomSlash } from '../../../tui/app/slash-commands.mjs';
16
+ import { promptContentText } from '../../../tui/session/queue-helpers.mjs';
14
17
 
15
18
  /** Whether an abort on this session is an Agent cancelling its own turn: the
16
19
  * catalog knows it, the runtime declares agent-only visibility, or it is a
@@ -76,6 +79,12 @@ export function createSessionTurnCalls(ctx) {
76
79
  },
77
80
  };
78
81
  }
82
+ // A bot's conversation room runs only its own /compact and /clear (the
83
+ // composer's rule): every other leading `/` is message text for the model.
84
+ if (isAgentModeSession(entry.runtime.session ?? { id })) {
85
+ const text = typeof intake.prompt === 'string' ? intake.prompt : promptContentText(intake.prompt);
86
+ if (!recognisedAgentRoomSlash(text)) submissionOptions = { ...submissionOptions, skipSlashCommands: true };
87
+ }
79
88
  const accepted = await Promise.resolve(target.call(entry.runtime, intake.prompt, submissionOptions));
80
89
  if (accepted === true) {
81
90
  entry.reservedOnly = false;
@@ -237,6 +237,23 @@ export function createSessionService({
237
237
  return stopPromise;
238
238
  }
239
239
 
240
+ /** Whether the runtime hosting `sessionId` is mid-turn or holds queued input. */
241
+ function liveSessionBusy(sessionId) {
242
+ const owner = projection.sessionOwner(sessionId);
243
+ return Boolean(owner) && retention.stateBusy(owner.runtime?.getState?.());
244
+ }
245
+
246
+ /** Show a transcript notice in the hosted runtime of `sessionId` (no turn)
247
+ * and publish it to its views; false when no runtime hosts it. */
248
+ function pushLiveSessionNotice(sessionId, { text, tone = 'info', ...options } = {}) {
249
+ const owner = projection.sessionOwner(sessionId);
250
+ if (typeof owner?.runtime?.pushNotice !== 'function') return false;
251
+ owner.runtime.pushNotice(text, tone, { ...options, transcript: true });
252
+ const step = projection.advance(owner);
253
+ if (step.changed) projection.publishStep(owner, step);
254
+ return true;
255
+ }
256
+
240
257
  function getStatus() {
241
258
  const busy = retention.liveBusyCount();
242
259
  let watched = 0;
@@ -282,6 +299,8 @@ export function createSessionService({
282
299
  },
283
300
  methods: {
284
301
  ...calls,
302
+ liveSessionBusy,
303
+ pushLiveSessionNotice,
285
304
  stop,
286
305
  startQuotaResume: () => quotaResume?.start(),
287
306
  runDueQuotaResumes: () => quotaResume?.tick() ?? Promise.resolve(),
@@ -142,6 +142,26 @@ for (const command of SLASH_COMMANDS) {
142
142
  }
143
143
  }
144
144
 
145
+ /**
146
+ * The registered command a prompt runs, by the renderer's rule
147
+ * (apps/desktop renderer/slash-commands.ts recognisedSlashSpan): the text,
148
+ * trimmed, begins with `/` and its first whitespace-delimited token names a
149
+ * command or alias. Returns that token lowercased, else null: any other
150
+ * leading `/` (an absolute path, a stray word) is ordinary message text.
151
+ */
152
+ export function recognisedSlashToken(text) {
153
+ const token = /^\s*\/(\S+)/.exec(String(text ?? ''))?.[1].toLowerCase();
154
+ return token && SLASH_COMMAND_BY_TOKEN.has(token) ? token : null;
155
+ }
156
+
157
+ /** The only commands a bot's conversation room runs, by their literal name
158
+ * (`/new` stays text); mirrors the renderer's recognisedAgentRoomSlash. */
159
+ const AGENT_ROOM_SLASH_TOKENS = new Set(['compact', 'clear']);
160
+
161
+ export function recognisedAgentRoomSlash(text) {
162
+ return AGENT_ROOM_SLASH_TOKENS.has(recognisedSlashToken(text));
163
+ }
164
+
145
165
  export function normalizeSlashCommandName(cmd) {
146
166
  const name = String(cmd || '').toLowerCase();
147
167
  return SLASH_COMMAND_BY_TOKEN.get(name)?.name || name;