@longrun-ai/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 +87 -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/LICENSE ADDED
@@ -0,0 +1 @@
1
+ See ../../LICENSE
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @longrun-ai/kernel
2
+
3
+ Public Dominds kernel contracts for app install-json parsing, app host/runtime types, and shared team-manual helpers.
@@ -0,0 +1,87 @@
1
+ import type { DomindsAppFrontendJson, DomindsAppHostReminderUpdateResult, DomindsAppHostToolHandler, DomindsAppReminderApplyRequest, DomindsAppReminderApplyResult, DomindsAppReminderState } from './app-json';
2
+ import type { LanguageCode } from './types/language';
3
+ export type ChatMessage = Readonly<Record<string, unknown>>;
4
+ export type DomindsAppRunControlContext = Readonly<{
5
+ dialog: Readonly<{
6
+ selfId: string;
7
+ rootId: string;
8
+ }>;
9
+ agentId: string;
10
+ taskDocPath: string;
11
+ genIterNo: number;
12
+ prompt?: Readonly<{
13
+ content: string;
14
+ msgId: string;
15
+ grammar: 'markdown';
16
+ userLanguageCode: LanguageCode;
17
+ origin?: 'user' | 'diligence_push' | 'runtime';
18
+ }>;
19
+ source: 'drive_dlg_by_user_msg' | 'drive_dialog_by_user_answer';
20
+ input: Readonly<Record<string, unknown>>;
21
+ q4h?: Readonly<{
22
+ questionId: string;
23
+ continuationType: 'answer' | 'followup' | 'retry' | 'new_message';
24
+ }>;
25
+ }>;
26
+ export type DomindsAppRunControlResult = Readonly<{
27
+ kind: 'continue';
28
+ } | {
29
+ kind: 'reject';
30
+ errorText: string;
31
+ }>;
32
+ export type DomindsAppRunControlHandler = (ctx: DomindsAppRunControlContext) => Promise<DomindsAppRunControlResult>;
33
+ export type DomindsAppReminderOwnerApplyContext = Readonly<{
34
+ dialogId: string;
35
+ ownedReminders: ReadonlyArray<DomindsAppReminderState>;
36
+ }>;
37
+ export type DomindsAppReminderOwnerUpdateContext = Readonly<{
38
+ dialogId: string;
39
+ reminder: DomindsAppReminderState;
40
+ }>;
41
+ export type DomindsAppReminderOwnerRenderContext = Readonly<{
42
+ dialogId: string;
43
+ reminder: DomindsAppReminderState;
44
+ reminderNo: number;
45
+ workLanguage: LanguageCode;
46
+ }>;
47
+ export type DomindsAppDynamicToolsetsContext = Readonly<{
48
+ memberId: string;
49
+ taskDocPath: string;
50
+ dialogId?: string;
51
+ rootDialogId?: string;
52
+ agentId?: string;
53
+ sessionSlug?: string;
54
+ }>;
55
+ export type DomindsAppReminderOwnerHandler = Readonly<{
56
+ apply: (request: DomindsAppReminderApplyRequest, ctx: DomindsAppReminderOwnerApplyContext) => Promise<DomindsAppReminderApplyResult>;
57
+ updateReminder: (ctx: DomindsAppReminderOwnerUpdateContext) => Promise<DomindsAppHostReminderUpdateResult>;
58
+ renderReminder: (ctx: DomindsAppReminderOwnerRenderContext) => Promise<ChatMessage>;
59
+ }>;
60
+ export type DomindsAppDynamicToolsetsHandler = (ctx: DomindsAppDynamicToolsetsContext) => Promise<readonly string[]>;
61
+ export type DomindsAppHostStartResult = Readonly<{
62
+ port: number;
63
+ baseUrl: string;
64
+ wsUrl: string | null;
65
+ }>;
66
+ export type DomindsAppHostInstance = Readonly<{
67
+ tools: Readonly<Record<string, DomindsAppHostToolHandler>>;
68
+ runControls?: Readonly<Record<string, DomindsAppRunControlHandler>>;
69
+ reminderOwners?: Readonly<Record<string, DomindsAppReminderOwnerHandler>>;
70
+ dynamicToolsets?: DomindsAppDynamicToolsetsHandler;
71
+ start?: (params: Readonly<{
72
+ runtimePort: number | null;
73
+ frontend?: DomindsAppFrontendJson;
74
+ }>) => Promise<DomindsAppHostStartResult>;
75
+ shutdown?: () => Promise<void>;
76
+ }>;
77
+ export type CreateDomindsAppFn = (ctx: Readonly<{
78
+ appId: string;
79
+ rtwsRootAbs: string;
80
+ rtwsAppDirAbs: string;
81
+ packageRootAbs: string;
82
+ kernel: Readonly<{
83
+ host: string;
84
+ port: number;
85
+ }>;
86
+ log: (level: 'info' | 'warn' | 'error', msg: string, data?: Readonly<Record<string, unknown>>) => void;
87
+ }>) => DomindsAppHostInstance | Promise<DomindsAppHostInstance>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,139 @@
1
+ import type { I18nText } from './types/i18n';
2
+ export type JsonPrimitive = string | number | boolean | null;
3
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
4
+ export type JsonObject = {
5
+ [key: string]: JsonValue;
6
+ };
7
+ export type JsonArray = JsonValue[];
8
+ export type ToolArguments = JsonObject;
9
+ export type JsonSchema = Record<string, unknown>;
10
+ export type ToolCallOutput = string | {
11
+ content: string;
12
+ contentItems?: ReadonlyArray<unknown>;
13
+ };
14
+ export interface ReminderUpdateResult {
15
+ treatment: 'drop' | 'keep' | 'update';
16
+ updatedContent?: string;
17
+ updatedMeta?: JsonValue;
18
+ }
19
+ export type DomindsAppJsonSchemaVersion = 1;
20
+ export type DomindsAppToolJson = Readonly<{
21
+ name: string;
22
+ description?: string;
23
+ descriptionI18n?: I18nText;
24
+ parameters: JsonSchema;
25
+ }>;
26
+ export type DomindsAppToolsetJson = Readonly<{
27
+ id: string;
28
+ descriptionI18n?: I18nText;
29
+ tools: ReadonlyArray<DomindsAppToolJson>;
30
+ }>;
31
+ export type DomindsAppDialogRunControlJson = Readonly<{
32
+ id: string;
33
+ descriptionI18n?: I18nText;
34
+ }>;
35
+ export type DomindsAppReminderOwnerJson = Readonly<{
36
+ ref: string;
37
+ managedByTool?: string;
38
+ updateExample?: string;
39
+ }>;
40
+ export type DomindsAppContributesJson = Readonly<{
41
+ teammatesYamlRelPath?: string;
42
+ toolsets?: ReadonlyArray<DomindsAppToolsetJson>;
43
+ dialogRunControls?: ReadonlyArray<DomindsAppDialogRunControlJson>;
44
+ reminderOwners?: ReadonlyArray<DomindsAppReminderOwnerJson>;
45
+ }>;
46
+ export type DomindsAppHostEntryJson = Readonly<{
47
+ kind: 'node_module';
48
+ moduleRelPath: string;
49
+ exportName: string;
50
+ }>;
51
+ export type DomindsAppFrontendJson = Readonly<{
52
+ kind: 'http';
53
+ defaultPort?: number;
54
+ basePath?: string;
55
+ wsPath?: string;
56
+ }>;
57
+ export type DomindsAppInstallJsonV1 = Readonly<{
58
+ schemaVersion: DomindsAppJsonSchemaVersion;
59
+ appId: string;
60
+ displayName?: string;
61
+ package: Readonly<{
62
+ name: string;
63
+ version: string | null;
64
+ rootAbs: string;
65
+ }>;
66
+ host: DomindsAppHostEntryJson;
67
+ frontend?: DomindsAppFrontendJson;
68
+ contributes?: DomindsAppContributesJson;
69
+ }>;
70
+ export declare function parseDomindsAppInstallJson(v: unknown): {
71
+ ok: true;
72
+ json: DomindsAppInstallJsonV1;
73
+ } | {
74
+ ok: false;
75
+ errorText: string;
76
+ };
77
+ export type DomindsAppHostToolContext = Readonly<{
78
+ dialogId: string;
79
+ rootDialogId: string;
80
+ agentId: string;
81
+ taskDocPath: string;
82
+ sessionSlug?: string;
83
+ callerId: string;
84
+ }>;
85
+ export type DomindsAppDialogTargetRef = Readonly<{
86
+ dialogId: string;
87
+ } | {
88
+ rootDialogId?: string;
89
+ agentId: string;
90
+ sessionSlug?: string;
91
+ }>;
92
+ export type DomindsAppDialogInfo = Readonly<{
93
+ dialogId: string;
94
+ rootDialogId: string;
95
+ agentId: string;
96
+ sessionSlug?: string;
97
+ }>;
98
+ export type DomindsAppReminderState = Readonly<{
99
+ content: string;
100
+ meta?: JsonValue;
101
+ echoback?: boolean;
102
+ }>;
103
+ export type DomindsAppReminderApplyRequest = Readonly<{
104
+ kind: 'upsert';
105
+ ownerRef: string;
106
+ content: string;
107
+ meta?: JsonValue;
108
+ position?: number;
109
+ echoback?: boolean;
110
+ } | {
111
+ kind: 'delete';
112
+ ownerRef: string;
113
+ meta?: JsonValue;
114
+ }>;
115
+ export type DomindsAppReminderApplyResult = Readonly<{
116
+ treatment: 'noop';
117
+ } | {
118
+ treatment: 'add';
119
+ reminder: DomindsAppReminderState;
120
+ position?: number;
121
+ } | {
122
+ treatment: 'update';
123
+ ownedIndex: number;
124
+ reminder: DomindsAppReminderState;
125
+ } | {
126
+ treatment: 'delete';
127
+ ownedIndex: number;
128
+ }>;
129
+ export type DomindsAppDialogReminderRequestBatch = Readonly<{
130
+ target: DomindsAppDialogTargetRef;
131
+ reminderRequests: ReadonlyArray<DomindsAppReminderApplyRequest>;
132
+ }>;
133
+ export type DomindsAppHostToolResult = Readonly<{
134
+ output: ToolCallOutput;
135
+ reminderRequests?: ReadonlyArray<DomindsAppReminderApplyRequest>;
136
+ dialogReminderRequests?: ReadonlyArray<DomindsAppDialogReminderRequestBatch>;
137
+ }>;
138
+ export type DomindsAppHostToolHandler = (args: ToolArguments, ctx: DomindsAppHostToolContext) => Promise<ToolCallOutput | DomindsAppHostToolResult>;
139
+ export type DomindsAppHostReminderUpdateResult = ReminderUpdateResult;
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseDomindsAppInstallJson = parseDomindsAppInstallJson;
4
+ function isRecord(v) {
5
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
6
+ }
7
+ function asString(v) {
8
+ return typeof v === 'string' ? v : null;
9
+ }
10
+ function asNullableString(v) {
11
+ if (v === null)
12
+ return null;
13
+ return typeof v === 'string' ? v : null;
14
+ }
15
+ function isI18nText(v) {
16
+ return isRecord(v) && typeof v['zh'] === 'string' && typeof v['en'] === 'string';
17
+ }
18
+ function isJsonSchema(v) {
19
+ return isRecord(v);
20
+ }
21
+ function parseToolJson(v, at) {
22
+ if (!isRecord(v))
23
+ return { ok: false, errorText: `Invalid ${at}: expected object` };
24
+ const name = asString(v['name']);
25
+ if (!name || name.trim() === '')
26
+ return { ok: false, errorText: `Invalid ${at}.name: required` };
27
+ const description = asString(v['description']) ?? undefined;
28
+ const descriptionI18n = v['descriptionI18n'];
29
+ if (descriptionI18n !== undefined && !isI18nText(descriptionI18n)) {
30
+ return { ok: false, errorText: `Invalid ${at}.descriptionI18n: expected {zh,en} string` };
31
+ }
32
+ const parameters = v['parameters'];
33
+ if (!isJsonSchema(parameters)) {
34
+ return { ok: false, errorText: `Invalid ${at}.parameters: expected JSON schema object` };
35
+ }
36
+ return {
37
+ ok: true,
38
+ tool: {
39
+ name,
40
+ description,
41
+ descriptionI18n: descriptionI18n,
42
+ parameters,
43
+ },
44
+ };
45
+ }
46
+ function parseToolsetJson(v, at) {
47
+ if (!isRecord(v))
48
+ return { ok: false, errorText: `Invalid ${at}: expected object` };
49
+ const id = asString(v['id']);
50
+ if (!id || id.trim() === '')
51
+ return { ok: false, errorText: `Invalid ${at}.id: required` };
52
+ const descriptionI18n = v['descriptionI18n'];
53
+ if (descriptionI18n !== undefined && !isI18nText(descriptionI18n)) {
54
+ return { ok: false, errorText: `Invalid ${at}.descriptionI18n: expected {zh,en} string` };
55
+ }
56
+ const toolsRaw = v['tools'];
57
+ if (!Array.isArray(toolsRaw))
58
+ return { ok: false, errorText: `Invalid ${at}.tools: expected array` };
59
+ const tools = [];
60
+ for (let i = 0; i < toolsRaw.length; i += 1) {
61
+ const parsed = parseToolJson(toolsRaw[i], `${at}.tools[${i}]`);
62
+ if (!parsed.ok)
63
+ return parsed;
64
+ tools.push(parsed.tool);
65
+ }
66
+ return {
67
+ ok: true,
68
+ toolset: {
69
+ id,
70
+ descriptionI18n: descriptionI18n,
71
+ tools,
72
+ },
73
+ };
74
+ }
75
+ function parseDialogRunControlJson(v, at) {
76
+ if (!isRecord(v))
77
+ return { ok: false, errorText: `Invalid ${at}: expected object` };
78
+ const id = asString(v['id']);
79
+ if (!id || id.trim() === '')
80
+ return { ok: false, errorText: `Invalid ${at}.id: required` };
81
+ const descriptionI18n = v['descriptionI18n'];
82
+ if (descriptionI18n !== undefined && !isI18nText(descriptionI18n)) {
83
+ return { ok: false, errorText: `Invalid ${at}.descriptionI18n: expected {zh,en} string` };
84
+ }
85
+ return {
86
+ ok: true,
87
+ control: {
88
+ id,
89
+ descriptionI18n: descriptionI18n,
90
+ },
91
+ };
92
+ }
93
+ function parseReminderOwnerJson(v, at) {
94
+ if (!isRecord(v))
95
+ return { ok: false, errorText: `Invalid ${at}: expected object` };
96
+ const ref = asString(v['ref']);
97
+ if (!ref || ref.trim() === '')
98
+ return { ok: false, errorText: `Invalid ${at}.ref: required` };
99
+ const managedByTool = asString(v['managedByTool']) ?? undefined;
100
+ const updateExample = asString(v['updateExample']) ?? undefined;
101
+ return {
102
+ ok: true,
103
+ owner: { ref, managedByTool, updateExample },
104
+ };
105
+ }
106
+ function parseDomindsAppInstallJson(v) {
107
+ if (!isRecord(v)) {
108
+ return { ok: false, errorText: 'Invalid app --dominds-app output: expected object' };
109
+ }
110
+ const schemaVersion = v['schemaVersion'];
111
+ if (schemaVersion !== 1) {
112
+ return { ok: false, errorText: `Unsupported app json schemaVersion: ${String(schemaVersion)}` };
113
+ }
114
+ const appId = asString(v['appId']);
115
+ if (!appId || appId.trim() === '')
116
+ return { ok: false, errorText: 'Invalid app json: appId required' };
117
+ const displayName = asString(v['displayName']) ?? undefined;
118
+ const pkg = v['package'];
119
+ if (!isRecord(pkg))
120
+ return { ok: false, errorText: 'Invalid app json: package must be an object' };
121
+ const packageName = asString(pkg['name']);
122
+ const packageVersion = asNullableString(pkg['version']);
123
+ const rootAbs = asString(pkg['rootAbs']);
124
+ if (!packageName || packageName.trim() === '') {
125
+ return { ok: false, errorText: 'Invalid app json: package.name required' };
126
+ }
127
+ if (packageVersion !== null && (!packageVersion || packageVersion.trim() === '')) {
128
+ return { ok: false, errorText: 'Invalid app json: package.version must be string|null' };
129
+ }
130
+ if (!rootAbs || rootAbs.trim() === '') {
131
+ return { ok: false, errorText: 'Invalid app json: package.rootAbs required' };
132
+ }
133
+ const host = v['host'];
134
+ if (!isRecord(host))
135
+ return { ok: false, errorText: 'Invalid app json: host must be an object' };
136
+ const hostKind = asString(host['kind']);
137
+ if (hostKind !== 'node_module') {
138
+ return { ok: false, errorText: "Invalid app json: host.kind must be 'node_module'" };
139
+ }
140
+ const moduleRelPath = asString(host['moduleRelPath']);
141
+ const exportName = asString(host['exportName']);
142
+ if (!moduleRelPath || moduleRelPath.trim() === '') {
143
+ return { ok: false, errorText: 'Invalid app json: host.moduleRelPath required' };
144
+ }
145
+ if (!exportName || exportName.trim() === '') {
146
+ return { ok: false, errorText: 'Invalid app json: host.exportName required' };
147
+ }
148
+ const frontendRaw = v['frontend'];
149
+ let frontend;
150
+ if (frontendRaw !== undefined) {
151
+ if (!isRecord(frontendRaw))
152
+ return { ok: false, errorText: 'Invalid app json: frontend must be an object' };
153
+ const kind = asString(frontendRaw['kind']);
154
+ if (kind !== 'http')
155
+ return { ok: false, errorText: "Invalid app json: frontend.kind must be 'http'" };
156
+ const defaultPortRaw = frontendRaw['defaultPort'];
157
+ const defaultPort = defaultPortRaw === undefined
158
+ ? undefined
159
+ : typeof defaultPortRaw === 'number' && Number.isFinite(defaultPortRaw)
160
+ ? Math.floor(defaultPortRaw)
161
+ : null;
162
+ if (defaultPort === null || (defaultPort !== undefined && defaultPort < 0)) {
163
+ return {
164
+ ok: false,
165
+ errorText: 'Invalid app json: frontend.defaultPort must be a non-negative number',
166
+ };
167
+ }
168
+ const basePath = asString(frontendRaw['basePath']) ?? undefined;
169
+ const wsPath = asString(frontendRaw['wsPath']) ?? undefined;
170
+ frontend = { kind: 'http', defaultPort, basePath, wsPath };
171
+ }
172
+ const contributesRaw = v['contributes'];
173
+ let contributes;
174
+ if (contributesRaw !== undefined) {
175
+ if (!isRecord(contributesRaw))
176
+ return { ok: false, errorText: 'Invalid app json: contributes must be an object' };
177
+ const teammatesYamlRelPath = asString(contributesRaw['teammatesYamlRelPath']) ?? undefined;
178
+ const toolsetsRaw = contributesRaw['toolsets'];
179
+ let toolsets;
180
+ if (toolsetsRaw !== undefined) {
181
+ if (!Array.isArray(toolsetsRaw)) {
182
+ return { ok: false, errorText: 'Invalid app json: contributes.toolsets must be an array' };
183
+ }
184
+ toolsets = [];
185
+ for (let i = 0; i < toolsetsRaw.length; i += 1) {
186
+ const parsed = parseToolsetJson(toolsetsRaw[i], `contributes.toolsets[${i}]`);
187
+ if (!parsed.ok)
188
+ return parsed;
189
+ toolsets.push(parsed.toolset);
190
+ }
191
+ }
192
+ const dialogRunControlsRaw = contributesRaw['dialogRunControls'];
193
+ let dialogRunControls;
194
+ if (dialogRunControlsRaw !== undefined) {
195
+ if (!Array.isArray(dialogRunControlsRaw)) {
196
+ return { ok: false, errorText: 'Invalid app json: contributes.dialogRunControls must be an array' };
197
+ }
198
+ dialogRunControls = [];
199
+ for (let i = 0; i < dialogRunControlsRaw.length; i += 1) {
200
+ const parsed = parseDialogRunControlJson(dialogRunControlsRaw[i], `contributes.dialogRunControls[${i}]`);
201
+ if (!parsed.ok)
202
+ return parsed;
203
+ dialogRunControls.push(parsed.control);
204
+ }
205
+ }
206
+ const reminderOwnersRaw = contributesRaw['reminderOwners'];
207
+ let reminderOwners;
208
+ if (reminderOwnersRaw !== undefined) {
209
+ if (!Array.isArray(reminderOwnersRaw)) {
210
+ return { ok: false, errorText: 'Invalid app json: contributes.reminderOwners must be an array' };
211
+ }
212
+ reminderOwners = [];
213
+ for (let i = 0; i < reminderOwnersRaw.length; i += 1) {
214
+ const parsed = parseReminderOwnerJson(reminderOwnersRaw[i], `contributes.reminderOwners[${i}]`);
215
+ if (!parsed.ok)
216
+ return parsed;
217
+ reminderOwners.push(parsed.owner);
218
+ }
219
+ }
220
+ contributes = { teammatesYamlRelPath, toolsets, dialogRunControls, reminderOwners };
221
+ }
222
+ return {
223
+ ok: true,
224
+ json: {
225
+ schemaVersion: 1,
226
+ appId,
227
+ displayName,
228
+ package: { name: packageName, version: packageVersion, rootAbs },
229
+ host: { kind: 'node_module', moduleRelPath, exportName },
230
+ frontend,
231
+ contributes,
232
+ },
233
+ };
234
+ }
@@ -0,0 +1,3 @@
1
+ import type { LanguageCode } from './types/language';
2
+ export declare const DEFAULT_DILIGENCE_PUSH_MAX = 3;
3
+ export declare const DILIGENCE_FALLBACK_TEXT: Readonly<Record<LanguageCode, string>>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DILIGENCE_FALLBACK_TEXT = exports.DEFAULT_DILIGENCE_PUSH_MAX = void 0;
4
+ exports.DEFAULT_DILIGENCE_PUSH_MAX = 3;
5
+ exports.DILIGENCE_FALLBACK_TEXT = {
6
+ zh: [
7
+ '你扪心自问(做一次 FBR),差遣牒已经包含足够明确的目标定义了吗?',
8
+ '',
9
+ '如果没有,使用 `askHuman` 请求人类给出足够清晰的目标。',
10
+ '',
11
+ '如果目标已经清晰定义,那么你已经完成了所有目标吗?',
12
+ '',
13
+ '如果已经完成,使用 `askHuman` 请求人类验收。',
14
+ '',
15
+ '如果尚未完成,优先直接确定并执行下一步最优行动项(调用工具或诉请队友)。仅当“下一步不清晰/难以决策”时,才发起一次 freshBootsReasoning 扪心自问(FBR);收齐该次回贴后,立即把结论落地为可执行动作并开始执行,不要只汇报决定。',
16
+ '',
17
+ '当你确信自己不该或者不能自主继续工作时,立即使用 `askHuman` 请求人类确认相关问题或者指出工作方向。',
18
+ '',
19
+ '---',
20
+ '',
21
+ '**注意**:',
22
+ '',
23
+ '扪心自问时,自诉请正文需要包含对当前状况的完整事实性总结(但不要包含差遣牒已有内容);发起 freshBootsReasoning 后不要立即下最终行动决策,先等回贴再综合。综合完成后必须立刻执行已确定行动(工具调用/诉请队友),避免停留在“仅汇报决定”的状态。',
24
+ '',
25
+ '队友如果回复 “将要/可以” 做 XXX 的,你要审视祂所说是否符合整体/分项任务目标,是否值得继续:',
26
+ '- 如果祂建议的事情可做可不做,那么就可以忽略,不以琐碎小事安排工作。',
27
+ '- 如果值得继续,你可加以纠正或鼓励,并立即诉请其继续,不要留祂停在那里等待指令,这是不可接受的。',
28
+ '',
29
+ '系统会在首次出现“尚未收到反馈、仍在执行中的诉请”时自动添加提醒项,并在状态变化时自动刷新;诉请全部结束后不会自动删除该提醒项。',
30
+ '',
31
+ '当该提醒项明确写出“当前没有任何执行中的诉请、没有其祂智能体在后台工作”时,任何“继续等待”的想法和行为都是错误的;如果你已经明确知晓这点,可手动删除该提醒项以免碍眼。',
32
+ '',
33
+ '同理,若不存在“⏳ 进行中诉请(共 N 路,自动添加,手动删除)”这类提醒项,或某条历史诉请未出现在该提醒项中,都表示当前没有可等待的进行中诉请(通常代表该轮已回贴或已结束);“继续等待”是错误动作,必须立即执行下一步:本地动作,或使用同一个 `sessionSlug` 再次调用 `tellask` 向对应队友发起下一轮诉请。',
34
+ ].join('\n'),
35
+ en: [
36
+ 'Do a self-check (run one FBR): does the Taskdoc already contain a sufficiently clear goal definition?',
37
+ '',
38
+ 'If not, use `askHuman` to request a sufficiently clear goal.',
39
+ '',
40
+ 'If the goal is already clearly defined, ask: have you completed all goals?',
41
+ '',
42
+ 'If yes, use `askHuman` to request acceptance.',
43
+ '',
44
+ 'If not complete, first determine and execute the best next action (tool call or teammate tellask). Use freshBootsReasoning for FBR only when the next move is unclear or hard to decide; after feedback from that FBR run is collected, immediately turn the conclusion into executable action and start execution. Do not stop at reporting a decision.',
45
+ '',
46
+ 'When you are convinced you should not or cannot continue autonomously, immediately use `askHuman` to confirm the relevant issue or provide direction.',
47
+ '',
48
+ '---',
49
+ '',
50
+ '**Notes**:',
51
+ '',
52
+ 'When running FBR, the FBR body must include a complete factual summary of the current situation (but do not repeat information already present in the Taskdoc). After initiating a freshBootsReasoning, do not finalize the next action immediately; wait for feedback first, then synthesize. Once synthesized, immediately execute the chosen action (tool call / teammate tellask), and avoid staying in a “decision report only” state.',
53
+ '',
54
+ 'If a teammate replies that they “will/can do X”, examine whether it aligns with the overall/sub-task goals and is worth continuing:',
55
+ '- If it is optional and low impact, ignore it instead of assigning trivial work.',
56
+ '- If it is worth continuing, correct or encourage as needed and immediately tellask them to continue; leaving them idle and waiting for instructions is unacceptable.',
57
+ '',
58
+ 'The system auto-adds this reminder when still-running Tellasks first appear and auto-refreshes it as status changes; after all Tellasks finish, it is not auto-deleted.',
59
+ '',
60
+ 'When this reminder explicitly says there are no in-flight Tellasks and no agents working in the background, any “keep waiting” thought or behavior is wrong; if you clearly know this, manually delete the reminder to reduce noise.',
61
+ '',
62
+ 'Likewise, if a “⏳ In-flight Tellasks (N total, auto-added, manually deleted)” reminder is absent, or a historical Tellask is not listed in that reminder, there is no waitable in-flight Tellask for it at the moment (usually the previous round has replied or ended). “Keep waiting” is a wrong action; execute the next step immediately: local action, or launch a new Tellask round to the same teammate via `tellask` with the same `sessionSlug`.',
63
+ ].join('\n'),
64
+ };
package/dist/evt.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Event processing constructs equivalent to Edh's:
3
+ * - PubChan: write-only broadcast channel
4
+ * - SubChan: read-only subscriber channel
5
+ * - EventSink: event source with sequence and most-recent value, streaming support
6
+ *
7
+ * Notes:
8
+ * - PubChan behaves like a broadcast channel: if there is no SubChan reading, writes are effectively dropped
9
+ * - SubChan buffers unboundedly relative to its own consumption speed
10
+ * - EndOfStream sentinel signals termination of streams
11
+ */
12
+ export declare const EndOfStream: unique symbol;
13
+ export type EOS = typeof EndOfStream;
14
+ type NodeValue<T> = readonly [value: T | EOS, next: Promise<NodeValue<T>>];
15
+ export declare class PubChan<T> {
16
+ private nxt;
17
+ write(ev: T | EOS): void;
18
+ get nextPromise(): Promise<NodeValue<T>>;
19
+ }
20
+ export declare class SubChan<T> {
21
+ private nxtP;
22
+ readonly cancelled: Promise<void>;
23
+ readonly cancel: () => void;
24
+ constructor(pub: PubChan<T>);
25
+ read(): Promise<T | EOS>;
26
+ stream(): AsyncGenerator<T, void, void>;
27
+ }
28
+ export declare class EventSink<T> {
29
+ private seqn;
30
+ private mrv;
31
+ private readonly chan;
32
+ get eos(): boolean;
33
+ publish(ev: T | EOS): void;
34
+ one_more(): Promise<T | EOS>;
35
+ stream(): AsyncGenerator<T, void, void>;
36
+ }
37
+ export declare function createPubChan<T>(): PubChan<T>;
38
+ export declare function createSubChan<T>(pub: PubChan<T>): SubChan<T>;
39
+ export declare function createEventSink<T>(): EventSink<T>;
40
+ export {};