@agents-tower/core 0.1.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 (178) hide show
  1. package/dist/adapters/claude.d.ts +2 -0
  2. package/dist/adapters/claude.js +43 -0
  3. package/dist/adapters/claude.js.map +1 -0
  4. package/dist/adapters/codex-cloud.d.ts +4 -0
  5. package/dist/adapters/codex-cloud.js +80 -0
  6. package/dist/adapters/codex-cloud.js.map +1 -0
  7. package/dist/adapters/codex-local.d.ts +17 -0
  8. package/dist/adapters/codex-local.js +180 -0
  9. package/dist/adapters/codex-local.js.map +1 -0
  10. package/dist/adapters/cursor-cloud.d.ts +2 -0
  11. package/dist/adapters/cursor-cloud.js +54 -0
  12. package/dist/adapters/cursor-cloud.js.map +1 -0
  13. package/dist/adapters/cursor-local.d.ts +2 -0
  14. package/dist/adapters/cursor-local.js +37 -0
  15. package/dist/adapters/cursor-local.js.map +1 -0
  16. package/dist/adapters/helpers.d.ts +15 -0
  17. package/dist/adapters/helpers.js +33 -0
  18. package/dist/adapters/helpers.js.map +1 -0
  19. package/dist/adapters/hermes.d.ts +2 -0
  20. package/dist/adapters/hermes.js +41 -0
  21. package/dist/adapters/hermes.js.map +1 -0
  22. package/dist/adapters/index.d.ts +2 -0
  23. package/dist/adapters/index.js +37 -0
  24. package/dist/adapters/index.js.map +1 -0
  25. package/dist/adapters/openclaw.d.ts +2 -0
  26. package/dist/adapters/openclaw.js +41 -0
  27. package/dist/adapters/openclaw.js.map +1 -0
  28. package/dist/adapters/presence.d.ts +2 -0
  29. package/dist/adapters/presence.js +36 -0
  30. package/dist/adapters/presence.js.map +1 -0
  31. package/dist/adapters/static-source.d.ts +15 -0
  32. package/dist/adapters/static-source.js +41 -0
  33. package/dist/adapters/static-source.js.map +1 -0
  34. package/dist/adapters/types.d.ts +44 -0
  35. package/dist/adapters/types.js +3 -0
  36. package/dist/adapters/types.js.map +1 -0
  37. package/dist/app-server.d.ts +94 -0
  38. package/dist/app-server.js +382 -0
  39. package/dist/app-server.js.map +1 -0
  40. package/dist/app-settings.d.ts +52 -0
  41. package/dist/app-settings.js +268 -0
  42. package/dist/app-settings.js.map +1 -0
  43. package/dist/appearance.d.ts +6 -0
  44. package/dist/appearance.js +84 -0
  45. package/dist/appearance.js.map +1 -0
  46. package/dist/aseprite.d.ts +4 -0
  47. package/dist/aseprite.js +42 -0
  48. package/dist/aseprite.js.map +1 -0
  49. package/dist/claude-agent-sdk.d.ts +44 -0
  50. package/dist/claude-agent-sdk.js +347 -0
  51. package/dist/claude-agent-sdk.js.map +1 -0
  52. package/dist/claude-home-cache.d.ts +61 -0
  53. package/dist/claude-home-cache.js +438 -0
  54. package/dist/claude-home-cache.js.map +1 -0
  55. package/dist/claude.d.ts +154 -0
  56. package/dist/claude.js +3495 -0
  57. package/dist/claude.js.map +1 -0
  58. package/dist/cloud.d.ts +2 -0
  59. package/dist/cloud.js +25 -0
  60. package/dist/cloud.js.map +1 -0
  61. package/dist/codex-command.d.ts +25 -0
  62. package/dist/codex-command.js +235 -0
  63. package/dist/codex-command.js.map +1 -0
  64. package/dist/codex-session-files.d.ts +8 -0
  65. package/dist/codex-session-files.js +509 -0
  66. package/dist/codex-session-files.js.map +1 -0
  67. package/dist/codex-thread-query.d.ts +14 -0
  68. package/dist/codex-thread-query.js +82 -0
  69. package/dist/codex-thread-query.js.map +1 -0
  70. package/dist/cursor-cloud-data.d.ts +34 -0
  71. package/dist/cursor-cloud-data.js +344 -0
  72. package/dist/cursor-cloud-data.js.map +1 -0
  73. package/dist/cursor-lib/local-discovery.d.ts +17 -0
  74. package/dist/cursor-lib/local-discovery.js +251 -0
  75. package/dist/cursor-lib/local-discovery.js.map +1 -0
  76. package/dist/cursor-lib/shared.d.ts +5 -0
  77. package/dist/cursor-lib/shared.js +88 -0
  78. package/dist/cursor-lib/shared.js.map +1 -0
  79. package/dist/cursor.d.ts +8 -0
  80. package/dist/cursor.js +1584 -0
  81. package/dist/cursor.js.map +1 -0
  82. package/dist/domain/codex-turn-semantics.d.ts +4 -0
  83. package/dist/domain/codex-turn-semantics.js +49 -0
  84. package/dist/domain/codex-turn-semantics.js.map +1 -0
  85. package/dist/domain/workload-policy.d.ts +8 -0
  86. package/dist/domain/workload-policy.js +268 -0
  87. package/dist/domain/workload-policy.js.map +1 -0
  88. package/dist/domain/workspace-activity.d.ts +10 -0
  89. package/dist/domain/workspace-activity.js +372 -0
  90. package/dist/domain/workspace-activity.js.map +1 -0
  91. package/dist/goal.d.ts +11 -0
  92. package/dist/goal.js +76 -0
  93. package/dist/goal.js.map +1 -0
  94. package/dist/hermes-hook-install.d.ts +12 -0
  95. package/dist/hermes-hook-install.js +335 -0
  96. package/dist/hermes-hook-install.js.map +1 -0
  97. package/dist/hermes.d.ts +97 -0
  98. package/dist/hermes.js +2446 -0
  99. package/dist/hermes.js.map +1 -0
  100. package/dist/index.d.ts +28 -0
  101. package/dist/index.js +47 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/live-monitor-lib/events.d.ts +43 -0
  104. package/dist/live-monitor-lib/events.js +1463 -0
  105. package/dist/live-monitor-lib/events.js.map +1 -0
  106. package/dist/live-monitor-lib/rollout-hooks.d.ts +13 -0
  107. package/dist/live-monitor-lib/rollout-hooks.js +253 -0
  108. package/dist/live-monitor-lib/rollout-hooks.js.map +1 -0
  109. package/dist/live-monitor.d.ts +102 -0
  110. package/dist/live-monitor.js +1461 -0
  111. package/dist/live-monitor.js.map +1 -0
  112. package/dist/local-thread-selection.d.ts +2 -0
  113. package/dist/local-thread-selection.js +58 -0
  114. package/dist/local-thread-selection.js.map +1 -0
  115. package/dist/openclaw.d.ts +41 -0
  116. package/dist/openclaw.js +715 -0
  117. package/dist/openclaw.js.map +1 -0
  118. package/dist/presence.d.ts +9 -0
  119. package/dist/presence.js +108 -0
  120. package/dist/presence.js.map +1 -0
  121. package/dist/project-identity.d.ts +7 -0
  122. package/dist/project-identity.js +162 -0
  123. package/dist/project-identity.js.map +1 -0
  124. package/dist/project-paths.d.ts +23 -0
  125. package/dist/project-paths.js +394 -0
  126. package/dist/project-paths.js.map +1 -0
  127. package/dist/project-storage.d.ts +7 -0
  128. package/dist/project-storage.js +79 -0
  129. package/dist/project-storage.js.map +1 -0
  130. package/dist/room-config.d.ts +21 -0
  131. package/dist/room-config.js +230 -0
  132. package/dist/room-config.js.map +1 -0
  133. package/dist/services/project-discovery.d.ts +1 -0
  134. package/dist/services/project-discovery.js +16 -0
  135. package/dist/services/project-discovery.js.map +1 -0
  136. package/dist/services/project-live-monitor.d.ts +1 -0
  137. package/dist/services/project-live-monitor.js +6 -0
  138. package/dist/services/project-live-monitor.js.map +1 -0
  139. package/dist/services/project-snapshot-coordinator.d.ts +49 -0
  140. package/dist/services/project-snapshot-coordinator.js +152 -0
  141. package/dist/services/project-snapshot-coordinator.js.map +1 -0
  142. package/dist/services/refresh-scheduler.d.ts +8 -0
  143. package/dist/services/refresh-scheduler.js +44 -0
  144. package/dist/services/refresh-scheduler.js.map +1 -0
  145. package/dist/services/snapshot-assembler.d.ts +8 -0
  146. package/dist/services/snapshot-assembler.js +167 -0
  147. package/dist/services/snapshot-assembler.js.map +1 -0
  148. package/dist/services/thread-store.d.ts +4 -0
  149. package/dist/services/thread-store.js +8 -0
  150. package/dist/services/thread-store.js.map +1 -0
  151. package/dist/snapshot-lib/activity-summary.d.ts +3 -0
  152. package/dist/snapshot-lib/activity-summary.js +220 -0
  153. package/dist/snapshot-lib/activity-summary.js.map +1 -0
  154. package/dist/snapshot-lib/dashboard-builder.d.ts +21 -0
  155. package/dist/snapshot-lib/dashboard-builder.js +146 -0
  156. package/dist/snapshot-lib/dashboard-builder.js.map +1 -0
  157. package/dist/snapshot-lib/thread-summary.d.ts +27 -0
  158. package/dist/snapshot-lib/thread-summary.js +953 -0
  159. package/dist/snapshot-lib/thread-summary.js.map +1 -0
  160. package/dist/snapshot.d.ts +2 -0
  161. package/dist/snapshot.js +21 -0
  162. package/dist/snapshot.js.map +1 -0
  163. package/dist/types.d.ts +368 -0
  164. package/dist/types.js +3 -0
  165. package/dist/types.js.map +1 -0
  166. package/dist/utils/json.d.ts +4 -0
  167. package/dist/utils/json.js +29 -0
  168. package/dist/utils/json.js.map +1 -0
  169. package/dist/utils/text.d.ts +3 -0
  170. package/dist/utils/text.js +26 -0
  171. package/dist/utils/text.js.map +1 -0
  172. package/dist/web-search.d.ts +1 -0
  173. package/dist/web-search.js +52 -0
  174. package/dist/web-search.js.map +1 -0
  175. package/dist/workload.d.ts +1 -0
  176. package/dist/workload.js +12 -0
  177. package/dist/workload.js.map +1 -0
  178. package/package.json +19 -0
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openClawAdapter = void 0;
4
+ const openclaw_1 = require("../openclaw");
5
+ const helpers_1 = require("./helpers");
6
+ const static_source_1 = require("./static-source");
7
+ exports.openClawAdapter = {
8
+ id: "openclaw",
9
+ source: "openclaw",
10
+ capabilities: {
11
+ discoverProjects: true
12
+ },
13
+ discoverProjects(limit) {
14
+ return (0, openclaw_1.discoverOpenClawProjects)(limit);
15
+ },
16
+ createSource(context) {
17
+ return new static_source_1.StaticProjectSource(async () => {
18
+ const generatedAt = new Date().toISOString();
19
+ try {
20
+ const agents = await (0, openclaw_1.loadOpenClawAgents)(context.projectRoot);
21
+ return (0, helpers_1.emptyAdapterSnapshot)({
22
+ adapterId: "openclaw",
23
+ source: "openclaw",
24
+ agents,
25
+ generatedAt
26
+ });
27
+ }
28
+ catch (error) {
29
+ const message = error instanceof Error ? error.message : String(error);
30
+ return (0, helpers_1.emptyAdapterSnapshot)({
31
+ adapterId: "openclaw",
32
+ source: "openclaw",
33
+ generatedAt,
34
+ notes: [`OpenClaw gateway agents unavailable: ${message}`],
35
+ health: (0, helpers_1.degradedHealth)(message, generatedAt)
36
+ });
37
+ }
38
+ }, (0, helpers_1.emptyAdapterSnapshot)({ adapterId: "openclaw", source: "openclaw" }));
39
+ }
40
+ };
41
+ //# sourceMappingURL=openclaw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw.js","sourceRoot":"","sources":["../../src/adapters/openclaw.ts"],"names":[],"mappings":";;;AAAA,0CAA2E;AAE3E,uCAAiE;AACjE,mDAAsD;AAEzC,QAAA,eAAe,GAAmB;IAC7C,EAAE,EAAE,UAAU;IACd,MAAM,EAAE,UAAU;IAClB,YAAY,EAAE;QACZ,gBAAgB,EAAE,IAAI;KACvB;IACD,gBAAgB,CAAC,KAAK;QACpB,OAAO,IAAA,mCAAwB,EAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,YAAY,CAAC,OAAO;QAClB,OAAO,IAAI,mCAAmB,CAAC,KAAK,IAAI,EAAE;YACxC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAkB,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC7D,OAAO,IAAA,8BAAoB,EAAC;oBAC1B,SAAS,EAAE,UAAU;oBACrB,MAAM,EAAE,UAAU;oBAClB,MAAM;oBACN,WAAW;iBACZ,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,OAAO,IAAA,8BAAoB,EAAC;oBAC1B,SAAS,EAAE,UAAU;oBACrB,MAAM,EAAE,UAAU;oBAClB,WAAW;oBACX,KAAK,EAAE,CAAC,wCAAwC,OAAO,EAAE,CAAC;oBAC1D,MAAM,EAAE,IAAA,wBAAc,EAAC,OAAO,EAAE,WAAW,CAAC;iBAC7C,CAAC,CAAC;YACL,CAAC;QACH,CAAC,EAAE,IAAA,8BAAoB,EAAC,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ProjectAdapter } from "./types";
2
+ export declare const presenceAdapter: ProjectAdapter;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.presenceAdapter = void 0;
4
+ const presence_1 = require("../presence");
5
+ const helpers_1 = require("./helpers");
6
+ const static_source_1 = require("./static-source");
7
+ exports.presenceAdapter = {
8
+ id: "presence",
9
+ source: "presence",
10
+ capabilities: {},
11
+ createSource(context) {
12
+ return new static_source_1.StaticProjectSource(async () => {
13
+ const generatedAt = new Date().toISOString();
14
+ try {
15
+ const agents = await (0, presence_1.loadFreshPresenceAgents)(context.projectRoot);
16
+ return (0, helpers_1.emptyAdapterSnapshot)({
17
+ adapterId: "presence",
18
+ source: "presence",
19
+ agents,
20
+ generatedAt
21
+ });
22
+ }
23
+ catch (error) {
24
+ const message = error instanceof Error ? error.message : String(error);
25
+ return (0, helpers_1.emptyAdapterSnapshot)({
26
+ adapterId: "presence",
27
+ source: "presence",
28
+ generatedAt,
29
+ notes: [`Presence unavailable: ${message}`],
30
+ health: (0, helpers_1.degradedHealth)(message, generatedAt)
31
+ });
32
+ }
33
+ }, (0, helpers_1.emptyAdapterSnapshot)({ adapterId: "presence", source: "presence" }));
34
+ }
35
+ };
36
+ //# sourceMappingURL=presence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/adapters/presence.ts"],"names":[],"mappings":";;;AAAA,0CAAsD;AAEtD,uCAAiE;AACjE,mDAAsD;AAEzC,QAAA,eAAe,GAAmB;IAC7C,EAAE,EAAE,UAAU;IACd,MAAM,EAAE,UAAU;IAClB,YAAY,EAAE,EAAE;IAChB,YAAY,CAAC,OAAO;QAClB,OAAO,IAAI,mCAAmB,CAAC,KAAK,IAAI,EAAE;YACxC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAA,kCAAuB,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAClE,OAAO,IAAA,8BAAoB,EAAC;oBAC1B,SAAS,EAAE,UAAU;oBACrB,MAAM,EAAE,UAAU;oBAClB,MAAM;oBACN,WAAW;iBACZ,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,OAAO,IAAA,8BAAoB,EAAC;oBAC1B,SAAS,EAAE,UAAU;oBACrB,MAAM,EAAE,UAAU;oBAClB,WAAW;oBACX,KAAK,EAAE,CAAC,yBAAyB,OAAO,EAAE,CAAC;oBAC3C,MAAM,EAAE,IAAA,wBAAc,EAAC,OAAO,EAAE,WAAW,CAAC;iBAC7C,CAAC,CAAC;YACL,CAAC;QACH,CAAC,EAAE,IAAA,8BAAoB,EAAC,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;CACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { AdapterSnapshot, ProjectSource, AdapterRefreshReason } from "./types";
2
+ type SnapshotLoader = () => Promise<AdapterSnapshot>;
3
+ export declare class StaticProjectSource implements ProjectSource {
4
+ private readonly loadSnapshot;
5
+ private cachedSnapshot;
6
+ private readonly listeners;
7
+ private refreshGeneration;
8
+ constructor(loadSnapshot: SnapshotLoader, initialSnapshot: AdapterSnapshot);
9
+ warm(): Promise<void>;
10
+ refresh(_reason: AdapterRefreshReason): Promise<void>;
11
+ getCachedSnapshot(): AdapterSnapshot;
12
+ subscribe(listener: () => void): () => void;
13
+ dispose(): Promise<void>;
14
+ }
15
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StaticProjectSource = void 0;
4
+ class StaticProjectSource {
5
+ loadSnapshot;
6
+ cachedSnapshot;
7
+ listeners = new Set();
8
+ refreshGeneration = 0;
9
+ constructor(loadSnapshot, initialSnapshot) {
10
+ this.loadSnapshot = loadSnapshot;
11
+ this.cachedSnapshot = initialSnapshot;
12
+ }
13
+ async warm() {
14
+ await this.refresh("warm");
15
+ }
16
+ async refresh(_reason) {
17
+ const generation = ++this.refreshGeneration;
18
+ const snapshot = await this.loadSnapshot();
19
+ if (generation !== this.refreshGeneration) {
20
+ return;
21
+ }
22
+ this.cachedSnapshot = snapshot;
23
+ for (const listener of this.listeners) {
24
+ listener();
25
+ }
26
+ }
27
+ getCachedSnapshot() {
28
+ return this.cachedSnapshot;
29
+ }
30
+ subscribe(listener) {
31
+ this.listeners.add(listener);
32
+ return () => {
33
+ this.listeners.delete(listener);
34
+ };
35
+ }
36
+ async dispose() {
37
+ this.listeners.clear();
38
+ }
39
+ }
40
+ exports.StaticProjectSource = StaticProjectSource;
41
+ //# sourceMappingURL=static-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-source.js","sourceRoot":"","sources":["../../src/adapters/static-source.ts"],"names":[],"mappings":";;;AAIA,MAAa,mBAAmB;IAMX;IALX,cAAc,CAAkB;IACvB,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAC3C,iBAAiB,GAAG,CAAC,CAAC;IAE9B,YACmB,YAA4B,EAC7C,eAAgC;QADf,iBAAY,GAAZ,YAAY,CAAgB;QAG7C,IAAI,CAAC,cAAc,GAAG,eAAe,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAA6B;QACzC,MAAM,UAAU,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC3C,IAAI,UAAU,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,QAAoB;QAC5B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AA1CD,kDA0CC"}
@@ -0,0 +1,44 @@
1
+ import type { CloudTask, DashboardAgent, DashboardEvent } from "../types";
2
+ import type { DiscoveredProject } from "../project-paths";
3
+ export type AdapterHealthStatus = "ready" | "degraded" | "error";
4
+ export type AdapterRefreshReason = "warm" | "startup" | "interval" | "manual" | "event";
5
+ export interface AdapterCapabilities {
6
+ discoverProjects?: boolean;
7
+ liveUpdates?: boolean;
8
+ typedNeedsUser?: boolean;
9
+ cloudTasks?: boolean;
10
+ }
11
+ export interface AdapterHealth {
12
+ status: AdapterHealthStatus;
13
+ detail: string | null;
14
+ lastUpdatedAt: string | null;
15
+ }
16
+ export interface AdapterSnapshot {
17
+ adapterId: string;
18
+ source: DashboardAgent["source"];
19
+ generatedAt: string;
20
+ agents: DashboardAgent[];
21
+ events: DashboardEvent[];
22
+ notes: string[];
23
+ cloudTasks?: CloudTask[];
24
+ health: AdapterHealth;
25
+ }
26
+ export interface ProjectAdapterContext {
27
+ projectRoot: string;
28
+ localLimit?: number;
29
+ readThreads?: boolean;
30
+ }
31
+ export interface ProjectSource {
32
+ warm(): Promise<void>;
33
+ refresh(reason: AdapterRefreshReason): Promise<void>;
34
+ getCachedSnapshot(): AdapterSnapshot;
35
+ subscribe?(listener: () => void): () => void;
36
+ dispose(): Promise<void>;
37
+ }
38
+ export interface ProjectAdapter {
39
+ id: string;
40
+ source: DashboardAgent["source"];
41
+ capabilities: AdapterCapabilities;
42
+ discoverProjects?(limit?: number): Promise<DiscoveredProject[]>;
43
+ createSource(context: ProjectAdapterContext): ProjectSource;
44
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,94 @@
1
+ import type { CodexThread } from "./types";
2
+ type ThreadListSortKey = "created_at" | "updated_at";
3
+ type SortDirection = "asc" | "desc";
4
+ export interface AppServerThreadGoal {
5
+ threadId: string;
6
+ objective: string;
7
+ status: string;
8
+ tokenBudget: number | null;
9
+ tokensUsed: number;
10
+ timeUsedSeconds: number;
11
+ createdAt: number;
12
+ updatedAt: number;
13
+ }
14
+ export declare function appServerCwdParam(cwd: string | null | undefined): string | null;
15
+ export interface ToolRequestUserInputAnswer {
16
+ answers: string[];
17
+ }
18
+ export interface ToolRequestUserInputResponse {
19
+ answers: Record<string, ToolRequestUserInputAnswer>;
20
+ }
21
+ export interface AppServerNotification {
22
+ method: string;
23
+ params?: Record<string, unknown>;
24
+ }
25
+ export interface AppServerServerRequest {
26
+ id: number;
27
+ method: string;
28
+ params?: Record<string, unknown>;
29
+ }
30
+ interface AppServerResponseMessage {
31
+ id: number;
32
+ result?: unknown;
33
+ error?: {
34
+ message?: string;
35
+ };
36
+ }
37
+ type ParsedAppServerMessage = {
38
+ kind: "response";
39
+ message: AppServerResponseMessage;
40
+ } | {
41
+ kind: "notification";
42
+ message: AppServerNotification;
43
+ } | {
44
+ kind: "serverRequest";
45
+ message: AppServerServerRequest;
46
+ } | {
47
+ kind: "unknown";
48
+ };
49
+ export declare function parseAppServerMessage(line: string): ParsedAppServerMessage;
50
+ export declare class CodexAppServerClient {
51
+ private child;
52
+ private buffer;
53
+ private nextId;
54
+ private pending;
55
+ private stderr;
56
+ private notificationListeners;
57
+ private serverRequestListeners;
58
+ private constructor();
59
+ static create(): Promise<CodexAppServerClient>;
60
+ static createWithCandidateLabel(): Promise<{
61
+ client: CodexAppServerClient;
62
+ candidateLabel: string;
63
+ }>;
64
+ private onStdout;
65
+ private send;
66
+ notify(method: string, params?: Record<string, unknown>): void;
67
+ onNotification(listener: (message: AppServerNotification) => void): () => void;
68
+ onServerRequest(listener: (message: AppServerServerRequest) => void): () => void;
69
+ request<TResult>(method: string, params?: Record<string, unknown>): Promise<TResult>;
70
+ requestNoWait(method: string, params?: Record<string, unknown>): number;
71
+ respondToServerRequest(requestId: number, result: unknown): void;
72
+ respondToToolRequestUserInput(requestId: number, response: ToolRequestUserInputResponse): void;
73
+ respondToApprovalRequest(requestId: number, decision: string): void;
74
+ respondToDynamicToolCallUnsupported(requestId: number, tool: string | null | undefined): void;
75
+ listThreads(params: {
76
+ cwd?: string;
77
+ limit?: number;
78
+ sourceKinds?: string[];
79
+ sortKey?: ThreadListSortKey;
80
+ sortDirection?: SortDirection;
81
+ }): Promise<CodexThread[]>;
82
+ readThread(threadId: string): Promise<CodexThread>;
83
+ getThreadGoal(threadId: string): Promise<AppServerThreadGoal | null>;
84
+ resumeThread(threadId: string): Promise<CodexThread>;
85
+ startTurn(threadId: string, text: string, cwd?: string): Promise<string>;
86
+ startTurnNoWait(threadId: string, text: string, cwd?: string): number;
87
+ steerTurn(threadId: string, expectedTurnId: string, text: string): Promise<string>;
88
+ steerTurnNoWait(threadId: string, expectedTurnId: string, text: string): number;
89
+ unsubscribeThread(threadId: string): Promise<"unsubscribed" | "notSubscribed" | "notLoaded">;
90
+ listLoadedThreads(): Promise<string[]>;
91
+ close(): void;
92
+ }
93
+ export declare function withAppServerClient<T>(fn: (client: CodexAppServerClient) => Promise<T>): Promise<T>;
94
+ export {};
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CodexAppServerClient = void 0;
4
+ exports.appServerCwdParam = appServerCwdParam;
5
+ exports.parseAppServerMessage = parseAppServerMessage;
6
+ exports.withAppServerClient = withAppServerClient;
7
+ const node_process_1 = require("node:process");
8
+ const codex_command_1 = require("./codex-command");
9
+ function appServerCwdParam(cwd) {
10
+ if (!cwd) {
11
+ return null;
12
+ }
13
+ const match = cwd.match(/^\/mnt\/([a-zA-Z])\/(.*)$/);
14
+ if (node_process_1.platform !== "win32" || !match) {
15
+ return cwd;
16
+ }
17
+ const drive = match[1].toUpperCase();
18
+ const rest = match[2].replace(/\//g, "\\");
19
+ return `${drive}:\\${rest}`;
20
+ }
21
+ const MAX_APP_SERVER_LINE_BYTES = 8 * 1024 * 1024;
22
+ const APP_SERVER_INITIALIZE_TIMEOUT_MS = 15000;
23
+ async function withTimeout(promise, timeoutMs, label) {
24
+ return await Promise.race([
25
+ promise,
26
+ new Promise((_, reject) => {
27
+ const timer = setTimeout(() => {
28
+ reject(new Error(`${label} timed out after ${timeoutMs}ms`));
29
+ }, timeoutMs);
30
+ timer.unref?.();
31
+ promise.finally(() => clearTimeout(timer)).catch(() => clearTimeout(timer));
32
+ })
33
+ ]);
34
+ }
35
+ function messageIdFromOversizedLine(line) {
36
+ const prefix = line.slice(0, 256);
37
+ const match = prefix.match(/"id"\s*:\s*(\d+)/);
38
+ return match ? Number(match[1]) : null;
39
+ }
40
+ function parseAppServerMessage(line) {
41
+ let message;
42
+ try {
43
+ message = JSON.parse(line);
44
+ }
45
+ catch {
46
+ return { kind: "unknown" };
47
+ }
48
+ if (typeof message.id === "number" && typeof message.method === "string") {
49
+ return {
50
+ kind: "serverRequest",
51
+ message: {
52
+ id: message.id,
53
+ method: message.method,
54
+ params: message.params
55
+ }
56
+ };
57
+ }
58
+ if (typeof message.method === "string") {
59
+ return {
60
+ kind: "notification",
61
+ message: {
62
+ method: message.method,
63
+ params: message.params
64
+ }
65
+ };
66
+ }
67
+ if (typeof message.id === "number") {
68
+ return {
69
+ kind: "response",
70
+ message: {
71
+ id: message.id,
72
+ result: message.result,
73
+ error: message.error
74
+ }
75
+ };
76
+ }
77
+ return { kind: "unknown" };
78
+ }
79
+ class CodexAppServerClient {
80
+ child;
81
+ buffer = "";
82
+ nextId = 1;
83
+ pending = new Map();
84
+ stderr = "";
85
+ notificationListeners = new Set();
86
+ serverRequestListeners = new Set();
87
+ constructor(child) {
88
+ this.child = child;
89
+ this.child.stdout.setEncoding("utf8");
90
+ this.child.stderr.setEncoding("utf8");
91
+ this.child.stdout.on("data", (chunk) => this.onStdout(chunk));
92
+ this.child.stderr.on("data", (chunk) => {
93
+ this.stderr += chunk;
94
+ });
95
+ this.child.on("error", (error) => {
96
+ for (const pending of this.pending.values()) {
97
+ pending.reject(error instanceof Error ? error : new Error(String(error)));
98
+ }
99
+ this.pending.clear();
100
+ });
101
+ this.child.on("exit", (code, signal) => {
102
+ const reason = code === 0 || signal === "SIGTERM"
103
+ ? null
104
+ : new Error(`codex app-server exited unexpectedly (${code ?? signal ?? "unknown"}).`);
105
+ if (!reason) {
106
+ return;
107
+ }
108
+ for (const pending of this.pending.values()) {
109
+ pending.reject(reason);
110
+ }
111
+ this.pending.clear();
112
+ });
113
+ }
114
+ static async create() {
115
+ const { child } = await (0, codex_command_1.spawnCodexProcess)(["app-server"]);
116
+ const client = new CodexAppServerClient(child);
117
+ try {
118
+ await withTimeout(client.request("initialize", {
119
+ clientInfo: {
120
+ name: "codex_agents_office",
121
+ title: "Codex Agents Office",
122
+ version: "0.1.0"
123
+ },
124
+ capabilities: {
125
+ experimentalApi: true,
126
+ requestAttestation: false
127
+ }
128
+ }), APP_SERVER_INITIALIZE_TIMEOUT_MS, "app-server initialize");
129
+ }
130
+ catch (error) {
131
+ client.close();
132
+ throw error;
133
+ }
134
+ client.notify("initialized");
135
+ return client;
136
+ }
137
+ static async createWithCandidateLabel() {
138
+ const { child, candidate } = await (0, codex_command_1.spawnCodexProcess)(["app-server"]);
139
+ const client = new CodexAppServerClient(child);
140
+ try {
141
+ await withTimeout(client.request("initialize", {
142
+ clientInfo: {
143
+ name: "codex_agents_office",
144
+ title: "Codex Agents Office",
145
+ version: "0.1.0"
146
+ },
147
+ capabilities: {
148
+ experimentalApi: true,
149
+ requestAttestation: false
150
+ }
151
+ }), APP_SERVER_INITIALIZE_TIMEOUT_MS, "app-server initialize");
152
+ }
153
+ catch (error) {
154
+ client.close();
155
+ throw error;
156
+ }
157
+ client.notify("initialized");
158
+ return { client, candidateLabel: candidate.label };
159
+ }
160
+ onStdout(chunk) {
161
+ this.buffer += chunk;
162
+ while (true) {
163
+ const newlineIndex = this.buffer.indexOf("\n");
164
+ if (newlineIndex === -1) {
165
+ return;
166
+ }
167
+ const line = this.buffer.slice(0, newlineIndex).trim();
168
+ this.buffer = this.buffer.slice(newlineIndex + 1);
169
+ if (!line) {
170
+ continue;
171
+ }
172
+ if (line.length > MAX_APP_SERVER_LINE_BYTES) {
173
+ const requestId = messageIdFromOversizedLine(line);
174
+ if (requestId !== null) {
175
+ const pending = this.pending.get(requestId);
176
+ if (pending) {
177
+ this.pending.delete(requestId);
178
+ pending.reject(new Error(`app-server message exceeded ${MAX_APP_SERVER_LINE_BYTES} bytes`));
179
+ }
180
+ }
181
+ continue;
182
+ }
183
+ const parsed = parseAppServerMessage(line);
184
+ if (parsed.kind === "notification") {
185
+ for (const listener of this.notificationListeners) {
186
+ listener(parsed.message);
187
+ }
188
+ continue;
189
+ }
190
+ if (parsed.kind === "serverRequest") {
191
+ for (const listener of this.serverRequestListeners) {
192
+ listener(parsed.message);
193
+ }
194
+ continue;
195
+ }
196
+ if (parsed.kind !== "response") {
197
+ continue;
198
+ }
199
+ const pending = this.pending.get(parsed.message.id);
200
+ if (!pending) {
201
+ continue;
202
+ }
203
+ this.pending.delete(parsed.message.id);
204
+ if (parsed.message.error) {
205
+ pending.reject(new Error(parsed.message.error.message ?? "app-server request failed"));
206
+ }
207
+ else {
208
+ pending.resolve(parsed.message.result);
209
+ }
210
+ }
211
+ }
212
+ send(payload) {
213
+ this.child.stdin.write(`${JSON.stringify(payload)}\n`);
214
+ }
215
+ notify(method, params) {
216
+ this.send(params ? { method, params } : { method });
217
+ }
218
+ onNotification(listener) {
219
+ this.notificationListeners.add(listener);
220
+ return () => {
221
+ this.notificationListeners.delete(listener);
222
+ };
223
+ }
224
+ onServerRequest(listener) {
225
+ this.serverRequestListeners.add(listener);
226
+ return () => {
227
+ this.serverRequestListeners.delete(listener);
228
+ };
229
+ }
230
+ request(method, params) {
231
+ const id = this.nextId++;
232
+ return new Promise((resolve, reject) => {
233
+ this.pending.set(id, { resolve: (value) => resolve(value), reject });
234
+ this.send(params ? { id, method, params } : { id, method });
235
+ });
236
+ }
237
+ requestNoWait(method, params) {
238
+ const id = this.nextId++;
239
+ this.send(params ? { id, method, params } : { id, method });
240
+ return id;
241
+ }
242
+ respondToServerRequest(requestId, result) {
243
+ this.send({ id: requestId, result });
244
+ }
245
+ respondToToolRequestUserInput(requestId, response) {
246
+ this.respondToServerRequest(requestId, response);
247
+ }
248
+ respondToApprovalRequest(requestId, decision) {
249
+ this.respondToServerRequest(requestId, { decision });
250
+ }
251
+ respondToDynamicToolCallUnsupported(requestId, tool) {
252
+ const toolLabel = tool && tool.trim().length > 0 ? tool.trim() : "dynamic tool";
253
+ const response = {
254
+ success: false,
255
+ contentItems: [
256
+ {
257
+ type: "inputText",
258
+ text: `Agents Office observes Codex workload but does not execute ${toolLabel} dynamic tool requests.`
259
+ }
260
+ ]
261
+ };
262
+ this.respondToServerRequest(requestId, response);
263
+ }
264
+ async listThreads(params) {
265
+ const requestedLimit = Math.max(0, params.limit ?? 12);
266
+ const sourceKinds = params.sourceKinds ?? [
267
+ "cli",
268
+ "vscode",
269
+ "exec",
270
+ "appServer",
271
+ "subAgent",
272
+ "subAgentReview",
273
+ "subAgentCompact",
274
+ "subAgentThreadSpawn",
275
+ "subAgentOther",
276
+ "unknown"
277
+ ];
278
+ const threads = [];
279
+ const seenCursors = new Set();
280
+ let cursor = null;
281
+ while (threads.length < requestedLimit) {
282
+ const result = await this.request("thread/list", {
283
+ cwd: appServerCwdParam(params.cwd),
284
+ cursor,
285
+ limit: Math.min(100, requestedLimit - threads.length),
286
+ sortKey: params.sortKey ?? "updated_at",
287
+ sortDirection: params.sortDirection ?? "desc",
288
+ sourceKinds,
289
+ archived: false
290
+ });
291
+ const page = result.data ?? [];
292
+ threads.push(...page);
293
+ const nextCursor = result.nextCursor ?? null;
294
+ if (page.length === 0 || !nextCursor || seenCursors.has(nextCursor)) {
295
+ break;
296
+ }
297
+ seenCursors.add(nextCursor);
298
+ cursor = nextCursor;
299
+ }
300
+ return threads.slice(0, requestedLimit);
301
+ }
302
+ async readThread(threadId) {
303
+ const result = await this.request("thread/read", {
304
+ threadId,
305
+ includeTurns: true
306
+ });
307
+ return result.thread;
308
+ }
309
+ async getThreadGoal(threadId) {
310
+ const result = await this.request("thread/goal/get", { threadId });
311
+ return result.goal ?? null;
312
+ }
313
+ async resumeThread(threadId) {
314
+ const result = await this.request("thread/resume", {
315
+ threadId
316
+ });
317
+ return result.thread;
318
+ }
319
+ async startTurn(threadId, text, cwd) {
320
+ const result = await this.request("turn/start", {
321
+ threadId,
322
+ input: [textUserInput(text)],
323
+ cwd: cwd ?? null
324
+ });
325
+ return result.turn?.id ?? "";
326
+ }
327
+ startTurnNoWait(threadId, text, cwd) {
328
+ return this.requestNoWait("turn/start", {
329
+ threadId,
330
+ input: [textUserInput(text)],
331
+ cwd: cwd ?? null
332
+ });
333
+ }
334
+ async steerTurn(threadId, expectedTurnId, text) {
335
+ const result = await this.request("turn/steer", {
336
+ threadId,
337
+ input: [textUserInput(text)],
338
+ expectedTurnId
339
+ });
340
+ return result.turnId ?? "";
341
+ }
342
+ steerTurnNoWait(threadId, expectedTurnId, text) {
343
+ return this.requestNoWait("turn/steer", {
344
+ threadId,
345
+ input: [textUserInput(text)],
346
+ expectedTurnId
347
+ });
348
+ }
349
+ async unsubscribeThread(threadId) {
350
+ const result = await this.request("thread/unsubscribe", {
351
+ threadId
352
+ });
353
+ return result.status;
354
+ }
355
+ async listLoadedThreads() {
356
+ const result = await this.request("thread/loaded/list", {});
357
+ return Array.isArray(result.data) ? result.data : [];
358
+ }
359
+ close() {
360
+ if (!this.child.killed) {
361
+ this.child.kill();
362
+ }
363
+ }
364
+ }
365
+ exports.CodexAppServerClient = CodexAppServerClient;
366
+ function textUserInput(text) {
367
+ return {
368
+ type: "text",
369
+ text,
370
+ text_elements: []
371
+ };
372
+ }
373
+ async function withAppServerClient(fn) {
374
+ const client = await CodexAppServerClient.create();
375
+ try {
376
+ return await fn(client);
377
+ }
378
+ finally {
379
+ client.close();
380
+ }
381
+ }
382
+ //# sourceMappingURL=app-server.js.map