@agimon-ai/po-computer-use 0.0.0-alpha.2 → 0.0.0-alpha.21

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.
@@ -1,16 +1,16 @@
1
1
  import { a as COMMAND_NAME, i as COMMAND_DESCRIPTION, n as ComputerScriptExecutionError, r as ComputerScriptRunner, t as DefaultComputerUseExtensionService } from "../extensionService-DXvF7esO.mjs";
2
2
  import path from "node:path";
3
- import { composeServerProviderOverrides, defineServerPlugin } from "@agimon-ai/po-core/serverFacet";
4
- import { composeRootHooks, defineChannel, defineRoot, defineRoutedContribution } from "@agimon-ai/po-core/extensionFile";
3
+ import { composeServerProviderOverrides, defineServerPlugin } from "@agimon-ai/po-core/serverPlugin";
4
+ import { composeRootHooks, composeRootInjects, defineChannel, defineRoot, defineRoutedContribution, runCleanups } from "@agimon-ai/po-core/extensionFile";
5
5
  import { defineMinorMode, serverMinorModes } from "@agimon-ai/po-minor-mode";
6
6
  import { randomUUID } from "node:crypto";
7
- import { doomApiCallerFrom } from "@agimon-ai/po-core/packageApi";
7
+ import { poApiCallerFrom } from "@agimon-ai/po-core/packageApi";
8
8
  import { apiResponse, defineApiRoutes } from "@agimon-ai/po-core/web";
9
9
  //#region src/types/computerUseApi.ts
10
10
  const API_BASE_PATH = "computer-use";
11
11
  const computerUseChannelType = "computer_use_state";
12
12
  const COMPUTER_USE_MODE_ID = "computer-use";
13
- const COMPUTER_USE_STATUS_KEY = "doom-computer-use";
13
+ const COMPUTER_USE_STATUS_KEY = "po-computer-use";
14
14
  const COMPUTER_USE_CONFIRMATION_WINDOW_MS = 12e4;
15
15
  /**
16
16
  * Every path this API answers on, below its mount.
@@ -36,7 +36,7 @@ const COMPUTER_USE_ROUTES = {
36
36
  const COMPUTER_USE_WAKE_LIMIT = 1e6;
37
37
  //#endregion
38
38
  //#region src/services/mcpTools/index.ts
39
- const COMPUTER_USE_MCP_TOOLS_SERVICE = "doom/computer-use-mcp-tools";
39
+ const COMPUTER_USE_MCP_TOOLS_SERVICE = "po/computer-use-mcp-tools";
40
40
  function mountMcpTools(tools) {
41
41
  return (context) => {
42
42
  context.plugin((providerContext) => {
@@ -411,7 +411,7 @@ var ComputerUseRequestBroker = class ComputerUseRequestBroker {
411
411
  async requestActivation(request) {
412
412
  if (!this.desktop?.available || !(this.desktop.authorizeActivation?.(request.headers) ?? this.desktop.authorize(request.headers))) return jsonError("Not found.", 404);
413
413
  if (this.desktop.enabled === false) return jsonError("Enable computer use in global Desktop settings first.", 409);
414
- const stamped = doomApiCallerFrom(request.headers);
414
+ const stamped = poApiCallerFrom(request.headers);
415
415
  const caller = stamped?.locality === "remote" ? stamped : {
416
416
  locality: "local",
417
417
  stepUp: "not-required"
@@ -985,13 +985,18 @@ function createComputerUseServer(host, apiContext) {
985
985
  if (client && state?.phase !== "inactive" && state?.phase !== "failed") await client.stop();
986
986
  }
987
987
  }],
988
- onDispose() {
989
- stopActivity?.();
990
- stopActivity = void 0;
991
- unsubscribeState?.();
992
- broker.close();
993
- restrictionListeners.clear();
994
- host.context.client.setStatus(COMPUTER_USE_STATUS_KEY, void 0);
988
+ async onDispose() {
989
+ await runCleanups([
990
+ () => {
991
+ const stop = stopActivity;
992
+ stopActivity = void 0;
993
+ stop?.();
994
+ },
995
+ () => unsubscribeState?.(),
996
+ () => broker.close(),
997
+ () => restrictionListeners.clear(),
998
+ () => host.context.client.setStatus(COMPUTER_USE_STATUS_KEY, void 0)
999
+ ], "Computer-use cleanup failed.");
995
1000
  }
996
1001
  };
997
1002
  }
@@ -1336,17 +1341,18 @@ const via = (identity, value) => value === void 0 ? void 0 : {
1336
1341
  ...identity,
1337
1342
  ...value
1338
1343
  };
1339
- const facet = defineServerPlugin({
1344
+ const serverPlugin = defineServerPlugin({
1340
1345
  name: "@agimon-ai/po-computer-use",
1341
1346
  providerOverrides: composeServerProviderOverrides(root_server_default),
1347
+ injects: composeRootInjects({ session: [root_server_default] }),
1342
1348
  global: () => ({ get channels() {
1343
1349
  return [() => via({ frameType: "computer_use" }, computer_use_server_default$2())];
1344
1350
  } }),
1345
- workspace: () => ({ get channels() {
1346
- return [() => via({ frameType: "computer_use" }, computer_use_server_default$2())];
1351
+ workspace: (context) => ({ get channels() {
1352
+ return defined([context.hosted("global") ? void 0 : () => via({ frameType: "computer_use" }, computer_use_server_default$2())]);
1347
1353
  } }),
1348
1354
  session: async (context) => {
1349
- const scopeSession = await root_server_default(context);
1355
+ const scopeSession = await context.scopeRoot("session", root_server_default, context);
1350
1356
  const contextSession = {
1351
1357
  ...context,
1352
1358
  root: scopeSession.value
@@ -1357,7 +1363,7 @@ const facet = defineServerPlugin({
1357
1363
  return defined([at(route_server_default, contextSession)]);
1358
1364
  },
1359
1365
  get channels() {
1360
- return [() => via({ frameType: "computer_use" }, computer_use_server_default$2())];
1366
+ return defined([context.hosted("global") ? void 0 : () => via({ frameType: "computer_use" }, computer_use_server_default$2())]);
1361
1367
  },
1362
1368
  get commands() {
1363
1369
  return defined([via({ name: "computer-use" }, at(computer_use_server_default$1, contextSession))]);
@@ -1383,6 +1389,6 @@ const facet = defineServerPlugin({
1383
1389
  }
1384
1390
  });
1385
1391
  //#endregion
1386
- export { facet as default, facet };
1392
+ export { serverPlugin as default, serverPlugin };
1387
1393
 
1388
1394
  //# sourceMappingURL=server.mjs.map