@lobu/cli 7.0.0 → 7.2.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/commands/_lib/apply/apply-cmd.d.ts.map +1 -1
- package/dist/commands/_lib/apply/apply-cmd.js +160 -12
- package/dist/commands/_lib/apply/apply-cmd.js.map +1 -1
- package/dist/commands/_lib/apply/client.d.ts +106 -0
- package/dist/commands/_lib/apply/client.d.ts.map +1 -1
- package/dist/commands/_lib/apply/client.js +163 -2
- package/dist/commands/_lib/apply/client.js.map +1 -1
- package/dist/commands/_lib/apply/desired-state.d.ts +53 -0
- package/dist/commands/_lib/apply/desired-state.d.ts.map +1 -1
- package/dist/commands/_lib/apply/desired-state.js +182 -5
- package/dist/commands/_lib/apply/desired-state.js.map +1 -1
- package/dist/commands/_lib/apply/diff.d.ts +12 -1
- package/dist/commands/_lib/apply/diff.d.ts.map +1 -1
- package/dist/commands/_lib/apply/diff.js +106 -7
- package/dist/commands/_lib/apply/diff.js.map +1 -1
- package/dist/commands/_lib/connector-loader.d.ts +3 -0
- package/dist/commands/_lib/connector-loader.d.ts.map +1 -0
- package/dist/commands/_lib/connector-loader.js +129 -0
- package/dist/commands/_lib/connector-loader.js.map +1 -0
- package/dist/commands/_lib/connector-run-cmd.d.ts +35 -0
- package/dist/commands/_lib/connector-run-cmd.d.ts.map +1 -0
- package/dist/commands/_lib/connector-run-cmd.js +351 -0
- package/dist/commands/_lib/connector-run-cmd.js.map +1 -0
- package/dist/commands/_lib/export/export-cmd.d.ts +35 -0
- package/dist/commands/_lib/export/export-cmd.d.ts.map +1 -0
- package/dist/commands/_lib/export/export-cmd.js +329 -0
- package/dist/commands/_lib/export/export-cmd.js.map +1 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +11 -14
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +19 -5
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/connector.d.ts +3 -0
- package/dist/commands/connector.d.ts.map +1 -0
- package/dist/commands/connector.js +5 -0
- package/dist/commands/connector.js.map +1 -0
- package/dist/commands/context.d.ts +7 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +19 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/dev.d.ts +15 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +156 -4
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -3
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/eval.d.ts.map +1 -1
- package/dist/commands/eval.js +12 -13
- package/dist/commands/eval.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +5 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +22 -16
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/memory/_lib/browser-auth-cmd.d.ts.map +1 -1
- package/dist/commands/memory/_lib/browser-auth-cmd.js +15 -144
- package/dist/commands/memory/_lib/browser-auth-cmd.js.map +1 -1
- package/dist/commands/token.d.ts.map +1 -1
- package/dist/commands/token.js +1 -4
- package/dist/commands/token.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +4 -13
- package/dist/commands/validate.js.map +1 -1
- package/dist/config/loader.js +2 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/connectors/README.md +0 -1
- package/dist/connectors/apple_photos.ts +178 -0
- package/dist/connectors/browser-scraper-utils.ts +76 -0
- package/dist/connectors/chrome.ts +351 -0
- package/dist/connectors/chrome_bookmarks.ts +79 -0
- package/dist/connectors/chrome_downloads.ts +80 -0
- package/dist/connectors/chrome_history.ts +80 -0
- package/dist/connectors/github.ts +1 -0
- package/dist/connectors/google_calendar.ts +14 -2
- package/dist/connectors/google_play.ts +22 -2
- package/dist/connectors/hackernews.ts +37 -2
- package/dist/connectors/index.ts +15 -1
- package/dist/connectors/reddit.ts +1 -0
- package/dist/connectors/revolut.ts +10 -13
- package/dist/connectors/rss.ts +33 -8
- package/dist/connectors/trustpilot.ts +31 -20
- package/dist/connectors/website.ts +7 -68
- package/dist/connectors/whatsapp.ts +12 -21
- package/dist/db/migrations/20260514130000_connection_action_modes.sql +103 -0
- package/dist/db/migrations/20260514160000_auth_profiles_mirror_mode.sql +32 -0
- package/dist/db/migrations/20260515120000_agents_per_org_pk.sql +66 -0
- package/dist/db/migrations/20260515150000_geo_enrichment.sql +208 -0
- package/dist/db/migrations/20260515160000_drop_agents_org_id_unique.sql +24 -0
- package/dist/db/migrations/20260515170000_auth_profiles_default_for_connector.sql +23 -0
- package/dist/db/migrations/20260516120000_agents_per_org_pk_swap.sql +125 -0
- package/dist/db/migrations/20260516200000_events_search_tsv.sql +134 -0
- package/dist/db/migrations/20260516200100_events_lifecycle_changes_index.sql +25 -0
- package/dist/db/migrations/20260517010000_drop_unused_indexes.sql +49 -0
- package/dist/db/migrations/20260517020000_softdelete_orphan_feeds.sql +56 -0
- package/dist/db/migrations/20260517030000_pat_worker_id_binding.sql +27 -0
- package/dist/db/migrations/20260517040000_archive_orphan_watchers.sql +30 -0
- package/dist/db/migrations/20260517050000_watcher_agent_id_not_null.sql +34 -0
- package/dist/db/migrations/20260517060000_watcher_schema_additions.sql +78 -0
- package/dist/db/migrations/20260517150000_goals_primitive.sql +55 -0
- package/dist/db/migrations/20260517160000_drop_goals_primitive.sql +45 -0
- package/dist/db/migrations/20260518000000_pending_interactions.sql +49 -0
- package/dist/db/migrations/20260518010000_runs_heartbeat_reaper_index.sql +22 -0
- package/dist/db/migrations/20260518020000_runs_heartbeat_inflight_narrow.sql +36 -0
- package/dist/db/migrations/20260518040000_agent_transcript_snapshot.sql +54 -0
- package/dist/db/migrations/20260518050000_runs_denormalize_agent_conversation.sql +36 -0
- package/dist/db/migrations/20260518060000_revert_runs_denormalize.sql +29 -0
- package/dist/db/migrations/20260518070000_runs_heartbeat_inflight_widen.sql +33 -0
- package/dist/eval/client.d.ts.map +1 -1
- package/dist/eval/client.js +11 -0
- package/dist/eval/client.js.map +1 -1
- package/dist/eval/grader.js +2 -1
- package/dist/eval/grader.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/context.d.ts +13 -1
- package/dist/internal/context.d.ts.map +1 -1
- package/dist/internal/context.js +83 -8
- package/dist/internal/context.js.map +1 -1
- package/dist/internal/credentials.d.ts +5 -0
- package/dist/internal/credentials.d.ts.map +1 -1
- package/dist/internal/credentials.js +75 -1
- package/dist/internal/credentials.js.map +1 -1
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +2 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/local-env.d.ts.map +1 -1
- package/dist/internal/local-env.js +9 -2
- package/dist/internal/local-env.js.map +1 -1
- package/dist/server.bundle.mjs +7085 -2832
- package/dist/start-local.bundle.mjs +8269 -3656
- package/package.json +7 -5
- package/dist/connectors/google_photos.ts +0 -776
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector source resolution + compilation for the CLI.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `packages/server/src/utils/connector-catalog.ts` (the server-side
|
|
5
|
+
* versions of these helpers) but inlined here so the CLI doesn't depend on
|
|
6
|
+
* @lobu/server — that package is private and never published, while the CLI
|
|
7
|
+
* is what end users install from npm.
|
|
8
|
+
*
|
|
9
|
+
* Lookup order for bundled connector source:
|
|
10
|
+
* 1. dist/connectors/ next to this file (published CLI runtime — see
|
|
11
|
+
* packages/cli/scripts/build.cjs which copies packages/connectors/src
|
|
12
|
+
* there at build time).
|
|
13
|
+
* 2. ../../../connectors/src relative to this file (monorepo dev).
|
|
14
|
+
* 3. process.cwd()/packages/connectors/src (running from a parent dir).
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync } from "node:fs";
|
|
17
|
+
import { mkdtemp, readFile, rm, stat } from "node:fs/promises";
|
|
18
|
+
import { createRequire } from "node:module";
|
|
19
|
+
import { tmpdir } from "node:os";
|
|
20
|
+
import { join, resolve } from "node:path";
|
|
21
|
+
import { build } from "esbuild";
|
|
22
|
+
const require_ = createRequire(import.meta.url);
|
|
23
|
+
const SDK_ENTRY = require_.resolve("@lobu/connector-sdk");
|
|
24
|
+
// Single source of truth lives in @lobu/connector-worker. Duplicated here as
|
|
25
|
+
// a flat string array to keep this file self-contained — drift cost is low
|
|
26
|
+
// (the list is tiny and rarely changes; if a new external dep is added the
|
|
27
|
+
// CLI surfaces a clear bundling error and we update both places).
|
|
28
|
+
const EXTERNAL_RUNTIME_DEPS = ["playwright", "sharp", "jimp"];
|
|
29
|
+
const SOURCE_DIR_CANDIDATES = [
|
|
30
|
+
// Published CLI runtime: packages/cli/scripts/build.cjs copies the
|
|
31
|
+
// connector .ts sources into dist/connectors right next to this file.
|
|
32
|
+
resolve(import.meta.dirname ?? __dirname, "../../connectors"),
|
|
33
|
+
// Monorepo source layout.
|
|
34
|
+
resolve(import.meta.dirname ?? __dirname, "../../../../connectors/src"),
|
|
35
|
+
// Project-root fallback.
|
|
36
|
+
resolve(process.cwd(), "packages/connectors/src"),
|
|
37
|
+
];
|
|
38
|
+
const bundledFileCache = new Map();
|
|
39
|
+
export function findBundledConnectorFile(key) {
|
|
40
|
+
const cached = bundledFileCache.get(key);
|
|
41
|
+
if (cached !== undefined)
|
|
42
|
+
return cached;
|
|
43
|
+
// Mirror the resolver in @lobu/connector-worker's compile-connector.ts:
|
|
44
|
+
// subdir layout (`browser.evaluate` → `browser/evaluate.ts`) first, then
|
|
45
|
+
// the flat underscore convention (`chrome.tabs` → `chrome_tabs.ts`).
|
|
46
|
+
const candidates = [
|
|
47
|
+
`${key.replace(/\./g, "/")}.ts`,
|
|
48
|
+
`${key.replace(/\./g, "_")}.ts`,
|
|
49
|
+
];
|
|
50
|
+
let found = null;
|
|
51
|
+
outer: for (const dir of SOURCE_DIR_CANDIDATES) {
|
|
52
|
+
for (const fileName of candidates) {
|
|
53
|
+
const filePath = resolve(dir, fileName);
|
|
54
|
+
if (!filePath.startsWith(`${dir}/`))
|
|
55
|
+
continue;
|
|
56
|
+
if (existsSync(filePath)) {
|
|
57
|
+
found = filePath;
|
|
58
|
+
break outer;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
bundledFileCache.set(key, found);
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
// Connectors import npm deps with the `npm:` prefix. Strip it so esbuild
|
|
66
|
+
// resolves the bare specifier against the local node_modules; mark unresolved
|
|
67
|
+
// ones external so the CLI bundle still produces (the runtime will fail loud
|
|
68
|
+
// if a missing dep is actually used).
|
|
69
|
+
const npmSpecifierPlugin = {
|
|
70
|
+
name: "npm-specifier",
|
|
71
|
+
setup(b) {
|
|
72
|
+
b.onResolve({ filter: /^npm:/ }, async (args) => {
|
|
73
|
+
const bare = args.path
|
|
74
|
+
.slice(4)
|
|
75
|
+
.replace(/^(@[^/]+\/[^/@]+)@[^/]*/, "$1")
|
|
76
|
+
.replace(/^([^/@]+)@[^/]*/, "$1");
|
|
77
|
+
const resolved = await b.resolve(bare, {
|
|
78
|
+
resolveDir: args.resolveDir,
|
|
79
|
+
kind: args.kind,
|
|
80
|
+
});
|
|
81
|
+
if (resolved.errors.length > 0) {
|
|
82
|
+
return { path: bare, external: true, errors: [], warnings: [] };
|
|
83
|
+
}
|
|
84
|
+
return resolved;
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
const compiledFileCache = new Map();
|
|
89
|
+
export async function compileConnectorFromFile(filePath) {
|
|
90
|
+
let mtimeMs = null;
|
|
91
|
+
try {
|
|
92
|
+
mtimeMs = (await stat(filePath)).mtimeMs;
|
|
93
|
+
const cached = compiledFileCache.get(filePath);
|
|
94
|
+
if (cached && cached.mtimeMs === mtimeMs)
|
|
95
|
+
return cached.code;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// stat failed — fall through and let the build surface the real error.
|
|
99
|
+
}
|
|
100
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "lobu-cli-connector-"));
|
|
101
|
+
const outPath = join(tmpDir, "out.mjs");
|
|
102
|
+
try {
|
|
103
|
+
await build({
|
|
104
|
+
entryPoints: [filePath],
|
|
105
|
+
outfile: outPath,
|
|
106
|
+
bundle: true,
|
|
107
|
+
format: "esm",
|
|
108
|
+
platform: "node",
|
|
109
|
+
target: "node20",
|
|
110
|
+
alias: { lobu: SDK_ENTRY, "@lobu/connector-sdk": SDK_ENTRY },
|
|
111
|
+
banner: {
|
|
112
|
+
js: "import { createRequire as __createRequire } from 'module'; const require = __createRequire(import.meta.url);",
|
|
113
|
+
},
|
|
114
|
+
plugins: [npmSpecifierPlugin],
|
|
115
|
+
external: [...EXTERNAL_RUNTIME_DEPS],
|
|
116
|
+
write: true,
|
|
117
|
+
minify: false,
|
|
118
|
+
sourcemap: false,
|
|
119
|
+
});
|
|
120
|
+
const code = await readFile(outPath, "utf-8");
|
|
121
|
+
if (mtimeMs !== null)
|
|
122
|
+
compiledFileCache.set(filePath, { mtimeMs, code });
|
|
123
|
+
return code;
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=connector-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-loader.js","sourceRoot":"","sources":["../../../src/commands/_lib/connector-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EA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KAAK;SACjB,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,OAAO,KAAK,IAAI;YAAE,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `lobu connector run` — execute a connector locally against a browser_session
|
|
3
|
+
* auth profile, no feed row required, no events persisted.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: testing a device-bound browser_session profile end-to-end
|
|
6
|
+
* (does Chrome launch, are we signed in, does the connector emit anything?)
|
|
7
|
+
* used to require creating a real connections row + a feed + triggering it,
|
|
8
|
+
* and even then events would commit. This command runs the same compiled
|
|
9
|
+
* connector code the server runs, against the same SessionState shape, but
|
|
10
|
+
* locally on the user's Mac (where the source Chrome profile lives) and dumps the
|
|
11
|
+
* would-be events + would-be-next-checkpoint to stdout and a run artifact.
|
|
12
|
+
*
|
|
13
|
+
* Scope (v1): browser_session profiles only. OAuth / env / interactive
|
|
14
|
+
* profiles need credentials the CLI doesn't have; they require gateway-side
|
|
15
|
+
* execution (a separate trigger_feed dry_run path, not yet wired).
|
|
16
|
+
*
|
|
17
|
+
* Execution uses SubprocessExecutor (the same one the worker daemon uses),
|
|
18
|
+
* not an in-process executor — bugs in connector code don't take the CLI
|
|
19
|
+
* down, and we get the same isolation production gets.
|
|
20
|
+
*/
|
|
21
|
+
export interface ConnectorRunOptions {
|
|
22
|
+
connectorKey?: string;
|
|
23
|
+
authProfile?: string;
|
|
24
|
+
config?: string;
|
|
25
|
+
checkpointFromFeed?: string;
|
|
26
|
+
fromFeed?: string;
|
|
27
|
+
maxItems?: string;
|
|
28
|
+
check?: boolean;
|
|
29
|
+
json?: boolean;
|
|
30
|
+
context?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
org?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function connectorRun(args: ConnectorRunOptions, positionalKey?: string): Promise<void>;
|
|
35
|
+
//# sourceMappingURL=connector-run-cmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-run-cmd.d.ts","sourceRoot":"","sources":["../../../src/commands/_lib/connector-run-cmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAgBH,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4GD,wBAAsB,YAAY,CAChC,IAAI,EAAE,mBAAmB,EACzB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAqUf"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `lobu connector run` — execute a connector locally against a browser_session
|
|
3
|
+
* auth profile, no feed row required, no events persisted.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: testing a device-bound browser_session profile end-to-end
|
|
6
|
+
* (does Chrome launch, are we signed in, does the connector emit anything?)
|
|
7
|
+
* used to require creating a real connections row + a feed + triggering it,
|
|
8
|
+
* and even then events would commit. This command runs the same compiled
|
|
9
|
+
* connector code the server runs, against the same SessionState shape, but
|
|
10
|
+
* locally on the user's Mac (where the source Chrome profile lives) and dumps the
|
|
11
|
+
* would-be events + would-be-next-checkpoint to stdout and a run artifact.
|
|
12
|
+
*
|
|
13
|
+
* Scope (v1): browser_session profiles only. OAuth / env / interactive
|
|
14
|
+
* profiles need credentials the CLI doesn't have; they require gateway-side
|
|
15
|
+
* execution (a separate trigger_feed dry_run path, not yet wired).
|
|
16
|
+
*
|
|
17
|
+
* Execution uses SubprocessExecutor (the same one the worker daemon uses),
|
|
18
|
+
* not an in-process executor — bugs in connector code don't take the CLI
|
|
19
|
+
* down, and we get the same isolation production gets.
|
|
20
|
+
*/
|
|
21
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
22
|
+
import { writeFile } from "node:fs/promises";
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { homedir } from "node:os";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import { printText } from "../memory/_lib/output.js";
|
|
27
|
+
import { resolveContext } from "../../internal/context.js";
|
|
28
|
+
import { getUsableToken, resolveOrg } from "../memory/_lib/openclaw-auth.js";
|
|
29
|
+
import { compileConnectorFromFile, findBundledConnectorFile, } from "./connector-loader.js";
|
|
30
|
+
// The connector-run REST routes live on the main app (mounted at `/`),
|
|
31
|
+
// not under the Agent API (`/lobu`) or the MCP path. We resolve the
|
|
32
|
+
// app origin from the context's agent API URL — *not* the memory MCP
|
|
33
|
+
// URL, which historically defaulted to lobu.ai/mcp and pointed the
|
|
34
|
+
// connector-run client at the marketing site (404).
|
|
35
|
+
function apiBaseFrom(agentApiUrl) {
|
|
36
|
+
const { origin } = new URL(agentApiUrl);
|
|
37
|
+
return origin;
|
|
38
|
+
}
|
|
39
|
+
async function authedGet(apiUrl, token) {
|
|
40
|
+
const res = await fetch(apiUrl, {
|
|
41
|
+
headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
|
|
42
|
+
});
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
const body = await res.text().catch(() => "");
|
|
45
|
+
throw new Error(`GET ${apiUrl} → ${res.status} ${res.statusText}${body ? ` — ${body}` : ""}`);
|
|
46
|
+
}
|
|
47
|
+
return (await res.json());
|
|
48
|
+
}
|
|
49
|
+
function ensurePlaywrightAvailable() {
|
|
50
|
+
try {
|
|
51
|
+
const require_ = createRequire(import.meta.url);
|
|
52
|
+
require_.resolve("playwright");
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw new Error("Playwright is not installed. `lobu connector run` drives browser_session profiles via Playwright. Install: `bunx playwright install chromium`");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function parseJsonFlag(raw, flagName) {
|
|
59
|
+
if (!raw?.trim())
|
|
60
|
+
return {};
|
|
61
|
+
try {
|
|
62
|
+
const value = JSON.parse(raw);
|
|
63
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
64
|
+
throw new Error("expected a JSON object");
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
70
|
+
throw new Error(`--${flagName} expects a JSON object: ${msg}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function summarizeEvents(contents, max = 3) {
|
|
74
|
+
if (contents.length === 0)
|
|
75
|
+
return " (no events emitted)";
|
|
76
|
+
const sample = contents.slice(0, max);
|
|
77
|
+
return sample
|
|
78
|
+
.map((c, i) => {
|
|
79
|
+
const date = c.occurred_at instanceof Date
|
|
80
|
+
? c.occurred_at.toISOString()
|
|
81
|
+
: c.occurred_at;
|
|
82
|
+
const head = c.payload_text
|
|
83
|
+
? String(c.payload_text).slice(0, 90)
|
|
84
|
+
: "(no payload)";
|
|
85
|
+
return ` [${i + 1}] ${c.semantic_type ?? "?"} · ${date ?? "?"} · ${head}`;
|
|
86
|
+
})
|
|
87
|
+
.join("\n");
|
|
88
|
+
}
|
|
89
|
+
export async function connectorRun(args, positionalKey) {
|
|
90
|
+
ensurePlaywrightAvailable();
|
|
91
|
+
// Resolve API endpoint + auth from the chosen context. The agent API URL
|
|
92
|
+
// (e.g. https://app.lobu.ai/api/v1) shares an origin with the connector-run
|
|
93
|
+
// REST routes — unlike the memory MCP URL, which historically defaulted to
|
|
94
|
+
// lobu.ai/mcp and pointed this client at the marketing site.
|
|
95
|
+
//
|
|
96
|
+
// --url is an explicit override (for testing); LOBU_API_TOKEN short-circuits
|
|
97
|
+
// the credential store.
|
|
98
|
+
const ctx = await resolveContext(args.context);
|
|
99
|
+
const explicitUrl = args.url?.trim();
|
|
100
|
+
const apiBase = explicitUrl
|
|
101
|
+
? new URL(explicitUrl).origin
|
|
102
|
+
: apiBaseFrom(ctx.apiUrl);
|
|
103
|
+
const envToken = process.env.LOBU_API_TOKEN?.trim();
|
|
104
|
+
let token;
|
|
105
|
+
let resolvedContextName;
|
|
106
|
+
if (envToken) {
|
|
107
|
+
token = envToken;
|
|
108
|
+
resolvedContextName = ctx.name;
|
|
109
|
+
}
|
|
110
|
+
else if (explicitUrl) {
|
|
111
|
+
// Refuse to silently forward the context's stored credentials to a URL the
|
|
112
|
+
// user typed on the command line — that's how tokens leak to the wrong
|
|
113
|
+
// backend. Pair --url with LOBU_API_TOKEN explicitly.
|
|
114
|
+
throw new Error("--url requires LOBU_API_TOKEN to be set (refuse to forward stored credentials to an explicit override).");
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const tokenInfo = await getUsableToken(undefined, ctx.name);
|
|
118
|
+
if (!tokenInfo) {
|
|
119
|
+
throw new Error("Not logged in. Run `lobu login` first (or set LOBU_API_TOKEN; or pass --context <name>).");
|
|
120
|
+
}
|
|
121
|
+
token = tokenInfo.token;
|
|
122
|
+
resolvedContextName = tokenInfo.contextName;
|
|
123
|
+
}
|
|
124
|
+
const orgSlug = await resolveOrg(args.org, undefined, resolvedContextName);
|
|
125
|
+
if (!orgSlug) {
|
|
126
|
+
throw new Error("No active org. Run `lobu org use <slug>` or pass --org <slug>.");
|
|
127
|
+
}
|
|
128
|
+
// Resolve auth profile and (optionally) feed in parallel.
|
|
129
|
+
let feed = null;
|
|
130
|
+
if (args.fromFeed) {
|
|
131
|
+
const feedId = Number(args.fromFeed);
|
|
132
|
+
if (!Number.isFinite(feedId))
|
|
133
|
+
throw new Error(`--from-feed expects a numeric feed id (got: ${args.fromFeed})`);
|
|
134
|
+
const { feed: feedRow } = await authedGet(`${apiBase}/api/${orgSlug}/connector-run/feed/${feedId}`, token);
|
|
135
|
+
feed = feedRow;
|
|
136
|
+
printText(`Resolved feed #${feed.id} (${feed.feed_key}) → connector ${feed.connector_key}, auth profile ${feed.auth_profile_slug ?? "<none>"}`);
|
|
137
|
+
}
|
|
138
|
+
const connectorKey = positionalKey ?? args.connectorKey ?? feed?.connector_key;
|
|
139
|
+
if (!connectorKey) {
|
|
140
|
+
throw new Error("Missing connector key. Pass it positionally or use --from-feed <id>.");
|
|
141
|
+
}
|
|
142
|
+
const authProfileSlug = args.authProfile ?? feed?.auth_profile_slug ?? undefined;
|
|
143
|
+
if (!authProfileSlug) {
|
|
144
|
+
throw new Error("Missing --auth-profile <slug> (and --from-feed didn't supply one).");
|
|
145
|
+
}
|
|
146
|
+
const { profile } = await authedGet(`${apiBase}/api/${orgSlug}/connector-run/auth-profile/${encodeURIComponent(authProfileSlug)}`, token);
|
|
147
|
+
printText(`Resolved auth profile '${profile.slug}' (${profile.profile_kind}, status=${profile.status})`);
|
|
148
|
+
// v1 scope: only browser_session profiles. OAuth/env profiles' credentials
|
|
149
|
+
// live on the server and can't be safely materialized in the CLI process.
|
|
150
|
+
if (profile.profile_kind !== "browser_session") {
|
|
151
|
+
throw new Error(`Profile kind '${profile.profile_kind}' is not supported by \`lobu connector run\` (v1 supports only browser_session). Use the server-side trigger_feed path for OAuth/env-based profiles.`);
|
|
152
|
+
}
|
|
153
|
+
// Two auth shapes for a browser_session profile:
|
|
154
|
+
// 1. Mirror mode (auth_data.source_profile_dir set): decrypt cookies
|
|
155
|
+
// from the user's Chrome via keychain at sync time. The source
|
|
156
|
+
// dir must exist on this machine.
|
|
157
|
+
// 2. CDP attach (cdp_url set, no source_profile_dir): the user is
|
|
158
|
+
// running Chrome with --remote-debugging-port and we attach.
|
|
159
|
+
const mirrorSourceDir = profile.auth_data?.source_profile_dir;
|
|
160
|
+
const mirrorBrowserRoot = profile.auth_data?.source_browser_root;
|
|
161
|
+
const mirrorSourceBrowser = profile.auth_data?.source_browser ?? "chrome";
|
|
162
|
+
if (mirrorSourceDir && mirrorBrowserRoot) {
|
|
163
|
+
const sourceProfilePath = `${mirrorBrowserRoot}/${mirrorSourceDir}`;
|
|
164
|
+
if (!existsSync(sourceProfilePath)) {
|
|
165
|
+
throw new Error(`Source Chrome profile not found at ${sourceProfilePath}.\n` +
|
|
166
|
+
`The profile may have been deleted or renamed in your Chrome — re-pick in the Lobu menu bar.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (profile.cdp_url && !mirrorSourceDir) {
|
|
170
|
+
printText(`Profile uses CDP at ${profile.cdp_url} — make sure that Chrome is running with --remote-debugging-port.`);
|
|
171
|
+
}
|
|
172
|
+
// Build connector config: feed config + CLI overrides (shallow, top-level).
|
|
173
|
+
const cliConfig = parseJsonFlag(args.config, "config");
|
|
174
|
+
const mergedConfig = { ...(feed?.config ?? {}), ...cliConfig };
|
|
175
|
+
const maxItems = args.maxItems ? Number(args.maxItems) : undefined;
|
|
176
|
+
if (maxItems !== undefined && Number.isFinite(maxItems) && maxItems > 0) {
|
|
177
|
+
// Common-case caps that connectors actually honor; harmless if they ignore.
|
|
178
|
+
mergedConfig.max_scrolls =
|
|
179
|
+
mergedConfig.max_scrolls ?? Math.min(20, maxItems);
|
|
180
|
+
mergedConfig.max_items = mergedConfig.max_items ?? maxItems;
|
|
181
|
+
}
|
|
182
|
+
// Borrow checkpoint either from --checkpoint-from-feed or --from-feed.
|
|
183
|
+
let checkpoint = null;
|
|
184
|
+
if (args.checkpointFromFeed) {
|
|
185
|
+
const cpFeedId = Number(args.checkpointFromFeed);
|
|
186
|
+
if (!Number.isFinite(cpFeedId))
|
|
187
|
+
throw new Error(`--checkpoint-from-feed expects a numeric feed id`);
|
|
188
|
+
const { feed: cpFeed } = await authedGet(`${apiBase}/api/${orgSlug}/connector-run/feed/${cpFeedId}`, token);
|
|
189
|
+
checkpoint = cpFeed.checkpoint;
|
|
190
|
+
printText(`Borrowed checkpoint from feed #${cpFeed.id} (${cpFeed.feed_key})`);
|
|
191
|
+
}
|
|
192
|
+
else if (feed) {
|
|
193
|
+
checkpoint = feed.checkpoint;
|
|
194
|
+
}
|
|
195
|
+
// --check: validate everything resolved, don't actually run the connector.
|
|
196
|
+
if (args.check) {
|
|
197
|
+
const summary = {
|
|
198
|
+
connector_key: connectorKey,
|
|
199
|
+
auth_profile: profile.slug,
|
|
200
|
+
mode: mirrorSourceDir ? "mirror" : "cdp",
|
|
201
|
+
mirror: mirrorSourceDir
|
|
202
|
+
? {
|
|
203
|
+
source_profile_dir: mirrorSourceDir,
|
|
204
|
+
source_browser_root: mirrorBrowserRoot,
|
|
205
|
+
source_browser: mirrorSourceBrowser,
|
|
206
|
+
}
|
|
207
|
+
: null,
|
|
208
|
+
cdp_url: profile.cdp_url,
|
|
209
|
+
profile_status: profile.status,
|
|
210
|
+
feed_id: feed?.id,
|
|
211
|
+
checkpoint: checkpoint ?? null,
|
|
212
|
+
config: mergedConfig,
|
|
213
|
+
};
|
|
214
|
+
if (args.json)
|
|
215
|
+
printText(JSON.stringify(summary, null, 2));
|
|
216
|
+
else
|
|
217
|
+
printText("✓ All resolved. Re-run without --check to execute.");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
// Resolve and compile the connector. Done late so --check above doesn't
|
|
221
|
+
// pay the esbuild cost.
|
|
222
|
+
const sourcePath = findBundledConnectorFile(connectorKey);
|
|
223
|
+
if (!sourcePath) {
|
|
224
|
+
throw new Error(`Connector '${connectorKey}' not found in the bundled catalog. Check: \`lobu memory run manage_connections '{"action":"list_connector_definitions"}'\`.`);
|
|
225
|
+
}
|
|
226
|
+
printText(`Compiling ${connectorKey} from ${sourcePath}...`);
|
|
227
|
+
const compiledCode = await compileConnectorFromFile(sourcePath);
|
|
228
|
+
// Build the SyncContext shape that executeCompiledConnector expects.
|
|
229
|
+
// For mirror profiles we layer two acquisition paths:
|
|
230
|
+
// 1. DevToolsActivePort lookup against the source Chrome's
|
|
231
|
+
// user-data root. If the file is there, Chrome is exposing a
|
|
232
|
+
// live CDP WebSocket — either the user toggled the M144 setting
|
|
233
|
+
// at chrome://inspect/#remote-debugging, or they launched Chrome
|
|
234
|
+
// with --remote-debugging-port. Either way, we attach via CDP and
|
|
235
|
+
// run inside the user's actual Chrome session. Best fidelity for
|
|
236
|
+
// fingerprint-pinned sites (Revolut etc.).
|
|
237
|
+
// 2. Keychain-decrypted cookies. If Chrome isn't exposing CDP, the
|
|
238
|
+
// connector subprocess falls back to headless Playwright with
|
|
239
|
+
// these cookies injected via addCookies. Covers ~90% of sites.
|
|
240
|
+
//
|
|
241
|
+
// The connector subprocess's browser-network.ts tries CDP first when
|
|
242
|
+
// cdp_url is explicitly set, falls through to cookies on failure.
|
|
243
|
+
const sessionState = {};
|
|
244
|
+
if (mirrorSourceDir && mirrorBrowserRoot) {
|
|
245
|
+
const { acquireMirroredCookies } = await import("@lobu/connector-sdk/browser-mirror");
|
|
246
|
+
const { readDevToolsActivePort } = await import("@lobu/connector-sdk/browser-devtools-active-port");
|
|
247
|
+
// Layer 1: DevToolsActivePort — *only* when the user explicitly
|
|
248
|
+
// opted into CDP for this profile. Otherwise we never probe their
|
|
249
|
+
// Chrome's debug surface, even if M144 is enabled for other tools.
|
|
250
|
+
// Default-off matches the "no surprise dialogs" UX: the only way
|
|
251
|
+
// Lobu attaches to a live Chrome is if the user checked the box at
|
|
252
|
+
// profile-create time.
|
|
253
|
+
if (profile.auth_data?.allow_cdp_attach === true) {
|
|
254
|
+
const activePort = await readDevToolsActivePort(mirrorBrowserRoot);
|
|
255
|
+
if (activePort) {
|
|
256
|
+
printText(`Detected Chrome CDP at ${activePort.wsUrl} (via DevToolsActivePort).`);
|
|
257
|
+
sessionState.cdp_url = activePort.wsUrl;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
printText("CDP attach allowed for this profile, but Chrome isn't exposing remote debugging — falling back to mirror cookies.");
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// Layer 2: cookies. Always acquire — even if CDP attach succeeds,
|
|
264
|
+
// the cookies are a free fallback in case the CDP socket drops
|
|
265
|
+
// mid-sync. Cheap to skip on CDP success in practice.
|
|
266
|
+
printText(`Acquiring cookies from ${mirrorBrowserRoot}/${mirrorSourceDir}...`);
|
|
267
|
+
const acquired = await acquireMirroredCookies({
|
|
268
|
+
sourceBrowser: mirrorSourceBrowser,
|
|
269
|
+
userDataRoot: mirrorBrowserRoot,
|
|
270
|
+
sourceProfileDir: mirrorSourceDir,
|
|
271
|
+
});
|
|
272
|
+
printText(` Kept ${acquired.cookies.length} cookies (skipped ${acquired.skipped_google_count} Google-account cookies, ${acquired.total_decrypted_count} total).`);
|
|
273
|
+
sessionState.cookies = acquired.cookies;
|
|
274
|
+
}
|
|
275
|
+
// Explicit cdp_url on the profile row overrides DevToolsActivePort
|
|
276
|
+
// auto-discovery — the user pinned a specific port at create time.
|
|
277
|
+
if (profile.cdp_url)
|
|
278
|
+
sessionState.cdp_url = profile.cdp_url;
|
|
279
|
+
// Lazy-import the worker so the CLI startup doesn't pay this cost for
|
|
280
|
+
// every command (only this one needs it). executeCompiledConnector defaults
|
|
281
|
+
// to SubprocessExecutor internally — no need to instantiate one ourselves.
|
|
282
|
+
const { executeCompiledConnector } = await import("@lobu/connector-worker/executor/runtime");
|
|
283
|
+
// Signal handlers — Chrome processes spawned by Playwright don't always die
|
|
284
|
+
// with the parent. The subprocess executor's child is forked from us, so
|
|
285
|
+
// exiting the CLI process tears it down; the explicit exit code keeps the
|
|
286
|
+
// shell's $? meaningful for scripts.
|
|
287
|
+
const onSignal = (sig) => {
|
|
288
|
+
process.stderr.write(`\nReceived ${sig}, shutting down...\n`);
|
|
289
|
+
process.exit(130);
|
|
290
|
+
};
|
|
291
|
+
process.once("SIGINT", () => onSignal("SIGINT"));
|
|
292
|
+
process.once("SIGTERM", () => onSignal("SIGTERM"));
|
|
293
|
+
// Stream progress to stderr (so --json output to stdout stays clean).
|
|
294
|
+
let streamedCount = 0;
|
|
295
|
+
const onContentChunk = (items) => {
|
|
296
|
+
streamedCount += items.length;
|
|
297
|
+
process.stderr.write(` ... ${streamedCount} events so far\n`);
|
|
298
|
+
};
|
|
299
|
+
printText(`Running ${connectorKey} (subprocess executor)...`);
|
|
300
|
+
const startMs = Date.now();
|
|
301
|
+
const result = await executeCompiledConnector({
|
|
302
|
+
mode: "sync",
|
|
303
|
+
compiledCode,
|
|
304
|
+
config: mergedConfig,
|
|
305
|
+
checkpoint,
|
|
306
|
+
env: process.env,
|
|
307
|
+
connectionCredentials: {},
|
|
308
|
+
sessionState,
|
|
309
|
+
credentials: {},
|
|
310
|
+
feedKey: feed?.feed_key ?? `${connectorKey}-cli-run`,
|
|
311
|
+
entityIds: [],
|
|
312
|
+
apiType: "browser",
|
|
313
|
+
hooks: { onContentChunk, collectContents: true },
|
|
314
|
+
});
|
|
315
|
+
const durationMs = Date.now() - startMs;
|
|
316
|
+
// Save artifact for debugging / sharing. ~/.lobu/cache/connector-runs/<ts>.json.
|
|
317
|
+
const cacheDir = join(homedir(), ".lobu", "cache", "connector-runs");
|
|
318
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
319
|
+
const artifactPath = join(cacheDir, `${connectorKey}-${Date.now()}.json`);
|
|
320
|
+
const artifact = {
|
|
321
|
+
timestamp: new Date().toISOString(),
|
|
322
|
+
connector_key: connectorKey,
|
|
323
|
+
auth_profile_slug: profile.slug,
|
|
324
|
+
feed_id: feed?.id ?? null,
|
|
325
|
+
config: mergedConfig,
|
|
326
|
+
input_checkpoint: checkpoint,
|
|
327
|
+
duration_ms: durationMs,
|
|
328
|
+
event_count: result.contents.length,
|
|
329
|
+
next_checkpoint: result.checkpoint,
|
|
330
|
+
events: result.contents,
|
|
331
|
+
metadata: result.metadata ?? {},
|
|
332
|
+
};
|
|
333
|
+
await writeFile(artifactPath, JSON.stringify(artifact, null, 2), "utf-8");
|
|
334
|
+
if (args.json) {
|
|
335
|
+
printText(JSON.stringify(artifact, null, 2));
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
printText("");
|
|
339
|
+
printText(`✓ Completed in ${(durationMs / 1000).toFixed(1)}s`);
|
|
340
|
+
printText(` Events: ${result.contents.length}`);
|
|
341
|
+
if (result.contents.length > 0) {
|
|
342
|
+
printText(" Sample:");
|
|
343
|
+
printText(summarizeEvents(result.contents));
|
|
344
|
+
}
|
|
345
|
+
if (result.checkpoint) {
|
|
346
|
+
printText(` Next checkpoint: ${JSON.stringify(result.checkpoint)}`);
|
|
347
|
+
}
|
|
348
|
+
printText(` Full artifact: ${artifactPath}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=connector-run-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-run-cmd.js","sourceRoot":"","sources":["../../../src/commands/_lib/connector-run-cmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;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CAAC;QACd,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,EAAE,CAAC,CAAC;QACd,SAAS,CAAC,kBAAkB,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/D,SAAS,CAAC,aAAa,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,SAAS,CAAC,WAAW,CAAC,CAAC;YACvB,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,SAAS,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,SAAS,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `lobu export` — pull server state into apply-compatible files.
|
|
3
|
+
*
|
|
4
|
+
* Round-trips with `lobu apply`: every file written here is a valid input for
|
|
5
|
+
* a future apply on the same (or another) org. Scope is intentionally narrow:
|
|
6
|
+
* memory models (entity types, relationship types, watchers including
|
|
7
|
+
* reaction scripts as sibling `.ts` files) and connectors (connections +
|
|
8
|
+
* auth_profile placeholders). Agent config / lobu.toml / SOUL.md aren't
|
|
9
|
+
* exported — those are author-time files that don't get edited in the UI.
|
|
10
|
+
*
|
|
11
|
+
* The default destination is `<cwd>/models/exported.yaml` +
|
|
12
|
+
* `<cwd>/connectors/exported.yaml`. Both write paths are skipped when the
|
|
13
|
+
* file exists unless `--force` is passed.
|
|
14
|
+
*/
|
|
15
|
+
import { readFile } from "node:fs/promises";
|
|
16
|
+
export interface ExportOptions {
|
|
17
|
+
cwd?: string;
|
|
18
|
+
/** Override the destination directory (defaults to `cwd`). */
|
|
19
|
+
out?: string;
|
|
20
|
+
/** Allow overwriting existing exported files. */
|
|
21
|
+
force?: boolean;
|
|
22
|
+
/** Org slug (defaults to active session). */
|
|
23
|
+
org?: string;
|
|
24
|
+
/** Server URL override. */
|
|
25
|
+
url?: string;
|
|
26
|
+
/** Restrict to one resource family. */
|
|
27
|
+
only?: "models" | "connectors";
|
|
28
|
+
/** Test seam — inject fetch. */
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
}
|
|
31
|
+
export declare function exportCommand(opts?: ExportOptions): Promise<void>;
|
|
32
|
+
export declare const __exportInternals: {
|
|
33
|
+
readFile: typeof readFile;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=export-cmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-cmd.d.ts","sourceRoot":"","sources":["../../../../src/commands/_lib/export/export-cmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAS,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AAiB9D,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC/B,gCAAgC;IAChC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAmND,wBAAsB,aAAa,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsK3E;AAMD,eAAO,MAAM,iBAAiB;;CAAe,CAAC"}
|