dominds 1.6.1 → 1.6.3

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.
@@ -12,6 +12,6 @@ async function applyAppDialogRunControl(params) {
12
12
  if (!meta) {
13
13
  throw new Error(`Unknown dialog run control: ${controlId}`);
14
14
  }
15
- const hostClient = (0, runtime_1.getAppsHostClient)();
15
+ const hostClient = await (0, runtime_1.waitForAppsHostClient)();
16
16
  return await hostClient.applyRunControl(controlId, params.payload);
17
17
  }
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getAppsHostClient = getAppsHostClient;
7
+ exports.waitForAppsHostClient = waitForAppsHostClient;
7
8
  exports.shutdownAppsRuntime = shutdownAppsRuntime;
8
9
  exports.registerEnabledAppsToolProxies = registerEnabledAppsToolProxies;
9
10
  exports.listDynamicAppToolsetsForMember = listDynamicAppToolsetsForMember;
@@ -23,6 +24,7 @@ const enabled_apps_1 = require("./enabled-apps");
23
24
  const problems_1 = require("./problems");
24
25
  const log = (0, log_1.createLogger)('apps-runtime');
25
26
  let appsHostClient = null;
27
+ let appsHostTransition = null;
26
28
  let hostedAppsSignature = null;
27
29
  let appsRuntimeConfig = null;
28
30
  let refreshQueue = Promise.resolve();
@@ -129,7 +131,7 @@ async function applyDialogReminderRequestBatches(sourceDlg, appId, dialogReminde
129
131
  await (0, app_reminders_1.applyAppReminderRequests)(targetDlg, {
130
132
  appId,
131
133
  reminderRequests: batch.reminderRequests,
132
- resolveHostClient: getAppsHostClient,
134
+ resolveHostClient: waitForAppsHostClient,
133
135
  });
134
136
  }
135
137
  }
@@ -139,6 +141,15 @@ function getAppsHostClient() {
139
141
  }
140
142
  return appsHostClient;
141
143
  }
144
+ async function waitForAppsHostClient() {
145
+ if (appsHostClient) {
146
+ return appsHostClient;
147
+ }
148
+ if (appsHostTransition) {
149
+ return await appsHostTransition;
150
+ }
151
+ throw new Error('Apps host is not initialized');
152
+ }
142
153
  async function stopAppsHost() {
143
154
  const client = appsHostClient;
144
155
  if (!client)
@@ -149,6 +160,17 @@ async function stopAppsHost() {
149
160
  }
150
161
  async function shutdownAppsRuntime() {
151
162
  await stopAppsHost();
163
+ const transition = appsHostTransition;
164
+ if (!transition) {
165
+ return;
166
+ }
167
+ const client = await transition;
168
+ if (appsHostClient !== client) {
169
+ return;
170
+ }
171
+ appsHostClient = null;
172
+ hostedAppsSignature = null;
173
+ await client.shutdown();
152
174
  }
153
175
  function ensureNoDuplicateTool(toolName, appId) {
154
176
  const existing = (0, registry_1.getTool)(toolName);
@@ -232,7 +254,7 @@ async function ensureAppsHostReadyForToolCalls() {
232
254
  if (config) {
233
255
  await registerEnabledAppsToolProxies({ rtwsRootAbs: config.rtwsRootAbs });
234
256
  }
235
- return getAppsHostClient();
257
+ return await waitForAppsHostClient();
236
258
  }
237
259
  function registerAppArtifacts(app) {
238
260
  const toolNames = [];
@@ -260,7 +282,7 @@ function registerAppArtifacts(app) {
260
282
  await (0, app_reminders_1.applyAppReminderRequests)(dlg, {
261
283
  appId: app.appId,
262
284
  reminderRequests: result.reminderRequests,
263
- resolveHostClient: getAppsHostClient,
285
+ resolveHostClient: waitForAppsHostClient,
264
286
  });
265
287
  }
266
288
  if (Array.isArray(result.dialogReminderRequests) &&
@@ -290,7 +312,7 @@ function registerAppArtifacts(app) {
290
312
  }
291
313
  (0, app_reminders_1.ensureAppReminderOwnersRegistered)({
292
314
  enabledApps: [app],
293
- resolveHostClient: getAppsHostClient,
315
+ resolveHostClient: waitForAppsHostClient,
294
316
  });
295
317
  registeredAppArtifactsById.set(app.appId, {
296
318
  signature: computeAppSignature(app),
@@ -331,15 +353,27 @@ async function syncAppsHostToEnabledApps(params) {
331
353
  if (appsHostClient && hostedAppsSignature === nextSignature) {
332
354
  return;
333
355
  }
334
- await stopAppsHost();
335
356
  log.info(`Starting apps-host (${params.enabledApps.length} enabled apps)`);
336
- const { client } = await (0, client_1.startAppsHost)({
337
- rtwsRootAbs: config.rtwsRootAbs,
338
- kernel: config.kernel,
339
- apps: params.enabledApps,
340
- });
341
- appsHostClient = client;
342
- hostedAppsSignature = nextSignature;
357
+ const transition = (async () => {
358
+ await stopAppsHost();
359
+ const { client } = await (0, client_1.startAppsHost)({
360
+ rtwsRootAbs: config.rtwsRootAbs,
361
+ kernel: config.kernel,
362
+ apps: params.enabledApps,
363
+ });
364
+ return client;
365
+ })();
366
+ appsHostTransition = transition;
367
+ try {
368
+ const client = await transition;
369
+ appsHostClient = client;
370
+ hostedAppsSignature = nextSignature;
371
+ }
372
+ finally {
373
+ if (appsHostTransition === transition) {
374
+ appsHostTransition = null;
375
+ }
376
+ }
343
377
  }
344
378
  async function refreshEnabledAppsRuntimeNow(params) {
345
379
  const snapshot = await (0, enabled_apps_1.loadEnabledAppsSnapshot)({ rtwsRootAbs: params.rtwsRootAbs });
@@ -368,6 +402,12 @@ async function registerEnabledAppsToolProxies(params) {
368
402
  }
369
403
  async function listDynamicAppToolsetsForMember(_params) {
370
404
  await registerEnabledAppsToolProxies({ rtwsRootAbs: _params.rtwsRootAbs });
405
+ if (!appsRuntimeConfig && !appsHostClient && !appsHostTransition) {
406
+ return [];
407
+ }
408
+ if (!appsHostClient && !appsHostTransition) {
409
+ return [];
410
+ }
371
411
  const host = await ensureAppsHostReadyForToolCalls();
372
412
  return await host.listDynamicToolsets({
373
413
  memberId: _params.memberId,
@@ -1,4 +1,4 @@
1
- # App Constitution(Kernel–App 分离:App 概念与机制,草案)
1
+ # App 建制(Kernel–App 分离:App 概念与机制,草案)
2
2
 
3
3
  英文版:[English](./app-constitution.md)
4
4
 
@@ -156,7 +156,7 @@ function createAppReminderOwner(params) {
156
156
  return { treatment: 'keep' };
157
157
  }
158
158
  try {
159
- const client = resolveHostClient();
159
+ const client = await resolveHostClient();
160
160
  const result = await client.updateReminder(descriptor.appId, descriptor.ownerRef, {
161
161
  dialogId: dlg.id.selfId,
162
162
  reminder: toReminderState(reminder),
@@ -181,7 +181,7 @@ function createAppReminderOwner(params) {
181
181
  return fallbackRenderedReminder(reminder, index + 1);
182
182
  }
183
183
  try {
184
- const client = resolveHostClient();
184
+ const client = await resolveHostClient();
185
185
  return await client.renderReminder(descriptor.appId, descriptor.ownerRef, {
186
186
  dialogId: dlg.id.selfId,
187
187
  reminder: toReminderState(reminder),
@@ -228,7 +228,7 @@ function unregisterAppReminderOwnersForApps(params) {
228
228
  }
229
229
  }
230
230
  async function applyAppReminderRequests(dlg, params) {
231
- const client = params.resolveHostClient();
231
+ const client = await params.resolveHostClient();
232
232
  let changed = false;
233
233
  for (const request of params.reminderRequests) {
234
234
  const registryName = buildAppReminderOwnerRegistryName(params.appId, request.ownerRef);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dominds",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "DevOps Mindsets — Sustainable Agentic Product Lifecycle",
5
5
  "type": "commonjs",
6
6
  "private": false,