@lobu/runtime-device 24.2.0 → 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 +38 -124
- package/npm-shrinkwrap.json +169 -653
- package/package.json +1 -1
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +6 -0
- package/vendor/cli/dist/commands/chat.d.ts +0 -12
- package/vendor/cli/dist/commands/chat.js +1 -1
- package/vendor/cli/dist/commands/daemon.js +36 -19
- 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/seed-cmd.d.ts +0 -8
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +1 -1
- package/vendor/cli/dist/config/define.d.ts +1 -1
- package/vendor/cli/dist/connectors/gchat.ts +31 -1
- package/vendor/cli/dist/connectors/postgres.ts +9 -5
- 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/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/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +29 -0
- 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/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/automation.js +1 -1
- package/vendor/connector-worker/dist/daemon/client.d.ts +15 -1
- package/vendor/connector-worker/dist/daemon/client.js +51 -4
- 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/poll-loop.js +6 -1
- 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 +1 -0
- package/vendor/connector-worker/dist/daemon/terminal-delivery.js +10 -6
- package/vendor/connector-worker/dist/executor/isolate.js +1 -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/connector-query-errors.d.ts +6 -0
- package/vendor/core/dist/connector-query-errors.js +4 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +4 -0
- package/vendor/core/dist/contracts/tools/manage-entity.js +6 -0
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +1 -1
- package/vendor/core/dist/contracts/worker/device-automation.js +1 -1
- 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/utils/ajv.js +3 -1
- package/vendor/core/package.json +26 -5
- 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/package.json
CHANGED
|
@@ -236,6 +236,8 @@ Search before create to avoid duplicates. Prefer a read or dry run before mutati
|
|
|
236
236
|
|
|
237
237
|
## Custom Views
|
|
238
238
|
|
|
239
|
+
When a user would benefit from exploring data, offer or build an interactive view: linked charts, searchable tables, filters, drilldowns, scenario controls, or a Canvas/SVG visualization. Prefer an existing view when it already answers the question. Views are ordinary React, so authors can compose their own components; the default components are a starting point.
|
|
240
|
+
|
|
239
241
|
Views are custom React panels attached to entity types, records, events, or the workspace Data hub. They render in the web app and MCP hosts (Claude and other MCP Apps hosts); chat channels get links to views, not the views themselves. Author them in `views/<type>/<key>.tsx` and ship with `lobu apply` (list them via `viewFromFile` in `defineConfig`), or set single-file sources over MCP with `manage_views` (owner/admin only).
|
|
240
242
|
|
|
241
243
|
Module shape (the server resolves React, React DOM, `@lobu/views` and `@lobu/views/components`; other dependencies need the CLI path with `node_modules` present):
|
|
@@ -294,6 +296,10 @@ export default function Pipeline() {
|
|
|
294
296
|
|
|
295
297
|
`attach` lists the pages a view appears on, one per entry: `{ record: "deal" }` is a card on every deal's page above its activity (`{ record: "deal", id: 7 }` pins one record), `{ collection: "deal", when? }` a tab on the deal list page, `{ workspace: true }` a Data hub tab, `{ event: "deal.won", type? }` one event's page. One view can list several pages and branch on `useScope()` when it answers the same question at each scale. A record card renders with `useHost().displayMode === "inline"` inside `container.maxHeight` (the host clips past it): render a summary there with a "See all" that calls `requestDisplayMode("fullscreen")`, and the full view when `displayMode` is `"fullscreen"` (the peek, a full page, a tab).
|
|
296
298
|
|
|
299
|
+
Workspace attachment does not render individual events. For an event presentation, attach to its specific `semantic_type` (event kind), optionally restricted to a linked entity type with `type`; a metadata schema name does not select the view. Avoid binding a specialized renderer to a generic kind such as `summary`. Register a dedicated kind in the workspace's event-kind registry and have its producer emit it. On event pages and event peeks, read `useScope().event` by exact ID and select that ID from the returned lineage; never substitute the latest event or let a URL date param change the subject. A shared workspace/event module should branch on `scope.event`, keeping history selection on its workspace surface. Preserve a readable stored body for fallback and evidence.
|
|
300
|
+
|
|
301
|
+
Before reporting a view working, open each attached surface, including an event page and peek when declared. Exercise filtering, drilldown, keyboard navigation, and a narrow pane; check loading, missing/error, and truncated data states. Refresh and reopen an earlier event of the kind to verify the view stays on that event rather than jumping to the newest one. Views render in an iframe, so an empty parent-page DOM is not evidence the view is empty; inspect the frame through an authorized browser or accessibility surface. A successful compile proves only that the bundle was built.
|
|
302
|
+
|
|
297
303
|
Rules that are load-bearing, not style:
|
|
298
304
|
|
|
299
305
|
- Reads go through `useQuery` (`sql`, a `query_sdk` script string, or a read-only `tool()`). `query_sql` allows 500 rows max with a 5 second timeout — branch on the typed `errorCode` (e.g. `UPSTREAM_TIMEOUT`), never on message text, and render `truncated` honestly instead of passing partial data off as complete. Each `query_sql` cell is bounded too: strings keep their first 4,000 Unicode code points plus "… [truncated]"; JSON values over 16 KiB become `{ _truncated: true, bytes }` (attachments become null with `attachments_truncated`). `truncatedColumns` names the affected columns. Select smaller elements or fields, for example one array element per row with `jsonb_array_elements(...)`, and paginate as needed; each returned cell is still subject to these limits.
|
|
@@ -10,18 +10,6 @@ interface ChatOptions {
|
|
|
10
10
|
org?: string;
|
|
11
11
|
json?: boolean;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Resolve which org the chat invocation targets. Precedence mirrors the other
|
|
15
|
-
* org-scoped commands (`lobu memory run`, `lobu call`): explicit `--org` >
|
|
16
|
-
* `LOBU_ORG` env > the context's stored `activeOrg`. `getActiveOrg` already
|
|
17
|
-
* folds in the env var and context lookup, so an explicit flag is the only
|
|
18
|
-
* thing layered on top.
|
|
19
|
-
*
|
|
20
|
-
* Returns `undefined` when nothing is configured — the server then falls back
|
|
21
|
-
* to the PAT-bound org / the user's default membership, preserving the
|
|
22
|
-
* pre-flag semantics for callers that never pass `--org`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function resolveChatOrg(options: Pick<ChatOptions, "org" | "context">): Promise<string | undefined>;
|
|
25
13
|
/**
|
|
26
14
|
* `lobu chat <prompt>` — send a prompt to an agent and stream the response.
|
|
27
15
|
*
|
|
@@ -53,7 +53,7 @@ async function setLastThread(context, agent, threadId) {
|
|
|
53
53
|
* to the PAT-bound org / the user's default membership, preserving the
|
|
54
54
|
* pre-flag semantics for callers that never pass `--org`.
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
async function resolveChatOrg(options) {
|
|
57
57
|
if (options.org?.trim())
|
|
58
58
|
return options.org.trim();
|
|
59
59
|
return getActiveOrg(options.context);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { resolveDaemonLaunchContext, resolveDaemonWorkerId, startDaemonCommand, } from "@lobu/connector-worker/daemon";
|
|
1
|
+
import { resolveDaemonLaunchContext, resolveDaemonWorkerId, startDaemonCommand, WorkerUpgradeRequiredError, } from "@lobu/connector-worker/daemon";
|
|
2
2
|
import { hostname } from "node:os";
|
|
3
|
+
import { CLI_DAEMON_UPGRADE_STEPS, startCliUpdateNotifier, } from "../internal/cli-update-check.js";
|
|
3
4
|
import { addContext, apiUrlToGatewayOrigin, findContextByOrigin, getActiveOrg, loadContextConfig, resolveContext, } from "../internal/context.js";
|
|
4
5
|
import { loadDeviceState } from "../internal/device-state.js";
|
|
5
6
|
import { canPrompt, DeviceMintError, mintDeviceCredentialWithReauth, persistDeviceCredential, requireInstallationLogin, } from "./_lib/device-credential.js";
|
|
@@ -148,25 +149,41 @@ export async function daemonCommand(options) {
|
|
|
148
149
|
})
|
|
149
150
|
: undefined;
|
|
150
151
|
const activeOrg = await getActiveOrg(contextName);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
version: options.cliVersion,
|
|
154
|
-
platform: sessionLane ? "headless" : requestedPlatform,
|
|
155
|
-
defaultPlatform,
|
|
156
|
-
workerId,
|
|
157
|
-
label: options.label?.trim() || undefined,
|
|
158
|
-
capabilities: (options.capabilities ?? "os.shell")
|
|
159
|
-
.split(",")
|
|
160
|
-
.map((entry) => entry.trim())
|
|
161
|
-
.filter(Boolean),
|
|
162
|
-
workerApiToken,
|
|
163
|
-
activeOrg,
|
|
164
|
-
...(workerCredentialMaintenance ? { workerCredentialMaintenance } : {}),
|
|
165
|
-
debug: options.debug === true,
|
|
166
|
-
...(options.interactiveSession === false
|
|
167
|
-
? { interactiveSession: false }
|
|
168
|
-
: {}),
|
|
152
|
+
const stopUpdateCheck = startCliUpdateNotifier({
|
|
153
|
+
currentVersion: options.cliVersion,
|
|
169
154
|
});
|
|
155
|
+
try {
|
|
156
|
+
await startDaemonCommand({
|
|
157
|
+
apiUrl: target.gatewayOrigin,
|
|
158
|
+
version: options.cliVersion,
|
|
159
|
+
platform: sessionLane ? "headless" : requestedPlatform,
|
|
160
|
+
defaultPlatform,
|
|
161
|
+
workerId,
|
|
162
|
+
label: options.label?.trim() || undefined,
|
|
163
|
+
capabilities: (options.capabilities ?? "os.shell")
|
|
164
|
+
.split(",")
|
|
165
|
+
.map((entry) => entry.trim())
|
|
166
|
+
.filter(Boolean),
|
|
167
|
+
workerApiToken,
|
|
168
|
+
activeOrg,
|
|
169
|
+
...(workerCredentialMaintenance ? { workerCredentialMaintenance } : {}),
|
|
170
|
+
debug: options.debug === true,
|
|
171
|
+
...(options.interactiveSession === false
|
|
172
|
+
? { interactiveSession: false }
|
|
173
|
+
: {}),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
// The server refused this version outright; retrying the same binary can
|
|
178
|
+
// only be refused again, so exit with the way out instead of a raw 409.
|
|
179
|
+
if (error instanceof WorkerUpgradeRequiredError) {
|
|
180
|
+
throw new Error(`${error.description}. This daemon runs @lobu/cli ${options.cliVersion ?? "(unknown version)"}; to update, ${CLI_DAEMON_UPGRADE_STEPS}.`);
|
|
181
|
+
}
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
stopUpdateCheck();
|
|
186
|
+
}
|
|
170
187
|
}
|
|
171
188
|
async function resolveDaemonTarget(explicitApiUrl) {
|
|
172
189
|
const explicit = explicitApiUrl?.trim();
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
interface Check {
|
|
2
|
-
name: string;
|
|
3
|
-
status: "ok" | "warn" | "fail";
|
|
4
|
-
detail: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function checkInstalledNativeModule(name: string, resolveModule?: (id: string) => string, loadModule?: (id: string) => unknown): Check | null;
|
|
7
1
|
interface DoctorOptions {
|
|
8
2
|
memoryOnly?: boolean;
|
|
9
3
|
cwd?: string;
|
|
@@ -28,7 +28,7 @@ function checkBinaryExists(name) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
const moduleRequire = createRequire(import.meta.url);
|
|
31
|
-
|
|
31
|
+
function checkInstalledNativeModule(name, resolveModule = moduleRequire.resolve, loadModule = moduleRequire) {
|
|
32
32
|
try {
|
|
33
33
|
resolveModule(`${name}/package.json`);
|
|
34
34
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
interface SeedContext {
|
|
2
|
-
apiBaseUrl: string;
|
|
3
|
-
orgSlug: string;
|
|
4
|
-
token: string;
|
|
5
|
-
dryRun: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function callTool(ctx: SeedContext, toolName: string, args: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
8
1
|
export interface SeedOptions {
|
|
9
2
|
path?: string;
|
|
10
3
|
dryRun?: boolean;
|
|
@@ -13,5 +6,4 @@ export interface SeedOptions {
|
|
|
13
6
|
context?: string;
|
|
14
7
|
}
|
|
15
8
|
export declare function seedMemoryWorkspace(opts?: SeedOptions): Promise<void>;
|
|
16
|
-
export {};
|
|
17
9
|
//# sourceMappingURL=seed-cmd.d.ts.map
|
|
@@ -76,7 +76,7 @@ function loadDataRecords(dataPath) {
|
|
|
76
76
|
recordType: data.type,
|
|
77
77
|
}));
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
async function callTool(ctx, toolName, args) {
|
|
80
80
|
const url = `${ctx.apiBaseUrl}/api/${ctx.orgSlug}/${toolName}`;
|
|
81
81
|
const res = await fetch(url, {
|
|
82
82
|
method: "POST",
|
|
@@ -53,7 +53,7 @@ export interface EntityEventKind {
|
|
|
53
53
|
* Optional authored render template (render-DSL root node). When omitted,
|
|
54
54
|
* events of this kind render a default field card built from `metadataSchema`.
|
|
55
55
|
* It renders the event card only; build an interactive dashboard as a
|
|
56
|
-
* React view (`defineView`) attached with `{
|
|
56
|
+
* React view (`defineView`) attached with `{ event: "<kind>" }`.
|
|
57
57
|
*/
|
|
58
58
|
jsonTemplate?: Record<string, unknown>;
|
|
59
59
|
/**
|
|
@@ -11,8 +11,38 @@ export default class GoogleChatConnector extends IntegrationConnector {
|
|
|
11
11
|
automationEvents: CHAT_AUTOMATION_EVENTS,
|
|
12
12
|
name: "Google Chat",
|
|
13
13
|
description: "Connect a Google Chat app to Lobu.",
|
|
14
|
-
version: "1.0.
|
|
14
|
+
version: "1.0.3",
|
|
15
15
|
faviconDomain: "chat.google.com",
|
|
16
|
+
webhook: {
|
|
17
|
+
// The hosted Lobu Google Chat app posts every space's events to the
|
|
18
|
+
// shared `/api/v1/app-webhooks/gchat` endpoint. Google signs each
|
|
19
|
+
// delivery with a bearer JWT, not an HMAC: either self-signed by the
|
|
20
|
+
// Chat service account for the project number, or a Google ID token
|
|
21
|
+
// for the endpoint URL (Workspace Add-on apps sign as the project's
|
|
22
|
+
// add-on identity). The generic engine verifies it from this
|
|
23
|
+
// declaration; unset GOOGLE_CHAT_PROJECT_NUMBER = no hosted app (404).
|
|
24
|
+
delivery: "app_installation",
|
|
25
|
+
// Verified deliveries go to the Google Chat platform's chat delivery
|
|
26
|
+
// (claimed space → its installation; otherwise the claim link).
|
|
27
|
+
deliveryKind: "chat",
|
|
28
|
+
verification: {
|
|
29
|
+
type: "google-jwt",
|
|
30
|
+
appIdKey: "GOOGLE_CHAT_PROJECT_NUMBER",
|
|
31
|
+
audiences: ["app_id", "endpoint_url"],
|
|
32
|
+
signers: [
|
|
33
|
+
"chat@system.gserviceaccount.com",
|
|
34
|
+
"service-{appId}@gcp-sa-gsuiteaddons.iam.gserviceaccount.com",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
// The space sits in different places across Chat event envelopes.
|
|
38
|
+
routingKeyPaths: [
|
|
39
|
+
"space.name",
|
|
40
|
+
"chat.messagePayload.space.name",
|
|
41
|
+
"chat.addedToSpacePayload.space.name",
|
|
42
|
+
"chat.removedFromSpacePayload.space.name",
|
|
43
|
+
"chat.appCommandPayload.space.name",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
16
46
|
authSchema: { methods: [{ type: "none", label: "Service account" }] },
|
|
17
47
|
optionsSchema: {
|
|
18
48
|
type: "object",
|
|
@@ -227,6 +227,10 @@ function hasTopLevelLimitOrOffset(sql: string): boolean {
|
|
|
227
227
|
return false;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
function queryValidationError(message: string) {
|
|
231
|
+
return Object.assign(new Error(message), { status: 400 });
|
|
232
|
+
}
|
|
233
|
+
|
|
230
234
|
/**
|
|
231
235
|
* Shared read-only gate for both the memory feed (sync) and live query(). It is
|
|
232
236
|
* a structural check, NOT a SQL parser: the HARD write seal is the read-only
|
|
@@ -248,20 +252,20 @@ function hasTopLevelLimitOrOffset(sql: string): boolean {
|
|
|
248
252
|
*/
|
|
249
253
|
function validateReadOnlySelect(raw: string): string {
|
|
250
254
|
const stripped = raw.trim().replace(/;\s*$/, '');
|
|
251
|
-
if (!stripped) throw
|
|
255
|
+
if (!stripped) throw queryValidationError('query is empty');
|
|
252
256
|
if (stripped.includes(';')) {
|
|
253
|
-
throw
|
|
257
|
+
throw queryValidationError('query must be a single statement (no embedded ";").');
|
|
254
258
|
}
|
|
255
259
|
if (/\$\d/.test(stripped) || /(^|[^:]):[A-Za-z_]/.test(stripped)) {
|
|
256
|
-
throw
|
|
260
|
+
throw queryValidationError('query must not contain bind parameters ($1, :name).');
|
|
257
261
|
}
|
|
258
262
|
// Allow a leading "(" for "(SELECT …) UNION …" / parenthesized selects.
|
|
259
263
|
const head = stripped.replace(/^\s*\(+\s*/, '');
|
|
260
264
|
if (!/^(select|with)\b/i.test(head)) {
|
|
261
|
-
throw
|
|
265
|
+
throw queryValidationError('query must be a single read-only SELECT (or WITH … SELECT).');
|
|
262
266
|
}
|
|
263
267
|
if (hasTopLevelLimitOrOffset(stripped)) {
|
|
264
|
-
throw
|
|
268
|
+
throw queryValidationError(
|
|
265
269
|
'query must not include a top-level LIMIT/OFFSET — the connector adds pagination automatically (an inner LIMIT inside a subquery is fine).',
|
|
266
270
|
);
|
|
267
271
|
}
|
|
@@ -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);
|
|
@@ -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
|
}
|
package/vendor/cli/package.json
CHANGED
|
@@ -182,6 +182,30 @@ export interface ConnectorRuntimeInfo {
|
|
|
182
182
|
packages: string[];
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* `app_installation` deliveries authenticated by a Google-signed bearer JWT
|
|
187
|
+
* (Google Chat) instead of an HMAC. `{appId}` in {@link signers} is replaced
|
|
188
|
+
* by the value of {@link appIdKey}.
|
|
189
|
+
*/
|
|
190
|
+
export interface ConnectorWebhookGoogleJwtVerification {
|
|
191
|
+
type: 'google-jwt';
|
|
192
|
+
/**
|
|
193
|
+
* Env var holding the receiving app's id (the Google Cloud project number).
|
|
194
|
+
* It is the installs' `provider_app_id`; when unset the provider is not
|
|
195
|
+
* registered and its app-webhook endpoint answers 404.
|
|
196
|
+
*/
|
|
197
|
+
appIdKey: string;
|
|
198
|
+
/**
|
|
199
|
+
* Token audiences to accept, either of which verifies:
|
|
200
|
+
* - `'app_id'` — a JWT self-signed by one of {@link signers} with `aud` = the
|
|
201
|
+
* app id, checked against that service account's published keys.
|
|
202
|
+
* - `'endpoint_url'` — a Google OIDC ID token with `aud` = this provider's
|
|
203
|
+
* public app-webhook URL and a verified `email` in {@link signers}.
|
|
204
|
+
*/
|
|
205
|
+
audiences: Array<'app_id' | 'endpoint_url'>;
|
|
206
|
+
/** Google service-account emails allowed to sign a delivery. */
|
|
207
|
+
signers: string[];
|
|
208
|
+
}
|
|
185
209
|
/**
|
|
186
210
|
* Declarative scheme the gateway uses to verify an inbound provider webhook in
|
|
187
211
|
* the request hot path — no connector code runs before the 202 ack. The shared
|
|
@@ -189,6 +213,11 @@ export interface ConnectorRuntimeInfo {
|
|
|
189
213
|
* at connect time and stored on the connection.
|
|
190
214
|
*/
|
|
191
215
|
export interface ConnectorWebhookSchema {
|
|
216
|
+
/**
|
|
217
|
+
* Non-HMAC verification for `app_installation` deliveries. When set, the HMAC
|
|
218
|
+
* fields below are not used and no webhook secret is resolved.
|
|
219
|
+
*/
|
|
220
|
+
verification?: ConnectorWebhookGoogleJwtVerification;
|
|
192
221
|
/**
|
|
193
222
|
* Request header carrying the provider's HMAC signature over the raw body,
|
|
194
223
|
* e.g. `x-hub-signature-256` (GitHub), `linear-signature`. Omit for providers
|
|
@@ -15,7 +15,7 @@ import { validateEntityMetrics } from './metrics.js';
|
|
|
15
15
|
export { validateEntityMetrics };
|
|
16
16
|
export type { Dimension, EntityMetrics, EventSet, FactMatchRule, Measure, MetricReadMode, MetricTier, Segment, } from './metrics.js';
|
|
17
17
|
export type { ConnectorActionSpec, ConnectorClass, ConnectorFeedSpec, ConnectorSpec, } from './define-connector.js';
|
|
18
|
-
export type { ActionContext, ActionDefinition, ActionResult, ApprovalStatus, AuthArtifact, AuthContext, AuthResult, Connection, ConnectorAgentTooling, ConnectorAgentToolingEnv, ConnectorAuthAppInstallation, ConnectorAuthBrowser, ConnectorAuthEnvField, ConnectorAuthEnvKeys, ConnectorAuthInteractive, ConnectorAuthMethod, ConnectorAuthNone, ConnectorAuthOAuth, ConnectorAuthSchema, ConnectorDefinition, ConnectorInstallationContext, ConnectorOperations, ConnectorRuntimeInfo, ConnectorWebhookSchema, ContentItem, EntityIdentitySpec, EntityLinkPredicate, EntityTraitSpec, EventAttributionRole, EventAttributionRule, EventAttributionTargetSpec, EventEnvelope, Feed, FeedDefinition, FeedOperation, FeedObserveContext, FeedReadContext, FeedReadHandler, FeedReadResult, FeedReadMatch, FeedReadWindow, FeedReadWindowCoverage, FeedSyncHandler, FeedWebhookDeclaration, EntityTypeContribution, QueryContext, QueryResult, ReflectContext, ReflectedMeasure, ReflectResult, Run, RunStatus, RunType, RuntimeConnectorDefinition, RuntimeFeedDefinition, RuntimeFeedWebhook, SyncContext, SyncCredentials, SyncResult, WebhookRecordContext, WebhookRecordNormalizer, WebhookRegistration, WebhookRegistrationContext, } from './connector-types.js';
|
|
18
|
+
export type { ActionContext, ActionDefinition, ActionResult, ApprovalStatus, AuthArtifact, AuthContext, AuthResult, Connection, ConnectorAgentTooling, ConnectorAgentToolingEnv, ConnectorAuthAppInstallation, ConnectorAuthBrowser, ConnectorAuthEnvField, ConnectorAuthEnvKeys, ConnectorAuthInteractive, ConnectorAuthMethod, ConnectorAuthNone, ConnectorAuthOAuth, ConnectorAuthSchema, ConnectorDefinition, ConnectorInstallationContext, ConnectorOperations, ConnectorRuntimeInfo, ConnectorWebhookGoogleJwtVerification, ConnectorWebhookSchema, ContentItem, EntityIdentitySpec, EntityLinkPredicate, EntityTraitSpec, EventAttributionRole, EventAttributionRule, EventAttributionTargetSpec, EventEnvelope, Feed, FeedDefinition, FeedOperation, FeedObserveContext, FeedReadContext, FeedReadHandler, FeedReadResult, FeedReadMatch, FeedReadWindow, FeedReadWindowCoverage, FeedSyncHandler, FeedWebhookDeclaration, EntityTypeContribution, QueryContext, QueryResult, ReflectContext, ReflectedMeasure, ReflectResult, Run, RunStatus, RunType, RuntimeConnectorDefinition, RuntimeFeedDefinition, RuntimeFeedWebhook, SyncContext, SyncCredentials, SyncResult, WebhookRecordContext, WebhookRecordNormalizer, WebhookRegistration, WebhookRegistrationContext, } from './connector-types.js';
|
|
19
19
|
import { normalizeAuthUserId, normalizeEmail, normalizeEmailDomain, normalizeIdentifier, normalizePhone } from './identity-normalize.js';
|
|
20
20
|
export { normalizeAuthUserId, normalizeEmail, normalizeEmailDomain, normalizeIdentifier, normalizePhone, };
|
|
21
21
|
export type { IdentityNamespace, IdentityNamespaceDefinition, IdentityNormalizerKind, IdentitySubjectKind, } from './identity-namespaces.js';
|
|
@@ -58,4 +58,6 @@ export type { FileDelta, FileSystemSource, Snapshot } from './file-source.js';
|
|
|
58
58
|
export { connect } from './net.js';
|
|
59
59
|
export type { ConnectFn, Socket, SocketAddress, SocketOptions, } from './net.js';
|
|
60
60
|
export { assertFeedReadWindow, validateFeedReadWindow } from './feed-read-window.js';
|
|
61
|
+
export { isSecretOutputKey, redactOutput } from './redact.js';
|
|
62
|
+
export { scrubDiagnosticValue } from '@lobu/core/diagnostic-scrubber';
|
|
61
63
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -46,4 +46,8 @@ export { extensionNetworkSync } from './extension-network.js';
|
|
|
46
46
|
// =============================================================================
|
|
47
47
|
export { connect } from './net.js';
|
|
48
48
|
export { assertFeedReadWindow, validateFeedReadWindow } from './feed-read-window.js';
|
|
49
|
+
// The worker's output redaction catalog, shared so a connector that returns
|
|
50
|
+
// third-party text (logs, messages) can scrub it with the same patterns.
|
|
51
|
+
export { isSecretOutputKey, redactOutput } from './redact.js';
|
|
52
|
+
export { scrubDiagnosticValue } from '@lobu/core/diagnostic-scrubber';
|
|
49
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redact secrets from connector output before it leaves the worker.
|
|
3
|
+
*
|
|
4
|
+
* Patterns are deliberately broad — false positives are preferred to leaking a
|
|
5
|
+
* real credential into the runs table. Add new patterns here when a connector
|
|
6
|
+
* surfaces a new sensitive shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSecretOutputKey(key: string): boolean;
|
|
9
|
+
export declare function redactOutput(text: string): string;
|
|
10
|
+
//# sourceMappingURL=redact.d.ts.map
|