@agimon-ai/po-codemode 0.0.1-alpha.1 → 0.0.1-alpha.11

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