@xanots/sdk 0.0.1
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/LICENSE +21 -0
- package/README.md +384 -0
- package/dist/agent-file-refresh-7XCACU34.js +95 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +184 -0
- package/dist/capture-HUV5BNTC.js +32 -0
- package/dist/chunk-26CNBZE2.js +963 -0
- package/dist/chunk-33ND6LKO.js +78 -0
- package/dist/chunk-3DUAGYGP.js +1550 -0
- package/dist/chunk-3IGNIP6R.js +89 -0
- package/dist/chunk-47WDWMBJ.js +14 -0
- package/dist/chunk-4BXJGVZ3.js +318 -0
- package/dist/chunk-4HT3BNZ7.js +675 -0
- package/dist/chunk-4YMD2OOZ.js +23 -0
- package/dist/chunk-5WGEURVI.js +156 -0
- package/dist/chunk-5YTBTF25.js +29 -0
- package/dist/chunk-6DHBYBTO.js +166 -0
- package/dist/chunk-76QBEIGO.js +66 -0
- package/dist/chunk-7DKX2SPN.js +100 -0
- package/dist/chunk-7REDODS2.js +468 -0
- package/dist/chunk-C56BC2FY.js +254 -0
- package/dist/chunk-DGSF2Q5H.js +60 -0
- package/dist/chunk-EMCAWMHC.js +3982 -0
- package/dist/chunk-EZG76F7R.js +159 -0
- package/dist/chunk-FJ6ZS5KB.js +3607 -0
- package/dist/chunk-GNPVYOPB.js +17 -0
- package/dist/chunk-HJPTWBLH.js +38 -0
- package/dist/chunk-IZW6MK3U.js +248 -0
- package/dist/chunk-LH6Z6KFV.js +247 -0
- package/dist/chunk-MZUI3JNX.js +93 -0
- package/dist/chunk-NDZFBZHC.js +167 -0
- package/dist/chunk-NOO35BQ2.js +37 -0
- package/dist/chunk-NUQCEOKA.js +13 -0
- package/dist/chunk-QTNO2WD6.js +56 -0
- package/dist/chunk-RVB7ITKN.js +49 -0
- package/dist/chunk-TRU5OHQ5.js +6904 -0
- package/dist/chunk-VKFQJEMW.js +814 -0
- package/dist/chunk-VTIL47DT.js +125 -0
- package/dist/chunk-WHOJWOSV.js +112 -0
- package/dist/chunk-WKP4D5MO.js +1692 -0
- package/dist/chunk-X4DVXBFY.js +38 -0
- package/dist/chunk-XQ22GLYS.js +118 -0
- package/dist/chunk-YDZYMZBE.js +670 -0
- package/dist/chunk-YGPIY3WT.js +1146 -0
- package/dist/chunk-YYRDLFSJ.js +602 -0
- package/dist/chunk-ZUTSMMAG.js +46 -0
- package/dist/cli.d.ts +331 -0
- package/dist/cli.js +33 -0
- package/dist/codegen-command-OOKK6AZK.js +40 -0
- package/dist/codegen.d.ts +114 -0
- package/dist/codegen.js +71 -0
- package/dist/completion-TIPPZN7H.js +298 -0
- package/dist/config-NL33PN4D.js +84 -0
- package/dist/deploy-command-4EQ7XX5G.js +451 -0
- package/dist/env-target-IFJ5QDHC.js +16 -0
- package/dist/ephemeral-command-3X3I4ULC.js +242 -0
- package/dist/index.d.ts +4477 -0
- package/dist/index.js +300 -0
- package/dist/init-command-R6H7ZXW5.js +27 -0
- package/dist/internal.d.ts +74 -0
- package/dist/internal.js +2065 -0
- package/dist/io-AMIKRLPC.js +11 -0
- package/dist/live-diff-Y3AKETHE.js +196 -0
- package/dist/lock-3CVKALKT.js +37 -0
- package/dist/lock-commands-XTR2YKLY.js +232 -0
- package/dist/login-command-ACJF6KWQ.js +167 -0
- package/dist/logout-command-MX3MJS5U.js +68 -0
- package/dist/loop-OM3P2Z6O.js +93 -0
- package/dist/marketplace-command-RATXTKXN.js +379 -0
- package/dist/meta-client-OW5WKWW7.js +170 -0
- package/dist/node.d.ts +59 -0
- package/dist/node.js +442 -0
- package/dist/profile-command-SWJ3SPKR.js +77 -0
- package/dist/release-command-VV5UVZKL.js +427 -0
- package/dist/response-CVAE2kMj.d.ts +1915 -0
- package/dist/routes-manifest-SP3ZXLMR.js +244 -0
- package/dist/runtime-V4C3AC3A.js +13 -0
- package/dist/sandbox-details-command-HJE5SPVG.js +18 -0
- package/dist/sandbox-export-command-QCJY4GMV.js +24 -0
- package/dist/static-host-D6KS7X45.js +138 -0
- package/dist/store-BQ97nKIF.d.ts +7760 -0
- package/dist/test-command-TSPBQHBM.js +383 -0
- package/dist/validate-command-4ERHJSCO.js +122 -0
- package/dist/verify-rollout-FAVQ6EJY.js +40 -0
- package/dist/workspace-K72NP7SX.js +49 -0
- package/dist/workspace-command-OF23DPNI.js +156 -0
- package/dist/workspace-export-AJMGN3CQ.js +10 -0
- package/llms/fields.md +104 -0
- package/llms/filters.md +183 -0
- package/llms/kinds-agent-mcp.md +11 -0
- package/llms/kinds-core.md +68 -0
- package/llms/kinds-realtime.md +76 -0
- package/llms/lambda.md +111 -0
- package/llms/legacy.md +43 -0
- package/llms/object-kinds.md +31 -0
- package/llms/statements-calls.md +23 -0
- package/llms/statements-catalog.md +309 -0
- package/llms/statements-data.md +58 -0
- package/llms/statements-runtime.md +48 -0
- package/llms/tests.md +58 -0
- package/llms/triggers.md +22 -0
- package/llms/values.md +29 -0
- package/llms-full.txt +1672 -0
- package/llms.txt +483 -0
- package/manifest.json +9592 -0
- package/package.json +110 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// src/auth/loopback.ts
|
|
2
|
+
import { createServer } from "http";
|
|
3
|
+
import { spawn } from "child_process";
|
|
4
|
+
var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
5
|
+
function formatDuration(ms) {
|
|
6
|
+
const seconds = Math.round(ms / 1e3);
|
|
7
|
+
if (seconds < 60) return `${seconds} second${seconds === 1 ? "" : "s"}`;
|
|
8
|
+
const minutes = Math.round(seconds / 60);
|
|
9
|
+
return `${minutes} minute${minutes === 1 ? "" : "s"}`;
|
|
10
|
+
}
|
|
11
|
+
var CLOSE_TAB_HTML = '<!doctype html><meta charset=utf-8><title>xanots</title><body style="font-family:system-ui;padding:3rem;text-align:center"><h1>Authentication complete</h1><p>You can close this tab and return to the terminal.</p></body>';
|
|
12
|
+
function startCallbackServer(opts) {
|
|
13
|
+
const { callbackPath, expectedState, port, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
|
|
14
|
+
return new Promise((resolveListener, rejectListener) => {
|
|
15
|
+
let resolveResult;
|
|
16
|
+
let rejectResult;
|
|
17
|
+
const waitForCallback = new Promise((res, rej) => {
|
|
18
|
+
resolveResult = res;
|
|
19
|
+
rejectResult = rej;
|
|
20
|
+
});
|
|
21
|
+
waitForCallback.catch(() => {
|
|
22
|
+
});
|
|
23
|
+
let redirectUri = "";
|
|
24
|
+
const server = createServer((req, res) => {
|
|
25
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
26
|
+
if (url.pathname !== callbackPath) {
|
|
27
|
+
respond(res, 404, "Not found");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const state = url.searchParams.get("state");
|
|
31
|
+
if (state !== expectedState) {
|
|
32
|
+
respond(res, 400, "Unexpected or missing state \u2014 ignoring this request.");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const error = url.searchParams.get("error");
|
|
36
|
+
if (error) {
|
|
37
|
+
const authError = new Error(
|
|
38
|
+
`Authorization server returned error: ${error}`
|
|
39
|
+
);
|
|
40
|
+
authError.error = error;
|
|
41
|
+
respond(res, 400, "Authorization failed. Check the terminal for details.", () => finish(authError));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const code = url.searchParams.get("code");
|
|
45
|
+
if (!code) {
|
|
46
|
+
respond(
|
|
47
|
+
res,
|
|
48
|
+
400,
|
|
49
|
+
"Missing authorization code.",
|
|
50
|
+
() => finish(new Error("Callback carried no authorization code."))
|
|
51
|
+
);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
res.writeHead(200, { "Content-Type": "text/html", Connection: "close" }).end(CLOSE_TAB_HTML, () => {
|
|
55
|
+
finish(void 0, { code, callbackUrl: `${redirectUri}?${url.searchParams.toString()}` });
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
const sockets = /* @__PURE__ */ new Set();
|
|
59
|
+
server.on("connection", (socket) => {
|
|
60
|
+
sockets.add(socket);
|
|
61
|
+
socket.on("close", () => sockets.delete(socket));
|
|
62
|
+
socket.on("error", () => {
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
finish(new Error(`Timed out after ${formatDuration(timeoutMs)} waiting for the browser redirect.`));
|
|
67
|
+
}, timeoutMs);
|
|
68
|
+
timer.unref?.();
|
|
69
|
+
let settled = false;
|
|
70
|
+
function finish(err, result) {
|
|
71
|
+
if (settled) return;
|
|
72
|
+
settled = true;
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
server.close();
|
|
75
|
+
for (const socket of sockets) socket.destroy();
|
|
76
|
+
if (err) rejectResult(err);
|
|
77
|
+
else resolveResult(result);
|
|
78
|
+
}
|
|
79
|
+
server.on("error", (err) => {
|
|
80
|
+
if (!settled) rejectListener(err);
|
|
81
|
+
});
|
|
82
|
+
server.listen(port ?? 0, "127.0.0.1", () => {
|
|
83
|
+
const boundPort = server.address().port;
|
|
84
|
+
redirectUri = `http://127.0.0.1:${boundPort}${callbackPath}`;
|
|
85
|
+
resolveListener({
|
|
86
|
+
redirectUri,
|
|
87
|
+
waitForCallback,
|
|
88
|
+
close: () => finish(new Error("Login cancelled."))
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function respond(res, status, message, onFlush) {
|
|
94
|
+
res.writeHead(status, { "Content-Type": "text/html", Connection: "close" }).end(
|
|
95
|
+
`<!doctype html><meta charset=utf-8><body style="font-family:system-ui;padding:3rem;text-align:center">${message}</body>`,
|
|
96
|
+
onFlush
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
function browserCommand(platform, url) {
|
|
100
|
+
switch (platform) {
|
|
101
|
+
case "darwin":
|
|
102
|
+
return { cmd: "open", args: [url] };
|
|
103
|
+
case "win32":
|
|
104
|
+
return { cmd: "cmd", args: ["/c", "start", "", url.replace(/&/g, "^&")] };
|
|
105
|
+
default:
|
|
106
|
+
return { cmd: "xdg-open", args: [url] };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function openBrowser(url) {
|
|
110
|
+
if (process.env.XANO_NO_BROWSER) return;
|
|
111
|
+
const { cmd, args } = browserCommand(process.platform, url);
|
|
112
|
+
try {
|
|
113
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
114
|
+
child.on("error", () => {
|
|
115
|
+
});
|
|
116
|
+
child.unref();
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
startCallbackServer,
|
|
123
|
+
openBrowser
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=chunk-VTIL47DT.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// src/kinds/path-params.ts
|
|
2
|
+
var PARAM_MARKER = /\{([^/{}]+)\}/g;
|
|
3
|
+
var NON_SEGMENT_TYPES = /* @__PURE__ */ new Set(["obj", "json", "blob", "blob_img", "blob_video", "blob_audio", "vector"]);
|
|
4
|
+
function isSegmentType(type) {
|
|
5
|
+
return !NON_SEGMENT_TYPES.has(type) && !type.startsWith("geo_");
|
|
6
|
+
}
|
|
7
|
+
function parsePathParams(context, path) {
|
|
8
|
+
const params = [];
|
|
9
|
+
const cleaned = path.replace(/^\/+/, "");
|
|
10
|
+
let residue = "";
|
|
11
|
+
let cursor = 0;
|
|
12
|
+
for (const match of cleaned.matchAll(PARAM_MARKER)) {
|
|
13
|
+
residue += cleaned.slice(cursor, match.index);
|
|
14
|
+
cursor = match.index + match[0].length;
|
|
15
|
+
const name = match[1];
|
|
16
|
+
if (params.includes(name)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`${context}: the path param \`${name}\` appears twice. Each {param} must be unique within one path \u2014 two segments cannot bind the same input.`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
params.push(name);
|
|
22
|
+
}
|
|
23
|
+
residue += cleaned.slice(cursor);
|
|
24
|
+
if (residue.includes("{") || residue.includes("}")) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`${context}: "${path}" has an unmatched brace. A path param is written \`{name}\`, where the name holds no "/", "{" or "}" \u2014 it may sit anywhere in the path ("blog/{slug}", "blog/post-{slug}"), and each name must have an input of the same name to bind to.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return params;
|
|
30
|
+
}
|
|
31
|
+
function assertPathParamInputs(context, params, inputs) {
|
|
32
|
+
for (const name of params) {
|
|
33
|
+
const descriptor = inputs?.[name];
|
|
34
|
+
if (!descriptor) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`${context}: the path declares {${name}} but there is no \`${name}\` input to bind it to, so the segment would be an inert part of the route string. Add it: input: { ${name}: input.text() }.`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (descriptor.options?.array === true) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`${context}: the path param \`${name}\` cannot be a list \u2014 one path segment holds one value. Use a scalar input, or take the list as a query-string/body param under a different name.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const type = descriptor.type;
|
|
45
|
+
if (!isSegmentType(type)) {
|
|
46
|
+
const article = /^[aeiou]/i.test(type) ? "an" : "a";
|
|
47
|
+
throw new Error(
|
|
48
|
+
`${context}: the path param \`${name}\` cannot be ${article} \`${type}\` \u2014 a path segment is a single string, so structured, binary, and multi-valued types have no URL form. Use a scalar input (text/int/uuid/\u2026), or move this value to a query-string or body param.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function unboundPathParams(path, storedInput) {
|
|
54
|
+
let params;
|
|
55
|
+
try {
|
|
56
|
+
params = parsePathParams("path", path);
|
|
57
|
+
} catch {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const bound = new Set(
|
|
61
|
+
(Array.isArray(storedInput) ? storedInput : []).map(
|
|
62
|
+
(entry) => entry !== null && typeof entry === "object" ? entry.name : void 0
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
return params.filter((param) => !bound.has(param));
|
|
66
|
+
}
|
|
67
|
+
var DOT_SEGMENT = /^(\.|%2e){1,2}$/i;
|
|
68
|
+
function fillPathParams(context, accessor, path, params, encode = false) {
|
|
69
|
+
const declared = parsePathParams(context, path);
|
|
70
|
+
const given = params ?? {};
|
|
71
|
+
for (const key of Object.keys(given)) {
|
|
72
|
+
if (!declared.includes(key)) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`${context}: ${accessor} was given \`${key}\`, which is not a {param} segment of the path. ` + (declared.length ? `Expected: ${declared.map((p) => `\`${p}\``).join(", ")}.` : `This path is static \u2014 call ${accessor} with no arguments.`)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return path.replace(PARAM_MARKER, (_all, key) => {
|
|
79
|
+
const value = given[key];
|
|
80
|
+
if (value === void 0 || value === null || value === "") {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`${context}: ${accessor} needs a value for the path param \`${key}\` \u2014 pass { ${declared.map((p) => `${p}: \u2026 `).join(", ")}}.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`${context}: the path param \`${key}\` is ${value} \u2014 not a finite value to put in a path.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
const text = String(value);
|
|
91
|
+
if (text.includes("/")) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`${context}: the path param \`${key}\` cannot contain "/" (got ${JSON.stringify(text)}) \u2014 it would fabricate a path segment and address a different route.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (!encode) return text;
|
|
97
|
+
if (DOT_SEGMENT.test(text)) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`${context}: the path param \`${key}\` cannot be ${JSON.stringify(text)} \u2014 a "." or ".." segment is REMOVED by every URL parser before the request is routed, so the path would address a different endpoint (with the segment before it dropped). Percent-encoding does not help: the URL standard reads "%2e" as a dot for this check too.`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return encodeURIComponent(text);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
parsePathParams,
|
|
108
|
+
assertPathParamInputs,
|
|
109
|
+
unboundPathParams,
|
|
110
|
+
fillPathParams
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=chunk-WHOJWOSV.js.map
|