@gurulu/cli 1.5.4 → 1.6.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/dist/bin.js +303 -114
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/index.js +303 -114
- package/dist/lib/api.d.ts +45 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/config.d.ts +13 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/identity.d.ts +21 -0
- package/dist/lib/identity.d.ts.map +1 -0
- package/dist/lib/install-plan.d.ts.map +1 -1
- package/dist/lib/install-plan.js +2 -2
- package/dist/wizard/auth.d.ts.map +1 -1
- package/dist/wizard/features.d.ts.map +1 -1
- package/dist/wizard/run.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -39299,27 +39299,60 @@ class ApiClient {
|
|
|
39299
39299
|
"User-Agent": "@gurulu/cli",
|
|
39300
39300
|
...extra
|
|
39301
39301
|
};
|
|
39302
|
-
if (this.opts.
|
|
39302
|
+
if (this.opts.bearer) {
|
|
39303
|
+
h2.Authorization = `Bearer ${this.opts.bearer}`;
|
|
39304
|
+
} else if (this.opts.apiKey) {
|
|
39303
39305
|
h2["X-Gurulu-Api-Key"] = this.opts.apiKey;
|
|
39304
39306
|
}
|
|
39305
39307
|
return h2;
|
|
39306
39308
|
}
|
|
39307
39309
|
async get(path, query) {
|
|
39308
39310
|
const qs = query ? `?${new URLSearchParams(Object.fromEntries(Object.entries(query).map(([k2, v2]) => [k2, String(v2)]))).toString()}` : "";
|
|
39309
|
-
|
|
39310
|
-
method: "GET",
|
|
39311
|
-
headers: this.headers()
|
|
39312
|
-
});
|
|
39313
|
-
return this.handle(res);
|
|
39311
|
+
return this.send("GET", `${path}${qs}`);
|
|
39314
39312
|
}
|
|
39315
39313
|
async post(path, body) {
|
|
39316
|
-
|
|
39317
|
-
|
|
39318
|
-
|
|
39319
|
-
|
|
39314
|
+
return this.send("POST", path, body);
|
|
39315
|
+
}
|
|
39316
|
+
async send(method, pathWithQs, body, retried = false) {
|
|
39317
|
+
const res = await $request(`${this.opts.endpoint}${pathWithQs}`, {
|
|
39318
|
+
method,
|
|
39319
|
+
headers: method === "POST" ? this.headers({ "Content-Type": "application/json" }) : this.headers(),
|
|
39320
|
+
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {}
|
|
39320
39321
|
});
|
|
39322
|
+
if (res.statusCode === 401 && this.opts.bearer && this.opts.refresh && !retried) {
|
|
39323
|
+
await res.body.text().catch(() => "");
|
|
39324
|
+
if (await this.refreshBearer()) {
|
|
39325
|
+
return this.send(method, pathWithQs, body, true);
|
|
39326
|
+
}
|
|
39327
|
+
}
|
|
39321
39328
|
return this.handle(res);
|
|
39322
39329
|
}
|
|
39330
|
+
async refreshBearer() {
|
|
39331
|
+
const rc = this.opts.refresh;
|
|
39332
|
+
if (!rc)
|
|
39333
|
+
return false;
|
|
39334
|
+
try {
|
|
39335
|
+
const res = await $request(`${this.opts.endpoint}/v1/cli/auth/refresh`, {
|
|
39336
|
+
method: "POST",
|
|
39337
|
+
headers: {
|
|
39338
|
+
Accept: "application/json",
|
|
39339
|
+
"Content-Type": "application/json",
|
|
39340
|
+
"User-Agent": "@gurulu/cli"
|
|
39341
|
+
},
|
|
39342
|
+
body: JSON.stringify({ refresh_token: rc.refreshToken })
|
|
39343
|
+
});
|
|
39344
|
+
const text = await res.body.text();
|
|
39345
|
+
if (res.statusCode < 200 || res.statusCode >= 300)
|
|
39346
|
+
return false;
|
|
39347
|
+
const t2 = JSON.parse(text);
|
|
39348
|
+
this.opts.bearer = t2.access_token;
|
|
39349
|
+
rc.refreshToken = t2.refresh_token;
|
|
39350
|
+
rc.onRotate(t2);
|
|
39351
|
+
return true;
|
|
39352
|
+
} catch {
|
|
39353
|
+
return false;
|
|
39354
|
+
}
|
|
39355
|
+
}
|
|
39323
39356
|
listWorkspaces() {
|
|
39324
39357
|
return this.get("/v1/cli/workspaces");
|
|
39325
39358
|
}
|
|
@@ -39329,6 +39362,15 @@ class ApiClient {
|
|
|
39329
39362
|
issueWriteKey(workspaceId) {
|
|
39330
39363
|
return this.post(`/v1/cli/workspaces/${encodeURIComponent(workspaceId)}/write-key`, {});
|
|
39331
39364
|
}
|
|
39365
|
+
identityListWorkspaces() {
|
|
39366
|
+
return this.get("/v1/workspaces");
|
|
39367
|
+
}
|
|
39368
|
+
identityCreateWorkspace(body) {
|
|
39369
|
+
return this.post("/v1/workspaces", body);
|
|
39370
|
+
}
|
|
39371
|
+
mintWorkspaceKey(workspaceId, body) {
|
|
39372
|
+
return this.post(`/v1/workspaces/${encodeURIComponent(workspaceId)}/keys`, body);
|
|
39373
|
+
}
|
|
39332
39374
|
planEvents(body) {
|
|
39333
39375
|
return this.post("/v1/cli/ai/plan-events", body);
|
|
39334
39376
|
}
|
|
@@ -39428,6 +39470,21 @@ function writeGlobalCredentials(creds) {
|
|
|
39428
39470
|
chmodSync(path, 384);
|
|
39429
39471
|
} catch {}
|
|
39430
39472
|
}
|
|
39473
|
+
function readIdentity() {
|
|
39474
|
+
return readGlobalCredentials().identity ?? null;
|
|
39475
|
+
}
|
|
39476
|
+
function writeIdentity(identity) {
|
|
39477
|
+
const creds = readGlobalCredentials();
|
|
39478
|
+
creds.identity = identity;
|
|
39479
|
+
writeGlobalCredentials(creds);
|
|
39480
|
+
}
|
|
39481
|
+
function clearIdentity() {
|
|
39482
|
+
const creds = readGlobalCredentials();
|
|
39483
|
+
if (creds.identity) {
|
|
39484
|
+
delete creds.identity;
|
|
39485
|
+
writeGlobalCredentials(creds);
|
|
39486
|
+
}
|
|
39487
|
+
}
|
|
39431
39488
|
function findCredentialForWorkspace(workspaceId) {
|
|
39432
39489
|
const creds = readGlobalCredentials();
|
|
39433
39490
|
return creds.workspaces.find((w2) => w2.workspace_id === workspaceId) ?? null;
|
|
@@ -39824,8 +39881,92 @@ var auditCmd = defineCommand({
|
|
|
39824
39881
|
});
|
|
39825
39882
|
|
|
39826
39883
|
// src/commands/auth.ts
|
|
39827
|
-
|
|
39884
|
+
import open from "open";
|
|
39885
|
+
|
|
39886
|
+
// src/lib/identity.ts
|
|
39887
|
+
function identityClient(id) {
|
|
39888
|
+
return new ApiClient({
|
|
39889
|
+
endpoint: id.endpoint,
|
|
39890
|
+
bearer: id.access_token,
|
|
39891
|
+
refresh: {
|
|
39892
|
+
refreshToken: id.refresh_token,
|
|
39893
|
+
onRotate: (t2) => {
|
|
39894
|
+
const cur = readIdentity();
|
|
39895
|
+
if (!cur)
|
|
39896
|
+
return;
|
|
39897
|
+
writeIdentity({
|
|
39898
|
+
...cur,
|
|
39899
|
+
access_token: t2.access_token,
|
|
39900
|
+
refresh_token: t2.refresh_token,
|
|
39901
|
+
expires_at: t2.expires_in != null ? new Date(Date.now() + t2.expires_in * 1000).toISOString() : cur.expires_at,
|
|
39902
|
+
last_used: new Date().toISOString()
|
|
39903
|
+
});
|
|
39904
|
+
}
|
|
39905
|
+
}
|
|
39906
|
+
});
|
|
39907
|
+
}
|
|
39828
39908
|
var POLL_MAX_ATTEMPTS = 180;
|
|
39909
|
+
function sleep(ms) {
|
|
39910
|
+
return new Promise((r3) => setTimeout(r3, ms));
|
|
39911
|
+
}
|
|
39912
|
+
function toIdentity(endpoint, token) {
|
|
39913
|
+
return {
|
|
39914
|
+
access_token: token.access_token,
|
|
39915
|
+
refresh_token: token.refresh_token ?? "",
|
|
39916
|
+
expires_at: token.expires_in != null ? new Date(Date.now() + token.expires_in * 1000).toISOString() : new Date(Date.now() + 6 * 24 * 60 * 60 * 1000).toISOString(),
|
|
39917
|
+
endpoint,
|
|
39918
|
+
user_id: token.user_id,
|
|
39919
|
+
last_used: new Date().toISOString()
|
|
39920
|
+
};
|
|
39921
|
+
}
|
|
39922
|
+
async function runDeviceFlowIdentity(endpoint, display) {
|
|
39923
|
+
const client = new ApiClient({ endpoint });
|
|
39924
|
+
const start = await client.post("/v1/cli/auth/device", {
|
|
39925
|
+
client_name: "@gurulu/cli",
|
|
39926
|
+
grant_type: "identity"
|
|
39927
|
+
});
|
|
39928
|
+
const url = start.verification_url_complete || start.verification_url;
|
|
39929
|
+
display.onPrompt(start.user_code, url);
|
|
39930
|
+
if (display.openBrowser) {
|
|
39931
|
+
try {
|
|
39932
|
+
await display.openBrowser(url);
|
|
39933
|
+
} catch {}
|
|
39934
|
+
}
|
|
39935
|
+
display.onWaiting?.();
|
|
39936
|
+
const interval = Math.max((start.interval ?? 5) * 1000, 3000);
|
|
39937
|
+
for (let i2 = 0;i2 < POLL_MAX_ATTEMPTS; i2++) {
|
|
39938
|
+
await sleep(interval);
|
|
39939
|
+
try {
|
|
39940
|
+
const token = await client.post("/v1/cli/auth/token", {
|
|
39941
|
+
device_code: start.device_code
|
|
39942
|
+
});
|
|
39943
|
+
if (token.access_token && token.refresh_token) {
|
|
39944
|
+
const id = toIdentity(endpoint, token);
|
|
39945
|
+
writeIdentity(id);
|
|
39946
|
+
return id;
|
|
39947
|
+
}
|
|
39948
|
+
} catch (err) {
|
|
39949
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
39950
|
+
if (msg.includes("AUTHORIZATION_PENDING"))
|
|
39951
|
+
continue;
|
|
39952
|
+
if (msg.includes("ACCESS_DENIED"))
|
|
39953
|
+
throw new Error("Yetkilendirme reddedildi");
|
|
39954
|
+
if (msg.includes("EXPIRED_TOKEN"))
|
|
39955
|
+
throw new Error("Kod süresi doldu — tekrar dene");
|
|
39956
|
+
}
|
|
39957
|
+
}
|
|
39958
|
+
throw new Error("device flow zaman aşımına uğradı");
|
|
39959
|
+
}
|
|
39960
|
+
function loadIdentity(endpoint) {
|
|
39961
|
+
const id = readIdentity();
|
|
39962
|
+
if (!id?.refresh_token)
|
|
39963
|
+
return null;
|
|
39964
|
+
if (id.endpoint !== endpoint)
|
|
39965
|
+
return null;
|
|
39966
|
+
return id;
|
|
39967
|
+
}
|
|
39968
|
+
|
|
39969
|
+
// src/commands/auth.ts
|
|
39829
39970
|
var loginCmd = defineCommand({
|
|
39830
39971
|
meta: {
|
|
39831
39972
|
name: "login",
|
|
@@ -39859,54 +40000,27 @@ var loginCmd = defineCommand({
|
|
|
39859
40000
|
console.log(`[gurulu] credential saved for workspace ${workspaceId}`);
|
|
39860
40001
|
return;
|
|
39861
40002
|
}
|
|
39862
|
-
const client = new ApiClient({ endpoint });
|
|
39863
|
-
let start;
|
|
39864
40003
|
try {
|
|
39865
|
-
|
|
39866
|
-
|
|
40004
|
+
const id = await runDeviceFlowIdentity(endpoint, {
|
|
40005
|
+
onPrompt: (userCode, url) => {
|
|
40006
|
+
console.log(`[gurulu] visit ${url}`);
|
|
40007
|
+
console.log(`[gurulu] code: ${userCode}`);
|
|
40008
|
+
console.log("[gurulu] waiting for browser approval (~15m)...");
|
|
40009
|
+
},
|
|
40010
|
+
openBrowser: async (url) => {
|
|
40011
|
+
await open(url);
|
|
40012
|
+
}
|
|
39867
40013
|
});
|
|
40014
|
+
console.log(`
|
|
40015
|
+
[gurulu] signed in ✓ — account session stored (reused across projects + MCP)`);
|
|
40016
|
+
if (id.user_id) {
|
|
40017
|
+
console.log(`[gurulu] user: ${id.user_id}`);
|
|
40018
|
+
}
|
|
39868
40019
|
} catch (err) {
|
|
39869
|
-
console.error(`
|
|
40020
|
+
console.error(`
|
|
40021
|
+
[gurulu] login failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
39870
40022
|
process.exit(1);
|
|
39871
40023
|
}
|
|
39872
|
-
console.log(`[gurulu] visit ${start.verification_url}`);
|
|
39873
|
-
console.log(`[gurulu] enter code: ${start.user_code}`);
|
|
39874
|
-
console.log(`[gurulu] or follow: ${start.verification_url_complete}
|
|
39875
|
-
`);
|
|
39876
|
-
console.log(`[gurulu] polling (${POLL_MAX_ATTEMPTS * 5}s timeout)...`);
|
|
39877
|
-
const interval = (start.interval ?? 5) * 1000;
|
|
39878
|
-
for (let i2 = 0;i2 < POLL_MAX_ATTEMPTS; i2++) {
|
|
39879
|
-
await sleep(Math.max(interval, POLL_INTERVAL_MS));
|
|
39880
|
-
try {
|
|
39881
|
-
const token = await client.post("/v1/cli/auth/token", {
|
|
39882
|
-
device_code: start.device_code
|
|
39883
|
-
});
|
|
39884
|
-
if (token.access_token) {
|
|
39885
|
-
upsertCredential({
|
|
39886
|
-
workspace_id: token.workspace_id,
|
|
39887
|
-
api_key: token.access_token,
|
|
39888
|
-
endpoint,
|
|
39889
|
-
last_used: new Date().toISOString()
|
|
39890
|
-
});
|
|
39891
|
-
console.log(`
|
|
39892
|
-
[gurulu] authorized — workspace ${token.workspace_id}`);
|
|
39893
|
-
return;
|
|
39894
|
-
}
|
|
39895
|
-
} catch (err) {
|
|
39896
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
39897
|
-
if (msg.includes("AUTHORIZATION_PENDING") || err.code === "AUTHORIZATION_PENDING") {
|
|
39898
|
-
continue;
|
|
39899
|
-
}
|
|
39900
|
-
if (msg.includes("ACCESS_DENIED") || msg.includes("EXPIRED_TOKEN")) {
|
|
39901
|
-
console.error(`
|
|
39902
|
-
[gurulu] device flow ended: ${msg}`);
|
|
39903
|
-
process.exit(1);
|
|
39904
|
-
}
|
|
39905
|
-
}
|
|
39906
|
-
}
|
|
39907
|
-
console.error(`
|
|
39908
|
-
[gurulu] timed out waiting for authorization`);
|
|
39909
|
-
process.exit(1);
|
|
39910
40024
|
}
|
|
39911
40025
|
});
|
|
39912
40026
|
var logoutCmd = defineCommand({
|
|
@@ -39924,14 +40038,23 @@ var logoutCmd = defineCommand({
|
|
|
39924
40038
|
const creds = readGlobalCredentials();
|
|
39925
40039
|
for (const w2 of creds.workspaces)
|
|
39926
40040
|
removeCredential(w2.workspace_id);
|
|
39927
|
-
|
|
40041
|
+
clearIdentity();
|
|
40042
|
+
console.log(`[gurulu] signed out — removed ${creds.workspaces.length} workspace credential(s) + account session`);
|
|
39928
40043
|
}
|
|
39929
40044
|
});
|
|
39930
40045
|
var whoamiCmd = defineCommand({
|
|
39931
40046
|
meta: { name: "whoami", description: "Show active credentials + workspace info" },
|
|
39932
40047
|
async run() {
|
|
40048
|
+
const identity = readIdentity();
|
|
40049
|
+
if (identity) {
|
|
40050
|
+
console.log(`[gurulu] account session: active${identity.user_id ? ` (user ${identity.user_id})` : ""} @ ${identity.endpoint}`);
|
|
40051
|
+
}
|
|
39933
40052
|
const cred = resolveActiveCredential({});
|
|
39934
40053
|
if (!cred) {
|
|
40054
|
+
if (identity) {
|
|
40055
|
+
console.log("[gurulu] no workspace bound yet — run `gurulu init` in a project");
|
|
40056
|
+
return;
|
|
40057
|
+
}
|
|
39935
40058
|
console.log("[gurulu] not logged in — run `gurulu login`");
|
|
39936
40059
|
process.exit(1);
|
|
39937
40060
|
}
|
|
@@ -39948,13 +40071,11 @@ var whoamiCmd = defineCommand({
|
|
|
39948
40071
|
}
|
|
39949
40072
|
}
|
|
39950
40073
|
});
|
|
39951
|
-
function sleep(ms) {
|
|
39952
|
-
return new Promise((r3) => setTimeout(r3, ms));
|
|
39953
|
-
}
|
|
39954
40074
|
|
|
39955
40075
|
// src/wizard/run.ts
|
|
39956
40076
|
import { existsSync as existsSync11, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
39957
|
-
import {
|
|
40077
|
+
import { homedir as homedir3 } from "node:os";
|
|
40078
|
+
import { dirname as dirname5, join as join11, resolve as resolve2 } from "node:path";
|
|
39958
40079
|
import * as p4 from "@clack/prompts";
|
|
39959
40080
|
|
|
39960
40081
|
// src/commands/pull.ts
|
|
@@ -40695,8 +40816,8 @@ function snippetWeb(workspaceKey, jsError = false) {
|
|
|
40695
40816
|
return `import gurulu from '@gurulu/web';
|
|
40696
40817
|
|
|
40697
40818
|
gurulu.init({
|
|
40698
|
-
workspaceKey: process.env.
|
|
40699
|
-
endpoint: process.env.
|
|
40819
|
+
workspaceKey: process.env.VITE_GURULU_WORKSPACE ?? '${workspaceKey}',
|
|
40820
|
+
endpoint: process.env.VITE_GURULU_ENDPOINT, // optional, defaults to https://ingest.gurulu.io${autocaptureLine(jsError, " ")}
|
|
40700
40821
|
});`;
|
|
40701
40822
|
}
|
|
40702
40823
|
function snippetNext(workspaceKey, jsError = false) {
|
|
@@ -40901,8 +41022,8 @@ function buildInstallPlan(detected, ctx = {}) {
|
|
|
40901
41022
|
|
|
40902
41023
|
// src/lib/ui.ts
|
|
40903
41024
|
var noColor = Boolean(process.env.NO_COLOR) || process.env.TERM === "dumb" || !process.stdout.isTTY;
|
|
40904
|
-
function wrap(
|
|
40905
|
-
return (s2) => noColor ? s2 : `\x1B[${
|
|
41025
|
+
function wrap(open2, close) {
|
|
41026
|
+
return (s2) => noColor ? s2 : `\x1B[${open2}m${s2}\x1B[${close}m`;
|
|
40906
41027
|
}
|
|
40907
41028
|
function fg(code) {
|
|
40908
41029
|
return (s2) => noColor ? s2 : `\x1B[38;5;${code}m${s2}\x1B[39m`;
|
|
@@ -41189,7 +41310,16 @@ function buildAugmentTask(competitors) {
|
|
|
41189
41310
|
|
|
41190
41311
|
// src/wizard/auth.ts
|
|
41191
41312
|
import * as p from "@clack/prompts";
|
|
41192
|
-
import
|
|
41313
|
+
import open2 from "open";
|
|
41314
|
+
var SECRET_SCOPES = [
|
|
41315
|
+
"admin",
|
|
41316
|
+
"ingest",
|
|
41317
|
+
"observability",
|
|
41318
|
+
"registry.read",
|
|
41319
|
+
"registry.write",
|
|
41320
|
+
"events.read",
|
|
41321
|
+
"events.write"
|
|
41322
|
+
];
|
|
41193
41323
|
async function ensureAuth(opts) {
|
|
41194
41324
|
const endpoint = opts.endpoint ?? DEFAULT_ENDPOINT;
|
|
41195
41325
|
if (opts.apiKey) {
|
|
@@ -41215,57 +41345,80 @@ async function ensureAuth(opts) {
|
|
|
41215
41345
|
endpoint: existing.endpoint
|
|
41216
41346
|
};
|
|
41217
41347
|
}
|
|
41218
|
-
return
|
|
41348
|
+
return identityWorkspaceFlow(endpoint, opts.workspaceId);
|
|
41219
41349
|
}
|
|
41220
|
-
async function
|
|
41221
|
-
|
|
41222
|
-
|
|
41223
|
-
|
|
41224
|
-
|
|
41225
|
-
|
|
41226
|
-
|
|
41227
|
-
|
|
41228
|
-
|
|
41229
|
-
|
|
41230
|
-
|
|
41231
|
-
} catch {
|
|
41232
|
-
p.log.warn("Tarayıcı otomatik açılamadı — yukarıdaki linki elle aç.");
|
|
41233
|
-
}
|
|
41234
|
-
const s2 = p.spinner();
|
|
41235
|
-
s2.start("Tarayıcıda onay bekleniyor…");
|
|
41236
|
-
const interval = Math.max((start.interval ?? 5) * 1000, 3000);
|
|
41237
|
-
const maxAttempts = 180;
|
|
41238
|
-
for (let i2 = 0;i2 < maxAttempts; i2++) {
|
|
41239
|
-
await sleep2(interval);
|
|
41240
|
-
try {
|
|
41241
|
-
const token = await client.post("/v1/cli/auth/token", {
|
|
41242
|
-
device_code: start.device_code
|
|
41243
|
-
});
|
|
41244
|
-
if (token.access_token) {
|
|
41245
|
-
upsertCredential({
|
|
41246
|
-
workspace_id: token.workspace_id,
|
|
41247
|
-
api_key: token.access_token,
|
|
41248
|
-
endpoint,
|
|
41249
|
-
last_used: new Date().toISOString()
|
|
41250
|
-
});
|
|
41251
|
-
s2.stop("Yetkilendirildi ✓");
|
|
41252
|
-
return { apiKey: token.access_token, workspaceId: token.workspace_id, endpoint };
|
|
41350
|
+
async function identityWorkspaceFlow(endpoint, wantWorkspaceId) {
|
|
41351
|
+
let id = loadIdentity(endpoint);
|
|
41352
|
+
if (!id) {
|
|
41353
|
+
const spin = p.spinner();
|
|
41354
|
+
id = await runDeviceFlowIdentity(endpoint, {
|
|
41355
|
+
onPrompt: (userCode, url) => p.note(`${userCode}
|
|
41356
|
+
|
|
41357
|
+
${url}`, "Tarayıcıda hesabına giriş yap"),
|
|
41358
|
+
onWaiting: () => spin.start("Tarayıcıda onay bekleniyor…"),
|
|
41359
|
+
openBrowser: async (url) => {
|
|
41360
|
+
await open2(url);
|
|
41253
41361
|
}
|
|
41254
|
-
}
|
|
41255
|
-
|
|
41256
|
-
if (msg.includes("AUTHORIZATION_PENDING"))
|
|
41257
|
-
continue;
|
|
41258
|
-
if (msg.includes("ACCESS_DENIED") || msg.includes("EXPIRED_TOKEN")) {
|
|
41259
|
-
s2.stop("Yetkilendirme reddedildi / süresi doldu", 1);
|
|
41260
|
-
throw new Error(msg);
|
|
41261
|
-
}
|
|
41262
|
-
}
|
|
41362
|
+
});
|
|
41363
|
+
spin.stop("Giriş yapıldı ✓ (bu cihaz artık kayıtlı — bir daha login gerekmez)");
|
|
41263
41364
|
}
|
|
41264
|
-
|
|
41265
|
-
|
|
41365
|
+
const client = identityClient(id);
|
|
41366
|
+
let workspaceId = wantWorkspaceId;
|
|
41367
|
+
if (!workspaceId) {
|
|
41368
|
+
const list = await client.identityListWorkspaces().catch(() => ({ workspaces: [] }));
|
|
41369
|
+
workspaceId = await selectOrCreateWorkspace(client, list.workspaces ?? []);
|
|
41370
|
+
}
|
|
41371
|
+
const mint = await client.mintWorkspaceKey(workspaceId, {
|
|
41372
|
+
name: "Gurulu CLI",
|
|
41373
|
+
type: "secret",
|
|
41374
|
+
scopes: SECRET_SCOPES
|
|
41375
|
+
});
|
|
41376
|
+
upsertCredential({
|
|
41377
|
+
workspace_id: workspaceId,
|
|
41378
|
+
api_key: mint.key,
|
|
41379
|
+
endpoint,
|
|
41380
|
+
last_used: new Date().toISOString()
|
|
41381
|
+
});
|
|
41382
|
+
return { apiKey: mint.key, workspaceId, endpoint };
|
|
41266
41383
|
}
|
|
41267
|
-
function
|
|
41268
|
-
|
|
41384
|
+
async function selectOrCreateWorkspace(client, workspaces) {
|
|
41385
|
+
if (workspaces.length === 0)
|
|
41386
|
+
return createWorkspace(client);
|
|
41387
|
+
const choice = await p.select({
|
|
41388
|
+
message: "Hangi workspace? (var olanı kullan ya da yeni oluştur)",
|
|
41389
|
+
options: [
|
|
41390
|
+
...workspaces.map((w2) => ({
|
|
41391
|
+
value: w2.workspace_id,
|
|
41392
|
+
label: `${w2.name}${w2.slug ? ` (${w2.slug})` : ""}`
|
|
41393
|
+
})),
|
|
41394
|
+
{ value: "__new__", label: "+ Yeni workspace oluştur" }
|
|
41395
|
+
]
|
|
41396
|
+
});
|
|
41397
|
+
if (p.isCancel(choice))
|
|
41398
|
+
throw new Error("iptal edildi");
|
|
41399
|
+
return choice === "__new__" ? createWorkspace(client) : String(choice);
|
|
41400
|
+
}
|
|
41401
|
+
async function createWorkspace(client) {
|
|
41402
|
+
const name = await p.text({
|
|
41403
|
+
message: "Workspace adı",
|
|
41404
|
+
placeholder: "my-app",
|
|
41405
|
+
validate: (v2) => v2 && v2.trim().length >= 1 ? undefined : "gerekli"
|
|
41406
|
+
});
|
|
41407
|
+
if (p.isCancel(name))
|
|
41408
|
+
throw new Error("iptal edildi");
|
|
41409
|
+
const domain = await p.text({
|
|
41410
|
+
message: "Site domain",
|
|
41411
|
+
placeholder: "example.com",
|
|
41412
|
+
initialValue: "example.com",
|
|
41413
|
+
validate: (v2) => v2 && v2.trim().length >= 3 ? undefined : "en az 3 karakter"
|
|
41414
|
+
});
|
|
41415
|
+
if (p.isCancel(domain))
|
|
41416
|
+
throw new Error("iptal edildi");
|
|
41417
|
+
const ws = await client.identityCreateWorkspace({
|
|
41418
|
+
name: String(name).trim(),
|
|
41419
|
+
domain: String(domain).trim()
|
|
41420
|
+
});
|
|
41421
|
+
return ws.workspace_id;
|
|
41269
41422
|
}
|
|
41270
41423
|
|
|
41271
41424
|
// src/wizard/checkpoint.ts
|
|
@@ -41664,10 +41817,11 @@ async function runFeatures(client, detected, opts) {
|
|
|
41664
41817
|
const s2 = p2.spinner();
|
|
41665
41818
|
s2.start("Özellikler registry'ye kuruluyor…");
|
|
41666
41819
|
try {
|
|
41667
|
-
await client.post("/features/register", { features: selectedKeys });
|
|
41820
|
+
await client.post("/v1/cli/features/register", { features: selectedKeys });
|
|
41668
41821
|
s2.stop(c3.neon(`✓ ${selected.length} özellik kuruldu`));
|
|
41669
|
-
} catch {
|
|
41670
|
-
|
|
41822
|
+
} catch (err) {
|
|
41823
|
+
const detail = err && typeof err === "object" && "status" in err ? `${err.status} ${err.message ?? ""}`.trim() : err instanceof Error ? err.message : String(err);
|
|
41824
|
+
s2.stop(`Özellik kurulumu atlandı (${detail}) — sonra: gurulu doctor`, 1);
|
|
41671
41825
|
return { selected, registered: false };
|
|
41672
41826
|
}
|
|
41673
41827
|
p2.note(selected.map((f3) => `${c3.bold(f3.label)}
|
|
@@ -42119,10 +42273,45 @@ function bail() {
|
|
|
42119
42273
|
p4.cancel("İptal edildi.");
|
|
42120
42274
|
process.exit(0);
|
|
42121
42275
|
}
|
|
42276
|
+
async function confirmTargetDir(cwd) {
|
|
42277
|
+
const isHome = cwd === homedir3();
|
|
42278
|
+
if (existsSync11(join11(cwd, "package.json")) && !isHome)
|
|
42279
|
+
return cwd;
|
|
42280
|
+
p4.log.warn(isHome ? `Ana dizinde kurulum yapmak üzeresin (${cwd}) — genelde yanlış; SDK'yı proje dizininde çalıştır.` : `Bu dizinde package.json yok (${cwd}) — proje kökünde olmayabilirsin.`);
|
|
42281
|
+
const choice = await p4.select({
|
|
42282
|
+
message: "Nasıl devam edelim?",
|
|
42283
|
+
options: [
|
|
42284
|
+
{ value: "here", label: "Yine de burada kur" },
|
|
42285
|
+
{ value: "path", label: "Başka bir proje dizini gir" },
|
|
42286
|
+
{ value: "cancel", label: "İptal et" }
|
|
42287
|
+
]
|
|
42288
|
+
});
|
|
42289
|
+
if (p4.isCancel(choice) || choice === "cancel")
|
|
42290
|
+
return null;
|
|
42291
|
+
if (choice === "here")
|
|
42292
|
+
return cwd;
|
|
42293
|
+
for (;; ) {
|
|
42294
|
+
const entered = await p4.text({ message: "Proje dizini yolu", placeholder: "./my-app" });
|
|
42295
|
+
if (p4.isCancel(entered))
|
|
42296
|
+
return null;
|
|
42297
|
+
const abs = resolve2(String(entered).trim());
|
|
42298
|
+
if (existsSync11(abs))
|
|
42299
|
+
return abs;
|
|
42300
|
+
p4.log.error(`Dizin bulunamadı: ${abs}`);
|
|
42301
|
+
}
|
|
42302
|
+
}
|
|
42122
42303
|
async function runWizard(opts) {
|
|
42123
42304
|
if (process.stdout.isTTY)
|
|
42124
42305
|
process.stdout.write(banner());
|
|
42125
42306
|
p4.intro(c3.dim("otonom kurulum başlıyor — auth → workspace → install → wire"));
|
|
42307
|
+
if (!opts.yes) {
|
|
42308
|
+
const target = await confirmTargetDir(opts.cwd);
|
|
42309
|
+
if (target === null) {
|
|
42310
|
+
p4.cancel("İptal edildi.");
|
|
42311
|
+
process.exit(0);
|
|
42312
|
+
}
|
|
42313
|
+
opts.cwd = target;
|
|
42314
|
+
}
|
|
42126
42315
|
const TOTAL = 6;
|
|
42127
42316
|
const phase = (n2, label) => {
|
|
42128
42317
|
p4.log.step(`${c3.dim(`[${n2}/${TOTAL}]`)} ${c3.bold(label)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;EAiEnB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;EAuBpB,CAAC;AAEH,eAAO,MAAM,SAAS,qDA6CpB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -38876,27 +38876,60 @@ class ApiClient {
|
|
|
38876
38876
|
"User-Agent": "@gurulu/cli",
|
|
38877
38877
|
...extra
|
|
38878
38878
|
};
|
|
38879
|
-
if (this.opts.
|
|
38879
|
+
if (this.opts.bearer) {
|
|
38880
|
+
h2.Authorization = `Bearer ${this.opts.bearer}`;
|
|
38881
|
+
} else if (this.opts.apiKey) {
|
|
38880
38882
|
h2["X-Gurulu-Api-Key"] = this.opts.apiKey;
|
|
38881
38883
|
}
|
|
38882
38884
|
return h2;
|
|
38883
38885
|
}
|
|
38884
38886
|
async get(path, query) {
|
|
38885
38887
|
const qs = query ? `?${new URLSearchParams(Object.fromEntries(Object.entries(query).map(([k2, v2]) => [k2, String(v2)]))).toString()}` : "";
|
|
38886
|
-
|
|
38887
|
-
method: "GET",
|
|
38888
|
-
headers: this.headers()
|
|
38889
|
-
});
|
|
38890
|
-
return this.handle(res);
|
|
38888
|
+
return this.send("GET", `${path}${qs}`);
|
|
38891
38889
|
}
|
|
38892
38890
|
async post(path, body) {
|
|
38893
|
-
|
|
38894
|
-
|
|
38895
|
-
|
|
38896
|
-
|
|
38891
|
+
return this.send("POST", path, body);
|
|
38892
|
+
}
|
|
38893
|
+
async send(method, pathWithQs, body, retried = false) {
|
|
38894
|
+
const res = await $request(`${this.opts.endpoint}${pathWithQs}`, {
|
|
38895
|
+
method,
|
|
38896
|
+
headers: method === "POST" ? this.headers({ "Content-Type": "application/json" }) : this.headers(),
|
|
38897
|
+
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {}
|
|
38897
38898
|
});
|
|
38899
|
+
if (res.statusCode === 401 && this.opts.bearer && this.opts.refresh && !retried) {
|
|
38900
|
+
await res.body.text().catch(() => "");
|
|
38901
|
+
if (await this.refreshBearer()) {
|
|
38902
|
+
return this.send(method, pathWithQs, body, true);
|
|
38903
|
+
}
|
|
38904
|
+
}
|
|
38898
38905
|
return this.handle(res);
|
|
38899
38906
|
}
|
|
38907
|
+
async refreshBearer() {
|
|
38908
|
+
const rc = this.opts.refresh;
|
|
38909
|
+
if (!rc)
|
|
38910
|
+
return false;
|
|
38911
|
+
try {
|
|
38912
|
+
const res = await $request(`${this.opts.endpoint}/v1/cli/auth/refresh`, {
|
|
38913
|
+
method: "POST",
|
|
38914
|
+
headers: {
|
|
38915
|
+
Accept: "application/json",
|
|
38916
|
+
"Content-Type": "application/json",
|
|
38917
|
+
"User-Agent": "@gurulu/cli"
|
|
38918
|
+
},
|
|
38919
|
+
body: JSON.stringify({ refresh_token: rc.refreshToken })
|
|
38920
|
+
});
|
|
38921
|
+
const text = await res.body.text();
|
|
38922
|
+
if (res.statusCode < 200 || res.statusCode >= 300)
|
|
38923
|
+
return false;
|
|
38924
|
+
const t2 = JSON.parse(text);
|
|
38925
|
+
this.opts.bearer = t2.access_token;
|
|
38926
|
+
rc.refreshToken = t2.refresh_token;
|
|
38927
|
+
rc.onRotate(t2);
|
|
38928
|
+
return true;
|
|
38929
|
+
} catch {
|
|
38930
|
+
return false;
|
|
38931
|
+
}
|
|
38932
|
+
}
|
|
38900
38933
|
listWorkspaces() {
|
|
38901
38934
|
return this.get("/v1/cli/workspaces");
|
|
38902
38935
|
}
|
|
@@ -38906,6 +38939,15 @@ class ApiClient {
|
|
|
38906
38939
|
issueWriteKey(workspaceId) {
|
|
38907
38940
|
return this.post(`/v1/cli/workspaces/${encodeURIComponent(workspaceId)}/write-key`, {});
|
|
38908
38941
|
}
|
|
38942
|
+
identityListWorkspaces() {
|
|
38943
|
+
return this.get("/v1/workspaces");
|
|
38944
|
+
}
|
|
38945
|
+
identityCreateWorkspace(body) {
|
|
38946
|
+
return this.post("/v1/workspaces", body);
|
|
38947
|
+
}
|
|
38948
|
+
mintWorkspaceKey(workspaceId, body) {
|
|
38949
|
+
return this.post(`/v1/workspaces/${encodeURIComponent(workspaceId)}/keys`, body);
|
|
38950
|
+
}
|
|
38909
38951
|
planEvents(body) {
|
|
38910
38952
|
return this.post("/v1/cli/ai/plan-events", body);
|
|
38911
38953
|
}
|
|
@@ -39005,6 +39047,21 @@ function writeGlobalCredentials(creds) {
|
|
|
39005
39047
|
chmodSync(path, 384);
|
|
39006
39048
|
} catch {}
|
|
39007
39049
|
}
|
|
39050
|
+
function readIdentity() {
|
|
39051
|
+
return readGlobalCredentials().identity ?? null;
|
|
39052
|
+
}
|
|
39053
|
+
function writeIdentity(identity) {
|
|
39054
|
+
const creds = readGlobalCredentials();
|
|
39055
|
+
creds.identity = identity;
|
|
39056
|
+
writeGlobalCredentials(creds);
|
|
39057
|
+
}
|
|
39058
|
+
function clearIdentity() {
|
|
39059
|
+
const creds = readGlobalCredentials();
|
|
39060
|
+
if (creds.identity) {
|
|
39061
|
+
delete creds.identity;
|
|
39062
|
+
writeGlobalCredentials(creds);
|
|
39063
|
+
}
|
|
39064
|
+
}
|
|
39008
39065
|
function findCredentialForWorkspace(workspaceId) {
|
|
39009
39066
|
const creds = readGlobalCredentials();
|
|
39010
39067
|
return creds.workspaces.find((w2) => w2.workspace_id === workspaceId) ?? null;
|
|
@@ -39401,8 +39458,92 @@ var auditCmd = defineCommand({
|
|
|
39401
39458
|
});
|
|
39402
39459
|
|
|
39403
39460
|
// src/commands/auth.ts
|
|
39404
|
-
|
|
39461
|
+
import open from "open";
|
|
39462
|
+
|
|
39463
|
+
// src/lib/identity.ts
|
|
39464
|
+
function identityClient(id) {
|
|
39465
|
+
return new ApiClient({
|
|
39466
|
+
endpoint: id.endpoint,
|
|
39467
|
+
bearer: id.access_token,
|
|
39468
|
+
refresh: {
|
|
39469
|
+
refreshToken: id.refresh_token,
|
|
39470
|
+
onRotate: (t2) => {
|
|
39471
|
+
const cur = readIdentity();
|
|
39472
|
+
if (!cur)
|
|
39473
|
+
return;
|
|
39474
|
+
writeIdentity({
|
|
39475
|
+
...cur,
|
|
39476
|
+
access_token: t2.access_token,
|
|
39477
|
+
refresh_token: t2.refresh_token,
|
|
39478
|
+
expires_at: t2.expires_in != null ? new Date(Date.now() + t2.expires_in * 1000).toISOString() : cur.expires_at,
|
|
39479
|
+
last_used: new Date().toISOString()
|
|
39480
|
+
});
|
|
39481
|
+
}
|
|
39482
|
+
}
|
|
39483
|
+
});
|
|
39484
|
+
}
|
|
39405
39485
|
var POLL_MAX_ATTEMPTS = 180;
|
|
39486
|
+
function sleep(ms) {
|
|
39487
|
+
return new Promise((r3) => setTimeout(r3, ms));
|
|
39488
|
+
}
|
|
39489
|
+
function toIdentity(endpoint, token) {
|
|
39490
|
+
return {
|
|
39491
|
+
access_token: token.access_token,
|
|
39492
|
+
refresh_token: token.refresh_token ?? "",
|
|
39493
|
+
expires_at: token.expires_in != null ? new Date(Date.now() + token.expires_in * 1000).toISOString() : new Date(Date.now() + 6 * 24 * 60 * 60 * 1000).toISOString(),
|
|
39494
|
+
endpoint,
|
|
39495
|
+
user_id: token.user_id,
|
|
39496
|
+
last_used: new Date().toISOString()
|
|
39497
|
+
};
|
|
39498
|
+
}
|
|
39499
|
+
async function runDeviceFlowIdentity(endpoint, display) {
|
|
39500
|
+
const client = new ApiClient({ endpoint });
|
|
39501
|
+
const start = await client.post("/v1/cli/auth/device", {
|
|
39502
|
+
client_name: "@gurulu/cli",
|
|
39503
|
+
grant_type: "identity"
|
|
39504
|
+
});
|
|
39505
|
+
const url = start.verification_url_complete || start.verification_url;
|
|
39506
|
+
display.onPrompt(start.user_code, url);
|
|
39507
|
+
if (display.openBrowser) {
|
|
39508
|
+
try {
|
|
39509
|
+
await display.openBrowser(url);
|
|
39510
|
+
} catch {}
|
|
39511
|
+
}
|
|
39512
|
+
display.onWaiting?.();
|
|
39513
|
+
const interval = Math.max((start.interval ?? 5) * 1000, 3000);
|
|
39514
|
+
for (let i2 = 0;i2 < POLL_MAX_ATTEMPTS; i2++) {
|
|
39515
|
+
await sleep(interval);
|
|
39516
|
+
try {
|
|
39517
|
+
const token = await client.post("/v1/cli/auth/token", {
|
|
39518
|
+
device_code: start.device_code
|
|
39519
|
+
});
|
|
39520
|
+
if (token.access_token && token.refresh_token) {
|
|
39521
|
+
const id = toIdentity(endpoint, token);
|
|
39522
|
+
writeIdentity(id);
|
|
39523
|
+
return id;
|
|
39524
|
+
}
|
|
39525
|
+
} catch (err) {
|
|
39526
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
39527
|
+
if (msg.includes("AUTHORIZATION_PENDING"))
|
|
39528
|
+
continue;
|
|
39529
|
+
if (msg.includes("ACCESS_DENIED"))
|
|
39530
|
+
throw new Error("Yetkilendirme reddedildi");
|
|
39531
|
+
if (msg.includes("EXPIRED_TOKEN"))
|
|
39532
|
+
throw new Error("Kod süresi doldu — tekrar dene");
|
|
39533
|
+
}
|
|
39534
|
+
}
|
|
39535
|
+
throw new Error("device flow zaman aşımına uğradı");
|
|
39536
|
+
}
|
|
39537
|
+
function loadIdentity(endpoint) {
|
|
39538
|
+
const id = readIdentity();
|
|
39539
|
+
if (!id?.refresh_token)
|
|
39540
|
+
return null;
|
|
39541
|
+
if (id.endpoint !== endpoint)
|
|
39542
|
+
return null;
|
|
39543
|
+
return id;
|
|
39544
|
+
}
|
|
39545
|
+
|
|
39546
|
+
// src/commands/auth.ts
|
|
39406
39547
|
var loginCmd = defineCommand({
|
|
39407
39548
|
meta: {
|
|
39408
39549
|
name: "login",
|
|
@@ -39436,54 +39577,27 @@ var loginCmd = defineCommand({
|
|
|
39436
39577
|
console.log(`[gurulu] credential saved for workspace ${workspaceId}`);
|
|
39437
39578
|
return;
|
|
39438
39579
|
}
|
|
39439
|
-
const client = new ApiClient({ endpoint });
|
|
39440
|
-
let start;
|
|
39441
39580
|
try {
|
|
39442
|
-
|
|
39443
|
-
|
|
39581
|
+
const id = await runDeviceFlowIdentity(endpoint, {
|
|
39582
|
+
onPrompt: (userCode, url) => {
|
|
39583
|
+
console.log(`[gurulu] visit ${url}`);
|
|
39584
|
+
console.log(`[gurulu] code: ${userCode}`);
|
|
39585
|
+
console.log("[gurulu] waiting for browser approval (~15m)...");
|
|
39586
|
+
},
|
|
39587
|
+
openBrowser: async (url) => {
|
|
39588
|
+
await open(url);
|
|
39589
|
+
}
|
|
39444
39590
|
});
|
|
39591
|
+
console.log(`
|
|
39592
|
+
[gurulu] signed in ✓ — account session stored (reused across projects + MCP)`);
|
|
39593
|
+
if (id.user_id) {
|
|
39594
|
+
console.log(`[gurulu] user: ${id.user_id}`);
|
|
39595
|
+
}
|
|
39445
39596
|
} catch (err) {
|
|
39446
|
-
console.error(`
|
|
39597
|
+
console.error(`
|
|
39598
|
+
[gurulu] login failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
39447
39599
|
process.exit(1);
|
|
39448
39600
|
}
|
|
39449
|
-
console.log(`[gurulu] visit ${start.verification_url}`);
|
|
39450
|
-
console.log(`[gurulu] enter code: ${start.user_code}`);
|
|
39451
|
-
console.log(`[gurulu] or follow: ${start.verification_url_complete}
|
|
39452
|
-
`);
|
|
39453
|
-
console.log(`[gurulu] polling (${POLL_MAX_ATTEMPTS * 5}s timeout)...`);
|
|
39454
|
-
const interval = (start.interval ?? 5) * 1000;
|
|
39455
|
-
for (let i2 = 0;i2 < POLL_MAX_ATTEMPTS; i2++) {
|
|
39456
|
-
await sleep(Math.max(interval, POLL_INTERVAL_MS));
|
|
39457
|
-
try {
|
|
39458
|
-
const token = await client.post("/v1/cli/auth/token", {
|
|
39459
|
-
device_code: start.device_code
|
|
39460
|
-
});
|
|
39461
|
-
if (token.access_token) {
|
|
39462
|
-
upsertCredential({
|
|
39463
|
-
workspace_id: token.workspace_id,
|
|
39464
|
-
api_key: token.access_token,
|
|
39465
|
-
endpoint,
|
|
39466
|
-
last_used: new Date().toISOString()
|
|
39467
|
-
});
|
|
39468
|
-
console.log(`
|
|
39469
|
-
[gurulu] authorized — workspace ${token.workspace_id}`);
|
|
39470
|
-
return;
|
|
39471
|
-
}
|
|
39472
|
-
} catch (err) {
|
|
39473
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
39474
|
-
if (msg.includes("AUTHORIZATION_PENDING") || err.code === "AUTHORIZATION_PENDING") {
|
|
39475
|
-
continue;
|
|
39476
|
-
}
|
|
39477
|
-
if (msg.includes("ACCESS_DENIED") || msg.includes("EXPIRED_TOKEN")) {
|
|
39478
|
-
console.error(`
|
|
39479
|
-
[gurulu] device flow ended: ${msg}`);
|
|
39480
|
-
process.exit(1);
|
|
39481
|
-
}
|
|
39482
|
-
}
|
|
39483
|
-
}
|
|
39484
|
-
console.error(`
|
|
39485
|
-
[gurulu] timed out waiting for authorization`);
|
|
39486
|
-
process.exit(1);
|
|
39487
39601
|
}
|
|
39488
39602
|
});
|
|
39489
39603
|
var logoutCmd = defineCommand({
|
|
@@ -39501,14 +39615,23 @@ var logoutCmd = defineCommand({
|
|
|
39501
39615
|
const creds = readGlobalCredentials();
|
|
39502
39616
|
for (const w2 of creds.workspaces)
|
|
39503
39617
|
removeCredential(w2.workspace_id);
|
|
39504
|
-
|
|
39618
|
+
clearIdentity();
|
|
39619
|
+
console.log(`[gurulu] signed out — removed ${creds.workspaces.length} workspace credential(s) + account session`);
|
|
39505
39620
|
}
|
|
39506
39621
|
});
|
|
39507
39622
|
var whoamiCmd = defineCommand({
|
|
39508
39623
|
meta: { name: "whoami", description: "Show active credentials + workspace info" },
|
|
39509
39624
|
async run() {
|
|
39625
|
+
const identity = readIdentity();
|
|
39626
|
+
if (identity) {
|
|
39627
|
+
console.log(`[gurulu] account session: active${identity.user_id ? ` (user ${identity.user_id})` : ""} @ ${identity.endpoint}`);
|
|
39628
|
+
}
|
|
39510
39629
|
const cred = resolveActiveCredential({});
|
|
39511
39630
|
if (!cred) {
|
|
39631
|
+
if (identity) {
|
|
39632
|
+
console.log("[gurulu] no workspace bound yet — run `gurulu init` in a project");
|
|
39633
|
+
return;
|
|
39634
|
+
}
|
|
39512
39635
|
console.log("[gurulu] not logged in — run `gurulu login`");
|
|
39513
39636
|
process.exit(1);
|
|
39514
39637
|
}
|
|
@@ -39525,13 +39648,11 @@ var whoamiCmd = defineCommand({
|
|
|
39525
39648
|
}
|
|
39526
39649
|
}
|
|
39527
39650
|
});
|
|
39528
|
-
function sleep(ms) {
|
|
39529
|
-
return new Promise((r3) => setTimeout(r3, ms));
|
|
39530
|
-
}
|
|
39531
39651
|
|
|
39532
39652
|
// src/wizard/run.ts
|
|
39533
39653
|
import { existsSync as existsSync11, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
39534
|
-
import {
|
|
39654
|
+
import { homedir as homedir3 } from "node:os";
|
|
39655
|
+
import { dirname as dirname5, join as join11, resolve as resolve2 } from "node:path";
|
|
39535
39656
|
import * as p4 from "@clack/prompts";
|
|
39536
39657
|
|
|
39537
39658
|
// src/commands/pull.ts
|
|
@@ -40272,8 +40393,8 @@ function snippetWeb(workspaceKey, jsError = false) {
|
|
|
40272
40393
|
return `import gurulu from '@gurulu/web';
|
|
40273
40394
|
|
|
40274
40395
|
gurulu.init({
|
|
40275
|
-
workspaceKey: process.env.
|
|
40276
|
-
endpoint: process.env.
|
|
40396
|
+
workspaceKey: process.env.VITE_GURULU_WORKSPACE ?? '${workspaceKey}',
|
|
40397
|
+
endpoint: process.env.VITE_GURULU_ENDPOINT, // optional, defaults to https://ingest.gurulu.io${autocaptureLine(jsError, " ")}
|
|
40277
40398
|
});`;
|
|
40278
40399
|
}
|
|
40279
40400
|
function snippetNext(workspaceKey, jsError = false) {
|
|
@@ -40478,8 +40599,8 @@ function buildInstallPlan(detected, ctx = {}) {
|
|
|
40478
40599
|
|
|
40479
40600
|
// src/lib/ui.ts
|
|
40480
40601
|
var noColor = Boolean(process.env.NO_COLOR) || process.env.TERM === "dumb" || !process.stdout.isTTY;
|
|
40481
|
-
function wrap(
|
|
40482
|
-
return (s2) => noColor ? s2 : `\x1B[${
|
|
40602
|
+
function wrap(open2, close) {
|
|
40603
|
+
return (s2) => noColor ? s2 : `\x1B[${open2}m${s2}\x1B[${close}m`;
|
|
40483
40604
|
}
|
|
40484
40605
|
function fg(code) {
|
|
40485
40606
|
return (s2) => noColor ? s2 : `\x1B[38;5;${code}m${s2}\x1B[39m`;
|
|
@@ -40766,7 +40887,16 @@ function buildAugmentTask(competitors) {
|
|
|
40766
40887
|
|
|
40767
40888
|
// src/wizard/auth.ts
|
|
40768
40889
|
import * as p from "@clack/prompts";
|
|
40769
|
-
import
|
|
40890
|
+
import open2 from "open";
|
|
40891
|
+
var SECRET_SCOPES = [
|
|
40892
|
+
"admin",
|
|
40893
|
+
"ingest",
|
|
40894
|
+
"observability",
|
|
40895
|
+
"registry.read",
|
|
40896
|
+
"registry.write",
|
|
40897
|
+
"events.read",
|
|
40898
|
+
"events.write"
|
|
40899
|
+
];
|
|
40770
40900
|
async function ensureAuth(opts) {
|
|
40771
40901
|
const endpoint = opts.endpoint ?? DEFAULT_ENDPOINT;
|
|
40772
40902
|
if (opts.apiKey) {
|
|
@@ -40792,57 +40922,80 @@ async function ensureAuth(opts) {
|
|
|
40792
40922
|
endpoint: existing.endpoint
|
|
40793
40923
|
};
|
|
40794
40924
|
}
|
|
40795
|
-
return
|
|
40925
|
+
return identityWorkspaceFlow(endpoint, opts.workspaceId);
|
|
40796
40926
|
}
|
|
40797
|
-
async function
|
|
40798
|
-
|
|
40799
|
-
|
|
40800
|
-
|
|
40801
|
-
|
|
40802
|
-
|
|
40803
|
-
|
|
40804
|
-
|
|
40805
|
-
|
|
40806
|
-
|
|
40807
|
-
|
|
40808
|
-
} catch {
|
|
40809
|
-
p.log.warn("Tarayıcı otomatik açılamadı — yukarıdaki linki elle aç.");
|
|
40810
|
-
}
|
|
40811
|
-
const s2 = p.spinner();
|
|
40812
|
-
s2.start("Tarayıcıda onay bekleniyor…");
|
|
40813
|
-
const interval = Math.max((start.interval ?? 5) * 1000, 3000);
|
|
40814
|
-
const maxAttempts = 180;
|
|
40815
|
-
for (let i2 = 0;i2 < maxAttempts; i2++) {
|
|
40816
|
-
await sleep2(interval);
|
|
40817
|
-
try {
|
|
40818
|
-
const token = await client.post("/v1/cli/auth/token", {
|
|
40819
|
-
device_code: start.device_code
|
|
40820
|
-
});
|
|
40821
|
-
if (token.access_token) {
|
|
40822
|
-
upsertCredential({
|
|
40823
|
-
workspace_id: token.workspace_id,
|
|
40824
|
-
api_key: token.access_token,
|
|
40825
|
-
endpoint,
|
|
40826
|
-
last_used: new Date().toISOString()
|
|
40827
|
-
});
|
|
40828
|
-
s2.stop("Yetkilendirildi ✓");
|
|
40829
|
-
return { apiKey: token.access_token, workspaceId: token.workspace_id, endpoint };
|
|
40927
|
+
async function identityWorkspaceFlow(endpoint, wantWorkspaceId) {
|
|
40928
|
+
let id = loadIdentity(endpoint);
|
|
40929
|
+
if (!id) {
|
|
40930
|
+
const spin = p.spinner();
|
|
40931
|
+
id = await runDeviceFlowIdentity(endpoint, {
|
|
40932
|
+
onPrompt: (userCode, url) => p.note(`${userCode}
|
|
40933
|
+
|
|
40934
|
+
${url}`, "Tarayıcıda hesabına giriş yap"),
|
|
40935
|
+
onWaiting: () => spin.start("Tarayıcıda onay bekleniyor…"),
|
|
40936
|
+
openBrowser: async (url) => {
|
|
40937
|
+
await open2(url);
|
|
40830
40938
|
}
|
|
40831
|
-
}
|
|
40832
|
-
|
|
40833
|
-
if (msg.includes("AUTHORIZATION_PENDING"))
|
|
40834
|
-
continue;
|
|
40835
|
-
if (msg.includes("ACCESS_DENIED") || msg.includes("EXPIRED_TOKEN")) {
|
|
40836
|
-
s2.stop("Yetkilendirme reddedildi / süresi doldu", 1);
|
|
40837
|
-
throw new Error(msg);
|
|
40838
|
-
}
|
|
40839
|
-
}
|
|
40939
|
+
});
|
|
40940
|
+
spin.stop("Giriş yapıldı ✓ (bu cihaz artık kayıtlı — bir daha login gerekmez)");
|
|
40840
40941
|
}
|
|
40841
|
-
|
|
40842
|
-
|
|
40942
|
+
const client = identityClient(id);
|
|
40943
|
+
let workspaceId = wantWorkspaceId;
|
|
40944
|
+
if (!workspaceId) {
|
|
40945
|
+
const list = await client.identityListWorkspaces().catch(() => ({ workspaces: [] }));
|
|
40946
|
+
workspaceId = await selectOrCreateWorkspace(client, list.workspaces ?? []);
|
|
40947
|
+
}
|
|
40948
|
+
const mint = await client.mintWorkspaceKey(workspaceId, {
|
|
40949
|
+
name: "Gurulu CLI",
|
|
40950
|
+
type: "secret",
|
|
40951
|
+
scopes: SECRET_SCOPES
|
|
40952
|
+
});
|
|
40953
|
+
upsertCredential({
|
|
40954
|
+
workspace_id: workspaceId,
|
|
40955
|
+
api_key: mint.key,
|
|
40956
|
+
endpoint,
|
|
40957
|
+
last_used: new Date().toISOString()
|
|
40958
|
+
});
|
|
40959
|
+
return { apiKey: mint.key, workspaceId, endpoint };
|
|
40843
40960
|
}
|
|
40844
|
-
function
|
|
40845
|
-
|
|
40961
|
+
async function selectOrCreateWorkspace(client, workspaces) {
|
|
40962
|
+
if (workspaces.length === 0)
|
|
40963
|
+
return createWorkspace(client);
|
|
40964
|
+
const choice = await p.select({
|
|
40965
|
+
message: "Hangi workspace? (var olanı kullan ya da yeni oluştur)",
|
|
40966
|
+
options: [
|
|
40967
|
+
...workspaces.map((w2) => ({
|
|
40968
|
+
value: w2.workspace_id,
|
|
40969
|
+
label: `${w2.name}${w2.slug ? ` (${w2.slug})` : ""}`
|
|
40970
|
+
})),
|
|
40971
|
+
{ value: "__new__", label: "+ Yeni workspace oluştur" }
|
|
40972
|
+
]
|
|
40973
|
+
});
|
|
40974
|
+
if (p.isCancel(choice))
|
|
40975
|
+
throw new Error("iptal edildi");
|
|
40976
|
+
return choice === "__new__" ? createWorkspace(client) : String(choice);
|
|
40977
|
+
}
|
|
40978
|
+
async function createWorkspace(client) {
|
|
40979
|
+
const name = await p.text({
|
|
40980
|
+
message: "Workspace adı",
|
|
40981
|
+
placeholder: "my-app",
|
|
40982
|
+
validate: (v2) => v2 && v2.trim().length >= 1 ? undefined : "gerekli"
|
|
40983
|
+
});
|
|
40984
|
+
if (p.isCancel(name))
|
|
40985
|
+
throw new Error("iptal edildi");
|
|
40986
|
+
const domain = await p.text({
|
|
40987
|
+
message: "Site domain",
|
|
40988
|
+
placeholder: "example.com",
|
|
40989
|
+
initialValue: "example.com",
|
|
40990
|
+
validate: (v2) => v2 && v2.trim().length >= 3 ? undefined : "en az 3 karakter"
|
|
40991
|
+
});
|
|
40992
|
+
if (p.isCancel(domain))
|
|
40993
|
+
throw new Error("iptal edildi");
|
|
40994
|
+
const ws = await client.identityCreateWorkspace({
|
|
40995
|
+
name: String(name).trim(),
|
|
40996
|
+
domain: String(domain).trim()
|
|
40997
|
+
});
|
|
40998
|
+
return ws.workspace_id;
|
|
40846
40999
|
}
|
|
40847
41000
|
|
|
40848
41001
|
// src/wizard/checkpoint.ts
|
|
@@ -41241,10 +41394,11 @@ async function runFeatures(client, detected, opts) {
|
|
|
41241
41394
|
const s2 = p2.spinner();
|
|
41242
41395
|
s2.start("Özellikler registry'ye kuruluyor…");
|
|
41243
41396
|
try {
|
|
41244
|
-
await client.post("/features/register", { features: selectedKeys });
|
|
41397
|
+
await client.post("/v1/cli/features/register", { features: selectedKeys });
|
|
41245
41398
|
s2.stop(c3.neon(`✓ ${selected.length} özellik kuruldu`));
|
|
41246
|
-
} catch {
|
|
41247
|
-
|
|
41399
|
+
} catch (err) {
|
|
41400
|
+
const detail = err && typeof err === "object" && "status" in err ? `${err.status} ${err.message ?? ""}`.trim() : err instanceof Error ? err.message : String(err);
|
|
41401
|
+
s2.stop(`Özellik kurulumu atlandı (${detail}) — sonra: gurulu doctor`, 1);
|
|
41248
41402
|
return { selected, registered: false };
|
|
41249
41403
|
}
|
|
41250
41404
|
p2.note(selected.map((f3) => `${c3.bold(f3.label)}
|
|
@@ -41696,10 +41850,45 @@ function bail() {
|
|
|
41696
41850
|
p4.cancel("İptal edildi.");
|
|
41697
41851
|
process.exit(0);
|
|
41698
41852
|
}
|
|
41853
|
+
async function confirmTargetDir(cwd) {
|
|
41854
|
+
const isHome = cwd === homedir3();
|
|
41855
|
+
if (existsSync11(join11(cwd, "package.json")) && !isHome)
|
|
41856
|
+
return cwd;
|
|
41857
|
+
p4.log.warn(isHome ? `Ana dizinde kurulum yapmak üzeresin (${cwd}) — genelde yanlış; SDK'yı proje dizininde çalıştır.` : `Bu dizinde package.json yok (${cwd}) — proje kökünde olmayabilirsin.`);
|
|
41858
|
+
const choice = await p4.select({
|
|
41859
|
+
message: "Nasıl devam edelim?",
|
|
41860
|
+
options: [
|
|
41861
|
+
{ value: "here", label: "Yine de burada kur" },
|
|
41862
|
+
{ value: "path", label: "Başka bir proje dizini gir" },
|
|
41863
|
+
{ value: "cancel", label: "İptal et" }
|
|
41864
|
+
]
|
|
41865
|
+
});
|
|
41866
|
+
if (p4.isCancel(choice) || choice === "cancel")
|
|
41867
|
+
return null;
|
|
41868
|
+
if (choice === "here")
|
|
41869
|
+
return cwd;
|
|
41870
|
+
for (;; ) {
|
|
41871
|
+
const entered = await p4.text({ message: "Proje dizini yolu", placeholder: "./my-app" });
|
|
41872
|
+
if (p4.isCancel(entered))
|
|
41873
|
+
return null;
|
|
41874
|
+
const abs = resolve2(String(entered).trim());
|
|
41875
|
+
if (existsSync11(abs))
|
|
41876
|
+
return abs;
|
|
41877
|
+
p4.log.error(`Dizin bulunamadı: ${abs}`);
|
|
41878
|
+
}
|
|
41879
|
+
}
|
|
41699
41880
|
async function runWizard(opts) {
|
|
41700
41881
|
if (process.stdout.isTTY)
|
|
41701
41882
|
process.stdout.write(banner());
|
|
41702
41883
|
p4.intro(c3.dim("otonom kurulum başlıyor — auth → workspace → install → wire"));
|
|
41884
|
+
if (!opts.yes) {
|
|
41885
|
+
const target = await confirmTargetDir(opts.cwd);
|
|
41886
|
+
if (target === null) {
|
|
41887
|
+
p4.cancel("İptal edildi.");
|
|
41888
|
+
process.exit(0);
|
|
41889
|
+
}
|
|
41890
|
+
opts.cwd = target;
|
|
41891
|
+
}
|
|
41703
41892
|
const TOTAL = 6;
|
|
41704
41893
|
const phase = (n2, label) => {
|
|
41705
41894
|
p4.log.step(`${c3.dim(`[${n2}/${TOTAL}]`)} ${c3.bold(label)}`);
|
package/dist/lib/api.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
export interface RefreshConfig {
|
|
2
|
+
refreshToken: string;
|
|
3
|
+
/** Yeni token'lar geldiğinde persist (global credentials.identity güncelle). */
|
|
4
|
+
onRotate: (t: {
|
|
5
|
+
access_token: string;
|
|
6
|
+
refresh_token: string;
|
|
7
|
+
expires_in: number | null;
|
|
8
|
+
}) => void;
|
|
9
|
+
}
|
|
1
10
|
export interface ApiClientOptions {
|
|
2
11
|
endpoint: string;
|
|
12
|
+
/** Workspace secret key (sk_) → X-Gurulu-Api-Key (apiKeyMiddleware). */
|
|
3
13
|
apiKey?: string;
|
|
14
|
+
/** identity grant: user session access JWT → Authorization: Bearer (authMiddleware). */
|
|
15
|
+
bearer?: string;
|
|
16
|
+
/** bearer 401 alınca /auth/refresh ile bir kez yenile + retry. */
|
|
17
|
+
refresh?: RefreshConfig;
|
|
4
18
|
}
|
|
5
19
|
export interface ApiError {
|
|
6
20
|
code: string;
|
|
@@ -22,10 +36,22 @@ export declare class ApiClient {
|
|
|
22
36
|
private headers;
|
|
23
37
|
get<T>(path: string, query?: Record<string, string | number>): Promise<T>;
|
|
24
38
|
post<T>(path: string, body: unknown): Promise<T>;
|
|
39
|
+
private send;
|
|
40
|
+
private refreshBearer;
|
|
25
41
|
listWorkspaces(): Promise<ListWorkspacesResponse>;
|
|
26
42
|
createWorkspace(body: CreateWorkspaceBody): Promise<CreateWorkspaceResponse>;
|
|
27
43
|
/** Mevcut workspace için taze public ingest key mint et (plaintext bir kez). */
|
|
28
44
|
issueWriteKey(workspaceId: string): Promise<IssueWriteKeyResponse>;
|
|
45
|
+
/** Membership-based workspace listesi (genel endpoint, apiKeyMiddleware DEĞİL). */
|
|
46
|
+
identityListWorkspaces(): Promise<UserWorkspacesResponse>;
|
|
47
|
+
/** Yeni workspace (user JWT). */
|
|
48
|
+
identityCreateWorkspace(body: Record<string, unknown>): Promise<UserWorkspace>;
|
|
49
|
+
/** Seçilen workspace için sk_ mint (user JWT + rbac api_key.create). */
|
|
50
|
+
mintWorkspaceKey(workspaceId: string, body: {
|
|
51
|
+
name: string;
|
|
52
|
+
type: 'secret';
|
|
53
|
+
scopes: string[];
|
|
54
|
+
}): Promise<MintKeyResponse>;
|
|
29
55
|
/** AI event planı (W2 gateway) — kod context'i → registry-bound plan. */
|
|
30
56
|
planEvents(body: PlanEventsBody): Promise<PlanEventsResponse>;
|
|
31
57
|
/** Yeni event önerisi → verification queue (W2.4 plan uygula). */
|
|
@@ -254,10 +280,28 @@ export interface DeviceStartResponse {
|
|
|
254
280
|
interval: number;
|
|
255
281
|
}
|
|
256
282
|
export interface DeviceTokenResponse {
|
|
283
|
+
grant_type?: 'identity' | 'workspace';
|
|
257
284
|
access_token: string;
|
|
258
285
|
token_type: 'Bearer';
|
|
286
|
+
refresh_token?: string;
|
|
287
|
+
user_id?: string;
|
|
288
|
+
workspace_id?: string;
|
|
289
|
+
tenant_id?: string;
|
|
290
|
+
expires_in: number | null;
|
|
291
|
+
}
|
|
292
|
+
export interface UserWorkspace {
|
|
259
293
|
workspace_id: string;
|
|
260
294
|
tenant_id: string;
|
|
261
|
-
|
|
295
|
+
name: string;
|
|
296
|
+
slug: string;
|
|
297
|
+
tenant_name?: string;
|
|
298
|
+
}
|
|
299
|
+
export interface UserWorkspacesResponse {
|
|
300
|
+
workspaces: UserWorkspace[];
|
|
301
|
+
}
|
|
302
|
+
export interface MintKeyResponse {
|
|
303
|
+
id: string;
|
|
304
|
+
key: string;
|
|
305
|
+
key_prefix: string;
|
|
262
306
|
}
|
|
263
307
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/lib/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,EAAE,CAAC,CAAC,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;CACnG;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;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C9B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -13,9 +13,19 @@ export interface GlobalCredentialEntry {
|
|
|
13
13
|
endpoint: string;
|
|
14
14
|
last_used: string;
|
|
15
15
|
}
|
|
16
|
+
export interface IdentityCredential {
|
|
17
|
+
access_token: string;
|
|
18
|
+
refresh_token: string;
|
|
19
|
+
/** Access token expiry (ISO) — dolunca refresh. */
|
|
20
|
+
expires_at: string;
|
|
21
|
+
endpoint: string;
|
|
22
|
+
user_id?: string;
|
|
23
|
+
last_used: string;
|
|
24
|
+
}
|
|
16
25
|
export interface GlobalCredentials {
|
|
17
26
|
workspaces: GlobalCredentialEntry[];
|
|
18
27
|
default_workspace_id?: string;
|
|
28
|
+
identity?: IdentityCredential;
|
|
19
29
|
}
|
|
20
30
|
export declare const DEFAULT_ENDPOINT: string;
|
|
21
31
|
export declare function projectRoot(cwd?: string): string;
|
|
@@ -29,6 +39,9 @@ export declare function readProjectConfig(cwd?: string): ProjectConfig | null;
|
|
|
29
39
|
export declare function writeProjectConfig(cfg: ProjectConfig, cwd?: string): void;
|
|
30
40
|
export declare function readGlobalCredentials(): GlobalCredentials;
|
|
31
41
|
export declare function writeGlobalCredentials(creds: GlobalCredentials): void;
|
|
42
|
+
export declare function readIdentity(): IdentityCredential | null;
|
|
43
|
+
export declare function writeIdentity(identity: IdentityCredential): void;
|
|
44
|
+
export declare function clearIdentity(): void;
|
|
32
45
|
export declare function findCredentialForWorkspace(workspaceId: string): GlobalCredentialEntry | null;
|
|
33
46
|
export declare function upsertCredential(entry: GlobalCredentialEntry): void;
|
|
34
47
|
export declare function removeCredential(workspaceId: string): boolean;
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AA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BAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO7D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmBnE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApiClient } from './api.ts';
|
|
2
|
+
import { type IdentityCredential } from './config.ts';
|
|
3
|
+
/** ApiClient'ı identity (bearer + auto-refresh persist) ile kur. */
|
|
4
|
+
export declare function identityClient(id: IdentityCredential): ApiClient;
|
|
5
|
+
export interface DeviceFlowDisplay {
|
|
6
|
+
/** user_code + verification URL'i kullanıcıya göster. */
|
|
7
|
+
onPrompt: (userCode: string, url: string) => void;
|
|
8
|
+
/** Poll başladı (spinner vb.). */
|
|
9
|
+
onWaiting?: () => void;
|
|
10
|
+
/** Tarayıcı otomatik açma callback'i (opsiyonel — CLI `open` ile). */
|
|
11
|
+
openBrowser?: (url: string) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Identity device flow — browser onayı → user session token'ı sakla + döndür. */
|
|
14
|
+
export declare function runDeviceFlowIdentity(endpoint: string, display: DeviceFlowDisplay): Promise<IdentityCredential>;
|
|
15
|
+
/**
|
|
16
|
+
* Kayıtlı identity'yi döndür (varsa) — yoksa null. Access token dolmuş olsa bile
|
|
17
|
+
* döner; ApiClient 401'de otomatik refresh eder. Endpoint uyuşmazsa (farklı
|
|
18
|
+
* backend) null (yeni login gerekir).
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadIdentity(endpoint: string): IdentityCredential | null;
|
|
21
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/lib/identity.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAsD,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,KAAK,kBAAkB,EAA+B,MAAM,aAAa,CAAC;AAEnF,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,EAAE,EAAE,kBAAkB,GAAG,SAAS,CAsBhE;AAED,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,sEAAsE;IACtE,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAsBD,kFAAkF;AAClF,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAuC7B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAKxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install-plan.d.ts","sourceRoot":"","sources":["../../src/lib/install-plan.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,WA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,WAAW,SAAS;IACxB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CA0BrF;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,eAAe,EACzB,GAAG,GAAE,kBAAuB,GAC3B,WAAW,CAiBb"}
|
package/dist/lib/install-plan.js
CHANGED
|
@@ -31,8 +31,8 @@ function snippetWeb(workspaceKey, jsError = false) {
|
|
|
31
31
|
return `import gurulu from '@gurulu/web';
|
|
32
32
|
|
|
33
33
|
gurulu.init({
|
|
34
|
-
workspaceKey: process.env.
|
|
35
|
-
endpoint: process.env.
|
|
34
|
+
workspaceKey: process.env.VITE_GURULU_WORKSPACE ?? '${workspaceKey}',
|
|
35
|
+
endpoint: process.env.VITE_GURULU_ENDPOINT, // optional, defaults to https://ingest.gurulu.io${autocaptureLine(jsError, " ")}
|
|
36
36
|
});`;
|
|
37
37
|
}
|
|
38
38
|
function snippetNext(workspaceKey, jsError = false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/wizard/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/wizard/auth.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD,wBAAsB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAkC7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/wizard/features.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AAG1E,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,aAAa,EAAE,CAwD5E;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACvC,OAAO,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/wizard/features.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AAG1E,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,aAAa,EAAE,CAwD5E;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACvC,OAAO,CAAC,cAAc,CAAC,CA6CzB"}
|
package/dist/wizard/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/wizard/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/wizard/run.ts"],"names":[],"mappings":"AAsCA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,sFAAsF;IACtF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA0DD,wBAAsB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA4blE"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gurulu/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"description": "Gurulu CLI. init / pull / push / validate / doctor
|
|
10
|
+
"description": "Gurulu CLI. init / pull / push / validate / doctor — registry as code, local schema sync.",
|
|
11
11
|
"homepage": "https://gurulu.io",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|