acryl 0.1.17 → 0.1.18

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/lib/bin.js CHANGED
@@ -70,6 +70,55 @@ function provideCmdline(ctx, host) {
70
70
  process.stdout, process.stderr;
71
71
  //#endregion
72
72
  //#region ../acryl-harness-runtime/lib/index.mjs
73
+ const shippedPresetsDir = join(resolve(dirname(fileURLToPath(import.meta.url)), "../.."), "deepseek-harness", "packages", "preset", "agent-presets", "presets");
74
+ const authorizationCapabilityPatches = [{
75
+ id: "system-prompt",
76
+ name: "@deepseek-ai/dsh-system-prompt",
77
+ config: { persona: "You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}." }
78
+ }, { insert: [
79
+ {
80
+ id: "agent-presets",
81
+ name: "@deepseek-ai/dsh-agent-presets",
82
+ config: {
83
+ default: "standard",
84
+ roots: existsSync(shippedPresetsDir) ? [{
85
+ path: shippedPresetsDir,
86
+ trust: "system"
87
+ }] : [],
88
+ includeShippedRoot: false,
89
+ includeUserRoot: true
90
+ }
91
+ },
92
+ {
93
+ id: "session-stats",
94
+ name: "@deepseek-ai/dsh-session-stats"
95
+ },
96
+ {
97
+ id: "authorization",
98
+ name: "@deepseek-ai/dsh-authorization"
99
+ }
100
+ ] }];
101
+ const NON_TUI_SHARED_ROW_IDS = /* @__PURE__ */ new Set(["authorization"]);
102
+ function selectNonTuiCapabilityPatches(patches) {
103
+ return patches.flatMap((patch) => {
104
+ if (!("insert" in patch) || !Array.isArray(patch.insert)) return [];
105
+ const insert = patch.insert.filter((row) => NON_TUI_SHARED_ROW_IDS.has(row.id));
106
+ return insert.length === 0 ? [] : [{ insert }];
107
+ });
108
+ }
109
+ const ACRYL_CODING_CAPABILITIES = [{
110
+ id: "authorization",
111
+ surfaces: [
112
+ "tui",
113
+ "web",
114
+ "desktop"
115
+ ],
116
+ loaderPatches: authorizationCapabilityPatches
117
+ }];
118
+ function createAcrylCodingCapabilityPatches(surfaces) {
119
+ const includeSharedCodingRows = surfaces.has("tui");
120
+ return structuredClone(ACRYL_CODING_CAPABILITIES.filter((capability) => capability.surfaces.some((surface) => surfaces.has(surface))).flatMap((capability) => includeSharedCodingRows ? capability.loaderPatches : selectNonTuiCapabilityPatches(capability.loaderPatches)));
121
+ }
73
122
  function contentText(content) {
74
123
  return content.filter((block) => {
75
124
  return block.type === "text" && typeof block.text === "string";
@@ -271,34 +320,6 @@ function createAcrylSessionBridge(ctx, options) {
271
320
  }
272
321
  const dshInstallAnchor = createRequire(import.meta.url).resolve("@deepseek-ai/dsh/package.json");
273
322
  const profileRoot = "[]\n";
274
- const shippedPresetsDir = join(resolve(dirname(fileURLToPath(import.meta.url)), "../.."), "deepseek-harness", "packages", "preset", "agent-presets", "presets");
275
- const ACRYL_RUNTIME_ROWS = [{
276
- id: "system-prompt",
277
- name: "@deepseek-ai/dsh-system-prompt",
278
- config: { persona: "You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}." }
279
- }, { insert: [
280
- {
281
- id: "agent-presets",
282
- name: "@deepseek-ai/dsh-agent-presets",
283
- config: {
284
- default: "standard",
285
- roots: existsSync(shippedPresetsDir) ? [{
286
- path: shippedPresetsDir,
287
- trust: "system"
288
- }] : [],
289
- includeShippedRoot: false,
290
- includeUserRoot: true
291
- }
292
- },
293
- {
294
- id: "session-stats",
295
- name: "@deepseek-ai/dsh-session-stats"
296
- },
297
- {
298
- id: "authorization",
299
- name: "@deepseek-ai/dsh-authorization"
300
- }
301
- ] }];
302
323
  /** Boot one normal pinned-Harness ACRYL profile in a single Cordis root. */
303
324
  async function bootAcrylHarnessProfile(options) {
304
325
  if (options.profile.trim() === "") throw new Error("ACRYL Harness profile must not be empty");
@@ -309,7 +330,7 @@ async function bootAcrylHarnessProfile(options) {
309
330
  writeFileSync(rootConfig, profileRoot);
310
331
  const patches = structuredClone([
311
332
  ...profile.layers.flatMap((layer) => layer.patches),
312
- ...ACRYL_RUNTIME_ROWS,
333
+ ...createAcrylCodingCapabilityPatches(/* @__PURE__ */ new Set(["tui"])),
313
334
  ...profile.patches
314
335
  ]);
315
336
  if (composeEntries([patches]).find((entry) => entry.id === "hmr")?.disabled !== true && !process.execArgv.includes("--expose-internals")) throw new Error("ACRYL profile enables Cordis HMR and must be launched with Node --expose-internals");
@@ -328,9 +349,9 @@ async function bootAcrylHarnessProfile(options) {
328
349
  /**
329
350
  * Boot the DSH browser surface (the `web` profile: `dsh-base` + `dsh-web-app`)
330
351
  * as one normal ACRYL runtime, so `pnpm acryl-web` serves the same DSH
331
- * HTTP/WebSocket seam the web surface always uses. The web profile already
332
- * composes the persona/agent rows ACRYL's terminal surface adds, so no
333
- * ACRYL_RUNTIME_ROWS are re-inserted (that would duplicate `system-prompt`).
352
+ * HTTP/WebSocket seam the web surface always uses. The shipped Web profile
353
+ * already owns its system prompt, agent-preset roster, and session stats, so
354
+ * the shared factory contributes only the missing authorization seam here.
334
355
  */
335
356
  async function bootAcrylWebProfile(options = {}) {
336
357
  const profileName = "web";
@@ -339,7 +360,11 @@ async function bootAcrylWebProfile(options = {}) {
339
360
  const profile = loadProfile("web", profileName, dshInstallAnchor);
340
361
  const rootConfig = join(profile.dir, "cordis.yml");
341
362
  writeFileSync(rootConfig, profileRoot);
342
- const patches = structuredClone([...profile.layers.flatMap((layer) => layer.patches), ...profile.patches]);
363
+ const patches = structuredClone([
364
+ ...profile.layers.flatMap((layer) => layer.patches),
365
+ ...createAcrylCodingCapabilityPatches(/* @__PURE__ */ new Set(["web"])),
366
+ ...profile.patches
367
+ ]);
343
368
  const cmdlineArgs = options.cmdlineArgs ?? [];
344
369
  const ctx = await boot("web", rootConfig, patches, (hostCtx) => {
345
370
  provideCmdline(hostCtx, {