dominds-kernel 1.8.5

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 (72) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +3 -0
  3. package/dist/app-host-contract.d.ts +87 -0
  4. package/dist/app-host-contract.js +2 -0
  5. package/dist/app-json.d.ts +139 -0
  6. package/dist/app-json.js +234 -0
  7. package/dist/diligence.d.ts +3 -0
  8. package/dist/diligence.js +64 -0
  9. package/dist/evt.d.ts +40 -0
  10. package/dist/evt.js +142 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/index.js +25 -0
  13. package/dist/team-mgmt-manual.d.ts +20 -0
  14. package/dist/team-mgmt-manual.js +121 -0
  15. package/dist/types/context-health.d.ts +33 -0
  16. package/dist/types/context-health.js +2 -0
  17. package/dist/types/dialog.d.ts +398 -0
  18. package/dist/types/dialog.js +8 -0
  19. package/dist/types/display-state.d.ts +43 -0
  20. package/dist/types/display-state.js +2 -0
  21. package/dist/types/i18n.d.ts +2 -0
  22. package/dist/types/i18n.js +2 -0
  23. package/dist/types/language.d.ts +5 -0
  24. package/dist/types/language.js +35 -0
  25. package/dist/types/priming.d.ts +55 -0
  26. package/dist/types/priming.js +2 -0
  27. package/dist/types/problems.d.ts +128 -0
  28. package/dist/types/problems.js +2 -0
  29. package/dist/types/q4h.d.ts +9 -0
  30. package/dist/types/q4h.js +2 -0
  31. package/dist/types/setup.d.ts +170 -0
  32. package/dist/types/setup.js +2 -0
  33. package/dist/types/snippets.d.ts +68 -0
  34. package/dist/types/snippets.js +2 -0
  35. package/dist/types/storage.d.ts +561 -0
  36. package/dist/types/storage.js +85 -0
  37. package/dist/types/tools-registry.d.ts +19 -0
  38. package/dist/types/tools-registry.js +2 -0
  39. package/dist/types/wire.d.ts +227 -0
  40. package/dist/types/wire.js +18 -0
  41. package/dist/types.d.ts +112 -0
  42. package/dist/types.js +28 -0
  43. package/dist/utils/html.d.ts +2 -0
  44. package/dist/utils/html.js +20 -0
  45. package/dist/utils/id.d.ts +1 -0
  46. package/dist/utils/id.js +6 -0
  47. package/dist/utils/time.d.ts +1 -0
  48. package/dist/utils/time.js +13 -0
  49. package/package.json +84 -0
  50. package/src/app-host-contract.ts +105 -0
  51. package/src/app-json.ts +401 -0
  52. package/src/diligence.ts +64 -0
  53. package/src/evt.ts +156 -0
  54. package/src/index.ts +48 -0
  55. package/src/team-mgmt-manual.ts +151 -0
  56. package/src/types/context-health.ts +39 -0
  57. package/src/types/dialog.ts +487 -0
  58. package/src/types/display-state.ts +21 -0
  59. package/src/types/i18n.ts +3 -0
  60. package/src/types/language.ts +33 -0
  61. package/src/types/priming.ts +69 -0
  62. package/src/types/problems.ts +144 -0
  63. package/src/types/q4h.ts +11 -0
  64. package/src/types/setup.ts +140 -0
  65. package/src/types/snippets.ts +55 -0
  66. package/src/types/storage.ts +682 -0
  67. package/src/types/tools-registry.ts +24 -0
  68. package/src/types/wire.ts +335 -0
  69. package/src/types.ts +133 -0
  70. package/src/utils/html.ts +17 -0
  71. package/src/utils/id.ts +3 -0
  72. package/src/utils/time.ts +10 -0
package/dist/evt.js ADDED
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /**
3
+ * Event processing constructs equivalent to Edh's:
4
+ * - PubChan: write-only broadcast channel
5
+ * - SubChan: read-only subscriber channel
6
+ * - EventSink: event source with sequence and most-recent value, streaming support
7
+ *
8
+ * Notes:
9
+ * - PubChan behaves like a broadcast channel: if there is no SubChan reading, writes are effectively dropped
10
+ * - SubChan buffers unboundedly relative to its own consumption speed
11
+ * - EndOfStream sentinel signals termination of streams
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.EventSink = exports.SubChan = exports.PubChan = exports.EndOfStream = void 0;
15
+ exports.createPubChan = createPubChan;
16
+ exports.createSubChan = createSubChan;
17
+ exports.createEventSink = createEventSink;
18
+ exports.EndOfStream = Symbol('EndOfStream');
19
+ function deferred() {
20
+ let resolveFn = null;
21
+ const promise = new Promise((resolve) => {
22
+ resolveFn = resolve;
23
+ });
24
+ if (!resolveFn) {
25
+ throw new Error('Deferred initialization failed.');
26
+ }
27
+ return { promise, resolve: resolveFn };
28
+ }
29
+ class PubChan {
30
+ constructor() {
31
+ this.nxt = deferred();
32
+ }
33
+ write(ev) {
34
+ const next = deferred();
35
+ this.nxt.resolve([ev, next.promise]);
36
+ this.nxt = next;
37
+ }
38
+ get nextPromise() {
39
+ return this.nxt.promise;
40
+ }
41
+ }
42
+ exports.PubChan = PubChan;
43
+ class SubChan {
44
+ constructor(pub) {
45
+ this.nxtP = pub.nextPromise;
46
+ const cancelDefer = deferred();
47
+ this.cancelled = cancelDefer.promise;
48
+ this.cancel = () => cancelDefer.resolve();
49
+ }
50
+ async read() {
51
+ const raceResult = await Promise.race([this.cancelled, this.nxtP]);
52
+ if (raceResult === undefined) {
53
+ return exports.EndOfStream;
54
+ }
55
+ const [ev, nextP] = raceResult;
56
+ this.nxtP = nextP;
57
+ return ev;
58
+ }
59
+ stream() {
60
+ let nxtP = this.nxtP;
61
+ return (async function* (self) {
62
+ // eslint-disable-next-line no-constant-condition
63
+ while (true) {
64
+ const result = await Promise.race([self.cancelled, nxtP]);
65
+ if (result === undefined) {
66
+ return;
67
+ }
68
+ const [ev, nextPResolved] = result;
69
+ nxtP = self.nxtP = nextPResolved;
70
+ if (ev === exports.EndOfStream) {
71
+ return;
72
+ }
73
+ yield ev;
74
+ }
75
+ })(this);
76
+ }
77
+ }
78
+ exports.SubChan = SubChan;
79
+ class EventSink {
80
+ constructor() {
81
+ this.seqn = 0;
82
+ this.mrv = null;
83
+ this.chan = new PubChan();
84
+ }
85
+ get eos() {
86
+ return this.mrv === exports.EndOfStream;
87
+ }
88
+ publish(ev) {
89
+ if (ev === exports.EndOfStream && this.mrv === exports.EndOfStream) {
90
+ return;
91
+ }
92
+ if (this.seqn >= 9223372036854776000) {
93
+ this.seqn = 1;
94
+ }
95
+ else {
96
+ this.seqn += 1;
97
+ }
98
+ this.mrv = ev;
99
+ this.chan.write(ev);
100
+ }
101
+ async one_more() {
102
+ if (this.seqn > 0 && this.mrv === exports.EndOfStream) {
103
+ return exports.EndOfStream;
104
+ }
105
+ const [ev] = await this.chan.nextPromise;
106
+ return ev;
107
+ }
108
+ stream() {
109
+ const yield1st = this.mrv;
110
+ const shouldYield1st = this.seqn > 0;
111
+ let nxtP = this.chan.nextPromise;
112
+ return (async function* () {
113
+ if (shouldYield1st) {
114
+ if (yield1st === exports.EndOfStream) {
115
+ return;
116
+ }
117
+ if (yield1st !== null) {
118
+ yield yield1st;
119
+ }
120
+ }
121
+ // eslint-disable-next-line no-constant-condition
122
+ while (true) {
123
+ const [ev, nextP] = await Promise.resolve(nxtP);
124
+ if (ev === exports.EndOfStream) {
125
+ return;
126
+ }
127
+ yield ev;
128
+ nxtP = nextP;
129
+ }
130
+ })();
131
+ }
132
+ }
133
+ exports.EventSink = EventSink;
134
+ function createPubChan() {
135
+ return new PubChan();
136
+ }
137
+ function createSubChan(pub) {
138
+ return new SubChan(pub);
139
+ }
140
+ function createEventSink() {
141
+ return new EventSink();
142
+ }
@@ -0,0 +1,6 @@
1
+ export type { CreateDomindsAppFn, DomindsAppDynamicToolsetsContext, DomindsAppDynamicToolsetsHandler, DomindsAppHostInstance, DomindsAppHostStartResult, DomindsAppReminderOwnerApplyContext, DomindsAppReminderOwnerHandler, DomindsAppReminderOwnerRenderContext, DomindsAppReminderOwnerUpdateContext, DomindsAppRunControlContext, DomindsAppRunControlHandler, DomindsAppRunControlResult, } from './app-host-contract';
2
+ export { parseDomindsAppInstallJson } from './app-json';
3
+ export * from './types';
4
+ export type { DomindsAppContributesJson, DomindsAppDialogInfo, DomindsAppDialogReminderRequestBatch, DomindsAppDialogRunControlJson, DomindsAppDialogTargetRef, DomindsAppFrontendJson, DomindsAppHostEntryJson, DomindsAppHostReminderUpdateResult, DomindsAppHostToolContext, DomindsAppHostToolHandler, DomindsAppHostToolResult, DomindsAppInstallJsonV1, DomindsAppJsonSchemaVersion, DomindsAppReminderApplyRequest, DomindsAppReminderApplyResult, DomindsAppReminderOwnerJson, DomindsAppReminderState, DomindsAppToolJson, DomindsAppToolsetJson, } from './app-json';
5
+ export { TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY, TEAM_MGMT_MANUAL_UI_TOPIC_ORDER, getTeamMgmtManualTopicTitle, isTeamMgmtManualTopicKey, } from './team-mgmt-manual';
6
+ export type { TeamMgmtManualLanguageCode, TeamMgmtManualTopicKey } from './team-mgmt-manual';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.isTeamMgmtManualTopicKey = exports.getTeamMgmtManualTopicTitle = exports.TEAM_MGMT_MANUAL_UI_TOPIC_ORDER = exports.TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY = exports.parseDomindsAppInstallJson = void 0;
18
+ var app_json_1 = require("./app-json");
19
+ Object.defineProperty(exports, "parseDomindsAppInstallJson", { enumerable: true, get: function () { return app_json_1.parseDomindsAppInstallJson; } });
20
+ __exportStar(require("./types"), exports);
21
+ var team_mgmt_manual_1 = require("./team-mgmt-manual");
22
+ Object.defineProperty(exports, "TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY", { enumerable: true, get: function () { return team_mgmt_manual_1.TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY; } });
23
+ Object.defineProperty(exports, "TEAM_MGMT_MANUAL_UI_TOPIC_ORDER", { enumerable: true, get: function () { return team_mgmt_manual_1.TEAM_MGMT_MANUAL_UI_TOPIC_ORDER; } });
24
+ Object.defineProperty(exports, "getTeamMgmtManualTopicTitle", { enumerable: true, get: function () { return team_mgmt_manual_1.getTeamMgmtManualTopicTitle; } });
25
+ Object.defineProperty(exports, "isTeamMgmtManualTopicKey", { enumerable: true, get: function () { return team_mgmt_manual_1.isTeamMgmtManualTopicKey; } });
@@ -0,0 +1,20 @@
1
+ export declare const TEAM_MGMT_MANUAL_TOPIC_KEYS: readonly ["topics", "llm", "model-params", "builtin-defaults", "mcp", "team", "member-properties", "minds", "skills", "priming", "env", "permissions", "toolsets", "troubleshooting"];
2
+ export type TeamMgmtManualTopicKey = (typeof TEAM_MGMT_MANUAL_TOPIC_KEYS)[number];
3
+ export type TeamMgmtManualLanguageCode = 'en' | 'zh';
4
+ export type TeamMgmtManualTopicMeta = Readonly<{
5
+ titleI18n: Readonly<{
6
+ en: string;
7
+ zh: string;
8
+ }>;
9
+ }>;
10
+ export declare const TEAM_MGMT_MANUAL_TOPIC_META: Readonly<Record<TeamMgmtManualTopicKey, TeamMgmtManualTopicMeta>>;
11
+ export declare function isTeamMgmtManualTopicKey(value: string): value is TeamMgmtManualTopicKey;
12
+ export declare function getTeamMgmtManualTopicTitle(lang: TeamMgmtManualLanguageCode, key: TeamMgmtManualTopicKey): string;
13
+ export declare const TEAM_MGMT_MANUAL_UI_TOPIC_ORDER: readonly TeamMgmtManualTopicKey[];
14
+ export declare const TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY: Readonly<Record<TeamMgmtManualTopicKey, readonly TeamMgmtManualTopicKey[]>>;
15
+ export type TeamMgmtManualPanelTopicKey = 'index' | 'permissions' | 'team' | 'toolsets' | 'skills';
16
+ export declare const TEAM_MGMT_MANUAL_PANEL_TOPIC_ORDER: readonly TeamMgmtManualPanelTopicKey[];
17
+ export declare const TEAM_MGMT_MANUAL_PANEL_TOOL_TOPICS_BY_KEY: Readonly<Record<TeamMgmtManualPanelTopicKey, readonly TeamMgmtManualTopicKey[]>>;
18
+ export declare function isTeamMgmtManualPanelTopicKey(value: string): value is TeamMgmtManualPanelTopicKey;
19
+ export declare const TEAM_MGMT_MANUAL_PANEL_TOPIC_META: Readonly<Record<TeamMgmtManualPanelTopicKey, TeamMgmtManualTopicMeta>>;
20
+ export declare function getTeamMgmtManualPanelTopicTitle(lang: TeamMgmtManualLanguageCode, key: TeamMgmtManualPanelTopicKey): string;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEAM_MGMT_MANUAL_PANEL_TOPIC_META = exports.TEAM_MGMT_MANUAL_PANEL_TOOL_TOPICS_BY_KEY = exports.TEAM_MGMT_MANUAL_PANEL_TOPIC_ORDER = exports.TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY = exports.TEAM_MGMT_MANUAL_UI_TOPIC_ORDER = exports.TEAM_MGMT_MANUAL_TOPIC_META = exports.TEAM_MGMT_MANUAL_TOPIC_KEYS = void 0;
4
+ exports.isTeamMgmtManualTopicKey = isTeamMgmtManualTopicKey;
5
+ exports.getTeamMgmtManualTopicTitle = getTeamMgmtManualTopicTitle;
6
+ exports.isTeamMgmtManualPanelTopicKey = isTeamMgmtManualPanelTopicKey;
7
+ exports.getTeamMgmtManualPanelTopicTitle = getTeamMgmtManualPanelTopicTitle;
8
+ exports.TEAM_MGMT_MANUAL_TOPIC_KEYS = [
9
+ 'topics',
10
+ 'llm',
11
+ 'model-params',
12
+ 'builtin-defaults',
13
+ 'mcp',
14
+ 'team',
15
+ 'member-properties',
16
+ 'minds',
17
+ 'skills',
18
+ 'priming',
19
+ 'env',
20
+ 'permissions',
21
+ 'toolsets',
22
+ 'troubleshooting',
23
+ ];
24
+ exports.TEAM_MGMT_MANUAL_TOPIC_META = {
25
+ topics: { titleI18n: { zh: '索引', en: 'Index' } },
26
+ team: { titleI18n: { zh: 'Team(team.yaml)', en: 'Team (team.yaml)' } },
27
+ 'member-properties': {
28
+ titleI18n: { zh: '成员字段(members.<id>)', en: 'Member Properties (members.<id>)' },
29
+ },
30
+ permissions: { titleI18n: { zh: '权限(permissions)', en: 'Permissions' } },
31
+ toolsets: { titleI18n: { zh: '工具集(toolsets)', en: 'Toolsets' } },
32
+ llm: { titleI18n: { zh: 'LLM(llm.yaml)', en: 'LLM (llm.yaml)' } },
33
+ 'builtin-defaults': { titleI18n: { zh: '内置 Defaults(LLM)', en: 'Built-in Defaults (LLM)' } },
34
+ 'model-params': {
35
+ titleI18n: { zh: '模型参数(model_params)', en: 'Model Params (model_params)' },
36
+ },
37
+ mcp: { titleI18n: { zh: 'MCP(mcp.yaml)', en: 'MCP (mcp.yaml)' } },
38
+ minds: {
39
+ titleI18n: { zh: '角色资产(.minds/team/<id>/*)', en: 'Minds Assets (.minds/team/<id>/*)' },
40
+ },
41
+ skills: {
42
+ titleI18n: { zh: '技能(.minds/skills/*)', en: 'Skills (.minds/skills/*)' },
43
+ },
44
+ priming: {
45
+ titleI18n: {
46
+ zh: '启动脚本(.minds/priming/*)',
47
+ en: 'Startup Scripts (.minds/priming/*)',
48
+ },
49
+ },
50
+ env: { titleI18n: { zh: '环境提示(env.*.md)', en: 'Environment Intro (env.*.md)' } },
51
+ troubleshooting: { titleI18n: { zh: '排障(troubleshooting)', en: 'Troubleshooting' } },
52
+ };
53
+ const TEAM_MGMT_MANUAL_TOPIC_KEY_SET = new Set(exports.TEAM_MGMT_MANUAL_TOPIC_KEYS);
54
+ function isTeamMgmtManualTopicKey(value) {
55
+ return TEAM_MGMT_MANUAL_TOPIC_KEY_SET.has(value);
56
+ }
57
+ function getTeamMgmtManualTopicTitle(lang, key) {
58
+ const meta = exports.TEAM_MGMT_MANUAL_TOPIC_META[key];
59
+ return lang === 'zh' ? meta.titleI18n.zh : meta.titleI18n.en;
60
+ }
61
+ exports.TEAM_MGMT_MANUAL_UI_TOPIC_ORDER = [
62
+ 'topics',
63
+ 'team',
64
+ 'member-properties',
65
+ 'permissions',
66
+ 'toolsets',
67
+ 'llm',
68
+ 'model-params',
69
+ 'builtin-defaults',
70
+ 'mcp',
71
+ 'minds',
72
+ 'skills',
73
+ 'priming',
74
+ 'env',
75
+ 'troubleshooting',
76
+ ];
77
+ exports.TEAM_MGMT_MANUAL_UI_TOOL_TOPICS_BY_KEY = {
78
+ topics: ['topics'],
79
+ team: ['team'],
80
+ 'member-properties': ['team', 'member-properties'],
81
+ permissions: ['permissions'],
82
+ toolsets: ['toolsets'],
83
+ llm: ['llm'],
84
+ 'model-params': ['llm', 'model-params'],
85
+ 'builtin-defaults': ['llm', 'builtin-defaults'],
86
+ mcp: ['mcp'],
87
+ minds: ['minds'],
88
+ skills: ['skills'],
89
+ priming: ['priming'],
90
+ env: ['env'],
91
+ troubleshooting: ['troubleshooting'],
92
+ };
93
+ exports.TEAM_MGMT_MANUAL_PANEL_TOPIC_ORDER = [
94
+ 'index',
95
+ 'permissions',
96
+ 'team',
97
+ 'toolsets',
98
+ 'skills',
99
+ ];
100
+ const EMPTY_TOOL_TOPICS = [];
101
+ exports.TEAM_MGMT_MANUAL_PANEL_TOOL_TOPICS_BY_KEY = {
102
+ index: EMPTY_TOOL_TOPICS,
103
+ permissions: ['permissions'],
104
+ team: ['team'],
105
+ toolsets: ['toolsets'],
106
+ skills: ['skills'],
107
+ };
108
+ function isTeamMgmtManualPanelTopicKey(value) {
109
+ return Object.prototype.hasOwnProperty.call(exports.TEAM_MGMT_MANUAL_PANEL_TOOL_TOPICS_BY_KEY, value);
110
+ }
111
+ exports.TEAM_MGMT_MANUAL_PANEL_TOPIC_META = {
112
+ index: { titleI18n: { zh: '索引', en: 'Index' } },
113
+ permissions: exports.TEAM_MGMT_MANUAL_TOPIC_META.permissions,
114
+ team: exports.TEAM_MGMT_MANUAL_TOPIC_META.team,
115
+ toolsets: exports.TEAM_MGMT_MANUAL_TOPIC_META.toolsets,
116
+ skills: exports.TEAM_MGMT_MANUAL_TOPIC_META.skills,
117
+ };
118
+ function getTeamMgmtManualPanelTopicTitle(lang, key) {
119
+ const meta = exports.TEAM_MGMT_MANUAL_PANEL_TOPIC_META[key];
120
+ return lang === 'zh' ? meta.titleI18n.zh : meta.titleI18n.en;
121
+ }
@@ -0,0 +1,33 @@
1
+ export type LlmUsageStats = {
2
+ kind: 'unavailable';
3
+ } | {
4
+ kind: 'available';
5
+ promptTokens: number;
6
+ completionTokens: number;
7
+ totalTokens?: number;
8
+ };
9
+ export type ContextHealthLevel = 'healthy' | 'caution' | 'critical';
10
+ export type ContextHealthSnapshot = {
11
+ kind: 'unavailable';
12
+ reason: 'usage_unavailable' | 'model_limit_unavailable';
13
+ modelContextWindowText?: string;
14
+ modelContextLimitTokens?: number;
15
+ effectiveOptimalMaxTokens?: number;
16
+ optimalMaxTokensConfigured?: number;
17
+ effectiveCriticalMaxTokens?: number;
18
+ criticalMaxTokensConfigured?: number;
19
+ } | {
20
+ kind: 'available';
21
+ promptTokens: number;
22
+ completionTokens: number;
23
+ totalTokens?: number;
24
+ modelContextWindowText?: string;
25
+ modelContextLimitTokens: number;
26
+ effectiveOptimalMaxTokens: number;
27
+ optimalMaxTokensConfigured?: number;
28
+ effectiveCriticalMaxTokens: number;
29
+ criticalMaxTokensConfigured?: number;
30
+ hardUtil: number;
31
+ optimalUtil: number;
32
+ level: ContextHealthLevel;
33
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });