@songsid/agend 2.3.5-alpha.12 → 2.3.5-alpha.14
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/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/agent-export.d.ts +74 -0
- package/dist/agent-export.js +362 -0
- package/dist/agent-export.js.map +1 -0
- package/dist/agent-workspace.d.ts +1 -2
- package/dist/agent-workspace.js +8 -29
- package/dist/agent-workspace.js.map +1 -1
- package/dist/auth-api.js +3 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/codex.d.ts +7 -14
- package/dist/backend/codex.js +25 -29
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok-mcp.d.ts +5 -0
- package/dist/backend/grok-mcp.js +221 -0
- package/dist/backend/grok-mcp.js.map +1 -0
- package/dist/backend/grok.d.ts +0 -10
- package/dist/backend/grok.js +5 -82
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +6 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/cli.js +45 -12
- package/dist/cli.js.map +1 -1
- package/dist/codex-pane-ownership.d.ts +13 -0
- package/dist/codex-pane-ownership.js +192 -0
- package/dist/codex-pane-ownership.js.map +1 -0
- package/dist/daemon.d.ts +2 -0
- package/dist/daemon.js +89 -8
- package/dist/daemon.js.map +1 -1
- package/dist/fleet-manager.d.ts +15 -1
- package/dist/fleet-manager.js +72 -17
- package/dist/fleet-manager.js.map +1 -1
- package/dist/hub/client.d.ts +1 -1
- package/dist/hub/client.js +11 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +2 -2
- package/dist/hub/compose/member.js +11 -3
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/join/local.d.ts +1 -0
- package/dist/hub/join/local.js +8 -3
- package/dist/hub/join/local.js.map +1 -1
- package/dist/hub/member/exposure-api.d.ts +2 -0
- package/dist/hub/member/exposure-api.js +4 -2
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/pairing-api.d.ts +2 -2
- package/dist/hub/member/pairing-api.js +2 -2
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/server.js +8 -0
- package/dist/hub/server.js.map +1 -1
- package/dist/hub-pairing-summary.d.ts +3 -1
- package/dist/hub-pairing-summary.js +6 -3
- package/dist/hub-pairing-summary.js.map +1 -1
- package/dist/install-user-systemd.d.ts +20 -0
- package/dist/install-user-systemd.js +55 -0
- package/dist/install-user-systemd.js.map +1 -0
- package/dist/linux-launchers.d.ts +88 -0
- package/dist/linux-launchers.js +296 -0
- package/dist/linux-launchers.js.map +1 -0
- package/dist/locale.js +91 -4
- package/dist/locale.js.map +1 -1
- package/dist/runtime-client-store.js +5 -0
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-pane-private.d.ts +2 -0
- package/dist/runtime-pane-private.js +25 -0
- package/dist/runtime-pane-private.js.map +1 -1
- package/dist/runtime-pane-private.ps1 +74 -7
- package/dist/selection-card.d.ts +4 -3
- package/dist/selection-card.js +2 -1
- package/dist/selection-card.js.map +1 -1
- package/dist/service-installer.js +11 -2
- package/dist/service-installer.js.map +1 -1
- package/dist/settings-change.d.ts +2 -0
- package/dist/settings-change.js +74 -31
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +23 -0
- package/dist/settings-confirmation.js +13 -2
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.d.ts +4 -0
- package/dist/settings-effect.js +14 -14
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -1
- package/dist/settings-http-confirmation.js +12 -7
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-summary.d.ts +24 -0
- package/dist/settings-summary.js +42 -0
- package/dist/settings-summary.js.map +1 -0
- package/dist/transcript-delta-reader.d.ts +9 -1
- package/dist/transcript-delta-reader.js +37 -8
- package/dist/transcript-delta-reader.js.map +1 -1
- package/dist/ui/agent-details-settings.js +253 -0
- package/dist/ui/agent-export-dialog.js +169 -0
- package/dist/ui/agent-export-strings.js +81 -0
- package/dist/ui/agent-instructions-field.js +69 -0
- package/dist/ui/agent-page-strings.js +148 -0
- package/dist/ui/chat-quote.js +12 -17
- package/dist/ui/hub-client.js +1 -1
- package/dist/ui/hub-company-join-strings.js +1 -1
- package/dist/ui/hub-company-join.js +7 -0
- package/dist/ui/hub-strings.js +4 -0
- package/dist/ui/native-instance-settings.js +47 -14
- package/dist/ui/panel-details.js +38 -14
- package/dist/ui/panel-fleet.js +2 -2
- package/dist/ui/panel-settings.js +12 -9
- package/dist/ui/settings-access-overview.js +24 -3
- package/dist/ui/settings-confirm.js +5 -5
- package/dist/ui/settings-dialogs.js +210 -100
- package/dist/ui/settings-hub-company-join.js +69 -14
- package/dist/ui/settings-hub.js +13 -5
- package/dist/ui/settings-layout.js +0 -2
- package/dist/ui/settings-model.js +15 -0
- package/dist/ui/shared/access-overview.css +48 -0
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-shell.js +144 -3
- package/dist/ui/shared/app.css +74 -50
- package/dist/ui/shared/instance-nav.js +5 -1
- package/dist/ui/shared/view-strings.js +2 -0
- package/dist/update-dispatch.d.ts +62 -0
- package/dist/update-dispatch.js +69 -2
- package/dist/update-dispatch.js.map +1 -1
- package/dist/web-api.d.ts +2 -0
- package/dist/web-api.js +49 -0
- package/dist/web-api.js.map +1 -1
- package/dist/web-session.d.ts +4 -2
- package/dist/web-session.js +5 -2
- package/dist/web-session.js.map +1 -1
- package/dist/windows-shortcuts.d.ts +29 -5
- package/dist/windows-shortcuts.js +52 -9
- package/dist/windows-shortcuts.js.map +1 -1
- package/dist/workspace-file-policy.d.ts +2 -0
- package/dist/workspace-file-policy.js +31 -0
- package/dist/workspace-file-policy.js.map +1 -0
- package/dist/workspace-follow.js +2 -1
- package/dist/workspace-follow.js.map +1 -1
- package/launcher/agend-install.cjs +7 -1
- package/package.json +2 -2
- package/templates/icons/agend-restart.ico +0 -0
- package/templates/icons/agend.ico +0 -0
- package/templates/runtime-assets/runtime-pane-private.ps1 +74 -7
- package/templates/windows-shortcuts.ps1 +45 -12
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -142,3 +142,7 @@ component's full licence text in its `LICENSES/` directory:
|
|
|
142
142
|
| ncurses, https://invisible-island.net/ncurses/ | 6.5 | X11 (MIT-style) | linked statically; the terminfo subset is compiled from its `misc/terminfo.src` |
|
|
143
143
|
| utf8proc, https://github.com/JuliaStrings/utf8proc | 2.12.0 | MIT, and the Unicode License v3 for its data tables | linked statically |
|
|
144
144
|
| musl libc, https://musl.libc.org | 1.2.5 (the Alpine build image's, checked at build time) | MIT | linked statically, Linux builds only |
|
|
145
|
+
|
|
146
|
+
## Windows Runtime pane assets
|
|
147
|
+
|
|
148
|
+
The contributor-only `vendor/node-pty` subset comes from Microsoft node-pty 1.1.0 (MIT), with the existing ConPTY license and third-party notices. The Runtime ships these same JS/prebuild/license bytes. See [the upstream provenance and file hashes](vendor/node-pty/README.agend.md), [node-pty license](vendor/node-pty/LICENSE), and [ConPTY notices](vendor/node-pty/CONPTY-NOTICE.md).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { InstanceConfig } from "./types.js";
|
|
2
|
+
export declare const AGENT_EXPORT_VERSION = 1;
|
|
3
|
+
/**
|
|
4
|
+
* The most an agent's `systemPrompt` ("Agent instructions") may hold, in characters: the editor's limit
|
|
5
|
+
* (ui/agent-instructions-field.js INSTRUCTIONS_MAX_CHARS; tests/agent-export-163.test.ts keeps the two equal).
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT_INSTRUCTIONS_MAX_CHARS = 24000;
|
|
8
|
+
/** The largest file `parseAgentExport` reads, in characters (the instructions alone may take 24,000). */
|
|
9
|
+
export declare const AGENT_EXPORT_MAX_CHARS = 200000;
|
|
10
|
+
/** What an export can carry, as the checkboxes of the export dialog. */
|
|
11
|
+
export declare const EXPORT_GROUPS: readonly ["identity", "systemPrompt", "runtime", "behavior"];
|
|
12
|
+
export type ExportGroup = (typeof EXPORT_GROUPS)[number];
|
|
13
|
+
/** Why a field of a file is not loaded (the page words each code). */
|
|
14
|
+
export type SkipReason = "machine" | "binding" | "account" | "permission" | "command" | "emoji" | "notice" | "fleetOnly" | "name" | "runtimeSwitch" | "fileRef" | "unknown" | "badValue" | "tooLong";
|
|
15
|
+
export interface Skipped {
|
|
16
|
+
path: string;
|
|
17
|
+
reason: SkipReason;
|
|
18
|
+
}
|
|
19
|
+
export interface SecretFinding {
|
|
20
|
+
field: string;
|
|
21
|
+
line: number;
|
|
22
|
+
kind: string;
|
|
23
|
+
}
|
|
24
|
+
/** Where a text looks like it holds a secret: the field, the line and the kind — never the secret itself. */
|
|
25
|
+
export declare function scanForSecrets(field: string, text: string): SecretFinding[];
|
|
26
|
+
export interface BuildResult {
|
|
27
|
+
/** The file, or null when something in it looks like a secret (nothing is offered to copy or download). */
|
|
28
|
+
text: string | null;
|
|
29
|
+
findings: SecretFinding[];
|
|
30
|
+
/** What the file holds, by group (the page's preview of "what will be in it"). */
|
|
31
|
+
groups: ExportGroup[];
|
|
32
|
+
/** True when none of the chosen settings is saved on this agent: the file would hold nothing. */
|
|
33
|
+
empty: boolean;
|
|
34
|
+
/** A chosen setting this agent has but the file does not carry, and why (the dialog says so beside the preview). */
|
|
35
|
+
omitted: Array<{
|
|
36
|
+
field: "systemPrompt";
|
|
37
|
+
reason: "fileRef" | "tooLong";
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
/** Only what this agent itself sets (a field that follows the fleet's defaults is not written). */
|
|
41
|
+
export declare function buildAgentExport(role: string, inst: Partial<InstanceConfig>, include: readonly string[]): BuildResult;
|
|
42
|
+
/** What a file fills into the form: only the values that passed every check, under the form's own names. */
|
|
43
|
+
export interface FillValues {
|
|
44
|
+
description?: string;
|
|
45
|
+
tags?: string[];
|
|
46
|
+
systemPrompt?: string;
|
|
47
|
+
model?: string;
|
|
48
|
+
model_failover?: string;
|
|
49
|
+
tool_set?: string;
|
|
50
|
+
lightweight?: boolean;
|
|
51
|
+
hang_detector?: number;
|
|
52
|
+
tool_progress?: string;
|
|
53
|
+
reply_completion_guard?: boolean;
|
|
54
|
+
log_level?: string;
|
|
55
|
+
auto_pause_after?: number;
|
|
56
|
+
agent_mode?: string;
|
|
57
|
+
cross_instance_visibility?: string;
|
|
58
|
+
board_cards_at_once?: number;
|
|
59
|
+
resume_interrupted_work?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export type FillKey = keyof FillValues;
|
|
62
|
+
export type ParseResult = {
|
|
63
|
+
ok: true;
|
|
64
|
+
role?: string;
|
|
65
|
+
fill: FillValues;
|
|
66
|
+
skipped: Skipped[];
|
|
67
|
+
libraryUsed: boolean;
|
|
68
|
+
extraFailover: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
ok: false;
|
|
71
|
+
error: "empty" | "too_large" | "invalid_yaml" | "not_export" | "unsupported_version" | "wrong_kind";
|
|
72
|
+
};
|
|
73
|
+
/** Read a file: the allow-listed values that are fine, and for every other field why it was left out. */
|
|
74
|
+
export declare function parseAgentExport(input: unknown): ParseResult;
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AGEND-163: an agent's portable settings as one YAML file (`<role>.agend-agent.yaml`, `agend_export: 1`), and the way back.
|
|
3
|
+
*
|
|
4
|
+
* Allow-list only: a field is written, or read, because it is named here — never because it is not excluded. Accounts,
|
|
5
|
+
* keys, channel ids, folders, machine ids, permissions, commands and status emojis are not in the allow-list, so they
|
|
6
|
+
* are neither exported nor loaded; a file that carries them (a hand edit) has them skipped with the reason.
|
|
7
|
+
*
|
|
8
|
+
* Both directions are pure functions of their input: nothing here reads or writes fleet.yaml, so loading a file only
|
|
9
|
+
* fills the form — the person still presses Apply and goes through the usual confirmations.
|
|
10
|
+
*/
|
|
11
|
+
import { parseDocument, stringify } from "yaml";
|
|
12
|
+
import { systemPromptParts } from "./prompt-file-ref.js";
|
|
13
|
+
export const AGENT_EXPORT_VERSION = 1;
|
|
14
|
+
/**
|
|
15
|
+
* The most an agent's `systemPrompt` ("Agent instructions") may hold, in characters: the editor's limit
|
|
16
|
+
* (ui/agent-instructions-field.js INSTRUCTIONS_MAX_CHARS; tests/agent-export-163.test.ts keeps the two equal).
|
|
17
|
+
*/
|
|
18
|
+
export const AGENT_INSTRUCTIONS_MAX_CHARS = 24_000;
|
|
19
|
+
/** The largest file `parseAgentExport` reads, in characters (the instructions alone may take 24,000). */
|
|
20
|
+
export const AGENT_EXPORT_MAX_CHARS = 200_000;
|
|
21
|
+
const DESCRIPTION_MAX = 2_000;
|
|
22
|
+
const TAG_MAX_CHARS = 64;
|
|
23
|
+
const TAGS_MAX = 50;
|
|
24
|
+
const MODEL_MAX_CHARS = 200;
|
|
25
|
+
const ROLE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
26
|
+
const MODEL_RE = /^[A-Za-z0-9][A-Za-z0-9._:/@+[\]-]*$/;
|
|
27
|
+
/** What an export can carry, as the checkboxes of the export dialog. */
|
|
28
|
+
export const EXPORT_GROUPS = ["identity", "systemPrompt", "runtime", "behavior"];
|
|
29
|
+
const TOOL_SETS = ["worker", "coordinator", "standard", "minimal", "full"];
|
|
30
|
+
const TOOL_PROGRESS = ["off", "standard", "verbose"];
|
|
31
|
+
const LOG_LEVELS = ["trace", "debug", "info", "warn", "error"];
|
|
32
|
+
const AGENT_MODES = ["mcp", "cli"];
|
|
33
|
+
const VISIBILITY = ["full", "summary", "hidden"];
|
|
34
|
+
/** The fields a file may name that are on purpose not loaded, and why. A name not here and not allowed is "unknown". */
|
|
35
|
+
const EXCLUDED = {
|
|
36
|
+
display_name: "name",
|
|
37
|
+
working_directory: "machine", runtime: "machine", machine_id: "machine", worktree_source: "machine",
|
|
38
|
+
channel_id: "binding", topic_id: "binding", general_topic: "binding",
|
|
39
|
+
backend_options: "account", credential_profile: "account",
|
|
40
|
+
dashboard: "permission", office_access: "permission", office_pack_access: "permission", skipPermissions: "permission",
|
|
41
|
+
pre_task_command: "command",
|
|
42
|
+
status_emojis: "emoji",
|
|
43
|
+
quota_notice: "notice",
|
|
44
|
+
workflow: "fleetOnly", cost_guard: "fleetOnly", restart_policy: "fleetOnly", profile: "fleetOnly", mcp_proxy_reply: "permission",
|
|
45
|
+
};
|
|
46
|
+
const excludedReason = (key) => (key.startsWith("native_") ? "machine" : Object.hasOwn(EXCLUDED, key) ? EXCLUDED[key] : "unknown");
|
|
47
|
+
// ── The secret scan ────────────────────────────────────────────────────
|
|
48
|
+
const SECRET_PATTERNS = [
|
|
49
|
+
["private_key", /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
|
|
50
|
+
["api_key", /\b(?:sk-[A-Za-z0-9_-]{16,}|[sr]k_(?:live|test)_[A-Za-z0-9]{16,}|hf_[A-Za-z0-9]{30,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|glpat-[A-Za-z0-9_-]{16,}|xox[baprs]-[A-Za-z0-9-]{10,}|xapp-\d-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|ASIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,}|npm_[A-Za-z0-9]{30,}|ya29\.[A-Za-z0-9._-]{20,})/],
|
|
51
|
+
["bot_token", /\b\d{7,12}:[A-Za-z0-9_-]{30,}\b/],
|
|
52
|
+
// A Discord bot token has no label of its own: <base64 id>.<timestamp>.<hmac>. This fleet's own credential, so the shape most likely to be pasted.
|
|
53
|
+
["discord_token", /\b[MNO][A-Za-z0-9_-]{23,27}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27,}/],
|
|
54
|
+
["webhook", /\b(?:discord(?:app)?\.com\/api\/(?:v\d+\/)?webhooks\/\d+\/[A-Za-z0-9_-]{20,}|hooks\.slack\.com\/services\/T[A-Za-z0-9]+\/B[A-Za-z0-9]+\/[A-Za-z0-9]{16,})/i],
|
|
55
|
+
["jwt", /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],
|
|
56
|
+
["bearer", /\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{20,}/],
|
|
57
|
+
["assignment", /\b[\w.-]{0,40}(?:api[_-]?key|secret|token|passwd|password|credential)[\w.-]{0,20}["']?\s*[:=]\s*["']?(?![<{$]|your|xxx|changeme|example)[A-Za-z0-9/+_.~=-]{16,}/i],
|
|
58
|
+
["url_password", /\b[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:[^\s@/]{3,}@/i],
|
|
59
|
+
];
|
|
60
|
+
/** Where a text looks like it holds a secret: the field, the line and the kind — never the secret itself. */
|
|
61
|
+
export function scanForSecrets(field, text) {
|
|
62
|
+
const found = [];
|
|
63
|
+
text.split(/\r?\n/).forEach((line, i) => {
|
|
64
|
+
// A very long line is read in overlapping pieces, so the patterns' cost stays small however long a line is.
|
|
65
|
+
for (let at = 0; at === 0 || at < line.length; at += 3000) {
|
|
66
|
+
const piece = line.slice(at, at + 4000);
|
|
67
|
+
const hit = SECRET_PATTERNS.find(([, re]) => re.test(piece));
|
|
68
|
+
if (hit) {
|
|
69
|
+
found.push({ field, line: i + 1, kind: hit[0] });
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return found;
|
|
75
|
+
}
|
|
76
|
+
const own = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
77
|
+
/** Only what this agent itself sets (a field that follows the fleet's defaults is not written). */
|
|
78
|
+
export function buildAgentExport(role, inst, include) {
|
|
79
|
+
const want = new Set(include.filter((g) => EXPORT_GROUPS.includes(g)));
|
|
80
|
+
const agent = {};
|
|
81
|
+
const behavior = {};
|
|
82
|
+
const findings = [];
|
|
83
|
+
const omitted = [];
|
|
84
|
+
const text = (v) => (typeof v === "string" && v.trim() !== "" ? v : undefined);
|
|
85
|
+
if (want.has("identity")) {
|
|
86
|
+
const d = text(inst.description);
|
|
87
|
+
if (d) {
|
|
88
|
+
agent.description = d;
|
|
89
|
+
findings.push(...scanForSecrets("description", d));
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(inst.tags) && inst.tags.length) {
|
|
92
|
+
agent.tags = inst.tags.filter((x) => typeof x === "string");
|
|
93
|
+
findings.push(...scanForSecrets("tags", agent.tags.join("\n")));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (want.has("systemPrompt")) {
|
|
97
|
+
// Agent instructions: an inline text only. A `file:` part (prompt-file-ref.ts systemPromptParts, the rule the editor and the
|
|
98
|
+
// daemon both use) names a file on the exporter's computer, which means nothing elsewhere: the whole value is left out.
|
|
99
|
+
const s = text(inst.systemPrompt);
|
|
100
|
+
// A text longer than the editor's limit would be written but then refused on load (`tooLong`), so it is left out here and said so.
|
|
101
|
+
if (s && systemPromptParts(s).some((part) => part.startsWith("file:")))
|
|
102
|
+
omitted.push({ field: "systemPrompt", reason: "fileRef" });
|
|
103
|
+
else if (s && s.length > AGENT_INSTRUCTIONS_MAX_CHARS)
|
|
104
|
+
omitted.push({ field: "systemPrompt", reason: "tooLong" });
|
|
105
|
+
else if (s) {
|
|
106
|
+
agent.systemPrompt = s.replace(/\s+$/, "");
|
|
107
|
+
findings.push(...scanForSecrets("systemPrompt", s));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (want.has("runtime")) {
|
|
111
|
+
if (text(inst.backend))
|
|
112
|
+
agent.backend = inst.backend;
|
|
113
|
+
if (text(inst.model))
|
|
114
|
+
agent.model = inst.model;
|
|
115
|
+
if (Array.isArray(inst.model_failover) && inst.model_failover.length)
|
|
116
|
+
agent.model_failover = inst.model_failover;
|
|
117
|
+
if (text(inst.tool_set))
|
|
118
|
+
agent.tool_set = inst.tool_set;
|
|
119
|
+
if (typeof inst.lightweight === "boolean")
|
|
120
|
+
agent.lightweight = inst.lightweight;
|
|
121
|
+
}
|
|
122
|
+
if (want.has("behavior")) {
|
|
123
|
+
const hang = inst.hang_detector;
|
|
124
|
+
if (hang && typeof hang === "object" && typeof hang.timeout_minutes === "number")
|
|
125
|
+
behavior.hang_detector = { timeout_minutes: hang.timeout_minutes };
|
|
126
|
+
for (const key of ["tool_progress", "reply_completion_guard", "log_level", "auto_pause_after", "agent_mode", "cross_instance_visibility", "board_cards_at_once", "resume_interrupted_work"]) {
|
|
127
|
+
if (own(inst, key) && inst[key] !== undefined && inst[key] !== null)
|
|
128
|
+
behavior[key] = inst[key];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const empty = !Object.keys(agent).length && !Object.keys(behavior).length;
|
|
132
|
+
if (findings.length)
|
|
133
|
+
return { text: null, findings, groups: [...want], empty, omitted };
|
|
134
|
+
const doc = { agend_export: AGENT_EXPORT_VERSION, kind: "agent" };
|
|
135
|
+
if (ROLE_RE.test(role))
|
|
136
|
+
doc.role = role;
|
|
137
|
+
doc.agent = agent;
|
|
138
|
+
if (Object.keys(behavior).length)
|
|
139
|
+
doc.behavior = behavior;
|
|
140
|
+
doc.library = { skills: [], mcp: [] };
|
|
141
|
+
return { text: stringify(doc, { lineWidth: 0, blockQuote: "literal" }), findings: [], groups: [...want], empty, omitted };
|
|
142
|
+
}
|
|
143
|
+
const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
144
|
+
const str = (v, max) => (typeof v === "string" && v.length <= max ? v : null);
|
|
145
|
+
const num = (v, min, max = 100_000) => (typeof v === "number" && Number.isFinite(v) && v >= min && v <= max ? v : null);
|
|
146
|
+
/** Read a file: the allow-listed values that are fine, and for every other field why it was left out. */
|
|
147
|
+
export function parseAgentExport(input) {
|
|
148
|
+
if (typeof input !== "string" || input.trim() === "")
|
|
149
|
+
return { ok: false, error: "empty" };
|
|
150
|
+
if (input.length > AGENT_EXPORT_MAX_CHARS)
|
|
151
|
+
return { ok: false, error: "too_large" };
|
|
152
|
+
// YAML 1.2 core schema, no aliases (nothing to expand), duplicate keys refused: plain data in, nothing else.
|
|
153
|
+
const doc = parseDocument(input, { version: "1.2", schema: "core", uniqueKeys: true, prettyErrors: false });
|
|
154
|
+
if (doc.errors.length)
|
|
155
|
+
return { ok: false, error: "invalid_yaml" };
|
|
156
|
+
let root;
|
|
157
|
+
try {
|
|
158
|
+
root = doc.toJS({ maxAliasCount: 0 });
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return { ok: false, error: "invalid_yaml" };
|
|
162
|
+
}
|
|
163
|
+
if (!isObj(root) || !own(root, "agend_export"))
|
|
164
|
+
return { ok: false, error: "not_export" };
|
|
165
|
+
if (root.agend_export !== AGENT_EXPORT_VERSION)
|
|
166
|
+
return { ok: false, error: "unsupported_version" };
|
|
167
|
+
if (own(root, "kind") && root.kind !== "agent")
|
|
168
|
+
return { ok: false, error: "wrong_kind" };
|
|
169
|
+
const fill = {};
|
|
170
|
+
const skipped = [];
|
|
171
|
+
const skip = (path, reason) => { skipped.push({ path, reason }); };
|
|
172
|
+
let role;
|
|
173
|
+
let libraryUsed = false;
|
|
174
|
+
let extraFailover = false;
|
|
175
|
+
for (const key of Object.keys(root)) {
|
|
176
|
+
if (key === "agend_export" || key === "kind")
|
|
177
|
+
continue;
|
|
178
|
+
if (key === "role") {
|
|
179
|
+
if (typeof root.role === "string" && ROLE_RE.test(root.role))
|
|
180
|
+
role = root.role;
|
|
181
|
+
else
|
|
182
|
+
skip("role", "badValue");
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (key === "agent") {
|
|
186
|
+
if (isObj(root.agent))
|
|
187
|
+
readAgent(root.agent);
|
|
188
|
+
else
|
|
189
|
+
skip("agent", "badValue");
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (key === "behavior") {
|
|
193
|
+
if (isObj(root.behavior))
|
|
194
|
+
readBehavior(root.behavior);
|
|
195
|
+
else
|
|
196
|
+
skip("behavior", "badValue");
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (key === "library") {
|
|
200
|
+
readLibrary(root.library);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
skip(key, "unknown");
|
|
204
|
+
}
|
|
205
|
+
function readAgent(a) {
|
|
206
|
+
for (const key of Object.keys(a)) {
|
|
207
|
+
const path = `agent.${key}`, v = a[key];
|
|
208
|
+
switch (key) {
|
|
209
|
+
case "description": {
|
|
210
|
+
const s = str(v, DESCRIPTION_MAX);
|
|
211
|
+
if (s === null)
|
|
212
|
+
skip(path, typeof v === "string" ? "tooLong" : "badValue");
|
|
213
|
+
else if (s.trim())
|
|
214
|
+
fill.description = s;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case "tags": {
|
|
218
|
+
if (!Array.isArray(v) || v.length > TAGS_MAX || v.some((x) => typeof x !== "string" || !x.trim() || x.length > TAG_MAX_CHARS))
|
|
219
|
+
skip(path, "badValue");
|
|
220
|
+
else
|
|
221
|
+
fill.tags = [...new Set(v.map((x) => x.trim()))];
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case "systemPrompt": {
|
|
225
|
+
const s = str(v, AGENT_INSTRUCTIONS_MAX_CHARS);
|
|
226
|
+
if (s === null)
|
|
227
|
+
skip(path, typeof v === "string" ? "tooLong" : "badValue");
|
|
228
|
+
// A `file:` part would make the daemon read a path on the computer that loads this file: never filled from a file.
|
|
229
|
+
else if (systemPromptParts(s).some((part) => part.startsWith("file:")))
|
|
230
|
+
skip(path, "fileRef");
|
|
231
|
+
else if (s.trim())
|
|
232
|
+
fill.systemPrompt = s;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
case "backend":
|
|
236
|
+
skip(path, "runtimeSwitch");
|
|
237
|
+
break;
|
|
238
|
+
case "model": {
|
|
239
|
+
const s = str(v, MODEL_MAX_CHARS);
|
|
240
|
+
if (s === null || !MODEL_RE.test(s))
|
|
241
|
+
skip(path, "badValue");
|
|
242
|
+
else
|
|
243
|
+
fill.model = s;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
case "model_failover": {
|
|
247
|
+
if (!Array.isArray(v) || !v.length || v.some((x) => typeof x !== "string" || x.length > MODEL_MAX_CHARS || !MODEL_RE.test(x)))
|
|
248
|
+
skip(path, "badValue");
|
|
249
|
+
else {
|
|
250
|
+
fill.model_failover = v[0];
|
|
251
|
+
extraFailover = v.length > 1;
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
case "tool_set":
|
|
256
|
+
if (typeof v === "string" && TOOL_SETS.includes(v))
|
|
257
|
+
fill.tool_set = v;
|
|
258
|
+
else
|
|
259
|
+
skip(path, "badValue");
|
|
260
|
+
break;
|
|
261
|
+
case "lightweight":
|
|
262
|
+
if (typeof v === "boolean")
|
|
263
|
+
fill.lightweight = v;
|
|
264
|
+
else
|
|
265
|
+
skip(path, "badValue");
|
|
266
|
+
break;
|
|
267
|
+
default: skip(path, excludedReason(key));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function readBehavior(b) {
|
|
272
|
+
for (const key of Object.keys(b)) {
|
|
273
|
+
const path = `behavior.${key}`, v = b[key];
|
|
274
|
+
switch (key) {
|
|
275
|
+
case "hang_detector": {
|
|
276
|
+
const m = isObj(v) ? num(v.timeout_minutes, 1) : null;
|
|
277
|
+
if (m === null)
|
|
278
|
+
skip(path, "badValue");
|
|
279
|
+
else
|
|
280
|
+
fill.hang_detector = m;
|
|
281
|
+
if (isObj(v))
|
|
282
|
+
for (const k of Object.keys(v))
|
|
283
|
+
if (k !== "timeout_minutes")
|
|
284
|
+
skip(`${path}.${k}`, "unknown");
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case "tool_progress":
|
|
288
|
+
if (typeof v === "string" && TOOL_PROGRESS.includes(v))
|
|
289
|
+
fill.tool_progress = v;
|
|
290
|
+
else
|
|
291
|
+
skip(path, "badValue");
|
|
292
|
+
break;
|
|
293
|
+
case "reply_completion_guard":
|
|
294
|
+
if (typeof v === "boolean")
|
|
295
|
+
fill.reply_completion_guard = v;
|
|
296
|
+
else
|
|
297
|
+
skip(path, "badValue");
|
|
298
|
+
break;
|
|
299
|
+
case "log_level":
|
|
300
|
+
if (typeof v === "string" && LOG_LEVELS.includes(v))
|
|
301
|
+
fill.log_level = v;
|
|
302
|
+
else
|
|
303
|
+
skip(path, "badValue");
|
|
304
|
+
break;
|
|
305
|
+
case "auto_pause_after": {
|
|
306
|
+
const n = num(v, 0);
|
|
307
|
+
if (n === null)
|
|
308
|
+
skip(path, "badValue");
|
|
309
|
+
else
|
|
310
|
+
fill.auto_pause_after = n;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case "agent_mode":
|
|
314
|
+
if (typeof v === "string" && AGENT_MODES.includes(v))
|
|
315
|
+
fill.agent_mode = v;
|
|
316
|
+
else
|
|
317
|
+
skip(path, "badValue");
|
|
318
|
+
break;
|
|
319
|
+
case "cross_instance_visibility":
|
|
320
|
+
if (typeof v === "string" && VISIBILITY.includes(v))
|
|
321
|
+
fill.cross_instance_visibility = v;
|
|
322
|
+
else
|
|
323
|
+
skip(path, "badValue");
|
|
324
|
+
break;
|
|
325
|
+
case "board_cards_at_once":
|
|
326
|
+
if (typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= 1000)
|
|
327
|
+
fill.board_cards_at_once = v;
|
|
328
|
+
else
|
|
329
|
+
skip(path, "badValue");
|
|
330
|
+
break;
|
|
331
|
+
case "resume_interrupted_work":
|
|
332
|
+
if (typeof v === "boolean")
|
|
333
|
+
fill.resume_interrupted_work = v;
|
|
334
|
+
else
|
|
335
|
+
skip(path, "badValue");
|
|
336
|
+
break;
|
|
337
|
+
default: skip(path, excludedReason(key));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function readLibrary(lib) {
|
|
342
|
+
if (lib === undefined || lib === null)
|
|
343
|
+
return;
|
|
344
|
+
if (!isObj(lib)) {
|
|
345
|
+
skip("library", "badValue");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
for (const key of Object.keys(lib)) {
|
|
349
|
+
if (key !== "skills" && key !== "mcp") {
|
|
350
|
+
skip(`library.${key}`, "unknown");
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
const list = lib[key];
|
|
354
|
+
if (!Array.isArray(list))
|
|
355
|
+
skip(`library.${key}`, "badValue");
|
|
356
|
+
else if (list.length)
|
|
357
|
+
libraryUsed = true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return { ok: true, ...(role ? { role } : {}), fill, skipped, libraryUsed, extraFailover };
|
|
361
|
+
}
|
|
362
|
+
//# sourceMappingURL=agent-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-export.js","sourceRoot":"","sources":["../src/agent-export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;AACnD,yGAAyG;AACzG,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAE9C,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,OAAO,GAAG,mCAAmC,CAAC;AACpD,MAAM,QAAQ,GAAG,qCAAqC,CAAC;AAEvD,wEAAwE;AACxE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAG1F,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,SAA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AO;QAAC,CAAC;QACzD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;gBAAC,IAAI,CAAC,WAAW,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;gBAAC,SAAS;YAAC,CAAC;YACvF,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,WAAW,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;iBACxD,IAAI,IAAI,CAAC,MAAM;gBAAE,WAAW,GAAG,IAAI,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AAC5F,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isHiddenPath } from "./workspace-file-policy.js";
|
|
1
2
|
export declare const WORKSPACE_LIMITS: Readonly<{
|
|
2
3
|
fileBytes: number;
|
|
3
4
|
diffBytes: number;
|
|
@@ -8,8 +9,6 @@ export declare const WORKSPACE_LIMITS: Readonly<{
|
|
|
8
9
|
untrackedDiffFiles: 50;
|
|
9
10
|
gitTimeoutMs: 10000;
|
|
10
11
|
}>;
|
|
11
|
-
/** Whether a path (relative, `/`-separated) is hidden: any part a hidden directory, or its name a secret-looking file. */
|
|
12
|
-
export declare function isHiddenPath(rel: string): boolean;
|
|
13
12
|
export type WorkspaceRefusal = "not_found" | "not_a_directory" | "outside" | "hidden" | "symlink" | "not_a_file" | "invalid";
|
|
14
13
|
export declare class WorkspaceError extends Error {
|
|
15
14
|
readonly code: WorkspaceRefusal;
|
package/dist/agent-workspace.js
CHANGED
|
@@ -22,6 +22,8 @@ import { execFile } from "./child-process.js";
|
|
|
22
22
|
import { constants as fsConstants } from "node:fs";
|
|
23
23
|
import { lstat, open, readdir, realpath } from "node:fs/promises";
|
|
24
24
|
import { basename, extname, isAbsolute, join, resolve, sep } from "node:path";
|
|
25
|
+
import { isHiddenPath } from "./workspace-file-policy.js";
|
|
26
|
+
export { isHiddenPath } from "./workspace-file-policy.js";
|
|
25
27
|
export const WORKSPACE_LIMITS = Object.freeze({
|
|
26
28
|
fileBytes: 1024 * 1024,
|
|
27
29
|
diffBytes: 2 * 1024 * 1024,
|
|
@@ -34,31 +36,6 @@ export const WORKSPACE_LIMITS = Object.freeze({
|
|
|
34
36
|
});
|
|
35
37
|
const IMAGE_TYPES = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
|
|
36
38
|
const EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
37
|
-
/** Names whose contents never leave the machine through this view (fixed in P1, #3153). Lowercase compare. */
|
|
38
|
-
const HIDDEN_DIRS = new Set([".git", ".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".agend", ".claude", ".codex", ".kiro"]);
|
|
39
|
-
const HIDDEN_FILES = new Set([".npmrc", ".netrc", ".pypirc", ".git-credentials", ".pgpass", "credentials", "credentials.json", "auth.json", "secrets.json",
|
|
40
|
-
"id_rsa", "id_dsa", "id_ecdsa", "id_ed25519", "known_hosts", "authorized_keys", ".htpasswd",
|
|
41
|
-
// Fable on #3158: tool credentials and shell histories (a history holds whatever was typed, tokens included).
|
|
42
|
-
".envrc", ".vault-token", ".s3cfg", ".boto", "kubeconfig", ".kubeconfig", "terraform.tfstate", "terraform.tfstate.backup"]);
|
|
43
|
-
/** Whether a path (relative, `/`-separated) is hidden: any part a hidden directory, or its name a secret-looking file. */
|
|
44
|
-
export function isHiddenPath(rel) {
|
|
45
|
-
const parts = rel.split("/").filter(Boolean);
|
|
46
|
-
for (const p of parts.slice(0, -1))
|
|
47
|
-
if (HIDDEN_DIRS.has(p.toLowerCase()))
|
|
48
|
-
return true;
|
|
49
|
-
const name = (parts[parts.length - 1] ?? "").toLowerCase();
|
|
50
|
-
if (HIDDEN_DIRS.has(name) || HIDDEN_FILES.has(name))
|
|
51
|
-
return true;
|
|
52
|
-
if (/^\.env(?:$|[.-])/.test(name) || /^id_(?:rsa|dsa|ecdsa|ed25519)/.test(name))
|
|
53
|
-
return true;
|
|
54
|
-
if (/\.(?:pem|key|p12|p8|pfx|jks|keystore|kdbx|asc|gpg|ppk|token|env|tfvars|tfstate)$/.test(name) || /\.tfstate\./.test(name))
|
|
55
|
-
return true;
|
|
56
|
-
if (/^service[-_]?account.*\.json$/.test(name) || /^\.[a-z0-9]*_?history$/.test(name) || /^\.?kubeconfig(?:[.-]|$)/.test(name))
|
|
57
|
-
return true;
|
|
58
|
-
if (/(?:^|[._-])(?:secret|secrets|credential|credentials|password|passwords|private[-_]?key)(?:[._-]|$)/.test(name))
|
|
59
|
-
return true;
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
39
|
export class WorkspaceError extends Error {
|
|
63
40
|
code;
|
|
64
41
|
constructor(code) {
|
|
@@ -176,10 +153,13 @@ export async function workspaceChanges(ws) {
|
|
|
176
153
|
files.push({ path, status: untracked ? "untracked" : code.includes("D") ? "deleted" : code.includes("A") ? "added" : "modified",
|
|
177
154
|
adds: null, dels: null, binary: false, hidden: isHiddenPath(path), untracked });
|
|
178
155
|
}
|
|
179
|
-
|
|
180
|
-
|
|
156
|
+
const visibleTracked = files.filter((f) => !f.untracked && !f.hidden).map((f) => f.path);
|
|
157
|
+
// Hidden files get neither hunks nor content-derived line counts. Use the same literal path admission for both.
|
|
158
|
+
const numstat = visibleTracked.length
|
|
159
|
+
? await git(ws.root, ["diff", base, "--numstat", "-z", "--no-renames", "--no-ext-diff", "--no-textconv", "--", ...visibleTracked.map((p) => `:(literal)${p}`)], 4 * 1024 * 1024)
|
|
160
|
+
: null;
|
|
181
161
|
const counts = new Map();
|
|
182
|
-
for (const row of numstat
|
|
162
|
+
for (const row of (numstat?.out.toString("utf8") ?? "").split("\u0000").filter(Boolean)) {
|
|
183
163
|
const m = /^(-|\d+)\t(-|\d+)\t(.*)$/s.exec(row);
|
|
184
164
|
if (m)
|
|
185
165
|
counts.set(m[3], { adds: m[1] === "-" ? null : Number(m[1]), dels: m[2] === "-" ? null : Number(m[2]), binary: m[1] === "-" });
|
|
@@ -190,7 +170,6 @@ export async function workspaceChanges(ws) {
|
|
|
190
170
|
Object.assign(f, c);
|
|
191
171
|
}
|
|
192
172
|
// The patch: tracked changes (hidden paths excluded by pathspec), then untracked text files as additions.
|
|
193
|
-
const visibleTracked = files.filter((f) => !f.untracked && !f.hidden).map((f) => f.path);
|
|
194
173
|
// Each file's section is kept only within its own share and the whole budget: one huge file never starves the rest.
|
|
195
174
|
let patch = "", cutBytes = false;
|
|
196
175
|
const byPath = new Map(files.map((f) => [f.path, f]));
|