@moxxy/sdk 0.25.0 → 0.27.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.
- package/dist/channel.d.ts +13 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +19 -0
- package/dist/channel.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/event-store.d.ts +5 -1
- package/dist/event-store.d.ts.map +1 -1
- package/dist/event-store.js +24 -1
- package/dist/event-store.js.map +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/first-party.d.ts +17 -0
- package/dist/first-party.d.ts.map +1 -0
- package/dist/first-party.js +19 -0
- package/dist/first-party.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/isolation.d.ts +14 -0
- package/dist/isolation.d.ts.map +1 -1
- package/dist/isolation.js +75 -0
- package/dist/isolation.js.map +1 -1
- package/dist/mode.d.ts +7 -0
- package/dist/mode.d.ts.map +1 -1
- package/dist/mode.js.map +1 -1
- package/dist/plugin.d.ts +10 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/reflector.d.ts +58 -0
- package/dist/reflector.d.ts.map +1 -0
- package/dist/reflector.js +2 -0
- package/dist/reflector.js.map +1 -0
- package/dist/schemas.d.ts +215 -8
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +37 -0
- package/dist/schemas.js.map +1 -1
- package/dist/session-like.d.ts +120 -1
- package/dist/session-like.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/channel.ts +25 -0
- package/src/errors.ts +1 -0
- package/src/event-store.ts +16 -1
- package/src/events.ts +1 -0
- package/src/exit-after-pair.test.ts +32 -0
- package/src/first-party.test.ts +26 -0
- package/src/first-party.ts +19 -0
- package/src/index.ts +21 -4
- package/src/isolation-aggregate.test.ts +69 -0
- package/src/isolation.ts +67 -0
- package/src/mode.ts +7 -0
- package/src/plugin.ts +10 -1
- package/src/reflector.ts +61 -0
- package/src/schemas.ts +41 -0
- package/src/session-like.ts +114 -1
package/dist/session-like.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { MoxxyEvent, TriggerOrigin, UserPromptAttachment } from './events.js';
|
|
2
2
|
import type { SessionId, TurnId } from './ids.js';
|
|
3
|
+
import type { CapabilitySpec } from './isolation.js';
|
|
3
4
|
import type { EventLogReader } from './log.js';
|
|
4
5
|
import type { ApprovalResolver, ModeBadge } from './mode.js';
|
|
5
6
|
import type { PermissionResolver } from './permission.js';
|
|
6
|
-
import type { ModelDescriptor } from './provider.js';
|
|
7
|
+
import type { ModelDescriptor, ProviderKeyValidation } from './provider.js';
|
|
8
|
+
import type { PluginSetupSpec } from './schemas.js';
|
|
7
9
|
import type { ToolCompactPresentation } from './tool.js';
|
|
8
10
|
/**
|
|
9
11
|
* Options accepted by `SessionLike.runTurn`. Defined here (rather than in
|
|
@@ -273,6 +275,12 @@ export interface InstallablePluginView {
|
|
|
273
275
|
readonly installSpec: string;
|
|
274
276
|
readonly kind?: string;
|
|
275
277
|
readonly startCommand?: string;
|
|
278
|
+
/** Registry contributions the package provides (category + name) — lets
|
|
279
|
+
* surfaces offer install-on-first-use for a missing capability. */
|
|
280
|
+
readonly provides?: ReadonlyArray<{
|
|
281
|
+
readonly category: string;
|
|
282
|
+
readonly name: string;
|
|
283
|
+
}>;
|
|
276
284
|
}
|
|
277
285
|
/** One loaded plugin in {@link PluginsAdminView.loaded}, grouped by `kinds`. */
|
|
278
286
|
export interface LoadedPluginView {
|
|
@@ -338,6 +346,103 @@ export interface PluginsAdminView {
|
|
|
338
346
|
* (`setActive`). Rejects an unknown category or an unregistered name.
|
|
339
347
|
*/
|
|
340
348
|
setCategoryDefault(category: string, name: string): Promise<void>;
|
|
349
|
+
/**
|
|
350
|
+
* Install a plugin (npm into `~/.moxxy/plugins`), persist its enable, and
|
|
351
|
+
* hot-reload the plugin host so its contributions register live. Accepts a
|
|
352
|
+
* catalog id, a package name, or a full npm spec. Resolves with the spec
|
|
353
|
+
* that installed plus the diff of contribution names that registered,
|
|
354
|
+
* keyed by kind (`tools`, `providers`, `modes`, …). Optional capability
|
|
355
|
+
* per the seam convention: a `RemoteSession` leaves it undefined and the
|
|
356
|
+
* picker falls back to printing the `moxxy plugins install` command.
|
|
357
|
+
*/
|
|
358
|
+
install?(idOrSpec: string): Promise<{
|
|
359
|
+
readonly installed: string;
|
|
360
|
+
readonly registered: Readonly<Partial<Record<string, ReadonlyArray<string>>>>;
|
|
361
|
+
/**
|
|
362
|
+
* Combined capability surface of the tools this install registered —
|
|
363
|
+
* the package's blast radius, so a channel can render post-install
|
|
364
|
+
* consent (third-party packages) or an info line (first-party). Absent
|
|
365
|
+
* when the install registered no tools or the host cannot introspect
|
|
366
|
+
* isolation specs.
|
|
367
|
+
*/
|
|
368
|
+
readonly capabilities?: {
|
|
369
|
+
/** Tools that declared an isolation spec. */
|
|
370
|
+
readonly declared: number;
|
|
371
|
+
/** Tools the install registered. */
|
|
372
|
+
readonly total: number;
|
|
373
|
+
/** Widest-wins union of the declared specs. */
|
|
374
|
+
readonly surface: CapabilitySpec;
|
|
375
|
+
/** Tools with NO declaration: their surface is unknown, not empty. */
|
|
376
|
+
readonly undeclaredTools?: ReadonlyArray<string>;
|
|
377
|
+
};
|
|
378
|
+
/** Present when the package declares a `moxxy.setup` step to complete. */
|
|
379
|
+
readonly needsSetup?: {
|
|
380
|
+
readonly title: string;
|
|
381
|
+
readonly required: boolean;
|
|
382
|
+
};
|
|
383
|
+
}>;
|
|
384
|
+
/**
|
|
385
|
+
* The package's declarative setup step (`moxxy.setup`), read from its
|
|
386
|
+
* installed package.json — plain data, safe to render anywhere. Null when
|
|
387
|
+
* absent. Powers the post-install dialog and `/setup`.
|
|
388
|
+
*/
|
|
389
|
+
setupSpec?(packageName: string): Promise<PluginSetupSpec | null>;
|
|
390
|
+
/**
|
|
391
|
+
* Persist collected setup values: secrets → vault + `${vault:NAME}` option
|
|
392
|
+
* ref; other kinds → `plugins.packages.<pkg>.options.<key>`. A complete
|
|
393
|
+
* required setup re-enables the package; an incomplete one disables it
|
|
394
|
+
* (mirrors the init wizard). Optional capability per the seam convention.
|
|
395
|
+
*/
|
|
396
|
+
applySetup?(packageName: string, values: Readonly<Record<string, string | boolean>>): Promise<{
|
|
397
|
+
readonly complete: boolean;
|
|
398
|
+
readonly missing: ReadonlyArray<string>;
|
|
399
|
+
}>;
|
|
400
|
+
}
|
|
401
|
+
/** IO a channel supplies to drive an interactive OAuth flow inside its own
|
|
402
|
+
* UI — mirrors `ProviderAuthContext` minus vault/headless (the host adds
|
|
403
|
+
* those). `write` receives the flow's progress lines (sign-in URL, status);
|
|
404
|
+
* `prompt` renders a single-line input (paste-back codes), masked for
|
|
405
|
+
* secrets. */
|
|
406
|
+
export interface ProviderConnectIo {
|
|
407
|
+
readonly write: (chunk: string) => void;
|
|
408
|
+
readonly prompt?: (question: string, opts?: {
|
|
409
|
+
readonly mask?: boolean;
|
|
410
|
+
}) => Promise<string>;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The slice of provider onboarding a channel needs to connect a provider
|
|
414
|
+
* WITHOUT leaving the session: install it if it's catalog-only, collect +
|
|
415
|
+
* validate + store an API key, or drive an OAuth sign-in. Present on a local
|
|
416
|
+
* Session (wired by the CLI, which owns vault + catalog); a `RemoteSession`
|
|
417
|
+
* leaves {@link SessionLike.providerSetup} undefined and the UI falls back
|
|
418
|
+
* to pointing at `moxxy init` / `moxxy login`.
|
|
419
|
+
*/
|
|
420
|
+
export interface ProviderSetupView {
|
|
421
|
+
/**
|
|
422
|
+
* How this provider authenticates: from its registered def, else the
|
|
423
|
+
* first-party catalog; null when the id is unknown to both.
|
|
424
|
+
*/
|
|
425
|
+
authKind(providerId: string): 'apiKey' | 'oauth' | 'none' | null;
|
|
426
|
+
/**
|
|
427
|
+
* Ensure the provider's package is registered — a catalog-only provider is
|
|
428
|
+
* npm-installed + enabled + hot-reloaded. Resolves false when the provider
|
|
429
|
+
* still isn't registered afterwards (unknown id, bad install).
|
|
430
|
+
*/
|
|
431
|
+
ensureInstalled(providerId: string): Promise<boolean>;
|
|
432
|
+
/** Validate a key against the provider's own `validateKey` (if it has one). */
|
|
433
|
+
testKey(providerId: string, key: string): Promise<ProviderKeyValidation>;
|
|
434
|
+
/** Store the key in the vault under the provider's canonical key name and
|
|
435
|
+
* mark the provider ready for this session. */
|
|
436
|
+
saveKey(providerId: string, key: string): Promise<void>;
|
|
437
|
+
/**
|
|
438
|
+
* Drive the provider's OAuth flow. `io` routes the flow's output/prompts
|
|
439
|
+
* into the calling channel's UI; when omitted the host's default terminal
|
|
440
|
+
* prompting applies (the clack path `moxxy init`/`moxxy login` use).
|
|
441
|
+
*/
|
|
442
|
+
loginOAuth(providerId: string, io?: ProviderConnectIo): Promise<{
|
|
443
|
+
readonly accountId?: string | null;
|
|
444
|
+
readonly expiresAt?: number;
|
|
445
|
+
}>;
|
|
341
446
|
}
|
|
342
447
|
/**
|
|
343
448
|
* The session surface a `Channel` depends on, decoupled from whether the
|
|
@@ -391,5 +496,19 @@ export interface SessionLike {
|
|
|
391
496
|
workflows?: WorkflowsView;
|
|
392
497
|
/** Plugin-management slice backing the `/plugins` picker. */
|
|
393
498
|
pluginsAdmin?: PluginsAdminView;
|
|
499
|
+
/** Provider onboarding slice backing in-channel connect (key entry / OAuth). */
|
|
500
|
+
providerSetup?: ProviderSetupView;
|
|
501
|
+
/**
|
|
502
|
+
* Re-read the merged config from disk and live-apply the safe subset —
|
|
503
|
+
* backs the TUI /settings panel's write-then-apply. Structurally matches
|
|
504
|
+
* @moxxy/config's ConfigApplyResult (the SDK stays config-free). Absent on
|
|
505
|
+
* a RemoteSession: writes still land, but apply waits for a restart.
|
|
506
|
+
*/
|
|
507
|
+
configAdmin?: {
|
|
508
|
+
apply(): Promise<{
|
|
509
|
+
readonly applied: ReadonlyArray<string>;
|
|
510
|
+
readonly pending: ReadonlyArray<string>;
|
|
511
|
+
}>;
|
|
512
|
+
};
|
|
394
513
|
}
|
|
395
514
|
//# sourceMappingURL=session-like.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-like.d.ts","sourceRoot":"","sources":["../src/session-like.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"session-like.d.ts","sourceRoot":"","sources":["../src/session-like.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;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,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;YACxC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;SACzC,CAAC,CAAC;KACJ,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxxy/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Typed public surface for the moxxy framework: event types, define* factories, lifecycle hook signatures.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"moxxy",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"typescript": "^5.7.3",
|
|
74
74
|
"vitest": "^2.1.8",
|
|
75
75
|
"zod": "^3.24.0",
|
|
76
|
-
"@moxxy/
|
|
77
|
-
"@moxxy/
|
|
76
|
+
"@moxxy/tsconfig": "0.0.0",
|
|
77
|
+
"@moxxy/vitest-preset": "0.0.0"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "tsc -p tsconfig.json",
|
package/src/channel.ts
CHANGED
|
@@ -300,6 +300,31 @@ export interface ChannelSubcommand {
|
|
|
300
300
|
run(ctx: ChannelSubcommandContext): Promise<number>;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Flag an orchestrator (e.g. `moxxy onboard`) passes to a channel's `pair`
|
|
305
|
+
* subcommand to say "hand control back once pairing succeeds". Every pair
|
|
306
|
+
* flow's default is to keep the just-paired channel running until Ctrl+C —
|
|
307
|
+
* right for a human running `moxxy <name> pair` standalone, wrong for a
|
|
308
|
+
* caller that pairs as one step of a longer flow (its SIGINT handlers call
|
|
309
|
+
* `process.exit`, which would kill the orchestrator). Pair flows check this
|
|
310
|
+
* via {@link exitAfterPairRequested} after a successful pairing and stop the
|
|
311
|
+
* channel + return 0 instead of blocking forever.
|
|
312
|
+
*/
|
|
313
|
+
export const EXIT_AFTER_PAIR_FLAG = 'exit-after-pair';
|
|
314
|
+
|
|
315
|
+
/** Whether the subcommand invocation asked for the pair-then-return contract. */
|
|
316
|
+
export function exitAfterPairRequested(
|
|
317
|
+
ctx: Pick<ChannelSubcommandContext, 'args' | 'deps'>,
|
|
318
|
+
): boolean {
|
|
319
|
+
// The CLI forwards subcommand argv flags both as `args.flags` and merged
|
|
320
|
+
// into `deps.options`; accept either carrier so programmatic callers that
|
|
321
|
+
// only build one of the two still opt in.
|
|
322
|
+
return (
|
|
323
|
+
ctx.args.flags[EXIT_AFTER_PAIR_FLAG] === true ||
|
|
324
|
+
ctx.deps.options?.[EXIT_AFTER_PAIR_FLAG] === true
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
303
328
|
/**
|
|
304
329
|
* Read-only registry of channels available in a Session. Implementation lives
|
|
305
330
|
* in @moxxy/core.
|
package/src/errors.ts
CHANGED
|
@@ -49,6 +49,7 @@ export type MoxxyErrorCode =
|
|
|
49
49
|
| 'CONFIG_INVALID'
|
|
50
50
|
| 'PLUGIN_LOAD_FAILED'
|
|
51
51
|
| 'PLUGIN_PROTECTED' // a kernel/critical package can't be disabled — swap its default instead
|
|
52
|
+
| 'PLUGIN_NOT_INSTALLED' // the capability exists in the catalog but its package isn't installed — offer the install
|
|
52
53
|
| 'UNKNOWN_COMMAND'
|
|
53
54
|
// --- Tool / runtime ---
|
|
54
55
|
| 'TOOL_ERROR' // a tool handler failed (bad input, not-found, exec error)
|
package/src/event-store.ts
CHANGED
|
@@ -12,8 +12,23 @@ import type { SessionId } from './ids.js';
|
|
|
12
12
|
* event (prompts, tool I/O), so that explicit opt-in is the trust boundary.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
/** Every valid {@link SessionSource}, as a runtime constant — so validators
|
|
16
|
+
* (e.g. the CLI's `MOXXY_SESSION_SOURCE` guard) enumerate the same list the
|
|
17
|
+
* type is derived from instead of hand-listing the literals. */
|
|
18
|
+
export const SESSION_SOURCES = [
|
|
19
|
+
'cli',
|
|
20
|
+
'tui',
|
|
21
|
+
'desktop',
|
|
22
|
+
'mobile',
|
|
23
|
+
'slack',
|
|
24
|
+
'telegram',
|
|
25
|
+
'signal',
|
|
26
|
+
'whatsapp',
|
|
27
|
+
'discord',
|
|
28
|
+
] as const;
|
|
29
|
+
|
|
15
30
|
/** Originating channel of a session (persisted into the meta sidecar). */
|
|
16
|
-
export type SessionSource =
|
|
31
|
+
export type SessionSource = (typeof SESSION_SOURCES)[number];
|
|
17
32
|
|
|
18
33
|
/**
|
|
19
34
|
* The single per-session metadata record (the JSONL impl writes it to
|
package/src/events.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { EXIT_AFTER_PAIR_FLAG, exitAfterPairRequested } from './channel.js';
|
|
3
|
+
|
|
4
|
+
function ctx(
|
|
5
|
+
flags: Record<string, string | boolean | undefined>,
|
|
6
|
+
options?: Record<string, unknown>,
|
|
7
|
+
): Parameters<typeof exitAfterPairRequested>[0] {
|
|
8
|
+
return {
|
|
9
|
+
args: { positional: [], flags },
|
|
10
|
+
deps: { cwd: '/tmp', ...(options ? { options } : {}) },
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('exitAfterPairRequested', () => {
|
|
15
|
+
it('defaults to false (standalone pair keeps the channel running)', () => {
|
|
16
|
+
expect(exitAfterPairRequested(ctx({}))).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('honors the flag via args.flags', () => {
|
|
20
|
+
expect(exitAfterPairRequested(ctx({ [EXIT_AFTER_PAIR_FLAG]: true }))).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('honors the flag via deps.options (programmatic callers)', () => {
|
|
24
|
+
expect(exitAfterPairRequested(ctx({}, { [EXIT_AFTER_PAIR_FLAG]: true }))).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('requires boolean true — a string "true" flag is not an opt-in', () => {
|
|
28
|
+
// argv flags are string|boolean; only an explicit boolean true counts, so
|
|
29
|
+
// `--exit-after-pair=weird` values can't accidentally change lifecycle.
|
|
30
|
+
expect(exitAfterPairRequested(ctx({ [EXIT_AFTER_PAIR_FLAG]: 'true' }))).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { FIRST_PARTY_PLUGIN_SCOPE, isFirstPartyPackage } from './first-party.js';
|
|
3
|
+
|
|
4
|
+
describe('isFirstPartyPackage (third-party detection)', () => {
|
|
5
|
+
it('accepts packages under the @moxxy scope', () => {
|
|
6
|
+
expect(isFirstPartyPackage('@moxxy/plugin-channel-slack')).toBe(true);
|
|
7
|
+
expect(isFirstPartyPackage('@moxxy/sdk')).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('rejects bare (unscoped) packages', () => {
|
|
11
|
+
expect(isFirstPartyPackage('left-pad')).toBe(false);
|
|
12
|
+
expect(isFirstPartyPackage('moxxy-plugin-evil')).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('rejects other scopes, including lookalikes', () => {
|
|
16
|
+
expect(isFirstPartyPackage('@moxxyy/plugin-x')).toBe(false);
|
|
17
|
+
expect(isFirstPartyPackage('@moxxy-plugins/x')).toBe(false);
|
|
18
|
+
expect(isFirstPartyPackage('@evil/moxxy')).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('rejects a scope-only prefix trick (@moxxy without the slash)', () => {
|
|
22
|
+
// `@moxxy` alone is not under the scope: the slash is part of the prefix.
|
|
23
|
+
expect(FIRST_PARTY_PLUGIN_SCOPE.endsWith('/')).toBe(true);
|
|
24
|
+
expect(isFirstPartyPackage('@moxxy')).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The npm scope every first-party moxxy package lives under. First-party
|
|
3
|
+
* packages are the trusted, co-versioned set (published together via the
|
|
4
|
+
* fixed changeset group); anything outside this scope is third-party code
|
|
5
|
+
* the user pulled in from the registry and gets stricter treatment:
|
|
6
|
+
* post-install capability consent and the `thirdPartyRequireDeclaration`
|
|
7
|
+
* ratchet in `@moxxy/plugin-security`.
|
|
8
|
+
*/
|
|
9
|
+
export const FIRST_PARTY_PLUGIN_SCOPE = '@moxxy/';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Whether a package name belongs to the trusted first-party scope. The input
|
|
13
|
+
* is a bare npm package name (`@moxxy/plugin-x`, `some-plugin`) — pass names,
|
|
14
|
+
* not install specs (`name@1.2.3` would still work, but git/path specs are
|
|
15
|
+
* not names and should be resolved to one first).
|
|
16
|
+
*/
|
|
17
|
+
export function isFirstPartyPackage(packageName: string): boolean {
|
|
18
|
+
return packageName.startsWith(FIRST_PARTY_PLUGIN_SCOPE);
|
|
19
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -66,6 +66,8 @@ export type {
|
|
|
66
66
|
LoadedPluginView,
|
|
67
67
|
CategoryView,
|
|
68
68
|
CategoryItemView,
|
|
69
|
+
ProviderSetupView,
|
|
70
|
+
ProviderConnectIo,
|
|
69
71
|
} from './session-like.js';
|
|
70
72
|
|
|
71
73
|
export type {
|
|
@@ -115,7 +117,9 @@ export type {
|
|
|
115
117
|
Isolator,
|
|
116
118
|
HandlerModuleRef,
|
|
117
119
|
} from './isolation.js';
|
|
118
|
-
export { ISOLATION_RANK } from './isolation.js';
|
|
120
|
+
export { ISOLATION_RANK, aggregateCapabilitySpecs } from './isolation.js';
|
|
121
|
+
|
|
122
|
+
export { FIRST_PARTY_PLUGIN_SCOPE, isFirstPartyPackage } from './first-party.js';
|
|
119
123
|
|
|
120
124
|
export type {
|
|
121
125
|
SubagentSpec,
|
|
@@ -188,6 +192,12 @@ export type {
|
|
|
188
192
|
SessionMeta,
|
|
189
193
|
SessionSource,
|
|
190
194
|
} from './event-store.js';
|
|
195
|
+
export { SESSION_SOURCES } from './event-store.js';
|
|
196
|
+
export type {
|
|
197
|
+
ReflectorDef,
|
|
198
|
+
ReflectContext,
|
|
199
|
+
ReflectionProposal,
|
|
200
|
+
} from './reflector.js';
|
|
191
201
|
// Node-runtime helpers (writeFileAtomic*, moxxyHome/moxxyPath,
|
|
192
202
|
// readRequestBody/bearerTokenMatches, channel-auth) are exported from the
|
|
193
203
|
// './server' subpath, NOT the main barrel — they statically reach node:*
|
|
@@ -226,6 +236,11 @@ export {
|
|
|
226
236
|
type MoxxyErrorCode,
|
|
227
237
|
type MoxxyErrorInit,
|
|
228
238
|
} from './errors.js';
|
|
239
|
+
// Shared retry primitives: a leak-safe, abort-aware sleep + the exponential
|
|
240
|
+
// back-off schedule. General-purpose — not mode-loop internals: the runner's
|
|
241
|
+
// connect retry and the desktop supervisor's restart wait use them too, so
|
|
242
|
+
// don't reimplement an ad-hoc `new Promise(setTimeout)` back-off elsewhere.
|
|
243
|
+
export { sleepWithAbort, nextBackoffMs } from './mode/abort-backoff.js';
|
|
229
244
|
export {
|
|
230
245
|
collectProviderStream,
|
|
231
246
|
runSingleShotTurn,
|
|
@@ -234,8 +249,6 @@ export {
|
|
|
234
249
|
buildSystemPromptWithSkills,
|
|
235
250
|
createStuckLoopDetector,
|
|
236
251
|
stableHash,
|
|
237
|
-
sleepWithAbort,
|
|
238
|
-
nextBackoffMs,
|
|
239
252
|
type CollectedToolUse,
|
|
240
253
|
type StreamResult,
|
|
241
254
|
type ProjectMessagesOptions,
|
|
@@ -365,7 +378,7 @@ export type {
|
|
|
365
378
|
ResolvedPluginManifest,
|
|
366
379
|
} from './plugin.js';
|
|
367
380
|
|
|
368
|
-
export { startChannelWith } from './channel.js';
|
|
381
|
+
export { startChannelWith, EXIT_AFTER_PAIR_FLAG, exitAfterPairRequested } from './channel.js';
|
|
369
382
|
export type {
|
|
370
383
|
Channel,
|
|
371
384
|
ChannelHandle,
|
|
@@ -456,10 +469,14 @@ export {
|
|
|
456
469
|
skillFrontmatterSchema,
|
|
457
470
|
pluginManifestSchema,
|
|
458
471
|
moxxyPackageSchema,
|
|
472
|
+
pluginSetupFieldSchema,
|
|
473
|
+
pluginSetupSchema,
|
|
459
474
|
requirementSchema,
|
|
460
475
|
type SkillFrontmatterInput,
|
|
461
476
|
type PluginManifestInput,
|
|
462
477
|
type MoxxyPackageInput,
|
|
478
|
+
type PluginSetupField,
|
|
479
|
+
type PluginSetupSpec,
|
|
463
480
|
} from './schemas.js';
|
|
464
481
|
|
|
465
482
|
export {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { aggregateCapabilitySpecs, type CapabilitySpec } from './isolation.js';
|
|
3
|
+
|
|
4
|
+
describe('aggregateCapabilitySpecs', () => {
|
|
5
|
+
it('empty / all-undefined input aggregates to an empty surface', () => {
|
|
6
|
+
expect(aggregateCapabilitySpecs([])).toEqual({});
|
|
7
|
+
expect(aggregateCapabilitySpecs([undefined, undefined])).toEqual({});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('unions fs globs, env, and commands (sorted, deduped)', () => {
|
|
11
|
+
const a: CapabilitySpec = {
|
|
12
|
+
fs: { read: ['$cwd/**', '/tmp/**'], write: ['/tmp/**'] },
|
|
13
|
+
env: ['PATH', 'HOME'],
|
|
14
|
+
subprocess: true,
|
|
15
|
+
commands: ['npm'],
|
|
16
|
+
};
|
|
17
|
+
const b: CapabilitySpec = {
|
|
18
|
+
fs: { read: ['/tmp/**'] },
|
|
19
|
+
env: ['PATH'],
|
|
20
|
+
subprocess: true,
|
|
21
|
+
commands: ['git', 'npm'],
|
|
22
|
+
};
|
|
23
|
+
expect(aggregateCapabilitySpecs([a, b])).toEqual({
|
|
24
|
+
fs: { read: ['$cwd/**', '/tmp/**'], write: ['/tmp/**'] },
|
|
25
|
+
env: ['HOME', 'PATH'],
|
|
26
|
+
subprocess: true,
|
|
27
|
+
commands: ['git', 'npm'],
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('net takes the strongest mode: any > allowlist > none', () => {
|
|
32
|
+
const none: CapabilitySpec = { net: { mode: 'none' } };
|
|
33
|
+
const list: CapabilitySpec = { net: { mode: 'allowlist', hosts: ['b.com', 'a.com'] } };
|
|
34
|
+
const any: CapabilitySpec = { net: { mode: 'any' } };
|
|
35
|
+
|
|
36
|
+
expect(aggregateCapabilitySpecs([none])).toEqual({ net: { mode: 'none' } });
|
|
37
|
+
expect(aggregateCapabilitySpecs([none, list])).toEqual({
|
|
38
|
+
net: { mode: 'allowlist', hosts: ['a.com', 'b.com'] },
|
|
39
|
+
});
|
|
40
|
+
expect(aggregateCapabilitySpecs([list, any, none])).toEqual({ net: { mode: 'any' } });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('merges allowlist hosts across specs', () => {
|
|
44
|
+
const a: CapabilitySpec = { net: { mode: 'allowlist', hosts: ['registry.npmjs.org'] } };
|
|
45
|
+
const b: CapabilitySpec = { net: { mode: 'allowlist', hosts: ['api.slack.com'] } };
|
|
46
|
+
expect(aggregateCapabilitySpecs([a, b])).toEqual({
|
|
47
|
+
net: { mode: 'allowlist', hosts: ['api.slack.com', 'registry.npmjs.org'] },
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('timeMs and memMb take the max; undeclared entries contribute nothing', () => {
|
|
52
|
+
const a: CapabilitySpec = { timeMs: 30_000, memMb: 128 };
|
|
53
|
+
const b: CapabilitySpec = { timeMs: 600_000 };
|
|
54
|
+
expect(aggregateCapabilitySpecs([a, undefined, b])).toEqual({
|
|
55
|
+
timeMs: 600_000,
|
|
56
|
+
memMb: 128,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('an "any" net dropped into a wide union does not resurrect allowlist hosts', () => {
|
|
61
|
+
// Regression guard: once mode is 'any', collected hosts must not leak
|
|
62
|
+
// back into the result as a misleading narrower-looking allowlist.
|
|
63
|
+
const spec = aggregateCapabilitySpecs([
|
|
64
|
+
{ net: { mode: 'allowlist', hosts: ['a.com'] } },
|
|
65
|
+
{ net: { mode: 'any' } },
|
|
66
|
+
]);
|
|
67
|
+
expect(spec.net).toEqual({ mode: 'any' });
|
|
68
|
+
});
|
|
69
|
+
});
|
package/src/isolation.ts
CHANGED
|
@@ -146,3 +146,70 @@ export const ISOLATION_RANK: Readonly<Record<IsolationStrength, number>> = Objec
|
|
|
146
146
|
wasm: 5,
|
|
147
147
|
docker: 6,
|
|
148
148
|
});
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Widest-wins union of capability declarations — the combined blast radius
|
|
152
|
+
* if every contributing tool exercised its full declared surface. Used for
|
|
153
|
+
* package-level views: `moxxy security audit --package`, the install-time
|
|
154
|
+
* capability report, and (later) signed-index capability manifests.
|
|
155
|
+
*
|
|
156
|
+
* Union semantics per axis: fs globs / env vars / commands are set-unions
|
|
157
|
+
* (sorted, deduped); net takes the strongest mode (`any` > `allowlist` with
|
|
158
|
+
* merged hosts > `none`); `subprocess` is an OR; `timeMs` / `memMb` take the
|
|
159
|
+
* max. `undefined` entries (undeclared tools) contribute nothing — callers
|
|
160
|
+
* report their count separately so a wide-open undeclared tool is never
|
|
161
|
+
* hidden behind a tidy aggregate.
|
|
162
|
+
*/
|
|
163
|
+
export function aggregateCapabilitySpecs(
|
|
164
|
+
specs: ReadonlyArray<CapabilitySpec | undefined>,
|
|
165
|
+
): CapabilitySpec {
|
|
166
|
+
const read = new Set<string>();
|
|
167
|
+
const write = new Set<string>();
|
|
168
|
+
const env = new Set<string>();
|
|
169
|
+
const commands = new Set<string>();
|
|
170
|
+
const hosts = new Set<string>();
|
|
171
|
+
let netMode: NetCapability['mode'] | undefined;
|
|
172
|
+
let subprocess = false;
|
|
173
|
+
let timeMs: number | undefined;
|
|
174
|
+
let memMb: number | undefined;
|
|
175
|
+
|
|
176
|
+
for (const spec of specs) {
|
|
177
|
+
if (!spec) continue;
|
|
178
|
+
for (const g of spec.fs?.read ?? []) read.add(g);
|
|
179
|
+
for (const g of spec.fs?.write ?? []) write.add(g);
|
|
180
|
+
if (spec.net) {
|
|
181
|
+
if (spec.net.mode === 'any') netMode = 'any';
|
|
182
|
+
else if (spec.net.mode === 'allowlist') {
|
|
183
|
+
if (netMode !== 'any') netMode = 'allowlist';
|
|
184
|
+
for (const h of spec.net.hosts) hosts.add(h);
|
|
185
|
+
} else netMode ??= 'none';
|
|
186
|
+
}
|
|
187
|
+
for (const e of spec.env ?? []) env.add(e);
|
|
188
|
+
if (spec.subprocess) subprocess = true;
|
|
189
|
+
for (const c of spec.commands ?? []) commands.add(c);
|
|
190
|
+
if (spec.timeMs !== undefined) timeMs = Math.max(timeMs ?? 0, spec.timeMs);
|
|
191
|
+
if (spec.memMb !== undefined) memMb = Math.max(memMb ?? 0, spec.memMb);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const sorted = (s: Set<string>): string[] => [...s].sort();
|
|
195
|
+
return {
|
|
196
|
+
...(read.size || write.size
|
|
197
|
+
? {
|
|
198
|
+
fs: {
|
|
199
|
+
...(read.size ? { read: sorted(read) } : {}),
|
|
200
|
+
...(write.size ? { write: sorted(write) } : {}),
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
: {}),
|
|
204
|
+
...(netMode === 'allowlist'
|
|
205
|
+
? { net: { mode: 'allowlist' as const, hosts: sorted(hosts) } }
|
|
206
|
+
: netMode
|
|
207
|
+
? { net: { mode: netMode } }
|
|
208
|
+
: {}),
|
|
209
|
+
...(env.size ? { env: sorted(env) } : {}),
|
|
210
|
+
...(timeMs !== undefined ? { timeMs } : {}),
|
|
211
|
+
...(memMb !== undefined ? { memMb } : {}),
|
|
212
|
+
...(subprocess ? { subprocess: true } : {}),
|
|
213
|
+
...(commands.size ? { commands: sorted(commands) } : {}),
|
|
214
|
+
};
|
|
215
|
+
}
|
package/src/mode.ts
CHANGED
|
@@ -46,6 +46,13 @@ export interface PluginHostHandle {
|
|
|
46
46
|
kinds?: ReadonlyArray<string>;
|
|
47
47
|
}>;
|
|
48
48
|
reload(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* The plugin (package) that contributed the named tool, or undefined for
|
|
51
|
+
* unknown / dynamically-attached tools. Optional so a thin-client
|
|
52
|
+
* `RemoteSession` can omit it; powers plugin-level security routing
|
|
53
|
+
* (`security.perPlugin`) and package-scoped audit views.
|
|
54
|
+
*/
|
|
55
|
+
ownerOfTool?(toolName: string): string | undefined;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
/**
|
package/src/plugin.ts
CHANGED
|
@@ -17,8 +17,9 @@ import type { ViewRendererDef } from './view-renderer.js';
|
|
|
17
17
|
import type { TunnelProviderDef } from './tunnel.js';
|
|
18
18
|
import type { WorkflowExecutorDef } from './workflow.js';
|
|
19
19
|
import type { EventStoreDef } from './event-store.js';
|
|
20
|
+
import type { ReflectorDef } from './reflector.js';
|
|
20
21
|
|
|
21
|
-
export type PluginKind = 'tools' | 'provider' | 'mode' | 'compactor' | 'cache-strategy' | 'view-renderer' | 'tunnel-provider' | 'mcp' | 'cli' | 'channel' | 'surface' | 'hooks' | 'agent' | 'command' | 'transcriber' | 'synthesizer' | 'embedder' | 'isolator' | 'workflow-executor' | 'event-store';
|
|
22
|
+
export type PluginKind = 'tools' | 'provider' | 'mode' | 'compactor' | 'cache-strategy' | 'view-renderer' | 'tunnel-provider' | 'mcp' | 'cli' | 'channel' | 'surface' | 'hooks' | 'agent' | 'command' | 'transcriber' | 'synthesizer' | 'embedder' | 'isolator' | 'workflow-executor' | 'event-store' | 'reflector';
|
|
22
23
|
|
|
23
24
|
export interface PluginSpec {
|
|
24
25
|
readonly name: string;
|
|
@@ -53,6 +54,14 @@ export interface PluginSpec {
|
|
|
53
54
|
* boundary, since the store sees every event). See {@link EventStoreDef}.
|
|
54
55
|
*/
|
|
55
56
|
readonly eventStores?: ReadonlyArray<EventStoreDef>;
|
|
57
|
+
/**
|
|
58
|
+
* Reflector backends — the learning-loop block that watches a finished turn
|
|
59
|
+
* and *proposes* memory/skill improvements without silently writing. One
|
|
60
|
+
* active at a time, selected via `plugins.reflector.default`. NULLABLE: core
|
|
61
|
+
* seeds no floor, so reflection is opt-in — no registered reflector means the
|
|
62
|
+
* session never reflects. See {@link ReflectorDef}.
|
|
63
|
+
*/
|
|
64
|
+
readonly reflectors?: ReadonlyArray<ReflectorDef>;
|
|
56
65
|
readonly channels?: ReadonlyArray<ChannelDef>;
|
|
57
66
|
/**
|
|
58
67
|
* Interactive surfaces contributed by the plugin — long-lived panes a human
|