@useorgx/openclaw-plugin 0.4.9 → 0.7.2

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 (224) hide show
  1. package/README.md +77 -11
  2. package/dashboard/dist/assets/6mILZQ2a.js +1 -0
  3. package/dashboard/dist/assets/6mILZQ2a.js.br +0 -0
  4. package/dashboard/dist/assets/6mILZQ2a.js.gz +0 -0
  5. package/dashboard/dist/assets/8dksYiq4.js +2 -0
  6. package/dashboard/dist/assets/8dksYiq4.js.br +0 -0
  7. package/dashboard/dist/assets/8dksYiq4.js.gz +0 -0
  8. package/dashboard/dist/assets/B5zYRHc3.js +1 -0
  9. package/dashboard/dist/assets/B5zYRHc3.js.br +0 -0
  10. package/dashboard/dist/assets/B5zYRHc3.js.gz +0 -0
  11. package/dashboard/dist/assets/B6wPWJ35.js +1 -0
  12. package/dashboard/dist/assets/B6wPWJ35.js.br +0 -0
  13. package/dashboard/dist/assets/B6wPWJ35.js.gz +0 -0
  14. package/dashboard/dist/assets/BJgZIVUQ.js +53 -0
  15. package/dashboard/dist/assets/BJgZIVUQ.js.br +0 -0
  16. package/dashboard/dist/assets/BJgZIVUQ.js.gz +0 -0
  17. package/dashboard/dist/assets/BWEwjt1W.js +1 -0
  18. package/dashboard/dist/assets/BWEwjt1W.js.br +0 -0
  19. package/dashboard/dist/assets/BWEwjt1W.js.gz +0 -0
  20. package/dashboard/dist/assets/BgOYB78t.js +4 -0
  21. package/dashboard/dist/assets/BgOYB78t.js.br +0 -0
  22. package/dashboard/dist/assets/BgOYB78t.js.gz +0 -0
  23. package/dashboard/dist/assets/BzRbDCAD.css +1 -0
  24. package/dashboard/dist/assets/BzRbDCAD.css.br +0 -0
  25. package/dashboard/dist/assets/BzRbDCAD.css.gz +0 -0
  26. package/dashboard/dist/assets/C-KIc3Wc.js.br +0 -0
  27. package/dashboard/dist/assets/C-KIc3Wc.js.gz +0 -0
  28. package/dashboard/dist/assets/C8uM3AX8.js +1 -0
  29. package/dashboard/dist/assets/C8uM3AX8.js.br +0 -0
  30. package/dashboard/dist/assets/C8uM3AX8.js.gz +0 -0
  31. package/dashboard/dist/assets/C9jy61eu.js +212 -0
  32. package/dashboard/dist/assets/C9jy61eu.js.br +0 -0
  33. package/dashboard/dist/assets/C9jy61eu.js.gz +0 -0
  34. package/dashboard/dist/assets/CC63EwFD.js +1 -0
  35. package/dashboard/dist/assets/CC63EwFD.js.br +0 -0
  36. package/dashboard/dist/assets/CC63EwFD.js.gz +0 -0
  37. package/dashboard/dist/assets/CL_wXqR7.js +1 -0
  38. package/dashboard/dist/assets/CL_wXqR7.js.br +0 -0
  39. package/dashboard/dist/assets/CL_wXqR7.js.gz +0 -0
  40. package/dashboard/dist/assets/CZaT3ob_.js +1 -0
  41. package/dashboard/dist/assets/CZaT3ob_.js.br +0 -0
  42. package/dashboard/dist/assets/CZaT3ob_.js.gz +0 -0
  43. package/dashboard/dist/assets/CgaottFX.js +1 -0
  44. package/dashboard/dist/assets/CgaottFX.js.br +0 -0
  45. package/dashboard/dist/assets/CgaottFX.js.gz +0 -0
  46. package/dashboard/dist/assets/{CpJsfbXo.js → CxQ08qFN.js} +2 -2
  47. package/dashboard/dist/assets/CxQ08qFN.js.br +0 -0
  48. package/dashboard/dist/assets/CxQ08qFN.js.gz +0 -0
  49. package/dashboard/dist/assets/CzCxAZlW.js +1 -0
  50. package/dashboard/dist/assets/CzCxAZlW.js.br +0 -0
  51. package/dashboard/dist/assets/CzCxAZlW.js.gz +0 -0
  52. package/dashboard/dist/assets/D3iMTYEj.js +1 -0
  53. package/dashboard/dist/assets/D3iMTYEj.js.br +0 -0
  54. package/dashboard/dist/assets/D3iMTYEj.js.gz +0 -0
  55. package/dashboard/dist/assets/D8JNX8kq.js +2 -0
  56. package/dashboard/dist/assets/D8JNX8kq.js.br +0 -0
  57. package/dashboard/dist/assets/D8JNX8kq.js.gz +0 -0
  58. package/dashboard/dist/assets/DnA8dpj6.js +1 -0
  59. package/dashboard/dist/assets/DnA8dpj6.js.br +0 -0
  60. package/dashboard/dist/assets/DnA8dpj6.js.gz +0 -0
  61. package/dashboard/dist/assets/IUexzymk.js +1 -0
  62. package/dashboard/dist/assets/IUexzymk.js.br +0 -0
  63. package/dashboard/dist/assets/IUexzymk.js.gz +0 -0
  64. package/dashboard/dist/assets/cNrhgGc1.js +8 -0
  65. package/dashboard/dist/assets/cNrhgGc1.js.br +0 -0
  66. package/dashboard/dist/assets/cNrhgGc1.js.gz +0 -0
  67. package/dashboard/dist/assets/ic2FaMnh.js +1 -0
  68. package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
  69. package/dashboard/dist/assets/ic2FaMnh.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/rttbDbEx.js +1 -0
  74. package/dashboard/dist/assets/rttbDbEx.js.br +0 -0
  75. package/dashboard/dist/assets/rttbDbEx.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 +34 -8
  88. package/dist/agent-context-store.js +79 -17
  89. package/dist/agent-run-store.js +44 -3
  90. package/dist/agent-suite.d.ts +9 -0
  91. package/dist/agent-suite.js +149 -9
  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/chat-store.d.ts +157 -0
  97. package/dist/chat-store.js +586 -0
  98. package/dist/cli/orgx.js +11 -0
  99. package/dist/contracts/client.d.ts +43 -3
  100. package/dist/contracts/client.js +159 -30
  101. package/dist/contracts/practice-exercise-schema.d.ts +216 -0
  102. package/dist/contracts/practice-exercise-schema.js +314 -0
  103. package/dist/contracts/retro-schema.d.ts +81 -0
  104. package/dist/contracts/retro-schema.js +80 -0
  105. package/dist/contracts/shared-types.d.ts +159 -0
  106. package/dist/contracts/shared-types.js +199 -1
  107. package/dist/contracts/skill-pack-schema.d.ts +192 -0
  108. package/dist/contracts/skill-pack-schema.js +180 -0
  109. package/dist/contracts/types.d.ts +247 -2
  110. package/dist/entities/auto-assignment.js +43 -17
  111. package/dist/event-sanitization.d.ts +11 -0
  112. package/dist/event-sanitization.js +113 -0
  113. package/dist/gateway-watchdog.d.ts +5 -0
  114. package/dist/gateway-watchdog.js +50 -0
  115. package/dist/hooks/post-reporting-event.mjs +1 -5
  116. package/dist/http/helpers/activity-headline.js +13 -132
  117. package/dist/http/helpers/auto-continue-engine.d.ts +198 -10
  118. package/dist/http/helpers/auto-continue-engine.js +3145 -186
  119. package/dist/http/helpers/autopilot-operations.d.ts +19 -0
  120. package/dist/http/helpers/autopilot-operations.js +182 -31
  121. package/dist/http/helpers/autopilot-runtime.d.ts +1 -0
  122. package/dist/http/helpers/autopilot-runtime.js +328 -25
  123. package/dist/http/helpers/autopilot-slice-utils.d.ts +18 -0
  124. package/dist/http/helpers/autopilot-slice-utils.js +514 -93
  125. package/dist/http/helpers/decision-mapper.d.ts +40 -0
  126. package/dist/http/helpers/decision-mapper.js +223 -7
  127. package/dist/http/helpers/dispatch-lifecycle.d.ts +19 -2
  128. package/dist/http/helpers/dispatch-lifecycle.js +242 -37
  129. package/dist/http/helpers/kickoff-context.js +104 -0
  130. package/dist/http/helpers/llm-client.d.ts +47 -0
  131. package/dist/http/helpers/llm-client.js +256 -0
  132. package/dist/http/helpers/mission-control.d.ts +102 -3
  133. package/dist/http/helpers/mission-control.js +498 -9
  134. package/dist/http/helpers/sentinel-catalog.d.ts +23 -0
  135. package/dist/http/helpers/sentinel-catalog.js +193 -0
  136. package/dist/http/helpers/session-classification.d.ts +9 -0
  137. package/dist/http/helpers/session-classification.js +564 -0
  138. package/dist/http/helpers/slice-experience-v2.d.ts +137 -0
  139. package/dist/http/helpers/slice-experience-v2.js +677 -0
  140. package/dist/http/helpers/slice-run-projections.d.ts +72 -0
  141. package/dist/http/helpers/slice-run-projections.js +877 -0
  142. package/dist/http/helpers/triage-mapper.d.ts +43 -0
  143. package/dist/http/helpers/triage-mapper.js +549 -0
  144. package/dist/http/helpers/value-utils.js +7 -2
  145. package/dist/http/helpers/workspace-scope.d.ts +15 -0
  146. package/dist/http/helpers/workspace-scope.js +170 -0
  147. package/dist/http/index.js +1420 -105
  148. package/dist/http/routes/agent-suite.d.ts +9 -0
  149. package/dist/http/routes/agent-suite.js +294 -8
  150. package/dist/http/routes/agents-catalog.js +64 -19
  151. package/dist/http/routes/chat.d.ts +19 -0
  152. package/dist/http/routes/chat.js +522 -0
  153. package/dist/http/routes/decision-actions.d.ts +8 -1
  154. package/dist/http/routes/decision-actions.js +42 -5
  155. package/dist/http/routes/dispatch-gateway-envelope.d.ts +25 -0
  156. package/dist/http/routes/dispatch-gateway-envelope.js +26 -0
  157. package/dist/http/routes/entities.d.ts +16 -0
  158. package/dist/http/routes/entities.js +232 -6
  159. package/dist/http/routes/live-legacy.d.ts +5 -0
  160. package/dist/http/routes/live-legacy.js +23 -509
  161. package/dist/http/routes/live-misc.d.ts +12 -0
  162. package/dist/http/routes/live-misc.js +251 -31
  163. package/dist/http/routes/live-snapshot.d.ts +49 -2
  164. package/dist/http/routes/live-snapshot.js +653 -23
  165. package/dist/http/routes/live-terminal.d.ts +11 -0
  166. package/dist/http/routes/live-terminal.js +154 -0
  167. package/dist/http/routes/live-triage.d.ts +61 -0
  168. package/dist/http/routes/live-triage.js +192 -0
  169. package/dist/http/routes/mission-control-actions.d.ts +49 -1
  170. package/dist/http/routes/mission-control-actions.js +1246 -84
  171. package/dist/http/routes/mission-control-read.d.ts +48 -3
  172. package/dist/http/routes/mission-control-read.js +1658 -20
  173. package/dist/http/routes/realtime-orchestrator.d.ts +10 -0
  174. package/dist/http/routes/realtime-orchestrator.js +74 -0
  175. package/dist/http/routes/run-control.d.ts +5 -2
  176. package/dist/http/routes/run-control.js +10 -0
  177. package/dist/http/routes/sentinels-catalog.d.ts +7 -0
  178. package/dist/http/routes/sentinels-catalog.js +24 -0
  179. package/dist/http/routes/summary.js +10 -3
  180. package/dist/http/routes/usage.d.ts +24 -0
  181. package/dist/http/routes/usage.js +362 -0
  182. package/dist/http/routes/work-artifacts.js +28 -9
  183. package/dist/index.js +165 -27
  184. package/dist/local-openclaw.js +29 -6
  185. package/dist/mcp-client-setup.js +3 -3
  186. package/dist/mcp-http-handler.d.ts +3 -0
  187. package/dist/mcp-http-handler.js +34 -60
  188. package/dist/next-up-queue-store.d.ts +16 -1
  189. package/dist/next-up-queue-store.js +89 -7
  190. package/dist/outbox.d.ts +5 -0
  191. package/dist/outbox.js +113 -9
  192. package/dist/paths.js +36 -5
  193. package/dist/reporting/rollups.d.ts +41 -0
  194. package/dist/reporting/rollups.js +113 -0
  195. package/dist/retro/domain-templates.d.ts +45 -0
  196. package/dist/retro/domain-templates.js +297 -0
  197. package/dist/retro/quality-rubric.d.ts +33 -0
  198. package/dist/retro/quality-rubric.js +213 -0
  199. package/dist/runtime-cleanup.d.ts +18 -0
  200. package/dist/runtime-cleanup.js +87 -0
  201. package/dist/services/background.d.ts +11 -0
  202. package/dist/services/background.js +22 -0
  203. package/dist/services/experiment-randomization.d.ts +21 -0
  204. package/dist/services/experiment-randomization.js +63 -0
  205. package/dist/skill-pack-state.d.ts +36 -5
  206. package/dist/skill-pack-state.js +273 -29
  207. package/dist/sync/local-agent-telemetry.d.ts +13 -0
  208. package/dist/sync/local-agent-telemetry.js +128 -0
  209. package/dist/sync/outbox-replay.js +131 -24
  210. package/dist/team-context-store.d.ts +23 -0
  211. package/dist/team-context-store.js +116 -0
  212. package/dist/telemetry/posthog.js +4 -2
  213. package/dist/tools/core-tools.d.ts +10 -14
  214. package/dist/tools/core-tools.js +1289 -24
  215. package/dist/types.d.ts +2 -0
  216. package/dist/types.js +2 -0
  217. package/dist/worker-supervisor.js +23 -0
  218. package/package.json +20 -6
  219. package/dashboard/dist/assets/B3ziCA02.js +0 -8
  220. package/dashboard/dist/assets/B5NEElEI.css +0 -1
  221. package/dashboard/dist/assets/BhapSNAs.js +0 -215
  222. package/dashboard/dist/assets/iFdvE7lx.js +0 -1
  223. package/dashboard/dist/assets/jRJsmpYM.js +0 -1
  224. package/dashboard/dist/assets/sAhvFnpk.js +0 -4
@@ -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
  }
@@ -12,6 +12,12 @@ const DEFAULT_SYNC_TIMEOUT_MS = 45_000;
12
12
  const USER_AGENT = "OrgX-Clawdbot-Plugin/1.0";
13
13
  const DECISION_MUTATION_CONCURRENCY = 6;
14
14
  const DEFAULT_CLIENT_BASE_URL = "https://www.useorgx.com";
15
+ function normalizeAgentStatus(value) {
16
+ if (value === "active" || value === "idle" || value === "throttled") {
17
+ return value;
18
+ }
19
+ return "idle";
20
+ }
15
21
  function isUserScopedApiKey(apiKey) {
16
22
  return apiKey.trim().toLowerCase().startsWith("oxk_");
17
23
  }
@@ -184,21 +190,42 @@ export class OrgXClient {
184
190
  }
185
191
  return `?${search.toString()}`;
186
192
  }
193
+ unwrapSyncResponse(response) {
194
+ if (response &&
195
+ typeof response === "object" &&
196
+ "data" in response &&
197
+ response.data) {
198
+ return response.data;
199
+ }
200
+ return response;
201
+ }
187
202
  // ===========================================================================
188
203
  // Org Snapshot
189
204
  // ===========================================================================
190
205
  async getOrgSnapshot() {
191
206
  // Use the sync endpoint with POST (empty body = pull only)
192
207
  const resp = await this.post("/api/client/sync", {});
193
- const data = resp.data;
208
+ const data = this.unwrapSyncResponse(resp);
194
209
  // Transform SyncResponse to OrgSnapshot format
210
+ const syncAgents = Array.isArray(data.agents) ? data.agents : [];
195
211
  return {
196
212
  initiatives: data.initiatives.map(i => ({
197
213
  id: i.id,
198
214
  title: i.title,
199
215
  status: i.status,
200
216
  })),
201
- agents: [], // Not returned by sync endpoint
217
+ agents: syncAgents.map((agent) => ({
218
+ id: String(agent.id ?? ""),
219
+ name: String(agent.name ?? ""),
220
+ domain: String(agent.domain ?? ""),
221
+ status: normalizeAgentStatus(agent.status),
222
+ currentTask: typeof agent.currentTask === "string" && agent.currentTask.trim().length > 0
223
+ ? agent.currentTask
224
+ : undefined,
225
+ lastActive: typeof agent.lastActive === "string" && agent.lastActive.trim().length > 0
226
+ ? agent.lastActive
227
+ : undefined,
228
+ })),
202
229
  activeTasks: data.activeTasks.map(t => ({
203
230
  id: t.id,
204
231
  title: t.title,
@@ -219,13 +246,7 @@ export class OrgXClient {
219
246
  // ===========================================================================
220
247
  async syncMemory(payload) {
221
248
  const response = await this.post("/api/client/sync", payload);
222
- if (response &&
223
- typeof response === "object" &&
224
- "data" in response &&
225
- response.data) {
226
- return response.data;
227
- }
228
- return response;
249
+ return this.unwrapSyncResponse(response);
229
250
  }
230
251
  // ===========================================================================
231
252
  // Kickoff Context
@@ -293,6 +314,20 @@ export class OrgXClient {
293
314
  clearTimeout(timeout);
294
315
  }
295
316
  }
317
+ // ===========================================================================
318
+ // Client Agent Runtime Settings
319
+ // ===========================================================================
320
+ async getClientAgentRuntimeSettings(input) {
321
+ const workspaceScope = input?.workspaceId ?? input?.projectId ?? null;
322
+ const query = this.buildQuery({
323
+ workspace_id: workspaceScope,
324
+ command_center_id: workspaceScope,
325
+ });
326
+ return this.get(`/api/client/agents/runtime-settings${query}`);
327
+ }
328
+ async updateClientAgentRuntimeSettings(payload) {
329
+ return this.patch("/api/client/agents/runtime-settings", payload);
330
+ }
296
331
  async delegationPreflight(payload) {
297
332
  return this.post("/api/client/delegation/preflight", payload);
298
333
  }
@@ -351,12 +386,34 @@ export class OrgXClient {
351
386
  * PATCH /api/entities { type, id, ...updates }
352
387
  */
353
388
  async updateEntity(type, id, updates) {
389
+ const result = await this.updateEntityDetailed(type, id, updates);
390
+ return result.entity;
391
+ }
392
+ /**
393
+ * Update an OrgX entity and preserve reassignment metadata when present.
394
+ * PATCH /api/entities { type, id, ...updates }
395
+ */
396
+ async updateEntityDetailed(type, id, updates) {
354
397
  const resp = await this.patch("/api/entities", {
355
398
  type,
356
399
  id,
357
400
  ...updates,
358
401
  });
359
- return resp.data ?? resp;
402
+ if (resp && typeof resp === "object") {
403
+ const envelope = resp;
404
+ const entity = envelope.entity ?? envelope.data ?? resp;
405
+ return {
406
+ entity,
407
+ reassignment: envelope.reassignment && typeof envelope.reassignment === "object"
408
+ ? envelope.reassignment
409
+ : null,
410
+ initiative_reassignment: envelope.initiative_reassignment &&
411
+ typeof envelope.initiative_reassignment === "object"
412
+ ? envelope.initiative_reassignment
413
+ : null,
414
+ };
415
+ }
416
+ return { entity: resp };
360
417
  }
361
418
  /**
362
419
  * List OrgX entities.
@@ -366,10 +423,49 @@ export class OrgXClient {
366
423
  const params = new URLSearchParams({ type });
367
424
  if (filters?.status)
368
425
  params.set("status", filters.status);
426
+ if (typeof filters?.offset === "number" && Number.isFinite(filters.offset)) {
427
+ params.set("offset", String(Math.max(0, Math.floor(filters.offset))));
428
+ }
429
+ if (filters?.search)
430
+ params.set("search", String(filters.search));
431
+ if (filters?.id)
432
+ params.set("id", String(filters.id));
433
+ if (filters?.ids) {
434
+ const values = Array.isArray(filters.ids)
435
+ ? filters.ids
436
+ : String(filters.ids)
437
+ .split(",")
438
+ .map((value) => value.trim())
439
+ .filter((value) => value.length > 0);
440
+ if (values.length > 0) {
441
+ params.set("ids", values.join(","));
442
+ }
443
+ }
369
444
  if (filters?.limit)
370
445
  params.set("limit", String(filters.limit));
371
446
  if (filters?.initiative_id)
372
447
  params.set("initiative_id", String(filters.initiative_id));
448
+ const legacyProjectIdRaw = filters?.project_id != null ? String(filters.project_id) : null;
449
+ const workspaceIdRaw = filters?.workspace_id != null ? String(filters.workspace_id) : null;
450
+ const commandCenterIdRaw = filters?.command_center_id != null
451
+ ? String(filters.command_center_id)
452
+ : null;
453
+ if (workspaceIdRaw &&
454
+ commandCenterIdRaw &&
455
+ workspaceIdRaw.trim() !== commandCenterIdRaw.trim()) {
456
+ throw new Error("workspace_id and command_center_id must match when both are provided");
457
+ }
458
+ if (legacyProjectIdRaw &&
459
+ workspaceIdRaw &&
460
+ legacyProjectIdRaw.trim() !== workspaceIdRaw.trim()) {
461
+ throw new Error("project_id cannot differ from workspace_id; use workspace_id as canonical scope");
462
+ }
463
+ const workspaceId = workspaceIdRaw ?? commandCenterIdRaw ?? legacyProjectIdRaw;
464
+ if (workspaceId) {
465
+ // Canonical scope param. Keep legacy alias for backward compatibility.
466
+ params.set("workspace_id", workspaceId);
467
+ params.set("command_center_id", workspaceId);
468
+ }
373
469
  return this.get(`/api/entities?${params.toString()}`);
374
470
  }
375
471
  // ===========================================================================
@@ -397,6 +493,18 @@ export class OrgXClient {
397
493
  return response;
398
494
  }
399
495
  // ===========================================================================
496
+ // Usage (Control Plane + Forecast)
497
+ // ===========================================================================
498
+ async getUsageControlPlaneSummary() {
499
+ return this.get("/api/usage/control-plane/summary");
500
+ }
501
+ async getUsageUnified() {
502
+ return this.get("/api/usage/unified");
503
+ }
504
+ async getUsageForecast() {
505
+ return this.get("/api/usage/forecast");
506
+ }
507
+ // ===========================================================================
400
508
  // Reporting Control Plane
401
509
  // ===========================================================================
402
510
  async emitActivity(payload) {
@@ -443,31 +551,44 @@ export class OrgXClient {
443
551
  // Live Sessions + Activity + Handoffs
444
552
  // ===========================================================================
445
553
  async getLiveSessions(params) {
554
+ const workspaceScope = params?.workspaceId ?? params?.projectId ?? null;
446
555
  const query = this.buildQuery({
447
556
  limit: params?.limit,
448
557
  initiative: params?.initiative ?? null,
558
+ workspace_id: workspaceScope,
559
+ command_center_id: workspaceScope,
449
560
  });
450
561
  return this.get(`/api/client/live/sessions${query}`);
451
562
  }
452
563
  async getLiveActivity(params) {
564
+ const workspaceScope = params?.workspaceId ?? params?.projectId ?? null;
453
565
  const query = this.buildQuery({
454
566
  limit: params?.limit,
455
567
  run: params?.run ?? null,
456
568
  since: params?.since ?? null,
569
+ workspace_id: workspaceScope,
570
+ command_center_id: workspaceScope,
457
571
  });
458
572
  return this.get(`/api/client/live/activity${query}`);
459
573
  }
460
574
  async getLiveAgents(params) {
575
+ const workspaceScope = params?.workspaceId ?? params?.projectId ?? null;
461
576
  const query = this.buildQuery({
462
577
  initiative: params?.initiative ?? null,
463
578
  include_idle: params?.includeIdle ?? undefined,
579
+ workspace_id: workspaceScope,
580
+ command_center_id: workspaceScope,
464
581
  });
465
582
  return this.get(`/api/client/live/agents${query}`);
466
583
  }
467
584
  async getLiveInitiatives(params) {
585
+ const workspaceScope = params?.workspaceId ?? params?.projectId ?? null;
468
586
  const query = this.buildQuery({
469
587
  id: params?.id ?? null,
470
588
  limit: params?.limit ?? null,
589
+ offset: params?.offset ?? null,
590
+ workspace_id: workspaceScope,
591
+ command_center_id: workspaceScope,
471
592
  });
472
593
  return this.get(`/api/client/live/initiatives${query}`);
473
594
  }
@@ -493,9 +614,12 @@ export class OrgXClient {
493
614
  return this.post(`/api/client/runs/${encodedRunId}/checkpoints/${encodedCheckpointId}/restore`, { reason: request.reason });
494
615
  }
495
616
  async getLiveDecisions(params) {
617
+ const workspaceScope = params?.workspaceId ?? params?.projectId ?? undefined;
496
618
  const response = await this.listEntities("decision", {
497
619
  status: params?.status,
498
620
  limit: params?.limit,
621
+ workspace_id: workspaceScope,
622
+ command_center_id: workspaceScope,
499
623
  });
500
624
  const decisions = Array.isArray(response.data) ? response.data : [];
501
625
  return {
@@ -503,32 +627,37 @@ export class OrgXClient {
503
627
  total: response.pagination?.total ?? decisions.length,
504
628
  };
505
629
  }
506
- async decideDecision(id, action, note) {
507
- const resolvedStatus = action === "approve" ? "approved" : "rejected";
508
- const resolvedAt = new Date().toISOString();
630
+ async decideDecision(id, action, input) {
631
+ const note = input?.note?.trim() || null;
632
+ const optionId = input?.optionId?.trim() || null;
633
+ const resolvedStatus = action === "approve" ? "approved" : "declined";
634
+ const primaryPatch = {
635
+ status: resolvedStatus,
636
+ ...(note ? { resolution_summary: note } : {}),
637
+ ...(optionId ? { option_id: optionId } : {}),
638
+ };
509
639
  try {
510
- return await this.updateEntity("decision", id, {
511
- status: resolvedStatus,
512
- resolution: resolvedStatus,
513
- resolved_at: resolvedAt,
514
- decided_at: resolvedAt,
515
- decided_by: this.userId || undefined,
516
- note: note ?? undefined,
517
- });
640
+ return await this.updateEntity("decision", id, primaryPatch);
518
641
  }
519
642
  catch {
520
- // Fallback for backends that only support generic "resolved" status.
643
+ // Keep fallback payload schema-safe for strict entity routes.
521
644
  return this.updateEntity("decision", id, {
522
- status: "resolved",
523
- decision_status: resolvedStatus,
524
- resolution: resolvedStatus,
525
- resolved_at: resolvedAt,
526
- decided_at: resolvedAt,
527
- note: note ?? undefined,
645
+ status: resolvedStatus,
646
+ ...(note
647
+ ? {
648
+ metadata: {
649
+ resolution: {
650
+ summary: note,
651
+ note,
652
+ },
653
+ },
654
+ }
655
+ : {}),
656
+ ...(optionId ? { option_id: optionId } : {}),
528
657
  });
529
658
  }
530
659
  }
531
- async bulkDecideDecisions(ids, action, note) {
660
+ async bulkDecideDecisions(ids, action, input) {
532
661
  const uniqueIds = Array.from(new Set(ids.filter(Boolean)));
533
662
  const results = new Array(uniqueIds.length);
534
663
  let cursor = 0;
@@ -541,7 +670,7 @@ export class OrgXClient {
541
670
  }
542
671
  const id = uniqueIds[index];
543
672
  try {
544
- const entity = await this.decideDecision(id, action, note);
673
+ const entity = await this.decideDecision(id, action, input);
545
674
  results[index] = { id, ok: true, entity };
546
675
  }
547
676
  catch (err) {
@@ -0,0 +1,216 @@
1
+ export declare const PRACTICE_EXERCISE_TEMPLATE_SCHEMA_VERSION: "practice-exercise-template.v1";
2
+ export type PracticeExerciseTemplateSchemaVersion = typeof PRACTICE_EXERCISE_TEMPLATE_SCHEMA_VERSION;
3
+ export type PracticeConstraintSeverity = "hard" | "soft";
4
+ export type PracticeTaskType = "analysis" | "implementation" | "review" | "debugging" | "planning";
5
+ export type PracticeOutputFormat = "json_object" | "markdown" | "text";
6
+ export interface PracticeConstraint {
7
+ id: string;
8
+ title: string;
9
+ description: string;
10
+ severity: PracticeConstraintSeverity;
11
+ rationale?: string;
12
+ }
13
+ export interface PracticeScenario {
14
+ id: string;
15
+ title: string;
16
+ input: Record<string, unknown>;
17
+ context?: string;
18
+ success_criteria: string[];
19
+ }
20
+ export interface PracticeExpectedOutputField {
21
+ path: string;
22
+ type: string;
23
+ required: boolean;
24
+ description: string;
25
+ }
26
+ export interface PracticeExpectedOutputShape {
27
+ format: PracticeOutputFormat;
28
+ fields: PracticeExpectedOutputField[];
29
+ example?: Record<string, unknown> | string;
30
+ }
31
+ export interface PracticeExerciseTemplate {
32
+ schema_version: PracticeExerciseTemplateSchemaVersion;
33
+ id: string;
34
+ title: string;
35
+ summary: string;
36
+ task_type: PracticeTaskType;
37
+ scenarios: PracticeScenario[];
38
+ constraints: PracticeConstraint[];
39
+ expected_output_shape: PracticeExpectedOutputShape;
40
+ tags?: string[];
41
+ }
42
+ export declare function validatePracticeExerciseTemplate(input: unknown): {
43
+ ok: boolean;
44
+ errors: string[];
45
+ template: PracticeExerciseTemplate | null;
46
+ };
47
+ export declare const PRACTICE_EXERCISE_TEMPLATE_JSON_SCHEMA: {
48
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
49
+ readonly $id: "https://schemas.useorgx.com/practice-exercise-template/v1.json";
50
+ readonly title: "OrgX Practice Exercise Template v1";
51
+ readonly description: "Structured exercise template for practice loops with scenarios, constraints, and expected output shape.";
52
+ readonly type: "object";
53
+ readonly additionalProperties: false;
54
+ readonly required: readonly ["schema_version", "id", "title", "summary", "task_type", "scenarios", "constraints", "expected_output_shape"];
55
+ readonly properties: {
56
+ readonly schema_version: {
57
+ readonly type: "string";
58
+ readonly const: "practice-exercise-template.v1";
59
+ };
60
+ readonly id: {
61
+ readonly type: "string";
62
+ readonly minLength: 1;
63
+ readonly maxLength: 120;
64
+ };
65
+ readonly title: {
66
+ readonly type: "string";
67
+ readonly minLength: 1;
68
+ readonly maxLength: 300;
69
+ };
70
+ readonly summary: {
71
+ readonly type: "string";
72
+ readonly minLength: 1;
73
+ readonly maxLength: 3000;
74
+ };
75
+ readonly task_type: {
76
+ readonly type: "string";
77
+ readonly enum: readonly ["analysis", "implementation", "review", "debugging", "planning"];
78
+ };
79
+ readonly scenarios: {
80
+ readonly type: "array";
81
+ readonly minItems: 1;
82
+ readonly maxItems: 25;
83
+ readonly items: {
84
+ readonly type: "object";
85
+ readonly additionalProperties: false;
86
+ readonly required: readonly ["id", "title", "input", "success_criteria"];
87
+ readonly properties: {
88
+ readonly id: {
89
+ readonly type: "string";
90
+ readonly minLength: 1;
91
+ readonly maxLength: 120;
92
+ };
93
+ readonly title: {
94
+ readonly type: "string";
95
+ readonly minLength: 1;
96
+ readonly maxLength: 300;
97
+ };
98
+ readonly input: {
99
+ readonly type: "object";
100
+ readonly additionalProperties: true;
101
+ };
102
+ readonly context: {
103
+ readonly type: "string";
104
+ readonly minLength: 1;
105
+ readonly maxLength: 4000;
106
+ };
107
+ readonly success_criteria: {
108
+ readonly type: "array";
109
+ readonly minItems: 1;
110
+ readonly maxItems: 20;
111
+ readonly items: {
112
+ readonly type: "string";
113
+ readonly minLength: 1;
114
+ readonly maxLength: 1000;
115
+ };
116
+ };
117
+ };
118
+ };
119
+ };
120
+ readonly constraints: {
121
+ readonly type: "array";
122
+ readonly maxItems: 25;
123
+ readonly items: {
124
+ readonly type: "object";
125
+ readonly additionalProperties: false;
126
+ readonly required: readonly ["id", "title", "description", "severity"];
127
+ readonly properties: {
128
+ readonly id: {
129
+ readonly type: "string";
130
+ readonly minLength: 1;
131
+ readonly maxLength: 120;
132
+ };
133
+ readonly title: {
134
+ readonly type: "string";
135
+ readonly minLength: 1;
136
+ readonly maxLength: 300;
137
+ };
138
+ readonly description: {
139
+ readonly type: "string";
140
+ readonly minLength: 1;
141
+ readonly maxLength: 2000;
142
+ };
143
+ readonly severity: {
144
+ readonly type: "string";
145
+ readonly enum: readonly ["hard", "soft"];
146
+ };
147
+ readonly rationale: {
148
+ readonly type: "string";
149
+ readonly minLength: 1;
150
+ readonly maxLength: 2000;
151
+ };
152
+ };
153
+ };
154
+ };
155
+ readonly expected_output_shape: {
156
+ readonly type: "object";
157
+ readonly additionalProperties: false;
158
+ readonly required: readonly ["format", "fields"];
159
+ readonly properties: {
160
+ readonly format: {
161
+ readonly type: "string";
162
+ readonly enum: readonly ["json_object", "markdown", "text"];
163
+ };
164
+ readonly fields: {
165
+ readonly type: "array";
166
+ readonly minItems: 1;
167
+ readonly maxItems: 50;
168
+ readonly items: {
169
+ readonly type: "object";
170
+ readonly additionalProperties: false;
171
+ readonly required: readonly ["path", "type", "required", "description"];
172
+ readonly properties: {
173
+ readonly path: {
174
+ readonly type: "string";
175
+ readonly minLength: 1;
176
+ readonly maxLength: 400;
177
+ };
178
+ readonly type: {
179
+ readonly type: "string";
180
+ readonly minLength: 1;
181
+ readonly maxLength: 120;
182
+ };
183
+ readonly required: {
184
+ readonly type: "boolean";
185
+ };
186
+ readonly description: {
187
+ readonly type: "string";
188
+ readonly minLength: 1;
189
+ readonly maxLength: 2000;
190
+ };
191
+ };
192
+ };
193
+ };
194
+ readonly example: {
195
+ readonly oneOf: readonly [{
196
+ readonly type: "string";
197
+ readonly minLength: 1;
198
+ readonly maxLength: 20000;
199
+ }, {
200
+ readonly type: "object";
201
+ readonly additionalProperties: true;
202
+ }];
203
+ };
204
+ };
205
+ };
206
+ readonly tags: {
207
+ readonly type: "array";
208
+ readonly maxItems: 30;
209
+ readonly items: {
210
+ readonly type: "string";
211
+ readonly minLength: 1;
212
+ readonly maxLength: 80;
213
+ };
214
+ };
215
+ };
216
+ };