@khorsheed/dsh-local-agent 0.2.0-rc.1 → 0.2.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 (57) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.en.md +23 -164
  3. package/README.i18n.yaml +2 -2
  4. package/README.md +23 -164
  5. package/lib/client.js +23707 -4768
  6. package/lib/index.js +827 -62
  7. package/lib/member-bridge.js +195 -25
  8. package/lib/tool-factory.js +52 -19
  9. package/lib/typert.host.js +1440 -353
  10. package/lib/typert.remote-client.d.ts +43 -3
  11. package/lib/typert.remote-client.js +973 -335
  12. package/lib/types/client/FamilyCard.d.ts +37 -0
  13. package/lib/types/client/FamilyCard.js +55 -0
  14. package/lib/types/client/HarnessModelPicker.d.ts +21 -1
  15. package/lib/types/client/HarnessModelPicker.js +31 -3
  16. package/lib/types/client/MemberLiveNode.js +38 -4
  17. package/lib/types/client/ModelListSection.d.ts +49 -0
  18. package/lib/types/client/ModelListSection.js +132 -0
  19. package/lib/types/client/ProviderAuthBlock.d.ts +10 -2
  20. package/lib/types/client/ProviderAuthBlock.js +13 -6
  21. package/lib/types/client/auth-status.d.ts +6 -0
  22. package/lib/types/client/auth-status.js +8 -0
  23. package/lib/types/client/harness-cards.d.ts +72 -0
  24. package/lib/types/client/harness-cards.js +57 -0
  25. package/lib/types/client/icons.d.ts +2 -1
  26. package/lib/types/client/icons.js +1 -0
  27. package/lib/types/client/index.d.ts +32 -7
  28. package/lib/types/client/index.js +66 -9
  29. package/lib/types/client/locales.d.ts +25 -1
  30. package/lib/types/client/locales.js +50 -2
  31. package/lib/types/client/model-directory-scope.d.ts +14 -0
  32. package/lib/types/client/model-directory-scope.js +20 -0
  33. package/lib/types/gateway.d.ts +49 -1
  34. package/lib/types/gateway.js +89 -0
  35. package/lib/types/index.d.ts +91 -38
  36. package/lib/types/index.js +190 -58
  37. package/lib/types/live-stream.d.ts +11 -0
  38. package/lib/types/live-stream.js +26 -0
  39. package/lib/types/member-bridge.d.ts +11 -1
  40. package/lib/types/member-bridge.js +81 -13
  41. package/lib/types/member-channel.d.ts +44 -1
  42. package/lib/types/member-channel.js +65 -2
  43. package/lib/types/member-controls.d.ts +8 -0
  44. package/lib/types/member-controls.js +15 -2
  45. package/lib/types/mode-skills.d.ts +18 -0
  46. package/lib/types/mode-skills.js +56 -0
  47. package/lib/types/model-list.d.ts +55 -0
  48. package/lib/types/model-list.js +101 -0
  49. package/lib/types/preset-tool-host.d.ts +70 -0
  50. package/lib/types/preset-tool-host.js +210 -0
  51. package/lib/types/tool-factory.d.ts +9 -3
  52. package/lib/types/tool-factory.js +55 -18
  53. package/lib/types/types.d.ts +62 -5
  54. package/package.json +27 -23
  55. package/lib/invariant.js +0 -85
  56. package/lib/types/invariant.d.ts +0 -16
  57. package/lib/types/invariant.js +0 -105
package/lib/invariant.js DELETED
@@ -1,85 +0,0 @@
1
- //#region lib/types/invariant.js
2
- /**
3
- * Package-owned invariant companion for `@khorsheed/dsh-local-agent`.
4
- * @module @khorsheed/dsh-local-agent/invariant
5
- */
6
- const PACKAGE_NAME = "@khorsheed/dsh-local-agent";
7
- /** Cordis companion plugin name. */
8
- const name = "local-agent-invariant";
9
- /** Service required before the companion can reserve package ownership. */
10
- const inject = ["invariants"];
11
- const NAME_PATTERN = /^[a-z][a-z0-9-]*$/u;
12
- /**
13
- * Audit the harness registry lifecycle: a registered harness must carry a
14
- * valid, unique command-prefix name, a home environment variable, and a
15
- * records adapter, and a removed name must have been registered first.
16
- */
17
- function auditLifecycle(ctx, fail) {
18
- const known = /* @__PURE__ */ new Set();
19
- ctx.on("internal/dispatch", (_mode, eventName, args) => {
20
- if (eventName === "localAgent/harness-added") {
21
- const harness = args[0];
22
- if (!NAME_PATTERN.test(harness.name)) fail(`localAgent/harness-added names a harness with invalid name ${JSON.stringify(harness.name)}`);
23
- if (known.has(harness.name)) fail(`localAgent/harness-added repeats name ${JSON.stringify(harness.name)}`);
24
- if (harness.homeEnvVar.length === 0) fail(`localAgent/harness-added for ${harness.name} has an empty homeEnvVar`);
25
- known.add(harness.name);
26
- return;
27
- }
28
- if (eventName !== "localAgent/harness-removed") return;
29
- const name = args[0];
30
- if (!known.delete(name)) fail(`localAgent/harness-removed names unknown harness ${JSON.stringify(name)}`);
31
- }, { global: true });
32
- }
33
- /**
34
- * Cross-check delegation claims against the mounted subagent providers after
35
- * the composition settles. A harness whose {@link LocalAgentHarness.delegationProvider}
36
- * names a provider the tree does not mount means "identity present, delegation
37
- * 404" — a typo in either the record or the bundle patch — and fails loud.
38
- * A composition without the subagent seam (record-and-login only) skips the
39
- * check; so does a harness without a delegation provider.
40
- */
41
- async function auditDelegationClaims(ctx, fail) {
42
- await ctx.get("loader")?.await();
43
- const subagents = ctx.get("subagents");
44
- if (subagents === void 0) return;
45
- const registry = ctx.get("localAgent");
46
- if (registry === void 0) return;
47
- for (const name of registry.list()) {
48
- const providerName = registry.get(name)?.delegationProvider;
49
- if (providerName === void 0) continue;
50
- if (subagents.getProvider(providerName) === void 0) fail(`local-agent harness ${name} declares delegation provider ${JSON.stringify(providerName)} which is not mounted`);
51
- }
52
- }
53
- /**
54
- * Audit the delegation registry: a recorded delegation must name a mounted
55
- * subagent provider (the record is only useful when a resume round can route
56
- * back through the same provider). Mirrors the harness-level delegation-claim
57
- * check with the same "identity present, delegation 404" rationale — a record
58
- * whose provider the tree does not mount means a provider rename left a stale
59
- * mapping that would fail loud on the first resume attempt.
60
- */
61
- async function auditDelegationProviders(ctx, fail) {
62
- await ctx.get("loader")?.await();
63
- const subagents = ctx.get("subagents");
64
- if (subagents === void 0) return;
65
- const registry = ctx.get("localAgent");
66
- if (registry === void 0) return;
67
- for (const record of registry.listDelegations()) if (subagents.getProvider(record.provider) === void 0) fail(`local-agent delegation for child session ${record.childSessionId} records provider ${JSON.stringify(record.provider)} which is not mounted`);
68
- }
69
- /**
70
- * Install the package's checks.
71
- * @param ctx - child context owned by this invariant registration.
72
- * @param fail - reporter bound to the registering package name.
73
- */
74
- const install = Object.assign((ctx, fail) => {
75
- auditLifecycle(ctx, fail);
76
- return Promise.all([auditDelegationClaims(ctx, fail), auditDelegationProviders(ctx, fail)]).then(() => {});
77
- }, {});
78
- /**
79
- * Register this package's invariant companion.
80
- * @param ctx - plugin context carrying the invariant registry.
81
- * @returns the installed registration's disposer.
82
- */
83
- const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
84
- //#endregion
85
- export { apply, inject, name };
@@ -1,16 +0,0 @@
1
- /**
2
- * Package-owned invariant companion for `@khorsheed/dsh-local-agent`.
3
- * @module @khorsheed/dsh-local-agent/invariant
4
- */
5
- import type { Context } from '@deepseek-ai/cordis';
6
- /** Cordis companion plugin name. */
7
- export declare const name = "local-agent-invariant";
8
- /** Service required before the companion can reserve package ownership. */
9
- export declare const inject: string[];
10
- /**
11
- * Register this package's invariant companion.
12
- * @param ctx - plugin context carrying the invariant registry.
13
- * @returns the installed registration's disposer.
14
- */
15
- export declare const apply: (ctx: Context) => Promise<() => void>;
16
- //# sourceMappingURL=invariant.d.ts.map
@@ -1,105 +0,0 @@
1
- /**
2
- * Package-owned invariant companion for `@khorsheed/dsh-local-agent`.
3
- * @module @khorsheed/dsh-local-agent/invariant
4
- */
5
- const PACKAGE_NAME = '@khorsheed/dsh-local-agent';
6
- /** Cordis companion plugin name. */
7
- export const name = 'local-agent-invariant';
8
- /** Service required before the companion can reserve package ownership. */
9
- export const inject = ['invariants'];
10
- const NAME_PATTERN = /^[a-z][a-z0-9-]*$/u;
11
- /**
12
- * Audit the harness registry lifecycle: a registered harness must carry a
13
- * valid, unique command-prefix name, a home environment variable, and a
14
- * records adapter, and a removed name must have been registered first.
15
- */
16
- function auditLifecycle(ctx, fail) {
17
- const known = new Set();
18
- ctx.on('internal/dispatch', (_mode, eventName, args) => {
19
- if (eventName === 'localAgent/harness-added') {
20
- const harness = args[0];
21
- if (!NAME_PATTERN.test(harness.name)) {
22
- fail(`localAgent/harness-added names a harness with invalid name ${JSON.stringify(harness.name)}`);
23
- }
24
- if (known.has(harness.name))
25
- fail(`localAgent/harness-added repeats name ${JSON.stringify(harness.name)}`);
26
- if (harness.homeEnvVar.length === 0)
27
- fail(`localAgent/harness-added for ${harness.name} has an empty homeEnvVar`);
28
- known.add(harness.name);
29
- return;
30
- }
31
- if (eventName !== 'localAgent/harness-removed')
32
- return;
33
- const name = args[0];
34
- if (!known.delete(name))
35
- fail(`localAgent/harness-removed names unknown harness ${JSON.stringify(name)}`);
36
- }, { global: true });
37
- }
38
- /**
39
- * Cross-check delegation claims against the mounted subagent providers after
40
- * the composition settles. A harness whose {@link LocalAgentHarness.delegationProvider}
41
- * names a provider the tree does not mount means "identity present, delegation
42
- * 404" — a typo in either the record or the bundle patch — and fails loud.
43
- * A composition without the subagent seam (record-and-login only) skips the
44
- * check; so does a harness without a delegation provider.
45
- */
46
- async function auditDelegationClaims(ctx, fail) {
47
- const loader = ctx.get('loader');
48
- await loader?.await();
49
- const subagents = ctx.get('subagents');
50
- if (subagents === undefined)
51
- return;
52
- const registry = ctx.get('localAgent');
53
- if (registry === undefined)
54
- return;
55
- for (const name of registry.list()) {
56
- const providerName = registry.get(name)?.delegationProvider;
57
- if (providerName === undefined)
58
- continue;
59
- if (subagents.getProvider(providerName) === undefined) {
60
- fail(`local-agent harness ${name} declares delegation provider ${JSON.stringify(providerName)} which is not mounted`);
61
- }
62
- }
63
- }
64
- /**
65
- * Audit the delegation registry: a recorded delegation must name a mounted
66
- * subagent provider (the record is only useful when a resume round can route
67
- * back through the same provider). Mirrors the harness-level delegation-claim
68
- * check with the same "identity present, delegation 404" rationale — a record
69
- * whose provider the tree does not mount means a provider rename left a stale
70
- * mapping that would fail loud on the first resume attempt.
71
- */
72
- async function auditDelegationProviders(ctx, fail) {
73
- const loader = ctx.get('loader');
74
- await loader?.await();
75
- const subagents = ctx.get('subagents');
76
- if (subagents === undefined)
77
- return;
78
- const registry = ctx.get('localAgent');
79
- if (registry === undefined)
80
- return;
81
- for (const record of registry.listDelegations()) {
82
- if (subagents.getProvider(record.provider) === undefined) {
83
- fail(`local-agent delegation for child session ${record.childSessionId} records provider ${JSON.stringify(record.provider)} which is not mounted`);
84
- }
85
- }
86
- }
87
- /**
88
- * Install the package's checks.
89
- * @param ctx - child context owned by this invariant registration.
90
- * @param fail - reporter bound to the registering package name.
91
- */
92
- const install = Object.assign((ctx, fail) => {
93
- auditLifecycle(ctx, fail);
94
- return Promise.all([
95
- auditDelegationClaims(ctx, fail),
96
- auditDelegationProviders(ctx, fail),
97
- ]).then(() => { });
98
- }, {});
99
- /**
100
- * Register this package's invariant companion.
101
- * @param ctx - plugin context carrying the invariant registry.
102
- * @returns the installed registration's disposer.
103
- */
104
- export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
105
- /* jscpd:ignore-end */