@superwall/cli 1.7.0 → 2.0.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.
- package/README.md +192 -52
- package/dist/{setup-Bxj22rYi.js → apple-CkKlHBZ9.js} +82 -76
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-B7ym3oVS.js → billing-XCZU_T46.js} +98 -28
- package/dist/{bind-YrJvuRF9.js → bind-drne__Ys.js} +38 -33
- package/dist/{build-DLoCW5Ri.js → build-Gpdq5QXP.js} +20 -26
- package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
- package/dist/client-DP6Rc0t_.js +176 -0
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/{notification-url-DuKF2659.js → create-BBrtgUgS.js} +235 -539
- package/dist/{create-pkANt1Gs.js → create-Cwc3SRWJ.js} +194 -168
- package/dist/create-Yvf2gStM.js +19 -0
- package/dist/doctor-C9ldpPFC.js +83 -0
- package/dist/{drivers-Qx9LxmRN.js → drivers-DNrx4LWA.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28073 -1134
- package/dist/environment-DF1qKlny.js +58 -0
- package/dist/{existing-AVEfZu2A.js → existing-78LWSsqS.js} +12 -6
- package/dist/held-Cy8Wl4D1.js +1112 -0
- package/dist/held-Ddw1XSsr.js +16 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-brmhPG-S.js → integrate-DcJhpXy8.js} +277 -254
- package/dist/kinds-GFXB3sYu.js +11 -0
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-B2TsCE2H.js +53 -0
- package/dist/login-BoBe8Psl.js +16 -0
- package/dist/{login-Do4wFuLv.js → login-D0lh3_JI.js} +118 -55
- package/dist/lookup-D-nmmAbw.js +71 -0
- package/dist/migrate-Cfec564E.js +274 -0
- package/dist/notification-url-YDbq6FMA.js +100 -0
- package/dist/{open-studio-DOw-6ydc.js → open-Ba2vBl1_.js} +34 -43
- package/dist/org-D0g_q3mv.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-DxSLdpOI.js +29 -0
- package/dist/playbook-DIeb7hne.js +53 -0
- package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
- package/dist/promote-COD4fYdz.js +91 -0
- package/dist/push-CncywhkQ.js +482 -0
- package/dist/push-CtD4FZQV.js +22 -0
- package/dist/registry-DSrosOYs.js +10228 -0
- package/dist/{reports-CfJqoava.js → reports-DdPq4blM.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
- package/dist/{run-DsVZ5snL.js → run-C9qg_QlC.js} +16 -22
- package/dist/scan-Cv5uOwVY.js +4 -0
- package/dist/{scan-zKsddO72.js → scan-DLrsrFS9.js} +48 -37
- package/dist/scope-V336uz8j.js +198 -0
- package/dist/screenshot-file-0UETadF8.js +16 -0
- package/dist/{selection-CxZoX4NT.js → selection-Rdw-ZUoG.js} +94 -51
- package/dist/send-BxD9yf6F.js +150 -0
- package/dist/{dev-DmB3XqaJ.js → server-D0tGG8C4.js} +82 -92
- package/dist/server-z1LH94R_.js +22 -0
- package/dist/session-1AV_Bs_d.js +6 -0
- package/dist/session-CFAmMhem.js +40 -0
- package/dist/session-D_nEWKXT.js +768 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +78 -28
- package/dist/skills/superwall-framework/references/cli.md +58 -28
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +30 -8
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/{skills-DPzlnfCK.js → skills-BvFOa4y6.js} +99 -122
- package/dist/skills-DMG4bpKk.js +14 -0
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-CneRK5rk.js +294 -0
- package/dist/storage-DYvmIOHa.d.ts +16 -0
- package/dist/storage-s2Dnz-yl.js +31 -0
- package/dist/storekit-DafAnGkM.js +16 -0
- package/dist/storekit-yY_kS2iR.js +47 -0
- package/dist/telemetry-DtG92m5O.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-C0it-Xh7.js → token-DzRh7dI1.js} +6 -38
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11178 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-Bt4Ouw1y.js +117 -0
- package/dist/upgrade-Cqy5orjb.js +7 -0
- package/package.json +10 -5
- package/dist/api-CZzirVMj.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-DH6U8yuI.js +0 -190
- package/dist/asa-C-sQzPPn.js +0 -1194
- package/dist/asc-1ZBJ6DwS.js +0 -778
- package/dist/auth-YRhlV3DE.js +0 -140
- package/dist/billing-CCYHdApx.js +0 -80
- package/dist/bundle-id-CKxl_026.js +0 -121
- package/dist/command-CMIz81Da.js +0 -301
- package/dist/dev-DZy6pOnB.js +0 -22
- package/dist/doctor-H-hf-Yww.js +0 -88
- package/dist/feedback-CKf-rpBW.js +0 -152
- package/dist/hosted-CXe9TrWx.js +0 -32
- package/dist/migrate-C9ERDR6y.js +0 -284
- package/dist/org-sj7uyvp-.js +0 -40
- package/dist/output-C4o2gJ1K.js +0 -146
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-BqzqZhX1.js +0 -977
- package/dist/print-skill-ZojRSybs.js +0 -74
- package/dist/promote-BG8X4Nv_.js +0 -88
- package/dist/publish-sxLh-G4G.js +0 -35
- package/dist/push-bQ6Vxtg8.js +0 -35
- package/dist/query-_FbybaH-.js +0 -53
- package/dist/resource-CGIwSd29.js +0 -323
- package/dist/revenue-provider-ebsRINY8.js +0 -100
- package/dist/scope-BvzD-kO4.js +0 -223
- package/dist/skills-D_R-lEsK.js +0 -64
- package/dist/spinner-TWa0hia6.js +0 -18
- package/dist/storekit-Cj9Cpjcz.js +0 -29
- package/dist/telemetry-DeA1mvnT.js +0 -169
- package/dist/ui-Dy0b-9L8.js +0 -27738
- package/dist/update-B2fWIc4q.js +0 -59
- package/dist/upgrade-BmzkTKrh.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as getOAuthAccessToken } from "./token-DzRh7dI1.js";
|
|
2
|
+
import { _ as VERSION, t as API_HOST } from "./environment-DF1qKlny.js";
|
|
3
|
+
import { t as readSession } from "./storage-s2Dnz-yl.js";
|
|
4
|
+
import { n as readVersion, r as spawnStream, t as onPath } from "./spawn-DmmmHIP-.js";
|
|
4
5
|
import { basename, join } from "node:path";
|
|
5
6
|
import { tmpdir } from "node:os";
|
|
6
7
|
import { readFile, rm } from "node:fs/promises";
|
|
7
8
|
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
8
9
|
|
|
9
|
-
//#region src/core/agent/drivers/
|
|
10
|
-
const USAGE_LIMIT_PATTERNS = [
|
|
11
|
-
/\b(?:session|usage) limit\b/i,
|
|
12
|
-
/\b(?:daily|weekly|monthly) limit (?:hit|reached|exceeded)\b/i,
|
|
13
|
-
/\b(?:credit|credits|quota) (?:is |are )?exhausted\b/i,
|
|
14
|
-
/\b(?:out of|no) (?:credits?|usage) remaining\b/i
|
|
15
|
-
];
|
|
16
|
-
function isUsageLimitText(text) {
|
|
17
|
-
return !!text && USAGE_LIMIT_PATTERNS.some((pattern) => pattern.test(text));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/core/agent/drivers/capabilities.ts
|
|
10
|
+
//#region src/core/workflows/agent/drivers/capabilities.ts
|
|
22
11
|
function toolsForCapabilities(capabilities) {
|
|
23
12
|
const tools = [
|
|
24
13
|
"Read",
|
|
@@ -32,24 +21,24 @@ function toolsForCapabilities(capabilities) {
|
|
|
32
21
|
}
|
|
33
22
|
|
|
34
23
|
//#endregion
|
|
35
|
-
//#region src/core/agent/drivers/
|
|
36
|
-
|
|
37
|
-
function toolSummary$1(name, input) {
|
|
38
|
-
const i = input ?? {};
|
|
39
|
-
if (typeof i.file_path === "string") return `${name} ${basename(i.file_path)}`;
|
|
40
|
-
if (typeof i.command === "string") return `${name}: ${String(i.command).slice(0, 60)}`;
|
|
41
|
-
if (typeof i.pattern === "string") return `${name} ${i.pattern}`;
|
|
42
|
-
return name;
|
|
43
|
-
}
|
|
44
|
-
function extractStatus$1(text) {
|
|
24
|
+
//#region src/core/workflows/agent/drivers/events.ts
|
|
25
|
+
function parseStatus(text) {
|
|
45
26
|
return text.match(/\[STATUS\]\s*(.+?)\s*$/m)?.[1]?.trim();
|
|
46
27
|
}
|
|
47
|
-
function
|
|
28
|
+
function summarizeTool(name, input) {
|
|
29
|
+
if (typeof input !== "object" || input === null) return name;
|
|
30
|
+
if ("file_path" in input && typeof input.file_path === "string") return `${name} ${basename(input.file_path)}`;
|
|
31
|
+
if ("command" in input && typeof input.command === "string") return `${name}: ${input.command.slice(0, 60)}`;
|
|
32
|
+
if ("pattern" in input && typeof input.pattern === "string") return `${name} ${input.pattern}`;
|
|
33
|
+
return name;
|
|
34
|
+
}
|
|
35
|
+
function emitAssistantEvents(message, onEvent) {
|
|
48
36
|
if (!onEvent) return;
|
|
49
|
-
|
|
37
|
+
if (typeof message !== "object" || message === null || !("content" in message)) return;
|
|
38
|
+
const { content } = message;
|
|
50
39
|
if (!Array.isArray(content)) return;
|
|
51
40
|
for (const block of content) if (block?.type === "text" && typeof block.text === "string") {
|
|
52
|
-
const status =
|
|
41
|
+
const status = parseStatus(block.text);
|
|
53
42
|
if (status) onEvent({
|
|
54
43
|
type: "status",
|
|
55
44
|
text: status
|
|
@@ -61,9 +50,25 @@ function emitAssistant$1(message, onEvent) {
|
|
|
61
50
|
} else if (block?.type === "tool_use" && typeof block.name === "string") onEvent({
|
|
62
51
|
type: "tool",
|
|
63
52
|
name: block.name,
|
|
64
|
-
summary:
|
|
53
|
+
summary: summarizeTool(block.name, block.input)
|
|
65
54
|
});
|
|
66
55
|
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/core/workflows/agent/drivers/limits.ts
|
|
59
|
+
const USAGE_LIMIT_PATTERNS = [
|
|
60
|
+
/\b(?:session|usage) limit\b/i,
|
|
61
|
+
/\b(?:daily|weekly|monthly) limit (?:hit|reached|exceeded)\b/i,
|
|
62
|
+
/\b(?:credit|credits|quota) (?:is |are )?exhausted\b/i,
|
|
63
|
+
/\b(?:out of|no) (?:credits?|usage) remaining\b/i
|
|
64
|
+
];
|
|
65
|
+
function isUsageLimitText(text) {
|
|
66
|
+
return !!text && USAGE_LIMIT_PATTERNS.some((pattern) => pattern.test(text));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/core/workflows/agent/drivers/claude.ts
|
|
71
|
+
const BIN$1 = "claude";
|
|
67
72
|
const claudeDriver = {
|
|
68
73
|
id: "claude",
|
|
69
74
|
displayName: "Claude Code",
|
|
@@ -94,7 +99,7 @@ const claudeDriver = {
|
|
|
94
99
|
} catch {
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
97
|
-
if (msg.type === "assistant")
|
|
102
|
+
if (msg.type === "assistant") emitAssistantEvents(msg.message, opts.onEvent);
|
|
98
103
|
else if (msg.type === "result") {
|
|
99
104
|
if (typeof msg.result === "string") finalText = msg.result;
|
|
100
105
|
ok = msg.subtype === "success" && msg.is_error !== true;
|
|
@@ -134,9 +139,9 @@ function buildClaudeArgs(opts) {
|
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
//#endregion
|
|
137
|
-
//#region src/core/agent/drivers/codex.ts
|
|
142
|
+
//#region src/core/workflows/agent/drivers/codex.ts
|
|
138
143
|
const BIN = "codex";
|
|
139
|
-
function
|
|
144
|
+
function emitCodexEvent(msg, onEvent) {
|
|
140
145
|
if (!onEvent) return;
|
|
141
146
|
const item = msg.item ?? null;
|
|
142
147
|
const node = msg.msg ?? null ?? item ?? msg;
|
|
@@ -144,10 +149,10 @@ function normalizeCodexEvent(msg, onEvent) {
|
|
|
144
149
|
if (t.includes("agent_message") || t.includes("assistant")) {
|
|
145
150
|
const text = node.message ?? node.text ?? node.delta;
|
|
146
151
|
if (typeof text === "string" && text.trim()) {
|
|
147
|
-
const status = text
|
|
152
|
+
const status = parseStatus(text);
|
|
148
153
|
if (status) onEvent({
|
|
149
154
|
type: "status",
|
|
150
|
-
text: status
|
|
155
|
+
text: status
|
|
151
156
|
});
|
|
152
157
|
else onEvent({
|
|
153
158
|
type: "text",
|
|
@@ -163,6 +168,25 @@ function normalizeCodexEvent(msg, onEvent) {
|
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
170
|
}
|
|
171
|
+
function parseCodexLine(line) {
|
|
172
|
+
let parsed;
|
|
173
|
+
try {
|
|
174
|
+
parsed = JSON.parse(line);
|
|
175
|
+
} catch {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
179
|
+
return parsed;
|
|
180
|
+
}
|
|
181
|
+
async function readLastMessage(file) {
|
|
182
|
+
try {
|
|
183
|
+
return (await readFile(file, "utf8")).trim() || void 0;
|
|
184
|
+
} catch {
|
|
185
|
+
return;
|
|
186
|
+
} finally {
|
|
187
|
+
await rm(file, { force: true }).catch(() => {});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
166
190
|
const codexDriver = {
|
|
167
191
|
id: "codex",
|
|
168
192
|
displayName: "Codex",
|
|
@@ -178,7 +202,6 @@ const codexDriver = {
|
|
|
178
202
|
async run(opts) {
|
|
179
203
|
const lastMsgFile = join(tmpdir(), `superwall-codex-${process.pid}-${Date.now()}.txt`);
|
|
180
204
|
const args = buildCodexArgs(opts, lastMsgFile);
|
|
181
|
-
let ok = false;
|
|
182
205
|
let usageLimited = false;
|
|
183
206
|
const { code } = await spawnStream({
|
|
184
207
|
bin: BIN,
|
|
@@ -187,21 +210,15 @@ const codexDriver = {
|
|
|
187
210
|
signal: opts.signal,
|
|
188
211
|
onStdoutLine: (line) => {
|
|
189
212
|
if (isUsageLimitText(line)) usageLimited = true;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
} catch {}
|
|
213
|
+
const event = parseCodexLine(line);
|
|
214
|
+
if (event) emitCodexEvent(event, opts.onEvent);
|
|
193
215
|
},
|
|
194
216
|
onStderrLine: (line) => {
|
|
195
217
|
if (isUsageLimitText(line)) usageLimited = true;
|
|
196
218
|
}
|
|
197
219
|
});
|
|
198
|
-
ok = code === 0;
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
finalText = (await readFile(lastMsgFile, "utf8")).trim() || void 0;
|
|
202
|
-
} catch {} finally {
|
|
203
|
-
await rm(lastMsgFile, { force: true }).catch(() => {});
|
|
204
|
-
}
|
|
220
|
+
const ok = code === 0;
|
|
221
|
+
const finalText = await readLastMessage(lastMsgFile);
|
|
205
222
|
if (!ok) opts.onEvent?.({
|
|
206
223
|
type: "error",
|
|
207
224
|
message: `codex exited with code ${code}`
|
|
@@ -229,47 +246,41 @@ function buildCodexArgs(opts, lastMsgFile) {
|
|
|
229
246
|
}
|
|
230
247
|
|
|
231
248
|
//#endregion
|
|
232
|
-
//#region src/core/agent/
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (typeof i.command === "string") return `${name}: ${String(i.command).slice(0, 60)}`;
|
|
238
|
-
if (typeof i.pattern === "string") return `${name} ${i.pattern}`;
|
|
239
|
-
return name;
|
|
249
|
+
//#region src/core/workflows/agent/hosted.ts
|
|
250
|
+
const STATUS_PATH = "/v2/cli-agent/status";
|
|
251
|
+
const ANTHROPIC_PROXY_PATH = "/v2/cli-agent/anthropic";
|
|
252
|
+
function resolveBaseUrl() {
|
|
253
|
+
return readSession()?.host || API_HOST();
|
|
240
254
|
}
|
|
241
|
-
function
|
|
242
|
-
return
|
|
255
|
+
function resolveHostedAnthropicBaseUrl() {
|
|
256
|
+
return `${resolveBaseUrl()}${ANTHROPIC_PROXY_PATH}`;
|
|
243
257
|
}
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
});
|
|
258
|
-
} else if (block?.type === "tool_use" && typeof block.name === "string") onEvent({
|
|
259
|
-
type: "tool",
|
|
260
|
-
name: block.name,
|
|
261
|
-
summary: toolSummary(block.name, block.input)
|
|
262
|
-
});
|
|
258
|
+
async function selectHostedStatus() {
|
|
259
|
+
const token = await getOAuthAccessToken();
|
|
260
|
+
if (!token) return null;
|
|
261
|
+
try {
|
|
262
|
+
const res = await fetch(`${resolveBaseUrl()}${STATUS_PATH}`, { headers: {
|
|
263
|
+
authorization: `Bearer ${token}`,
|
|
264
|
+
accept: "application/json"
|
|
265
|
+
} });
|
|
266
|
+
if (!res.ok) return null;
|
|
267
|
+
return await res.json();
|
|
268
|
+
} catch {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
263
271
|
}
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/core/workflows/agent/drivers/superwall.ts
|
|
275
|
+
const SDK_MODEL_ALIAS = "claude-sonnet-5";
|
|
264
276
|
function resultText(message) {
|
|
265
|
-
if (message.type !== "result") return void 0;
|
|
266
277
|
if ("result" in message && typeof message.result === "string") return message.result;
|
|
267
278
|
if ("errors" in message && Array.isArray(message.errors)) return message.errors.join("\n");
|
|
268
279
|
}
|
|
269
|
-
function
|
|
280
|
+
function resolveHostedEnv(token) {
|
|
270
281
|
return {
|
|
271
282
|
...process.env,
|
|
272
|
-
ANTHROPIC_BASE_URL:
|
|
283
|
+
ANTHROPIC_BASE_URL: resolveHostedAnthropicBaseUrl(),
|
|
273
284
|
ANTHROPIC_AUTH_TOKEN: token,
|
|
274
285
|
ANTHROPIC_API_KEY: "",
|
|
275
286
|
ANTHROPIC_MODEL: SDK_MODEL_ALIAS,
|
|
@@ -282,13 +293,13 @@ function buildEnv(token) {
|
|
|
282
293
|
CLAUDE_CODE_MAX_RETRIES: "2"
|
|
283
294
|
};
|
|
284
295
|
}
|
|
285
|
-
async function
|
|
286
|
-
const token = await
|
|
296
|
+
async function resolveRunAuth() {
|
|
297
|
+
const token = await getOAuthAccessToken();
|
|
287
298
|
if (!token) return {
|
|
288
299
|
ok: false,
|
|
289
300
|
message: "Sign in with `superwall login` to use the bundled Superwall Agent."
|
|
290
301
|
};
|
|
291
|
-
const status = await
|
|
302
|
+
const status = await selectHostedStatus();
|
|
292
303
|
if (!status) return {
|
|
293
304
|
ok: false,
|
|
294
305
|
message: "The hosted Superwall Agent is unavailable right now."
|
|
@@ -302,105 +313,107 @@ async function getRunAuth() {
|
|
|
302
313
|
token
|
|
303
314
|
};
|
|
304
315
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
id: "superwall",
|
|
311
|
-
displayName: "Superwall Agent",
|
|
312
|
-
bin: "claude-agent-sdk"
|
|
313
|
-
};
|
|
314
|
-
},
|
|
315
|
-
async run(opts) {
|
|
316
|
-
const auth = await getRunAuth();
|
|
317
|
-
if (!auth.ok) {
|
|
318
|
-
opts.onEvent?.({
|
|
319
|
-
type: "error",
|
|
320
|
-
message: auth.message
|
|
321
|
-
});
|
|
316
|
+
function createSuperwallDriver(runQuery) {
|
|
317
|
+
return {
|
|
318
|
+
id: "superwall",
|
|
319
|
+
displayName: "Superwall Agent",
|
|
320
|
+
async detect() {
|
|
322
321
|
return {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
const abortController = new AbortController();
|
|
329
|
-
const onAbort = () => abortController.abort(opts.signal?.reason);
|
|
330
|
-
if (opts.signal?.aborted) onAbort();
|
|
331
|
-
else opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
332
|
-
let finalText;
|
|
333
|
-
let ok = false;
|
|
334
|
-
try {
|
|
335
|
-
const options = {
|
|
336
|
-
abortController,
|
|
337
|
-
cwd: opts.cwd,
|
|
338
|
-
tools: {
|
|
339
|
-
type: "preset",
|
|
340
|
-
preset: "claude_code"
|
|
341
|
-
},
|
|
342
|
-
allowedTools: toolsForCapabilities(opts.capabilities),
|
|
343
|
-
disallowedTools: opts.capabilities.filesystem === "read" ? [
|
|
344
|
-
"Write",
|
|
345
|
-
"Edit",
|
|
346
|
-
"MultiEdit",
|
|
347
|
-
"NotebookEdit"
|
|
348
|
-
] : void 0,
|
|
349
|
-
permissionMode: opts.capabilities.filesystem === "read" ? "plan" : "acceptEdits",
|
|
350
|
-
systemPrompt: opts.systemAppend ? {
|
|
351
|
-
type: "preset",
|
|
352
|
-
preset: "claude_code",
|
|
353
|
-
append: opts.systemAppend
|
|
354
|
-
} : {
|
|
355
|
-
type: "preset",
|
|
356
|
-
preset: "claude_code"
|
|
357
|
-
},
|
|
358
|
-
model: SDK_MODEL_ALIAS,
|
|
359
|
-
settingSources: [],
|
|
360
|
-
strictMcpConfig: true,
|
|
361
|
-
persistSession: false,
|
|
362
|
-
env: buildEnv(auth.token),
|
|
363
|
-
stderr: () => {}
|
|
322
|
+
id: "superwall",
|
|
323
|
+
displayName: "Superwall Agent",
|
|
324
|
+
bin: "claude-agent-sdk"
|
|
364
325
|
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
326
|
+
},
|
|
327
|
+
async run(opts) {
|
|
328
|
+
const auth = await resolveRunAuth();
|
|
329
|
+
if (!auth.ok) {
|
|
330
|
+
opts.onEvent?.({
|
|
331
|
+
type: "error",
|
|
332
|
+
message: auth.message
|
|
333
|
+
});
|
|
334
|
+
return {
|
|
335
|
+
ok: false,
|
|
336
|
+
finalText: auth.message,
|
|
337
|
+
failureReason: isUsageLimitText(auth.message) ? "usage-limit" : void 0
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const abortController = new AbortController();
|
|
341
|
+
const onAbort = () => abortController.abort(opts.signal?.reason);
|
|
342
|
+
if (opts.signal?.aborted) onAbort();
|
|
343
|
+
else opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
344
|
+
let finalText;
|
|
345
|
+
let ok = false;
|
|
346
|
+
try {
|
|
347
|
+
const options = {
|
|
348
|
+
abortController,
|
|
349
|
+
cwd: opts.cwd,
|
|
350
|
+
tools: {
|
|
351
|
+
type: "preset",
|
|
352
|
+
preset: "claude_code"
|
|
353
|
+
},
|
|
354
|
+
allowedTools: toolsForCapabilities(opts.capabilities),
|
|
355
|
+
disallowedTools: opts.capabilities.filesystem === "read" ? [
|
|
356
|
+
"Write",
|
|
357
|
+
"Edit",
|
|
358
|
+
"MultiEdit",
|
|
359
|
+
"NotebookEdit"
|
|
360
|
+
] : void 0,
|
|
361
|
+
permissionMode: opts.capabilities.filesystem === "read" ? "plan" : "acceptEdits",
|
|
362
|
+
systemPrompt: opts.systemAppend ? {
|
|
363
|
+
type: "preset",
|
|
364
|
+
preset: "claude_code",
|
|
365
|
+
append: opts.systemAppend
|
|
366
|
+
} : {
|
|
367
|
+
type: "preset",
|
|
368
|
+
preset: "claude_code"
|
|
369
|
+
},
|
|
370
|
+
model: SDK_MODEL_ALIAS,
|
|
371
|
+
settingSources: [],
|
|
372
|
+
strictMcpConfig: true,
|
|
373
|
+
persistSession: false,
|
|
374
|
+
env: resolveHostedEnv(auth.token),
|
|
375
|
+
stderr: () => {}
|
|
376
|
+
};
|
|
377
|
+
for await (const message of runQuery({
|
|
378
|
+
prompt: opts.prompt,
|
|
379
|
+
options
|
|
380
|
+
})) if (message.type === "assistant") emitAssistantEvents(message.message, opts.onEvent);
|
|
381
|
+
else if (message.type === "result") {
|
|
382
|
+
finalText = resultText(message);
|
|
383
|
+
ok = message.subtype === "success" && message.is_error !== true;
|
|
384
|
+
}
|
|
385
|
+
} catch (e) {
|
|
386
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
387
|
+
opts.onEvent?.({
|
|
388
|
+
type: "error",
|
|
389
|
+
message
|
|
390
|
+
});
|
|
391
|
+
return {
|
|
392
|
+
ok: false,
|
|
393
|
+
finalText: message,
|
|
394
|
+
failureReason: isUsageLimitText(message) ? "usage-limit" : void 0
|
|
395
|
+
};
|
|
396
|
+
} finally {
|
|
397
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
372
398
|
}
|
|
373
|
-
} catch (e) {
|
|
374
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
375
|
-
opts.onEvent?.({
|
|
376
|
-
type: "error",
|
|
377
|
-
message
|
|
378
|
-
});
|
|
379
399
|
return {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
failureReason: isUsageLimitText(
|
|
400
|
+
finalText,
|
|
401
|
+
ok,
|
|
402
|
+
failureReason: !ok && isUsageLimitText(finalText) ? "usage-limit" : void 0
|
|
383
403
|
};
|
|
384
|
-
} finally {
|
|
385
|
-
opts.signal?.removeEventListener("abort", onAbort);
|
|
386
404
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
failureReason: !ok && isUsageLimitText(finalText) ? "usage-limit" : void 0
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
};
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
const superwallDriver = createSuperwallDriver(query);
|
|
394
408
|
|
|
395
409
|
//#endregion
|
|
396
|
-
//#region src/core/agent/drivers/index.ts
|
|
397
|
-
const ALL_DRIVERS = [
|
|
398
|
-
claudeDriver,
|
|
399
|
-
codexDriver,
|
|
400
|
-
superwallDriver
|
|
401
|
-
];
|
|
410
|
+
//#region src/core/workflows/agent/drivers/index.ts
|
|
402
411
|
async function detectDrivers() {
|
|
403
|
-
return (await Promise.all(
|
|
412
|
+
return (await Promise.all([
|
|
413
|
+
claudeDriver,
|
|
414
|
+
codexDriver,
|
|
415
|
+
superwallDriver
|
|
416
|
+
].map(async (driver) => {
|
|
404
417
|
const info = await driver.detect();
|
|
405
418
|
return info ? {
|
|
406
419
|
driver,
|
|
@@ -410,4 +423,4 @@ async function detectDrivers() {
|
|
|
410
423
|
}
|
|
411
424
|
|
|
412
425
|
//#endregion
|
|
413
|
-
export { detectDrivers as t };
|
|
426
|
+
export { selectHostedStatus as n, detectDrivers as t };
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
//#region src/entry.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The CLI's programmatic entrypoint: the `superwall` package's bin calls
|
|
4
|
-
* this after registering tsx (which is what lets the paywall commands load
|
|
5
|
-
* the project's framework TypeScript at runtime).
|
|
6
|
-
*/
|
|
7
2
|
declare function main(): Promise<void>;
|
|
8
3
|
//#endregion
|
|
9
4
|
export { main };
|