@moxxy/sdk 0.1.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 (211) hide show
  1. package/dist/agent.d.ts +39 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +2 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/cache-strategy.d.ts +35 -0
  6. package/dist/cache-strategy.d.ts.map +1 -0
  7. package/dist/cache-strategy.js +2 -0
  8. package/dist/cache-strategy.js.map +1 -0
  9. package/dist/channel.d.ts +146 -0
  10. package/dist/channel.d.ts.map +1 -0
  11. package/dist/channel.js +2 -0
  12. package/dist/channel.js.map +1 -0
  13. package/dist/client-session.d.ts +83 -0
  14. package/dist/client-session.d.ts.map +1 -0
  15. package/dist/client-session.js +2 -0
  16. package/dist/client-session.js.map +1 -0
  17. package/dist/command.d.ts +90 -0
  18. package/dist/command.d.ts.map +1 -0
  19. package/dist/command.js +15 -0
  20. package/dist/command.js.map +1 -0
  21. package/dist/compactor-helpers.d.ts +34 -0
  22. package/dist/compactor-helpers.d.ts.map +1 -0
  23. package/dist/compactor-helpers.js +156 -0
  24. package/dist/compactor-helpers.js.map +1 -0
  25. package/dist/compactor.d.ts +20 -0
  26. package/dist/compactor.d.ts.map +1 -0
  27. package/dist/compactor.js +2 -0
  28. package/dist/compactor.js.map +1 -0
  29. package/dist/define.d.ts +51 -0
  30. package/dist/define.d.ts.map +1 -0
  31. package/dist/define.js +71 -0
  32. package/dist/define.js.map +1 -0
  33. package/dist/elision-helpers.d.ts +27 -0
  34. package/dist/elision-helpers.d.ts.map +1 -0
  35. package/dist/elision-helpers.js +109 -0
  36. package/dist/elision-helpers.js.map +1 -0
  37. package/dist/elision-state.d.ts +49 -0
  38. package/dist/elision-state.d.ts.map +1 -0
  39. package/dist/elision-state.js +144 -0
  40. package/dist/elision-state.js.map +1 -0
  41. package/dist/embedding-cache.d.ts +32 -0
  42. package/dist/embedding-cache.d.ts.map +1 -0
  43. package/dist/embedding-cache.js +0 -0
  44. package/dist/embedding-cache.js.map +1 -0
  45. package/dist/embedding.d.ts +21 -0
  46. package/dist/embedding.d.ts.map +1 -0
  47. package/dist/embedding.js +2 -0
  48. package/dist/embedding.js.map +1 -0
  49. package/dist/errors.d.ts +81 -0
  50. package/dist/errors.d.ts.map +1 -0
  51. package/dist/errors.js +241 -0
  52. package/dist/errors.js.map +1 -0
  53. package/dist/events.d.ts +193 -0
  54. package/dist/events.d.ts.map +1 -0
  55. package/dist/events.js +2 -0
  56. package/dist/events.js.map +1 -0
  57. package/dist/hooks.d.ts +52 -0
  58. package/dist/hooks.d.ts.map +1 -0
  59. package/dist/hooks.js +2 -0
  60. package/dist/hooks.js.map +1 -0
  61. package/dist/ids.d.ts +18 -0
  62. package/dist/ids.d.ts.map +1 -0
  63. package/dist/ids.js +7 -0
  64. package/dist/ids.js.map +1 -0
  65. package/dist/index.d.ts +45 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +18 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/install-hints.d.ts +26 -0
  70. package/dist/install-hints.d.ts.map +1 -0
  71. package/dist/install-hints.js +15 -0
  72. package/dist/install-hints.js.map +1 -0
  73. package/dist/isolation.d.ts +125 -0
  74. package/dist/isolation.d.ts.map +1 -0
  75. package/dist/isolation.js +11 -0
  76. package/dist/isolation.js.map +1 -0
  77. package/dist/log.d.ts +11 -0
  78. package/dist/log.d.ts.map +1 -0
  79. package/dist/log.js +2 -0
  80. package/dist/log.js.map +1 -0
  81. package/dist/mode-helpers.d.ts +99 -0
  82. package/dist/mode-helpers.d.ts.map +1 -0
  83. package/dist/mode-helpers.js +368 -0
  84. package/dist/mode-helpers.js.map +1 -0
  85. package/dist/mode.d.ts +133 -0
  86. package/dist/mode.d.ts.map +1 -0
  87. package/dist/mode.js +2 -0
  88. package/dist/mode.js.map +1 -0
  89. package/dist/permission.d.ts +35 -0
  90. package/dist/permission.d.ts.map +1 -0
  91. package/dist/permission.js +2 -0
  92. package/dist/permission.js.map +1 -0
  93. package/dist/plugin.d.ts +88 -0
  94. package/dist/plugin.d.ts.map +1 -0
  95. package/dist/plugin.js +2 -0
  96. package/dist/plugin.js.map +1 -0
  97. package/dist/provider-utils.d.ts +40 -0
  98. package/dist/provider-utils.d.ts.map +1 -0
  99. package/dist/provider-utils.js +163 -0
  100. package/dist/provider-utils.js.map +1 -0
  101. package/dist/provider.d.ts +219 -0
  102. package/dist/provider.d.ts.map +1 -0
  103. package/dist/provider.js +2 -0
  104. package/dist/provider.js.map +1 -0
  105. package/dist/requirements.d.ts +22 -0
  106. package/dist/requirements.d.ts.map +1 -0
  107. package/dist/requirements.js +2 -0
  108. package/dist/requirements.js.map +1 -0
  109. package/dist/schemas.d.ts +228 -0
  110. package/dist/schemas.d.ts.map +1 -0
  111. package/dist/schemas.js +88 -0
  112. package/dist/schemas.js.map +1 -0
  113. package/dist/session-like.d.ts +111 -0
  114. package/dist/session-like.d.ts.map +1 -0
  115. package/dist/session-like.js +2 -0
  116. package/dist/session-like.js.map +1 -0
  117. package/dist/skill.d.ts +30 -0
  118. package/dist/skill.d.ts.map +1 -0
  119. package/dist/skill.js +2 -0
  120. package/dist/skill.js.map +1 -0
  121. package/dist/subagent.d.ts +45 -0
  122. package/dist/subagent.d.ts.map +1 -0
  123. package/dist/subagent.js +11 -0
  124. package/dist/subagent.js.map +1 -0
  125. package/dist/token-accounting.d.ts +73 -0
  126. package/dist/token-accounting.d.ts.map +1 -0
  127. package/dist/token-accounting.js +129 -0
  128. package/dist/token-accounting.js.map +1 -0
  129. package/dist/tool-dispatch.d.ts +19 -0
  130. package/dist/tool-dispatch.d.ts.map +1 -0
  131. package/dist/tool-dispatch.js +118 -0
  132. package/dist/tool-dispatch.js.map +1 -0
  133. package/dist/tool-gating.d.ts +32 -0
  134. package/dist/tool-gating.d.ts.map +1 -0
  135. package/dist/tool-gating.js +83 -0
  136. package/dist/tool-gating.js.map +1 -0
  137. package/dist/tool.d.ts +166 -0
  138. package/dist/tool.d.ts.map +1 -0
  139. package/dist/tool.js +2 -0
  140. package/dist/tool.js.map +1 -0
  141. package/dist/transcriber.d.ts +64 -0
  142. package/dist/transcriber.d.ts.map +1 -0
  143. package/dist/transcriber.js +21 -0
  144. package/dist/transcriber.js.map +1 -0
  145. package/dist/tunnel.d.ts +25 -0
  146. package/dist/tunnel.d.ts.map +1 -0
  147. package/dist/tunnel.js +2 -0
  148. package/dist/tunnel.js.map +1 -0
  149. package/dist/type-contracts.d.ts +2 -0
  150. package/dist/type-contracts.d.ts.map +1 -0
  151. package/dist/type-contracts.js +4 -0
  152. package/dist/type-contracts.js.map +1 -0
  153. package/dist/types.test-d.d.ts +2 -0
  154. package/dist/types.test-d.d.ts.map +1 -0
  155. package/dist/types.test-d.js +22 -0
  156. package/dist/types.test-d.js.map +1 -0
  157. package/dist/view-renderer.d.ts +97 -0
  158. package/dist/view-renderer.d.ts.map +1 -0
  159. package/dist/view-renderer.js +72 -0
  160. package/dist/view-renderer.js.map +1 -0
  161. package/package.json +38 -0
  162. package/src/agent.ts +38 -0
  163. package/src/cache-strategy.ts +39 -0
  164. package/src/channel.ts +158 -0
  165. package/src/client-session.ts +88 -0
  166. package/src/command.ts +86 -0
  167. package/src/compactor-helpers.test.ts +206 -0
  168. package/src/compactor-helpers.ts +163 -0
  169. package/src/compactor.ts +20 -0
  170. package/src/define.test.ts +76 -0
  171. package/src/define.ts +113 -0
  172. package/src/elision-helpers.ts +143 -0
  173. package/src/elision-state.ts +170 -0
  174. package/src/embedding-cache.ts +0 -0
  175. package/src/embedding.ts +22 -0
  176. package/src/errors.test.ts +176 -0
  177. package/src/errors.ts +308 -0
  178. package/src/events.ts +250 -0
  179. package/src/hooks.ts +54 -0
  180. package/src/ids.ts +16 -0
  181. package/src/index.ts +304 -0
  182. package/src/install-hints.ts +43 -0
  183. package/src/isolation.ts +148 -0
  184. package/src/log.ts +11 -0
  185. package/src/loop-helpers.test.ts +78 -0
  186. package/src/mode-helpers.ts +483 -0
  187. package/src/mode.ts +139 -0
  188. package/src/package-root.test.ts +40 -0
  189. package/src/permission.ts +37 -0
  190. package/src/plugin.ts +92 -0
  191. package/src/provider-utils.test.ts +84 -0
  192. package/src/provider-utils.ts +171 -0
  193. package/src/provider.ts +195 -0
  194. package/src/requirements.ts +35 -0
  195. package/src/schemas.test.ts +106 -0
  196. package/src/schemas.ts +97 -0
  197. package/src/session-like.ts +118 -0
  198. package/src/skill.ts +34 -0
  199. package/src/subagent.ts +46 -0
  200. package/src/token-accounting.test.ts +93 -0
  201. package/src/token-accounting.ts +202 -0
  202. package/src/token-efficiency.test.ts +459 -0
  203. package/src/tool-dispatch.ts +137 -0
  204. package/src/tool-gating.ts +107 -0
  205. package/src/tool.ts +175 -0
  206. package/src/transcriber.ts +71 -0
  207. package/src/tunnel.ts +26 -0
  208. package/src/type-contracts.ts +4 -0
  209. package/src/types.test-d.ts +29 -0
  210. package/src/view-renderer.test.ts +90 -0
  211. package/src/view-renderer.ts +156 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Agent definitions — typed templates for subagent spawning. Each
3
+ * `AgentDef` describes a flavor of subagent (researcher, code-reviewer,
4
+ * summarizer, …) so plugins can register named agent kinds and the
5
+ * `dispatch_agent` tool can spawn them by type instead of relying on
6
+ * ad-hoc prompts.
7
+ *
8
+ * Why this lives in SDK (not core): the interface is the cross-package
9
+ * contract. Plugins import `AgentDef` from `@moxxy/sdk`, register
10
+ * agents via `PluginSpec.agents`, and the core's `AgentRegistry`
11
+ * surfaces them at runtime.
12
+ */
13
+ export interface AgentDef {
14
+ /** Stable name; what `dispatch_agent({ agentType })` looks up. */
15
+ readonly name: string;
16
+ /** One-line user-visible summary — surfaced in the `/agents` modal. */
17
+ readonly description: string;
18
+ /**
19
+ * System prompt prepended to the child's first message. Use to set
20
+ * persona, output format, hard constraints, etc.
21
+ */
22
+ readonly systemPrompt?: string;
23
+ /**
24
+ * Mode name for the child. Defaults to `'tool-use'`. The
25
+ * spawner falls back to tool-use if the named strategy isn't
26
+ * registered (no point failing a child over a missing block).
27
+ */
28
+ readonly mode?: string;
29
+ /**
30
+ * Restrict the child to these tools by name. Omit for full
31
+ * inheritance from the parent's registry.
32
+ */
33
+ readonly allowedTools?: ReadonlyArray<string>;
34
+ /** Default model id; overrides the parent's active model. */
35
+ readonly model?: string;
36
+ /** Per-child iteration cap. Defaults to 50. */
37
+ readonly maxIterations?: number;
38
+ }
39
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAQ;IACvB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC"}
package/dist/agent.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { EventLogReader } from './log.js';
2
+ import type { CacheHint, ProviderMessage } from './provider.js';
3
+ /**
4
+ * Context handed to a CacheStrategy when it plans breakpoints for one call.
5
+ */
6
+ export interface CacheStrategyContext {
7
+ readonly model: string;
8
+ /** Active model's context window, for strategies that scale behavior to it. */
9
+ readonly contextWindow: number;
10
+ readonly log: EventLogReader;
11
+ /**
12
+ * Index (into the `messages` array passed to `plan`) of the last message
13
+ * belonging to the stable, cacheable prefix — everything at or before it is
14
+ * byte-identical across the inner iterations of the current turn, so a
15
+ * rolling breakpoint placed here yields cache reads on every iteration.
16
+ * Undefined when the mode can't compute a boundary (e.g. no elision active);
17
+ * strategies should then fall back to a conservative breakpoint.
18
+ */
19
+ readonly stablePrefixMessageIndex?: number;
20
+ }
21
+ /**
22
+ * A swappable prompt-caching strategy. One is active per session (registered
23
+ * via plugins, exactly like compactors/modes). It decides *where* cache
24
+ * breakpoints go and returns provider-neutral {@link CacheHint}s; the provider
25
+ * is responsible for *how* to express them (Anthropic → `cache_control`).
26
+ *
27
+ * `plan` MUST be deterministic given identical inputs — a non-deterministic
28
+ * breakpoint placement shifts the cached prefix between calls and silently
29
+ * defeats the cache (paying 1.25x writes for 0 reads).
30
+ */
31
+ export interface CacheStrategyDef {
32
+ readonly name: string;
33
+ plan(messages: ReadonlyArray<ProviderMessage>, ctx: CacheStrategyContext): ReadonlyArray<CacheHint>;
34
+ }
35
+ //# sourceMappingURL=cache-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-strategy.d.ts","sourceRoot":"","sources":["../src/cache-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC7B;;;;;;;OAOG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAC5C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,CACF,QAAQ,EAAE,aAAa,CAAC,eAAe,CAAC,EACxC,GAAG,EAAE,oBAAoB,GACxB,aAAa,CAAC,SAAS,CAAC,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cache-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-strategy.js","sourceRoot":"","sources":["../src/cache-strategy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,146 @@
1
+ import type { PermissionResolver } from './permission.js';
2
+ import type { ClientSession } from './client-session.js';
3
+ /**
4
+ * A Channel is a bidirectional surface that drives a Session: it feeds user
5
+ * prompts in, renders assistant chunks + tool activity out, and implements a
6
+ * PermissionResolver so it can interrupt tool execution to ask the user.
7
+ *
8
+ * The TUI (Ink) and Telegram are both Channels. Future Slack / Discord / HTTP
9
+ * channels implement this same interface so the moxxy CLI binary (or any
10
+ * embedded consumer) can dispatch to them uniformly.
11
+ *
12
+ * The generic `TStartOpts` is the concrete options shape a given channel
13
+ * accepts.
14
+ */
15
+ export interface Channel<TStartOpts = unknown> {
16
+ /** Stable name (lowercase, single word). Used by dispatchers to look up by string. */
17
+ readonly name: string;
18
+ /** The PermissionResolver this channel installs on the session. */
19
+ readonly permissionResolver: PermissionResolver;
20
+ /**
21
+ * Begin running the channel. Returns a handle whose `running` promise
22
+ * resolves when the channel exits gracefully.
23
+ */
24
+ start(opts: TStartOpts): Promise<ChannelHandle>;
25
+ }
26
+ export interface ChannelHandle {
27
+ /**
28
+ * Resolves when the channel exits cleanly (user quit, SIGINT caught,
29
+ * upstream disconnected). Rejects on fatal error.
30
+ */
31
+ readonly running: Promise<void>;
32
+ /** Request graceful shutdown. Implementations should abort any in-flight work. */
33
+ stop(reason?: string): Promise<void>;
34
+ }
35
+ /** Common base shape for channel start options. */
36
+ export interface ChannelStartOptsBase {
37
+ readonly model?: string;
38
+ readonly systemPrompt?: string;
39
+ }
40
+ /**
41
+ * Standard dependencies that a channel factory receives. Channels pick what
42
+ * they need from this bag. Production CLI populates all of these; tests may
43
+ * pass only a subset.
44
+ */
45
+ export interface ChannelFactoryDeps {
46
+ /** Working directory for the channel (matches the Session's cwd). */
47
+ readonly cwd: string;
48
+ /** Optional encrypted-secret store (typed loosely — plugins import the concrete VaultStore type when needed). */
49
+ readonly vault?: unknown;
50
+ /** Optional structured logger. */
51
+ readonly logger?: {
52
+ debug?(msg: string, meta?: Record<string, unknown>): void;
53
+ info?(msg: string, meta?: Record<string, unknown>): void;
54
+ warn?(msg: string, meta?: Record<string, unknown>): void;
55
+ error?(msg: string, meta?: Record<string, unknown>): void;
56
+ };
57
+ /** Free-form per-channel overrides forwarded from the CLI invocation. */
58
+ readonly options?: Record<string, unknown>;
59
+ }
60
+ /**
61
+ * A registered, named factory for a Channel. Plugins contribute these via
62
+ * `definePlugin({ channels: [defineChannel(...)] })`. The CLI looks up by name
63
+ * and dispatches: `moxxy <name>` calls `def.create(deps).start({session,...})`.
64
+ */
65
+ export interface ChannelDef<TStartOpts = unknown> {
66
+ readonly name: string;
67
+ readonly description: string;
68
+ create(deps: ChannelFactoryDeps): Channel<TStartOpts>;
69
+ /**
70
+ * Optional runtime gate. Lets a channel declare "I can only run if these
71
+ * preconditions are met" (e.g., Telegram needs a token in the vault; TUI
72
+ * needs a TTY). The dispatcher uses this to filter the visible channel list
73
+ * and to give the user a helpful error before construction.
74
+ *
75
+ * Default: always available.
76
+ */
77
+ isAvailable?(deps: ChannelFactoryDeps): Promise<ChannelAvailability>;
78
+ /**
79
+ * One-shot subcommands the channel exposes. Routed as
80
+ * `moxxy channels <name> <subcommand>` by the CLI. Use this for
81
+ * channel-specific maintenance commands that don't need to run the channel
82
+ * (e.g., Telegram's `unpair`, `status`) — or that want to nudge a start with
83
+ * a flag (e.g., `pair` -> start with options.pair=true).
84
+ */
85
+ readonly subcommands?: Readonly<Record<string, ChannelSubcommand>>;
86
+ /**
87
+ * Name of a subcommand to run for a bare `moxxy <name>` invocation on a TTY -
88
+ * e.g. an interactive setup wizard. When absent, a bare invocation just
89
+ * starts the channel.
90
+ */
91
+ readonly interactiveCommand?: string;
92
+ }
93
+ export interface ChannelAvailability {
94
+ readonly ok: boolean;
95
+ /** Human-readable explanation when ok=false. Shown by `moxxy channels list`. */
96
+ readonly reason?: string;
97
+ }
98
+ /** Positional + flag args handed to a channel subcommand by the CLI. */
99
+ export interface ChannelCommandArgs {
100
+ readonly positional: ReadonlyArray<string>;
101
+ readonly flags: Readonly<Record<string, string | boolean | undefined>>;
102
+ }
103
+ /**
104
+ * Context handed to a channel subcommand. The CLI builds `deps` exactly like
105
+ * it does for `Channel.create()` so subcommands can:
106
+ * - inspect `deps.vault` for one-shot ops (unpair, status)
107
+ * - mutate `deps.options` and call `startChannel()` to launch the channel
108
+ * with extra start opts (e.g., pair=true)
109
+ */
110
+ export interface ChannelSubcommandContext {
111
+ readonly deps: ChannelFactoryDeps;
112
+ readonly args: ChannelCommandArgs;
113
+ /**
114
+ * Boot a session and run the channel by name. Returns the process exit code
115
+ * (0 on clean shutdown). Subcommands that want to "start with twist" call
116
+ * this with overrides instead of duplicating the start-loop themselves.
117
+ */
118
+ startChannel(options?: Readonly<Record<string, unknown>>): Promise<number>;
119
+ /**
120
+ * The booted session, so a subcommand can do channel-instance work like
121
+ * pairing.
122
+ */
123
+ readonly session: ClientSession;
124
+ }
125
+ export interface ChannelSubcommand {
126
+ readonly description: string;
127
+ run(ctx: ChannelSubcommandContext): Promise<number>;
128
+ }
129
+ /**
130
+ * Read-only registry of channels available in a Session. Implementation lives
131
+ * in @moxxy/core.
132
+ */
133
+ export interface ChannelRegistry {
134
+ list(): ReadonlyArray<ChannelDef>;
135
+ get(name: string): ChannelDef | undefined;
136
+ has(name: string): boolean;
137
+ /**
138
+ * Returns every channel paired with its current availability. Channels
139
+ * without an `isAvailable` hook are treated as `{ok: true}`.
140
+ */
141
+ listWithAvailability(deps: ChannelFactoryDeps): Promise<ReadonlyArray<{
142
+ readonly def: ChannelDef;
143
+ readonly availability: ChannelAvailability;
144
+ }>>;
145
+ }
146
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO,CAAC,UAAU,GAAG,OAAO;IAC3C,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,mEAAmE;IACnE,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAEhD;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC,kFAAkF;IAClF,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,mDAAmD;AACnD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iHAAiH;IACjH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,kCAAkC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,KAAK,CAAC,CAAC,GAAG,EA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.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import type { AgentDef } from './agent.js';
2
+ import type { CommandDef } from './command.js';
3
+ import type { ModeDef } from './mode.js';
4
+ import type { LLMProvider, ProviderDef } from './provider.js';
5
+ import type { RequirementCheck, MoxxyRequirement } from './requirements.js';
6
+ import type { SessionLike, SessionLogReader } from './session-like.js';
7
+ import type { Skill } from './skill.js';
8
+ import type { ToolDef } from './tool.js';
9
+ import type { Transcriber } from './transcriber.js';
10
+ /**
11
+ * `ClientSession` widens {@link SessionLike} with the read-and-act registry
12
+ * surface a rich interactive channel (the Ink TUI) actually touches. Both the
13
+ * in-process `Session` (whose concrete registries are supersets of these
14
+ * views) and the `RemoteSession` proxy implement it, so the TUI is written
15
+ * once against `ClientSession` and runs unchanged either way.
16
+ *
17
+ * The views are intentionally narrow - only what the TUI calls. Methods are
18
+ * declared method-style (bivariant) so a concrete `Session` registry satisfies
19
+ * the view even where its real signature is slightly wider. On a remote
20
+ * client, the facades behind these views are backed by the runner's `getInfo`
21
+ * snapshot for reads and by RPCs for the few mutating calls; genuinely
22
+ * server-only capabilities (voice transcription, MCP admin) degrade rather
23
+ * than pretend.
24
+ */
25
+ export interface ProvidersClientView {
26
+ getActive(): LLMProvider;
27
+ getActiveName(): string | null;
28
+ list(): ReadonlyArray<ProviderDef>;
29
+ setActive(name: string, config?: Record<string, unknown>): LLMProvider;
30
+ replace(def: ProviderDef, instance?: LLMProvider): void;
31
+ }
32
+ export interface ModesClientView {
33
+ list(): ReadonlyArray<ModeDef>;
34
+ getActive(): ModeDef;
35
+ setActive(name: string): void;
36
+ }
37
+ export interface ToolsClientView {
38
+ list(): ReadonlyArray<ToolDef>;
39
+ get(name: string): ToolDef | undefined;
40
+ }
41
+ export interface CommandsClientView {
42
+ get(name: string): CommandDef | undefined;
43
+ listForChannel(channel: string): ReadonlyArray<CommandDef>;
44
+ }
45
+ export interface SkillsClientView {
46
+ list(): ReadonlyArray<Skill>;
47
+ }
48
+ export interface AgentsClientView {
49
+ list(): ReadonlyArray<AgentDef>;
50
+ }
51
+ export interface TranscribersClientView {
52
+ getActiveName(): string | null;
53
+ has(name: string): boolean;
54
+ getActive(): Transcriber;
55
+ /** Active transcriber or null. Channels guard on this for audio input. */
56
+ tryGetActive(): Transcriber | null;
57
+ setActive(name: string, config?: Record<string, unknown>): Transcriber;
58
+ }
59
+ export interface RequirementsClientView {
60
+ check(requirements: ReadonlyArray<MoxxyRequirement>): RequirementCheck;
61
+ }
62
+ export interface PermissionsClientView {
63
+ addAllow(rule: {
64
+ readonly name: string;
65
+ readonly reason?: string;
66
+ }): Promise<void>;
67
+ }
68
+ export interface ClientSession extends SessionLike {
69
+ /** The mirror/real log, plus `clear()` for `/new`. */
70
+ readonly log: SessionLogReader & {
71
+ clear(): void;
72
+ };
73
+ readonly providers: ProvidersClientView;
74
+ readonly modes: ModesClientView;
75
+ readonly tools: ToolsClientView;
76
+ readonly commands: CommandsClientView;
77
+ readonly skills: SkillsClientView;
78
+ readonly agents: AgentsClientView;
79
+ readonly transcribers: TranscribersClientView;
80
+ readonly requirements: RequirementsClientView;
81
+ readonly permissions: PermissionsClientView;
82
+ }
83
+ //# sourceMappingURL=client-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-session.d.ts","sourceRoot":"","sources":["../src/client-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,K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":"client-session.js","sourceRoot":"","sources":["../src/client-session.ts"],"names":[],"mappings":""}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Commands — channel-agnostic actions the user can trigger with a
3
+ * `/<name>` prefix. Live on the Session's CommandRegistry so every
4
+ * channel (TUI slash menu, Telegram bot command, future HTTP `/cmd`
5
+ * endpoint) reads the same set. Plugins contribute commands via
6
+ * `PluginSpec.commands`.
7
+ *
8
+ * Why a registry instead of channel-local switch statements:
9
+ * /info works the same way whether the user types it in the TUI or
10
+ * sends `/info` to the Telegram bot. The handler returns a typed
11
+ * CommandOutput; each channel decides how to render it (TUI as a
12
+ * systemNotice, Telegram as a chat message, HTTP as JSON).
13
+ */
14
+ import type { SessionId } from './ids.js';
15
+ export interface CommandDef {
16
+ /** Name without the leading `/`. */
17
+ readonly name: string;
18
+ /** One-line description shown in `/help` and channel pickers. */
19
+ readonly description: string;
20
+ /**
21
+ * Usage hint for the arguments, e.g. `set <name> <value>`. Interactive
22
+ * channels may render it as dimmed ghost text after the command name
23
+ * while the user is typing (autocomplete preview). Placeholders like
24
+ * `<name>` are illustrative — never inserted into the buffer literally.
25
+ */
26
+ readonly argumentHint?: string;
27
+ /** Alternative names (without leading `/`). */
28
+ readonly aliases?: ReadonlyArray<string>;
29
+ /**
30
+ * When set, the command only surfaces in these channels by name
31
+ * (e.g. `['tui']` for an overlay-style command that wouldn't make
32
+ * sense in Telegram). Omit for "all channels".
33
+ */
34
+ readonly channels?: ReadonlyArray<string>;
35
+ /** Optional short status shown by interactive channels while the command runs. */
36
+ readonly pendingNotice?: string;
37
+ /** Handler invoked by the channel. Receives raw args after the name. */
38
+ readonly handler: (ctx: CommandContext) => Promise<CommandOutput> | CommandOutput;
39
+ }
40
+ export interface CommandContext {
41
+ /** Channel that invoked the command — `'tui'`, `'telegram'`, etc. */
42
+ readonly channel: string;
43
+ /** Session id the command runs against. */
44
+ readonly sessionId: SessionId;
45
+ /** Raw text after the command name (`"hello"` for `/echo hello`). */
46
+ readonly args: string;
47
+ /**
48
+ * The active Session. Loosely typed (`unknown`) so the SDK doesn't
49
+ * pull in core; handlers cast to `Session` from `@moxxy/core` when
50
+ * they need registries. The plugin host always passes the real
51
+ * Session here.
52
+ */
53
+ readonly session: unknown;
54
+ }
55
+ /**
56
+ * What a command returns. Channels pick the appropriate UI for each
57
+ * variant. New variants are additive — channels that don't know a
58
+ * variant fall back to rendering its `text` field if present.
59
+ */
60
+ export type CommandOutput =
61
+ /** Simple text response. Every channel can render this. */
62
+ {
63
+ readonly kind: 'text';
64
+ readonly text: string;
65
+ }
66
+ /**
67
+ * Structural action that the host channel performs in its UI
68
+ * (`clear`/`new`/`exit`). Carries an optional message the channel
69
+ * may surface alongside the action.
70
+ */
71
+ | {
72
+ readonly kind: 'session-action';
73
+ readonly action: 'new' | 'clear' | 'exit';
74
+ readonly notice?: string;
75
+ }
76
+ /** No-op (handler decided nothing needs surfacing). */
77
+ | {
78
+ readonly kind: 'noop';
79
+ }
80
+ /**
81
+ * Handler errored. Channels render this distinctly (red text, etc.).
82
+ * Use this instead of throwing so the command pipeline never
83
+ * crashes the channel.
84
+ */
85
+ | {
86
+ readonly kind: 'error';
87
+ readonly message: string;
88
+ };
89
+ export type CommandHandlerResult = CommandOutput;
90
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,UAAU;IACzB,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,M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
+ * channel (TUI slash menu, Telegram bot command, future HTTP `/cmd`
5
+ * endpoint) reads the same set. Plugins contribute commands via
6
+ * `PluginSpec.commands`.
7
+ *
8
+ * Why a registry instead of channel-local switch statements:
9
+ * /info works the same way whether the user types it in the TUI or
10
+ * sends `/info` to the Telegram bot. The handler returns a typed
11
+ * CommandOutput; each channel decides how to render it (TUI as a
12
+ * systemNotice, Telegram as a chat message, HTTP as JSON).
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,34 @@
1
+ import type { EventLogReader } from './log.js';
2
+ import type { ModeContext } from './mode.js';
3
+ /**
4
+ * Cheap, no-network estimate of how many tokens the current event log
5
+ * would consume on the next provider request. Char-based (chars/4) with
6
+ * compaction events honored — events covered by a CompactionEvent.replacedRange
7
+ * count as the (much shorter) summary rather than their original bytes — and
8
+ * elision honored: old tool results (seq ≤ the elision high-water mark) count
9
+ * as their ~stub size rather than their full payload, matching what
10
+ * `projectMessagesFromLog` actually sends.
11
+ *
12
+ * Used by the auto-compact helper (see `runCompactionIfNeeded`) and by
13
+ * the TUI's context meter. For perfect accuracy callers can use the
14
+ * provider's `countTokens(req)`; this is the fast path that doesn't
15
+ * touch the network and is safe to run on every iteration.
16
+ */
17
+ export declare function estimateContextTokens(log: EventLogReader): number;
18
+ /**
19
+ * Auto-compaction hook every mode calls once per iteration, right
20
+ * before building messages for the next provider call. Reads the
21
+ * active model's real `contextWindow` (not a magic max-int sentinel),
22
+ * estimates current token use, and — if the configured compactor's
23
+ * `shouldCompact` returns true — runs `compact()` and emits the
24
+ * resulting CompactionEvent onto the log. `projectMessagesFromLog`
25
+ * already honors compaction events, so the next provider call sees
26
+ * the summarized prefix automatically.
27
+ *
28
+ * Designed to be tolerant: no compactor, no model descriptor, no
29
+ * contextWindow, or a compactor throw all degrade to a no-op so a
30
+ * compactor bug can't kill the turn. Failures emit a non-fatal
31
+ * `error` event for observability.
32
+ */
33
+ export declare function runCompactionIfNeeded(ctx: ModeContext): Promise<void>;
34
+ //# sourceMappingURL=compactor-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactor-helpers.d.ts","sourceRoot":"","sources":["../src/compactor-helpers.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,CA8BjE;AA2BD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAgE3E"}