@xopcai/xopc 0.0.434 → 0.0.436
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CmxICTM4.js → automations-page-BjbM15eY.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-R6YNDdAO.js → automations-workspace-CqurzLYX.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-BJ8PlDjZ.js → chat-page--wcFhTjW.js} +30 -30
- package/dist/gateway/static/root/assets/{index-DWQ4LbBn.js → index-C4moZbZv.js} +4 -4
- package/dist/gateway/static/root/assets/{personal-page-l9_vYfdJ.js → personal-page-BhuT79Wd.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BbyV8EiG.js → project-detail-page-CuugOYfe.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-BWpw9qxc.js → route-preload-BQapekpy.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-XJXcnE1_.js → settings-page-CedwaHM0.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DvX9JoEd.js → task-detail-page-_Og3plZL.js} +1 -1
- package/dist/gateway/static/root/index.html +3 -3
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/external-tools/cliProvider.js +2 -2
- package/dist/src/agent/external-tools/composio-provider.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/repository.js +1 -1
- package/dist/src/automations/api/routes.js +2 -2
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/write.js +1 -1
- package/dist/src/automations/configuration-conversation.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/broker.d.ts +5 -0
- package/dist/src/computer/broker.js +33 -9
- package/dist/src/computer/diagnostics.d.ts +340 -0
- package/dist/src/computer/diagnostics.js +4 -0
- package/dist/src/computer/errors.d.ts +340 -0
- package/dist/src/computer/errors.js +121 -4
- package/dist/src/computer/evaluation.d.ts +186 -0
- package/dist/src/computer/model-adapter.js +47 -20
- package/dist/src/computer/runtime.d.ts +170 -0
- package/dist/src/computer/runtime.js +36 -8
- package/dist/src/computer/stability-diagnostics.d.ts +23 -0
- package/dist/src/computer/stability-diagnostics.js +71 -0
- package/dist/src/computer/validation-diagnostics.d.ts +9 -0
- package/dist/src/computer/validation-diagnostics.js +54 -0
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/global-defaults-admin.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/imports/importService.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/realtime/runtime.js +13 -5
- package/dist/src/realtime/writer.d.ts +7 -0
- package/dist/src/realtime/writer.js +96 -30
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComputerTarget } from '@xopcai/computer-control-contract';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { ComputerDiagnosticSchema, ComputerStabilitySchema } from './errors.js';
|
|
4
|
+
type Stability = z.infer<typeof ComputerStabilitySchema>;
|
|
5
|
+
type Snapshot = {
|
|
6
|
+
target: ComputerTarget;
|
|
7
|
+
summary: string;
|
|
8
|
+
stateDigest: string;
|
|
9
|
+
imageWidth: number;
|
|
10
|
+
imageHeight: number;
|
|
11
|
+
};
|
|
12
|
+
/** Compare privately; retain only fixed change categories and bounded element positions, never values or hashes. */
|
|
13
|
+
export declare class ComputerStabilityTracker {
|
|
14
|
+
private readonly stage;
|
|
15
|
+
private readonly action?;
|
|
16
|
+
private readonly changes;
|
|
17
|
+
private readonly indices;
|
|
18
|
+
constructor(stage: Stability['stage'], action?: Stability['action']);
|
|
19
|
+
deadline(): void;
|
|
20
|
+
compare(before: Snapshot, after: Snapshot): void;
|
|
21
|
+
diagnostic(errorCode: string, samples: number): z.infer<typeof ComputerDiagnosticSchema>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
//#region src/computer/stability-diagnostics.ts
|
|
3
|
+
/** Compare privately; retain only fixed change categories and bounded element positions, never values or hashes. */
|
|
4
|
+
var ComputerStabilityTracker = class {
|
|
5
|
+
changes = /* @__PURE__ */ new Set();
|
|
6
|
+
indices = /* @__PURE__ */ new Set();
|
|
7
|
+
constructor(stage, action) {
|
|
8
|
+
this.stage = stage;
|
|
9
|
+
this.action = action;
|
|
10
|
+
}
|
|
11
|
+
deadline() {
|
|
12
|
+
this.changes.add("deadline");
|
|
13
|
+
}
|
|
14
|
+
compare(before, after) {
|
|
15
|
+
const a = before.target, b = after.target;
|
|
16
|
+
if (a.appId !== b.appId || a.pid !== b.pid || a.processIdentity !== b.processIdentity || a.windowId !== b.windowId) this.changes.add("window_identity");
|
|
17
|
+
if (a.geometryRevision !== b.geometryRevision || a.width !== b.width || a.height !== b.height) this.changes.add("window_geometry");
|
|
18
|
+
if (before.imageWidth !== after.imageWidth || before.imageHeight !== after.imageHeight) this.changes.add("image_dimensions");
|
|
19
|
+
if (before.summary !== after.summary) try {
|
|
20
|
+
const left = JSON.parse(before.summary), right = JSON.parse(after.summary);
|
|
21
|
+
const ae = Array.isArray(left.elements) ? left.elements : [], be = Array.isArray(right.elements) ? right.elements : [];
|
|
22
|
+
if (ae.length !== be.length) this.changes.add("accessibility_structure");
|
|
23
|
+
if (left.text !== right.text) this.changes.add("accessibility_text");
|
|
24
|
+
const groups = {
|
|
25
|
+
accessibility_structure: [
|
|
26
|
+
"role",
|
|
27
|
+
"ref",
|
|
28
|
+
"depth",
|
|
29
|
+
"parent_index"
|
|
30
|
+
],
|
|
31
|
+
accessibility_text: [
|
|
32
|
+
"label",
|
|
33
|
+
"value",
|
|
34
|
+
"value_description"
|
|
35
|
+
],
|
|
36
|
+
accessibility_state: [
|
|
37
|
+
"enabled",
|
|
38
|
+
"selected",
|
|
39
|
+
"keyboardFocused",
|
|
40
|
+
"inputAllowed",
|
|
41
|
+
"semanticActions",
|
|
42
|
+
"in_web_content"
|
|
43
|
+
],
|
|
44
|
+
accessibility_geometry: ["bounds", "frame"]
|
|
45
|
+
};
|
|
46
|
+
for (let i = 0; i < Math.max(ae.length, be.length); i++) {
|
|
47
|
+
if (JSON.stringify(ae[i]) !== JSON.stringify(be[i]) && this.indices.size < 8 && i <= 16384) this.indices.add(i);
|
|
48
|
+
for (const [category, fields] of Object.entries(groups)) if (fields.some((field) => JSON.stringify(ae[i]?.[field]) !== JSON.stringify(be[i]?.[field]))) this.changes.add(category);
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
this.changes.add("accessibility_structure");
|
|
52
|
+
}
|
|
53
|
+
if (before.stateDigest !== after.stateDigest && before.summary === after.summary && JSON.stringify(a) === JSON.stringify(b) && before.imageWidth === after.imageWidth && before.imageHeight === after.imageHeight) this.changes.add("visual_or_unexposed_state");
|
|
54
|
+
}
|
|
55
|
+
diagnostic(errorCode, samples) {
|
|
56
|
+
return {
|
|
57
|
+
errorCode,
|
|
58
|
+
phase: this.stage === "initial_capture" ? "observe" : "dispatch",
|
|
59
|
+
diagnosticId: randomUUID(),
|
|
60
|
+
stability: {
|
|
61
|
+
stage: this.stage,
|
|
62
|
+
samples,
|
|
63
|
+
...this.action ? { action: this.action } : {},
|
|
64
|
+
changes: [...this.changes],
|
|
65
|
+
changedElementIndices: [...this.indices]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ComputerStabilityTracker };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ComputerValidationSchema } from './errors.js';
|
|
3
|
+
type Validation = z.infer<typeof ComputerValidationSchema>;
|
|
4
|
+
/** Project only allowlisted metadata; Zod messages, values and arbitrary property names may contain private data. */
|
|
5
|
+
export declare function modelValidation(value: unknown, stage: Validation['stage'], error?: unknown, failure?: {
|
|
6
|
+
path: (string | number)[];
|
|
7
|
+
code: Validation['issues'][number]['code'];
|
|
8
|
+
}): Validation;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ComputerValidationSchema } from "./errors.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/computer/validation-diagnostics.ts
|
|
4
|
+
const Field = ComputerValidationSchema.shape.issues.element.shape.path.element;
|
|
5
|
+
const Action = ComputerValidationSchema.shape.action;
|
|
6
|
+
const Code = ComputerValidationSchema.shape.issues.element.shape.code;
|
|
7
|
+
function actionName(value) {
|
|
8
|
+
if (!value || typeof value !== "object") return "unknown";
|
|
9
|
+
const node = value;
|
|
10
|
+
return Action.safeParse(typeof node.action === "string" ? node.action : node.kind).data ?? "unknown";
|
|
11
|
+
}
|
|
12
|
+
/** Project only allowlisted metadata; Zod messages, values and arbitrary property names may contain private data. */
|
|
13
|
+
function modelValidation(value, stage, error, failure) {
|
|
14
|
+
const root = value && typeof value === "object" ? value : {};
|
|
15
|
+
const payload = root.arguments && typeof root.arguments === "object" ? root.arguments : root;
|
|
16
|
+
const proposal = payload.proposal && typeof payload.proposal === "object" ? payload.proposal : payload;
|
|
17
|
+
const action = actionName(typeof proposal.action === "object" ? proposal.action : proposal);
|
|
18
|
+
const issues = [];
|
|
19
|
+
const append = (path, code) => {
|
|
20
|
+
if (issues.length >= 4) return;
|
|
21
|
+
let node = value;
|
|
22
|
+
let nestedAction = action;
|
|
23
|
+
for (const part of path) {
|
|
24
|
+
if (!node || typeof node !== "object") break;
|
|
25
|
+
node = node[part];
|
|
26
|
+
const candidate = actionName(node);
|
|
27
|
+
if (candidate !== "unknown") nestedAction = candidate;
|
|
28
|
+
}
|
|
29
|
+
issues.push({
|
|
30
|
+
path: path.slice(0, 10).map((part) => Field.safeParse(part).data ?? "unknown_field"),
|
|
31
|
+
code: Code.safeParse(code).data ?? "invalid_value",
|
|
32
|
+
action: nestedAction
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const branchScore = (list) => list.length + list.filter((issue) => issue.code === "invalid_value" && ["kind", "action"].includes(String(issue.path.at(-1)))).length * 100;
|
|
36
|
+
const visit = (list, prefix = []) => {
|
|
37
|
+
for (const issue of list) if (issue.code === "invalid_union" && issue.errors.length) visit([...issue.errors].sort((a, b) => branchScore(a) - branchScore(b))[0], [...prefix, ...issue.path]);
|
|
38
|
+
else if (issue.code === "unrecognized_keys") for (const key of issue.keys) append([
|
|
39
|
+
...prefix,
|
|
40
|
+
...issue.path,
|
|
41
|
+
key
|
|
42
|
+
], issue.code);
|
|
43
|
+
else append([...prefix, ...issue.path], issue.code);
|
|
44
|
+
};
|
|
45
|
+
if (error instanceof z.ZodError) visit(error.issues);
|
|
46
|
+
if (failure) append(failure.path, failure.code);
|
|
47
|
+
return {
|
|
48
|
+
action,
|
|
49
|
+
stage,
|
|
50
|
+
issues
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { modelValidation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
1
2
|
import { resolveEffectiveAgentConfig } from "../agent-config/resolver.js";
|
|
2
3
|
import { init_agent_config } from "../agent-config/index.js";
|
|
3
|
-
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
4
4
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
5
5
|
import { init_agent_scope, resolveAgentWorkspaceDir } from "../agent/agent-scope.js";
|
|
6
6
|
import { getConversationRouting } from "../storage/sqlite/conversation-repository.js";
|
|
@@ -8,8 +8,8 @@ import { assertManagedWorktreePath, assertNoNestedRegisteredWorktrees, readDirec
|
|
|
8
8
|
import { dirname, resolve } from "node:path";
|
|
9
9
|
import { existsSync } from "node:fs";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
|
-
import { mkdir, rm, stat } from "node:fs/promises";
|
|
12
11
|
import lockfile from "proper-lockfile";
|
|
12
|
+
import { mkdir, rm, stat } from "node:fs/promises";
|
|
13
13
|
//#region src/execution-environments/local-worktree-manager.ts
|
|
14
14
|
init_logger();
|
|
15
15
|
const log = createLogger("ExecutionEnvironment:LocalWorktree");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { parseFrontmatter } from "../../markdown/frontmatter.js";
|
|
2
1
|
import { containedPath } from "./contained-path.js";
|
|
3
2
|
import "./validation.js";
|
|
4
3
|
import { AgentPluginStore } from "./store.js";
|
|
4
|
+
import { parseFrontmatter } from "../../markdown/frontmatter.js";
|
|
5
5
|
import { createSkillConfigManager } from "../../agent/skills/config.js";
|
|
6
6
|
import { parseSkillLocalizations } from "../../agent/skills/parse-skill-metadata.js";
|
|
7
7
|
import { buildSkillMarkdownPreviewFromRaw } from "../../agent/skills/skill-markdown-preview-from-raw.js";
|
|
@@ -9,8 +9,8 @@ import { dirname, join, resolve } from "node:path";
|
|
|
9
9
|
import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
-
import yaml from "js-yaml";
|
|
13
12
|
import { validateHeaderName, validateHeaderValue } from "node:http";
|
|
13
|
+
import yaml from "js-yaml";
|
|
14
14
|
//#region src/extensions/agent-plugins/validation.ts
|
|
15
15
|
init_schema();
|
|
16
16
|
const PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { normalizeAgentId, validateAgentIdForNewAgent } from "../agent-catalog/id.js";
|
|
2
2
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
3
3
|
import { init_agent_scope, listAgentEntries, resolveAgentProfileDir, resolveAgentWorkspaceDir, resolveDefaultAgentId, resolveUserPath } from "../agent/agent-scope.js";
|
|
4
|
+
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
4
5
|
import { AGENT_PROFILE_MARKDOWN_SYSTEM_FILES, REQUIRED_AGENT_PROFILE_MARKDOWN_FILE_SET } from "../agent/context/workspace.js";
|
|
5
6
|
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
6
|
-
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
7
7
|
import { isPathUnderWorkspace, resolveWorkspaceSafePath } from "./workspace-editor-path.js";
|
|
8
8
|
import { GATEWAY_BUILTIN_TOOL_IDS } from "./agent-builtin-tools.js";
|
|
9
9
|
import { resolve } from "node:path";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AgentDefaultsSchema } from "../agent-config/schema.js";
|
|
2
2
|
import { init_agent_config } from "../agent-config/index.js";
|
|
3
3
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
4
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
4
|
import { validatePhoneModelChange } from "../phone/model-adapter.js";
|
|
5
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
6
6
|
import { validateComputerModelChange } from "../computer/model-config.js";
|
|
7
7
|
import { GATEWAY_BUILTIN_TOOLS } from "./agent-builtin-tools.js";
|
|
8
8
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { normalizeAgentId } from "../../../agent-catalog/id.js";
|
|
1
2
|
import { AgentEntrySchema, AgentModelsOverrideSchema, AgentProfileSchema, RuntimePolicySchema, SkillOverrideSchema, ToolPoliciesSchema } from "../../../agent-config/schema.js";
|
|
2
3
|
import { init_agent_config } from "../../../agent-config/index.js";
|
|
3
|
-
import { normalizeAgentId } from "../../../agent-catalog/id.js";
|
|
4
4
|
import { init_agent_scope } from "../../../agent/agent-scope.js";
|
|
5
5
|
import { getVoiceModelsConfig } from "../../../config/voice.js";
|
|
6
6
|
import { createGatewayAgent, deleteAgentAvatarFile, deleteGatewayAgent, getGatewayAgentEffectiveConfig, listAgentProfileFiles, listGatewayAgents, readAgentAvatarFile, readAgentProfileFile, resolveAgentAvatarImage, updateGatewayAgent, writeAgentAvatarFromBase64, writeAgentProfileFile } from "../../agents-admin.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BindingsSchema, init_binding_schema } from "../../../../routing/binding-schema.js";
|
|
2
|
-
import { AgentCatalogService } from "../../../../agent-catalog/service.js";
|
|
3
2
|
import { ComputerConfigSchema, init_config } from "../../../../computer/config.js";
|
|
4
3
|
import { ContextPlanningConfigSchema, HomeIntelligenceConfigSchema, KnowledgeMemoryConfigSchema, UserContextConfigSchema, UserModelConfigSchema, init_config as init_config$1 } from "../../../../user-context/config.js";
|
|
5
4
|
import { BrowserConfigSchema, McpConfigSchema, VoiceConfigSchema, init_schema } from "../../../../config/schema.js";
|
|
6
5
|
import { CredentialResolver, init_credentials } from "../../../../auth/credentials.js";
|
|
7
6
|
import { canonicalizeConfiguredMcpServer } from "../../../../config/mcp-config-normalize.js";
|
|
7
|
+
import { AgentCatalogService } from "../../../../agent-catalog/service.js";
|
|
8
8
|
import { mergeGatewaySkillsMarketplacePatch, mergeSessionConfigPatch, mergeUpdateConfigPatch } from "../../../../config/web-patch.js";
|
|
9
9
|
import { assertGatewayAuthConfigured, resolveGatewayAuth } from "../../../auth.js";
|
|
10
10
|
import { isMaskedSecretPatchValue } from "../../lib/mask-secret-length.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NoteDeleteOutputSchema, NoteGetOutputSchema, ProductReadContracts } from "../../../../packages/gateway-contract/src/capabilities.js";
|
|
2
2
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
3
|
-
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
4
|
-
import "../../../capabilities/runtime/dispatcher.js";
|
|
5
3
|
import { init_session_key, resolveConversationId } from "../../../routing/session-key.js";
|
|
6
4
|
import { agentExists, getDefaultAgentId, init_resolve_route } from "../../../routing/resolve-route.js";
|
|
5
|
+
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
6
|
+
import "../../../capabilities/runtime/dispatcher.js";
|
|
7
7
|
import { resolveReverseProxyPublicUrl } from "../../public-url.js";
|
|
8
8
|
import { createProductDispatcher } from "../../../capabilities/runtime/product.js";
|
|
9
9
|
import { resolveGatewayEffectiveHost } from "../../../config/gateway-bind.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { resolveStateDir } from "../../../config/paths-state.js";
|
|
2
2
|
import { getSessionMetadata, init_session_read_repository } from "../../../storage/sqlite/session-read-repository.js";
|
|
3
3
|
import { AgentCatalogRepository, init_repository } from "../../../agent-catalog/repository.js";
|
|
4
|
-
import { AgentCatalogService } from "../../../agent-catalog/service.js";
|
|
5
4
|
import { init_paths } from "../../../config/paths.js";
|
|
6
5
|
import { resolveEffectiveAgentConfigForAgent } from "../../../config/agent-profile.js";
|
|
7
6
|
import { phoneModelProfile } from "../../../phone/model-policy.js";
|
|
@@ -11,6 +10,7 @@ import { managedHdcPath, managedHosJar, managedJavaHome } from "../../../runtime
|
|
|
11
10
|
import { managedPhoneAdbPath } from "../../../runtime-tools/phone-dependency-catalog.js";
|
|
12
11
|
import "../../../phone/model-adapter.js";
|
|
13
12
|
import { getPhoneRuntime } from "../../../phone/runtime.js";
|
|
13
|
+
import { AgentCatalogService } from "../../../agent-catalog/service.js";
|
|
14
14
|
import { PhoneSetupService } from "../../../phone/setup/service.js";
|
|
15
15
|
import { PhoneDependencyManager, probePhoneAdb } from "../../../runtime-tools/phone-dependencies.js";
|
|
16
16
|
import { createHash } from "node:crypto";
|
|
@@ -6,12 +6,12 @@ import { loadTranscriptRowsForSession } from "../../../storage/sqlite/transcript
|
|
|
6
6
|
import "../../../storage/sqlite/index.js";
|
|
7
7
|
import { ActivityService } from "../../../activity/service.js";
|
|
8
8
|
import "../../../activity/index.js";
|
|
9
|
-
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
10
|
-
import "../../../capabilities/runtime/dispatcher.js";
|
|
11
9
|
import { listKnowledgeItems, writeKnowledgeItem } from "../../../knowledge-memory/repository.js";
|
|
12
10
|
import "../../../knowledge-memory/index.js";
|
|
13
11
|
import { resolveEffectiveAgentProfile } from "../../../config/agent-profile.js";
|
|
14
12
|
import { TaskReadModelProjector } from "../../../tasks/task-read-model-projector.js";
|
|
13
|
+
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
14
|
+
import "../../../capabilities/runtime/dispatcher.js";
|
|
15
15
|
import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError } from "../../../projects/workspace-project.js";
|
|
16
16
|
import { inferProjectExecutionMode, inferProjectKind } from "../../../projects/project-kind.js";
|
|
17
17
|
import { ProjectDeletionBlockedError, ProjectWorkspaceInUseError } from "../../../projects/project-service.js";
|
|
@@ -6,9 +6,9 @@ import { parseUserTurnDocument, userTurnDocumentRefIds } from "../../../../packa
|
|
|
6
6
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
7
7
|
import { SessionInputControlConflict, init_session_input_control_repository } from "../../../storage/sqlite/session-input-control-repository.js";
|
|
8
8
|
import { endpointTurnClaimSchema, init_src as init_src$1 } from "../../../../packages/endpoint-tools-protocol/src/index.js";
|
|
9
|
+
import { init_providers, resolveModel } from "../../../providers/index.js";
|
|
9
10
|
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
10
11
|
import "../../../capabilities/runtime/dispatcher.js";
|
|
11
|
-
import { init_providers, resolveModel } from "../../../providers/index.js";
|
|
12
12
|
import { parseTurnContextRefs } from "../../../agent/source-context/types.js";
|
|
13
13
|
import { getModelThinking } from "../../../providers/model-thinking.js";
|
|
14
14
|
import { validateWebchatAttachments, validateWebchatContent } from "../../chat-limits.js";
|
|
@@ -6,9 +6,9 @@ import { hasGatewayScope } from "../../security/gateway-scopes.js";
|
|
|
6
6
|
import { enqueueTaskChangedEvent, init_task_change_events } from "../../../tasks/task-change-events.js";
|
|
7
7
|
import { TaskRepository, init_task_repository } from "../../../tasks/task-repository.js";
|
|
8
8
|
import { TaskRunRepository, init_task_run_repository } from "../../../tasks/task-run-repository.js";
|
|
9
|
+
import { TaskConversationRepository } from "../../../tasks/task-conversation-repository.js";
|
|
9
10
|
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
10
11
|
import "../../../capabilities/runtime/dispatcher.js";
|
|
11
|
-
import { TaskConversationRepository } from "../../../tasks/task-conversation-repository.js";
|
|
12
12
|
import { TaskCriterionReviewRepository } from "../../../tasks/task-criterion-review-repository.js";
|
|
13
13
|
import { TaskContextMutationOutputSchema } from "../../../tasks/capabilities/relations.js";
|
|
14
14
|
import { TaskDeleteOutputSchema } from "../../../tasks/capabilities/management.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
2
2
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
3
3
|
import { init_agent_scope } from "../agent/agent-scope.js";
|
|
4
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
4
|
import { ConfigSchema, init_schema } from "../config/schema.js";
|
|
6
5
|
import { resolveEffectiveAgentConfigForAgent } from "../config/agent-profile.js";
|
|
7
6
|
import { fetchWithTimeoutGuarded } from "../media-shared/http/provider-http.js";
|
|
8
7
|
import "../media-shared/http/index.js";
|
|
8
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
9
9
|
import { getImageGenerationProvider, listImageGenerationProvidersSummary } from "../agent/image/generation/provider-registry.js";
|
|
10
10
|
//#region src/gateway/image-generation-setup.ts
|
|
11
11
|
init_repository();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../agent-config/schema.js";
|
|
2
2
|
import { init_agent_config } from "../agent-config/index.js";
|
|
3
3
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
4
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
4
|
import { ConfigSchema, init_schema } from "../config/schema.js";
|
|
6
5
|
import { phoneModelProfile } from "../phone/model-policy.js";
|
|
7
6
|
import { init_model_policy, isComputerModel, isDedicatedComputerProfile } from "../computer/model-policy.js";
|
|
@@ -10,6 +9,7 @@ import { init_voice } from "../../packages/realtime-protocol/src/voice.js";
|
|
|
10
9
|
import { getModelCatalogStore, init_model_catalog_store } from "../providers/model-catalog-store.js";
|
|
11
10
|
import "../phone/model-adapter.js";
|
|
12
11
|
import { compareCatalogModels } from "../providers/model-catalog-ranking.js";
|
|
12
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
13
13
|
import { prepareUpdateGlobalDefaults } from "./global-defaults-admin.js";
|
|
14
14
|
//#region src/gateway/xopc-cloud-capability-setup.ts
|
|
15
15
|
init_voice();
|
|
@@ -11,8 +11,8 @@ import { scanLocal } from "./scanner.js";
|
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { randomUUID } from "node:crypto";
|
|
14
|
-
import yaml from "js-yaml";
|
|
15
14
|
import lockfile from "proper-lockfile";
|
|
15
|
+
import yaml from "js-yaml";
|
|
16
16
|
//#region src/imports/importService.ts
|
|
17
17
|
init_write_file_atomic();
|
|
18
18
|
init_logger();
|
|
@@ -5,9 +5,9 @@ import { init_logger } from "../utils/logger.js";
|
|
|
5
5
|
import { afterSqliteCommit, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
6
6
|
import { ExtensionCapabilityBindingsSchema, extensionCapabilityPermissions } from "../../packages/gateway-contract/src/extension-capabilities.js";
|
|
7
7
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
8
|
-
import { CapabilityError } from "../capabilities/runtime/errors.js";
|
|
9
8
|
import { init_paths, resolveExtensionsDir } from "../config/paths.js";
|
|
10
9
|
import { slugifyProjectName } from "../projects/project-store.js";
|
|
10
|
+
import { CapabilityError } from "../capabilities/runtime/errors.js";
|
|
11
11
|
import { LocalAppStore } from "./store.js";
|
|
12
12
|
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
13
13
|
import { validateLocalAppCapabilityContracts } from "./capabilities/contracts.js";
|
|
@@ -2,11 +2,11 @@ import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js
|
|
|
2
2
|
import { init_session_repository, patchSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
3
3
|
import { setSessionConfig } from "../storage/sqlite/config-repository.js";
|
|
4
4
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
5
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
6
5
|
import { createConversation, init_conversation_repository } from "../storage/sqlite/conversation-repository.js";
|
|
7
6
|
import { getAvailableModels, init_providers } from "../providers/index.js";
|
|
8
7
|
import { getPersonalAgent, personalAgentId } from "./repository.js";
|
|
9
8
|
import { PERSONAL_MAIN_TOOL_IDS, PERSONAL_READ_TOOL_ALIASES } from "./policy.js";
|
|
9
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
10
10
|
import { getModelThinking } from "../providers/model-thinking.js";
|
|
11
11
|
import { personalInstructions } from "./prompts.js";
|
|
12
12
|
import { completePersonalOnboarding } from "./onboarding.js";
|
|
@@ -195,15 +195,23 @@ var RealtimeRuntime = class {
|
|
|
195
195
|
const output = item.view === "compact" ? compactRunEvent(event) : event;
|
|
196
196
|
if (output) writer.enqueue(output);
|
|
197
197
|
});
|
|
198
|
-
subscriptions.set(item.topic, handle);
|
|
199
198
|
writer.enqueue(serverMessage("realtime.subscribed", {
|
|
200
199
|
topic: item.topic,
|
|
201
200
|
cursor: handle.cursor
|
|
202
201
|
}), "critical");
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
const cancelReplay = writer.enqueueReplay((function* () {
|
|
203
|
+
for (const message of handle.initial) {
|
|
204
|
+
const output = item.view === "compact" ? compactRunEvent(message) : message;
|
|
205
|
+
if (output) yield output;
|
|
206
|
+
}
|
|
207
|
+
})());
|
|
208
|
+
subscriptions.set(item.topic, {
|
|
209
|
+
...handle,
|
|
210
|
+
unsubscribe: () => {
|
|
211
|
+
cancelReplay();
|
|
212
|
+
handle.unsubscribe();
|
|
213
|
+
}
|
|
214
|
+
});
|
|
207
215
|
}
|
|
208
216
|
return true;
|
|
209
217
|
};
|
|
@@ -8,8 +8,15 @@ export declare class RealtimeSocketWriter {
|
|
|
8
8
|
private sending;
|
|
9
9
|
private closed;
|
|
10
10
|
private retryTimer?;
|
|
11
|
+
private stallTimer?;
|
|
11
12
|
constructor(socket: WebSocket);
|
|
12
13
|
enqueue(message: ServerRealtimeMessage, priority?: 'critical' | 'normal'): boolean;
|
|
14
|
+
/** Serialize replay only as the socket drains; live messages stay behind the replay. */
|
|
15
|
+
enqueueReplay(messages: Iterable<ServerRealtimeMessage>): () => void;
|
|
13
16
|
close(): void;
|
|
17
|
+
private fail;
|
|
18
|
+
private serialize;
|
|
19
|
+
private watchForStall;
|
|
20
|
+
private next;
|
|
14
21
|
private flush;
|
|
15
22
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../utils/logger.js";
|
|
1
3
|
//#region src/realtime/writer.ts
|
|
4
|
+
init_logger();
|
|
5
|
+
const log = createLogger("RealtimeSocketWriter");
|
|
2
6
|
const SOFT_BUFFERED_BYTES = 512 * 1024;
|
|
3
|
-
const
|
|
4
|
-
const MAX_QUEUED_BYTES =
|
|
7
|
+
const MAX_EVENT_BYTES = 2 * 1024 * 1024;
|
|
8
|
+
const MAX_QUEUED_BYTES = 16 * 1024 * 1024;
|
|
9
|
+
const DELIVERY_STALL_MS = 15e3;
|
|
5
10
|
var RealtimeSocketWriter = class {
|
|
6
11
|
critical = [];
|
|
7
12
|
normal = [];
|
|
@@ -9,80 +14,141 @@ var RealtimeSocketWriter = class {
|
|
|
9
14
|
sending = false;
|
|
10
15
|
closed = false;
|
|
11
16
|
retryTimer;
|
|
17
|
+
stallTimer;
|
|
12
18
|
constructor(socket) {
|
|
13
19
|
this.socket = socket;
|
|
14
20
|
}
|
|
15
21
|
enqueue(message, priority = "normal") {
|
|
16
22
|
if (this.closed || this.socket.readyState !== 1) return false;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
data = JSON.stringify(message);
|
|
20
|
-
} catch {
|
|
21
|
-
this.socket.close(1011, "Realtime message serialization failed");
|
|
22
|
-
this.close();
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const item = {
|
|
26
|
-
data,
|
|
27
|
-
bytes: Buffer.byteLength(data)
|
|
28
|
-
};
|
|
29
|
-
if (item.bytes > MAX_QUEUED_BYTES) {
|
|
30
|
-
this.socket.close(1009, "Realtime event exceeds delivery limit");
|
|
31
|
-
this.close();
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
23
|
+
const item = this.serialize(message);
|
|
24
|
+
if (!item) return false;
|
|
34
25
|
if (this.queuedBytes + item.bytes > MAX_QUEUED_BYTES) {
|
|
35
|
-
this.
|
|
36
|
-
|
|
26
|
+
this.fail(4413, "Realtime delivery queue limit exceeded", {
|
|
27
|
+
eventBytes: item.bytes,
|
|
28
|
+
...message.kind === "realtime.event" ? {
|
|
29
|
+
topic: message.payload.topic,
|
|
30
|
+
event: message.payload.event
|
|
31
|
+
} : {}
|
|
32
|
+
});
|
|
37
33
|
return false;
|
|
38
34
|
}
|
|
39
35
|
this.queuedBytes += item.bytes;
|
|
40
36
|
(priority === "critical" ? this.critical : this.normal).push(item);
|
|
41
37
|
this.flush();
|
|
42
|
-
return
|
|
38
|
+
return !this.closed;
|
|
39
|
+
}
|
|
40
|
+
/** Serialize replay only as the socket drains; live messages stay behind the replay. */
|
|
41
|
+
enqueueReplay(messages) {
|
|
42
|
+
if (this.closed || this.socket.readyState !== 1) return () => {};
|
|
43
|
+
const item = { iterator: messages[Symbol.iterator]() };
|
|
44
|
+
this.normal.push(item);
|
|
45
|
+
this.flush();
|
|
46
|
+
return () => {
|
|
47
|
+
const index = this.normal.indexOf(item);
|
|
48
|
+
if (index >= 0) this.normal.splice(index, 1);
|
|
49
|
+
item.iterator.return?.();
|
|
50
|
+
};
|
|
43
51
|
}
|
|
44
52
|
close() {
|
|
45
53
|
if (this.closed) return;
|
|
46
54
|
this.closed = true;
|
|
47
55
|
if (this.retryTimer) clearTimeout(this.retryTimer);
|
|
56
|
+
if (this.stallTimer) clearTimeout(this.stallTimer);
|
|
48
57
|
this.retryTimer = void 0;
|
|
58
|
+
this.stallTimer = void 0;
|
|
59
|
+
for (const item of this.normal) if ("iterator" in item) item.iterator.return?.();
|
|
49
60
|
this.critical.length = 0;
|
|
50
61
|
this.normal.length = 0;
|
|
51
62
|
this.queuedBytes = 0;
|
|
52
63
|
}
|
|
64
|
+
fail(code, reason, fields = {}) {
|
|
65
|
+
log.warn({
|
|
66
|
+
...fields,
|
|
67
|
+
code,
|
|
68
|
+
queuedBytes: this.queuedBytes,
|
|
69
|
+
bufferedBytes: this.socket.bufferedAmount,
|
|
70
|
+
pendingItems: this.normal.length + this.critical.length
|
|
71
|
+
}, reason);
|
|
72
|
+
this.close();
|
|
73
|
+
this.socket.close(code, reason);
|
|
74
|
+
}
|
|
75
|
+
serialize(message) {
|
|
76
|
+
let data;
|
|
77
|
+
try {
|
|
78
|
+
data = JSON.stringify(message);
|
|
79
|
+
} catch {
|
|
80
|
+
this.fail(1011, "Realtime message serialization failed");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const bytes = Buffer.byteLength(data);
|
|
84
|
+
if (bytes > MAX_EVENT_BYTES) {
|
|
85
|
+
this.fail(1009, "Realtime event exceeds delivery limit", {
|
|
86
|
+
eventBytes: bytes,
|
|
87
|
+
...message.kind === "realtime.event" ? {
|
|
88
|
+
topic: message.payload.topic,
|
|
89
|
+
event: message.payload.event
|
|
90
|
+
} : {}
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
data,
|
|
96
|
+
bytes
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
watchForStall() {
|
|
100
|
+
if (!this.stallTimer) this.stallTimer = setTimeout(() => this.fail(4413, "Realtime delivery stalled"), DELIVERY_STALL_MS);
|
|
101
|
+
}
|
|
102
|
+
next() {
|
|
103
|
+
const critical = this.critical.shift();
|
|
104
|
+
if (critical) return critical;
|
|
105
|
+
while (this.normal.length) {
|
|
106
|
+
const head = this.normal[0];
|
|
107
|
+
if (!("iterator" in head)) return this.normal.shift();
|
|
108
|
+
const next = head.iterator.next();
|
|
109
|
+
if (next.done) {
|
|
110
|
+
this.normal.shift();
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const item = this.serialize(next.value);
|
|
114
|
+
if (item) this.queuedBytes += item.bytes;
|
|
115
|
+
return item;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
53
118
|
flush() {
|
|
54
119
|
if (this.closed || this.sending || this.socket.readyState !== 1) return;
|
|
55
|
-
if (this.socket.bufferedAmount >
|
|
56
|
-
this.
|
|
57
|
-
this.close();
|
|
120
|
+
if (this.socket.bufferedAmount > MAX_QUEUED_BYTES) {
|
|
121
|
+
this.fail(4413, "Realtime socket buffer limit exceeded");
|
|
58
122
|
return;
|
|
59
123
|
}
|
|
60
124
|
if (this.socket.bufferedAmount > SOFT_BUFFERED_BYTES) {
|
|
125
|
+
this.watchForStall();
|
|
61
126
|
if (!this.retryTimer) this.retryTimer = setTimeout(() => {
|
|
62
127
|
this.retryTimer = void 0;
|
|
63
128
|
this.flush();
|
|
64
129
|
}, 10);
|
|
65
130
|
return;
|
|
66
131
|
}
|
|
67
|
-
const item = this.
|
|
132
|
+
const item = this.next();
|
|
68
133
|
if (!item) return;
|
|
69
134
|
this.sending = true;
|
|
135
|
+
this.watchForStall();
|
|
70
136
|
try {
|
|
71
137
|
this.socket.send(item.data, (error) => {
|
|
72
138
|
if (this.closed) return;
|
|
73
139
|
this.sending = false;
|
|
74
140
|
this.queuedBytes -= item.bytes;
|
|
141
|
+
if (this.stallTimer) clearTimeout(this.stallTimer);
|
|
142
|
+
this.stallTimer = void 0;
|
|
75
143
|
if (error) {
|
|
76
|
-
this.
|
|
77
|
-
this.close();
|
|
144
|
+
this.fail(1011, "Realtime delivery failed");
|
|
78
145
|
return;
|
|
79
146
|
}
|
|
80
147
|
this.flush();
|
|
81
148
|
});
|
|
82
149
|
} catch {
|
|
83
150
|
this.sending = false;
|
|
84
|
-
this.
|
|
85
|
-
this.socket.close(1011, "Realtime delivery failed");
|
|
151
|
+
this.fail(1011, "Realtime delivery failed");
|
|
86
152
|
}
|
|
87
153
|
}
|
|
88
154
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RuntimeError } from "./errors.js";
|
|
2
2
|
import { isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
-
import { lstat, mkdir, readdir, readlink, rename, rm, stat } from "node:fs/promises";
|
|
5
4
|
import AdmZip from "adm-zip";
|
|
5
|
+
import { lstat, mkdir, readdir, readlink, rename, rm, stat } from "node:fs/promises";
|
|
6
6
|
//#region src/runtime-tools/archive.ts
|
|
7
7
|
const MAX_ARCHIVE_ENTRIES = 5e4;
|
|
8
8
|
const MAX_TAR_OUTPUT_BYTES = 16 * 1024 * 1024;
|