@agimon-ai/po-codemode 0.0.1-alpha.0 → 0.0.1-alpha.10

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.
@@ -1,9 +1,14 @@
1
- import { n as createCodemodeRegistry, t as createCodemodeTools } from "../codemodeTools-CSYUxIeA.mjs";
1
+ import { n as createCodemodeRegistry, t as createCodemodeTools } from "../codemodeTools-Dl-IEjBr.mjs";
2
2
  import { PO_CODEMODE_CONTRACT, PO_CODEMODE_SERVICE } from "@agimon-ai/po-core/codemode";
3
+ import { Type } from "typebox";
3
4
  import { PO_SERVER_SCOPE_SERVICE, composeServerProviderOverrides, defineServerPlugin, packageResourcePath, readPackageResource, requirePoServerScope } from "@agimon-ai/po-core/serverPlugin";
4
5
  import { composeRootHooks, composeRootInjects, defineResource, defineRoot, defineServerTool, defineServiceContract } from "@agimon-ai/po-core/extensionFile";
5
- import { BACKGROUND_CONTEXT, PO_SESSION_FILES_SERVICE, getOrThrow, readPoFs, readPoIsolate } from "@agimon-ai/po-core/platform";
6
- import { PO_HELP_WHEN } from "@agimon-ai/po-core/help";
6
+ import { PO_CONFIG_SERVICE } from "@agimon-ai/po-config";
7
+ import { PO_BACKGROUND_WORK_SERVICE, readPoBackgroundWorkService } from "@agimon-ai/po-core/backgroundWork";
8
+ import { BACKGROUND_CONTEXT, PO_SESSION_FILES_SERVICE, PO_SHELL_SERVICE, getOrThrow, readPoFs, readPoIsolate, readPoNpm, withAbortSignal } from "@agimon-ai/po-core/platform";
9
+ import { readMajorModesConfig, readPackageConfigurations } from "@agimon-ai/po-config/majorModes";
10
+ import { Check } from "typebox/value";
11
+ import { Check as Check$1, Errors, Meta } from "typebox/schema";
7
12
  //#region src/services/codemodeScripts/index.ts
8
13
  const SESSION_FOLDER = "codemode";
9
14
  const SESSION_PREFIX = "session:";
@@ -113,9 +118,377 @@ var FileSystemCodemodeScriptsService = class {
113
118
  }
114
119
  };
115
120
  //#endregion
121
+ //#region src/schemas/packageConfig.ts
122
+ const CODEMODE_PACKAGE = "@agimon-ai/po-codemode";
123
+ const CodemodePackageConfigSchema = Type.Object({ llmModel: Type.Optional(Type.String({
124
+ pattern: "^[^/\\s]+/\\S+$",
125
+ maxLength: 256
126
+ })) }, { additionalProperties: false });
127
+ //#endregion
128
+ //#region src/services/llmConfig/index.ts
129
+ const PO_CODEMODE_LLM_CONFIG_SERVICE = "po/codemode-llm-config";
130
+ /** Session policy is loaded once per immutable Po config snapshot, including failed loads. */
131
+ var LlmConfigService = class {
132
+ io;
133
+ snapshot;
134
+ loads = /* @__PURE__ */ new WeakMap();
135
+ constructor(io) {
136
+ this.io = io;
137
+ }
138
+ bind(snapshot) {
139
+ this.snapshot = snapshot;
140
+ return () => {
141
+ if (this.snapshot === snapshot) this.snapshot = void 0;
142
+ };
143
+ }
144
+ current() {
145
+ if (!this.snapshot) return Promise.resolve({});
146
+ const snapshot = this.snapshot();
147
+ let load = this.loads.get(snapshot);
148
+ if (!load) {
149
+ load = this.load(snapshot);
150
+ this.loads.set(snapshot, load);
151
+ }
152
+ return load;
153
+ }
154
+ async load(snapshot) {
155
+ if (!snapshot.harness.root) return {};
156
+ const { environment, homeDirectory } = this.io;
157
+ const fs = this.io.fs();
158
+ if (!fs || !homeDirectory) throw new Error("Code mode LLM configuration requires host filesystem and home.");
159
+ const modes = await readMajorModesConfig(fs, snapshot.harness.root, BACKGROUND_CONTEXT, {
160
+ environment,
161
+ homeDirectory
162
+ });
163
+ const configurations = await readPackageConfigurations(fs, modes, [...snapshot.harness.layers], CODEMODE_PACKAGE, BACKGROUND_CONTEXT);
164
+ let merged = {};
165
+ for (const entry of configurations) {
166
+ if (!Check(CodemodePackageConfigSchema, entry.config)) throw new TypeError("Invalid code mode package configuration: llmModel must be provider/modelId.");
167
+ merged = {
168
+ ...merged,
169
+ ...entry.config
170
+ };
171
+ }
172
+ return merged;
173
+ }
174
+ };
175
+ //#endregion
176
+ //#region src/services/llmNamespace/index.ts
177
+ const MAX_INPUT_BYTES = 65536;
178
+ const MAX_SCHEMA_BYTES = 16384;
179
+ const MAX_OUTPUT_BYTES = 65536;
180
+ const MAX_CALLS = 8;
181
+ const MAX_CONCURRENT = 2;
182
+ const DEFAULT_TOKENS = 1024;
183
+ const MAX_TOKENS = 4096;
184
+ const RESULT_TOOL = "return_result";
185
+ const MODEL = /^[^/\s]+\/\S+$/u;
186
+ const META = Meta["http://json-schema.org/draft-07/schema#"];
187
+ const DECLARATIONS$1 = `interface LlmRequest {
188
+ prompt: string;
189
+ /** Explicit JSON input only, never the surrounding conversation. */
190
+ input?: unknown;
191
+ system?: string;
192
+ /** provider/modelId; overrides llmModel config and the live session model. */
193
+ model?: string;
194
+ /** Defaults to 1024, maximum 4096. */
195
+ maxTokens?: number;
196
+ }
197
+ declare const llm: {
198
+ /** One-shot text transform. At most 8 calls per exec, 2 concurrently. */
199
+ complete(request: LlmRequest): Promise<{ text: string; model: string }>;
200
+ /** Object-root JSON Schema (draft 7), local nonrecursive refs only. Invalid output rejects without retry. */
201
+ json(request: LlmRequest & { schema: Record<string, unknown> }): Promise<{ value: unknown; model: string }>;
202
+ };`;
203
+ function jsonText(value, limit, label) {
204
+ const json = JSON.stringify(value, (_key, item) => {
205
+ if (item === void 0 || typeof item === "function" || typeof item === "symbol" || typeof item === "bigint" || typeof item === "number" && !Number.isFinite(item)) throw new TypeError(`${label} must be JSON serializable.`);
206
+ return item;
207
+ });
208
+ if (json === void 0) throw new TypeError(`${label} must be JSON serializable.`);
209
+ if (new TextEncoder().encode(json).length > limit) throw new RangeError(`${label} exceeds ${limit} bytes.`);
210
+ return json;
211
+ }
212
+ function object(value) {
213
+ return value !== null && typeof value === "object" && !Array.isArray(value);
214
+ }
215
+ /** Reject unsupported references and recursive schemas before spending tokens or entering the validator. */
216
+ function checkedSchema(value) {
217
+ const schema = JSON.parse(jsonText(value, MAX_SCHEMA_BYTES, "LLM schema"));
218
+ if (!object(schema) || schema.type !== "object") throw new TypeError("LLM schema must have type: object.");
219
+ if (schema.$schema !== void 0 && schema.$schema !== "http://json-schema.org/draft-07/schema#") throw new TypeError("LLM schema supports JSON Schema draft 7 only.");
220
+ if (!Check$1(META, schema)) throw new TypeError("Invalid LLM JSON Schema.");
221
+ let expanded = 0;
222
+ const visit = (node, ancestors) => {
223
+ if (!object(node)) return;
224
+ if (++expanded > 1024) throw new TypeError("LLM schema exceeds 1024 expanded schema nodes.");
225
+ if (ancestors.length > 32 || ancestors.includes(node)) throw new TypeError("LLM schema references must be nonrecursive and at most 32 levels deep.");
226
+ const stack = [...ancestors, node];
227
+ if (node.$dynamicRef !== void 0 || node.$recursiveRef !== void 0 || node.$id !== void 0) throw new TypeError("LLM schema supports local $ref only, without $id.");
228
+ if (node.$ref !== void 0) {
229
+ if (typeof node.$ref !== "string" || !node.$ref.startsWith("#/")) throw new TypeError("LLM schema supports local JSON-pointer $ref only.");
230
+ let resolved = schema;
231
+ for (const segment of node.$ref.slice(2).split("/")) {
232
+ const key = segment.replace(/~1/gu, "/").replace(/~0/gu, "~");
233
+ resolved = resolved !== null && typeof resolved === "object" && Object.hasOwn(resolved, key) ? Reflect.get(resolved, key) : void 0;
234
+ }
235
+ if (!object(resolved) && typeof resolved !== "boolean") throw new TypeError("Unresolved LLM schema $ref.");
236
+ visit(resolved, stack);
237
+ }
238
+ for (const key of [
239
+ "properties",
240
+ "patternProperties",
241
+ "definitions",
242
+ "$defs",
243
+ "dependencies"
244
+ ]) if (object(node[key])) for (const child of Object.values(node[key])) visit(child, stack);
245
+ for (const key of [
246
+ "items",
247
+ "additionalItems",
248
+ "additionalProperties",
249
+ "contains",
250
+ "propertyNames",
251
+ "not",
252
+ "if",
253
+ "then",
254
+ "else",
255
+ "allOf",
256
+ "anyOf",
257
+ "oneOf"
258
+ ]) {
259
+ const child = node[key];
260
+ if (Array.isArray(child)) for (const item of child) visit(item, stack);
261
+ else visit(child, stack);
262
+ }
263
+ };
264
+ visit(schema, []);
265
+ return schema;
266
+ }
267
+ function request$1(value, structured) {
268
+ if (!object(value)) throw new TypeError("LLM request must be an object.");
269
+ const allowed = [
270
+ "prompt",
271
+ "input",
272
+ "system",
273
+ "model",
274
+ "maxTokens",
275
+ ...structured ? ["schema"] : []
276
+ ];
277
+ if (Object.keys(value).some((key) => !allowed.includes(key))) throw new TypeError("Unknown LLM request field.");
278
+ if (typeof value.prompt !== "string" || !value.prompt.trim()) throw new TypeError("LLM prompt must be nonempty text.");
279
+ if (value.system !== void 0 && typeof value.system !== "string") throw new TypeError("LLM system must be text.");
280
+ if (value.model !== void 0 && (typeof value.model !== "string" || !MODEL.test(value.model) || value.model.length > 256)) throw new TypeError("LLM model must be provider/modelId.");
281
+ if (value.maxTokens !== void 0 && (!Number.isInteger(value.maxTokens) || Number(value.maxTokens) < 1 || Number(value.maxTokens) > MAX_TOKENS)) throw new RangeError(`LLM maxTokens must be an integer from 1 to ${MAX_TOKENS}.`);
282
+ return {
283
+ prompt: value.prompt,
284
+ ...value.input === void 0 ? {} : { input: value.input },
285
+ ...value.system === void 0 ? {} : { system: value.system },
286
+ ...value.model === void 0 ? {} : { model: value.model },
287
+ ...value.maxTokens === void 0 ? {} : { maxTokens: value.maxTokens },
288
+ ...structured ? { schema: checkedSchema(value.schema) } : {}
289
+ };
290
+ }
291
+ /** Explicit data transforms over the host's guarded completions, never a tool-using agent. */
292
+ function createLlmNamespace(options) {
293
+ const { context } = options;
294
+ return {
295
+ name: "llm",
296
+ summary: "One-shot LLM text and schema-validated JSON transforms. Explicit input only, bounded calls, no tools or retries.",
297
+ declarations: DECLARATIONS$1,
298
+ portable: true,
299
+ bind(run) {
300
+ if (run.sessionId !== context.sessionId) throw new Error("LLM namespace belongs to another session.");
301
+ let disposed = false;
302
+ let calls = 0;
303
+ let active = 0;
304
+ run.onDispose(() => {
305
+ disposed = true;
306
+ });
307
+ const available = () => {
308
+ run.signal.throwIfAborted();
309
+ if (disposed) throw new Error("LLM namespace run is disposed.");
310
+ };
311
+ const call = async (input, structured) => {
312
+ available();
313
+ if (calls >= MAX_CALLS) throw new RangeError(`At most ${MAX_CALLS} LLM calls per exec.`);
314
+ if (active >= MAX_CONCURRENT) throw new RangeError(`At most ${MAX_CONCURRENT} concurrent LLM calls per exec.`);
315
+ const params = request$1(input, structured);
316
+ const userInput = params.input === void 0 ? params.prompt : `${params.prompt}\n\nInput (JSON):\n${jsonText(params.input, MAX_INPUT_BYTES, "LLM input")}`;
317
+ const systemPrompt = `${params.system ?? "Transform only the explicit input according to the request."}${structured ? "\nCall return_result exactly once with the result. Do not call other tools." : ""}`;
318
+ if (new TextEncoder().encode(systemPrompt + userInput).length > MAX_INPUT_BYTES) throw new RangeError("LLM prompt and input exceed 65536 bytes.");
319
+ active += 1;
320
+ const started = Date.now();
321
+ let model;
322
+ let tokens;
323
+ const record = (ok, error) => run.record?.({
324
+ name: structured ? "llm.json" : "llm.complete",
325
+ tool: "llm",
326
+ args: {
327
+ ...model ? { model } : {},
328
+ maxTokens: params.maxTokens ?? DEFAULT_TOKENS
329
+ },
330
+ ok,
331
+ ms: Date.now() - started,
332
+ ...error === void 0 ? {} : { error },
333
+ ...tokens === void 0 ? {} : { result: {
334
+ content: [],
335
+ details: { totalTokens: tokens }
336
+ } }
337
+ });
338
+ try {
339
+ const config = await options.config();
340
+ const current = params.model || config.llmModel ? void 0 : (await context.session.readModelSettings?.())?.model ?? context.model;
341
+ model = params.model ?? config.llmModel ?? (current ? `${current.provider}/${current.id}` : void 0);
342
+ available();
343
+ if (!model || !context.textCompletion?.available(model)) throw new Error(`LLM model is unavailable${model ? `: ${model}` : ""}.`);
344
+ if (structured ? !context.toolCompletion : !context.textCompletion) throw new Error("LLM completion is unavailable on this host.");
345
+ if (calls >= MAX_CALLS) throw new RangeError(`At most ${MAX_CALLS} LLM calls per exec.`);
346
+ calls += 1;
347
+ const completion = {
348
+ systemPrompt,
349
+ input: userInput,
350
+ maxTokens: params.maxTokens ?? DEFAULT_TOKENS,
351
+ signal: run.signal,
352
+ recordUsage: true
353
+ };
354
+ if (!structured) {
355
+ const text = await context.textCompletion.complete(model, completion);
356
+ available();
357
+ jsonText(text, MAX_OUTPUT_BYTES, "LLM output");
358
+ record(true);
359
+ return {
360
+ text,
361
+ model
362
+ };
363
+ }
364
+ const schema = params.schema;
365
+ const response = await context.toolCompletion.complete(model, {
366
+ ...completion,
367
+ tools: [{
368
+ name: RESULT_TOOL,
369
+ description: "Return the requested structured result.",
370
+ parameters: schema
371
+ }]
372
+ });
373
+ tokens = response.usage.totalTokens;
374
+ available();
375
+ if (response.toolCalls.length !== 1 || response.toolCalls[0]?.name !== RESULT_TOOL) throw new Error("LLM must return exactly one return_result call.");
376
+ const value = JSON.parse(jsonText(response.toolCalls[0].arguments, MAX_OUTPUT_BYTES, "LLM output"));
377
+ if (!Check$1(schema, value)) {
378
+ const [, errors] = Errors(schema, value);
379
+ throw new TypeError(`LLM result failed schema validation: ${errors[0]?.message ?? "invalid result"}`);
380
+ }
381
+ record(true);
382
+ return {
383
+ value,
384
+ model
385
+ };
386
+ } catch (error) {
387
+ record(false, error instanceof Error ? error.message : String(error));
388
+ throw error;
389
+ } finally {
390
+ active -= 1;
391
+ }
392
+ };
393
+ return {
394
+ complete: (input) => call(input, false),
395
+ json: (input) => call(input, true)
396
+ };
397
+ }
398
+ };
399
+ }
400
+ //#endregion
401
+ //#region src/services/shellNamespace/index.ts
402
+ const DEFAULT_TIMEOUT_MS = 1e4;
403
+ const MAX_TIMEOUT_MS = 12e4;
404
+ const MAX_COMMAND_CHARS = 65536;
405
+ const MAX_OUTPUT_CHARS = 32768;
406
+ const TRUNCATED = "\n[truncated]";
407
+ const DECLARATIONS = `declare const shell: {
408
+ /** Short foreground Bash command in the session cwd/environment. Nonzero exits are returned; cancellation and timeout reject. */
409
+ bash(input: { command: string; timeoutMs?: number }): Promise<{ stdout: string; stderr: string; exitCode: number }>;
410
+ };`;
411
+ function request(input) {
412
+ if (input === null || typeof input !== "object" || Array.isArray(input)) throw new TypeError("shell.bash expects an object.");
413
+ const value = input;
414
+ if (Object.keys(value).some((key) => key !== "command" && key !== "timeoutMs")) throw new TypeError("shell.bash accepts only command and timeoutMs.");
415
+ if (typeof value.command !== "string" || !value.command.trim() || value.command.length > MAX_COMMAND_CHARS) throw new TypeError(`shell.bash command must be nonempty text of at most ${MAX_COMMAND_CHARS} characters.`);
416
+ if (value.timeoutMs !== void 0 && (!Number.isInteger(value.timeoutMs) || Number(value.timeoutMs) < 1 || Number(value.timeoutMs) > MAX_TIMEOUT_MS)) throw new RangeError(`shell.bash timeoutMs must be an integer from 1 to ${MAX_TIMEOUT_MS}.`);
417
+ return {
418
+ command: value.command,
419
+ timeoutMs: value.timeoutMs
420
+ };
421
+ }
422
+ /** Deadline-bound commands for post-processing, separate from Runner's supervised processes. */
423
+ function createShellNamespace(options) {
424
+ return {
425
+ name: "shell",
426
+ summary: "Run short foreground Bash commands with bounded stdout/stderr and a deadline. No background or interactive mode.",
427
+ declarations: DECLARATIONS,
428
+ portable: true,
429
+ bind(run) {
430
+ if (run.sessionId !== options.context.sessionId) throw new Error("Shell namespace belongs to another session.");
431
+ const disposal = new AbortController();
432
+ const lifetime = AbortSignal.any([run.signal, disposal.signal]);
433
+ run.onDispose(() => disposal.abort(/* @__PURE__ */ new Error("Shell namespace run is disposed.")));
434
+ return { async bash(input) {
435
+ lifetime.throwIfAborted();
436
+ const params = request(input);
437
+ const shell = options.shell();
438
+ if (!shell) throw new Error("Shell commands are not available on this host.");
439
+ const timeoutMs = params.timeoutMs ?? DEFAULT_TIMEOUT_MS;
440
+ const signal = AbortSignal.any([lifetime, AbortSignal.timeout(timeoutMs)]);
441
+ const output = {
442
+ stdout: "",
443
+ stderr: ""
444
+ };
445
+ const truncated = {
446
+ stdout: false,
447
+ stderr: false
448
+ };
449
+ const started = Date.now();
450
+ let ok = false;
451
+ let failure;
452
+ try {
453
+ const result = await shell.exec(params.command, {
454
+ cwd: options.context.cwd,
455
+ env: Object.fromEntries(Object.entries(options.context.environment).filter((entry) => entry[1] !== void 0)),
456
+ inheritEnv: false,
457
+ onOutput: (text, _context, { stream }) => {
458
+ const remaining = MAX_OUTPUT_CHARS - output[stream].length;
459
+ output[stream] += text.slice(0, remaining);
460
+ if (text.length > remaining) truncated[stream] = true;
461
+ }
462
+ }, withAbortSignal(signal, BACKGROUND_CONTEXT));
463
+ signal.throwIfAborted();
464
+ const { exitCode } = getOrThrow(result);
465
+ ok = exitCode === 0;
466
+ return {
467
+ stdout: output.stdout + (truncated.stdout ? TRUNCATED : ""),
468
+ stderr: output.stderr + (truncated.stderr ? TRUNCATED : ""),
469
+ exitCode
470
+ };
471
+ } catch (error) {
472
+ failure = error instanceof Error ? error.message : String(error);
473
+ throw error;
474
+ } finally {
475
+ run.record?.({
476
+ name: "shell.bash",
477
+ tool: "shell",
478
+ args: { timeoutMs },
479
+ ok,
480
+ ms: Date.now() - started,
481
+ ...failure === void 0 ? {} : { error: failure }
482
+ });
483
+ }
484
+ } };
485
+ }
486
+ };
487
+ }
488
+ //#endregion
116
489
  //#region src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts
117
490
  /** One registry per session: contributors register into it, `discover` and `exec` read it. */
118
- function createCodemodeSession({ context }) {
491
+ function createCodemodeSession({ context, agent, host, signal }) {
119
492
  const registry = createCodemodeRegistry();
120
493
  context.inject([PO_SERVER_SCOPE_SERVICE], (scoped) => requirePoServerScope(scoped).provide(PO_CODEMODE_CONTRACT, registry));
121
494
  let temporaryDirectory;
@@ -130,14 +503,61 @@ function createCodemodeSession({ context }) {
130
503
  fs: () => readPoFs(context),
131
504
  temporaryDirectory: () => temporaryDirectory
132
505
  });
133
- return { value: {
506
+ const execution = agent?.context;
507
+ const config = execution ? new LlmConfigService({
508
+ fs: () => readPoFs(context),
509
+ environment: execution.environment,
510
+ homeDirectory: host.context.homeDirectory
511
+ }) : void 0;
512
+ let disposeNamespaces;
513
+ if (execution && config) {
514
+ context.inject([PO_CONFIG_SERVICE], (scoped) => {
515
+ const service = scoped.get(PO_CONFIG_SERVICE);
516
+ return service ? config.bind(() => service.getSnapshot()) : void 0;
517
+ });
518
+ const registration = registry.register("@agimon-ai/po-codemode", createLlmNamespace({
519
+ context: execution,
520
+ config: () => config.current()
521
+ }));
522
+ const shellRegistration = registry.register("@agimon-ai/po-codemode", createShellNamespace({
523
+ context: execution,
524
+ shell: () => context.get(PO_SHELL_SERVICE)
525
+ }));
526
+ disposeNamespaces = () => {
527
+ registration.dispose();
528
+ shellRegistration.dispose();
529
+ };
530
+ }
531
+ let background;
532
+ const tools = createCodemodeTools({
134
533
  registry,
135
- ...createCodemodeTools({
534
+ isolate: () => readPoIsolate(context),
535
+ npm: () => readPoNpm(context),
536
+ scripts,
537
+ signal,
538
+ onBackgroundChange: () => background?.update()
539
+ });
540
+ context.inject([PO_BACKGROUND_WORK_SERVICE], (scoped) => {
541
+ const registration = readPoBackgroundWorkService(scoped)?.register(tools.backgroundWork);
542
+ background = registration;
543
+ return () => {
544
+ if (background === registration) background = void 0;
545
+ registration?.dispose();
546
+ };
547
+ });
548
+ return {
549
+ value: {
136
550
  registry,
137
- isolate: () => readPoIsolate(context),
138
- scripts
139
- })
140
- } };
551
+ ...tools
552
+ },
553
+ services: [(scoped) => {
554
+ if (config) scoped.provide(PO_CODEMODE_LLM_CONFIG_SERVICE, config);
555
+ }],
556
+ onDispose: async () => {
557
+ await tools.dispose();
558
+ disposeNamespaces?.();
559
+ }
560
+ };
141
561
  }
142
562
  const root = defineRoot(createCodemodeSession);
143
563
  //#endregion
@@ -147,19 +567,45 @@ var root_server_default = defineRoot(root);
147
567
  //#region src/extensions/workspaces/sessions/(backend)/contract/codemode.server.ts
148
568
  var codemode_server_default = defineServiceContract(PO_CODEMODE_SERVICE, { scope: "session" });
149
569
  //#endregion
150
- //#region src/extensions/workspaces/sessions/(backend)/resource/po-use-codemode.server.ts
151
- var po_use_codemode_server_default = defineResource({
152
- name: "po-use-codemode",
153
- description: "Use @agimon-ai/po-codemode: Code mode for Po sessions: discover and exec over namespaces other packages contribute",
154
- when: PO_HELP_WHEN,
570
+ //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-llm.server.ts
571
+ var codemode_how_to_llm_server_default = defineResource({
572
+ name: "codemode-how-to-llm",
573
+ description: "Have a model classify, extract or summarize data inside a script, with JSON output checked against a schema. Use when a script step needs judgement over many items or messy text; answer directly when no script needs the result.",
574
+ pinned: true,
575
+ kind: "skill",
576
+ path: packageResourcePath(import.meta.url, "src/prompts/codemode-how-to-llm/SKILL.md"),
577
+ read: () => readPackageResource(import.meta.url, "src/prompts/codemode-how-to-llm/SKILL.md")
578
+ });
579
+ //#endregion
580
+ //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-shell.server.ts
581
+ var codemode_how_to_shell_server_default = defineResource({
582
+ name: "codemode-how-to-shell",
583
+ description: "Run a quick command inside a script and work with its output as data. Use when command output needs parsing or filtering in code; use the bash tool for long-running, interactive or visible commands.",
584
+ pinned: true,
585
+ kind: "skill",
586
+ path: packageResourcePath(import.meta.url, "src/prompts/codemode-how-to-shell/SKILL.md"),
587
+ read: () => readPackageResource(import.meta.url, "src/prompts/codemode-how-to-shell/SKILL.md")
588
+ });
589
+ //#endregion
590
+ //#region src/extensions/workspaces/sessions/(backend)/resource/how-to-codemode.server.ts
591
+ var how_to_codemode_server_default = defineResource({
592
+ name: "how-to-codemode",
593
+ description: "Do multi-step work in one call: script loops, filtering and chained calls across live namespaces in exec instead of many separate tool calls. Use when a task repeats a tool, combines namespaces, or needs a long-running workflow.",
594
+ pinned: true,
155
595
  kind: "skill",
156
- path: packageResourcePath(import.meta.url, "src/prompts/po-use-codemode/SKILL.md"),
157
- read: () => readPackageResource(import.meta.url, "src/prompts/po-use-codemode/SKILL.md")
596
+ path: packageResourcePath(import.meta.url, "src/prompts/how-to-codemode/SKILL.md"),
597
+ read: () => readPackageResource(import.meta.url, "src/prompts/how-to-codemode/SKILL.md")
158
598
  });
159
599
  //#endregion
160
600
  //#region src/extensions/workspaces/sessions/(backend)/tool/discover.server.ts
161
601
  var discover_server_default = defineServerTool((context) => context.root.discover);
162
602
  //#endregion
603
+ //#region src/extensions/workspaces/sessions/(backend)/tool/exec_background.server.ts
604
+ var exec_background_server_default = defineServerTool((context) => context.root.execBackground);
605
+ //#endregion
606
+ //#region src/extensions/workspaces/sessions/(backend)/tool/exec_cancel.server.ts
607
+ var exec_cancel_server_default = defineServerTool((context) => context.root.execCancel);
608
+ //#endregion
163
609
  //#region src/extensions/workspaces/sessions/(backend)/tool/exec.server.ts
164
610
  var exec_server_default = defineServerTool((context) => context.root.exec);
165
611
  //#endregion
@@ -183,10 +629,19 @@ const serverPlugin = defineServerPlugin({
183
629
  return {
184
630
  ...composeRootHooks(scopeSession),
185
631
  get resources() {
186
- return [at(po_use_codemode_server_default, contextSession)];
632
+ return [
633
+ at(codemode_how_to_llm_server_default, contextSession),
634
+ at(codemode_how_to_shell_server_default, contextSession),
635
+ at(how_to_codemode_server_default, contextSession)
636
+ ];
187
637
  },
188
638
  get tools() {
189
- return [via({ name: "discover" }, at(discover_server_default, contextSession)), via({ name: "exec" }, at(exec_server_default, contextSession))];
639
+ return [
640
+ via({ name: "discover" }, at(discover_server_default, contextSession)),
641
+ via({ name: "exec_background" }, at(exec_background_server_default, contextSession)),
642
+ via({ name: "exec_cancel" }, at(exec_cancel_server_default, contextSession)),
643
+ via({ name: "exec" }, at(exec_server_default, contextSession))
644
+ ];
190
645
  },
191
646
  services: [...scopeSession.services ?? []],
192
647
  get activities() {