@lobu/runtime-device 24.4.0 → 24.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.json +1 -1
- package/dist/dependencies.bun.lock +77 -64
- package/dist/verify.mjs +1 -1
- package/npm-shrinkwrap.json +176 -141
- package/package.json +3 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +65 -11
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +20 -13
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +48 -100
- package/vendor/cli/dist/commands/_lib/apply/client.js +76 -27
- package/vendor/cli/dist/commands/_lib/apply/deployment.js +1 -1
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +7 -11
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +9 -40
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +4 -4
- package/vendor/cli/dist/commands/_lib/apply/diff.js +37 -33
- package/vendor/cli/dist/commands/_lib/apply/map-config.d.ts +1 -1
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +79 -92
- package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +3 -6
- package/vendor/cli/dist/commands/_lib/apply/shared.js +8 -19
- package/vendor/cli/dist/commands/_lib/view-bundler.js +9 -1
- package/vendor/cli/dist/commands/dev.js +21 -7
- package/vendor/cli/dist/commands/doctor.js +1 -8
- package/vendor/cli/dist/commands/init.js +4 -5
- package/vendor/cli/dist/config/define.d.ts +27 -28
- package/vendor/cli/dist/config/define.js +4 -5
- package/vendor/cli/dist/connectors/linkedin-identity.ts +43 -0
- package/vendor/cli/dist/connectors/linkedin.ts +154 -3
- package/vendor/cli/dist/connectors/postgres.ts +77 -48
- package/vendor/cli/dist/connectors/x-like-follow.ts +329 -0
- package/vendor/cli/dist/connectors/x.ts +709 -80
- package/vendor/cli/dist/internal/api-client.d.ts +2 -0
- package/vendor/cli/dist/internal/api-client.js +6 -1
- package/vendor/cli/dist/internal/connector-compiler.js +3 -1
- package/vendor/cli/dist/internal/node-binary.d.ts +22 -0
- package/vendor/cli/dist/internal/node-binary.js +73 -0
- package/vendor/cli/dist/internal/node-version.d.ts +7 -12
- package/vendor/cli/dist/internal/node-version.js +16 -20
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +2 -2
- package/vendor/cli/package.json +3 -2
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
- package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/connector-worker/dist/compile/index.d.ts +4 -3
- package/vendor/connector-worker/dist/compile/index.js +6 -3
- package/vendor/connector-worker/dist/daemon/acp-adapters/claude.js +1 -1
- package/vendor/connector-worker/dist/daemon/agent-turn.js +21 -10
- package/vendor/connector-worker/dist/daemon/client.d.ts +25 -8
- package/vendor/connector-worker/dist/daemon/client.js +25 -3
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +7 -1
- package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +17 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.js +75 -6
- package/vendor/connector-worker/dist/daemon/resource-admission.d.ts +19 -0
- package/vendor/connector-worker/dist/daemon/resource-admission.js +59 -0
- package/vendor/connector-worker/dist/daemon/resources.d.ts +20 -0
- package/vendor/connector-worker/dist/daemon/resources.js +163 -0
- package/vendor/connector-worker/dist/daemon/start.js +29 -4
- package/vendor/connector-worker/dist/daemon/worker.d.ts +2 -0
- package/vendor/connector-worker/dist/daemon/worker.js +4 -0
- package/vendor/connector-worker/dist/executor/select.d.ts +1 -1
- package/vendor/connector-worker/dist/executor/select.js +1 -1
- package/vendor/connector-worker/dist/isolate/ivm-types.d.ts +1 -2
- package/vendor/connector-worker/dist/isolate/ivm-types.js +1 -2
- package/vendor/connector-worker/dist/isolate/load.d.ts +10 -12
- package/vendor/connector-worker/dist/isolate/load.js +23 -27
- package/vendor/connector-worker/dist/self-check/index.d.ts +2 -2
- package/vendor/connector-worker/dist/self-check/index.js +2 -2
- package/vendor/connector-worker/package.json +3 -4
- package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
- package/vendor/core/dist/contracts/agent-settings.js +10 -7
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
- package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
- package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
- package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
- package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
- package/vendor/core/dist/contracts/tools/view-host.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/view-host.js +28 -0
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -4
- package/vendor/core/dist/contracts/tools/view-runtime.js +19 -7
- package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
- package/vendor/core/dist/error-report.d.ts +73 -0
- package/vendor/core/dist/error-report.js +346 -0
- package/vendor/core/dist/index.d.ts +3 -1
- package/vendor/core/dist/index.js +4 -1
- package/vendor/core/dist/logger.js +7 -4
- package/vendor/core/dist/otel-fetch.d.ts +19 -0
- package/vendor/core/dist/otel-fetch.js +96 -0
- package/vendor/core/dist/otel.d.ts +9 -0
- package/vendor/core/dist/otel.js +28 -7
- package/vendor/core/dist/reserved.d.ts +1 -1
- package/vendor/core/dist/reserved.js +6 -4
- package/vendor/core/dist/tool-result.d.ts +8 -0
- package/vendor/core/dist/tool-result.js +61 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
- package/vendor/core/dist/worker/auth.js +4 -0
- package/vendor/core/package.json +16 -1
- package/vendor/views/dist/api.d.ts +290 -0
- package/vendor/views/dist/api.js +714 -0
- package/vendor/views/dist/bridge.d.ts +157 -0
- package/vendor/views/dist/bridge.js +372 -0
- package/vendor/views/dist/components.d.ts +172 -0
- package/vendor/views/dist/components.js +376 -0
- package/vendor/views/dist/index.d.ts +13 -0
- package/vendor/views/dist/index.js +3 -0
- package/vendor/views/dist/native.d.ts +327 -0
- package/vendor/views/dist/native.js +57 -0
- package/vendor/views/package.json +53 -0
- /package/vendor/cli/dist/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
- /package/vendor/ora/{.bun-tag-fde20e9a6df212fa → .bun-tag-77bb9b258a474a18} +0 -0
- /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getToolResultFailure, isPendingToolApproval, } from "@lobu/core";
|
|
1
2
|
import { ApiClient } from "../../../internal/api-client.js";
|
|
2
3
|
import { resolveApiClient } from "../../../internal/index.js";
|
|
3
4
|
import { ApiError } from "../../memory/_lib/errors.js";
|
|
@@ -105,6 +106,7 @@ function hoistEntityTypeSchema(row) {
|
|
|
105
106
|
export class ApplyClient {
|
|
106
107
|
orgSlug;
|
|
107
108
|
http;
|
|
109
|
+
agentRevisions = new Map();
|
|
108
110
|
constructor(cfg, fetchImpl = fetch) {
|
|
109
111
|
this.orgSlug = cfg.orgSlug;
|
|
110
112
|
this.http = new ApiClient(cfg.apiBaseUrl, cfg.token, fetchImpl, {
|
|
@@ -123,8 +125,13 @@ export class ApplyClient {
|
|
|
123
125
|
* same outcome the local pipeline did. `Content-Type: application/json` is
|
|
124
126
|
* sent on every request (no `Accept`) to mirror the previous wire shape.
|
|
125
127
|
*/
|
|
126
|
-
async request(method, path, body, okStatuses = [200, 201, 204]) {
|
|
127
|
-
const { status, body: raw } = await this.http.requestWithStatus(method, path, body, {
|
|
128
|
+
async request(method, path, body, okStatuses = [200, 201, 204], headers) {
|
|
129
|
+
const { status, body: raw, headers: responseHeaders, } = await this.http.requestWithStatus(method, path, body, {
|
|
130
|
+
okStatuses,
|
|
131
|
+
sendAccept: false,
|
|
132
|
+
alwaysJsonContentType: true,
|
|
133
|
+
headers,
|
|
134
|
+
});
|
|
128
135
|
let parsed;
|
|
129
136
|
if (raw === undefined) {
|
|
130
137
|
parsed = {};
|
|
@@ -135,10 +142,15 @@ export class ApplyClient {
|
|
|
135
142
|
else {
|
|
136
143
|
parsed = { value: raw };
|
|
137
144
|
}
|
|
138
|
-
if (
|
|
139
|
-
|
|
145
|
+
if (isPendingToolApproval(parsed)) {
|
|
146
|
+
const run = parsed.run_id != null ? ` (run ${parsed.run_id})` : "";
|
|
147
|
+
throw new ApiError(`Configuration change requires approval${run}. This apply is incomplete; approve the pending change before retrying.`, status, "approval_pending");
|
|
148
|
+
}
|
|
149
|
+
const failure = getToolResultFailure(`${method} ${path}`, parsed);
|
|
150
|
+
if (failure) {
|
|
151
|
+
throw new ApiError(`${method} ${path} returned error: ${failure.message}`, status);
|
|
140
152
|
}
|
|
141
|
-
return { status, body: parsed };
|
|
153
|
+
return { status, body: parsed, headers: responseHeaders };
|
|
142
154
|
}
|
|
143
155
|
// ── Organization ──────────────────────────────────────────────────────────
|
|
144
156
|
/**
|
|
@@ -186,12 +198,31 @@ export class ApplyClient {
|
|
|
186
198
|
`/api/${this.orgSlug}/agents`, agent, [200, 201]);
|
|
187
199
|
return body;
|
|
188
200
|
}
|
|
189
|
-
async patchAgentMetadata(agentId,
|
|
190
|
-
|
|
201
|
+
async patchAgentMetadata(agentId, updates) {
|
|
202
|
+
const revision = this.agentRevisions.get(agentId);
|
|
203
|
+
const { headers } = await this.request("PATCH", `/api/${this.orgSlug}/agents/${encodeURIComponent(agentId)}`, updates, undefined, revision ? { "If-Match": revision } : undefined);
|
|
204
|
+
const next = headers.get("etag");
|
|
205
|
+
if (next)
|
|
206
|
+
this.agentRevisions.set(agentId, next);
|
|
191
207
|
}
|
|
192
|
-
async getAgentSettings(agentId) {
|
|
208
|
+
async getAgentSettings(agentId, metadata) {
|
|
193
209
|
try {
|
|
194
|
-
|
|
210
|
+
// Apply needs metadata and settings from one revision. Bootstrap callers
|
|
211
|
+
// that only read settings retain the smaller /config response.
|
|
212
|
+
const path = `/api/${this.orgSlug}/agents/${encodeURIComponent(agentId)}`;
|
|
213
|
+
if (metadata) {
|
|
214
|
+
const { body, headers } = await this.request("GET", path);
|
|
215
|
+
const revision = headers.get("etag");
|
|
216
|
+
if (revision)
|
|
217
|
+
this.agentRevisions.set(agentId, revision);
|
|
218
|
+
metadata.name = body.name;
|
|
219
|
+
metadata.description = body.description;
|
|
220
|
+
return body.settings;
|
|
221
|
+
}
|
|
222
|
+
const { body, headers } = await this.request("GET", `${path}/config`);
|
|
223
|
+
const revision = headers.get("etag");
|
|
224
|
+
if (revision)
|
|
225
|
+
this.agentRevisions.set(agentId, revision);
|
|
195
226
|
return body;
|
|
196
227
|
}
|
|
197
228
|
catch (err) {
|
|
@@ -201,7 +232,8 @@ export class ApplyClient {
|
|
|
201
232
|
}
|
|
202
233
|
}
|
|
203
234
|
async patchAgentSettings(agentId, settings) {
|
|
204
|
-
|
|
235
|
+
const revision = this.agentRevisions.get(agentId);
|
|
236
|
+
await this.request("PATCH", `/api/${this.orgSlug}/agents/${encodeURIComponent(agentId)}/config`, settings, undefined, revision ? { "If-Match": revision } : undefined);
|
|
205
237
|
}
|
|
206
238
|
/**
|
|
207
239
|
* Record this apply run as a deployment (`POST /api/<org>/deployments`).
|
|
@@ -770,25 +802,42 @@ export class ApplyClient {
|
|
|
770
802
|
* connector by id or pass connector source; server returns the resolved
|
|
771
803
|
* connectorKey plus updated.
|
|
772
804
|
*/
|
|
773
|
-
async installConnector(payload) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
:
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
805
|
+
async installConnector(payload, target) {
|
|
806
|
+
if (target && payload.sourceCode === undefined) {
|
|
807
|
+
throw new ApiError("Updating an installed connector requires its prepared source code.");
|
|
808
|
+
}
|
|
809
|
+
const artifact = {
|
|
810
|
+
compiled: payload.compiled ?? false,
|
|
811
|
+
compiled_code: payload.compiledCode,
|
|
812
|
+
source_files: payload.sourceFiles,
|
|
813
|
+
dependencies: payload.dependencies,
|
|
814
|
+
};
|
|
815
|
+
const body = await this.connectionsTool(target
|
|
816
|
+
? {
|
|
817
|
+
action: "update_connector_source",
|
|
818
|
+
...target,
|
|
819
|
+
source_code: payload.sourceCode,
|
|
820
|
+
...artifact,
|
|
821
|
+
}
|
|
822
|
+
: {
|
|
823
|
+
action: "install_connector",
|
|
824
|
+
...(payload.connectorId
|
|
825
|
+
? { connector_id: payload.connectorId }
|
|
826
|
+
: {}),
|
|
827
|
+
...(payload.sourceCode !== undefined
|
|
828
|
+
? {
|
|
829
|
+
source_code: payload.sourceCode,
|
|
830
|
+
...artifact,
|
|
831
|
+
}
|
|
832
|
+
: {}),
|
|
833
|
+
...(payload.sourceUrl ? { source_url: payload.sourceUrl } : {}),
|
|
834
|
+
...(payload.sourceUri ? { source_uri: payload.sourceUri } : {}),
|
|
835
|
+
});
|
|
789
836
|
return {
|
|
790
837
|
connectorKey: body.connector_key ?? "",
|
|
791
|
-
updated:
|
|
838
|
+
updated: target
|
|
839
|
+
? body.version !== target.expected_version
|
|
840
|
+
: (body.updated ?? false),
|
|
792
841
|
...(body.version ? { version: body.version } : {}),
|
|
793
842
|
};
|
|
794
843
|
}
|
|
@@ -205,7 +205,7 @@ export function buildAttributionAndOwned(state, remote, orgId, prune = false) {
|
|
|
205
205
|
// The three-way baseline must record the effective execution_config after
|
|
206
206
|
// apply (including preserved remote keys), or a later model edit is
|
|
207
207
|
// misclassified as "remote moved" blocking drift instead of an update.
|
|
208
|
-
execution_config: automationExecutionConfig(d.model, r?.execution_config, d.
|
|
208
|
+
execution_config: automationExecutionConfig(d.model, r?.execution_config, d.executionConfig),
|
|
209
209
|
outputs: p.outputs,
|
|
210
210
|
};
|
|
211
211
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ConnectorDefinition, EntityMetrics } from "@lobu/connector-sdk";
|
|
2
2
|
import type { AgentSettings } from "@lobu/core";
|
|
3
|
-
import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger } from "@lobu/core/contracts/tools/manage-automations";
|
|
4
3
|
import type { CollectionPresentation } from "@lobu/core/contracts/tools/collection-presentation";
|
|
4
|
+
import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger, ManageAutomationsArgs } from "@lobu/core/contracts/tools/manage-automations";
|
|
5
5
|
import type { RetainedSource } from "@lobu/core/contracts/tools/source-files";
|
|
6
|
-
import type { InferenceCapabilityBlock, InferenceModality, Project } from "../../../config/index.js";
|
|
6
|
+
import type { Automation, InferenceCapabilityBlock, InferenceModality, Project } from "../../../config/index.js";
|
|
7
7
|
import { type AutomationSource, type EntityBacking, type RelationshipRule } from "./shared.js";
|
|
8
8
|
export interface DesiredAgentMetadata {
|
|
9
9
|
agentId: string;
|
|
@@ -71,13 +71,9 @@ export interface DesiredRelationshipType {
|
|
|
71
71
|
}
|
|
72
72
|
export interface DesiredAutomation {
|
|
73
73
|
slug: string;
|
|
74
|
-
|
|
75
|
-
agent
|
|
76
|
-
|
|
77
|
-
kind: "script";
|
|
78
|
-
source: string;
|
|
79
|
-
params?: Record<string, unknown>;
|
|
80
|
-
} | null;
|
|
74
|
+
executionConfig?: Automation["executionConfig"];
|
|
75
|
+
/** Managed agent identity, independent of device placement. */
|
|
76
|
+
agent: string | null;
|
|
81
77
|
name?: string;
|
|
82
78
|
description?: string;
|
|
83
79
|
triggers?: DesiredAutomationTrigger[];
|
|
@@ -127,8 +123,8 @@ export interface DesiredAutomation {
|
|
|
127
123
|
minCooldownSeconds?: number;
|
|
128
124
|
/** Free-form tags for filtering. */
|
|
129
125
|
tags?: string[];
|
|
130
|
-
/** Optional agent
|
|
131
|
-
agentKind?:
|
|
126
|
+
/** Optional agent runtime override. */
|
|
127
|
+
agentKind?: NonNullable<ManageAutomationsArgs["agent_kind"]>;
|
|
132
128
|
/** Named durable outputs; explicit null clears existing declarations. */
|
|
133
129
|
outputs?: Record<string, unknown> | null;
|
|
134
130
|
}
|
|
@@ -135,8 +135,7 @@ async function readMarkdown(agentDir) {
|
|
|
135
135
|
for (const [key, filename] of files) {
|
|
136
136
|
try {
|
|
137
137
|
const content = await readFile(join(agentDir, filename), "utf-8");
|
|
138
|
-
|
|
139
|
-
result[key] = content.trim();
|
|
138
|
+
result[key] = content.trim();
|
|
140
139
|
}
|
|
141
140
|
catch {
|
|
142
141
|
// missing file is fine
|
|
@@ -679,9 +678,11 @@ export async function loadDesiredStateFromConfig(opts) {
|
|
|
679
678
|
return;
|
|
680
679
|
const agentDir = resolve(opts.cwd, agent.dir ?? join("agents", agent.id));
|
|
681
680
|
const markdown = await readMarkdown(agentDir);
|
|
682
|
-
const localSkills =
|
|
681
|
+
const localSkills = agent.skills === undefined
|
|
682
|
+
? undefined
|
|
683
|
+
: await resolveAgentSkills(agent.skills, opts.cwd);
|
|
683
684
|
mergeAgentDirArtifacts(settings, markdown, localSkills);
|
|
684
|
-
skillsByAgentId.set(agent.id,
|
|
685
|
+
skillsByAgentId.set(agent.id, settings.skillsConfig?.skills ?? []);
|
|
685
686
|
}));
|
|
686
687
|
// Resolve each Automation's `skills[]` to {name, content} snapshots against the
|
|
687
688
|
// owning agent's library. This happens BEFORE the diff reads them, so a change
|
|
@@ -691,44 +692,13 @@ export async function loadDesiredStateFromConfig(opts) {
|
|
|
691
692
|
// The bodies are no longer folded into `prompt`: the prompt is the author's
|
|
692
693
|
// task statement (or empty), and skills ride alongside as pinned files.
|
|
693
694
|
for (const automation of state.automations) {
|
|
694
|
-
automation.skillSnapshots = resolveAutomationSkills(automation, skillsByAgentId.get(automation.agent) ?? []);
|
|
695
|
+
automation.skillSnapshots = resolveAutomationSkills(automation, automation.agent ? (skillsByAgentId.get(automation.agent) ?? []) : []);
|
|
695
696
|
}
|
|
696
|
-
// Automation
|
|
697
|
+
// Automation lifecycle modules: sibling `.ts` files referenced
|
|
697
698
|
// by path. The mapper stays pure; resolve + read each raw source here for the
|
|
698
699
|
// server to compile. state.automations[i] aligns with
|
|
699
700
|
// typedProject.automations[i] (the mapper maps them in order).
|
|
700
701
|
(typedProject.automations ?? []).forEach((automation, i) => {
|
|
701
|
-
if (automation.executor !== undefined && automation.executor !== "agent") {
|
|
702
|
-
const desired = state.automations[i];
|
|
703
|
-
if (!desired)
|
|
704
|
-
return;
|
|
705
|
-
if (!automation.executor ||
|
|
706
|
-
typeof automation.executor !== "object" ||
|
|
707
|
-
automation.executor.kind !== "scriptSource" ||
|
|
708
|
-
typeof automation.executor.path !== "string") {
|
|
709
|
-
throw new ValidationError(`Automation "${automation.slug}": use scriptFromFile("./job.ts") for a script executor.`);
|
|
710
|
-
}
|
|
711
|
-
if (automation.executor.params !== undefined &&
|
|
712
|
-
!isRecord(automation.executor.params)) {
|
|
713
|
-
throw new ValidationError(`Automation "${automation.slug}": scriptFromFile params must be an object, not an array.`);
|
|
714
|
-
}
|
|
715
|
-
const script = resolveLocalSourceFile({
|
|
716
|
-
cwd: opts.cwd,
|
|
717
|
-
owner: `Automation ${JSON.stringify(automation.slug)}`,
|
|
718
|
-
field: "executor",
|
|
719
|
-
example: 'scriptFromFile("./job.ts")',
|
|
720
|
-
rel: automation.executor.path,
|
|
721
|
-
maxBytes: 131072,
|
|
722
|
-
sizeHint: "Automation scripts must stay within the sandbox source limit",
|
|
723
|
-
});
|
|
724
|
-
desired.executor = {
|
|
725
|
-
kind: "script",
|
|
726
|
-
source: script.sourceCode,
|
|
727
|
-
...(automation.executor.params
|
|
728
|
-
? { params: automation.executor.params }
|
|
729
|
-
: {}),
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
702
|
// Gate on absence, not truthiness — a present-but-empty
|
|
733
703
|
// `reactionFromFile("")` must reach the validator (which rejects it),
|
|
734
704
|
// matching parseAutomation.
|
|
@@ -738,9 +708,8 @@ export async function loadDesiredStateFromConfig(opts) {
|
|
|
738
708
|
if (!dw)
|
|
739
709
|
return;
|
|
740
710
|
// Explicit `null` removes a previously installed reaction. Carried through
|
|
741
|
-
// the diff as declared and applied via set_reaction_script("")
|
|
742
|
-
//
|
|
743
|
-
// executor never runs both paths. Omitted (`undefined`) preserves.
|
|
711
|
+
// the diff as declared and applied via set_reaction_script("").
|
|
712
|
+
// Omitted (`undefined`) preserves.
|
|
744
713
|
if (automation.reaction === null) {
|
|
745
714
|
dw.reactionScript = null;
|
|
746
715
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AgentSettings } from "@lobu/core";
|
|
2
2
|
import type { InferenceModality } from "../../../config/define.js";
|
|
3
3
|
import type { RemoteAgent, RemoteAuthProfile, RemoteAutomation, RemoteConnection, RemoteConnectorDefinition, RemoteEntityType, RemoteFeed, RemoteInferenceProvider, RemoteRelationshipType, RemoteView, UpdateConnectionPayload, UpdateFeedPayload } from "./client.js";
|
|
4
|
-
import type { DesiredAgent, DesiredAuthProfile, DesiredAutomationTrigger, DesiredConnection, DesiredConnectorDefinition, DesiredEntityType, DesiredFeed, DesiredOrgProvider, DesiredRelationshipType, DesiredState,
|
|
4
|
+
import type { DesiredAgent, DesiredAuthProfile, DesiredAutomation, DesiredAutomationTrigger, DesiredConnection, DesiredConnectorDefinition, DesiredEntityType, DesiredFeed, DesiredOrgProvider, DesiredRelationshipType, DesiredState, DesiredView } from "./desired-state.js";
|
|
5
5
|
import { type AutomationSource } from "./shared.js";
|
|
6
6
|
type DiffVerb = "create" | "update" | "noop" | "drift" | "delete";
|
|
7
7
|
interface BaseRow {
|
|
@@ -226,7 +226,7 @@ interface FieldTable<D, R, P, F extends string> {
|
|
|
226
226
|
* BYO chat connections never reach `updateConnection` (apply routes them to the
|
|
227
227
|
* secret-aware chat-upsert), so the BYO branches below only govern diffing.
|
|
228
228
|
*/
|
|
229
|
-
declare const CONNECTION_FIELDS: FieldTable<DesiredConnection, RemoteConnection, UpdateConnectionPayload, "config" | "name" | "
|
|
229
|
+
declare const CONNECTION_FIELDS: FieldTable<DesiredConnection, RemoteConnection, UpdateConnectionPayload, "config" | "name" | "device_worker_id" | "auth" | "app_auth">;
|
|
230
230
|
/** Every updatable feed field. See {@link CONNECTION_FIELDS}. */
|
|
231
231
|
declare const FEED_FIELDS: FieldTable<DesiredFeed, RemoteFeed, UpdateFeedPayload, "config" | "name" | "schedule">;
|
|
232
232
|
export type ConnectionField = keyof typeof CONNECTION_FIELDS.fields;
|
|
@@ -239,7 +239,7 @@ export type FeedField = keyof typeof FEED_FIELDS.fields;
|
|
|
239
239
|
export declare function buildUpdatePayload<D, R, P, F extends string>(table: FieldTable<D, R, P, F>, changedFields: readonly F[] | undefined, desired: D): Partial<P>;
|
|
240
240
|
/** The connection and feed field tables, for apply to build payloads from. */
|
|
241
241
|
export declare const UPDATE_FIELD_TABLES: {
|
|
242
|
-
readonly connection: FieldTable<DesiredConnection, RemoteConnection, UpdateConnectionPayload, "config" | "name" | "
|
|
242
|
+
readonly connection: FieldTable<DesiredConnection, RemoteConnection, UpdateConnectionPayload, "config" | "name" | "device_worker_id" | "auth" | "app_auth">;
|
|
243
243
|
readonly feed: FieldTable<DesiredFeed, RemoteFeed, UpdateFeedPayload, "config" | "name" | "schedule">;
|
|
244
244
|
};
|
|
245
245
|
/**
|
|
@@ -282,7 +282,7 @@ export interface RelationshipTypeFacets {
|
|
|
282
282
|
*/
|
|
283
283
|
export declare const effectiveRelationshipTypeAfterApply: (d: DesiredRelationshipType, r: RemoteRelationshipType | undefined) => RelationshipTypeFacets;
|
|
284
284
|
interface AutomationProjection {
|
|
285
|
-
|
|
285
|
+
executionConfig?: RemoteAutomation["execution_config"];
|
|
286
286
|
agent?: string | null;
|
|
287
287
|
name?: string | null;
|
|
288
288
|
description?: string | null;
|
|
@@ -77,18 +77,19 @@ const CONNECTION_FIELDS = defineFieldTable()({
|
|
|
77
77
|
// payload (`apply_chat_connection` only persists slug/connector/name/config),
|
|
78
78
|
// and a BYO chat declaration can't even set them (map-config rejects them).
|
|
79
79
|
// Never diff them for BYO, or a remote row carrying a stray value would
|
|
80
|
-
// report a perpetual "update" that apply can't clear.
|
|
80
|
+
// report a perpetual "update" that apply can't clear. Undeclared is not a
|
|
81
|
+
// difference, same rule as `name` and `config`: an omitted pin is unmanaged.
|
|
81
82
|
auth: {
|
|
82
|
-
changed: (d, r) => d.credentialMode
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
payload: (d) => ({ authProfileSlug: d.authProfileSlug
|
|
83
|
+
changed: (d, r) => d.credentialMode !== "byo" &&
|
|
84
|
+
d.authProfileSlug !== undefined &&
|
|
85
|
+
d.authProfileSlug !== (r.auth_profile_slug ?? null),
|
|
86
|
+
payload: (d) => ({ authProfileSlug: d.authProfileSlug }),
|
|
86
87
|
},
|
|
87
88
|
app_auth: {
|
|
88
|
-
changed: (d, r) => d.credentialMode
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
payload: (d) => ({ appAuthProfileSlug: d.appAuthProfileSlug
|
|
89
|
+
changed: (d, r) => d.credentialMode !== "byo" &&
|
|
90
|
+
d.appAuthProfileSlug !== undefined &&
|
|
91
|
+
d.appAuthProfileSlug !== (r.app_auth_profile_slug ?? null),
|
|
92
|
+
payload: (d) => ({ appAuthProfileSlug: d.appAuthProfileSlug }),
|
|
92
93
|
},
|
|
93
94
|
config: {
|
|
94
95
|
// A BYO chat connection's config holds a resolved secret (plaintext) on the
|
|
@@ -109,11 +110,11 @@ const CONNECTION_FIELDS = defineFieldTable()({
|
|
|
109
110
|
payload: (d) => ({ config: d.config }),
|
|
110
111
|
},
|
|
111
112
|
device_worker_id: {
|
|
112
|
-
changed: (d, r) => d.credentialMode
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
payload: (d) => ({ deviceWorkerId: d.deviceWorkerId
|
|
113
|
+
changed: (d, r) => d.credentialMode !== "byo" &&
|
|
114
|
+
d.deviceWorkerId !== undefined &&
|
|
115
|
+
d.deviceWorkerId !== (r.device_worker_id ?? null),
|
|
116
|
+
// A declared uuid moves the connection to that device.
|
|
117
|
+
payload: (d) => ({ deviceWorkerId: d.deviceWorkerId }),
|
|
117
118
|
},
|
|
118
119
|
});
|
|
119
120
|
/** Every updatable feed field. See {@link CONNECTION_FIELDS}. */
|
|
@@ -858,9 +859,9 @@ function remoteOnlyDefinitionRow(kind, remote, baseline, prune, unchangedSinceBa
|
|
|
858
859
|
* use the same defaults as `diffAutomation`.
|
|
859
860
|
*/
|
|
860
861
|
export const projectDesiredAutomation = (d, remote) => ({
|
|
861
|
-
|
|
862
|
-
? d.
|
|
863
|
-
: (remote?.execution_config
|
|
862
|
+
executionConfig: d.executionConfig !== undefined
|
|
863
|
+
? d.executionConfig
|
|
864
|
+
: (remote?.execution_config ?? null),
|
|
864
865
|
agent: d.agent ?? null,
|
|
865
866
|
// Name/description are optional in config; the server defaults name to the
|
|
866
867
|
// slug. Inherit live remote when omitted so a second apply does not
|
|
@@ -879,11 +880,13 @@ export const projectDesiredAutomation = (d, remote) => ({
|
|
|
879
880
|
deviceWorkerId: d.deviceWorkerId !== undefined
|
|
880
881
|
? d.deviceWorkerId
|
|
881
882
|
: (remote?.device_worker_id ?? null),
|
|
882
|
-
model: d.
|
|
883
|
-
? d.model
|
|
884
|
-
:
|
|
885
|
-
?
|
|
886
|
-
:
|
|
883
|
+
model: d.executionConfig !== undefined
|
|
884
|
+
? (d.executionConfig?.model ?? null)
|
|
885
|
+
: d.model !== undefined
|
|
886
|
+
? d.model
|
|
887
|
+
: typeof remote?.execution_config?.model === "string"
|
|
888
|
+
? remote.execution_config.model
|
|
889
|
+
: null,
|
|
887
890
|
minCooldownSeconds: d.minCooldownSeconds !== undefined
|
|
888
891
|
? d.minCooldownSeconds
|
|
889
892
|
: (remote?.min_cooldown_seconds ?? null),
|
|
@@ -893,7 +896,7 @@ export const projectDesiredAutomation = (d, remote) => ({
|
|
|
893
896
|
outputs: d.outputs ?? null,
|
|
894
897
|
});
|
|
895
898
|
const projectRemoteAutomation = (w) => ({
|
|
896
|
-
|
|
899
|
+
executionConfig: w.execution_config ?? null,
|
|
897
900
|
agent: w.managed_agent_id ?? null,
|
|
898
901
|
// `?? null` mirrors projectDesiredAutomation: an unnamed remote Automation must
|
|
899
902
|
// compare EQUAL to the desired side that inherited it, or deepEqual(null,
|
|
@@ -1020,7 +1023,7 @@ function diffAutomation(desired, remote) {
|
|
|
1020
1023
|
if (!deepEqual(desired.triggers ?? [], remote.triggers ?? [])) {
|
|
1021
1024
|
scalar.push("triggers");
|
|
1022
1025
|
}
|
|
1023
|
-
if (desired.agent !== (remote.managed_agent_id ??
|
|
1026
|
+
if (desired.agent !== (remote.managed_agent_id ?? null)) {
|
|
1024
1027
|
scalar.push("managed_agent_id");
|
|
1025
1028
|
}
|
|
1026
1029
|
if (desired.deviceWorkerId !== undefined &&
|
|
@@ -1039,10 +1042,10 @@ function diffAutomation(desired, remote) {
|
|
|
1039
1042
|
desired.agentKind !== (remote.agent_kind ?? undefined)) {
|
|
1040
1043
|
scalar.push("agent_kind");
|
|
1041
1044
|
}
|
|
1042
|
-
if ((desired.
|
|
1043
|
-
desired.
|
|
1044
|
-
(desired.
|
|
1045
|
-
|
|
1045
|
+
if ((desired.executionConfig !== undefined &&
|
|
1046
|
+
!deepEqual(desired.executionConfig, remote.execution_config ?? null)) ||
|
|
1047
|
+
(desired.model !== undefined &&
|
|
1048
|
+
desired.model !== (remote.execution_config?.model ?? null))) {
|
|
1046
1049
|
scalar.push("execution_config");
|
|
1047
1050
|
}
|
|
1048
1051
|
const versionBound = [];
|
|
@@ -1120,16 +1123,15 @@ function diffConnectorDefinition(desired, installedKeys) {
|
|
|
1120
1123
|
const id = connectorDefinitionId(desired);
|
|
1121
1124
|
// The CLI can't compare source hashes (the server compiles, and the stored
|
|
1122
1125
|
// hash is of the *compiled* output) — so we always emit a "sync" row;
|
|
1123
|
-
//
|
|
1124
|
-
//
|
|
1126
|
+
// The server preserves identical retained versions and enforces version bumps
|
|
1127
|
+
// for source changes. Installed definitions use the version-checked update.
|
|
1125
1128
|
// Local files have no resolved key during planning; the static hint lets
|
|
1126
1129
|
// the plan recognise an installed definition without compiling the source.
|
|
1127
1130
|
const key = desired.key ?? desired.declaredKeyHint;
|
|
1128
1131
|
const installedRemotely = key ? installedKeys.has(key) : false;
|
|
1129
1132
|
return {
|
|
1130
1133
|
kind: "connector-definition",
|
|
1131
|
-
//
|
|
1132
|
-
// idempotent and reports `updated:false` if the code is unchanged.
|
|
1134
|
+
// Installed definitions reuse update_connector_source with the read version.
|
|
1133
1135
|
verb: installedRemotely ? "update" : "create",
|
|
1134
1136
|
id,
|
|
1135
1137
|
desired,
|
|
@@ -1154,7 +1156,9 @@ function diffAuthProfile(desired, remote) {
|
|
|
1154
1156
|
throw new ValidationError(`${desired.sourceFile}: auth_profile "${desired.slug}" is bound to ${remote.connector_key}/${remote.profile_kind} remotely, but the manifest declares ${desired.connector}/${desired.kind} — delete it manually or use a new slug`);
|
|
1155
1157
|
}
|
|
1156
1158
|
const changed = [];
|
|
1157
|
-
|
|
1159
|
+
// An omitted name is unmanaged; apply never sends it.
|
|
1160
|
+
if (desired.name !== undefined &&
|
|
1161
|
+
desired.name !== (remote.display_name ?? "")) {
|
|
1158
1162
|
changed.push("name");
|
|
1159
1163
|
}
|
|
1160
1164
|
// Credentials can't be read back from the server (write-only secrets). For
|
|
@@ -28,7 +28,7 @@ export interface AgentMarkdown {
|
|
|
28
28
|
* config. Packages come from the agent (`nixConfig`, already in `settings`) or
|
|
29
29
|
* connector `agentTooling`, never from skills.
|
|
30
30
|
*/
|
|
31
|
-
export declare function mergeAgentDirArtifacts(settings: Partial<AgentSettings>, markdown: AgentMarkdown, localSkills
|
|
31
|
+
export declare function mergeAgentDirArtifacts(settings: Partial<AgentSettings>, markdown: AgentMarkdown, localSkills?: LocalSkills): void;
|
|
32
32
|
/**
|
|
33
33
|
* Translate an authoring project into the apply `DesiredState`. When `only` is
|
|
34
34
|
* set, connector definitions/connections/auth-profiles are skipped (and their
|