@lobu/runtime-device 24.1.1 → 24.3.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/component.json +1 -1
- package/dist/dependencies.bun.lock +46 -134
- package/npm-shrinkwrap.json +229 -730
- package/package.json +1 -1
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +20 -5
- package/vendor/cli/dist/chrome-extension/accessibility-tree.js +834 -0
- package/vendor/cli/dist/chrome-extension/ambient-context.js +53 -0
- package/vendor/cli/dist/chrome-extension/auth-refresh.js +167 -0
- package/vendor/cli/dist/chrome-extension/automation-run.js +13 -0
- package/vendor/cli/dist/chrome-extension/background.js +1155 -0
- package/vendor/cli/dist/chrome-extension/bridge.js +140 -0
- package/vendor/cli/dist/chrome-extension/browser-origin-policy.js +62 -0
- package/vendor/cli/dist/chrome-extension/browser-recovery.js +260 -0
- package/vendor/cli/dist/chrome-extension/browser-url-sanitizer.js +284 -0
- package/vendor/cli/dist/chrome-extension/completion-response.js +12 -0
- package/vendor/cli/dist/chrome-extension/config.js +144 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome.json +1516 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome_bookmarks.json +84 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome_downloads.json +86 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome_history.json +78 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests.js +1767 -0
- package/vendor/cli/dist/chrome-extension/console-capture.js +627 -0
- package/vendor/cli/dist/chrome-extension/control-activity.js +70 -0
- package/vendor/cli/dist/chrome-extension/debugger-lease.js +439 -0
- package/vendor/cli/dist/chrome-extension/feed-listener.js +488 -0
- package/vendor/cli/dist/chrome-extension/feed-transaction.js +48 -0
- package/vendor/cli/dist/chrome-extension/feeds.js +632 -0
- package/vendor/cli/dist/chrome-extension/focus-tab.js +25 -0
- package/vendor/cli/dist/chrome-extension/fonts/dm-mono-latin-500-normal.woff2 +0 -0
- package/vendor/cli/dist/chrome-extension/fonts/dm-sans-latin-400-normal.woff2 +0 -0
- package/vendor/cli/dist/chrome-extension/fonts/dm-sans-latin-600-normal.woff2 +0 -0
- package/vendor/cli/dist/chrome-extension/heartbeat.js +140 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-128-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-128.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-16-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-16.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-32-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-32.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-48-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-48.png +0 -0
- package/vendor/cli/dist/chrome-extension/lens-page.js +135 -0
- package/vendor/cli/dist/chrome-extension/lens-target.js +20 -0
- package/vendor/cli/dist/chrome-extension/manifest.json +76 -0
- package/vendor/cli/dist/chrome-extension/network-intercept.js +657 -0
- package/vendor/cli/dist/chrome-extension/page-activation.js +120 -0
- package/vendor/cli/dist/chrome-extension/page-dialogs.js +125 -0
- package/vendor/cli/dist/chrome-extension/page-url.js +11 -0
- package/vendor/cli/dist/chrome-extension/panel-session.js +184 -0
- package/vendor/cli/dist/chrome-extension/poll-auth.js +85 -0
- package/vendor/cli/dist/chrome-extension/poll-backoff.js +22 -0
- package/vendor/cli/dist/chrome-extension/run-fence.js +117 -0
- package/vendor/cli/dist/chrome-extension/setup-status.js +71 -0
- package/vendor/cli/dist/chrome-extension/side-panel-action-click.js +65 -0
- package/vendor/cli/dist/chrome-extension/sidepanel-context.js +50 -0
- package/vendor/cli/dist/chrome-extension/sidepanel.html +680 -0
- package/vendor/cli/dist/chrome-extension/sidepanel.js +1643 -0
- package/vendor/cli/dist/chrome-extension/tab-labels.js +233 -0
- package/vendor/cli/dist/chrome-extension/tools.js +3354 -0
- package/vendor/cli/dist/chrome-extension/watch-observer.js +354 -0
- package/vendor/cli/dist/chrome-extension/watch-redact.js +96 -0
- package/vendor/cli/dist/chrome-extension/watch.js +348 -0
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +6 -4
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +5 -3
- package/vendor/cli/dist/commands/_lib/apply/diff.js +4 -3
- package/vendor/cli/dist/commands/_lib/chrome-for-testing.d.ts +13 -0
- package/vendor/cli/dist/commands/_lib/chrome-for-testing.js +226 -0
- package/vendor/cli/dist/commands/_lib/device-credential.d.ts +34 -0
- package/vendor/cli/dist/commands/_lib/device-credential.js +157 -0
- package/vendor/cli/dist/commands/_lib/device-wizard.d.ts +17 -0
- package/vendor/cli/dist/commands/_lib/device-wizard.js +11 -2
- package/vendor/cli/dist/commands/_lib/native-messaging.d.ts +7 -0
- package/vendor/cli/dist/commands/_lib/native-messaging.js +40 -0
- package/vendor/cli/dist/commands/browser.d.ts +23 -0
- package/vendor/cli/dist/commands/browser.js +492 -0
- package/vendor/cli/dist/commands/call.d.ts +12 -0
- package/vendor/cli/dist/commands/call.js +48 -26
- package/vendor/cli/dist/commands/chat.d.ts +0 -12
- package/vendor/cli/dist/commands/chat.js +1 -1
- package/vendor/cli/dist/commands/context.d.ts +3 -1
- package/vendor/cli/dist/commands/context.js +13 -2
- package/vendor/cli/dist/commands/daemon.js +38 -171
- package/vendor/cli/dist/commands/doctor.d.ts +0 -6
- package/vendor/cli/dist/commands/doctor.js +1 -1
- package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +4 -1
- package/vendor/cli/dist/commands/memory/_lib/errors.js +9 -1
- package/vendor/cli/dist/commands/memory/_lib/mcp.d.ts +0 -9
- package/vendor/cli/dist/commands/memory/_lib/mcp.js +1 -23
- package/vendor/cli/dist/commands/memory/_lib/memory-auth.d.ts +20 -4
- package/vendor/cli/dist/commands/memory/_lib/memory-auth.js +21 -17
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.d.ts +0 -8
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +7 -18
- package/vendor/cli/dist/commands/memory/run.js +4 -25
- package/vendor/cli/dist/config/define.d.ts +1 -1
- package/vendor/cli/dist/connectors/gchat.ts +31 -1
- package/vendor/cli/dist/connectors/google_gmail.ts +70 -41
- package/vendor/cli/dist/connectors/google_gmail_references.ts +406 -0
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +107 -36
- package/vendor/cli/dist/connectors/linkedin-inbox.ts +13 -0
- package/vendor/cli/dist/connectors/linkedin.ts +1 -1
- package/vendor/cli/dist/connectors/postgres.ts +14 -8
- package/vendor/cli/dist/connectors/reddit.ts +171 -5
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +147 -61
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +6 -2
- package/vendor/cli/dist/connectors/whatsapp_web.ts +48 -17
- package/vendor/cli/dist/connectors/x-dm-adapter.js +252 -35
- package/vendor/cli/dist/connectors/x.ts +189 -13
- package/vendor/cli/dist/index.js +46 -6
- package/vendor/cli/dist/internal/cli-update-check.d.ts +33 -0
- package/vendor/cli/dist/internal/cli-update-check.js +98 -0
- package/vendor/cli/dist/internal/credentials.js +10 -36
- package/vendor/cli/dist/internal/device-state.d.ts +2 -0
- package/vendor/cli/dist/internal/device-state.js +4 -0
- package/vendor/cli/dist/internal/gateway-url.d.ts +0 -8
- package/vendor/cli/dist/internal/gateway-url.js +1 -1
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +3 -1
- package/vendor/cli/dist/templates/TESTING.md.tmpl +8 -8
- package/vendor/cli/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +34 -1
- package/vendor/connector-sdk/dist/index.d.ts +3 -1
- package/vendor/connector-sdk/dist/index.js +4 -0
- package/vendor/connector-sdk/dist/redact.d.ts +10 -0
- package/vendor/{connector-worker/dist/executor → connector-sdk/dist}/redact.js +0 -49
- package/vendor/connector-sdk/dist/types.d.ts +2 -1
- package/vendor/connector-sdk/package.json +6 -1
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.d.ts +9 -0
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.js +23 -2
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +14 -6
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +62 -25
- package/vendor/connector-worker/dist/agent-turn/media-tools.d.ts +1 -0
- package/vendor/connector-worker/dist/agent-turn/media-tools.js +5 -2
- package/vendor/connector-worker/dist/bin.js +2 -0
- package/vendor/connector-worker/dist/daemon/acp-adapters/THIRD_PARTY_LICENSES.txt +1 -1
- package/vendor/connector-worker/dist/daemon/acp-adapters/claude.js +7339 -2136
- package/vendor/connector-worker/dist/daemon/agent-turn.js +52 -17
- package/vendor/connector-worker/dist/daemon/automation.js +3 -13
- package/vendor/connector-worker/dist/daemon/client.d.ts +23 -3
- package/vendor/connector-worker/dist/daemon/client.js +59 -5
- package/vendor/connector-worker/dist/daemon/executor.d.ts +0 -28
- package/vendor/connector-worker/dist/daemon/executor.js +27 -12
- package/vendor/connector-worker/dist/daemon/index.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/index.js +1 -1
- package/vendor/connector-worker/dist/daemon/interactive-session.js +29 -6
- package/vendor/connector-worker/dist/daemon/poll-loop.js +29 -2
- package/vendor/connector-worker/dist/daemon/start.d.ts +0 -1
- package/vendor/connector-worker/dist/daemon/start.js +1 -1
- package/vendor/connector-worker/dist/daemon/terminal-delivery.d.ts +6 -10
- package/vendor/connector-worker/dist/daemon/terminal-delivery.js +59 -23
- package/vendor/connector-worker/dist/daemon/terminal-failure.js +2 -2
- package/vendor/connector-worker/dist/executor/isolate.js +4 -1
- package/vendor/connector-worker/dist/isolate/bridge.d.ts +6 -2
- package/vendor/connector-worker/dist/isolate/bridge.js +14 -8
- package/vendor/connector-worker/package.json +2 -2
- package/vendor/core/dist/agent-tooling.d.ts +8 -0
- package/vendor/core/dist/agent-tooling.js +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +5 -0
- package/vendor/core/dist/connector-query-errors.d.ts +6 -0
- package/vendor/core/dist/connector-query-errors.js +4 -0
- package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
- package/vendor/core/dist/contracts/entity-reference.js +31 -0
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +4 -1
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +117 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +47 -14
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
- package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
- package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
- package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
- package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
- package/vendor/core/dist/contracts/worker/protocol.js +20 -0
- package/vendor/core/dist/errors.d.ts +0 -20
- package/vendor/core/dist/errors.js +1 -25
- package/vendor/core/dist/otel.js +38 -10
- package/vendor/core/dist/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/utils/ajv.js +3 -1
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +31 -5
- package/vendor/postgres/cf/src/query.js +3 -1
- package/vendor/postgres/cjs/src/query.js +3 -1
- package/vendor/postgres/src/query.js +3 -1
- package/vendor/connector-worker/dist/executor/http-status.d.ts +0 -16
- package/vendor/connector-worker/dist/executor/http-status.js +0 -21
- package/vendor/connector-worker/dist/executor/redact.d.ts +0 -29
- /package/vendor/postgres/{.bun-tag-2f292c6554a8475e → .bun-tag-22d644c2873790db} +0 -0
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* - live_messages: DMs read live from the signed-in browser without importing
|
|
24
24
|
* history; Automations subscribe to `message.created` and can
|
|
25
25
|
* answer through `send_message`
|
|
26
|
+
* - notifications: signed-in All timeline; metadata-only sync, explicit source reads
|
|
26
27
|
* - following_timeline: live chronological Following timeline (OAuth API,
|
|
27
28
|
* source reads only; does not import tweet events)
|
|
28
29
|
* - home_feed: personalized x.com home timeline (extension only — the
|
|
@@ -3146,19 +3147,32 @@ async function readyXLiveTab(
|
|
|
3146
3147
|
return nav.tab_id;
|
|
3147
3148
|
}
|
|
3148
3149
|
|
|
3150
|
+
/** Bind source access to the account saved by the connection's browser probe. */
|
|
3151
|
+
function requireXAccount(ctx: {
|
|
3152
|
+
sessionState?: Record<string, unknown> | null;
|
|
3153
|
+
}): string {
|
|
3154
|
+
const account = ctx.sessionState?.account_id;
|
|
3155
|
+
if (typeof account !== "string" || !/^[0-9]{1,20}$/.test(account))
|
|
3156
|
+
throw new Error(
|
|
3157
|
+
"X saved account identity is unavailable; reconnect this connection",
|
|
3158
|
+
);
|
|
3159
|
+
return account;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3149
3162
|
/** One call into the page program, installing it first when absent or stale. */
|
|
3150
3163
|
async function invokeXDirectMessages<T>(
|
|
3151
3164
|
dispatcher: ChromeActionDispatcher,
|
|
3152
3165
|
tabId: number,
|
|
3153
|
-
op: "read" | "listen" | "send",
|
|
3166
|
+
op: "read" | "listen" | "send" | "readNotifications",
|
|
3154
3167
|
input: Record<string, unknown>,
|
|
3168
|
+
accountId: string,
|
|
3155
3169
|
): Promise<T> {
|
|
3156
3170
|
const result = await dispatcher.dispatch<{
|
|
3157
3171
|
value?: T;
|
|
3158
3172
|
exception?: { description?: string } | unknown;
|
|
3159
3173
|
}>("evaluate", {
|
|
3160
3174
|
tab_id: tabId,
|
|
3161
|
-
expression: `(() => { (${xDirectMessagesProgram.toString()})(); return globalThis.__lobuXDirectMessagesV1.${op}(${xScriptArgument(input)}); })()`,
|
|
3175
|
+
expression: `(() => { (${xDirectMessagesProgram.toString()})(); return globalThis.__lobuXDirectMessagesV1.${op}(${xScriptArgument({ ...input, account_id: accountId })}); })()`,
|
|
3162
3176
|
await_promise: true,
|
|
3163
3177
|
});
|
|
3164
3178
|
if (result.exception || !result.value) {
|
|
@@ -3184,16 +3198,23 @@ async function readXLiveMessages(
|
|
|
3184
3198
|
assertNoWindow(ctx, message);
|
|
3185
3199
|
assertNoMatch(ctx, message);
|
|
3186
3200
|
const dispatcher = requireXBrowser(ctx);
|
|
3201
|
+
const accountId = requireXAccount(ctx);
|
|
3187
3202
|
const tabId = await readyXLiveTab(dispatcher);
|
|
3188
3203
|
const page = await invokeXDirectMessages<{
|
|
3189
3204
|
rows: Array<Record<string, unknown>>;
|
|
3190
3205
|
nextCursor?: string;
|
|
3191
3206
|
hasMore: boolean;
|
|
3192
|
-
}>(
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3207
|
+
}>(
|
|
3208
|
+
dispatcher,
|
|
3209
|
+
tabId,
|
|
3210
|
+
"read",
|
|
3211
|
+
{
|
|
3212
|
+
query: ctx.query,
|
|
3213
|
+
cursor: ctx.cursor,
|
|
3214
|
+
limit: ctx.limit,
|
|
3215
|
+
},
|
|
3216
|
+
accountId,
|
|
3217
|
+
);
|
|
3197
3218
|
return {
|
|
3198
3219
|
rows: page.rows,
|
|
3199
3220
|
columns: X_LIVE_MESSAGE_COLUMNS,
|
|
@@ -3209,6 +3230,7 @@ async function readXLiveMessages(
|
|
|
3209
3230
|
*/
|
|
3210
3231
|
async function observeXLiveMessages(ctx: FeedObserveContext): Promise<void> {
|
|
3211
3232
|
const dispatcher = requireXBrowser(ctx);
|
|
3233
|
+
const accountId = requireXAccount(ctx);
|
|
3212
3234
|
const tabId = await readyXLiveTab(dispatcher);
|
|
3213
3235
|
const binding = await dispatcher.dispatch<{
|
|
3214
3236
|
bridge_id?: string;
|
|
@@ -3224,11 +3246,148 @@ async function observeXLiveMessages(ctx: FeedObserveContext): Promise<void> {
|
|
|
3224
3246
|
) {
|
|
3225
3247
|
throw new Error("The paired browser must support source subscriptions");
|
|
3226
3248
|
}
|
|
3227
|
-
await invokeXDirectMessages(
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3249
|
+
await invokeXDirectMessages(
|
|
3250
|
+
dispatcher,
|
|
3251
|
+
tabId,
|
|
3252
|
+
"listen",
|
|
3253
|
+
{
|
|
3254
|
+
checkpoint: ctx.checkpoint ?? null,
|
|
3255
|
+
bridge_id: binding.bridge_id,
|
|
3256
|
+
token: binding.token,
|
|
3257
|
+
},
|
|
3258
|
+
accountId,
|
|
3259
|
+
);
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
async function readXNotifications(
|
|
3263
|
+
ctx: FeedReadContext,
|
|
3264
|
+
): Promise<FeedReadResult> {
|
|
3265
|
+
const message =
|
|
3266
|
+
"X notifications support source cursor pagination only; queries, windows, offsets, matching and sorting are unsupported";
|
|
3267
|
+
assertNoOffsetPaging(ctx, message);
|
|
3268
|
+
assertNoSort(ctx, message);
|
|
3269
|
+
assertNoWindow(ctx, message);
|
|
3270
|
+
assertNoMatch(ctx, message);
|
|
3271
|
+
if (ctx.query) throw new Error(message);
|
|
3272
|
+
const browser = requireXBrowser(ctx);
|
|
3273
|
+
const accountId = requireXAccount(ctx);
|
|
3274
|
+
const result = await invokeXDirectMessages<FeedReadResult>(
|
|
3275
|
+
browser,
|
|
3276
|
+
await readyXLiveTab(browser),
|
|
3277
|
+
"readNotifications",
|
|
3278
|
+
{ cursor: ctx.cursor, limit: ctx.limit },
|
|
3279
|
+
accountId,
|
|
3280
|
+
);
|
|
3281
|
+
return {
|
|
3282
|
+
rows: result.rows,
|
|
3283
|
+
nextCursor: result.nextCursor,
|
|
3284
|
+
hasMore: result.hasMore,
|
|
3285
|
+
};
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
async function syncXNotifications(ctx: SyncContext): Promise<SyncResult> {
|
|
3289
|
+
const browser = requireXBrowser(ctx);
|
|
3290
|
+
const accountId = requireXAccount(ctx);
|
|
3291
|
+
if (
|
|
3292
|
+
ctx.checkpoint?.notifications_account &&
|
|
3293
|
+
ctx.checkpoint.notifications_account !== accountId
|
|
3294
|
+
)
|
|
3295
|
+
throw new Error("X notification checkpoint belongs to another account");
|
|
3296
|
+
const tab = await readyXLiveTab(browser);
|
|
3297
|
+
const saved = ctx.checkpoint?.notifications_cursor as
|
|
3298
|
+
| string
|
|
3299
|
+
| null
|
|
3300
|
+
| undefined;
|
|
3301
|
+
const previousHead = ctx.checkpoint?.notifications_head_revision;
|
|
3302
|
+
let head: string | undefined;
|
|
3303
|
+
let catchingUp = !!saved;
|
|
3304
|
+
let cursor: string | undefined;
|
|
3305
|
+
let account: string | undefined;
|
|
3306
|
+
let cursorReset = false;
|
|
3307
|
+
const seenCursors = new Set<string>();
|
|
3308
|
+
const seenItems = new Set<string>();
|
|
3309
|
+
const events: EventEnvelope[] = [];
|
|
3310
|
+
for (let page = 0; page < 10; page++) {
|
|
3311
|
+
if (cursor) seenCursors.add(cursor);
|
|
3312
|
+
const result = await invokeXDirectMessages<
|
|
3313
|
+
FeedReadResult & { account_id: string; expired?: boolean }
|
|
3314
|
+
>(
|
|
3315
|
+
browser,
|
|
3316
|
+
tab,
|
|
3317
|
+
"readNotifications",
|
|
3318
|
+
{
|
|
3319
|
+
cursor,
|
|
3320
|
+
limit: 100,
|
|
3321
|
+
restartExpired: !cursorReset,
|
|
3322
|
+
metadataOnly: true,
|
|
3323
|
+
},
|
|
3324
|
+
accountId,
|
|
3325
|
+
);
|
|
3326
|
+
account = result.account_id;
|
|
3327
|
+
if (
|
|
3328
|
+
ctx.checkpoint?.notifications_account &&
|
|
3329
|
+
ctx.checkpoint.notifications_account !== account
|
|
3330
|
+
)
|
|
3331
|
+
throw new Error("X notification checkpoint belongs to another account");
|
|
3332
|
+
if (result.expired) {
|
|
3333
|
+
if (page === 9)
|
|
3334
|
+
throw new Error(
|
|
3335
|
+
"X notification cursor restart exceeds the page budget; retry without committing",
|
|
3336
|
+
);
|
|
3337
|
+
cursorReset = true;
|
|
3338
|
+
cursor = undefined;
|
|
3339
|
+
seenCursors.clear();
|
|
3340
|
+
continue;
|
|
3341
|
+
}
|
|
3342
|
+
head ??= result.rows[0]?.revision as string | undefined;
|
|
3343
|
+
for (const row of result.rows) {
|
|
3344
|
+
if (seenItems.has(String(row.id))) continue;
|
|
3345
|
+
seenItems.add(String(row.id));
|
|
3346
|
+
events.push({
|
|
3347
|
+
origin_id: `x_notification_${row.id}`,
|
|
3348
|
+
origin_type: "notification",
|
|
3349
|
+
payload_text: "",
|
|
3350
|
+
title: "X notification reference",
|
|
3351
|
+
source_url: String(row.url),
|
|
3352
|
+
occurred_at: new Date(String(row.occurred_at)),
|
|
3353
|
+
metadata: {
|
|
3354
|
+
account_id: row.account_id,
|
|
3355
|
+
entry_id: row.entry_id,
|
|
3356
|
+
notification_id: row.notification_id,
|
|
3357
|
+
kind: row.kind,
|
|
3358
|
+
actor_ids: row.actor_ids,
|
|
3359
|
+
tweet_ids: row.tweet_ids,
|
|
3360
|
+
revision: row.revision,
|
|
3361
|
+
timestamp_basis: row.timestamp_basis,
|
|
3362
|
+
},
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
cursor = result.nextCursor;
|
|
3366
|
+
// Do not skip arrivals spanning multiple pages before resuming history.
|
|
3367
|
+
// A missing head boundary falls back to a full sweep from this position.
|
|
3368
|
+
if (
|
|
3369
|
+
catchingUp &&
|
|
3370
|
+
result.rows.some((row) => row.revision === previousHead)
|
|
3371
|
+
) {
|
|
3372
|
+
catchingUp = false;
|
|
3373
|
+
if (cursor && saved) cursor = saved;
|
|
3374
|
+
}
|
|
3375
|
+
if (!cursor) break;
|
|
3376
|
+
if (seenCursors.has(cursor))
|
|
3377
|
+
throw new Error("X notification cursor did not advance");
|
|
3378
|
+
}
|
|
3379
|
+
await ctx.commit(events, {
|
|
3380
|
+
notifications_cursor: cursor ?? null,
|
|
3381
|
+
notifications_account: account,
|
|
3382
|
+
notifications_head_revision: head ?? null,
|
|
3231
3383
|
});
|
|
3384
|
+
return {
|
|
3385
|
+
status: cursor ? "more" : "complete",
|
|
3386
|
+
metadata: {
|
|
3387
|
+
items_found: events.length,
|
|
3388
|
+
...(cursorReset ? { cursor_reset: true } : {}),
|
|
3389
|
+
},
|
|
3390
|
+
};
|
|
3232
3391
|
}
|
|
3233
3392
|
|
|
3234
3393
|
// ── Connector ──────────────────────────────────────────────────
|
|
@@ -3238,8 +3397,8 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3238
3397
|
key: "x",
|
|
3239
3398
|
name: "X (Twitter)",
|
|
3240
3399
|
description:
|
|
3241
|
-
"Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, reads the chronological Following timeline live through the X API, and reads and answers DMs live in the paired browser. Links social actors into the person graph.",
|
|
3242
|
-
version: "3.
|
|
3400
|
+
"Fetches tweets, browser-visible like history, bookmarks, and DMs through the X API v2 or the paired Owletto Chrome extension, reads the chronological Following timeline live through the X API, captures notification references, and reads and answers DMs live in the paired browser. Links social actors into the person graph.",
|
|
3401
|
+
version: "3.16.0",
|
|
3243
3402
|
faviconDomain: "x.com",
|
|
3244
3403
|
browser: {
|
|
3245
3404
|
origins: ["https://x.com", "https://twitter.com"],
|
|
@@ -3324,8 +3483,23 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3324
3483
|
{ key: "liked_tweet", label: "Liked Tweet" },
|
|
3325
3484
|
{ key: "bookmark", label: "Bookmark" },
|
|
3326
3485
|
{ key: "dm_message", label: "DM Message" },
|
|
3486
|
+
{ key: "notification", label: "Notification" },
|
|
3327
3487
|
],
|
|
3328
3488
|
feeds: {
|
|
3489
|
+
notifications: {
|
|
3490
|
+
key: "notifications",
|
|
3491
|
+
name: "Notifications",
|
|
3492
|
+
description:
|
|
3493
|
+
"Read the signed-in account's retained All notifications timeline and capture metadata-only references without opening the notification panel or marking items seen. Includes source-exposed grouped reactions/follows and post entries; source icon categories are retained. History is limited by X. For post entries the source date is post creation time, not an invented notification time. Requires browser authentication; this is not OS push interception.",
|
|
3494
|
+
read: readXNotifications,
|
|
3495
|
+
sync: syncXNotifications,
|
|
3496
|
+
eventKinds: {
|
|
3497
|
+
notification: {
|
|
3498
|
+
description:
|
|
3499
|
+
"A metadata-only reference to an X notification timeline item",
|
|
3500
|
+
},
|
|
3501
|
+
},
|
|
3502
|
+
},
|
|
3329
3503
|
live_messages: {
|
|
3330
3504
|
key: "live_messages",
|
|
3331
3505
|
name: "Live messages",
|
|
@@ -3585,6 +3759,7 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3585
3759
|
try {
|
|
3586
3760
|
if (ctx.actionKey === "send_message") {
|
|
3587
3761
|
const dispatcher = requireXBrowser(ctx);
|
|
3762
|
+
const accountId = requireXAccount(ctx);
|
|
3588
3763
|
const tabId = await readyXLiveTab(dispatcher);
|
|
3589
3764
|
const output = await invokeXDirectMessages<Record<string, unknown>>(
|
|
3590
3765
|
dispatcher,
|
|
@@ -3595,6 +3770,7 @@ export default class XConnector extends ConnectorRuntime {
|
|
|
3595
3770
|
text: ctx.input.text,
|
|
3596
3771
|
idempotency_key: ctx.input.idempotency_key,
|
|
3597
3772
|
},
|
|
3773
|
+
accountId,
|
|
3598
3774
|
);
|
|
3599
3775
|
return { success: true, output };
|
|
3600
3776
|
}
|
package/vendor/cli/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { dirname, join } from "node:path";
|
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import chalk from "chalk";
|
|
20
20
|
import { Command } from "commander";
|
|
21
|
+
import { browserListCommand, browserNativeHostCommand, browserRemoveCommand, browserStartCommand, browserStopCommand, } from "./commands/browser.js";
|
|
21
22
|
import { opencodePluginCommand, } from "./commands/opencode-plugin.js";
|
|
22
23
|
import { GATEWAY_DEFAULT_URL } from "./internal/index.js";
|
|
23
24
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -88,12 +89,12 @@ Cloud:
|
|
|
88
89
|
providers <subcmd> Manage org model providers (create, set-key, ...)
|
|
89
90
|
sandbox <subcmd> Manage sandboxes (runtime providers)
|
|
90
91
|
clients <subcmd> List / revoke connected clients (MCP, messaging)
|
|
91
|
-
call [tool] Invoke
|
|
92
|
+
call [tool] Invoke a tool by name (run_sdk/query_sdk/query_sql need --arg title=)
|
|
92
93
|
token [create] Print or mint personal access tokens
|
|
94
|
+
browser <subcmd> Named browsers paired as devices (start, stop, list, rm)
|
|
93
95
|
|
|
94
96
|
Memory:
|
|
95
97
|
memory run [tool] Invoke a memory MCP tool
|
|
96
|
-
memory exec <script> Run a ClientSDK script
|
|
97
98
|
memory health Validate login + MCP connectivity
|
|
98
99
|
memory seed [path] Provision a memory workspace
|
|
99
100
|
`);
|
|
@@ -202,7 +203,7 @@ Memory:
|
|
|
202
203
|
// ─── rollback ───────────────────────────────────────────────────────────
|
|
203
204
|
program
|
|
204
205
|
.command("rollback")
|
|
205
|
-
.argument("<applyId>", "Deployment to restore (apl_… from
|
|
206
|
+
.argument("<applyId>", "Deployment to restore (apl_… from the Events page, Applies filter)")
|
|
206
207
|
.description("Restore a previous deployment from its stored snapshot (pauses future applies until --resume)")
|
|
207
208
|
.option("--yes", "Skip the confirmation prompt (CI mode)")
|
|
208
209
|
.option("--org <slug>", "Org slug override (defaults to active session)")
|
|
@@ -240,6 +241,7 @@ Memory:
|
|
|
240
241
|
.option("-q, --quiet", "Suppress spinner; bail immediately if non-interactive (CI / backgrounded shells)")
|
|
241
242
|
.option("--email <address>", "Headless login on a user's behalf: the server emails them an approval link (auth.md user_claimed flow)")
|
|
242
243
|
.option("--wait-for-approval", "Keep polling for browser approval when supervised without a TTY")
|
|
244
|
+
.option("--client-name <name>", 'Register this login as its own OAuth client name (default "Lobu CLI"); the activity feed attributes the context\'s calls to it')
|
|
243
245
|
.action(async (options) => {
|
|
244
246
|
const { loginCommand } = await import("./commands/login.js");
|
|
245
247
|
await loginCommand({ ...options, cliVersion: version });
|
|
@@ -303,9 +305,10 @@ Memory:
|
|
|
303
305
|
context
|
|
304
306
|
.command("list")
|
|
305
307
|
.description("List configured contexts")
|
|
306
|
-
.
|
|
308
|
+
.option("--json", "Print JSON: each context's name, URL, and whether credentials are stored")
|
|
309
|
+
.action(async (options) => {
|
|
307
310
|
const { contextListCommand } = await import("./commands/context.js");
|
|
308
|
-
await contextListCommand();
|
|
311
|
+
await contextListCommand(options);
|
|
309
312
|
});
|
|
310
313
|
context
|
|
311
314
|
.command("current")
|
|
@@ -596,7 +599,7 @@ Memory:
|
|
|
596
599
|
// the REST proxy. See packages/cli/src/commands/call.ts for the arg shape.
|
|
597
600
|
withCommonOpts(program
|
|
598
601
|
.command("call [tool]")
|
|
599
|
-
.description("Invoke
|
|
602
|
+
.description("Invoke a tool by name (POST /api/<org>/<tool>; MCP tools/call when LOBU_API_TOKEN + LOBU_MEMORY_URL are set). run_sdk, query_sdk and query_sql require --arg title=<heading>. Run with --list or no args to discover.")
|
|
600
603
|
.option("--list", "List tools available to the current token (default when called bare)")
|
|
601
604
|
.option("--all", "Include internal/admin-only tools in --list output")
|
|
602
605
|
.option("--input-file <path>", "Read the JSON args body from a file (top-level object)")
|
|
@@ -638,6 +641,43 @@ Memory:
|
|
|
638
641
|
const { daemonCommand } = await loadDeviceCommand("daemon");
|
|
639
642
|
await daemonCommand({ ...options, cliVersion: version });
|
|
640
643
|
});
|
|
644
|
+
// ─── browser ────────────────────────────────────────────────────────
|
|
645
|
+
const browser = program
|
|
646
|
+
.command("browser")
|
|
647
|
+
.description("Run named Chrome browsers paired to Lobu as devices");
|
|
648
|
+
browser
|
|
649
|
+
.command("start <name>")
|
|
650
|
+
.description("Open a named browser and connect it as a device (downloads Chrome for Testing on first use)")
|
|
651
|
+
.option("-c, --context <name>", "Use a named context for a new browser")
|
|
652
|
+
.option("--headless", "Run without a window (servers without a display)")
|
|
653
|
+
.action(async (name, options) => {
|
|
654
|
+
await browserStartCommand(name, options);
|
|
655
|
+
});
|
|
656
|
+
browser
|
|
657
|
+
.command("stop <name>")
|
|
658
|
+
.description("Close a named browser")
|
|
659
|
+
.action(async (name) => {
|
|
660
|
+
await browserStopCommand(name);
|
|
661
|
+
});
|
|
662
|
+
browser
|
|
663
|
+
.command("list")
|
|
664
|
+
.description("List named browsers and whether their devices are online")
|
|
665
|
+
.option("--json", "Print JSON")
|
|
666
|
+
.action(async (options) => {
|
|
667
|
+
await browserListCommand(options);
|
|
668
|
+
});
|
|
669
|
+
browser
|
|
670
|
+
.command("rm <name>")
|
|
671
|
+
.description("Remove a named browser, its device, and its profile")
|
|
672
|
+
.action(async (name) => {
|
|
673
|
+
await browserRemoveCommand(name);
|
|
674
|
+
});
|
|
675
|
+
browser
|
|
676
|
+
.command("native-host <name>", { hidden: true })
|
|
677
|
+
.description("Pair the Lobu extension in a named browser (run by Chrome)")
|
|
678
|
+
.action(async (name) => {
|
|
679
|
+
await browserNativeHostCommand(name);
|
|
680
|
+
});
|
|
641
681
|
program
|
|
642
682
|
.command("opencode-plugin <action>")
|
|
643
683
|
.description("Manage Lobu's interactive-session plugin for OpenCode")
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells a long-running `lobu daemon` user that a newer CLI is published.
|
|
3
|
+
*
|
|
4
|
+
* A headless daemon runs for weeks on whatever version started it, and nothing
|
|
5
|
+
* else tells its owner that it is outdated. The check reads the public
|
|
6
|
+
* `@lobu/cli` dist-tags once at start and about once a day after that. It
|
|
7
|
+
* never blocks the daemon and never fails it: any network, parse or version
|
|
8
|
+
* problem is a silent skip. `LOBU_NO_UPDATE_CHECK=1` turns it off.
|
|
9
|
+
*/
|
|
10
|
+
/** How a headless daemon user gets onto the latest CLI. */
|
|
11
|
+
export declare const CLI_DAEMON_UPGRADE_STEPS = "restart it with `npx -y @lobu/cli@latest daemon`, or run `npm install -g @lobu/cli@latest` and restart `lobu daemon`";
|
|
12
|
+
/**
|
|
13
|
+
* True when `latest` is a strictly newer release than `current`. A canary
|
|
14
|
+
* (`X.Y.Z-canary…`) is built after release X.Y.Z, so it is only behind a
|
|
15
|
+
* strictly newer release.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isNewerCliRelease(current: string, latest: string): boolean;
|
|
18
|
+
/** The one line printed when a newer CLI exists, or null. Never throws. */
|
|
19
|
+
export declare function checkForCliUpdate(currentVersion: string, fetchImpl?: typeof fetch, stopSignal?: AbortSignal): Promise<string | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Check now and about every 24h, printing to stderr when a newer CLI exists.
|
|
22
|
+
* Returns a stop function. Does nothing when the running version is unknown
|
|
23
|
+
* or the user opted out. The timer is unref'd so it never keeps the process
|
|
24
|
+
* alive on its own.
|
|
25
|
+
*/
|
|
26
|
+
export declare function startCliUpdateNotifier(options: {
|
|
27
|
+
currentVersion: string | undefined;
|
|
28
|
+
env?: NodeJS.ProcessEnv;
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
print?: (line: string) => void;
|
|
31
|
+
intervalMs?: number;
|
|
32
|
+
}): () => void;
|
|
33
|
+
//# sourceMappingURL=cli-update-check.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells a long-running `lobu daemon` user that a newer CLI is published.
|
|
3
|
+
*
|
|
4
|
+
* A headless daemon runs for weeks on whatever version started it, and nothing
|
|
5
|
+
* else tells its owner that it is outdated. The check reads the public
|
|
6
|
+
* `@lobu/cli` dist-tags once at start and about once a day after that. It
|
|
7
|
+
* never blocks the daemon and never fails it: any network, parse or version
|
|
8
|
+
* problem is a silent skip. `LOBU_NO_UPDATE_CHECK=1` turns it off.
|
|
9
|
+
*/
|
|
10
|
+
const DIST_TAGS_URL = "https://registry.npmjs.org/-/package/@lobu/cli/dist-tags";
|
|
11
|
+
const CHECK_TIMEOUT_MS = 5_000;
|
|
12
|
+
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
13
|
+
const OPT_OUT_ENV = "LOBU_NO_UPDATE_CHECK";
|
|
14
|
+
/** How a headless daemon user gets onto the latest CLI. */
|
|
15
|
+
export const CLI_DAEMON_UPGRADE_STEPS = "restart it with `npx -y @lobu/cli@latest daemon`, or run `npm install -g @lobu/cli@latest` and restart `lobu daemon`";
|
|
16
|
+
/**
|
|
17
|
+
* Release components of `major.minor.patch`, ignoring any `-prerelease` or
|
|
18
|
+
* `+build` suffix and a fourth build component; null when unparseable.
|
|
19
|
+
*/
|
|
20
|
+
function releaseOf(version) {
|
|
21
|
+
const core = version.trim().split("+")[0]?.split("-")[0] ?? "";
|
|
22
|
+
const parts = core.split(".");
|
|
23
|
+
if (parts.length < 3 || parts.length > 4)
|
|
24
|
+
return null;
|
|
25
|
+
const numbers = parts.map((part) => part !== "" && [...part].every((char) => char >= "0" && char <= "9")
|
|
26
|
+
? Number(part)
|
|
27
|
+
: Number.NaN);
|
|
28
|
+
if (numbers.some((value) => !Number.isSafeInteger(value)))
|
|
29
|
+
return null;
|
|
30
|
+
const [major, minor, patch] = numbers;
|
|
31
|
+
return [major, minor, patch];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* True when `latest` is a strictly newer release than `current`. A canary
|
|
35
|
+
* (`X.Y.Z-canary…`) is built after release X.Y.Z, so it is only behind a
|
|
36
|
+
* strictly newer release.
|
|
37
|
+
*/
|
|
38
|
+
export function isNewerCliRelease(current, latest) {
|
|
39
|
+
const have = releaseOf(current);
|
|
40
|
+
const want = releaseOf(latest);
|
|
41
|
+
if (!have || !want)
|
|
42
|
+
return false;
|
|
43
|
+
const [haveMajor, haveMinor, havePatch] = have;
|
|
44
|
+
const [wantMajor, wantMinor, wantPatch] = want;
|
|
45
|
+
if (wantMajor !== haveMajor)
|
|
46
|
+
return wantMajor > haveMajor;
|
|
47
|
+
if (wantMinor !== haveMinor)
|
|
48
|
+
return wantMinor > haveMinor;
|
|
49
|
+
return wantPatch > havePatch;
|
|
50
|
+
}
|
|
51
|
+
/** The one line printed when a newer CLI exists, or null. Never throws. */
|
|
52
|
+
export async function checkForCliUpdate(currentVersion, fetchImpl = fetch, stopSignal) {
|
|
53
|
+
try {
|
|
54
|
+
const timeout = AbortSignal.timeout(CHECK_TIMEOUT_MS);
|
|
55
|
+
const response = await fetchImpl(DIST_TAGS_URL, {
|
|
56
|
+
signal: stopSignal ? AbortSignal.any([stopSignal, timeout]) : timeout,
|
|
57
|
+
});
|
|
58
|
+
if (!response.ok)
|
|
59
|
+
return null;
|
|
60
|
+
const tags = (await response.json());
|
|
61
|
+
const latest = typeof tags?.latest === "string" ? tags.latest : null;
|
|
62
|
+
if (!latest || !isNewerCliRelease(currentVersion, latest))
|
|
63
|
+
return null;
|
|
64
|
+
return `Lobu CLI ${latest} is available (this daemon runs ${currentVersion}). To update, ${CLI_DAEMON_UPGRADE_STEPS}. Set ${OPT_OUT_ENV}=1 to silence this check.`;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check now and about every 24h, printing to stderr when a newer CLI exists.
|
|
72
|
+
* Returns a stop function. Does nothing when the running version is unknown
|
|
73
|
+
* or the user opted out. The timer is unref'd so it never keeps the process
|
|
74
|
+
* alive on its own.
|
|
75
|
+
*/
|
|
76
|
+
export function startCliUpdateNotifier(options) {
|
|
77
|
+
const env = options.env ?? process.env;
|
|
78
|
+
const currentVersion = options.currentVersion?.trim();
|
|
79
|
+
const optOut = env[OPT_OUT_ENV]?.trim();
|
|
80
|
+
if (!currentVersion || (optOut && optOut !== "0"))
|
|
81
|
+
return () => undefined;
|
|
82
|
+
const print = options.print ?? ((line) => process.stderr.write(`${line}\n`));
|
|
83
|
+
const controller = new AbortController();
|
|
84
|
+
const check = () => {
|
|
85
|
+
void checkForCliUpdate(currentVersion, options.fetchImpl, controller.signal).then((line) => {
|
|
86
|
+
if (line && !controller.signal.aborted)
|
|
87
|
+
print(line);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
check();
|
|
91
|
+
const timer = setInterval(check, options.intervalMs ?? CHECK_INTERVAL_MS);
|
|
92
|
+
timer.unref?.();
|
|
93
|
+
return () => {
|
|
94
|
+
clearInterval(timer);
|
|
95
|
+
controller.abort();
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=cli-update-check.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { credentialCanRefresh, credentialNeedsRefresh, deleteContextCredential, readContextCredential, writeContextCredential, } from "@lobu/core";
|
|
3
|
-
import { DEFAULT_CONTEXT_NAME,
|
|
3
|
+
import { DEFAULT_CONTEXT_NAME, LOBU_CONFIG_DIR, resolveContext, setActiveOrg, } from "./context.js";
|
|
4
4
|
import { refreshTokens } from "./oauth.js";
|
|
5
5
|
const CREDENTIALS_FILE = join(LOBU_CONFIG_DIR, "credentials.json");
|
|
6
6
|
// Per-process cache. `lobu apply` calls `getToken()` once per request; without
|
|
@@ -75,24 +75,14 @@ export async function getAgentApiToken(contextName) {
|
|
|
75
75
|
const token = await getCredentialsToken(contextName);
|
|
76
76
|
if (!token)
|
|
77
77
|
return null;
|
|
78
|
-
|
|
79
|
-
if (!creds?.localWorkerToken && (await isLoopbackContext(contextName))) {
|
|
80
|
-
creds = await tryLocalInit(contextName);
|
|
81
|
-
}
|
|
78
|
+
const creds = await loadCredentials(contextName);
|
|
82
79
|
return creds?.localWorkerToken ?? token;
|
|
83
80
|
}
|
|
84
81
|
async function getCredentialsToken(contextName) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
else if (!creds.localWorkerToken &&
|
|
90
|
-
(await isLoopbackContext(contextName))) {
|
|
91
|
-
// Heal credentials saved by older CLIs that stored only the local-init
|
|
92
|
-
// worker PAT as accessToken. Re-mint so admin REST/MCP get the session
|
|
93
|
-
// token while chat keeps the companion worker PAT.
|
|
94
|
-
creds = (await tryLocalInit(contextName)) ?? creds;
|
|
95
|
-
}
|
|
82
|
+
// Mint only when the context has no credential at all. A stored credential
|
|
83
|
+
// (an OAuth login, a `lobu login --token` PAT, or an earlier local-init) is
|
|
84
|
+
// the user's choice for this context; a token lookup must never replace it.
|
|
85
|
+
const creds = (await loadCredentials(contextName)) ?? (await tryLocalInit(contextName));
|
|
96
86
|
if (!creds)
|
|
97
87
|
return null;
|
|
98
88
|
if (!credentialNeedsRefresh(creds))
|
|
@@ -160,32 +150,16 @@ async function tryLocalInit(contextName) {
|
|
|
160
150
|
if (orgSlug) {
|
|
161
151
|
await setActiveOrg(orgSlug, target.name).catch(() => undefined);
|
|
162
152
|
}
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
// local context exists is invisible. Announce on stderr so the change is
|
|
168
|
-
// visible but doesn't pollute stdout pipelines.
|
|
169
|
-
try {
|
|
170
|
-
const current = await getCurrentContextName();
|
|
171
|
-
if (current !== target.name) {
|
|
172
|
-
await setCurrentContext(target.name);
|
|
173
|
-
process.stderr.write(`Switched active context to "${target.name}" (lobu run)\n`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
catch {
|
|
177
|
-
// Best-effort — a write failure here shouldn't break the auth flow.
|
|
178
|
-
}
|
|
153
|
+
// Never switch the global current context here: this runs inside token
|
|
154
|
+
// lookups such as `lobu whoami -c local`, and a lookup must not retarget
|
|
155
|
+
// every later `lobu` command. An interactive `lobu run` makes that switch
|
|
156
|
+
// itself (`announceLocalSignIn` in commands/dev.ts).
|
|
179
157
|
return creds;
|
|
180
158
|
}
|
|
181
159
|
catch {
|
|
182
160
|
return null;
|
|
183
161
|
}
|
|
184
162
|
}
|
|
185
|
-
async function isLoopbackContext(contextName) {
|
|
186
|
-
const target = await resolveContext(contextName);
|
|
187
|
-
return isLoopbackUrl(target.url);
|
|
188
|
-
}
|
|
189
163
|
function isLoopbackUrl(url) {
|
|
190
164
|
try {
|
|
191
165
|
const { hostname } = new URL(url);
|
|
@@ -11,4 +11,6 @@ export declare function loadDeviceState(context: string, platform: string): Prom
|
|
|
11
11
|
export declare function updateDeviceState(context: string, platform: string, state: DeviceState): Promise<void>;
|
|
12
12
|
/** Persist one completed setup without allowing two first boots to race. */
|
|
13
13
|
export declare function saveDeviceState(context: string, platform: string, state: DeviceState): Promise<void>;
|
|
14
|
+
/** Forget one saved identity after its device has been removed. */
|
|
15
|
+
export declare function deleteDeviceState(context: string, platform: string): Promise<void>;
|
|
14
16
|
//# sourceMappingURL=device-state.d.ts.map
|
|
@@ -95,4 +95,8 @@ function isErrno(error, code) {
|
|
|
95
95
|
"code" in error &&
|
|
96
96
|
error.code === code);
|
|
97
97
|
}
|
|
98
|
+
/** Forget one saved identity after its device has been removed. */
|
|
99
|
+
export async function deleteDeviceState(context, platform) {
|
|
100
|
+
await rm(statePath(context, platform), { force: true });
|
|
101
|
+
}
|
|
98
102
|
//# sourceMappingURL=device-state.js.map
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
export declare const GATEWAY_DEFAULT_URL = "http://localhost:8787";
|
|
2
|
-
/**
|
|
3
|
-
* The embedded Lobu server mounts its public Agent API (`/api/v1/agents/*`,
|
|
4
|
-
* `/api/docs`) under this path prefix — see `buildWrapperApp` in
|
|
5
|
-
* `packages/server/src/server-lifecycle.ts`. Every deployment (local `lobu run`,
|
|
6
|
-
* app.lobu.ai, community.lobu.ai) follows this layout: the org-scoped admin
|
|
7
|
-
* REST API and OAuth live at the origin, the Agent API lives at `<origin>/lobu`.
|
|
8
|
-
*/
|
|
9
|
-
export declare const GATEWAY_AGENT_API_PREFIX = "/lobu";
|
|
10
2
|
/**
|
|
11
3
|
* Normalize a gateway URL (from `--gateway`, a context's apiUrl, or `.env`) to
|
|
12
4
|
* the base the Agent API is served from: `<origin>/lobu`. Idempotent — passing
|
|
@@ -9,7 +9,7 @@ export const GATEWAY_DEFAULT_URL = "http://localhost:8787";
|
|
|
9
9
|
* app.lobu.ai, community.lobu.ai) follows this layout: the org-scoped admin
|
|
10
10
|
* REST API and OAuth live at the origin, the Agent API lives at `<origin>/lobu`.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const GATEWAY_AGENT_API_PREFIX = "/lobu";
|
|
13
13
|
/**
|
|
14
14
|
* Normalize a gateway URL (from `--gateway`, a context's apiUrl, or `.env`) to
|
|
15
15
|
* the base the Agent API is served from: `<origin>/lobu`. Idempotent — passing
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"server": "dist/server.bundle.mjs",
|
|
6
6
|
"embeddingsServer": "dist/embeddings-server.mjs"
|
|
7
7
|
},
|
|
8
|
-
"version": "24.
|
|
8
|
+
"version": "24.3.0",
|
|
9
9
|
"verify": "dist/verify.mjs"
|
|
10
10
|
},
|
|
11
11
|
"device": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"connector": "node_modules/@lobu/cli/dist/commands/connector.js",
|
|
17
17
|
"worker": "node_modules/@lobu/connector-worker/dist/bin.js"
|
|
18
18
|
},
|
|
19
|
-
"version": "24.
|
|
19
|
+
"version": "24.3.0",
|
|
20
20
|
"verify": "dist/verify.mjs"
|
|
21
21
|
},
|
|
22
22
|
"postgres": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"entries": {
|
|
25
25
|
"postgres": "dist/index.mjs"
|
|
26
26
|
},
|
|
27
|
-
"version": "24.
|
|
27
|
+
"version": "24.3.0",
|
|
28
28
|
"verify": "dist/verify.mjs"
|
|
29
29
|
},
|
|
30
30
|
"embeddings": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"entries": {
|
|
33
33
|
"embeddings": "dist/embeddings.js"
|
|
34
34
|
},
|
|
35
|
-
"version": "24.
|
|
35
|
+
"version": "24.3.0",
|
|
36
36
|
"verify": "dist/verify.mjs"
|
|
37
37
|
}
|
|
38
38
|
}
|