@useorgx/openclaw-plugin 0.4.8 → 0.7.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 (284) hide show
  1. package/README.md +35 -0
  2. package/dashboard/dist/assets/BJgZIVUQ.js +53 -0
  3. package/dashboard/dist/assets/BJgZIVUQ.js.br +0 -0
  4. package/dashboard/dist/assets/BJgZIVUQ.js.gz +0 -0
  5. package/dashboard/dist/assets/BXWDRGm-.js +1 -0
  6. package/dashboard/dist/assets/BXWDRGm-.js.br +0 -0
  7. package/dashboard/dist/assets/BXWDRGm-.js.gz +0 -0
  8. package/dashboard/dist/assets/BgOYB78t.js +4 -0
  9. package/dashboard/dist/assets/BgOYB78t.js.br +0 -0
  10. package/dashboard/dist/assets/BgOYB78t.js.gz +0 -0
  11. package/dashboard/dist/assets/C-KIc3Wc.js.br +0 -0
  12. package/dashboard/dist/assets/C-KIc3Wc.js.gz +0 -0
  13. package/dashboard/dist/assets/CE38zU4U.js +1 -0
  14. package/dashboard/dist/assets/CE38zU4U.js.br +0 -0
  15. package/dashboard/dist/assets/CE38zU4U.js.gz +0 -0
  16. package/dashboard/dist/assets/CFGKRAzG.js +1 -0
  17. package/dashboard/dist/assets/CFGKRAzG.js.br +0 -0
  18. package/dashboard/dist/assets/CFGKRAzG.js.gz +0 -0
  19. package/dashboard/dist/assets/CGGR2GZh.js +1 -0
  20. package/dashboard/dist/assets/CGGR2GZh.js.br +0 -0
  21. package/dashboard/dist/assets/CGGR2GZh.js.gz +0 -0
  22. package/dashboard/dist/assets/CL_wXqR7.js +1 -0
  23. package/dashboard/dist/assets/CL_wXqR7.js.br +0 -0
  24. package/dashboard/dist/assets/CL_wXqR7.js.gz +0 -0
  25. package/dashboard/dist/assets/CPFiTmlw.js +8 -0
  26. package/dashboard/dist/assets/CPFiTmlw.js.br +0 -0
  27. package/dashboard/dist/assets/CPFiTmlw.js.gz +0 -0
  28. package/dashboard/dist/assets/CZZTvkQZ.js +1 -0
  29. package/dashboard/dist/assets/CZZTvkQZ.js.br +0 -0
  30. package/dashboard/dist/assets/CZZTvkQZ.js.gz +0 -0
  31. package/dashboard/dist/assets/{CpJsfbXo.js → CxQ08qFN.js} +2 -2
  32. package/dashboard/dist/assets/CxQ08qFN.js.br +0 -0
  33. package/dashboard/dist/assets/CxQ08qFN.js.gz +0 -0
  34. package/dashboard/dist/assets/D-bf6hEI.js +213 -0
  35. package/dashboard/dist/assets/D-bf6hEI.js.br +0 -0
  36. package/dashboard/dist/assets/D-bf6hEI.js.gz +0 -0
  37. package/dashboard/dist/assets/DG6y9wJI.js +2 -0
  38. package/dashboard/dist/assets/DG6y9wJI.js.br +0 -0
  39. package/dashboard/dist/assets/DG6y9wJI.js.gz +0 -0
  40. package/dashboard/dist/assets/DNxKz-GV.js +1 -0
  41. package/dashboard/dist/assets/DNxKz-GV.js.br +0 -0
  42. package/dashboard/dist/assets/DNxKz-GV.js.gz +0 -0
  43. package/dashboard/dist/assets/DW_rKUic.js +11 -0
  44. package/dashboard/dist/assets/DW_rKUic.js.br +0 -0
  45. package/dashboard/dist/assets/DW_rKUic.js.gz +0 -0
  46. package/dashboard/dist/assets/DbNoijHm.js +1 -0
  47. package/dashboard/dist/assets/DbNoijHm.js.br +0 -0
  48. package/dashboard/dist/assets/DbNoijHm.js.gz +0 -0
  49. package/dashboard/dist/assets/DjcdE6jC.js +2 -0
  50. package/dashboard/dist/assets/DjcdE6jC.js.br +0 -0
  51. package/dashboard/dist/assets/DjcdE6jC.js.gz +0 -0
  52. package/dashboard/dist/assets/FZYuCDnt.js +1 -0
  53. package/dashboard/dist/assets/FZYuCDnt.js.br +0 -0
  54. package/dashboard/dist/assets/FZYuCDnt.js.gz +0 -0
  55. package/dashboard/dist/assets/PAUiij_z.js +1 -0
  56. package/dashboard/dist/assets/PAUiij_z.js.br +0 -0
  57. package/dashboard/dist/assets/PAUiij_z.js.gz +0 -0
  58. package/dashboard/dist/assets/cNrhgGc1.js +8 -0
  59. package/dashboard/dist/assets/cNrhgGc1.js.br +0 -0
  60. package/dashboard/dist/assets/cNrhgGc1.js.gz +0 -0
  61. package/dashboard/dist/assets/h5biQs2I.css +1 -0
  62. package/dashboard/dist/assets/h5biQs2I.css.br +0 -0
  63. package/dashboard/dist/assets/h5biQs2I.css.gz +0 -0
  64. package/dashboard/dist/assets/ic2FaMnh.js +1 -0
  65. package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
  66. package/dashboard/dist/assets/ic2FaMnh.js.gz +0 -0
  67. package/dashboard/dist/assets/nByHNHoW.js +1 -0
  68. package/dashboard/dist/assets/nByHNHoW.js.br +0 -0
  69. package/dashboard/dist/assets/nByHNHoW.js.gz +0 -0
  70. package/dashboard/dist/assets/qm8xLgv-.css +1 -0
  71. package/dashboard/dist/assets/qm8xLgv-.css.br +0 -0
  72. package/dashboard/dist/assets/qm8xLgv-.css.gz +0 -0
  73. package/dashboard/dist/assets/tS9mbYZi.js +1 -0
  74. package/dashboard/dist/assets/tS9mbYZi.js.br +0 -0
  75. package/dashboard/dist/assets/tS9mbYZi.js.gz +0 -0
  76. package/dashboard/dist/brand/anthropic-mark.svg.br +0 -0
  77. package/dashboard/dist/brand/anthropic-mark.svg.gz +0 -0
  78. package/dashboard/dist/brand/openai-mark.svg.br +0 -0
  79. package/dashboard/dist/brand/openai-mark.svg.gz +0 -0
  80. package/dashboard/dist/brand/openclaw-mark.svg.br +0 -0
  81. package/dashboard/dist/brand/openclaw-mark.svg.gz +0 -0
  82. package/dashboard/dist/brand/xandy-orchestrator.png +0 -0
  83. package/dashboard/dist/index.html +7 -5
  84. package/dashboard/dist/index.html.br +0 -0
  85. package/dashboard/dist/index.html.gz +0 -0
  86. package/dist/activity-actor-fields.js +26 -4
  87. package/dist/activity-store.js +38 -26
  88. package/dist/agent-context-store.js +84 -42
  89. package/dist/agent-run-store.js +49 -28
  90. package/dist/agent-suite.d.ts +9 -0
  91. package/dist/agent-suite.js +150 -17
  92. package/dist/artifacts/artifact-domain-schemas.d.ts +66 -0
  93. package/dist/artifacts/artifact-domain-schemas.js +357 -0
  94. package/dist/artifacts/register-artifact.d.ts +4 -3
  95. package/dist/artifacts/register-artifact.js +170 -57
  96. package/dist/auth/flows.d.ts +47 -0
  97. package/dist/auth/flows.js +169 -0
  98. package/dist/auth-store.js +6 -26
  99. package/dist/byok-store.js +5 -19
  100. package/dist/chat-store.d.ts +157 -0
  101. package/dist/chat-store.js +586 -0
  102. package/dist/cli/orgx.d.ts +66 -0
  103. package/dist/cli/orgx.js +102 -0
  104. package/dist/config/refresh.d.ts +32 -0
  105. package/dist/config/refresh.js +55 -0
  106. package/dist/config/resolution.d.ts +37 -0
  107. package/dist/config/resolution.js +178 -0
  108. package/dist/contracts/client.d.ts +43 -3
  109. package/dist/contracts/client.js +159 -30
  110. package/dist/contracts/retro-schema.d.ts +81 -0
  111. package/dist/contracts/retro-schema.js +80 -0
  112. package/dist/contracts/shared-types.d.ts +306 -0
  113. package/dist/contracts/shared-types.js +179 -0
  114. package/dist/contracts/skill-pack-schema.d.ts +192 -0
  115. package/dist/contracts/skill-pack-schema.js +180 -0
  116. package/dist/contracts/types.d.ts +224 -132
  117. package/dist/contracts/types.js +5 -0
  118. package/dist/entities/auto-assignment.d.ts +36 -0
  119. package/dist/entities/auto-assignment.js +141 -0
  120. package/dist/entity-comment-store.js +5 -25
  121. package/dist/event-sanitization.d.ts +11 -0
  122. package/dist/event-sanitization.js +113 -0
  123. package/dist/fs-utils.js +13 -1
  124. package/dist/gateway-watchdog.d.ts +5 -0
  125. package/dist/gateway-watchdog.js +50 -0
  126. package/dist/hash-utils.d.ts +2 -0
  127. package/dist/hash-utils.js +12 -0
  128. package/dist/hooks/post-reporting-event.mjs +1 -5
  129. package/dist/http/helpers/activity-headline.d.ts +10 -0
  130. package/dist/http/helpers/activity-headline.js +73 -0
  131. package/dist/http/helpers/artifact-fallback.d.ts +13 -0
  132. package/dist/http/helpers/artifact-fallback.js +148 -0
  133. package/dist/http/helpers/auto-continue-engine.d.ts +486 -0
  134. package/dist/http/helpers/auto-continue-engine.js +3563 -0
  135. package/dist/http/helpers/autopilot-operations.d.ts +176 -0
  136. package/dist/http/helpers/autopilot-operations.js +554 -0
  137. package/dist/http/helpers/autopilot-runtime.d.ts +43 -0
  138. package/dist/http/helpers/autopilot-runtime.js +607 -0
  139. package/dist/http/helpers/autopilot-slice-utils.d.ts +56 -0
  140. package/dist/http/helpers/autopilot-slice-utils.js +899 -0
  141. package/dist/http/helpers/decision-mapper.d.ts +52 -0
  142. package/dist/http/helpers/decision-mapper.js +260 -0
  143. package/dist/http/helpers/dispatch-lifecycle.d.ts +119 -0
  144. package/dist/http/helpers/dispatch-lifecycle.js +809 -0
  145. package/dist/http/helpers/hash-utils.d.ts +1 -0
  146. package/dist/http/helpers/hash-utils.js +1 -0
  147. package/dist/http/helpers/kickoff-context.d.ts +12 -0
  148. package/dist/http/helpers/kickoff-context.js +228 -0
  149. package/dist/http/helpers/llm-client.d.ts +47 -0
  150. package/dist/http/helpers/llm-client.js +256 -0
  151. package/dist/http/helpers/mission-control.d.ts +193 -0
  152. package/dist/http/helpers/mission-control.js +1383 -0
  153. package/dist/http/helpers/openclaw-cli.d.ts +37 -0
  154. package/dist/http/helpers/openclaw-cli.js +283 -0
  155. package/dist/http/helpers/runtime-sse.d.ts +20 -0
  156. package/dist/http/helpers/runtime-sse.js +110 -0
  157. package/dist/http/helpers/sentinel-catalog.d.ts +23 -0
  158. package/dist/http/helpers/sentinel-catalog.js +193 -0
  159. package/dist/http/helpers/session-classification.d.ts +9 -0
  160. package/dist/http/helpers/session-classification.js +564 -0
  161. package/dist/http/helpers/slice-experience-v2.d.ts +137 -0
  162. package/dist/http/helpers/slice-experience-v2.js +677 -0
  163. package/dist/http/helpers/slice-run-projections.d.ts +72 -0
  164. package/dist/http/helpers/slice-run-projections.js +860 -0
  165. package/dist/http/helpers/triage-mapper.d.ts +43 -0
  166. package/dist/http/helpers/triage-mapper.js +549 -0
  167. package/dist/http/helpers/value-utils.d.ts +6 -0
  168. package/dist/http/helpers/value-utils.js +72 -0
  169. package/dist/http/helpers/workspace-scope.d.ts +15 -0
  170. package/dist/http/helpers/workspace-scope.js +170 -0
  171. package/dist/http/index.d.ts +88 -0
  172. package/dist/http/index.js +3610 -0
  173. package/dist/http/router.d.ts +23 -0
  174. package/dist/http/router.js +23 -0
  175. package/dist/http/routes/agent-control.d.ts +79 -0
  176. package/dist/http/routes/agent-control.js +684 -0
  177. package/dist/http/routes/agent-suite.d.ts +38 -0
  178. package/dist/http/routes/agent-suite.js +397 -0
  179. package/dist/http/routes/agents-catalog.d.ts +40 -0
  180. package/dist/http/routes/agents-catalog.js +128 -0
  181. package/dist/http/routes/billing.d.ts +23 -0
  182. package/dist/http/routes/billing.js +55 -0
  183. package/dist/http/routes/chat.d.ts +19 -0
  184. package/dist/http/routes/chat.js +522 -0
  185. package/dist/http/routes/debug.d.ts +14 -0
  186. package/dist/http/routes/debug.js +21 -0
  187. package/dist/http/routes/decision-actions.d.ts +20 -0
  188. package/dist/http/routes/decision-actions.js +103 -0
  189. package/dist/http/routes/delegation.d.ts +19 -0
  190. package/dist/http/routes/delegation.js +32 -0
  191. package/dist/http/routes/dispatch-gateway-envelope.d.ts +25 -0
  192. package/dist/http/routes/dispatch-gateway-envelope.js +26 -0
  193. package/dist/http/routes/entities.d.ts +63 -0
  194. package/dist/http/routes/entities.js +440 -0
  195. package/dist/http/routes/entity-dynamic.d.ts +25 -0
  196. package/dist/http/routes/entity-dynamic.js +191 -0
  197. package/dist/http/routes/health.d.ts +22 -0
  198. package/dist/http/routes/health.js +49 -0
  199. package/dist/http/routes/live-legacy.d.ts +115 -0
  200. package/dist/http/routes/live-legacy.js +112 -0
  201. package/dist/http/routes/live-misc.d.ts +81 -0
  202. package/dist/http/routes/live-misc.js +426 -0
  203. package/dist/http/routes/live-snapshot.d.ts +136 -0
  204. package/dist/http/routes/live-snapshot.js +916 -0
  205. package/dist/http/routes/live-terminal.d.ts +11 -0
  206. package/dist/http/routes/live-terminal.js +261 -0
  207. package/dist/http/routes/live-triage.d.ts +61 -0
  208. package/dist/http/routes/live-triage.js +248 -0
  209. package/dist/http/routes/mission-control-actions.d.ts +131 -0
  210. package/dist/http/routes/mission-control-actions.js +1791 -0
  211. package/dist/http/routes/mission-control-read.d.ts +73 -0
  212. package/dist/http/routes/mission-control-read.js +1640 -0
  213. package/dist/http/routes/onboarding.d.ts +34 -0
  214. package/dist/http/routes/onboarding.js +101 -0
  215. package/dist/http/routes/realtime-orchestrator.d.ts +10 -0
  216. package/dist/http/routes/realtime-orchestrator.js +74 -0
  217. package/dist/http/routes/run-control.d.ts +27 -0
  218. package/dist/http/routes/run-control.js +96 -0
  219. package/dist/http/routes/runtime-hooks.d.ts +69 -0
  220. package/dist/http/routes/runtime-hooks.js +437 -0
  221. package/dist/http/routes/sentinels-catalog.d.ts +7 -0
  222. package/dist/http/routes/sentinels-catalog.js +24 -0
  223. package/dist/http/routes/settings-byok.d.ts +23 -0
  224. package/dist/http/routes/settings-byok.js +163 -0
  225. package/dist/http/routes/summary.d.ts +18 -0
  226. package/dist/http/routes/summary.js +49 -0
  227. package/dist/http/routes/usage.d.ts +24 -0
  228. package/dist/http/routes/usage.js +362 -0
  229. package/dist/http/routes/work-artifacts.d.ts +9 -0
  230. package/dist/http/routes/work-artifacts.js +55 -0
  231. package/dist/http/shared-state.d.ts +16 -0
  232. package/dist/http/shared-state.js +1 -0
  233. package/dist/http-handler.d.ts +1 -88
  234. package/dist/http-handler.js +1 -10605
  235. package/dist/index.js +287 -2284
  236. package/dist/json-utils.d.ts +1 -0
  237. package/dist/json-utils.js +8 -0
  238. package/dist/local-openclaw.js +29 -6
  239. package/dist/mcp-client-setup.js +3 -3
  240. package/dist/mcp-http-handler.js +33 -59
  241. package/dist/next-up-queue-store.d.ts +16 -1
  242. package/dist/next-up-queue-store.js +93 -25
  243. package/dist/outbox.d.ts +5 -0
  244. package/dist/outbox.js +113 -9
  245. package/dist/paths.js +24 -5
  246. package/dist/reporting/rollups.d.ts +53 -0
  247. package/dist/reporting/rollups.js +148 -0
  248. package/dist/retro/domain-templates.d.ts +45 -0
  249. package/dist/retro/domain-templates.js +297 -0
  250. package/dist/retro/quality-rubric.d.ts +33 -0
  251. package/dist/retro/quality-rubric.js +213 -0
  252. package/dist/runtime-cleanup.d.ts +18 -0
  253. package/dist/runtime-cleanup.js +87 -0
  254. package/dist/runtime-instance-store.js +5 -31
  255. package/dist/services/background.d.ts +34 -0
  256. package/dist/services/background.js +45 -0
  257. package/dist/services/experiment-randomization.d.ts +21 -0
  258. package/dist/services/experiment-randomization.js +63 -0
  259. package/dist/services/instrumentation.d.ts +29 -0
  260. package/dist/services/instrumentation.js +136 -0
  261. package/dist/skill-pack-state.d.ts +36 -5
  262. package/dist/skill-pack-state.js +273 -29
  263. package/dist/snapshot-store.js +5 -25
  264. package/dist/stores/json-store.d.ts +11 -0
  265. package/dist/stores/json-store.js +42 -0
  266. package/dist/sync/local-agent-telemetry.d.ts +13 -0
  267. package/dist/sync/local-agent-telemetry.js +128 -0
  268. package/dist/sync/outbox-replay.d.ts +55 -0
  269. package/dist/sync/outbox-replay.js +621 -0
  270. package/dist/team-context-store.d.ts +23 -0
  271. package/dist/team-context-store.js +116 -0
  272. package/dist/telemetry/posthog.js +4 -2
  273. package/dist/tools/core-tools.d.ts +72 -0
  274. package/dist/tools/core-tools.js +2270 -0
  275. package/dist/types.d.ts +2 -0
  276. package/dist/types.js +2 -0
  277. package/dist/worker-supervisor.js +23 -0
  278. package/package.json +14 -4
  279. package/dashboard/dist/assets/B3ziCA02.js +0 -8
  280. package/dashboard/dist/assets/BNeJ0kpF.js +0 -1
  281. package/dashboard/dist/assets/BzkiMPmM.js +0 -215
  282. package/dashboard/dist/assets/CUV9IHHi.js +0 -1
  283. package/dashboard/dist/assets/Ie7d9Iq2.css +0 -1
  284. package/dashboard/dist/assets/sAhvFnpk.js +0 -4
@@ -0,0 +1,102 @@
1
+ export function registerOrgxCli(deps) {
2
+ deps.registerCli(({ program }) => {
3
+ const cmd = program.command("orgx").description("OrgX integration commands");
4
+ cmd
5
+ .command("status")
6
+ .description("Show current OrgX org status")
7
+ .action(async () => {
8
+ try {
9
+ const snap = await deps.client.getOrgSnapshot();
10
+ console.log(deps.formatSnapshot(snap));
11
+ }
12
+ catch (err) {
13
+ console.error(`Error: ${err instanceof Error ? err.message : err}`);
14
+ process.exit(1);
15
+ }
16
+ });
17
+ cmd
18
+ .command("sync")
19
+ .description("Trigger manual memory sync")
20
+ .option("--memory <text>", "Memory to push")
21
+ .option("--daily-log <text>", "Daily log to push")
22
+ .option("--agents-json <json>", "JSON array of local agent states to include (id,name,domain,status)")
23
+ .action(async (opts = {}) => {
24
+ try {
25
+ let agents;
26
+ if (typeof opts.agentsJson === "string" && opts.agentsJson.trim().length > 0) {
27
+ const parsed = JSON.parse(opts.agentsJson);
28
+ if (!Array.isArray(parsed)) {
29
+ throw new Error("--agents-json must be a JSON array");
30
+ }
31
+ agents = parsed;
32
+ }
33
+ const resp = await deps.client.syncMemory({
34
+ memory: opts.memory,
35
+ dailyLog: opts.dailyLog,
36
+ agents,
37
+ });
38
+ console.log("Sync complete:");
39
+ console.log(` Initiatives: ${resp.initiatives?.length ?? 0}`);
40
+ console.log(` Agents: ${resp.agents?.length ?? 0}`);
41
+ console.log(` Active tasks: ${resp.activeTasks?.length ?? 0}`);
42
+ console.log(` Pending decisions: ${resp.pendingDecisions?.length ?? 0}`);
43
+ }
44
+ catch (err) {
45
+ console.error(`Sync failed: ${err instanceof Error ? err.message : err}`);
46
+ process.exit(1);
47
+ }
48
+ });
49
+ cmd
50
+ .command("doctor")
51
+ .description("Run plugin diagnostics and connectivity checks")
52
+ .option("--json", "Print the report as JSON")
53
+ .option("--no-remote", "Skip remote OrgX API reachability probe")
54
+ .action(async (opts = {}) => {
55
+ try {
56
+ const report = await deps.buildHealthReport({
57
+ probeRemote: opts.remote !== false,
58
+ });
59
+ if (opts.json) {
60
+ console.log(JSON.stringify(report, null, 2));
61
+ if (!report.ok)
62
+ process.exit(1);
63
+ return;
64
+ }
65
+ console.log("OrgX Doctor");
66
+ console.log(` Status: ${report.status.toUpperCase()}`);
67
+ console.log(` Plugin: v${report.plugin.version}`);
68
+ console.log(` Base URL: ${report.plugin.baseUrl}`);
69
+ console.log(` API Key Source: ${deps.apiKeySourceLabel(report.auth.keySource)}`);
70
+ console.log(` Outbox Pending: ${report.outbox.pendingTotal}`);
71
+ console.log("");
72
+ console.log("Checks:");
73
+ for (const check of report.checks) {
74
+ const prefix = check.status === "pass"
75
+ ? "[PASS]"
76
+ : check.status === "warn"
77
+ ? "[WARN]"
78
+ : "[FAIL]";
79
+ console.log(` ${prefix} ${check.message}`);
80
+ }
81
+ if (report.remote.enabled) {
82
+ if (report.remote.reachable === true) {
83
+ console.log(` Remote probe latency: ${report.remote.latencyMs ?? "?"}ms`);
84
+ }
85
+ else if (report.remote.reachable === false) {
86
+ console.log(` Remote probe error: ${report.remote.error ?? "Unknown error"}`);
87
+ }
88
+ else {
89
+ console.log(" Remote probe: skipped");
90
+ }
91
+ }
92
+ if (!report.ok) {
93
+ process.exit(1);
94
+ }
95
+ }
96
+ catch (err) {
97
+ console.error(`Doctor failed: ${err instanceof Error ? err.message : err}`);
98
+ process.exit(1);
99
+ }
100
+ });
101
+ }, { commands: ["orgx"] });
102
+ }
@@ -0,0 +1,32 @@
1
+ import type { OnboardingState } from "../types.js";
2
+ import type { PluginApiLike, ResolvedConfig } from "./resolution.js";
3
+ type AuthStoreState = {
4
+ apiKey?: string | null;
5
+ userId?: string | null;
6
+ } | null;
7
+ type RefreshInput = {
8
+ reason?: string;
9
+ allowApiKeyChanges?: boolean;
10
+ };
11
+ type RefreshDeps = {
12
+ api: PluginApiLike;
13
+ config: ResolvedConfig;
14
+ loadAuthStore: () => AuthStoreState;
15
+ resolveConfig: (api: PluginApiLike, input: {
16
+ installationId: string;
17
+ persistedApiKey: string | null;
18
+ persistedUserId: string | null;
19
+ }) => ResolvedConfig;
20
+ updateOnboardingState: (updates: Partial<OnboardingState>) => unknown;
21
+ setCredentials: (input: {
22
+ apiKey: string;
23
+ userId: string;
24
+ baseUrl: string;
25
+ }) => void;
26
+ logInfo?: (message: string, meta?: Record<string, unknown>) => void;
27
+ };
28
+ export declare function refreshResolvedConfig(deps: RefreshDeps, input?: RefreshInput): {
29
+ changed: boolean;
30
+ baseApiUrl: string;
31
+ };
32
+ export {};
@@ -0,0 +1,55 @@
1
+ export function refreshResolvedConfig(deps, input) {
2
+ const allowApiKeyChanges = input?.allowApiKeyChanges !== false;
3
+ const previousApiKey = deps.config.apiKey;
4
+ const previousBaseUrl = deps.config.baseUrl;
5
+ const previousUserId = deps.config.userId;
6
+ const previousDocsUrl = deps.config.docsUrl;
7
+ const previousKeySource = deps.config.apiKeySource;
8
+ const latestPersisted = deps.loadAuthStore();
9
+ const next = deps.resolveConfig(deps.api, {
10
+ installationId: deps.config.installationId,
11
+ persistedApiKey: latestPersisted?.apiKey ?? null,
12
+ persistedUserId: latestPersisted?.userId ?? null,
13
+ });
14
+ const nextApiKey = allowApiKeyChanges ? next.apiKey : previousApiKey;
15
+ const nextUserId = allowApiKeyChanges ? next.userId : previousUserId;
16
+ const changed = nextApiKey !== previousApiKey ||
17
+ next.baseUrl !== previousBaseUrl ||
18
+ nextUserId !== previousUserId ||
19
+ next.docsUrl !== previousDocsUrl ||
20
+ next.apiKeySource !== previousKeySource;
21
+ if (!changed) {
22
+ return {
23
+ changed: false,
24
+ baseApiUrl: deps.config.baseUrl.replace(/\/+$/, ""),
25
+ };
26
+ }
27
+ if (allowApiKeyChanges) {
28
+ deps.config.apiKey = nextApiKey;
29
+ deps.config.userId = nextUserId;
30
+ deps.config.apiKeySource = next.apiKeySource;
31
+ }
32
+ deps.config.baseUrl = next.baseUrl;
33
+ deps.config.docsUrl = next.docsUrl;
34
+ deps.setCredentials({
35
+ apiKey: deps.config.apiKey,
36
+ userId: deps.config.userId,
37
+ baseUrl: deps.config.baseUrl,
38
+ });
39
+ deps.updateOnboardingState({
40
+ hasApiKey: Boolean(deps.config.apiKey),
41
+ keySource: deps.config.apiKeySource,
42
+ docsUrl: deps.config.docsUrl,
43
+ installationId: deps.config.installationId,
44
+ });
45
+ deps.logInfo?.("[orgx] Config refreshed", {
46
+ reason: input?.reason ?? "runtime_refresh",
47
+ baseUrl: deps.config.baseUrl,
48
+ hasApiKey: Boolean(deps.config.apiKey),
49
+ apiKeySource: deps.config.apiKeySource,
50
+ });
51
+ return {
52
+ changed: true,
53
+ baseApiUrl: deps.config.baseUrl.replace(/\/+$/, ""),
54
+ };
55
+ }
@@ -0,0 +1,37 @@
1
+ import type { OrgXConfig } from "../types.js";
2
+ export interface ResolvedConfig extends OrgXConfig {
3
+ dashboardEnabled: boolean;
4
+ installationId: string;
5
+ pluginVersion: string;
6
+ docsUrl: string;
7
+ apiKeySource: "config" | "environment" | "persisted" | "openclaw-config-file" | "legacy-dev" | "none";
8
+ }
9
+ export interface PluginApiLike {
10
+ config?: {
11
+ plugins?: {
12
+ entries?: {
13
+ orgx?: {
14
+ config?: Partial<OrgXConfig & {
15
+ dashboardEnabled: boolean;
16
+ }>;
17
+ };
18
+ };
19
+ };
20
+ };
21
+ }
22
+ export declare function isUserScopedApiKey(apiKey: string): boolean;
23
+ export declare function resolveRuntimeUserId(apiKey: string, candidates: Array<string | null | undefined>): string;
24
+ export declare function normalizeBaseUrl(raw: string | undefined): string;
25
+ export declare function readLegacyEnvValue(keyPattern: RegExp): string;
26
+ export declare function readOpenClawOrgxConfig(): {
27
+ apiKey: string;
28
+ userId: string;
29
+ baseUrl: string;
30
+ };
31
+ export declare function resolvePluginVersion(): string;
32
+ export declare function resolveDocsUrl(baseUrl: string): string;
33
+ export declare function resolveConfig(api: PluginApiLike, input: {
34
+ installationId: string;
35
+ persistedApiKey: string | null;
36
+ persistedUserId: string | null;
37
+ }): ResolvedConfig;
@@ -0,0 +1,178 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ const DEFAULT_BASE_URL = "https://www.useorgx.com";
6
+ const DEFAULT_DOCS_URL = "https://orgx.mintlify.site/guides/openclaw-plugin-setup";
7
+ export function isUserScopedApiKey(apiKey) {
8
+ return apiKey.trim().toLowerCase().startsWith("oxk_");
9
+ }
10
+ export function resolveRuntimeUserId(apiKey, candidates) {
11
+ if (isUserScopedApiKey(apiKey)) {
12
+ // For oxk_ keys, the OrgX API ignores X-Orgx-User-Id, but we still keep a UUID
13
+ // around for created_by_id on certain entity writes (e.g., work_artifacts).
14
+ for (const candidate of candidates) {
15
+ if (typeof candidate !== "string")
16
+ continue;
17
+ const trimmed = candidate.trim();
18
+ if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(trimmed)) {
19
+ return trimmed;
20
+ }
21
+ }
22
+ return "";
23
+ }
24
+ for (const candidate of candidates) {
25
+ if (typeof candidate === "string") {
26
+ const trimmed = candidate.trim();
27
+ if (trimmed.length > 0)
28
+ return trimmed;
29
+ }
30
+ }
31
+ return "";
32
+ }
33
+ function normalizeHost(value) {
34
+ return value.trim().toLowerCase().replace(/^\[|\]$/g, "");
35
+ }
36
+ function isLoopbackHostname(hostname) {
37
+ const normalized = normalizeHost(hostname);
38
+ return normalized === "localhost" || normalized === "127.0.0.1" || normalized === "::1";
39
+ }
40
+ export function normalizeBaseUrl(raw) {
41
+ const candidate = raw?.trim() ?? "";
42
+ if (!candidate) {
43
+ return DEFAULT_BASE_URL;
44
+ }
45
+ try {
46
+ const parsed = new URL(candidate);
47
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
48
+ return DEFAULT_BASE_URL;
49
+ }
50
+ // Do not allow credential-bearing URLs.
51
+ if (parsed.username || parsed.password) {
52
+ return DEFAULT_BASE_URL;
53
+ }
54
+ // Plain HTTP is only allowed for local loopback development.
55
+ if (parsed.protocol === "http:" && !isLoopbackHostname(parsed.hostname)) {
56
+ return DEFAULT_BASE_URL;
57
+ }
58
+ parsed.search = "";
59
+ parsed.hash = "";
60
+ const normalizedPath = parsed.pathname.replace(/\/+$/, "");
61
+ parsed.pathname = normalizedPath;
62
+ const normalized = parsed.toString().replace(/\/+$/, "");
63
+ return normalized.length > 0 ? normalized : DEFAULT_BASE_URL;
64
+ }
65
+ catch {
66
+ return DEFAULT_BASE_URL;
67
+ }
68
+ }
69
+ export function readLegacyEnvValue(keyPattern) {
70
+ try {
71
+ const envPath = join(homedir(), "Code", "orgx", "orgx", ".env.local");
72
+ const envContent = readFileSync(envPath, "utf-8");
73
+ const match = envContent.match(keyPattern);
74
+ return match?.[1]?.trim() ?? "";
75
+ }
76
+ catch {
77
+ return "";
78
+ }
79
+ }
80
+ export function readOpenClawOrgxConfig() {
81
+ try {
82
+ const configPath = join(homedir(), ".openclaw", "openclaw.json");
83
+ const raw = readFileSync(configPath, "utf8");
84
+ const parsed = JSON.parse(raw);
85
+ const plugins = parsed.plugins && typeof parsed.plugins === "object"
86
+ ? parsed.plugins
87
+ : {};
88
+ const entries = plugins.entries && typeof plugins.entries === "object"
89
+ ? plugins.entries
90
+ : {};
91
+ const orgx = entries.orgx && typeof entries.orgx === "object"
92
+ ? entries.orgx
93
+ : {};
94
+ const config = orgx.config && typeof orgx.config === "object"
95
+ ? orgx.config
96
+ : {};
97
+ const apiKey = typeof config.apiKey === "string" ? config.apiKey.trim() : "";
98
+ const userId = typeof config.userId === "string" ? config.userId.trim() : "";
99
+ const baseUrl = typeof config.baseUrl === "string" ? config.baseUrl.trim() : "";
100
+ return { apiKey, userId, baseUrl };
101
+ }
102
+ catch {
103
+ return { apiKey: "", userId: "", baseUrl: "" };
104
+ }
105
+ }
106
+ function resolveApiKey(pluginConf, persistedApiKey) {
107
+ if (pluginConf.apiKey && pluginConf.apiKey.trim().length > 0) {
108
+ return { value: pluginConf.apiKey.trim(), source: "config" };
109
+ }
110
+ if (process.env.ORGX_API_KEY && process.env.ORGX_API_KEY.trim().length > 0) {
111
+ return { value: process.env.ORGX_API_KEY.trim(), source: "environment" };
112
+ }
113
+ if (persistedApiKey && persistedApiKey.trim().length > 0) {
114
+ return { value: persistedApiKey.trim(), source: "persisted" };
115
+ }
116
+ const openclaw = readOpenClawOrgxConfig();
117
+ if (openclaw.apiKey) {
118
+ return { value: openclaw.apiKey, source: "openclaw-config-file" };
119
+ }
120
+ // For local dev convenience we read `ORGX_API_KEY` from `~/Code/orgx/orgx/.env.local`.
121
+ // Do not auto-consume `ORGX_SERVICE_KEY` because service keys often require `X-Orgx-User-Id`,
122
+ // and the dashboard/client flows are intended to run on user-scoped keys (`oxk_...`).
123
+ const legacy = readLegacyEnvValue(/^ORGX_API_KEY=["']?([^"'\n]+)["']?$/m);
124
+ if (legacy) {
125
+ return { value: legacy, source: "legacy-dev" };
126
+ }
127
+ return { value: "", source: "none" };
128
+ }
129
+ export function resolvePluginVersion() {
130
+ try {
131
+ const packagePath = fileURLToPath(new URL("../../package.json", import.meta.url));
132
+ const parsed = JSON.parse(readFileSync(packagePath, "utf8"));
133
+ return parsed.version && parsed.version.trim().length > 0 ? parsed.version : "dev";
134
+ }
135
+ catch {
136
+ return "dev";
137
+ }
138
+ }
139
+ export function resolveDocsUrl(baseUrl) {
140
+ const normalized = baseUrl.replace(/\/+$/, "");
141
+ try {
142
+ const parsed = new URL(normalized);
143
+ if (isLoopbackHostname(parsed.hostname)) {
144
+ return `${normalized}/docs/mintlify/guides/openclaw-plugin-setup`;
145
+ }
146
+ }
147
+ catch {
148
+ return DEFAULT_DOCS_URL;
149
+ }
150
+ return DEFAULT_DOCS_URL;
151
+ }
152
+ export function resolveConfig(api, input) {
153
+ const pluginConf = api.config?.plugins?.entries?.orgx?.config ?? {};
154
+ const openclaw = readOpenClawOrgxConfig();
155
+ const apiKeyResolution = resolveApiKey(pluginConf, input.persistedApiKey);
156
+ const apiKey = apiKeyResolution.value;
157
+ const userId = resolveRuntimeUserId(apiKey, [
158
+ pluginConf.userId,
159
+ process.env.ORGX_USER_ID,
160
+ input.persistedUserId,
161
+ openclaw.userId,
162
+ readLegacyEnvValue(/^ORGX_USER_ID=["']?([^"'\n]+)["']?$/m),
163
+ ]);
164
+ const baseUrl = normalizeBaseUrl(pluginConf.baseUrl || process.env.ORGX_BASE_URL || openclaw.baseUrl || DEFAULT_BASE_URL);
165
+ return {
166
+ apiKey,
167
+ userId,
168
+ baseUrl,
169
+ syncIntervalMs: pluginConf.syncIntervalMs ?? 300_000,
170
+ enabled: pluginConf.enabled ?? true,
171
+ autoInstallAgentSuiteOnConnect: pluginConf.autoInstallAgentSuiteOnConnect ?? true,
172
+ dashboardEnabled: pluginConf.dashboardEnabled ?? true,
173
+ installationId: input.installationId,
174
+ pluginVersion: resolvePluginVersion(),
175
+ docsUrl: resolveDocsUrl(baseUrl),
176
+ apiKeySource: apiKeyResolution.source,
177
+ };
178
+ }
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Uses native fetch — no external dependencies.
8
8
  */
9
- import type { OrgSnapshot, SyncPayload, SyncResponse, SpawnGuardResult, QualityScore, Entity, EntityListFilters, EmitActivityRequest, EmitActivityResponse, ApplyChangesetRequest, ApplyChangesetResponse, RecordRunOutcomeRequest, RecordRunOutcomeResponse, RecordRunRetroRequest, RecordRunRetroResponse, LiveActivityItem, SessionTreeResponse, HandoffSummary, CheckpointSummary, RestoreRequest, DelegationPreflightResult, BillingStatus, BillingCheckoutRequest, BillingUrlResult, KickoffContextRequest, KickoffContextResponse, SkillPack } from "./types.js";
9
+ import type { OrgSnapshot, SyncPayload, SyncResponse, SpawnGuardResult, QualityScore, Entity, EntityListFilters, EmitActivityRequest, EmitActivityResponse, ApplyChangesetRequest, ApplyChangesetResponse, RecordRunOutcomeRequest, RecordRunOutcomeResponse, RecordRunRetroRequest, RecordRunRetroResponse, LiveActivityItem, SessionTreeResponse, HandoffSummary, EntityUpdateResult, CheckpointSummary, RestoreRequest, DelegationPreflightResult, BillingStatus, BillingCheckoutRequest, BillingUrlResult, UsageControlPlaneSummary, KickoffContextRequest, KickoffContextResponse, SkillPack, ClientRuntimeSettingsResponse, ClientRuntimeSettingsUpdateRequest } from "./types.js";
10
10
  export type DecisionAction = "approve" | "reject";
11
11
  export type RunAction = "pause" | "resume" | "cancel" | "rollback";
12
12
  export interface DecisionActionResult {
@@ -15,6 +15,10 @@ export interface DecisionActionResult {
15
15
  entity?: Entity;
16
16
  error?: string;
17
17
  }
18
+ export interface DecisionMutationInput {
19
+ note?: string;
20
+ optionId?: string;
21
+ }
18
22
  export declare class OrgXClient {
19
23
  private apiKey;
20
24
  private baseUrl;
@@ -40,6 +44,7 @@ export declare class OrgXClient {
40
44
  private post;
41
45
  private patch;
42
46
  private buildQuery;
47
+ private unwrapSyncResponse;
43
48
  getOrgSnapshot(): Promise<OrgSnapshot>;
44
49
  syncMemory(payload: SyncPayload): Promise<SyncResponse>;
45
50
  getKickoffContext(payload: KickoffContextRequest): Promise<KickoffContextResponse>;
@@ -61,6 +66,12 @@ export declare class OrgXClient {
61
66
  status: number;
62
67
  error: string;
63
68
  }>;
69
+ getClientAgentRuntimeSettings(input?: {
70
+ workspaceId?: string | null;
71
+ /** Legacy alias retained for backward compatibility */
72
+ projectId?: string | null;
73
+ }): Promise<ClientRuntimeSettingsResponse>;
74
+ updateClientAgentRuntimeSettings(payload: ClientRuntimeSettingsUpdateRequest): Promise<ClientRuntimeSettingsResponse>;
64
75
  delegationPreflight(payload: {
65
76
  intent: string;
66
77
  acceptanceCriteria?: string[];
@@ -84,6 +95,11 @@ export declare class OrgXClient {
84
95
  * PATCH /api/entities { type, id, ...updates }
85
96
  */
86
97
  updateEntity(type: string, id: string, updates: Record<string, unknown>): Promise<Entity>;
98
+ /**
99
+ * Update an OrgX entity and preserve reassignment metadata when present.
100
+ * PATCH /api/entities { type, id, ...updates }
101
+ */
102
+ updateEntityDetailed(type: string, id: string, updates: Record<string, unknown>): Promise<EntityUpdateResult>;
87
103
  /**
88
104
  * List OrgX entities.
89
105
  * GET /api/entities?type={type}&status={status}&limit={n}
@@ -98,6 +114,9 @@ export declare class OrgXClient {
98
114
  getBillingStatus(): Promise<BillingStatus>;
99
115
  createBillingCheckout(payload: BillingCheckoutRequest): Promise<BillingUrlResult>;
100
116
  createBillingPortal(): Promise<BillingUrlResult>;
117
+ getUsageControlPlaneSummary(): Promise<UsageControlPlaneSummary>;
118
+ getUsageUnified(): Promise<UsageControlPlaneSummary>;
119
+ getUsageForecast(): Promise<Pick<UsageControlPlaneSummary, "generatedAt" | "period" | "predicted" | "risk" | "headroom" | "utilization">>;
101
120
  emitActivity(payload: EmitActivityRequest): Promise<EmitActivityResponse>;
102
121
  applyChangeset(payload: ApplyChangesetRequest): Promise<ApplyChangesetResponse>;
103
122
  recordRunOutcome(payload: RecordRunOutcomeRequest): Promise<RecordRunOutcomeResponse>;
@@ -105,11 +124,17 @@ export declare class OrgXClient {
105
124
  getLiveSessions(params?: {
106
125
  limit?: number;
107
126
  initiative?: string | null;
127
+ workspaceId?: string | null;
128
+ /** @deprecated Use workspaceId */
129
+ projectId?: string | null;
108
130
  }): Promise<SessionTreeResponse>;
109
131
  getLiveActivity(params?: {
110
132
  limit?: number;
111
133
  run?: string | null;
112
134
  since?: string | null;
135
+ workspaceId?: string | null;
136
+ /** @deprecated Use workspaceId */
137
+ projectId?: string | null;
113
138
  }): Promise<{
114
139
  activities: LiveActivityItem[];
115
140
  total: number;
@@ -117,6 +142,9 @@ export declare class OrgXClient {
117
142
  getLiveAgents(params?: {
118
143
  initiative?: string | null;
119
144
  includeIdle?: boolean;
145
+ workspaceId?: string | null;
146
+ /** @deprecated Use workspaceId */
147
+ projectId?: string | null;
120
148
  }): Promise<{
121
149
  agents: unknown[];
122
150
  summary: Record<string, number>;
@@ -124,9 +152,18 @@ export declare class OrgXClient {
124
152
  getLiveInitiatives(params?: {
125
153
  id?: string | null;
126
154
  limit?: number;
155
+ offset?: number;
156
+ workspaceId?: string | null;
157
+ /** @deprecated Use workspaceId */
158
+ projectId?: string | null;
127
159
  }): Promise<{
128
160
  initiatives: unknown[];
129
161
  total: number;
162
+ pagination?: {
163
+ limit?: number;
164
+ offset?: number;
165
+ has_more?: boolean;
166
+ };
130
167
  }>;
131
168
  getHandoffs(): Promise<{
132
169
  handoffs: HandoffSummary[];
@@ -166,10 +203,13 @@ export declare class OrgXClient {
166
203
  getLiveDecisions(params?: {
167
204
  status?: string;
168
205
  limit?: number;
206
+ workspaceId?: string | null;
207
+ /** @deprecated Use workspaceId */
208
+ projectId?: string | null;
169
209
  }): Promise<{
170
210
  decisions: Entity[];
171
211
  total: number;
172
212
  }>;
173
- decideDecision(id: string, action: DecisionAction, note?: string): Promise<Entity>;
174
- bulkDecideDecisions(ids: string[], action: DecisionAction, note?: string): Promise<DecisionActionResult[]>;
213
+ decideDecision(id: string, action: DecisionAction, input?: DecisionMutationInput): Promise<Entity>;
214
+ bulkDecideDecisions(ids: string[], action: DecisionAction, input?: DecisionMutationInput): Promise<DecisionActionResult[]>;
175
215
  }