@useorgx/openclaw-plugin 0.4.8 → 0.4.9

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 (125) hide show
  1. package/dashboard/dist/assets/B5NEElEI.css +1 -0
  2. package/dashboard/dist/assets/BhapSNAs.js +215 -0
  3. package/dashboard/dist/assets/{BNeJ0kpF.js → iFdvE7lx.js} +1 -1
  4. package/dashboard/dist/assets/{CUV9IHHi.js → jRJsmpYM.js} +1 -1
  5. package/dashboard/dist/index.html +2 -2
  6. package/dist/activity-store.js +4 -18
  7. package/dist/agent-context-store.js +5 -25
  8. package/dist/agent-run-store.js +5 -25
  9. package/dist/agent-suite.js +1 -8
  10. package/dist/auth/flows.d.ts +47 -0
  11. package/dist/auth/flows.js +169 -0
  12. package/dist/auth-store.js +6 -26
  13. package/dist/byok-store.js +5 -19
  14. package/dist/cli/orgx.d.ts +66 -0
  15. package/dist/cli/orgx.js +91 -0
  16. package/dist/config/refresh.d.ts +32 -0
  17. package/dist/config/refresh.js +55 -0
  18. package/dist/config/resolution.d.ts +37 -0
  19. package/dist/config/resolution.js +178 -0
  20. package/dist/contracts/shared-types.d.ts +147 -0
  21. package/dist/contracts/shared-types.js +3 -0
  22. package/dist/contracts/types.d.ts +1 -134
  23. package/dist/contracts/types.js +5 -0
  24. package/dist/entities/auto-assignment.d.ts +36 -0
  25. package/dist/entities/auto-assignment.js +115 -0
  26. package/dist/entity-comment-store.js +5 -25
  27. package/dist/hash-utils.d.ts +2 -0
  28. package/dist/hash-utils.js +12 -0
  29. package/dist/http/helpers/activity-headline.d.ts +10 -0
  30. package/dist/http/helpers/activity-headline.js +192 -0
  31. package/dist/http/helpers/artifact-fallback.d.ts +13 -0
  32. package/dist/http/helpers/artifact-fallback.js +148 -0
  33. package/dist/http/helpers/auto-continue-engine.d.ts +298 -0
  34. package/dist/http/helpers/auto-continue-engine.js +1218 -0
  35. package/dist/http/helpers/autopilot-operations.d.ts +157 -0
  36. package/dist/http/helpers/autopilot-operations.js +403 -0
  37. package/dist/http/helpers/autopilot-runtime.d.ts +42 -0
  38. package/dist/http/helpers/autopilot-runtime.js +319 -0
  39. package/dist/http/helpers/autopilot-slice-utils.d.ts +38 -0
  40. package/dist/http/helpers/autopilot-slice-utils.js +476 -0
  41. package/dist/http/helpers/decision-mapper.d.ts +12 -0
  42. package/dist/http/helpers/decision-mapper.js +44 -0
  43. package/dist/http/helpers/dispatch-lifecycle.d.ts +102 -0
  44. package/dist/http/helpers/dispatch-lifecycle.js +604 -0
  45. package/dist/http/helpers/hash-utils.d.ts +1 -0
  46. package/dist/http/helpers/hash-utils.js +1 -0
  47. package/dist/http/helpers/kickoff-context.d.ts +12 -0
  48. package/dist/http/helpers/kickoff-context.js +154 -0
  49. package/dist/http/helpers/mission-control.d.ts +94 -0
  50. package/dist/http/helpers/mission-control.js +894 -0
  51. package/dist/http/helpers/openclaw-cli.d.ts +37 -0
  52. package/dist/http/helpers/openclaw-cli.js +283 -0
  53. package/dist/http/helpers/runtime-sse.d.ts +20 -0
  54. package/dist/http/helpers/runtime-sse.js +110 -0
  55. package/dist/http/helpers/value-utils.d.ts +6 -0
  56. package/dist/http/helpers/value-utils.js +67 -0
  57. package/dist/http/index.d.ts +88 -0
  58. package/dist/http/index.js +2353 -0
  59. package/dist/http/router.d.ts +23 -0
  60. package/dist/http/router.js +23 -0
  61. package/dist/http/routes/agent-control.d.ts +79 -0
  62. package/dist/http/routes/agent-control.js +684 -0
  63. package/dist/http/routes/agent-suite.d.ts +29 -0
  64. package/dist/http/routes/agent-suite.js +198 -0
  65. package/dist/http/routes/agents-catalog.d.ts +40 -0
  66. package/dist/http/routes/agents-catalog.js +83 -0
  67. package/dist/http/routes/billing.d.ts +23 -0
  68. package/dist/http/routes/billing.js +55 -0
  69. package/dist/http/routes/debug.d.ts +14 -0
  70. package/dist/http/routes/debug.js +21 -0
  71. package/dist/http/routes/decision-actions.d.ts +13 -0
  72. package/dist/http/routes/decision-actions.js +66 -0
  73. package/dist/http/routes/delegation.d.ts +19 -0
  74. package/dist/http/routes/delegation.js +32 -0
  75. package/dist/http/routes/entities.d.ts +47 -0
  76. package/dist/http/routes/entities.js +152 -0
  77. package/dist/http/routes/entity-dynamic.d.ts +25 -0
  78. package/dist/http/routes/entity-dynamic.js +191 -0
  79. package/dist/http/routes/health.d.ts +22 -0
  80. package/dist/http/routes/health.js +49 -0
  81. package/dist/http/routes/live-legacy.d.ts +110 -0
  82. package/dist/http/routes/live-legacy.js +598 -0
  83. package/dist/http/routes/live-misc.d.ts +69 -0
  84. package/dist/http/routes/live-misc.js +206 -0
  85. package/dist/http/routes/live-snapshot.d.ts +90 -0
  86. package/dist/http/routes/live-snapshot.js +297 -0
  87. package/dist/http/routes/mission-control-actions.d.ts +83 -0
  88. package/dist/http/routes/mission-control-actions.js +541 -0
  89. package/dist/http/routes/mission-control-read.d.ts +28 -0
  90. package/dist/http/routes/mission-control-read.js +67 -0
  91. package/dist/http/routes/onboarding.d.ts +34 -0
  92. package/dist/http/routes/onboarding.js +101 -0
  93. package/dist/http/routes/run-control.d.ts +24 -0
  94. package/dist/http/routes/run-control.js +86 -0
  95. package/dist/http/routes/runtime-hooks.d.ts +69 -0
  96. package/dist/http/routes/runtime-hooks.js +437 -0
  97. package/dist/http/routes/settings-byok.d.ts +23 -0
  98. package/dist/http/routes/settings-byok.js +163 -0
  99. package/dist/http/routes/summary.d.ts +18 -0
  100. package/dist/http/routes/summary.js +42 -0
  101. package/dist/http/routes/work-artifacts.d.ts +9 -0
  102. package/dist/http/routes/work-artifacts.js +36 -0
  103. package/dist/http/shared-state.d.ts +16 -0
  104. package/dist/http/shared-state.js +1 -0
  105. package/dist/http-handler.d.ts +1 -88
  106. package/dist/http-handler.js +1 -10605
  107. package/dist/index.js +108 -2243
  108. package/dist/json-utils.d.ts +1 -0
  109. package/dist/json-utils.js +8 -0
  110. package/dist/next-up-queue-store.js +4 -18
  111. package/dist/runtime-instance-store.js +5 -31
  112. package/dist/services/background.d.ts +23 -0
  113. package/dist/services/background.js +23 -0
  114. package/dist/services/instrumentation.d.ts +29 -0
  115. package/dist/services/instrumentation.js +136 -0
  116. package/dist/snapshot-store.js +5 -25
  117. package/dist/stores/json-store.d.ts +11 -0
  118. package/dist/stores/json-store.js +42 -0
  119. package/dist/sync/outbox-replay.d.ts +55 -0
  120. package/dist/sync/outbox-replay.js +514 -0
  121. package/dist/tools/core-tools.d.ts +76 -0
  122. package/dist/tools/core-tools.js +1005 -0
  123. package/package.json +1 -1
  124. package/dashboard/dist/assets/BzkiMPmM.js +0 -215
  125. package/dashboard/dist/assets/Ie7d9Iq2.css +0 -1
@@ -0,0 +1,101 @@
1
+ export function registerOnboardingRoutes(router, deps) {
2
+ router.add("GET", "onboarding/status", async ({ res }) => {
3
+ try {
4
+ const state = await deps.onboarding.getStatus();
5
+ deps.sendJson(res, 200, {
6
+ ok: true,
7
+ data: deps.getOnboardingState(state),
8
+ });
9
+ }
10
+ catch (err) {
11
+ deps.sendJson(res, 500, {
12
+ ok: false,
13
+ error: deps.safeErrorMessage(err),
14
+ });
15
+ }
16
+ }, "Read onboarding status");
17
+ router.add("POST", "onboarding/start", async ({ req, res }) => {
18
+ try {
19
+ const payload = await deps.parseJsonRequest(req);
20
+ const started = await deps.onboarding.startPairing({
21
+ openclawVersion: deps.pickString(payload, ["openclawVersion", "openclaw_version"]) ??
22
+ undefined,
23
+ platform: deps.pickString(payload, ["platform"]) ?? undefined,
24
+ deviceName: deps.pickString(payload, ["deviceName", "device_name"]) ?? undefined,
25
+ });
26
+ deps.sendJson(res, 200, {
27
+ ok: true,
28
+ data: {
29
+ pairingId: started.pairingId,
30
+ connectUrl: started.connectUrl,
31
+ expiresAt: started.expiresAt,
32
+ pollIntervalMs: started.pollIntervalMs,
33
+ state: deps.getOnboardingState(started.state),
34
+ },
35
+ });
36
+ }
37
+ catch (err) {
38
+ deps.sendJson(res, 400, {
39
+ ok: false,
40
+ error: deps.safeErrorMessage(err),
41
+ });
42
+ }
43
+ }, "Start onboarding pairing flow");
44
+ router.add("POST", "onboarding/manual-key", async ({ req, res }) => {
45
+ try {
46
+ const payload = await deps.parseJsonRequest(req);
47
+ const reqWithHeaders = req;
48
+ const authHeader = deps.pickHeaderString(reqWithHeaders.headers, ["authorization"]);
49
+ const bearerApiKey = authHeader && authHeader.toLowerCase().startsWith("bearer ")
50
+ ? authHeader.slice("bearer ".length).trim()
51
+ : null;
52
+ const headerApiKey = deps.pickHeaderString(reqWithHeaders.headers, [
53
+ "x-orgx-api-key",
54
+ "x-api-key",
55
+ ]);
56
+ const apiKey = deps.pickString(payload, ["apiKey", "api_key"]) ??
57
+ headerApiKey ??
58
+ bearerApiKey;
59
+ if (!apiKey) {
60
+ deps.sendJson(res, 400, {
61
+ ok: false,
62
+ error: "apiKey is required",
63
+ });
64
+ return;
65
+ }
66
+ const requestedUserId = deps.pickString(payload, ["userId", "user_id"]) ??
67
+ deps.pickHeaderString(reqWithHeaders.headers, ["x-orgx-user-id", "x-user-id"]) ??
68
+ undefined;
69
+ const userId = deps.isUserScopedApiKey(apiKey) ? undefined : requestedUserId;
70
+ const state = await deps.onboarding.submitManualKey({
71
+ apiKey,
72
+ userId,
73
+ });
74
+ deps.sendJson(res, 200, {
75
+ ok: true,
76
+ data: deps.getOnboardingState(state),
77
+ });
78
+ }
79
+ catch (err) {
80
+ deps.sendJson(res, 400, {
81
+ ok: false,
82
+ error: deps.safeErrorMessage(err),
83
+ });
84
+ }
85
+ }, "Submit manual OrgX API key");
86
+ router.add("POST", "onboarding/disconnect", async ({ res }) => {
87
+ try {
88
+ const state = await deps.onboarding.disconnect();
89
+ deps.sendJson(res, 200, {
90
+ ok: true,
91
+ data: deps.getOnboardingState(state),
92
+ });
93
+ }
94
+ catch (err) {
95
+ deps.sendJson(res, 500, {
96
+ ok: false,
97
+ error: deps.safeErrorMessage(err),
98
+ });
99
+ }
100
+ }, "Disconnect onboarding session");
101
+ }
@@ -0,0 +1,24 @@
1
+ import type { Router } from "../router.js";
2
+ type JsonRecord = Record<string, unknown>;
3
+ type RunAction = "pause" | "resume" | "cancel" | "rollback";
4
+ type RegisterRunControlRoutesDeps<TReq, TRes> = {
5
+ parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
6
+ pickString: (input: Record<string, unknown>, keys: string[]) => string | null;
7
+ listRunCheckpoints: (runId: string) => Promise<unknown>;
8
+ createRunCheckpoint: (runId: string, input: {
9
+ reason?: string;
10
+ payload?: Record<string, unknown>;
11
+ }) => Promise<unknown>;
12
+ restoreRunCheckpoint: (runId: string, input: {
13
+ checkpointId: string;
14
+ reason?: string;
15
+ }) => Promise<unknown>;
16
+ runAction: (runId: string, action: RunAction, input: {
17
+ checkpointId?: string;
18
+ reason?: string;
19
+ }) => Promise<unknown>;
20
+ sendJson: (res: TRes, status: number, payload: unknown) => void;
21
+ safeErrorMessage: (err: unknown) => string;
22
+ };
23
+ export declare function registerRunControlRoutes<TReq, TRes>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterRunControlRoutesDeps<TReq, TRes>): void;
24
+ export {};
@@ -0,0 +1,86 @@
1
+ export function registerRunControlRoutes(router, deps) {
2
+ router.add("*", "runs/*", async ({ req, res, path }) => {
3
+ const method = (req.method ?? "GET").toUpperCase();
4
+ const runCheckpointsMatch = path.match(/^runs\/([^/]+)\/checkpoints$/);
5
+ const runCheckpointRestoreMatch = path.match(/^runs\/([^/]+)\/checkpoints\/([^/]+)\/restore$/);
6
+ const runActionMatch = path.match(/^runs\/([^/]+)\/actions\/([^/]+)$/);
7
+ if (runCheckpointsMatch) {
8
+ const runId = decodeURIComponent(runCheckpointsMatch[1]);
9
+ if (method === "POST") {
10
+ try {
11
+ const payload = await deps.parseJsonRequest(req);
12
+ const reason = deps.pickString(payload, ["reason"]) ?? undefined;
13
+ const rawPayload = payload.payload;
14
+ const checkpointPayload = rawPayload && typeof rawPayload === "object" && !Array.isArray(rawPayload)
15
+ ? rawPayload
16
+ : undefined;
17
+ const data = await deps.createRunCheckpoint(runId, {
18
+ reason,
19
+ payload: checkpointPayload,
20
+ });
21
+ deps.sendJson(res, 200, data);
22
+ }
23
+ catch (err) {
24
+ deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
25
+ }
26
+ return;
27
+ }
28
+ if (method === "GET" || method === "HEAD") {
29
+ try {
30
+ const data = await deps.listRunCheckpoints(runId);
31
+ deps.sendJson(res, 200, data);
32
+ }
33
+ catch (err) {
34
+ deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
35
+ }
36
+ return;
37
+ }
38
+ deps.sendJson(res, 405, { error: "Method not allowed" });
39
+ return;
40
+ }
41
+ if (runCheckpointRestoreMatch) {
42
+ if (method !== "POST") {
43
+ deps.sendJson(res, 405, { error: "Use POST for this endpoint" });
44
+ return;
45
+ }
46
+ try {
47
+ const runId = decodeURIComponent(runCheckpointRestoreMatch[1]);
48
+ const checkpointId = decodeURIComponent(runCheckpointRestoreMatch[2]);
49
+ const payload = await deps.parseJsonRequest(req);
50
+ const reason = deps.pickString(payload, ["reason"]) ?? undefined;
51
+ const data = await deps.restoreRunCheckpoint(runId, {
52
+ checkpointId,
53
+ reason,
54
+ });
55
+ deps.sendJson(res, 200, data);
56
+ }
57
+ catch (err) {
58
+ deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
59
+ }
60
+ return;
61
+ }
62
+ if (runActionMatch) {
63
+ if (method !== "POST") {
64
+ deps.sendJson(res, 405, { error: "Use POST for this endpoint" });
65
+ return;
66
+ }
67
+ try {
68
+ const runId = decodeURIComponent(runActionMatch[1]);
69
+ const action = decodeURIComponent(runActionMatch[2]);
70
+ const payload = await deps.parseJsonRequest(req);
71
+ const checkpointId = deps.pickString(payload, ["checkpointId", "checkpoint_id"]);
72
+ const reason = deps.pickString(payload, ["reason"]);
73
+ const data = await deps.runAction(runId, action, {
74
+ checkpointId: checkpointId ?? undefined,
75
+ reason: reason ?? undefined,
76
+ });
77
+ deps.sendJson(res, 200, data);
78
+ }
79
+ catch (err) {
80
+ deps.sendJson(res, 500, { error: deps.safeErrorMessage(err) });
81
+ }
82
+ return;
83
+ }
84
+ deps.sendJson(res, 404, { error: "Unknown API endpoint" });
85
+ }, "Run control (checkpoints/actions)");
86
+ }
@@ -0,0 +1,69 @@
1
+ import type { RuntimeHookPayload } from "../../runtime-instance-store.js";
2
+ import type { Router } from "../router.js";
3
+ type JsonRecord = Record<string, unknown>;
4
+ type RuntimeStreamSubscriber = {
5
+ id: string;
6
+ write: (chunk: Buffer) => boolean;
7
+ end: () => void;
8
+ };
9
+ type RuntimeInstanceLike = {
10
+ id: string;
11
+ state: string;
12
+ event: string;
13
+ displayName: string;
14
+ lastHeartbeatAt: string | null;
15
+ lastEventAt: string;
16
+ runId: string | null;
17
+ correlationId: string | null;
18
+ initiativeId: string | null;
19
+ sourceClient: string;
20
+ taskId: string | null;
21
+ workstreamId: string | null;
22
+ progressPct: number | null;
23
+ metadata: Record<string, unknown> | null;
24
+ };
25
+ type RegisterRuntimeHookRoutesDeps<TReq, TRes> = {
26
+ parseJsonRequest: (req: TReq) => Promise<JsonRecord>;
27
+ pickString: (record: Record<string, unknown>, keys: string[]) => string | null;
28
+ pickNumber: (record: Record<string, unknown>, keys: string[]) => number | null;
29
+ pickHeaderString: (headers: Record<string, string | string[] | undefined>, names: string[]) => string | null;
30
+ resolveRuntimeHookToken: () => string;
31
+ maskSecret: (value: string | null) => string | null;
32
+ parseJsonSafe: <T>(value: string) => T | null;
33
+ sendJson: (res: TRes, status: number, payload: unknown) => void;
34
+ safeErrorMessage: (err: unknown) => string;
35
+ randomUUID: () => string;
36
+ listRuntimeInstances: (input: {
37
+ limit: number;
38
+ }) => unknown;
39
+ writeRuntimeSseEvent: (subscriber: RuntimeStreamSubscriber, event: string, payload: unknown) => void;
40
+ runtimeStreamSubscribers: Map<string, RuntimeStreamSubscriber>;
41
+ ensureRuntimeStreamTimers: () => void;
42
+ stopRuntimeStreamTimers: () => void;
43
+ upsertRuntimeInstanceFromHook: (payload: RuntimeHookPayload) => RuntimeInstanceLike;
44
+ broadcastRuntimeSse: (event: string, payload: unknown) => void;
45
+ clearSnapshotResponseCache: () => void;
46
+ normalizeHookPhase: (value: string | null) => "intent" | "execution" | "blocked" | "review" | "handoff" | "completed";
47
+ normalizeRuntimeSourceForReporting: (value: unknown) => string;
48
+ emitActivity: (input: {
49
+ initiative_id: string;
50
+ run_id?: string;
51
+ correlation_id?: string;
52
+ source_client: string;
53
+ message: string;
54
+ phase: "intent" | "execution" | "blocked" | "review" | "handoff" | "completed";
55
+ progress_pct?: number;
56
+ level: "info" | "warn" | "error";
57
+ metadata?: Record<string, unknown>;
58
+ }) => Promise<unknown>;
59
+ securityHeaders: Record<string, string>;
60
+ corsHeaders: Record<string, string>;
61
+ };
62
+ export declare function registerRuntimeHookRoutes<TReq, TRes extends {
63
+ write?: (chunk: string | Buffer) => boolean | void;
64
+ end: () => void;
65
+ writeHead: (statusCode: number, headers?: Record<string, string>) => unknown;
66
+ writableEnded?: boolean;
67
+ on?: (event: string, listener: () => void) => void;
68
+ }>(router: Router<Record<string, never>, TReq, TRes>, deps: RegisterRuntimeHookRoutesDeps<TReq, TRes>): void;
69
+ export {};